Auto32k Y Offset Bugfix

This commit is contained in:
blockparole 2019-10-27 16:43:11 +01:00
parent ed7919f686
commit 749947579a
1 changed files with 27 additions and 14 deletions

View File

@ -10,7 +10,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockAir; import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockLiquid;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.entity.RenderEntityItem;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@ -61,7 +60,7 @@ public class Auto32k extends Module {
private Setting<Boolean> moveToHotbar = register(Settings.b("Move 32k to Hotbar", true)); private Setting<Boolean> moveToHotbar = register(Settings.b("Move 32k to Hotbar", true));
private Setting<Double> placeRange = register(Settings.d("Place Range", 4.0d)); private Setting<Double> placeRange = register(Settings.d("Place Range", 4.0d));
private Setting<Boolean> placeClose = register(Settings.b("Place close to Player", false)); private Setting<Integer> yOffset = register(Settings.i("Y Offset (both directions)", 2));
private Setting<Boolean> placeBehind = register(Settings.b("Place behind", true)); private Setting<Boolean> placeBehind = register(Settings.b("Place behind", true));
private Setting<Boolean> placeObi = register(Settings.b("Obi on Top", true)); private Setting<Boolean> placeObi = register(Settings.b("Obi on Top", true));
private Setting<Boolean> spoofRotation = register(Settings.b("Spoof Rotation", true)); private Setting<Boolean> spoofRotation = register(Settings.b("Spoof Rotation", true));
@ -175,44 +174,58 @@ public class Auto32k extends Module {
} }
int range = (int) Math.ceil(placeRange.getValue()); 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 // 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) // 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 // but i think this would not work in most cases cause of raytrace checks on click
for (int i = range; i > 0; i--) { for (int i = range; i > 0; i--) {
placeTestNextPos = placeTestNextPos.add(facingDirection.getXOffset(), 0, facingDirection.getZOffset());
// max y Offset is 2 Blocks (3 iterations) // max y Offset is 2 Blocks (3 iterations)
for (int yOffset = 0; yOffset < 3; yOffset++) { for (int j = -1 * yOffsetSanitized; j < (1 + yOffsetSanitized); j++) {
placeTestNextPos = placeTestNextPos.add(facingDirection.getXOffset(), -1 * yOffset, facingDirection.getZOffset());
BlockPos placeTestNextPosOffsetY = placeTestNextPos.add(0, j, 0);
boolean EntityLivingBaseOnTargetBlockPos = false; 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) { if (entity instanceof EntityLivingBase) {
EntityLivingBaseOnTargetBlockPos = true; EntityLivingBaseOnTargetBlockPos = true;
break; break;
} }
} }
if (EntityLivingBaseOnTargetBlockPos) { if (EntityLivingBaseOnTargetBlockPos) {
continue; // entity on block continue; // entity on block
} }
if (!Wrapper.getWorld().getBlockState(placeTestNextPos).getMaterial().isReplaceable()) {
if (!Wrapper.getWorld().getBlockState(placeTestNextPosOffsetY).getMaterial().isReplaceable()) {
continue; // no space for hopper 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 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 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 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 continue; // out of range
} }
placeTestSuccessfull = placeTestNextPos;
if (placeClose.getValue()) { placeTestSuccessfull = placeTestNextPosOffsetY;
break; break;
}
} }
} }
if (placeTestSuccessfull == null) { if (placeTestSuccessfull == null) {