use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.
the class AutoBedrockBreak method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (pos != null) {
switch(step) {
case 0:
if (!mc.world.isSpaceEmpty(new Box(pos.up(), pos.add(1, 8, 1)))) {
reset();
BleachLogger.info("Not enough empty space to break this block!");
} else if (InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.PISTON) == -1) {
reset();
BleachLogger.info("Missing pistons!");
} else if (InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.REDSTONE_BLOCK) == -1) {
reset();
BleachLogger.info("Missing a redstone block!");
} else if (InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.TNT) == -1) {
reset();
BleachLogger.info("Missing TNT!");
} else if (InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.LEVER) == -1) {
reset();
BleachLogger.info("Missing a lever!");
} else if (dirtyPlace(pos.up(3), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.REDSTONE_BLOCK), Direction.DOWN)) {
step++;
}
break;
case 1:
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.getYaw(), 90, mc.player.isOnGround()));
// mc.player.setPitch(90) "its jank either way"
step++;
break;
case 2:
if (dirtyPlace(pos.up(), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.PISTON), Direction.DOWN))
step++;
break;
case 3:
if (dirtyPlace(pos.up(7), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.TNT), Direction.DOWN))
step++;
break;
case 4:
if (dirtyPlace(pos.up(6), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.LEVER), Direction.UP))
step++;
break;
case 5:
if (dirtyPlace(pos.up(5), InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.TNT), Direction.DOWN))
step++;
break;
case 6:
Vec3d leverCenter = Vec3d.ofCenter(pos.up(6));
if (mc.player.getEyePos().distanceTo(leverCenter) <= 4.75) {
mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(leverCenter, Direction.DOWN, pos.up(6), false));
step++;
}
break;
default:
if (mc.world.getBlockState(pos).isAir() || mc.world.getBlockState(pos).getBlock() instanceof PistonBlock || (mc.world.getBlockState(pos.up()).getBlock() instanceof PistonBlock && mc.world.getBlockState(pos.up()).get(PistonBlock.FACING) != Direction.UP)) {
setEnabled(false);
return;
}
if (step >= 82) {
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.getYaw(), -90, mc.player.isOnGround()));
// mc.player.setPitch(-90) "its jank either way"
}
if (step > 84) {
Hand hand = InventoryUtils.selectSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.PISTON);
if (hand != null) {
mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(hand, new BlockHitResult(Vec3d.ofBottomCenter(pos.up()), Direction.DOWN, pos.up(), false)));
}
}
step++;
break;
}
}
}
use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.
the class AutoBedrockBreak method dirtyPlace.
private boolean dirtyPlace(BlockPos pos, int slot, Direction dir) {
Vec3d hitPos = Vec3d.ofCenter(pos).add(dir.getOffsetX() * 0.5, dir.getOffsetY() * 0.5, dir.getOffsetZ() * 0.5);
if (mc.player.getEyePos().distanceTo(hitPos) >= 4.75 || !mc.world.getOtherEntities(null, new Box(pos)).isEmpty()) {
return false;
}
Hand hand = InventoryUtils.selectSlot(slot);
if (hand != null) {
mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(hitPos, dir, pos, false));
return true;
}
return false;
}
use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.
the class Ghosthand method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (!mc.options.keyUse.isPressed() || mc.player.isSneaking())
return;
// Return if we are looking at any block entities
BlockPos lookingPos = new BlockPos(mc.player.raycast(4.25, mc.getTickDelta(), false).getPos());
for (BlockEntity b : WorldUtils.getBlockEntities()) {
if (lookingPos.equals(b.getPos())) {
return;
}
}
Set<BlockPos> posList = new HashSet<>();
Vec3d nextPos = new Vec3d(0, 0, 0.1).rotateX(-(float) Math.toRadians(mc.player.getPitch())).rotateY(-(float) Math.toRadians(mc.player.getYaw()));
for (int i = 1; i < 50; i++) {
BlockPos curPos = new BlockPos(mc.player.getCameraPosVec(mc.getTickDelta()).add(nextPos.multiply(i)));
if (!posList.contains(curPos)) {
posList.add(curPos);
for (BlockEntity b : WorldUtils.getBlockEntities()) {
if (b.getPos().equals(curPos)) {
mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(mc.player.getPos(), Direction.UP, curPos, true));
return;
}
}
}
}
}
use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.
the class ClickTp method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (InputUtil.isKeyPressed(mc.getWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT)) {
pos = null;
dir = null;
return;
}
BlockHitResult hit = (BlockHitResult) mc.player.raycast(100, mc.getTickDelta(), getSetting(1).asToggle().getState());
boolean miss = hit.getType() == Type.MISS && !getSetting(0).asToggle().getState();
pos = miss ? null : hit.getBlockPos();
dir = miss ? null : getSetting(3).asToggle().getState() ? Direction.UP : hit.getSide();
if (pos != null && dir != null) {
if (GLFW.glfwGetMouseButton(mc.getWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == 1 && mc.currentScreen == null && !antiSpamClick) {
antiSpamClick = true;
Vec3d tpPos = Vec3d.ofBottomCenter(pos.offset(dir, dir == Direction.DOWN ? 2 : 1));
if (getSetting(2).asToggle().getState()) {
mc.player.updatePosition(mc.player.getX(), tpPos.y, mc.player.getZ());
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), tpPos.y, mc.player.getZ(), false));
}
mc.player.updatePosition(tpPos.x, tpPos.y, tpPos.z);
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(tpPos.x, tpPos.y, tpPos.z, false));
} else if (GLFW.glfwGetMouseButton(mc.getWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == 0) {
antiSpamClick = false;
}
}
}
use of net.minecraft.util.hit.BlockHitResult in project BleachHack by BleachDrinker420.
the class CmdNBT method getNbt.
private NbtCompound getNbt(String arg) {
if (arg.equalsIgnoreCase("hand")) {
return mc.player.getMainHandStack().getOrCreateNbt();
} else if (arg.equalsIgnoreCase("block")) {
HitResult target = mc.crosshairTarget;
if (target.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult) target).getBlockPos();
BlockEntity be = mc.world.getBlockEntity(pos);
if (be != null) {
return be.writeNbt(new NbtCompound());
} else {
return new NbtCompound();
}
}
BleachLogger.error("Not looking at a block.");
return null;
} else if (arg.equalsIgnoreCase("entity")) {
HitResult target = mc.crosshairTarget;
if (target.getType() == HitResult.Type.ENTITY) {
return ((EntityHitResult) target).getEntity().writeNbt(new NbtCompound());
}
BleachLogger.error("Not looking at an entity.");
return null;
}
throw new CmdSyntaxException();
}
Aggregations