diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/combat/Auto32k.java b/src/main/java/me/zeroeightsix/kami/module/modules/combat/Auto32k.java index 6307322f..522a1d89 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/combat/Auto32k.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/combat/Auto32k.java @@ -10,7 +10,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockLiquid; import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.entity.RenderEntityItem; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; @@ -61,7 +60,7 @@ public class Auto32k extends Module { private Setting moveToHotbar = register(Settings.b("Move 32k to Hotbar", true)); private Setting placeRange = register(Settings.d("Place Range", 4.0d)); - private Setting placeClose = register(Settings.b("Place close to Player", false)); + private Setting yOffset = register(Settings.i("Y Offset (both directions)", 2)); private Setting placeBehind = register(Settings.b("Place behind", true)); private Setting placeObi = register(Settings.b("Obi on Top", true)); private Setting spoofRotation = register(Settings.b("Spoof Rotation", true)); @@ -175,44 +174,58 @@ public class Auto32k extends Module { } int range = (int) Math.ceil(placeRange.getValue()); + //int yOffsetSanitized = yOffset.getValue() < 0 ? -1 * yOffset.getValue() : yOffset.getValue(); + int yOffsetSanitized = yOffset.getValue(); // searching placeable area in front / behind the player in a straight line // we could test interations on both sides of the player while range - n (where n is iterations) // but i think this would not work in most cases cause of raytrace checks on click for (int i = range; i > 0; i--) { + + placeTestNextPos = placeTestNextPos.add(facingDirection.getXOffset(), 0, facingDirection.getZOffset()); + // max y Offset is 2 Blocks (3 iterations) - for (int yOffset = 0; yOffset < 3; yOffset++) { - placeTestNextPos = placeTestNextPos.add(facingDirection.getXOffset(), -1 * yOffset, facingDirection.getZOffset()); + for (int j = -1 * yOffsetSanitized; j < (1 + yOffsetSanitized); j++) { + + BlockPos placeTestNextPosOffsetY = placeTestNextPos.add(0, j, 0); + boolean EntityLivingBaseOnTargetBlockPos = false; - for (Entity entity : mc.world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(placeTestNextPos))) { + for (Entity entity : mc.world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(placeTestNextPosOffsetY))) { if (entity instanceof EntityLivingBase) { EntityLivingBaseOnTargetBlockPos = true; break; } } + if (EntityLivingBaseOnTargetBlockPos) { continue; // entity on block } - if (!Wrapper.getWorld().getBlockState(placeTestNextPos).getMaterial().isReplaceable()) { + + if (!Wrapper.getWorld().getBlockState(placeTestNextPosOffsetY).getMaterial().isReplaceable()) { continue; // no space for hopper } - if (!Wrapper.getWorld().getBlockState(placeTestNextPos.add(0, 1, 0)).getMaterial().isReplaceable()) { + + if (!Wrapper.getWorld().getBlockState(placeTestNextPosOffsetY.add(0, 1, 0)).getMaterial().isReplaceable()) { continue; // no space for shulker } - if (Wrapper.getWorld().getBlockState(placeTestNextPos.add(0, -1, 0)).getBlock() instanceof BlockAir) { + + if (Wrapper.getWorld().getBlockState(placeTestNextPosOffsetY.add(0, -1, 0)).getBlock() instanceof BlockAir) { continue; // air below hopper } - if (Wrapper.getWorld().getBlockState(placeTestNextPos.add(0, -1, 0)).getBlock() instanceof BlockLiquid) { + + if (Wrapper.getWorld().getBlockState(placeTestNextPosOffsetY.add(0, -1, 0)).getBlock() instanceof BlockLiquid) { continue; // liquid below hopper } - if (mc.player.getPositionVector().distanceTo(new Vec3d(placeTestNextPos)) > placeRange.getValue()) { + + if (mc.player.getPositionVector().distanceTo(new Vec3d(placeTestNextPosOffsetY)) > placeRange.getValue()) { continue; // out of range } - placeTestSuccessfull = placeTestNextPos; - if (placeClose.getValue()) { - break; - } + + placeTestSuccessfull = placeTestNextPosOffsetY; + break; + } + } if (placeTestSuccessfull == null) {