net.minecraft.client.gui.inventory.GuiChest Java Examples

The following examples show how to use net.minecraft.client.gui.inventory.GuiChest. 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: PlayerListener.java    From SkyblockAddons with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent e) {
    if (e.gui == null && GuiChest.class.equals(lastOpenedInventory)) {
        lastClosedInv = System.currentTimeMillis();
        lastOpenedInventory = null;
    }
    if (e.gui != null) {
        lastOpenedInventory = e.gui.getClass();

        if (e.gui instanceof GuiChest) {
            Minecraft mc = Minecraft.getMinecraft();
            IInventory chestInventory = ((GuiChest)e.gui).lowerChestInventory;
            if (chestInventory.hasCustomName()) {
                if (chestInventory.getDisplayName().getUnformattedText().contains("Backpack")) {
                    if (ThreadLocalRandom.current().nextInt(0, 2) == 0) {
                        mc.thePlayer.playSound("mob.horse.armor", 0.5F, 1);
                    } else {
                        mc.thePlayer.playSound("mob.horse.leather", 0.5F, 1);
                    }
                }
            }
        }
    }
}
 
Example #2
Source File: MouseListener.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@InvokeEvent
public void onGuiOpen(GuiOpenEvent event) {
    if (event.getGui() == null && GuiChest.class.equals(lastOpenedInventory)) {
        lastClosedInv = System.currentTimeMillis();
        lastOpenedInventory = null;
    }

    if (event.getGui() != null) {
        lastOpenedInventory = event.getGui().getClass();
    }
}
 
Example #3
Source File: ChestStealer.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTicks() {
    if (!Wrapper.INSTANCE.mc().inGameHasFocus && Wrapper.INSTANCE.mc().currentScreen instanceof GuiChest) {
        if (!this.isContainerEmpty(Wrapper.INSTANCE.player().openContainer)) {
            int slotId = this.getNextSlotInContainer(Wrapper.INSTANCE.player().openContainer);
            if (this.delay >= 5) {
                Wrapper.INSTANCE.mc().playerController.windowClick(Wrapper.INSTANCE.player().openContainer.windowId, slotId, 0, 1, Wrapper.INSTANCE.player());
                this.delay = 0;
            }
            ++this.delay;
        } else {
            Wrapper.INSTANCE.player().closeScreen();
        }
    }
}
 
Example #4
Source File: NEIChestGuiHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) {
    return gui instanceof GuiChest ? NEIServerUtils.getRange(0, chestSize(gui)) : Collections.emptyList();
}
 
Example #5
Source File: NEIChestGuiHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
    return gui instanceof GuiChest ? Collections.singletonList(new TaggedInventoryArea("Chest", 0, chestSize(gui), gui.inventorySlots)) : null;
}
 
Example #6
Source File: NEIChestGuiHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) {
    return gui instanceof GuiChest ? NEIServerUtils.getRange(0, chestSize(gui)) : Collections.<Integer>emptyList();
}
 
Example #7
Source File: NEIChestGuiHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
    return gui instanceof GuiChest ? Arrays.asList(new TaggedInventoryArea("Chest", 0, chestSize(gui), gui.inventorySlots)) : null;
}