Search in sources :

Example 1 with GuiShulkerBox

use of net.minecraft.client.gui.inventory.GuiShulkerBox 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)

Example 2 with GuiShulkerBox

use of net.minecraft.client.gui.inventory.GuiShulkerBox in project Spark-Client by Spark-Client-Development.

the class MixinGuiScreen method initGui.

@Inject(method = "initGui", at = @At("HEAD"))
public void initGui(final CallbackInfo callbackInfo) {
    Minecraft mc = Minecraft.getMinecraft();
    if (mc.currentScreen instanceof GuiShulkerBox || mc.currentScreen instanceof GuiChest) {
        GuiContainer screen = (GuiContainer) mc.currentScreen;
        InventoryManager instance = InventoryManager.instance;
        if (instance.isEnabled() && instance.isAuto(screen))
            instance.StartSteal();
        if (instance.isEnabled() && !instance.isAuto(screen))
            screen.buttonList.add(new GuiButton(66, screen.width / 2 + 5, (screen.height - screen.getYSize()) / 2 - 6, 40, 12, "Steal"));
    }
}
Also used : InventoryManager(me.wallhacks.spark.systems.module.modules.misc.InventoryManager) GuiButton(net.minecraft.client.gui.GuiButton) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) GuiShulkerBox(net.minecraft.client.gui.inventory.GuiShulkerBox) GuiChest(net.minecraft.client.gui.inventory.GuiChest) Minecraft(net.minecraft.client.Minecraft) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with GuiShulkerBox

use of net.minecraft.client.gui.inventory.GuiShulkerBox in project Spark-Client by Spark-Client-Development.

the class InventoryManager method handleContainer.

void handleContainer() {
    if (mc.currentScreen instanceof GuiChest || mc.currentScreen instanceof GuiShulkerBox) {
        Container container = ((GuiContainer) mc.currentScreen).inventorySlots;
        ArrayList<Integer> list = new ArrayList<>();
        int slots = (mc.currentScreen instanceof GuiShulkerBox ? ((GuiShulkerBox) mc.currentScreen).inventory : ((GuiChest) mc.currentScreen).lowerChestInventory).getSizeInventory();
        int slot = 0;
        while (slot < slots) {
            ItemStack l_Stack = container.getSlot(slot).getStack();
            if (!l_Stack.isEmpty() && l_Stack.getItem() != Items.AIR) {
                if (KeepItemStack(l_Stack)) {
                    int i = itemNeededInPerfectKit(l_Stack);
                    if (i >= 0) {
                        int convert = i;
                        if (convert < 9)
                            convert += 27;
                        else
                            convert -= 9;
                        InventoryUtil.moveItemInContainer(slot, convert + slots);
                        timer.delayRandom(stealDelay.getValue() * 10, stealDelay.getValue() * 3);
                        return;
                    } else
                        list.add(slot);
                }
            }
            slot++;
        }
        if (!stealKitNeeded.isOn())
            while (list.size() > 0) {
                mc.playerController.windowClick(container.windowId, list.get(0), 0, ClickType.QUICK_MOVE, mc.player);
                timer.delayRandom(stealDelay.getValue() * 10, stealDelay.getValue() * 3);
                return;
            }
        isStealing = false;
        slot = 0;
    }
}
Also used : GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) Container(net.minecraft.inventory.Container) ArrayList(java.util.ArrayList) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) GuiChest(net.minecraft.client.gui.inventory.GuiChest) GuiShulkerBox(net.minecraft.client.gui.inventory.GuiShulkerBox)

Aggregations

GuiChest (net.minecraft.client.gui.inventory.GuiChest)3 GuiContainer (net.minecraft.client.gui.inventory.GuiContainer)3 GuiShulkerBox (net.minecraft.client.gui.inventory.GuiShulkerBox)3 ArrayList (java.util.ArrayList)1 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 InventoryManager (me.wallhacks.spark.systems.module.modules.misc.InventoryManager)1 BlockEnderChest (net.minecraft.block.BlockEnderChest)1 Minecraft (net.minecraft.client.Minecraft)1 GuiButton (net.minecraft.client.gui.GuiButton)1 Items (net.minecraft.init.Items)1 ClickType (net.minecraft.inventory.ClickType)1 Container (net.minecraft.inventory.Container)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