use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project BleachHack by BleachDrinker420.
the class WorldUtils method placeBlock.
public static boolean placeBlock(BlockPos pos, int slot, int rotateMode, boolean forceLegit, boolean airPlace, boolean swingHand) {
if (!mc.world.isInBuildLimit(pos) || !isBlockEmpty(pos))
return false;
for (Direction d : Direction.values()) {
if (!mc.world.isInBuildLimit(pos.offset(d)))
continue;
Block neighborBlock = mc.world.getBlockState(pos.offset(d)).getBlock();
if (!airPlace && neighborBlock.getDefaultState().getMaterial().isReplaceable())
continue;
Vec3d vec = getLegitLookPos(pos.offset(d), d.getOpposite(), true, 5);
if (vec == null) {
if (forceLegit) {
continue;
}
vec = getLegitLookPos(pos.offset(d), d.getOpposite(), false, 5);
if (vec == null) {
continue;
}
}
int prevSlot = mc.player.getInventory().selectedSlot;
Hand hand = InventoryUtils.selectSlot(slot);
if (hand == null) {
return false;
}
if (rotateMode == 1) {
facePosPacket(vec.x, vec.y, vec.z);
} else if (rotateMode == 2) {
facePos(vec.x, vec.y, vec.z);
}
if (RIGHTCLICKABLE_BLOCKS.contains(neighborBlock)) {
mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.PRESS_SHIFT_KEY));
}
if (swingHand) {
mc.player.swingHand(hand);
} else {
mc.player.networkHandler.sendPacket(new HandSwingC2SPacket(hand));
}
mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(Vec3d.of(pos), airPlace ? d : d.getOpposite(), airPlace ? pos : pos.offset(d), false));
if (RIGHTCLICKABLE_BLOCKS.contains(neighborBlock))
mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.RELEASE_SHIFT_KEY));
mc.player.getInventory().selectedSlot = prevSlot;
return true;
}
return false;
}
use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project meteor-client by MeteorDevelopment.
the class BlockUtils method breakBlock.
/**
* Needs to be used in {@link TickEvent.Pre}
*/
public static boolean breakBlock(BlockPos blockPos, boolean swing) {
if (!canBreak(blockPos, mc.world.getBlockState(blockPos)))
return false;
// Creating new instance of block pos because minecraft assigns the parameter to a field and we don't want it to change when it has been stored in a field somewhere
BlockPos pos = blockPos instanceof BlockPos.Mutable ? new BlockPos(blockPos) : blockPos;
if (mc.interactionManager.isBreakingBlock())
mc.interactionManager.updateBlockBreakingProgress(pos, Direction.UP);
else
mc.interactionManager.attackBlock(pos, Direction.UP);
if (swing)
mc.player.swingHand(Hand.MAIN_HAND);
else
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
breaking = true;
breakingThisTick = true;
return true;
}
use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project meteor-client by MeteorDevelopment.
the class BlockUtils method place.
private static void place(BlockHitResult blockHitResult, Hand hand, boolean swing) {
boolean wasSneaking = mc.player.input.sneaking;
mc.player.input.sneaking = false;
ActionResult result = mc.interactionManager.interactBlock(mc.player, mc.world, hand, blockHitResult);
if (result.shouldSwingHand()) {
if (swing)
mc.player.swingHand(hand);
else
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand));
}
mc.player.input.sneaking = wasSneaking;
}
use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project meteor-client by MeteorDevelopment.
the class AntiBed method sendStopPackets.
private void sendStopPackets(BlockPos blockPos) {
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, blockPos, Direction.UP));
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
}
use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project Client by MatHax.
the class TNTAura method mine.
public void mine(BlockPos blockPos, FindItemResult item) {
if (breakMode.get() == Mode.Normal) {
InvUtils.swap(item.slot(), false);
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, Direction.UP));
mc.player.swingHand(Hand.MAIN_HAND);
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, Direction.UP));
}
if (breakMode.get() == Mode.Instant) {
InvUtils.swap(item.slot(), false);
if (!startBreak) {
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, Direction.UP));
startBreak = true;
}
if (rotate.get())
Rotations.rotate(Rotations.getYaw(blockPos), Rotations.getPitch(blockPos), () -> mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, direction)));
else
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, direction));
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
}
}
Aggregations