Search in sources :

Example 1 with TickEvent

use of me.earth.earthhack.impl.event.events.misc.TickEvent in project 3arthh4ck by 3arthqu4ke.

the class ListenerTick method invoke.

@Override
public void invoke(TickEvent event) {
    if (mc.currentScreen instanceof GuiShulkerBox) {
        for (int i = 0; i < 36; i++) {
            if (module.delayTimer.passed(module.delay.getValue())) {
                Setting<?> setting = module.getSettingFromSlot(i);
                if (setting == null)
                    continue;
                int itemId = Integer.parseInt(setting.getName().split(":")[1]);
                if (itemId == 0)
                    continue;
                Item item = Item.getItemById(itemId);
                int shulkerSlot = InventoryUtil.findItem(item, ((GuiShulkerBox) mc.currentScreen).inventorySlots);
                ItemStack stackInSlot = ((GuiContainer) mc.currentScreen).inventorySlots.getInventory().get(i + 27);
                if (stackInSlot.getMaxStackSize() == 1 || stackInSlot.getMaxStackSize() == stackInSlot.getCount() || stackInSlot.getItem() != item && stackInSlot.getItem() != Items.AIR || shulkerSlot == -1 || shulkerSlot > 26)
                    continue;
                mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, shulkerSlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, i + 27, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, shulkerSlot, 0, ClickType.PICKUP, mc.player);
                module.delayTimer.reset();
            }
        }
    } else if (mc.currentScreen instanceof GuiChest && module.shouldRegear && module.grabShulker.getValue() && !module.hasKit()) {
        int slot = -1;
        // TODO: improve method of finding kits in chests
        for (int i = 0; i < 28; i++) {
            boolean foundExp = false;
            boolean foundCrystals = false;
            boolean foundGapples = false;
            ItemStack stack = ((GuiContainer) mc.currentScreen).inventorySlots.getInventory().get(i);
            if (stack.getItem() instanceof ItemShulkerBox) {
                NBTTagCompound tagCompound = stack.getTagCompound();
                if (tagCompound != null && tagCompound.hasKey("BlockEntityTag", 10)) {
                    NBTTagCompound blockEntityTag = tagCompound.getCompoundTag("BlockEntityTag");
                    if (blockEntityTag.hasKey("Items", 9)) {
                        NonNullList<ItemStack> nonNullList = NonNullList.withSize(27, ItemStack.EMPTY);
                        ItemStackHelper.loadAllItems(blockEntityTag, nonNullList);
                        for (ItemStack stack1 : nonNullList) {
                            if (stack1.getItem() == Items.GOLDEN_APPLE) {
                                foundGapples = true;
                            } else if (stack1.getItem() == Items.EXPERIENCE_BOTTLE) {
                                foundExp = true;
                            } else if (stack1.getItem() == Items.END_CRYSTAL) {
                                foundCrystals = true;
                            }
                        }
                        if (foundExp && foundGapples && foundCrystals) {
                            slot = i;
                        } else {
                            if (!module.hasKit() && module.getShulkerBox() == null) {
                                module.shouldRegear = false;
                                mc.player.closeScreen();
                                return;
                            }
                        }
                    }
                }
            }
        }
        if (slot != -1) {
            int emptySlot = InventoryUtil.findInInventory(stack -> stack.isEmpty() || stack.getItem() == Items.AIR, false);
            if (emptySlot != -1) {
                mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, slot, 0, ClickType.QUICK_MOVE, mc.player);
            }
        }
        mc.player.closeScreen();
    }
}
Also used : ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) InventoryEnderChest(net.minecraft.inventory.InventoryEnderChest) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SimpleRemovingSetting(me.earth.earthhack.impl.util.helpers.addable.setting.SimpleRemovingSetting) Items(net.minecraft.init.Items) Item(net.minecraft.item.Item) Setting(me.earth.earthhack.api.setting.Setting) TickEvent(me.earth.earthhack.impl.event.events.misc.TickEvent) BlockEnderChest(net.minecraft.block.BlockEnderChest) GuiChest(net.minecraft.client.gui.inventory.GuiChest) GuiShulkerBox(net.minecraft.client.gui.inventory.GuiShulkerBox) ItemStack(net.minecraft.item.ItemStack) CPacketCloseWindow(net.minecraft.network.play.client.CPacketCloseWindow) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) ItemStackHelper(net.minecraft.inventory.ItemStackHelper) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) NonNullList(net.minecraft.util.NonNullList) ItemShulkerBox(net.minecraft.item.ItemShulkerBox) ClickType(net.minecraft.inventory.ClickType) Item(net.minecraft.item.Item) NonNullList(net.minecraft.util.NonNullList) ItemShulkerBox(net.minecraft.item.ItemShulkerBox) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) GuiShulkerBox(net.minecraft.client.gui.inventory.GuiShulkerBox) ItemStack(net.minecraft.item.ItemStack) GuiChest(net.minecraft.client.gui.inventory.GuiChest)

Aggregations

Setting (me.earth.earthhack.api.setting.Setting)1 TickEvent (me.earth.earthhack.impl.event.events.misc.TickEvent)1 ModuleListener (me.earth.earthhack.impl.event.listeners.ModuleListener)1 SimpleRemovingSetting (me.earth.earthhack.impl.util.helpers.addable.setting.SimpleRemovingSetting)1 InventoryUtil (me.earth.earthhack.impl.util.minecraft.InventoryUtil)1 BlockEnderChest (net.minecraft.block.BlockEnderChest)1 GuiChest (net.minecraft.client.gui.inventory.GuiChest)1 GuiContainer (net.minecraft.client.gui.inventory.GuiContainer)1 GuiShulkerBox (net.minecraft.client.gui.inventory.GuiShulkerBox)1 Items (net.minecraft.init.Items)1 ClickType (net.minecraft.inventory.ClickType)1 InventoryEnderChest (net.minecraft.inventory.InventoryEnderChest)1 ItemStackHelper (net.minecraft.inventory.ItemStackHelper)1 Item (net.minecraft.item.Item)1 ItemShulkerBox (net.minecraft.item.ItemShulkerBox)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 CPacketCloseWindow (net.minecraft.network.play.client.CPacketCloseWindow)1 NonNullList (net.minecraft.util.NonNullList)1