Search in sources :

Example 16 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project KiwiClient by TangyKiwi.

the class Dupe method packetSent.

public static void packetSent(Packet<?> p) {
    if (shouldDupe() && p instanceof PlayerActionC2SPacket) {
        PlayerActionC2SPacket packet = (PlayerActionC2SPacket) p;
        if (packet.getAction() == PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK) {
            ScreenHandler var3 = MinecraftClient.getInstance().player.currentScreenHandler;
            if (var3 instanceof ShulkerBoxScreenHandler) {
                ShulkerBoxScreenHandler screenHandler = (ShulkerBoxScreenHandler) var3;
                Int2ObjectArrayMap<ItemStack> stack = new Int2ObjectArrayMap();
                stack.put(0, screenHandler.getSlot(0).getStack());
                ClickSlotC2SPacket cs = new ClickSlotC2SPacket(screenHandler.syncId, 0, 0, 0, SlotActionType.PICKUP, screenHandler.getSlot(0).getStack(), stack);
                MinecraftClient.getInstance().getNetworkHandler().sendPacket(cs);
                actuallyPullThrough = false;
                preDoDupe = false;
            }
        }
    }
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) ShulkerBoxScreenHandler(net.minecraft.screen.ShulkerBoxScreenHandler) Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap) ScreenHandler(net.minecraft.screen.ScreenHandler) ShulkerBoxScreenHandler(net.minecraft.screen.ShulkerBoxScreenHandler) ItemStack(net.minecraft.item.ItemStack) ClickSlotC2SPacket(net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket)

Example 17 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project meteor-client by MeteorDevelopment.

the class AntiBed method sendMinePackets.

private void sendMinePackets(BlockPos blockPos) {
    mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, Direction.UP));
    mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, Direction.UP));
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)

Example 18 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project meteor-client by MeteorDevelopment.

the class AutoCity method mine.

private void mine(BlockPos blockPos) {
    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));
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)

Example 19 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket 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;
}
Also used : ClientPlayerInteractionManager(net.minecraft.client.network.ClientPlayerInteractionManager) BlockState(net.minecraft.block.BlockState) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler)

Example 20 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project meteor-rejects by AntiCope.

the class AutoExtinguish method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    if (mc.world.getDimension().isRespawnAnchorWorking()) {
        if (doesWaterBucketWork) {
            warning("Water Buckets don't work in this dimension!");
            doesWaterBucketWork = false;
        }
    } else {
        if (!doesWaterBucketWork) {
            warning("Enabled Water Buckets!");
            doesWaterBucketWork = true;
        }
    }
    if (onGround.get() && !mc.player.isOnGround()) {
        return;
    }
    if (waterBucket.get() && doesWaterBucketWork) {
        if (hasPlacedWater) {
            final int slot = findSlot(Items.BUCKET);
            blockPos = mc.player.getBlockPos();
            place(slot);
            hasPlacedWater = false;
        } else if (!mc.player.hasStatusEffect(FIRE_RESISTANCE) && mc.player.isOnFire()) {
            blockPos = mc.player.getBlockPos();
            final int slot = findSlot(Items.WATER_BUCKET);
            if (mc.world.getBlockState(blockPos).getBlock() == Blocks.FIRE || mc.world.getBlockState(blockPos).getBlock() == Blocks.SOUL_FIRE) {
                float yaw = mc.gameRenderer.getCamera().getYaw() % 360;
                float pitch = mc.gameRenderer.getCamera().getPitch() % 360;
                if (center.get()) {
                    PlayerUtils.centerPlayer();
                }
                Rotations.rotate(yaw, 90);
                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));
                Rotations.rotate(yaw, pitch);
            }
            place(slot);
            hasPlacedWater = true;
        }
    }
    if (extinguish.get()) {
        AtomicInteger blocksPerTick = new AtomicInteger();
        BlockIterator.register(horizontalRadius.get(), verticalRadius.get(), (blockPos, blockState) -> {
            if (blocksPerTick.get() <= maxBlockPerTick.get()) {
                if (blockState.getBlock() == Blocks.FIRE || mc.world.getBlockState(blockPos).getBlock() == Blocks.SOUL_FIRE) {
                    extinguishFire(blockPos);
                    blocksPerTick.getAndIncrement();
                }
            }
        });
    }
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EventHandler(meteordevelopment.orbit.EventHandler)

Aggregations

PlayerActionC2SPacket (net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)32 BlockPos (net.minecraft.util.math.BlockPos)10 HandSwingC2SPacket (net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)6 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)4 EventTarget (dev.hypnotic.event.EventTarget)3 EventHandler (mathax.client.eventbus.EventHandler)3 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)3 Items (net.minecraft.item.Items)3 Hand (net.minecraft.util.Hand)3 Direction (net.minecraft.util.math.Direction)3 Vec3d (net.minecraft.util.math.Vec3d)3 Comparator (java.util.Comparator)2 BlockState (net.minecraft.block.BlockState)2 LivingEntity (net.minecraft.entity.LivingEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 ItemStack (net.minecraft.item.ItemStack)2 PlayerInteractBlockC2SPacket (net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket)2 UpdateSelectedSlotC2SPacket (net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket)2 BlockHitResult (net.minecraft.util.hit.BlockHitResult)2 Lists (com.google.common.collect.Lists)1