Search in sources :

Example 1 with ISPacketSetSlot

use of me.earth.earthhack.impl.core.mixins.network.server.ISPacketSetSlot in project 3arthh4ck by 3arthqu4ke.

the class ListenerSetSlot method invoke.

@Override
public void invoke(PacketEvent.Receive<SPacketSetSlot> event) {
    if (module.getParent().isEnabled() && mc.player != null) {
        SPacketSetSlot packet = event.getPacket();
        if (packet.getSlot() == -1337) {
            ((IContainer) mc.player.openContainer).setTransactionID((short) packet.getWindowId());
            // make NetHandlerPlayClient set mouse slot.
            ((ISPacketSetSlot) packet).setWindowId(-1);
        } else if (packet.getWindowId() == -128) {
            event.setCancelled(true);
            mc.addScheduledTask(() -> {
                OffhandMode recovery = OFFHAND.returnIfPresent(Offhand::getMode, null);
                OFFHAND.computeIfPresent(offhand -> {
                    offhand.setMode(OffhandMode.TOTEM);
                    offhand.postWindowClick();
                });
                OFFHAND.computeIfPresent(offhand -> offhand.setRecovery(recovery));
                Slot slot = mc.player.inventoryContainer.inventorySlots.get(packet.getSlot());
                slot.putStack(packet.getStack());
            });
        }
    }
}
Also used : ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) OffhandMode(me.earth.earthhack.impl.modules.combat.offhand.modes.OffhandMode) IContainer(me.earth.earthhack.impl.core.ducks.util.IContainer) Offhand(me.earth.earthhack.impl.modules.combat.offhand.Offhand) ModuleCache(me.earth.earthhack.api.cache.ModuleCache) Caches(me.earth.earthhack.impl.modules.Caches) Slot(net.minecraft.inventory.Slot) SPacketSetSlot(net.minecraft.network.play.server.SPacketSetSlot) PacketEvent(me.earth.earthhack.impl.event.events.network.PacketEvent) ISPacketSetSlot(me.earth.earthhack.impl.core.mixins.network.server.ISPacketSetSlot) ISPacketSetSlot(me.earth.earthhack.impl.core.mixins.network.server.ISPacketSetSlot) Slot(net.minecraft.inventory.Slot) SPacketSetSlot(net.minecraft.network.play.server.SPacketSetSlot) ISPacketSetSlot(me.earth.earthhack.impl.core.mixins.network.server.ISPacketSetSlot) SPacketSetSlot(net.minecraft.network.play.server.SPacketSetSlot) ISPacketSetSlot(me.earth.earthhack.impl.core.mixins.network.server.ISPacketSetSlot) IContainer(me.earth.earthhack.impl.core.ducks.util.IContainer) OffhandMode(me.earth.earthhack.impl.modules.combat.offhand.modes.OffhandMode)

Aggregations

ModuleCache (me.earth.earthhack.api.cache.ModuleCache)1 IContainer (me.earth.earthhack.impl.core.ducks.util.IContainer)1 ISPacketSetSlot (me.earth.earthhack.impl.core.mixins.network.server.ISPacketSetSlot)1 PacketEvent (me.earth.earthhack.impl.event.events.network.PacketEvent)1 ModuleListener (me.earth.earthhack.impl.event.listeners.ModuleListener)1 Caches (me.earth.earthhack.impl.modules.Caches)1 Offhand (me.earth.earthhack.impl.modules.combat.offhand.Offhand)1 OffhandMode (me.earth.earthhack.impl.modules.combat.offhand.modes.OffhandMode)1 Slot (net.minecraft.inventory.Slot)1 SPacketSetSlot (net.minecraft.network.play.server.SPacketSetSlot)1