Search in sources :

Example 11 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Client by MatHax.

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(mathax.client.eventbus.EventHandler)

Example 12 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Hypnotic-Client by Hypnotic-Development.

the class Disabler method onSendPacket.

@EventTarget
public void onSendPacket(EventSendPacket event) {
    if (mode.is("Verus")) {
        if (event.getPacket() instanceof PlayerInteractEntityC2SPacket) {
            event.setCancelled(true);
        }
        if (event.getPacket() instanceof PlayerActionC2SPacket) {
            mc.player.networkHandler.sendPacket(new PlayerInputC2SPacket(0, 0, false, false));
        }
        if (event.getPacket() instanceof PlayerInputC2SPacket) {
            final PlayerInputC2SPacket packet = (PlayerInputC2SPacket) event.getPacket();
            // mc.player.networkHandler.sendPacket(new PlayerInputC2SPacket(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, mc.player.age % 2 == 0, mc.player.age % 2 != 0));
            ((PlayerInputC2SPacketAccessor) packet).setForward(Float.POSITIVE_INFINITY);
            ((PlayerInputC2SPacketAccessor) packet).setSideways(Float.POSITIVE_INFINITY);
            ((PlayerInputC2SPacketAccessor) packet).setJumping(mc.player.age % 2 == 0);
            ((PlayerInputC2SPacketAccessor) packet).setSneaking(mc.player.age % 2 != 0);
        }
    }
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) PlayerInputC2SPacketAccessor(dev.hypnotic.mixin.PlayerInputC2SPacketAccessor) PlayerInputC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInputC2SPacket) PlayerInteractEntityC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket) EventTarget(dev.hypnotic.event.EventTarget)

Example 13 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Hypnotic-Client by Hypnotic-Development.

the class OffhandCrash method onTick.

@Override
public void onTick() {
    if (crash.isEnabled()) {
        Channel channel = ((ClientConnectionAccessor) mc.player.networkHandler.getConnection()).getChannel();
        for (int i = 0; i < speed.getValue(); i++) {
            channel.write(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, new BlockPos(0, 0, 0), Direction.UP));
        }
        channel.flush();
    }
    super.onTick();
}
Also used : ClientConnectionAccessor(dev.hypnotic.mixin.ClientConnectionAccessor) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) Channel(io.netty.channel.Channel) BlockPos(net.minecraft.util.math.BlockPos)

Example 14 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Hypnotic-Client by Hypnotic-Development.

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 15 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project orion by AntiCope.

the class AutomationUtils method doPacketMine.

public static void doPacketMine(BlockPos targetPos) {
    mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, targetPos, Direction.UP));
    Wrapper.swingHand(false);
    mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, targetPos, Direction.UP));
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)

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