forked from RepoMirrors/kami-blue
add any mode to autonametag and made finding custom withers safer
This commit is contained in:
parent
0fb24f3d65
commit
d8e7f64792
|
@ -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<Mode> modeSetting = register(Settings.e("Mode", Mode.WITHER));
|
||||
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));
|
||||
|
||||
|
@ -28,14 +32,28 @@ 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")) {
|
||||
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");
|
||||
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 }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue