From 8390451ef86d5d935265b7d523b3ee747da56714 Mon Sep 17 00:00:00 2001 From: blockparole <48992448+blockparole@users.noreply.github.com> Date: Thu, 21 Nov 2019 17:56:03 +0100 Subject: [PATCH 1/5] AutoRespawn anti bug --- .../kami/module/modules/misc/AutoRespawn.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoRespawn.java b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoRespawn.java index 12aaeec3..52a576aa 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoRespawn.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoRespawn.java @@ -11,24 +11,31 @@ import net.minecraft.client.gui.GuiGameOver; /** * Created by 086 on 9/04/2018. + * Updated 16 November 2019 by hub */ -@Module.Info(name = "AutoRespawn", description = "Automatically respawns upon death and tells you where you died", category = Module.Category.MISC) +@Module.Info(name = "AutoRespawn", description = "Respawn utility", category = Module.Category.MISC) public class AutoRespawn extends Module { - private Setting deathCoords = register(Settings.b("DeathCoords", false)); private Setting respawn = register(Settings.b("Respawn", true)); + private Setting deathCoords = register(Settings.b("DeathCoords", false)); + private Setting antiBug = register(Settings.b("Anti Bug", true)); @EventHandler public Listener listener = new Listener<>(event -> { - if (event.getScreen() instanceof GuiGameOver) { - if (deathCoords.getValue()) - Command.sendChatMessage(String.format("You died at x %d y %d z %d", (int)mc.player.posX, (int)mc.player.posY, (int)mc.player.posZ)); - if (respawn.getValue()) { - mc.player.respawnPlayer(); - mc.displayGuiScreen(null); - } + if (!(event.getScreen() instanceof GuiGameOver)) { + return; } + + if (deathCoords.getValue() && mc.player.getHealth() <= 0) { + Command.sendChatMessage(String.format("You died at x %d y %d z %d", (int) mc.player.posX, (int) mc.player.posY, (int) mc.player.posZ)); + } + + if (respawn.getValue() || (antiBug.getValue() && mc.player.getHealth() > 0)) { + mc.player.respawnPlayer(); + mc.displayGuiScreen(null); + } + }); } From 9bc05ebac8aae252cb21c6c314a0e16259892636 Mon Sep 17 00:00:00 2001 From: blockparole <48992448+blockparole@users.noreply.github.com> Date: Thu, 21 Nov 2019 23:09:55 +0100 Subject: [PATCH 2/5] AutoRespawn more clear naming and description "Anti Bug" -> "Anti Glitch Screen" --- .../me/zeroeightsix/kami/module/modules/misc/AutoRespawn.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoRespawn.java b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoRespawn.java index 52a576aa..9838c7c3 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoRespawn.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoRespawn.java @@ -18,7 +18,7 @@ public class AutoRespawn extends Module { private Setting respawn = register(Settings.b("Respawn", true)); private Setting deathCoords = register(Settings.b("DeathCoords", false)); - private Setting antiBug = register(Settings.b("Anti Bug", true)); + private Setting antiGlitchScreen = register(Settings.b("Anti Glitch Screen", true)); @EventHandler public Listener listener = new Listener<>(event -> { @@ -31,7 +31,7 @@ public class AutoRespawn extends Module { Command.sendChatMessage(String.format("You died at x %d y %d z %d", (int) mc.player.posX, (int) mc.player.posY, (int) mc.player.posZ)); } - if (respawn.getValue() || (antiBug.getValue() && mc.player.getHealth() > 0)) { + if (respawn.getValue() || (antiGlitchScreen.getValue() && mc.player.getHealth() > 0)) { mc.player.respawnPlayer(); mc.displayGuiScreen(null); } From d6f789f30517545335252f1da424cbbd7ba9396f Mon Sep 17 00:00:00 2001 From: Ridan Vandenbergh Date: Thu, 21 Nov 2019 23:57:12 +0100 Subject: [PATCH 3/5] Fix a NPE bug when joining Sometimes AntiForceLook tried to adjust packets using a nonexistant player while joining. --- .../zeroeightsix/kami/module/modules/player/AntiForceLook.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/player/AntiForceLook.java b/src/main/java/me/zeroeightsix/kami/module/modules/player/AntiForceLook.java index 22e3e492..21b5dbcd 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/player/AntiForceLook.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/player/AntiForceLook.java @@ -14,6 +14,7 @@ public class AntiForceLook extends Module { @EventHandler Listener receiveListener = new Listener<>(event -> { + if (mc.player == null) return; if (event.getPacket() instanceof SPacketPlayerPosLook) { SPacketPlayerPosLook packet = (SPacketPlayerPosLook) event.getPacket(); packet.yaw = mc.player.rotationYaw; From 0a7630c6c7324936de76ebfcf0077846b2f49674 Mon Sep 17 00:00:00 2001 From: Ridan Vandenbergh Date: Sat, 23 Nov 2019 13:22:20 +0100 Subject: [PATCH 4/5] Fix floating point conversion errors for float settings Not a pretty fix. This also fixes a visual bug with sliders and minimum values that are not equal to 0. Closes #145 --- .../kami/gui/kami/component/SettingsPanel.java | 17 +++++++++++++---- .../kami/gui/kami/theme/kami/RootSliderUI.java | 9 +++------ .../kami/gui/rgui/component/use/Slider.java | 3 ++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/gui/kami/component/SettingsPanel.java b/src/main/java/me/zeroeightsix/kami/gui/kami/component/SettingsPanel.java index 7c39277a..ac2005f8 100644 --- a/src/main/java/me/zeroeightsix/kami/gui/kami/component/SettingsPanel.java +++ b/src/main/java/me/zeroeightsix/kami/gui/kami/component/SettingsPanel.java @@ -81,17 +81,26 @@ public class SettingsPanel extends OrganisedContainer { if (numberSetting.getMin() != null) slider.setMin(numberSetting.getMin().doubleValue()); addChild(slider); } else { - Slider slider = new Slider(numberSetting.getValue().doubleValue(), numberSetting.getMin().doubleValue(), numberSetting.getMax().doubleValue(), Slider.getDefaultStep(numberSetting.getMin().doubleValue(), numberSetting.getMax().doubleValue()), name, setting instanceof IntegerSetting); + // Terrible terrible bug fix. + // I know, these parseDoubles look awful, but any conversions I tried here would end up with weird floating point conversion errors. + // This is really the easiest solution.. + double value = Double.parseDouble(numberSetting.getValue().toString()); + double min = Double.parseDouble(numberSetting.getMin().toString()); + double max = Double.parseDouble(numberSetting.getMax().toString()); + Slider slider = new Slider( + value, min, max, + Slider.getDefaultStep(min, max), + name, + setting instanceof IntegerSetting); slider.addPoof(new Slider.SliderPoof() { @Override public void execute(Slider component, SliderPoofInfo info) { if (setting instanceof IntegerSetting) - setting.setValue(new Integer((int) info.getNewValue())); + setting.setValue((int) info.getNewValue()); else if (setting instanceof FloatSetting) - setting.setValue(new Float(info.getNewValue())); + setting.setValue((float) info.getNewValue()); else if (setting instanceof DoubleSetting) setting.setValue(info.getNewValue()); - setModule(module); } }); addChild(slider); diff --git a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/RootSliderUI.java b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/RootSliderUI.java index a0d62d15..a25f002b 100644 --- a/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/RootSliderUI.java +++ b/src/main/java/me/zeroeightsix/kami/gui/kami/theme/kami/RootSliderUI.java @@ -21,7 +21,8 @@ public class RootSliderUI extends AbstractComponentUI { glColor4f(1,0.33f,0.33f,component.getOpacity()); glLineWidth(2.5f); int height = component.getHeight(); - double w = component.getWidth() * (component.getValue() / component.getMaximum()); + double value = component.getValue(); + double w = component.getWidth() * ((value - component.getMinimum()) / (component.getMaximum() - component.getMinimum())); float downscale = 1.1f; glBegin(GL_LINES); { @@ -37,11 +38,7 @@ public class RootSliderUI extends AbstractComponentUI { glColor3f(1,0.33f,0.33f); RenderHelper.drawCircle((int)w,height/downscale,2f); - String s = ""; - if (Math.floor(component.getValue())==component.getValue()) - s += (int) component.getValue(); - else - s += component.getValue(); + String s = value + ""; if (component.isPressed()){ w -= smallFontRenderer.getStringWidth(s)/2; w = Math.max(0,Math.min(w, component.getWidth()-smallFontRenderer.getStringWidth(s))); diff --git a/src/main/java/me/zeroeightsix/kami/gui/rgui/component/use/Slider.java b/src/main/java/me/zeroeightsix/kami/gui/rgui/component/use/Slider.java index 748ee7d2..e4795d01 100644 --- a/src/main/java/me/zeroeightsix/kami/gui/rgui/component/use/Slider.java +++ b/src/main/java/me/zeroeightsix/kami/gui/rgui/component/use/Slider.java @@ -102,7 +102,8 @@ public class Slider extends AbstractComponent { public void setValue(double value) { SliderPoof.SliderPoofInfo info = new SliderPoof.SliderPoofInfo(this.value, value); callPoof(SliderPoof.class, info); - this.value = integer ? (int) info.getNewValue() : info.getNewValue(); + double newValue = info.getNewValue(); + this.value = integer ? (int) newValue : newValue; } public static abstract class SliderPoof extends Poof { From f1c8222b82cc5d218571708667cb3a6384681e47 Mon Sep 17 00:00:00 2001 From: Ridan Vandenbergh Date: Sun, 24 Nov 2019 16:12:21 +0100 Subject: [PATCH 5/5] Update README.md no longer true --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b682c5c..2c79b59a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## A minecraft utility mod for anarchy servers. -Development has slowed down considerably. KAMI will likely no longer be updated. Pull requests are still welcome. +Development has slowed down considerably. See [forgehax](https://github.com/fr1kin/forgehax) for a more polished equivalent. Some features in KAMI may be based on those of forgehax, as I sometimes used it as reference.