Search in sources :

Example 6 with PlayerInteractBlockC2SPacket

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

the class Notebot method tuneBlock.

private boolean tuneBlock(BlockPos pos, int note) {
    if (mc.world == null || mc.player == null)
        return false;
    BlockState block = mc.world.getBlockState(pos);
    if (block.getBlock() != Blocks.NOTE_BLOCK) {
        offset++;
        stage = Stage.Set_Up;
        return true;
    }
    if (block.get(NoteBlock.NOTE).equals(note)) {
        currentNote++;
        stage = Stage.Set_Up;
        return true;
    }
    mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(mc.player.getPos(), rayTraceCheck(pos), pos, true)));
    mc.player.swingHand(Hand.MAIN_HAND);
    return true;
}
Also used : BlockState(net.minecraft.block.BlockState) BlockHitResult(net.minecraft.util.hit.BlockHitResult) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket)

Example 7 with PlayerInteractBlockC2SPacket

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

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

Example 8 with PlayerInteractBlockC2SPacket

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

the class ServerCrasher method onTick.

@Override
public void onTick() {
    for (int i = 0; i < 10; i++) {
        Random random = new Random();
        Vec3d pos = new Vec3d(random.nextInt(1000000 - 100000) + 100000, 255, random.nextInt(1000000 - 100000) + 100000);
        mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(pos, Direction.UP, new BlockPos(pos), false)));
    }
    super.onTick();
}
Also used : Random(java.util.Random) BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Vec3d(net.minecraft.util.math.Vec3d) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket)

Example 9 with PlayerInteractBlockC2SPacket

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

the class AutoCityPlus method placeCrystal.

private void placeCrystal(BlockPos placePos) {
    FindItemResult crystalSlot = InvUtils.findInHotbar(Items.END_CRYSTAL);
    Hand hand;
    if (mc.player.getOffHandStack().getItem() == Items.END_CRYSTAL) {
        hand = Hand.OFF_HAND;
    } else {
        hand = Hand.MAIN_HAND;
    }
    if (hand == Hand.MAIN_HAND && !crystalSlot.found())
        return;
    if (hand == Hand.MAIN_HAND)
        Wrapper.updateSlot(crystalSlot.slot());
    mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(hand, new BlockHitResult(mc.player.getPos(), getDirection(placePos), placePos, false)));
    Wrapper.swingHand(hand != Hand.MAIN_HAND);
}
Also used : FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Hand(net.minecraft.util.Hand) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket)

Example 10 with PlayerInteractBlockC2SPacket

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

the class Notebot method tuneBlock.

private boolean tuneBlock(BlockPos pos, int note) {
    if (mc.world == null || mc.player == null)
        return false;
    BlockState block = mc.world.getBlockState(pos);
    if (block.getBlock() != Blocks.NOTE_BLOCK) {
        offset++;
        stage = Stage.SetUp;
        return true;
    }
    if (block.get(NoteBlock.NOTE).equals(note)) {
        currentNote++;
        stage = Stage.SetUp;
        return true;
    }
    mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(mc.player.getPos(), rayTraceCheck(pos), pos, true)));
    mc.player.swingHand(Hand.MAIN_HAND);
    return true;
}
Also used : BlockState(net.minecraft.block.BlockState) BlockHitResult(net.minecraft.util.hit.BlockHitResult) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket)

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