Search in sources :

Example 1 with PlayerActionC2SPacket

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

the class GhostCommand method execute.

private void execute(int radius) {
    ClientPlayNetworkHandler conn = mc.getNetworkHandler();
    if (conn == null)
        return;
    BlockPos pos = mc.player.getBlockPos();
    for (int dx = -radius; dx <= radius; dx++) for (int dy = -radius; dy <= radius; dy++) for (int dz = -radius; dz <= radius; dz++) {
        PlayerActionC2SPacket packet = new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, new BlockPos(pos.getX() + dx, pos.getY() + dy, pos.getZ() + dz), Direction.UP);
        conn.sendPacket(packet);
    }
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) BlockPos(net.minecraft.util.math.BlockPos) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler)

Example 2 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project BleachHack by BleachDrinker420.

the class AutoTool method onPacketSend.

@BleachSubscribe
public void onPacketSend(EventPacket.Send event) {
    if (event.getPacket() instanceof PlayerActionC2SPacket) {
        PlayerActionC2SPacket p = (PlayerActionC2SPacket) event.getPacket();
        if (p.getAction() == Action.START_DESTROY_BLOCK) {
            if (mc.player.isCreative() || mc.player.isSpectator())
                return;
            queueSlot = -1;
            lastSlot = mc.player.getInventory().selectedSlot;
            int slot = getBestSlot(p.getPos());
            if (slot != mc.player.getInventory().selectedSlot) {
                if (slot < 9) {
                    mc.player.getInventory().selectedSlot = slot;
                    mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(slot));
                } else if (mc.player.playerScreenHandler == mc.player.currentScreenHandler) {
                    boolean itemInHand = !mc.player.getInventory().getMainHandStack().isEmpty();
                    mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, slot, 0, SlotActionType.PICKUP, mc.player);
                    mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 36 + mc.player.getInventory().selectedSlot, 0, SlotActionType.PICKUP, mc.player);
                    if (itemInHand)
                        mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, slot, 0, SlotActionType.PICKUP, mc.player);
                }
            }
        } else if (p.getAction() == Action.STOP_DESTROY_BLOCK) {
            if (getSetting(1).asToggle().getState()) {
                ItemStack handSlot = mc.player.getMainHandStack();
                if (getSetting(0).asToggle().getState() && handSlot.isDamageable() && handSlot.getMaxDamage() - handSlot.getDamage() < 2 && queueSlot == mc.player.getInventory().selectedSlot) {
                    queueSlot = mc.player.getInventory().selectedSlot == 0 ? 1 : mc.player.getInventory().selectedSlot - 1;
                } else if (lastSlot >= 0 && lastSlot <= 8 && lastSlot != mc.player.getInventory().selectedSlot) {
                    queueSlot = lastSlot;
                }
            }
        }
    }
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) UpdateSelectedSlotC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket) ItemStack(net.minecraft.item.ItemStack) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 3 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project BleachHack by BleachDrinker420.

