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. 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 { 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..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 @@ -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 antiGlitchScreen = register(Settings.b("Anti Glitch Screen", 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() || (antiGlitchScreen.getValue() && mc.player.getHealth() > 0)) { + mc.player.respawnPlayer(); + mc.displayGuiScreen(null); + } + }); } 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;