forked from RepoMirrors/kami-blue
commit
174297962d
|
@ -18,26 +18,40 @@ import net.minecraft.inventory.ClickType;
|
|||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.CPacketEntityAction;
|
||||
import net.minecraft.network.play.client.CPacketPlayer;
|
||||
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static me.zeroeightsix.kami.module.modules.combat.CrystalAura.getPlayerPos;
|
||||
import static me.zeroeightsix.kami.module.modules.player.Scaffold.faceVectorPacketInstant;
|
||||
|
||||
/**
|
||||
* Created by hub on 7 August 2019
|
||||
* Updated by hub on 27 October 2019
|
||||
* Updated by hub on 31 October 2019
|
||||
*/
|
||||
@Module.Info(name = "Auto32k", category = Module.Category.COMBAT)
|
||||
@Module.Info(name = "Auto32k", category = Module.Category.COMBAT, description = "Do not use with any AntiGhostBlock Mod!")
|
||||
public class Auto32k extends Module {
|
||||
|
||||
private static final DecimalFormat df = new DecimalFormat("#.#");
|
||||
private static final List<Block> blackList = Arrays.asList(
|
||||
Blocks.ENDER_CHEST,
|
||||
Blocks.CHEST,
|
||||
Blocks.TRAPPED_CHEST,
|
||||
Blocks.CRAFTING_TABLE,
|
||||
Blocks.ANVIL,
|
||||
Blocks.BREWING_STAND,
|
||||
Blocks.HOPPER,
|
||||
Blocks.DROPPER,
|
||||
Blocks.DISPENSER,
|
||||
Blocks.TRAPDOOR
|
||||
);
|
||||
|
||||
private static final List<Block> shulkerList = Arrays.asList(
|
||||
Blocks.WHITE_SHULKER_BOX,
|
||||
Blocks.ORANGE_SHULKER_BOX,
|
||||
|
@ -57,15 +71,18 @@ public class Auto32k extends Module {
|
|||
Blocks.BLACK_SHULKER_BOX
|
||||
);
|
||||
|
||||
private static final DecimalFormat df = new DecimalFormat("#.#");
|
||||
|
||||
private Setting<Boolean> moveToHotbar = register(Settings.b("Move 32k to Hotbar", true));
|
||||
private Setting<Boolean> autoEnableHitAura = register(Settings.b("Auto enable Hit Aura", true));
|
||||
private Setting<Double> placeRange = register(Settings.d("Place Range", 4.0d));
|
||||
private Setting<Integer> yOffset = register(Settings.i("Y Offset (Hopper)", 2));
|
||||
private Setting<Boolean> placeCloseToEnemy = register(Settings.b("Place close to enemy", false));
|
||||
private Setting<Boolean> placeObiOnTop = register(Settings.b("Place Obi on Top", true));
|
||||
private Setting<Boolean> spoofRotation = register(Settings.b("Spoof Rotation", true));
|
||||
private Setting<Boolean> raytraceCheck = register(Settings.b("Raytrace Check", false));
|
||||
private Setting<Boolean> debugMessages = register(Settings.b("Debug Messages", false));
|
||||
|
||||
private int swordSlot;
|
||||
private static boolean isSneaking;
|
||||
|
||||
@Override
|
||||
protected void onEnable() {
|
||||
|
@ -108,7 +125,7 @@ public class Auto32k extends Module {
|
|||
|
||||
if (hopperSlot == -1) {
|
||||
if (debugMessages.getValue()) {
|
||||
Command.sendChatMessage("Hopper missing, disabling.");
|
||||
Command.sendChatMessage("[Auto32k] Hopper missing, disabling.");
|
||||
}
|
||||
this.disable();
|
||||
return;
|
||||
|
@ -116,7 +133,7 @@ public class Auto32k extends Module {
|
|||
|
||||
if (shulkerSlot == -1) {
|
||||
if (debugMessages.getValue()) {
|
||||
Command.sendChatMessage("Shulker missing, disabling.");
|
||||
Command.sendChatMessage("[Auto32k] Shulker missing, disabling.");
|
||||
}
|
||||
this.disable();
|
||||
return;
|
||||
|
@ -137,17 +154,26 @@ public class Auto32k extends Module {
|
|||
if (!(entity instanceof EntityPlayer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entity == mc.player) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Friends.isFriend(entity.getName())) {
|
||||
continue;
|
||||
}
|
||||
useRangeSorting = true;
|
||||
|
||||
if (yOffset.getValue() != 0) {
|
||||
if (Math.abs(mc.player.getPosition().y - placeTargetTest.y) > Math.abs(yOffset.getValue())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAreaPlaceable(placeTargetTest)) {
|
||||
double distanceToEntity = entity.getDistance(placeTargetTest.x, placeTargetTest.y, placeTargetTest.z);
|
||||
// Add distance to Map Value of placeTarget Key
|
||||
placeTargetMap.put(placeTargetTest, placeTargetMap.containsKey(placeTargetTest) ? placeTargetMap.get(placeTargetTest) + distanceToEntity : distanceToEntity);
|
||||
useRangeSorting = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -171,13 +197,13 @@ public class Auto32k extends Module {
|
|||
|
||||
if (placeCloseToEnemy.getValue()) {
|
||||
if (debugMessages.getValue()) {
|
||||
Command.sendChatMessage("Placing close to Enemy");
|
||||
Command.sendChatMessage("[Auto32k] Placing close to Enemy");
|
||||
}
|
||||
// Get Key with lowest Value (closest to enemies)
|
||||
placeTarget = Collections.min(placeTargetMap.entrySet(), Map.Entry.comparingByValue()).getKey();
|
||||
} else {
|
||||
if (debugMessages.getValue()) {
|
||||
Command.sendChatMessage("Placing far from Enemy");
|
||||
Command.sendChatMessage("[Auto32k] Placing far from Enemy");
|
||||
}
|
||||
// Get Key with highest Value (furthest away from enemies)
|
||||
placeTarget = Collections.max(placeTargetMap.entrySet(), Map.Entry.comparingByValue()).getKey();
|
||||
|
@ -186,7 +212,7 @@ public class Auto32k extends Module {
|
|||
} else {
|
||||
|
||||
if (debugMessages.getValue()) {
|
||||
Command.sendChatMessage("No enemy nearby, placing at first found");
|
||||
Command.sendChatMessage("[Auto32k] No enemy nearby, placing at first valid position.");
|
||||
}
|
||||
|
||||
// Use any place target position if no enemies are around
|
||||
|
@ -201,30 +227,31 @@ public class Auto32k extends Module {
|
|||
|
||||
if (placeTarget == null) {
|
||||
if (debugMessages.getValue()) {
|
||||
Command.sendChatMessage("No valid position in range to place.");
|
||||
Command.sendChatMessage("[Auto32k] No valid position in range to place!");
|
||||
}
|
||||
this.disable();
|
||||
return;
|
||||
}
|
||||
|
||||
if (debugMessages.getValue()) {
|
||||
Command.sendChatMessage("Place Target: " + placeTarget.toString() + " Distance: " + df.format(mc.player.getPositionVector().distanceTo(new Vec3d(placeTarget))));
|
||||
Command.sendChatMessage("[Auto32k] Place Target: " + placeTarget.x + " " + placeTarget.y + " " + placeTarget.z + " Distance: " + df.format(mc.player.getPositionVector().distanceTo(new Vec3d(placeTarget))));
|
||||
}
|
||||
|
||||
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
|
||||
|
||||
mc.player.inventory.currentItem = hopperSlot;
|
||||
placeBlock(new BlockPos(placeTarget), spoofRotation.getValue());
|
||||
placeBlock(new BlockPos(placeTarget));
|
||||
|
||||
mc.player.inventory.currentItem = shulkerSlot;
|
||||
placeBlock(new BlockPos(placeTarget.add(0, 1, 0)), spoofRotation.getValue());
|
||||
placeBlock(new BlockPos(placeTarget.add(0, 1, 0)));
|
||||
|
||||
if (placeObiOnTop.getValue() && obiSlot != -1) {
|
||||
mc.player.inventory.currentItem = obiSlot;
|
||||
placeBlock(new BlockPos(placeTarget.add(0, 2, 0)), spoofRotation.getValue());
|
||||
placeBlock(new BlockPos(placeTarget.add(0, 2, 0)));
|
||||
}
|
||||
|
||||
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
|
||||
if (isSneaking) {
|
||||
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
|
||||
isSneaking = false;
|
||||
}
|
||||
|
||||
mc.player.inventory.currentItem = shulkerSlot;
|
||||
BlockPos hopperPos = new BlockPos(placeTarget);
|
||||
|
@ -265,6 +292,9 @@ public class Auto32k extends Module {
|
|||
|
||||
if (swapReady) {
|
||||
mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, 0, swordSlot - 32, ClickType.SWAP, mc.player);
|
||||
if (autoEnableHitAura.getValue()) {
|
||||
ModuleManager.getModuleByName("Aura").enable();
|
||||
}
|
||||
this.disable();
|
||||
}
|
||||
|
||||
|
@ -298,21 +328,26 @@ public class Auto32k extends Module {
|
|||
return false; // out of range
|
||||
}
|
||||
|
||||
if (raytraceCheck.getValue()) {
|
||||
RayTraceResult result = mc.world.rayTraceBlocks(new Vec3d(mc.player.posX, mc.player.posY + mc.player.getEyeHeight(), mc.player.posZ), new Vec3d(blockPos), false, true, false);
|
||||
return result == null || result.getBlockPos().equals(blockPos);
|
||||
Block block = mc.world.getBlockState(blockPos.add(0, -1, 0)).getBlock();
|
||||
if (blackList.contains(block) || shulkerList.contains(block)) {
|
||||
return false; // would need sneak
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(mc.player.getPositionVector().distanceTo(new Vec3d(blockPos).add(0, 1, 0)) > placeRange.getValue()); // out of range
|
||||
|
||||
}
|
||||
|
||||
private static void placeBlock(BlockPos pos, boolean spoofRotation) {
|
||||
private static void placeBlock(BlockPos pos) {
|
||||
|
||||
if (!mc.world.getBlockState(pos).getMaterial().isReplaceable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if we have a block adjacent to blockpos to click at
|
||||
if (!checkForNeighbours(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (EnumFacing side : EnumFacing.values()) {
|
||||
|
||||
BlockPos neighbor = pos.offset(side);
|
||||
|
@ -324,17 +359,13 @@ public class Auto32k extends Module {
|
|||
|
||||
Vec3d hitVec = new Vec3d(neighbor).add(0.5, 0.5, 0.5).add(new Vec3d(side2.getDirectionVec()).scale(0.5));
|
||||
|
||||
if (spoofRotation) {
|
||||
Vec3d eyesPos = new Vec3d(mc.player.posX, mc.player.posY + mc.player.getEyeHeight(), mc.player.posZ);
|
||||
double diffX = hitVec.x - eyesPos.x;
|
||||
double diffY = hitVec.y - eyesPos.y;
|
||||
double diffZ = hitVec.z - eyesPos.z;
|
||||
double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
||||
float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
|
||||
float pitch = (float) -Math.toDegrees(Math.atan2(diffY, diffXZ));
|
||||
mc.player.connection.sendPacket(new CPacketPlayer.Rotation(mc.player.rotationYaw + MathHelper.wrapDegrees(yaw - mc.player.rotationYaw), mc.player.rotationPitch + MathHelper.wrapDegrees(pitch - mc.player.rotationPitch), mc.player.onGround));
|
||||
Block neighborPos = mc.world.getBlockState(neighbor).getBlock();
|
||||
if (blackList.contains(neighborPos) || shulkerList.contains(neighborPos)) {
|
||||
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
|
||||
isSneaking = true;
|
||||
}
|
||||
|
||||
faceVectorPacketInstant(hitVec);
|
||||
mc.playerController.processRightClickBlock(mc.player, mc.world, neighbor, side2, hitVec, EnumHand.MAIN_HAND);
|
||||
mc.player.swingArm(EnumHand.MAIN_HAND);
|
||||
mc.rightClickDelayTimer = 4;
|
||||
|
@ -345,4 +376,27 @@ public class Auto32k extends Module {
|
|||
|
||||
}
|
||||
|
||||
private static boolean checkForNeighbours(BlockPos blockPos) {
|
||||
if (!hasNeighbour(blockPos)) {
|
||||
for (EnumFacing side : EnumFacing.values()) {
|
||||
BlockPos neighbour = blockPos.offset(side);
|
||||
if (hasNeighbour(neighbour)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean hasNeighbour(BlockPos blockPos) {
|
||||
for (EnumFacing side : EnumFacing.values()) {
|
||||
BlockPos neighbour = blockPos.offset(side);
|
||||
if (!mc.world.getBlockState(neighbour).getMaterial().isReplaceable()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue