Skip to content

Commit 77111bf

Browse files
committed
mc
1 parent 2f94633 commit 77111bf

File tree

10 files changed

+38
-44
lines changed

10 files changed

+38
-44
lines changed

src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private void drawClosing(int updateCounter, CallbackInfo ci) {
104104
int q = m * 9;
105105
String string = chatLine.getChatComponent().getFormattedText();
106106
GlStateManager.enableBlend();
107-
ModCompatHooks.redirectDrawString(string, chatting$config().getFade() ? 0 : 3, -q - 8, 16777215 + (chatting$getOpacity(0, chatLine) << 24), chatLine, false);
107+
ModCompatHooks.redirectDrawString(string, chatting$config().getFade() ? 0 : 3, -q - 8, 16777215 + (chatting$getOpacity(chatting$updateCounter, chatLine) << 24), chatLine, false);
108108
GlStateManager.disableAlpha();
109109
GlStateManager.disableBlend();
110110
}

src/main/kotlin/org/polyfrost/chatting/Chatting.kt

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
package org.polyfrost.chatting
22

3-
import cc.polyfrost.oneconfig.events.EventManager
4-
import cc.polyfrost.oneconfig.events.event.InitializationEvent
5-
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe
63
import cc.polyfrost.oneconfig.libs.universal.UDesktop
7-
import cc.polyfrost.oneconfig.libs.universal.UMinecraft
84
import cc.polyfrost.oneconfig.utils.Notifications
95
import cc.polyfrost.oneconfig.utils.commands.CommandManager
106
import cc.polyfrost.oneconfig.utils.dsl.browseLink
117
import cc.polyfrost.oneconfig.utils.dsl.mc
12-
import cc.polyfrost.oneconfig.utils.dsl.runAsync
13-
import net.minecraft.client.Minecraft
148
import net.minecraft.client.gui.*
159
import net.minecraft.client.renderer.GlStateManager
1610
import net.minecraft.client.renderer.OpenGlHelper
@@ -70,7 +64,7 @@ object Chatting {
7064

7165
private val fileFormatter: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd_HH.mm.ss'.png'")
7266

73-
val oldModDir = File(File(Minecraft.getMinecraft().mcDataDir, "W-OVERFLOW"), NAME)
67+
val oldModDir = File(File(mc.mcDataDir, "W-OVERFLOW"), NAME)
7468

7569
@Mod.EventHandler
7670
fun onInitialization(event: FMLInitializationEvent) {
@@ -158,7 +152,7 @@ object Chatting {
158152

159153
@SubscribeEvent
160154
fun onTickEvent(event: TickEvent.ClientTickEvent) {
161-
if (event.phase == TickEvent.Phase.START && Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null && (Minecraft.getMinecraft().currentScreen == null || Minecraft.getMinecraft().currentScreen is GuiChat)) {
155+
if (event.phase == TickEvent.Phase.START && mc.theWorld != null && mc.thePlayer != null && (mc.currentScreen == null || mc.currentScreen is GuiChat)) {
162156
if (doTheThing) {
163157
screenshotChat()
164158
doTheThing = false
@@ -205,15 +199,15 @@ object Chatting {
205199
}
206200

207201
fun screenshotLine(line: ChatLine): BufferedImage? {
208-
val hud = Minecraft.getMinecraft().ingameGUI
202+
val hud = mc.ingameGUI
209203
val chat = hud.chatGUI
210204
val i = MathHelper.floor_float(getChatWidth() / chat.chatScale)
211205
return screenshot(
212206
hashMapOf<ChatLine, String>().also {
213207
GuiUtilRenderComponents.splitText(
214208
line.chatComponent,
215209
i,
216-
Minecraft.getMinecraft().fontRendererObj,
210+
mc.fontRendererObj,
217211
false,
218212
false
219213
).map { it.formattedText }.reversed().forEach { string ->
@@ -228,7 +222,7 @@ object Chatting {
228222
}
229223

230224
fun screenshotChat(scrollPos: Int) {
231-
val hud = Minecraft.getMinecraft().ingameGUI
225+
val hud = mc.ingameGUI
232226
val chat = hud.chatGUI
233227
val chatLines = LinkedHashMap<ChatLine, String>()
234228
ChatSearchingManager.filterMessages(
@@ -237,7 +231,7 @@ object Chatting {
237231
)?.let { drawnLines ->
238232
val chatHeight =
239233
if (ChattingConfig.chatWindow.customChatHeight) getChatHeight(true) / 9 else GuiNewChat.calculateChatboxHeight(
240-
Minecraft.getMinecraft().gameSettings.chatHeightFocused / 9
234+
mc.gameSettings.chatHeightFocused / 9
241235
)
242236
for (i in scrollPos until drawnLines.size.coerceAtMost(scrollPos + chatHeight)) {
243237
chatLines[drawnLines[i]] = drawnLines[i].chatComponent.formattedText
@@ -263,18 +257,18 @@ object Chatting {
263257
val fr: FontRenderer = ModCompatHooks.fontRenderer
264258
val width = messages.maxOf { fr.getStringWidth(it.value) + (if (ChattingConfig.showChatHeads && ((it.key as ChatLineHook).`chatting$hasDetected`() || ChattingConfig.offsetNonPlayerMessages)) 10 else 0) } + 4
265259
val fb: Framebuffer = createBindFramebuffer(width * 2, (messages.size * 9) * 2)
266-
val file = File(Minecraft.getMinecraft().mcDataDir, "screenshots/chat/" + fileFormatter.format(Date()))
260+
val file = File(mc.mcDataDir, "screenshots/chat/" + fileFormatter.format(Date()))
267261

268262
GlStateManager.scale(2f, 2f, 1f)
269-
val scale = Minecraft.getMinecraft().gameSettings.chatScale
263+
val scale = mc.gameSettings.chatScale
270264
GlStateManager.scale(scale, scale, 1f)
271265
messages.entries.forEachIndexed { i: Int, entry: MutableMap.MutableEntry<ChatLine, String> ->
272266
ModCompatHooks.redirectDrawString(entry.value, 0f, (messages.size - 1 - i) * 9f, 0xffffff, entry.key, true)
273267
}
274268

275269
val image = fb.screenshot(file)
276-
Minecraft.getMinecraft().entityRenderer.setupOverlayRendering()
277-
Minecraft.getMinecraft().framebuffer.bindFramebuffer(true)
270+
mc.entityRenderer.setupOverlayRendering()
271+
mc.framebuffer.bindFramebuffer(true)
278272
Notifications.INSTANCE.send(
279273
"Chatting",
280274
"Chat screenshotted successfully." + (if (ChattingConfig.copyMode != 1) "\nClick to open." else ""),

src/main/kotlin/org/polyfrost/chatting/chat/ChatTab.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.polyfrost.chatting.chat
22

33
import cc.polyfrost.oneconfig.libs.universal.ChatColor
4+
import cc.polyfrost.oneconfig.utils.dsl.mc
45
import org.polyfrost.chatting.gui.components.TabButton
56
import com.google.gson.annotations.SerializedName
67
import net.minecraft.client.Minecraft
@@ -40,7 +41,7 @@ data class ChatTab(
4041
fun initialize() {
4142
compiledRegex = ChatRegexes(uncompiledRegex)
4243
compiledIgnoreRegex = ChatRegexes(uncompiledIgnoreRegex)
43-
val width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(name)
44+
val width = mc.fontRendererObj.getStringWidth(name)
4445
button = TabButton(653452, run {
4546
val returnValue = x - 2
4647
x += 6 + width

src/main/kotlin/org/polyfrost/chatting/chat/ChatTabs.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.polyfrost.chatting.chat
22

33
import cc.polyfrost.oneconfig.config.core.ConfigUtils
4+
import cc.polyfrost.oneconfig.utils.dsl.mc
45
import org.polyfrost.chatting.Chatting
56
import org.polyfrost.chatting.gui.components.TabButton
67
import com.google.gson.GsonBuilder
@@ -19,8 +20,8 @@ object ChatTabs {
1920
var currentTabs: ArrayList<ChatTab> = object : ArrayList<ChatTab>() {
2021
override fun add(element: ChatTab): Boolean {
2122
val returnValue = super.add(element)
22-
if (Minecraft.getMinecraft().theWorld != null && returnValue) {
23-
Minecraft.getMinecraft().ingameGUI.chatGUI.refreshChat()
23+
if (mc.theWorld != null && returnValue) {
24+
mc.ingameGUI.chatGUI.refreshChat()
2425
}
2526
return returnValue
2627
}

src/main/kotlin/org/polyfrost/chatting/config/ChattingConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import cc.polyfrost.oneconfig.config.data.Mod
99
import cc.polyfrost.oneconfig.config.data.ModType
1010
import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator
1111
import cc.polyfrost.oneconfig.libs.universal.UKeyboard
12-
import cc.polyfrost.oneconfig.libs.universal.UMinecraft
12+
import cc.polyfrost.oneconfig.utils.dsl.mc
1313
import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils
1414
import org.polyfrost.chatting.Chatting
1515
import org.polyfrost.chatting.chat.*
@@ -399,7 +399,7 @@ object ChattingConfig : Config(
399399
"chatTabs"
400400
).forEach {
401401
addListener(it) {
402-
UMinecraft.getMinecraft().currentScreen?.let { screen ->
402+
mc.currentScreen?.let { screen ->
403403
if (screen is GuiChatHook) {
404404
screen.`chatting$triggerButtonReset`()
405405
}

src/main/kotlin/org/polyfrost/chatting/gui/components/CleanButton.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ open class CleanButton(
9595
((xPosition + width / 2) - (fontrenderer.getStringWidth(displayString) / 2)).toFloat(),
9696
(yPosition + (height - 8) / 2).toFloat(),
9797
j,
98-
(Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).`chatting$getTextOpacity`()
98+
(mc.ingameGUI.chatGUI as GuiNewChatHook).`chatting$getTextOpacity`()
9999
)
100100
}
101101
}

src/main/kotlin/org/polyfrost/chatting/gui/components/ClearButton.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cc.polyfrost.oneconfig.libs.universal.ChatColor
44
import cc.polyfrost.oneconfig.libs.universal.UChat
55
import cc.polyfrost.oneconfig.libs.universal.UResolution
66
import cc.polyfrost.oneconfig.utils.Multithreading
7+
import cc.polyfrost.oneconfig.utils.dsl.mc
78
import net.minecraft.client.Minecraft
89
import net.minecraft.client.gui.Gui
910
import net.minecraft.client.renderer.GlStateManager
@@ -23,7 +24,7 @@ class ClearButton :
2324
++times
2425
if (times > 1) {
2526
times = 0
26-
Minecraft.getMinecraft().ingameGUI.chatGUI.clearChatMessages()
27+
mc.ingameGUI.chatGUI.clearChatMessages()
2728
} else {
2829
UChat.chat(ChatColor.RED + ChatColor.BOLD.toString() + "Click again to clear the chat!")
2930
Multithreading.runAsync {

src/main/kotlin/org/polyfrost/chatting/gui/components/ScreenshotButton.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.polyfrost.chatting.gui.components
22

33
import cc.polyfrost.oneconfig.libs.universal.UResolution
44
import cc.polyfrost.oneconfig.libs.universal.UScreen
5+
import cc.polyfrost.oneconfig.utils.dsl.mc
56
import org.polyfrost.chatting.Chatting
67
import org.polyfrost.chatting.mixin.GuiNewChatAccessor
78
import net.minecraft.client.Minecraft
@@ -18,9 +19,8 @@ class ScreenshotButton :
1819
{ RenderType.NONE }) {
1920

2021
override fun onMousePress() {
21-
val chat = Minecraft.getMinecraft().ingameGUI.chatGUI
2222
if (UScreen.currentScreen is GuiChat) {
23-
Chatting.screenshotChat((chat as GuiNewChatAccessor).scrollPos)
23+
Chatting.screenshotChat((mc.ingameGUI.chatGUI as GuiNewChatAccessor).scrollPos)
2424
}
2525
}
2626

src/main/kotlin/org/polyfrost/chatting/gui/components/SearchButton.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.polyfrost.chatting.gui.components
22

33
import cc.polyfrost.oneconfig.config.core.OneColor
44
import cc.polyfrost.oneconfig.libs.universal.UResolution
5+
import cc.polyfrost.oneconfig.utils.dsl.mc
56
import org.polyfrost.chatting.Chatting
67
import org.polyfrost.chatting.chat.ChatSearchingManager
78
import net.minecraft.client.Minecraft
@@ -54,7 +55,7 @@ class SearchButton() :
5455

5556
inner class SearchTextField : GuiTextField(
5657
69420,
57-
Minecraft.getMinecraft().fontRendererObj,
58+
mc.fontRendererObj,
5859
UResolution.scaledWidth * 4 / 5 - 60,
5960
UResolution.scaledHeight - 26,
6061
UResolution.scaledWidth / 5,

src/main/kotlin/org/polyfrost/chatting/utils/ModCompatHooks.kt

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
package org.polyfrost.chatting.utils
22

3+
import cc.polyfrost.oneconfig.platform.Platform
34
import cc.polyfrost.oneconfig.renderer.TextRenderer
45
import cc.polyfrost.oneconfig.utils.dsl.getAlpha
56
import cc.polyfrost.oneconfig.utils.dsl.mc
6-
import org.polyfrost.chatting.Chatting.isBetterChat
7-
import org.polyfrost.chatting.Chatting.isPatcher
8-
import org.polyfrost.chatting.config.ChattingConfig.offsetNonPlayerMessages
9-
import org.polyfrost.chatting.config.ChattingConfig.showChatHeads
10-
import org.polyfrost.chatting.config.ChattingConfig.textRenderType
117
import club.sk1er.patcher.config.PatcherConfig
128
import com.llamalad7.betterchat.BetterChat
13-
import net.minecraft.client.Minecraft
149
import net.minecraft.client.gui.ChatLine
1510
import net.minecraft.client.gui.FontRenderer
1611
import net.minecraft.client.gui.Gui
1712
import net.minecraft.client.renderer.GlStateManager
13+
import org.polyfrost.chatting.Chatting.isBetterChat
14+
import org.polyfrost.chatting.Chatting.isPatcher
1815
import org.polyfrost.chatting.config.ChattingConfig
16+
import org.polyfrost.chatting.config.ChattingConfig.offsetNonPlayerMessages
17+
import org.polyfrost.chatting.config.ChattingConfig.showChatHeads
1918
import org.polyfrost.chatting.hook.ChatLineHook
20-
import org.polyfrost.chatting.hook.GuiNewChatHook
2119
import org.polyfrost.chatting.mixin.GuiNewChatAccessor
2220

2321
// This exists because mixin doesn't like dummy classes
@@ -44,15 +42,15 @@ object ModCompatHooks {
4442

4543
@JvmStatic
4644
val fontRenderer: FontRenderer
47-
get() = Minecraft.getMinecraft().fontRendererObj
45+
get() = mc.fontRendererObj
4846

4947
@JvmStatic
5048
val chatLines: List<ChatLine>
51-
get() = (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatAccessor).chatLines
49+
get() = (mc.ingameGUI.chatGUI as GuiNewChatAccessor).chatLines
5250

5351
@JvmStatic
5452
val drawnChatLines: List<ChatLine>
55-
get() = (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatAccessor).drawnChatLines
53+
get() = (mc.ingameGUI.chatGUI as GuiNewChatAccessor).drawnChatLines
5654

5755
@JvmStatic
5856
val chatHeadOffset
@@ -65,6 +63,7 @@ object ModCompatHooks {
6563
@JvmStatic
6664
val chatInputLimit
6765
get() = if (isPatcher && PatcherConfig.extendedChatLength) 256 else 100
66+
6867
@JvmStatic
6968
val shouldDrawInputBox
7069
get() = !isPatcher || !PatcherConfig.transparentChatInputField
@@ -112,13 +111,10 @@ object ModCompatHooks {
112111
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f)
113112
}
114113
}
115-
return when (textRenderType) {
116-
0 -> fontRenderer.drawString(text, actualX, y, color, false)
117-
2 -> TextRenderer.drawBorderedText(text,
118-
actualX,
119-
y,
120-
color,
121-
(Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).`chatting$getTextOpacity`())
114+
return when (ChattingConfig.textRenderType) {
115+
0 -> Platform.getGLPlatform().drawText(text, actualX, y, color, false).toInt()
116+
1 -> Platform.getGLPlatform().drawText(text, actualX, y, color, true).toInt()
117+
2 -> TextRenderer.drawBorderedText(text, actualX, y, color, color.getAlpha())
122118
else -> fontRenderer.drawString(text, actualX, y, color, true)
123119
}
124120
}

0 commit comments

Comments
 (0)