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] 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); + } + }); }