forked from RepoMirrors/kami-blue
fix spammed use of nametags in autonametag
This commit is contained in:
parent
c0ab056a5c
commit
c8ed989d5f
|
@ -1,5 +1,6 @@
|
||||||
package me.zeroeightsix.kami.module.modules.misc;
|
package me.zeroeightsix.kami.module.modules.misc;
|
||||||
|
|
||||||
|
import me.zeroeightsix.kami.command.Command;
|
||||||
import me.zeroeightsix.kami.module.Module;
|
import me.zeroeightsix.kami.module.Module;
|
||||||
import me.zeroeightsix.kami.setting.Setting;
|
import me.zeroeightsix.kami.setting.Setting;
|
||||||
import me.zeroeightsix.kami.setting.Settings;
|
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)
|
@Module.Info(name = "AutoNametag", description = "Automatically nametags entities", category = Module.Category.MISC)
|
||||||
public class AutoNametag extends Module {
|
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<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 Setting<Boolean> debug = register(Settings.b("Debug", false));
|
||||||
|
|
||||||
private String currentName = "";
|
private String currentName = "";
|
||||||
|
private int currentSlot = -1;
|
||||||
|
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
useNameTag();
|
|
||||||
findNameTags();
|
findNameTags();
|
||||||
|
useNameTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void useNameTag() {
|
private void useNameTag() {
|
||||||
|
@ -39,18 +41,22 @@ public class AutoNametag extends Module {
|
||||||
for (Entity w : mc.world.getLoadedEntityList()) {
|
for (Entity w : mc.world.getLoadedEntityList()) {
|
||||||
switch (modeSetting.getValue()) {
|
switch (modeSetting.getValue()) {
|
||||||
case WITHER:
|
case WITHER:
|
||||||
if (w instanceof EntityWither && !w.getDisplayName().getUnformattedText().equals(currentName)) {
|
// sendChatMessage("a");
|
||||||
|
if (w instanceof EntityMob) {
|
||||||
|
// sendChatMessage("mob");
|
||||||
final EntityWither wither = (EntityWither) w;
|
final EntityWither wither = (EntityWither) w;
|
||||||
|
// sendChatMessage("wither");
|
||||||
if (mc.player.getDistance(wither) <= range.getValue()) {
|
if (mc.player.getDistance(wither) <= range.getValue()) {
|
||||||
|
// sendChatMessage("a");
|
||||||
if (debug.getValue())
|
if (debug.getValue())
|
||||||
sendChatMessage("Found unnamed Wither");
|
sendChatMessage("Found unnamed " + w.getDisplayName().getUnformattedText());
|
||||||
selectNameTags();
|
selectNameTags();
|
||||||
mc.playerController.interactWithEntity(mc.player, wither, EnumHand.MAIN_HAND);
|
mc.playerController.interactWithEntity(mc.player, wither, EnumHand.MAIN_HAND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case ANY:
|
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 (mc.player.getDistance(w) <= range.getValue()) {
|
||||||
if (debug.getValue())
|
if (debug.getValue())
|
||||||
sendChatMessage("Found unnamed " + w.getDisplayName().getUnformattedText());
|
sendChatMessage("Found unnamed " + w.getDisplayName().getUnformattedText());
|
||||||
|
@ -69,7 +75,7 @@ public class AutoNametag extends Module {
|
||||||
ItemStack stack = mc.player.inventory.getStackInSlot(i);
|
ItemStack stack = mc.player.inventory.getStackInSlot(i);
|
||||||
if (stack == ItemStack.EMPTY || stack.getItem() instanceof ItemBlock) continue;
|
if (stack == ItemStack.EMPTY || stack.getItem() instanceof ItemBlock) continue;
|
||||||
Item tag = stack.getItem();
|
Item tag = stack.getItem();
|
||||||
if (tag instanceof ItemNameTag) {
|
if (tag instanceof ItemNameTag && !stack.getDisplayName().equals("Name Tag")) {
|
||||||
tagSlot = i;
|
tagSlot = i;
|
||||||
currentName = stack.getDisplayName();
|
currentName = stack.getDisplayName();
|
||||||
}
|
}
|
||||||
|
@ -89,8 +95,9 @@ public class AutoNametag extends Module {
|
||||||
ItemStack stack = mc.player.inventory.getStackInSlot(i);
|
ItemStack stack = mc.player.inventory.getStackInSlot(i);
|
||||||
if (stack == ItemStack.EMPTY || stack.getItem() instanceof ItemBlock) continue;
|
if (stack == ItemStack.EMPTY || stack.getItem() instanceof ItemBlock) continue;
|
||||||
Item tag = stack.getItem();
|
Item tag = stack.getItem();
|
||||||
if (tag instanceof ItemNameTag) {
|
if (tag instanceof ItemNameTag && !stack.getDisplayName().equals("Name Tag")) {
|
||||||
currentName = stack.getDisplayName();
|
currentName = stack.getDisplayName();
|
||||||
|
currentSlot = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue