net.minecraft.network.play.client.C09PacketHeldItemChange Java Examples

The following examples show how to use net.minecraft.network.play.client.C09PacketHeldItemChange. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Scaffold.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Disable scaffold module
 */
@Override
public void onDisable() {
    if (mc.thePlayer == null) return;

    if (!GameSettings.isKeyDown(mc.gameSettings.keyBindSneak)) {
        mc.gameSettings.keyBindSneak.pressed = false;

        if (eagleSneaking)
            mc.getNetHandler().addToSendQueue(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.STOP_SNEAKING));
    }

    if (!GameSettings.isKeyDown(mc.gameSettings.keyBindRight))
        mc.gameSettings.keyBindRight.pressed = false;

    if (!GameSettings.isKeyDown(mc.gameSettings.keyBindLeft))
        mc.gameSettings.keyBindLeft.pressed = false;

    lockRotation = null;
    mc.timer.timerSpeed = 1F;
    shouldGoDown = false;

    if (slot != mc.thePlayer.inventory.currentItem)
        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
}
 
Example #2
Source File: MineplexGround.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMotion() {
    if(!MovementUtils.isMoving() || !mc.thePlayer.onGround || mc.thePlayer.inventory.getCurrentItem() == null || mc.thePlayer.isUsingItem())
        return;

    spoofSlot = false;

    for(int i = 36; i < 45; i++) {
        final ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();

        if(itemStack != null) continue;

        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(i - 36));
        spoofSlot = true;
        break;
    }
}
 
Example #3
Source File: MineplexGround.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdate() {
    if(!MovementUtils.isMoving() || !mc.thePlayer.onGround || mc.thePlayer.isUsingItem()) {
        speed = 0F;
        return;
    }

    if(!spoofSlot && mc.thePlayer.inventory.getCurrentItem() != null) {
        ClientUtils.displayChatMessage("§8[§c§lMineplex§aSpeed§8] §cYou need one empty slot.");
        return;
    }

    final BlockPos blockPos = new BlockPos(mc.thePlayer.posX, mc.thePlayer.getEntityBoundingBox().minY - 1, mc.thePlayer.posZ);
    final Vec3 vec = new Vec3(blockPos).addVector(0.4F, 0.4F, 0.4F).add(new Vec3(EnumFacing.UP.getDirectionVec()));
    mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, null, blockPos, EnumFacing.UP, new Vec3(vec.xCoord * 0.4F, vec.yCoord * 0.4F, vec.zCoord * 0.4F));

    final float targetSpeed = ((Speed) LiquidBounce.moduleManager.getModule(Speed.class)).mineplexGroundSpeedValue.get();

    if(targetSpeed > speed) speed += targetSpeed / 8;
    if(speed >= targetSpeed) speed = targetSpeed;

    MovementUtils.strafe(speed);

    if(!spoofSlot)
        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
}
 
Example #4
Source File: FastEat.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onTicks() {
    if (this.isActive() && Mouse.getEventButton() == 1 && Mouse.isButtonDown(1)) {
        if (this.mode == 1) {
            int[] ignoredBlockIds = new int[]{23, 25, 26, 54, 58, 61, 62, 64, 69, 71, 77, 84, 92, 96, 107, 116, 117, 118, 120, 130, 137, 143, 145, 146, 149, 150, 154, 158};
            for (int id : ignoredBlockIds) {
                if (Block.getIdFromBlock(Wrapper.INSTANCE.world().getBlock(Wrapper.INSTANCE.mc().objectMouseOver.blockX, Wrapper.INSTANCE.mc().objectMouseOver.blockY, Wrapper.INSTANCE.mc().objectMouseOver.blockZ)) != id) {
                    continue;
                }
                return;
            }
        }
        if (Wrapper.INSTANCE.player().inventory.getCurrentItem() == null) {
            return;
        }
        Item item = Wrapper.INSTANCE.player().inventory.getCurrentItem().getItem();
        if (Wrapper.INSTANCE.player().onGround && (item instanceof ItemFood || item instanceof ItemPotion) && (Wrapper.INSTANCE.player().getFoodStats().needFood() || item instanceof ItemPotion || item instanceof ItemAppleGold)) {
            Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C09PacketHeldItemChange(Wrapper.INSTANCE.player().inventory.currentItem));
            for (int i = 0; i < 1000; ++i) {
                Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C03PacketPlayer(false));
            }
            Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C07PacketPlayerDigging(5, 0, 0, 0, 255));
        }
    }
}
 
