Skip to content

Commit 1964fbf

Browse files
authored
Add a warning when KAMI Blue is detected (#211)
* Add a warning when KAMI Blue is detected To prevent incompatibilities * Missed URL import I originally put the check in the main init * Different error message WhY nOt?
1 parent f47ba98 commit 1964fbf

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

src/main/java/com/lambda/client/mixin/client/gui/MixinGuiMainMenu.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.lambda.client.mixin.client.gui;
22

33
import com.lambda.client.LambdaMod;
4+
import com.lambda.client.gui.mc.LambdaGuiIncompat;
45
import com.lambda.client.module.modules.client.MenuShader;
6+
import com.lambda.client.util.KamiCheck;
57
import com.lambda.client.util.WebUtils;
68
import net.minecraft.client.gui.FontRenderer;
79
import net.minecraft.client.gui.GuiMainMenu;
@@ -27,6 +29,10 @@ public abstract class MixinGuiMainMenu extends GuiScreen {
2729

2830
@Inject(method = "drawScreen", at = @At("RETURN"))
2931
public void drawScreen$Inject$RETURN(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
32+
if (KamiCheck.INSTANCE.isKami() && !KamiCheck.INSTANCE.getDidDisplayWarning()) {
33+
KamiCheck.INSTANCE.setDidDisplayWarning(true);
34+
mc.displayGuiScreen(new LambdaGuiIncompat());
35+
}
3036
FontRenderer fr = fontRenderer;
3137
String slogan = TextFormatting.WHITE + LambdaMod.NAME + " " + TextFormatting.GRAY + LambdaMod.VERSION;
3238
String version;

src/main/kotlin/com/lambda/client/LambdaMod.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.lambda.client
33
import com.lambda.client.event.ForgeEventProcessor
44
import com.lambda.client.gui.clickgui.LambdaClickGui
55
import com.lambda.client.util.ConfigUtils
6+
import com.lambda.client.util.KamiCheck
67
import com.lambda.client.util.WebUtils
78
import com.lambda.client.util.threads.BackgroundScope
89
import net.minecraftforge.common.MinecraftForge
@@ -75,6 +76,8 @@ class LambdaMod {
7576
WebUtils.updateCheck()
7677
LambdaClickGui.populateRemotePlugins()
7778

79+
KamiCheck.runCheck()
80+
7881
LOG.info("$NAME initialized!")
7982
}
8083

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.lambda.client.gui.mc
2+
3+
import net.minecraft.client.gui.GuiButton
4+
import net.minecraft.client.gui.GuiMainMenu
5+
import net.minecraft.client.gui.GuiOptionButton
6+
import net.minecraft.client.gui.GuiScreen
7+
import net.minecraft.client.resources.I18n
8+
9+
class LambdaGuiIncompat : GuiScreen() {
10+
11+
override fun initGui() {
12+
buttonList.clear()
13+
// I used the minecraft "Out of Memory" class as a reference, turns out it has exactly the buttons I need, with internationalization support too
14+
buttonList.add(GuiOptionButton(0, width / 2 - 155, height / 4 + 120, I18n.format("gui.toTitle", *arrayOfNulls(0))))
15+
buttonList.add(GuiOptionButton(1, width / 2 - 155 + 160, height / 4 + 120, I18n.format("menu.quit", *arrayOfNulls(0))))
16+
}
17+
18+
override fun actionPerformed(button: GuiButton) {
19+
if (button.id == 0) {
20+
mc.displayGuiScreen(GuiMainMenu())
21+
} else if (button.id == 1) {
22+
mc.shutdown()
23+
}
24+
}
25+
26+
override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) {
27+
drawDefaultBackground()
28+
drawCenteredString(fontRenderer, "Found KAMI Blue!", width / 2, height / 4 - 60 + 20, 16777215)
29+
drawString(fontRenderer, "It appears you are using KAMI Blue alongside Lambda Client.", width / 2 - 140, height / 4 - 60 + 60 + 0, 10526880)
30+
drawString(fontRenderer, "Lambda Client is a continued version of KAMI Blue,", width / 2 - 140, height / 4 - 60 + 60 + 18, 10526880)
31+
drawString(fontRenderer, "and is not compatible as a result.", width / 2 - 140, height / 4 - 60 + 60 + 27, 10526880)
32+
drawString(fontRenderer, "It is not recommended to use both clients", width / 2 - 140, height / 4 - 60 + 60 + 45, 10526880)
33+
drawString(fontRenderer, "together, since many modules will override each other.", width / 2 - 140, height / 4 - 60 + 60 + 54, 10526880)
34+
drawString(fontRenderer, "You may continue, but it may cause serious issues,", width / 2 - 140, height / 4 - 60 + 60 + 63, 10526880)
35+
drawString(fontRenderer, "and support will not be provided to dual users.", width / 2 - 140, height / 4 - 60 + 60 + 72, 10526880)
36+
super.drawScreen(mouseX, mouseY, partialTicks)
37+
}
38+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.lambda.client.util
2+
3+
import com.lambda.client.LambdaMod
4+
import java.net.URL
5+
6+
object KamiCheck {
7+
var isKami: Boolean = false
8+
var didDisplayWarning: Boolean = false
9+
fun runCheck() {
10+
val kamiCheckList: List<URL> = this.javaClass.classLoader.getResources("org/kamiblue/client/KamiMod.class").toList()
11+
if (kamiCheckList.isNotEmpty()) {
12+
LambdaMod.LOG.error("KAMI Blue detected!")
13+
isKami = true
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)