net.minecraft.inventory.Container Java Examples
The following examples show how to use
net.minecraft.inventory.Container.
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: GuiContainerHook.java From SkyblockAddons with MIT License | 6 votes |
public static void drawGradientRect(GuiContainer guiContainer, int left, int top, int right, int bottom, int startColor, int endColor, Slot theSlot) { if (freezeBackpack) return; SkyblockAddons main = SkyblockAddons.getInstance(); Container container = Minecraft.getMinecraft().thePlayer.openContainer; if (theSlot != null) { int slotNum = theSlot.slotNumber + main.getInventoryUtils().getSlotDifference(container); main.getUtils().setLastHoveredSlot(slotNum); if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && main.getUtils().isOnSkyblock() && main.getConfigValues().getLockedSlots().contains(slotNum) && (slotNum >= 9 || container instanceof ContainerPlayer && slotNum >= 5)) { drawRightGradientRect(guiContainer, left, top, right, bottom, OVERLAY_RED, OVERLAY_RED); return; } } drawRightGradientRect(guiContainer, left, top, right, bottom, startColor, endColor); }
Example #2
Source File: FastTransferManager.java From NotEnoughItems with MIT License | 6 votes |
private void generateSlotMap(Container container, ItemStack stack) { stack = stack.copy(); stack.stackSize = 1; for (int slotNo = 0; slotNo < container.inventorySlots.size(); slotNo++) { if (slotZoneMap.containsKey(slotNo) || !container.getSlot(slotNo).isItemValid(stack)) continue; HashSet<Integer> connectedSlots = new HashSet<Integer>(); findConnectedSlots(container, slotNo, connectedSlots); LinkedList<Integer> zoneSlots = new LinkedList<Integer>(connectedSlots); Collections.sort(zoneSlots, new SlotPositionComparator(container)); slotZones.add(zoneSlots); for (int i : zoneSlots) { slotZoneMap.put(i, slotZones.size() - 1); } } }
Example #3
Source File: InputUtil.java From CraftingKeys with MIT License | 6 votes |
/** * Returns the Slot at the current Mouse Position. [FROM GUICONTAINER] * * @param guiContainer The (Inventory) Container to work with. * @return Returns the slot (or null) */ public static Slot getSlotAtMousePosition(GuiContainer guiContainer) { if (guiContainer != null) { Container container = guiContainer.inventorySlots; int x = getMouseX(guiContainer); int y = getMouseY(guiContainer); for (int k = 0; k < container.inventorySlots.size(); k++) { Slot slot = (Slot) container.inventorySlots.get(k); if (getIsMouseOverSlot(guiContainer, slot, x, y)) { return slot; } } return null; } else { Logger.debug("getSlotAtMousePosition(gui)", "guiContainer == null"); return null; } }
Example #4
Source File: DamageableShapelessOreRecipeTest.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
private void doTest(boolean inOrder, boolean enoughDamage) { DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"), new int[] {enoughDamage ? 5 : 5000, 0}, new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD), new ItemStack(Items.APPLE)); InventoryCrafting inv = new InventoryCrafting(new Container() { @Override public boolean canInteractWith(EntityPlayer playerIn) { return false; } }, 3, 3); inv.setInventorySlotContents(inOrder ? 3 : 4, new ItemStack(Items.WOODEN_SWORD)); inv.setInventorySlotContents(inOrder ? 4 : 3, new ItemStack(Items.APPLE)); assertSame(enoughDamage, recipe.matches(inv, null)); if (enoughDamage) { NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv); assertSame(Items.WOODEN_SWORD, remaining.get(inOrder ? 3 : 4).getItem()); assertEquals(5, remaining.get(inOrder ? 3 : 4).getItemDamage()); } }
Example #5
Source File: MCCraftingGrid.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
private MCCraftingGrid(InventoryCrafting inventory) { this.inventory = inventory; width = height = (int) Math.sqrt(inventory.getSizeInventory()); items = new nova.core.item.Item[width * height]; original = new net.minecraft.item.ItemStack[items.length]; itemCount = 0; update(); Container container = ReflectionUtil.getCraftingContainer(inventory); if (container != null) { @SuppressWarnings("unchecked") List<Slot> slots = container.inventorySlots; EntityPlayer playerOrig = null; Optional<Player> player = Optional.empty(); for (Slot slot : slots) { if (slot instanceof SlotCrafting) { playerOrig = ReflectionUtil.getCraftingSlotPlayer((SlotCrafting) slot); player = WrapUtility.getNovaPlayer(playerOrig); if (player.isPresent()) { break; } } } this.playerOrig = playerOrig; this.player = player; } else { playerOrig = null; player = Optional.empty(); } }
Example #6
Source File: SlotSpecialCraftingOutput.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public SlotSpecialCraftingOutput(Container container, EntityPlayer entityplayer, IInventory iinventory, IInventory iinventory1, int i, int j, int k) { super(iinventory1, i, j, k); this.container = container; thePlayer = entityplayer; craftMatrix = iinventory; }
Example #7
Source File: TileCraftingGrid.java From Translocators with MIT License | 5 votes |
private InventoryCrafting getCraftMatrix() { InventoryCrafting craftMatrix = new InventoryCrafting(new Container() { @Override public boolean canInteractWith(EntityPlayer entityplayer) { return true; } }, 3, 3); for (int i = 0; i < 9; i++) craftMatrix.setInventorySlotContents(i, items[i]); return craftMatrix; }
Example #8
Source File: MessageGuiSeedStorageClearSeed.java From AgriCraft with MIT License | 5 votes |
@Override protected void processMessage(MessageContext ctx) { final Container container = this.player.openContainer; if (container instanceof ContainerSeedStorageBase) { final ContainerSeedStorageBase storage = ((ContainerSeedStorageBase) container); final TileEntity tileEntity = storage.getTile(); if (tileEntity instanceof ISeedStorageControllable) { ((ISeedStorageControllable) tileEntity).clearLockedSeed(); } } }
Example #9
Source File: CraftingManager.java From CraftingKeys with MIT License | 5 votes |
/** * Returns a Crafting Manager Instance operating on the given container * * @param container A container from a GUI * @return manager-singleton */ public static CraftingManager getInstance(Container container) { if (instance == null) { instance = new CraftingManager(container); } else { instance.container = container; } return instance; }
Example #10
Source File: FastTransferManager.java From NotEnoughItems with MIT License | 5 votes |
public void restoreContainer(Container container, LinkedList<ItemStack> items) { for (int i = 0; i < container.inventorySlots.size(); i++) { container.getSlot(i).putStack(items.get(i)); } container.slotClick(-999, 0, 0, Minecraft.getMinecraft().thePlayer); }
Example #11
Source File: GuiReactorStatus.java From BigReactors with MIT License | 5 votes |
public GuiReactorStatus(Container container, TileEntityReactorPart tileEntityReactorPart) { super(container); ySize = 186; this.part = tileEntityReactorPart; this.reactor = part.getReactorController(); }
Example #12
Source File: PlayerInventory.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public static void buildInventoryLayout(Container container, InventoryPlayer inventory, int x, int y, boolean freezeSlot, boolean toolBarAfterMainInv) { index = 0; if(!toolBarAfterMainInv) addToolbarSlots(container, inventory, x, y, freezeSlot); for(int i = 0; i < 3; ++i) { for(int k = 0; k < 9; ++k) { index = k + (i+1) * 9; addSlotToContainer(container, new Slot(inventory, index, x + k * 18, y + i * 18)); } } if(toolBarAfterMainInv) addToolbarSlots(container, inventory, x, y, freezeSlot); /*ItemStack is = getInventory(inventory.player).extraEquipInventory[0]; if(is != null) { if(is.getItem() instanceof ItemQuiver) { addSlotToContainer(container, new SlotQuiver(containerInv, index++, x + 178, y)); addSlotToContainer(container, new SlotQuiver(containerInv, index++, x + 178, y+18)); addSlotToContainer(container, new SlotQuiver(containerInv, index++, x + 178, y+36)); addSlotToContainer(container, new SlotQuiver(containerInv, index++, x + 178, y+54)); addSlotToContainer(container, new SlotQuiver(containerInv, index++, x + 196, y)); addSlotToContainer(container, new SlotQuiver(containerInv, index++, x + 196, y+18)); addSlotToContainer(container, new SlotQuiver(containerInv, index++, x + 196, y+36)); addSlotToContainer(container, new SlotQuiver(containerInv, index++, x + 196, y+54)); } loadBagInventory(is, container); }*/ }
Example #13
Source File: ReflectionUtil.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
public static Container getCraftingContainer(InventoryCrafting inventory) { try { return (Container) INVENTORYCRAFTING_EVENTHANDLER.get(inventory); } catch (IllegalAccessException ex) { Game.logger().error("could not get inventory eventhandler"); return null; } }
Example #14
Source File: ModulePlanetSelector.java From AdvancedRocketry with MIT License | 5 votes |
@Override public void sendChanges(Container container, IContainerListener crafter, int variableId, int localId) { for(ModuleBase module : staticModuleList) { if(localId >= 0 && localId < module.numberOfChangesToSend()) { module.sendChanges(container, crafter, variableId, localId); return; } localId -= module.numberOfChangesToSend(); } }
Example #15
Source File: ReflectionUtil.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
public static Container getCraftingContainer(InventoryCrafting inventory) { try { return (Container) INVENTORYCRAFTING_EVENTHANDLER.get(inventory); } catch (IllegalAccessException ex) { Game.logger().error("could not get inventory eventhandler"); return null; } }
Example #16
Source File: TaggedInventoryArea.java From NotEnoughItems with MIT License | 5 votes |
public TaggedInventoryArea(String name, int first, int last, Container container) { this.container = container; tagName = name; for(int i = first; i <= last; i++) slots.add(i); }
Example #17
Source File: BlockPresent.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
@Override public int getComparatorInputOverride(World world, int x, int y, int z, int strength) { TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TileEntityPresent) { return Container.calcRedstoneFromInventory((TileEntityPresent) te); } return 0; }
Example #18
Source File: PlayerInventory.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public static void loadBagInventory(ItemStack is, Container c) { if(is != null && is.hasTagCompound()) { NBTTagList nbttaglist = is.getTagCompound().getTagList("Items", 10); containerInv = new InventoryCrafting(c, 4, 2); for(int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); if(byte0 >= 0 && byte0 < 8) containerInv.setInventorySlotContents(byte0, new ItemStack(nbttagcompound1)); } } }
Example #19
Source File: NEIClientUtils.java From NotEnoughItems with MIT License | 5 votes |
public static void deleteItemsOfType(ItemStack type) { Container c = getGuiContainer().inventorySlots; for (int i = 0; i < c.inventorySlots.size(); i++) { Slot slot = c.getSlot(i); if (slot == null) continue; ItemStack stack = slot.getStack(); if (stack != null && stack.getItem() == type.getItem() && stack.getItemDamage() == type.getItemDamage()) { setSlotContents(i, null, true); slot.putStack(null); } } }
Example #20
Source File: FastTransferManager.java From NotEnoughItems with MIT License | 5 votes |
public LinkedList<ItemStack> saveContainer(Container container) { LinkedList<ItemStack> stacks = new LinkedList<ItemStack>(); for (int i = 0; i < container.inventorySlots.size(); i++) stacks.add(copyStack(container.getSlot(i).getStack())); return stacks; }
Example #21
Source File: SlotBackpackWrapper.java From WearableBackpacks with MIT License | 5 votes |
/** When a backpack is equipped, go through the currently open container, see if * any slot contains the player's equipped backpack. If so, replace that slot with * a wrapper that prevents the backpack from being unequipped though normal means. */ public static void replace(EntityPlayer player, ItemStack backpack) { Container container = player.openContainer; if (container == null) return; for (Slot slot : container.inventorySlots) { if (slot.getStack() != backpack) continue; if (slot instanceof SlotBackpackWrapper) continue; Slot newSlot = new SlotBackpackWrapper(slot); newSlot.slotNumber = slot.slotNumber; container.inventorySlots.set(slot.slotNumber, newSlot); // Keep going, there may be more slots to fix! } }
Example #22
Source File: GuiReactorRedNetPort.java From BigReactors with MIT License | 5 votes |
public GuiReactorRedNetPort(Container container, TileEntityReactorRedNetPort redNetPort) { super(container); port = redNetPort; xSize = 255; ySize = 214; _guiBackground = new ResourceLocation(BigReactors.GUI_DIRECTORY + "RedNetPort.png"); }
Example #23
Source File: VillagerManager.java From CraftingKeys with MIT License | 5 votes |
/** * Returns a Villager Manager Instance operating on the given container * * @param container A container from a GUI * @return manager-singleton */ public static VillagerManager getInstance(Container container) { if (instance == null) { instance = new VillagerManager(container); } else { instance.container = container; } return instance; }
Example #24
Source File: GuiCyaniteReprocessor.java From BigReactors with MIT License | 5 votes |
public GuiCyaniteReprocessor(Container container, TileEntityCyaniteReprocessor entity) { super(container, entity); _entity = entity; xSize = 245; ySize = 175; }
Example #25
Source File: PlayerInventory.java From TFC2 with GNU General Public License v3.0 | 5 votes |
private static void addToolbarSlots(Container container, InventoryPlayer inventory, int x, int y, boolean freezeSlot) { for(int j = 0; j < 9; ++j) { if(freezeSlot && j == inventory.currentItem) addSlotToContainer(container, new SlotForShowOnly(inventory, j, x + j * 18, y+58)); else addSlotToContainer(container, new Slot(inventory, j, x + j * 18, y+58)); } }
Example #26
Source File: AnvilManager.java From CraftingKeys with MIT License | 5 votes |
/** * Returns a Anvil Manager Instance operating on the given container * * @param container A container from a GUI * @return manager-singleton */ public static AnvilManager getInstance(Container container) { if (instance == null) { instance = new AnvilManager(container); } else { instance.container = container; } return instance; }
Example #27
Source File: FastTransferManager.java From NotEnoughItems with MIT License | 5 votes |
public static int findSlotWithItem(Container container, ItemStack teststack) { for (int slotNo = 0; slotNo < container.inventorySlots.size(); slotNo++) { ItemStack stack = container.getSlot(slotNo).getStack(); if (!stack.isEmpty() && areStacksSameType(stack, teststack)) { return slotNo; } } return -1; }
Example #28
Source File: PacketUpdateGui.java From Signals with GNU General Public License v3.0 | 5 votes |
@Override public void handleClientSide(EntityPlayer player){ Container container = player.openContainer; if(container instanceof ContainerBase) { ((ContainerBase<?>)container).updateField(syncId, value); } }
Example #29
Source File: PacketUpdateGui.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void handleClientSide(PacketUpdateGui message, EntityPlayer player){ Container container = player.openContainer; if(container instanceof ContainerPneumaticBase) { ((ContainerPneumaticBase)container).updateField(message.syncId, message.value); } }
Example #30
Source File: GuiContainer.java From NotEnoughItems with MIT License | 5 votes |
/** * Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY, * lastButtonClicked & timeSinceMouseClick. */ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { Slot slot = this.getSlotAtPosition(mouseX, mouseY); ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); manager.mouseDragged(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) { if (clickedMouseButton == 0 || clickedMouseButton == 1) { if (this.draggedStack == null) { if (slot != this.clickedSlot && this.clickedSlot.getStack() != null) { this.draggedStack = this.clickedSlot.getStack().copy(); } } else if (this.draggedStack.stackSize > 1 && slot != null && Container.canAddItemToSlot(slot, this.draggedStack, false)) { long i = Minecraft.getSystemTime(); if (this.currentDragTargetSlot == slot) { if (i - this.dragItemDropDelay > 500L) { managerHandleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP); managerHandleMouseClick(slot, slot.slotNumber, 1, ClickType.PICKUP); managerHandleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP); this.dragItemDropDelay = i + 750L; --this.draggedStack.stackSize; } } else { this.currentDragTargetSlot = slot; this.dragItemDropDelay = i; } } } } else if (this.dragSplitting && slot != null && itemstack != null && itemstack.stackSize > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot)) { this.dragSplittingSlots.add(slot); this.updateActivePotionEffects(); } }