add nametag to autosummon

This commit is contained in:
Bella 2020-03-17 09:12:11 -04:00
parent bcd2b2cf02
commit c19224d64b
No known key found for this signature in database
GPG Key ID: 03B01AC937D1C89C
1 changed files with 44 additions and 11 deletions

View File

@ -10,11 +10,14 @@ import me.zeroeightsix.kami.setting.Settings;
import net.minecraft.block.*;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemNameTag;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CPacketEntityAction;
import net.minecraft.util.EnumFacing;
@ -39,10 +42,11 @@ public class AutoSpawner extends Module {
private Setting<Boolean> party = register(Settings.b("Party", false));
private Setting<Boolean> partyWithers = register(Settings.booleanBuilder("Withers").withValue(false).withVisibility(v -> party.getValue()).build());
private Setting<EntityMode> entityMode = register(Settings.enumBuilder(EntityMode.class).withName("Entity Mode").withValue(EntityMode.SNOW).withVisibility(v -> !party.getValue()).build());
private Setting<Boolean> nametagWithers = register(Settings.booleanBuilder("Nametag").withValue(true).withVisibility(v -> (party.getValue() && partyWithers.getValue()) || entityMode.getValue().equals(EntityMode.WITHER)).build());
private Setting<Float> placeRange = register(Settings.floatBuilder("Place Range").withMinimum(2.0f).withValue(3.5f).withMaximum(10.0f).build());
private Setting<Integer> delay = register(Settings.integerBuilder("Delay").withMinimum(12).withValue(20).withMaximum(100).withVisibility(v -> useMode.getValue().equals(UseMode.SPAM)).build());
private Setting<Boolean> rotate = register(Settings.b("Rotate", true));
private Setting<Boolean> notifications = register(Settings.b("Notifications", false));
private Setting<Boolean> debug = register(Settings.b("Debug", false));
private static boolean isSneaking;
@ -57,12 +61,9 @@ public class AutoSpawner extends Module {
private int delayStep;
private static void placeBlock(BlockPos pos, boolean rotate) {
EnumFacing side = getPlaceableSide(pos);
if (side == null) {
return;
}
if (side == null) return;
BlockPos neighbour = pos.offset(side);
EnumFacing opposite = side.getOpposite();
@ -83,6 +84,38 @@ public class AutoSpawner extends Module {
mc.rightClickDelayTimer = 4;
}
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) <= placeRange.getValue()) {
if (debug.getValue()) Command.sendChatMessage("Found Unnamed Wither");
selectNameTags();
mc.playerController.interactWithEntity(mc.player, wither, EnumHand.MAIN_HAND);
}
}
}
mc.player.inventory.currentItem = originalSlot;
}
private void selectNameTags() {
int tagSlot = -1;
for (int i = 0; i < 9; i++) {
ItemStack stack = mc.player.inventory.getStackInSlot(i);
if (stack == ItemStack.EMPTY || stack.getItem() instanceof ItemBlock) continue;
Item tag = stack.getItem();
if (tag instanceof ItemNameTag) tagSlot = i;
}
if (tagSlot == -1) {
if (debug.getValue()) Command.sendErrorMessage(getChatName() + "Error: No nametags in hotbar");
return;
}
mc.player.inventory.currentItem = tagSlot;
}
private static EnumFacing getPlaceableSide(BlockPos pos) {
for (EnumFacing side : EnumFacing.values()) {
BlockPos neighbour = pos.offset(side);
@ -323,6 +356,8 @@ public class AutoSpawner extends Module {
public void onUpdate() {
if (mc.player == null) return;
if (nametagWithers.getValue()) useNameTag();
if (buildStage == 1) {
isSneaking = false;
rotationPlaceableX = false;
@ -349,8 +384,8 @@ public class AutoSpawner extends Module {
if (!checkBlocksInHotbar()) {
if (!party.getValue()) {
if (notifications.getValue()) {
Command.sendChatMessage(this.getChatName() + " " + ChatFormatting.RED.toString() + "Blocks missing for: " + ChatFormatting.RESET.toString() + entityMode.getValue().toString() + ChatFormatting.RED.toString() + ", disabling.");
if (debug.getValue()) {
Command.sendChatMessage(getChatName() + ChatFormatting.RED.toString() + "Blocks missing for: " + ChatFormatting.RESET.toString() + entityMode.getValue().toString() + ChatFormatting.RED.toString() + ", disabling.");
}
this.disable();
}
@ -372,8 +407,8 @@ public class AutoSpawner extends Module {
if (noPositionInArea) {
if (useMode.getValue().equals(UseMode.SINGLE)) {
if (notifications.getValue()) {
Command.sendChatMessage(this.getChatName() + " " + ChatFormatting.RED.toString() + "Position not valid, disabling.");
if (debug.getValue()) {
Command.sendChatMessage(getChatName() + ChatFormatting.RED.toString() + "Position not valid, disabling.");
}
this.disable();
}
@ -425,14 +460,12 @@ public class AutoSpawner extends Module {
if (useMode.getValue().equals(UseMode.SINGLE)) this.disable();
buildStage = 3;
} else if (buildStage == 3) {
if (delayStep < delay.getValue()) {
delayStep++;
} else {
delayStep = 1;
buildStage = 1;
}
}
}