use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project Client by MatHax.
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 orion by AntiCope.
the class SurroundPlus method onTick.
@EventHandler
private void onTick(TickEvent.Pre event) {
int bpt = 0;
if ((disableJump.get() && (mc.options.jumpKey.isPressed() || mc.player.input.jumping)) || (disableYchange.get() && mc.player.prevY < mc.player.getY())) {
toggle();
return;
}
if (groundOnly.get() && !mc.player.isOnGround())
return;
if (sneakOnly.get() && !mc.options.sneakKey.isPressed())
return;
if (BlockHelper.isVecComplete(getSurrDesign())) {
if (disableAfter.get()) {
info("Surround Complete.");
toggle();
}
} else {
BlockPos ppos = mc.player.getBlockPos();
for (Vec3d b : getSurrDesign()) {
if (bpt >= blockPerTick.get())
return;
BlockPos bb = ppos.add(b.x, b.y, b.z);
if (BlockHelper.getBlock(bb) == Blocks.AIR) {
if (placeInside.get()) {
BlockUtils.place(bb, InvUtils.findInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem()))), rotation.get(), 100, false);
} else {
BlockUtils.place(bb, InvUtils.findInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem()))), rotation.get(), 100, true);
}
bpt++;
}
}
}
if (protect.get()) {
for (Entity entity : mc.world.getEntities()) {
if (entity instanceof EndCrystalEntity) {
BlockPos crystalPos = entity.getBlockPos();
if (isDangerousCrystal(crystalPos)) {
mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.attack(entity, mc.player.isSneaking()));
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
return;
}
}
}
}
}
use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project EdenClient by HahaOO7.
the class Nuker method onTick.
private void onTick(ClientPlayerEntity player) {
if (!enabled)
return;
ClientPlayNetworkHandler nh = MinecraftClient.getInstance().getNetworkHandler();
BlockState air = Blocks.AIR.getDefaultState();
ClientPlayerInteractionManager im = MinecraftClient.getInstance().interactionManager;
if (im == null)
return;
if (nh == null)
return;
if (limit > 1) {
List<BlockPos> minableBlocks = getInstantMinableBlocksInRange(player);
if (!minableBlocks.isEmpty()) {
target = null;
minableBlocks.forEach(p -> {
nh.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, p, getHitDirectionForBlock(player, p)));
nh.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, p, getHitDirectionForBlock(player, p)));
player.clientWorld.setBlockState(p, air);
});
nh.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
return;
}
}
if (target == null || Vec3d.ofCenter(target).distanceTo(player.getEyePos()) > distance)
findTarget(player);
if (target == null)
return;
Direction dir = getHitDirectionForBlock(player, target);
if (im.updateBlockBreakingProgress(target, dir))
nh.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
else
target = null;
}
use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project Client by MatHax.
the class BlockUtils method placePrinter.
private static void placePrinter(BlockHitResult blockHitResult, boolean swing) {
if (mc.player == null || mc.interactionManager == null || mc.getNetworkHandler() == null)
return;
boolean wasSneaking = mc.player.input.sneaking;
mc.player.input.sneaking = false;
ActionResult result = mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, blockHitResult);
if (result.shouldSwingHand()) {
if (swing)
mc.player.swingHand(Hand.MAIN_HAND);
else
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
}
mc.player.input.sneaking = wasSneaking;
}
use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project Client by MatHax.
the class BlockUtils method placeEnhanced.
private static void placeEnhanced(int n, Vec3d vec3d, Hand hand, Direction direction, BlockPos blockPos, boolean bl, boolean bl2, boolean bl3) {
int n2 = mc.player.getInventory().selectedSlot;
if (bl2)
mc.player.getInventory().selectedSlot = n;
boolean bl4 = mc.player.input.sneaking;
mc.player.input.sneaking = false;
mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(vec3d, direction, blockPos, false));
if (bl)
mc.player.swingHand(hand);
else
mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand));
mc.player.input.sneaking = bl4;
if (bl3)
mc.player.getInventory().selectedSlot = n2;
}
Aggregations