use of net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket in project meteor-rejects by AntiCope.
the class AntiSpawnpoint method onSendPacket.
@EventHandler
private void onSendPacket(PacketEvent.Send event) {
if (mc.world == null)
return;
if (!(event.packet instanceof PlayerInteractBlockC2SPacket))
return;
BlockPos blockPos = ((PlayerInteractBlockC2SPacket) event.packet).getBlockHitResult().getBlockPos();
boolean IsOverWorld = mc.world.getDimension().isBedWorking();
boolean IsNetherWorld = mc.world.getDimension().isRespawnAnchorWorking();
boolean BlockIsBed = mc.world.getBlockState(blockPos).getBlock() instanceof BedBlock;
boolean BlockIsAnchor = mc.world.getBlockState(blockPos).getBlock().equals(Blocks.RESPAWN_ANCHOR);
if (fakeUse.get()) {
if (BlockIsBed && IsOverWorld) {
mc.player.swingHand(Hand.MAIN_HAND);
mc.player.updatePosition(blockPos.getX(), blockPos.up().getY(), blockPos.getZ());
} else if (BlockIsAnchor && IsNetherWorld) {
mc.player.swingHand(Hand.MAIN_HAND);
}
}
if ((BlockIsBed && IsOverWorld) || (BlockIsAnchor && IsNetherWorld)) {
event.cancel();
}
}
use of net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket in project BleachHack by BleachDrinker420.
the class AutoSteal method onSendPacket.
@BleachSubscribe
public void onSendPacket(EventPacket.Send event) {
if (event.getPacket() instanceof CloseHandledScreenC2SPacket) {
currentItems = null;
currentSyncId = -1;
}
if (event.getPacket() instanceof PlayerInteractBlockC2SPacket) {
BlockPos pos = ((PlayerInteractBlockC2SPacket) event.getPacket()).getBlockHitResult().getBlockPos();
if (mc.world.getBlockState(pos).getBlock() instanceof ChestBlock) {
currentPos = pos;
}
}
}
use of net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket 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.network.packet.c2s.play.PlayerInteractBlockC2SPacket in project meteor-crash-addon by AntiCope.
the class ContainerCrash method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE) == GLFW.GLFW_PRESS) {
toggle();
mc.player.closeHandledScreen();
}
BlockIterator.register(4, 4, ((blockPos, blockState) -> {
Block block = blockState.getBlock();
if (block instanceof AbstractChestBlock || block instanceof ShulkerBoxBlock) {
BlockHitResult bhr = new BlockHitResult(new Vec3d(blockPos.getX(), blockPos.getY(), blockPos.getZ()), Direction.DOWN, blockPos, false);
PlayerInteractBlockC2SPacket openPacket = new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, bhr);
for (int i = 0; i < amount.get(); i++) {
mc.getNetworkHandler().sendPacket(openPacket);
}
}
}));
}
use of net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket in project meteor-crash-addon by AntiCope.
the class TryUseCrash method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
BlockHitResult bhr = new BlockHitResult(new Vec3d(.5, .5, .5), Direction.DOWN, mc.player.getBlockPos(), false);
net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket packet = new PlayerInteractItemC2SPacket(Hand.MAIN_HAND);
PlayerInteractBlockC2SPacket packet1 = new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, bhr);
if (mc.getNetworkHandler() == null)
return;
for (int i = 0; i < packets.get(); i++) {
mc.getNetworkHandler().sendPacket(packet);
mc.getNetworkHandler().sendPacket(packet1);
}
}
Aggregations