use of net.minecraft.block.PistonBlock 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.block.PistonBlock in project lithium-fabric by CaffeineMC.
the class PistonBlockEntityMixin method skipVoxelShapeUnion.
/**
* Avoid calling {@link VoxelShapes#union(VoxelShape, VoxelShape)} whenever possible - use precomputed merged piston head + base shapes and
* cache the results for all union calls with an empty shape as first argument. (these are all other cases)
*/
@Inject(method = "getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/shape/VoxelShape;", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/Direction;getOffsetX()I", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void skipVoxelShapeUnion(BlockView world, BlockPos pos, CallbackInfoReturnable<VoxelShape> cir, VoxelShape voxelShape, Direction direction, BlockState blockState, float f) {
if (this.extending || !this.source || !(this.pushedBlock.getBlock() instanceof PistonBlock)) {
// here voxelShape2.isEmpty() is guaranteed, vanilla code would call union() which calls simplify()
VoxelShape blockShape = blockState.getCollisionShape(world, pos);
// we cache the simplified shapes, as the simplify() method costs a lot of CPU time and allocates several objects
VoxelShape offsetAndSimplified = getOffsetAndSimplified(blockShape, Math.abs(f), f < 0f ? this.facing.getOpposite() : this.facing);
cir.setReturnValue(offsetAndSimplified);
} else {
// retracting piston heads have to act like their base as well, as the base block is replaced with the moving block
// f >= 0f is guaranteed (assuming no other mod interferes)
int index = getIndexForMergedShape(f, this.facing);
cir.setReturnValue(PISTON_BASE_WITH_MOVING_HEAD_SHAPES[index]);
}
}
Aggregations