the class AutoEXP method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (mc.player.currentScreenHandler != mc.player.playerScreenHandler)
        return;
    int xpSlot = InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.EXPERIENCE_BOTTLE);
    if (xpSlot == -1)
        return;
    int damage = getSetting(3).asSlider().getValueInt();
    double target = getSetting(4).asSlider().getValue();
    if (slot != -1) {
        if (xpNeeded == 0) {
            ItemStack item = slot < 45 ? mc.player.currentScreenHandler.getSlot(slot).getStack() : mc.player.getOffHandStack();
            if (item.isDamaged() && item.getMaxDamage() - item.getDamage() <= damage)
                return;
            for (int i = 1; i <= 4; i++) {
                ItemStack stack = mc.player.currentScreenHandler.getSlot(i).getStack();
                if (!stack.isEmpty()) {
                    for (int j = 5; j <= 8; j++) {
                        if (mc.player.currentScreenHandler.getSlot(j).canInsert(stack)) {
                            mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player);
                            mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, j, 0, SlotActionType.PICKUP, mc.player);
                            return;
                        }
                    }
                }
            }
            if (slot >= 46) {
                if (slot - 46 != mc.player.getInventory().selectedSlot) {
                    mc.player.getInventory().selectedSlot = slot - 46;
                    mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(slot - 46));
                }
                mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN));
            }
            delay = 0;
            slot = -1;
            return;
        }
        for (int i = 5; i <= 8; i++) {
            if (i != slot && EnchantmentHelper.getLevel(Enchantments.MENDING, mc.player.currentScreenHandler.getSlot(i).getStack()) != 0) {
                for (int j = 1; j <= 4; j++) {
                    ItemStack craftingStack = mc.player.currentScreenHandler.getSlot(j).getStack();
                    if (!craftingStack.isDamageable()) {
                        mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player);
                        mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, j, 0, SlotActionType.PICKUP, mc.player);
                        if (!craftingStack.isEmpty())
                            mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, j, 1, SlotActionType.THROW, mc.player);
                        return;
                    }
                }
            }
        }
        if (slot > 8 && slot < 45) {
            if (slot - 36 != mc.player.getInventory().selectedSlot) {
                mc.player.getInventory().selectedSlot = slot - 36;
                mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(slot - 36));
            }
            mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN));
            // hack
            slot += 10;
            return;
        }
        delay++;
        if (delay >= getSetting(6).asSlider().getValueInt()) {
            delay = 0;
            int toThrow = Math.min(getSetting(5).asSlider().getValueInt(), xpNeeded);
            if (toThrow != 0) {
                mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(mc.player.getYaw(), 90, mc.player.isOnGround()));
                for (int t = 0; t < toThrow; t++) {
                    if (InventoryUtils.selectSlot(false, i -> mc.player.getInventory().getStack(i).getItem() == Items.EXPERIENCE_BOTTLE) == Hand.MAIN_HAND) {
                        // Trying to use without bruh
                        mc.player.networkHandler.sendPacket(new PlayerInteractItemC2SPacket(Hand.MAIN_HAND));
                        ItemStack itemStack2 = mc.player.getMainHandStack().use(mc.world, mc.player, Hand.MAIN_HAND).getValue();
                        if (itemStack2 != mc.player.getMainHandStack()) {
                            mc.player.setStackInHand(Hand.MAIN_HAND, itemStack2);
                        }
                        xpNeeded--;
                    }
                }
            }
        }
        return;
    }
    IntSet slots = new IntArraySet();
    if (getSetting(0).asToggle().getState()) {
        slots.add(5);
        slots.add(6);
        slots.add(7);
        slots.add(8);
    }
    if (getSetting(1).asToggle().getState())
        slots.add(36 + mc.player.getInventory().selectedSlot);
    if (getSetting(2).asToggle().getState())
        slots.add(45);
    if (getSetting(0).asToggle().getState()) {
        for (int s : slots) {
            ItemStack item = mc.player.currentScreenHandler.getSlot(s).getStack();
            if (item.isDamageable() && item.getMaxDamage() - item.getDamage() <= damage && item.getMaxDamage() - item.getDamage() < item.getMaxDamage() * target) {
                slot = s;
                xpNeeded = (int) Math.ceil((item.getMaxDamage() * target - (item.getMaxDamage() - item.getDamage())) / 14d);
                return;
            }
        }
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) SettingSlider(org.bleachhack.setting.module.SettingSlider) CloseHandledScreenC2SPacket(net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket) ModuleCategory(org.bleachhack.module.ModuleCategory) PlayerInteractItemC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket) InventoryUtils(org.bleachhack.util.InventoryUtils) IntArraySet(it.unimi.dsi.fastutil.ints.IntArraySet) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) EnchantmentHelper(net.minecraft.enchantment.EnchantmentHelper) Module(org.bleachhack.module.Module) Action(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.Action) Direction(net.minecraft.util.math.Direction) ItemStack(net.minecraft.item.ItemStack) UpdateSelectedSlotC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket) Enchantments(net.minecraft.enchantment.Enchantments) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) IntSet(it.unimi.dsi.fastutil.ints.IntSet) Hand(net.minecraft.util.Hand) SettingToggle(org.bleachhack.setting.module.SettingToggle) SlotActionType(net.minecraft.screen.slot.SlotActionType) EventPacket(org.bleachhack.event.events.EventPacket) EventTick(org.bleachhack.event.events.EventTick) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) IntSet(it.unimi.dsi.fastutil.ints.IntSet) UpdateSelectedSlotC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) PlayerInteractItemC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket) IntArraySet(it.unimi.dsi.fastutil.ints.IntArraySet) ItemStack(net.minecraft.item.ItemStack) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 4 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project SeedcrackerX by 19MisterX98.

the class BlockUpdateQueue method tick.

public void tick() {
    if (blocksAndAction.isEmpty())
        return;
    Pair<Thread, ArrayList<BlockPos>> current = blocksAndAction.peek();
    ArrayList<BlockPos> currentBlocks = current.getRight();
    for (int i = 0; i < 5; i++) {
        if (currentBlocks.isEmpty()) {
            current.getLeft().start();
            blocksAndAction.remove();
            if (blocksAndAction.isEmpty()) {
                return;
            } else {
                current = blocksAndAction.peek();
                currentBlocks = current.getRight();
            }
        }
        if (MinecraftClient.getInstance().getNetworkHandler() == null) {
            blocksAndAction.clear();
            return;
        }
        PlayerActionC2SPacket p = new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, currentBlocks.remove(0), Direction.DOWN);
        MinecraftClient.getInstance().getNetworkHandler().sendPacket(p);
    }
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with PlayerActionC2SPacket

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

the class AutoCityPlus method mine.

private void mine(BlockPos blockPos) {
    if (!instant.get())
        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)

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