Search in sources :

Example 1 with PlayerInteractBlockC2SPacket

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();
    }
}
Also used : BedBlock(net.minecraft.block.BedBlock) BlockPos(net.minecraft.util.math.BlockPos) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) EventHandler(meteordevelopment.orbit.EventHandler)

Example 2 with PlayerInteractBlockC2SPacket

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;
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) ChestBlock(net.minecraft.block.ChestBlock) CloseHandledScreenC2SPacket(net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 3 with PlayerInteractBlockC2SPacket

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;
        }
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) ModuleCategory(org.bleachhack.module.ModuleCategory) EventInteract(org.bleachhack.event.events.EventInteract) Box(net.minecraft.util.math.Box) EventWorldRender(org.bleachhack.event.events.EventWorldRender) InventoryUtils(org.bleachhack.util.InventoryUtils) PistonBlock(net.minecraft.block.PistonBlock) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Renderer(org.bleachhack.util.render.Renderer) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) Module(org.bleachhack.module.Module) QuadColor(org.bleachhack.util.render.color.QuadColor) Direction(net.minecraft.util.math.Direction) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) Vec3d(net.minecraft.util.math.Vec3d) BleachLogger(org.bleachhack.util.BleachLogger) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) Hand(net.minecraft.util.Hand) EventTick(org.bleachhack.event.events.EventTick) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) Box(net.minecraft.util.math.Box) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Hand(net.minecraft.util.Hand) Vec3d(net.minecraft.util.math.Vec3d) PistonBlock(net.minecraft.block.PistonBlock) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 4 with PlayerInteractBlockC2SPacket

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);
            }
        }
    }));
}
Also used : BlockIterator(meteordevelopment.meteorclient.utils.world.BlockIterator) Setting(meteordevelopment.meteorclient.settings.Setting) CrashAddon(widecat.meteorcrashaddon.CrashAddon) AbstractInventoryScreen(net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen) GameLeftEvent(meteordevelopment.meteorclient.events.game.GameLeftEvent) PlaySoundEvent(meteordevelopment.meteorclient.events.world.PlaySoundEvent) BlockHitResult(net.minecraft.util.hit.BlockHitResult) IntSetting(meteordevelopment.meteorclient.settings.IntSetting) SettingGroup(meteordevelopment.meteorclient.settings.SettingGroup) GLFW(org.lwjgl.glfw.GLFW) TickEvent(meteordevelopment.meteorclient.events.world.TickEvent) Direction(net.minecraft.util.math.Direction) OpenScreenEvent(meteordevelopment.meteorclient.events.game.OpenScreenEvent) Module(meteordevelopment.meteorclient.systems.modules.Module) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) Vec3d(net.minecraft.util.math.Vec3d) BoolSetting(meteordevelopment.meteorclient.settings.BoolSetting) net.minecraft.block(net.minecraft.block) Hand(net.minecraft.util.Hand) EventHandler(meteordevelopment.orbit.EventHandler) HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Vec3d(net.minecraft.util.math.Vec3d) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) EventHandler(meteordevelopment.orbit.EventHandler)

Example 5 with PlayerInteractBlockC2SPacket

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);
    }
}
Also used : PlayerInteractItemC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket) PlayerInteractItemC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Vec3d(net.minecraft.util.math.Vec3d) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) EventHandler(meteordevelopment.orbit.EventHandler)

Aggregations

PlayerInteractBlockC2SPacket (net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket)13 BlockHitResult (net.minecraft.util.hit.BlockHitResult)10 BlockPos (net.minecraft.util.math.BlockPos)7 Vec3d (net.minecraft.util.math.Vec3d)6 Hand (net.minecraft.util.Hand)4 EventHandler (meteordevelopment.orbit.EventHandler)3 EventTarget (dev.hypnotic.event.EventTarget)2 Random (java.util.Random)2 BedBlock (net.minecraft.block.BedBlock)2 BlockState (net.minecraft.block.BlockState)2 PlayerActionC2SPacket (net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)2 Direction (net.minecraft.util.math.Direction)2 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)2 Lists (com.google.common.collect.Lists)1 FriendManager (dev.hypnotic.config.friends.FriendManager)1 EventMotionUpdate (dev.hypnotic.event.events.EventMotionUpdate)1 EventRender3D (dev.hypnotic.event.events.EventRender3D)1 EventSendPacket (dev.hypnotic.event.events.EventSendPacket)1 PlayerMoveC2SPacketAccessor (dev.hypnotic.mixin.PlayerMoveC2SPacketAccessor)1 Category (dev.hypnotic.module.Category)1