fix spammed use of nametags in autonametag

This commit is contained in:
Bella 2020-04-16 21:18:31 -04:00
parent c0ab056a5c
commit c8ed989d5f
No known key found for this signature in database
GPG Key ID: DBD4A6030080C8B3
1 changed files with 14 additions and 7 deletions

View File

@ -1,5 +1,6 @@
package me.zeroeightsix.kami.module.modules.misc;
import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
@ -23,15 +24,16 @@ import static me.zeroeightsix.kami.util.MessageSendHelper.sendErrorMessage;
*/
@Module.Info(name = "AutoNametag", description = "Automatically nametags entities", category = Module.Category.MISC)
public class AutoNametag extends Module {
private Setting<Mode> modeSetting = register(Settings.e("Mode", Mode.WITHER));
private Setting<Mode> modeSetting = register(Settings.e("Mode", Mode.ANY));
private Setting<Float> range = register(Settings.floatBuilder("Range").withMinimum(2.0f).withValue(3.5f).withMaximum(10.0f).build());
private Setting<Boolean> debug = register(Settings.b("Debug", false));
private String currentName = "";
private int currentSlot = -1;
public void onUpdate() {
useNameTag();
findNameTags();
useNameTag();
}
private void useNameTag() {
@ -39,18 +41,22 @@ public class AutoNametag extends Module {
for (Entity w : mc.world.getLoadedEntityList()) {
switch (modeSetting.getValue()) {
case WITHER:
if (w instanceof EntityWither && !w.getDisplayName().getUnformattedText().equals(currentName)) {
// sendChatMessage("a");
if (w instanceof EntityMob) {
// sendChatMessage("mob");
final EntityWither wither = (EntityWither) w;
// sendChatMessage("wither");
if (mc.player.getDistance(wither) <= range.getValue()) {
// sendChatMessage("a");
if (debug.getValue())
sendChatMessage("Found unnamed Wither");
sendChatMessage("Found unnamed " + w.getDisplayName().getUnformattedText());
selectNameTags();
mc.playerController.interactWithEntity(mc.player, wither, EnumHand.MAIN_HAND);
}
}
return;
case ANY:
if (w instanceof EntityMob || w instanceof EntityAnimal && !w.getDisplayName().getUnformattedText().equals(currentName)) {
if ((w instanceof EntityMob || w instanceof EntityAnimal) && !w.getDisplayName().getUnformattedText().equals(currentName)) {
if (mc.player.getDistance(w) <= range.getValue()) {
if (debug.getValue())
sendChatMessage("Found unnamed " + w.getDisplayName().getUnformattedText());
@ -69,7 +75,7 @@ public class AutoNametag extends Module {
ItemStack stack = mc.player.inventory.getStackInSlot(i);
if (stack == ItemStack.EMPTY || stack.getItem() instanceof ItemBlock) continue;
Item tag = stack.getItem();
if (tag instanceof ItemNameTag) {
if (tag instanceof ItemNameTag && !stack.getDisplayName().equals("Name Tag")) {
tagSlot = i;
currentName = stack.getDisplayName();
}
@ -89,8 +95,9 @@ public class AutoNametag extends Module {
ItemStack stack = mc.player.inventory.getStackInSlot(i);
if (stack == ItemStack.EMPTY || stack.getItem() instanceof ItemBlock) continue;
Item tag = stack.getItem();
if (tag instanceof ItemNameTag) {
if (tag instanceof ItemNameTag && !stack.getDisplayName().equals("Name Tag")) {
currentName = stack.getDisplayName();
currentSlot = i;
}
}
}