Search in sources :

Example 6 with HandSwingC2SPacket

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;
}
Also used : ActionResult(net.minecraft.util.ActionResult) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)

Example 7 with HandSwingC2SPacket

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;
                }
            }
        }
    }
}
Also used : BlockUtils(meteordevelopment.meteorclient.utils.world.BlockUtils) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) ShapeMode(meteordevelopment.meteorclient.renderer.ShapeMode) meteordevelopment.meteorclient.settings(meteordevelopment.meteorclient.settings) BlockHelper(me.ghosttypes.orion.utils.world.BlockHelper) BlockPos(net.minecraft.util.math.BlockPos) SettingColor(meteordevelopment.meteorclient.utils.render.color.SettingColor) Blocks(net.minecraft.block.Blocks) TickEvent(meteordevelopment.meteorclient.events.world.TickEvent) ArrayList(java.util.ArrayList) List(java.util.List) Module(meteordevelopment.meteorclient.systems.modules.Module) PlayerUtils(meteordevelopment.meteorclient.utils.player.PlayerUtils) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) InvUtils(meteordevelopment.meteorclient.utils.player.InvUtils) PlayerInteractEntityC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket) Orion(me.ghosttypes.orion.Orion) Hand(net.minecraft.util.Hand) EventHandler(meteordevelopment.orbit.EventHandler) Collections(java.util.Collections) Render3DEvent(meteordevelopment.meteorclient.events.render.Render3DEvent) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) EventHandler(meteordevelopment.orbit.EventHandler)

Example 8 with HandSwingC2SPacket

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;
}
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 9 with HandSwingC2SPacket

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;
}
Also used : ActionResult(net.minecraft.util.ActionResult) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)

Example 10 with HandSwingC2SPacket

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;
}
Also used : HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) BlockHitResult(net.minecraft.util.hit.BlockHitResult)

Aggregations

HandSwingC2SPacket (net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)16 PlayerActionC2SPacket (net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)6 ActionResult (net.minecraft.util.ActionResult)4 BlockHitResult (net.minecraft.util.hit.BlockHitResult)4 BlockPos (net.minecraft.util.math.BlockPos)4 Vec3d (net.minecraft.util.math.Vec3d)4 Hand (net.minecraft.util.Hand)3 Direction (net.minecraft.util.math.Direction)3 Scaffold (dev.hypnotic.module.player.Scaffold)2 List (java.util.List)2 Entity (net.minecraft.entity.Entity)2 PlayerMoveC2SPacket (net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket)2 Lists (com.google.common.collect.Lists)1 FriendManager (dev.hypnotic.config.friends.FriendManager)1 EventTarget (dev.hypnotic.event.EventTarget)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