Example #5
Source File: Tower.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDisable() {
    if (mc.thePlayer == null) return;

    mc.timer.timerSpeed = 1F;
    lockRotation = null;

    if (slot != mc.thePlayer.inventory.currentItem)
        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
}
 
Example #6
Source File: Tower.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Place target block
 */
private void place() {
    if(placeInfo == null)
        return;

    // AutoBlock
    int blockSlot = -1;
    ItemStack itemStack = mc.thePlayer.getHeldItem();

    if(mc.thePlayer.getHeldItem() == null || !(mc.thePlayer.getHeldItem().getItem() instanceof ItemBlock)) {
        if (!autoBlockValue.get())
            return;

        blockSlot = InventoryUtils.findAutoBlockBlock();

        if (blockSlot == -1)
            return;

        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(blockSlot - 36));
        itemStack = mc.thePlayer.inventoryContainer.getSlot(blockSlot).getStack();
    }

    // Place block
    if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, itemStack, this.placeInfo.getBlockPos(), placeInfo.getEnumFacing(), placeInfo.getVec3())) {
        if (swingValue.get())
            mc.thePlayer.swingItem();
        else
            mc.getNetHandler().addToSendQueue(new C0APacketAnimation());
    }

    this.placeInfo = null;

    // Switch back to old slot when using auto block
    if (!stayAutoBlock.get() && blockSlot >= 0)
        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
}
 
Example #7
Source File: AutoArmor.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Shift+Left clicks the specified item
 *
 * @param item        Slot of the item to click
 * @param isArmorSlot
 * @return True if it is unable to move the item
 */
private boolean move(int item, boolean isArmorSlot) {
    if (!isArmorSlot && item < 9 && hotbarValue.get() && !(mc.currentScreen instanceof GuiInventory)) {
        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(item));
        mc.getNetHandler().addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventoryContainer.getSlot(item).getStack()));
        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));

        delay = TimeUtils.randomDelay(minDelayValue.get(), maxDelayValue.get());

        return true;
    } else if (!(noMoveValue.get() && MovementUtils.isMoving()) && (!invOpenValue.get() || mc.currentScreen instanceof GuiInventory) && item != -1) {
        final boolean openInventory = simulateInventory.get() && !(mc.currentScreen instanceof GuiInventory);

        if (openInventory)
            mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT));

        mc.playerController.windowClick(mc.thePlayer.inventoryContainer.windowId, isArmorSlot ? item : (item < 9 ? item + 36 : item), 0, 1, mc.thePlayer);

        delay = TimeUtils.randomDelay(minDelayValue.get(), maxDelayValue.get());

        if (openInventory)
            mc.getNetHandler().addToSendQueue(new C0DPacketCloseWindow());

        return true;
    }

    return false;
}
 
Example #8
Source File: Scaffold.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@EventTarget
public void onPacket(final PacketEvent event) {
    if (mc.thePlayer == null)
        return;

    final Packet<?> packet = event.getPacket();

    // AutoBlock
    if (packet instanceof C09PacketHeldItemChange) {
        final C09PacketHeldItemChange packetHeldItemChange = (C09PacketHeldItemChange) packet;

        slot = packetHeldItemChange.getSlotId();
    }
}
 
Example #9
Source File: Scaffold.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Place target block
 */
private void place() {
    if (targetPlace == null) {
        if (placeableDelay.get())
            delayTimer.reset();
        return;
    }

    if (!delayTimer.hasTimePassed(delay) || (sameYValue.get() && launchY - 1 != (int) targetPlace.getVec3().yCoord))
        return;

    int blockSlot = -1;
    ItemStack itemStack = mc.thePlayer.getHeldItem();

    if (mc.thePlayer.getHeldItem() == null || !(mc.thePlayer.getHeldItem().getItem() instanceof ItemBlock) || mc.thePlayer.getHeldItem().stackSize <= 0) {
        if (!autoBlockValue.get())
            return;

        blockSlot = InventoryUtils.findAutoBlockBlock();

        if (blockSlot == -1)
            return;

        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(blockSlot - 36));
        itemStack = mc.thePlayer.inventoryContainer.getSlot(blockSlot).getStack();
    }


    if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, itemStack, targetPlace.getBlockPos(), targetPlace.getEnumFacing(), targetPlace.getVec3())) {
        delayTimer.reset();
        delay = TimeUtils.randomDelay(minDelayValue.get(), maxDelayValue.get());

        if (mc.thePlayer.onGround) {
            final float modifier = speedModifierValue.get();

            mc.thePlayer.motionX *= modifier;
            mc.thePlayer.motionZ *= modifier;
        }

        if (swingValue.get())
            mc.thePlayer.swingItem();
        else
            mc.getNetHandler().addToSendQueue(new C0APacketAnimation());
    }

    if (!stayAutoBlock.get() && blockSlot >= 0)
        mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));

    // Reset
    this.targetPlace = null;
}
 
Example #10
Source File: Tower.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@EventTarget
public void onPacket(final PacketEvent event) {
    if(mc.thePlayer == null)
        return;

    final Packet<?> packet = event.getPacket();

    if(packet instanceof C09PacketHeldItemChange) {
        final C09PacketHeldItemChange packetHeldItemChange = (C09PacketHeldItemChange) packet;

        slot = packetHeldItemChange.getSlotId();
    }
}
 
Example #11
Source File: NoFall.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@EventTarget
private void onMotionUpdate(MotionEvent event) {
    if (!modeValue.get().equalsIgnoreCase("MLG"))
        return;

    if (event.getEventState() == EventState.PRE) {
        currentMlgRotation = null;
        mlgTimer.update();

        if (!mlgTimer.hasTimePassed(10))
            return;

        if (mc.thePlayer.fallDistance > minFallDistance.get()) {
            FallingPlayer fallingPlayer = new FallingPlayer(
                    mc.thePlayer.posX,
                    mc.thePlayer.posY,
                    mc.thePlayer.posZ,
                    mc.thePlayer.motionX,
                    mc.thePlayer.motionY,
                    mc.thePlayer.motionZ,
                    mc.thePlayer.rotationYaw,
                    mc.thePlayer.moveStrafing,
                    mc.thePlayer.moveForward
            );

            double maxDist = mc.playerController.getBlockReachDistance() + 1.5;

            FallingPlayer.CollisionResult collision = fallingPlayer.findCollision((int) Math.ceil((1.0 / mc.thePlayer.motionY) * (-maxDist)));

            if (collision == null)
                return;

            boolean ok = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + mc.thePlayer.eyeHeight, mc.thePlayer.posZ).distanceTo(new Vec3(collision.getPos()).addVector(0.5, 0.5, 0.5)) < mc.playerController.getBlockReachDistance() + Math.sqrt(0.75);

            if (mc.thePlayer.motionY < (collision.getPos().getY() + 1) - mc.thePlayer.posY) {
                ok = true;
            }

            if (!ok)
                return;

            int index = -1;

            for (int i = 36; i < 45; i++) {
                ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();

                if (itemStack != null && (itemStack.getItem() == Items.water_bucket || itemStack.getItem() instanceof ItemBlock && ((ItemBlock) itemStack.getItem()).getBlock() == Blocks.web)) {
                    index = i - 36;

                    if (mc.thePlayer.inventory.currentItem == index)
                        break;
                }
            }

            if (index == -1)
                return;

            currentMlgItemIndex = index;
            currentMlgBlock = collision.getPos();

            if (mc.thePlayer.inventory.currentItem != index) {
                mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(index));
            }

            currentMlgRotation = RotationUtils.faceBlock(collision.getPos());
            currentMlgRotation.getRotation().toPlayer(mc.thePlayer);
        }
    } else if (currentMlgRotation != null) {
        ItemStack stack = mc.thePlayer.inventoryContainer.getSlot(currentMlgItemIndex + 36).getStack();

        if (stack.getItem() instanceof ItemBucket) {
            mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, stack);
        } else {
            Vec3i dirVec = EnumFacing.UP.getDirectionVec();

            if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, stack, currentMlgBlock, EnumFacing.UP, new Vec3(dirVec.getX() * 0.5, dirVec.getY() * 0.5, dirVec.getZ() * 0.5).add(new Vec3(currentMlgBlock)))) {
                mlgTimer.reset();
            }
        }

        if (mc.thePlayer.inventory.currentItem != currentMlgItemIndex)
            mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
    }
}
 
Example #12
Source File: MineplexGround.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onDisable() {
    speed = 0F;
    mc.getNetHandler().addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem));
}
 
Example #13
Source File: FakeNetServerHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_) {
}