From d8e7f647920bff0b70ae9d3607f1c06d285f8e0e Mon Sep 17 00:00:00 2001 From: Bella Date: Sun, 5 Apr 2020 09:15:37 -0400 Subject: [PATCH] add any mode to autonametag and made finding custom withers safer --- .../kami/module/modules/misc/AutoNametag.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoNametag.java b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoNametag.java index e1a9821e..5f4917aa 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoNametag.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoNametag.java @@ -6,6 +6,8 @@ import me.zeroeightsix.kami.setting.Setting; import me.zeroeightsix.kami.setting.Settings; import net.minecraft.entity.Entity; import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemNameTag; @@ -15,9 +17,11 @@ import net.minecraft.util.EnumHand; /** * @author S-B99 * Created by S-B99 on this commit: 83387d6c2243c2a70dc864c9fbef96a77b9a9735 + * Updated by S-B99 on 05/04/20 */ @Module.Info(name = "AutoNametag", description = "Automatically nametags entities", category = Module.Category.MISC) public class AutoNametag extends Module { + private Setting modeSetting = register(Settings.e("Mode", Mode.WITHER)); private Setting range = register(Settings.floatBuilder("Range").withMinimum(2.0f).withValue(3.5f).withMaximum(10.0f).build()); private Setting debug = register(Settings.b("Debug", false)); @@ -28,13 +32,27 @@ public class AutoNametag extends Module { private void useNameTag() { int originalSlot = mc.player.inventory.currentItem; for (Entity w : mc.world.getLoadedEntityList()) { - if (w instanceof EntityWither && w.getDisplayName().getUnformattedText().equalsIgnoreCase("Wither")) { - final EntityWither wither = (EntityWither) w; - if (mc.player.getDistance(wither) <= range.getValue()) { - if (debug.getValue()) Command.sendChatMessage("Found Unnamed Wither"); - selectNameTags(); - mc.playerController.interactWithEntity(mc.player, wither, EnumHand.MAIN_HAND); - } + switch (modeSetting.getValue()) { + case WITHER: + if (w instanceof EntityWither && !w.hasCustomName()) { + final EntityWither wither = (EntityWither) w; + if (mc.player.getDistance(wither) <= range.getValue()) { + if (debug.getValue()) + Command.sendChatMessage("Found unnamed Wither"); + selectNameTags(); + mc.playerController.interactWithEntity(mc.player, wither, EnumHand.MAIN_HAND); + } + } + return; + case ANY: + if (w instanceof EntityMob || w instanceof EntityAnimal && !w.hasCustomName()) { + if (mc.player.getDistance(w) <= range.getValue()) { + if (debug.getValue()) + Command.sendChatMessage("Found unnamed " + w.getDisplayName().getUnformattedText()); + selectNameTags(); + mc.playerController.interactWithEntity(mc.player, w, EnumHand.MAIN_HAND); + } + } } } mc.player.inventory.currentItem = originalSlot; @@ -51,9 +69,12 @@ public class AutoNametag extends Module { if (tagSlot == -1) { if (debug.getValue()) Command.sendErrorMessage(getChatName() + "Error: No nametags in hotbar"); + disable(); return; } mc.player.inventory.currentItem = tagSlot; } + + private enum Mode { WITHER, ANY } }