Java Code Examples for net.minecraft.inventory.Slot#isEnabled()
The following examples show how to use
net.minecraft.inventory.Slot#isEnabled() .
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: MaterialListHudRenderer.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
private static List<Pair<Slot, Color4f>> getHilightedSlots(GuiContainer gui, HashMap<ItemType, MaterialListEntry> materialListEntries) { List<Pair<Slot, Color4f>> hilightedSlots = new ArrayList<>(); for (int slotNum = 0; slotNum < gui.inventorySlots.inventorySlots.size(); ++slotNum) { Slot slot = gui.inventorySlots.inventorySlots.get(slotNum); if (slot.isEnabled() && slot.getHasStack() && (slot.inventory instanceof InventoryPlayer) == false) { ItemType type = new ItemType(slot.getStack(), false, false); MaterialListEntry entry = materialListEntries.get(type); // The item in the slot is on the material list's missing items list if (entry != null) { long available = entry.getCountAvailable(); Color4f color; if (available == 0L) { color = Configs.Colors.MATERIAL_LIST_SLOT_HL_NONE.getColor(); } else if (available < entry.getStack().getMaxStackSize()) { color = Configs.Colors.MATERIAL_LIST_SLOT_HL_LT_STACK.getColor(); } else { color = Configs.Colors.MATERIAL_LIST_SLOT_HL_NOT_ENOUGH.getColor(); } hilightedSlots.add(Pair.of(slot, color)); } } } return hilightedSlots; }
Example 2
Source File: ModularUIGui.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.hoveredSlot = null; drawDefaultBackground(); GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); GlStateManager.disableLighting(); GlStateManager.disableDepth(); drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.pushMatrix(); GlStateManager.translate(guiLeft, guiTop, 0.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.enableRescaleNormal(); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i) { Slot slot = this.inventorySlots.inventorySlots.get(i); if (slot.isEnabled()) { this.drawSlotContents(slot); } if (isPointInRegion(slot.xPos, slot.yPos, 16, 16, mouseX, mouseY) && slot.isEnabled()) { renderSlotOverlay(slot); setHoveredSlot(slot); } } RenderHelper.disableStandardItemLighting(); GlStateManager.popMatrix(); drawGuiContainerForegroundLayer(mouseX, mouseY); GlStateManager.pushMatrix(); GlStateManager.translate(guiLeft, guiTop, 0.0F); RenderHelper.enableGUIStandardItemLighting(); MinecraftForge.EVENT_BUS.post(new GuiContainerEvent.DrawForeground(this, mouseX, mouseY)); GlStateManager.enableDepth(); renderItemStackOnMouse(mouseX, mouseY); renderReturningItemStack(); GlStateManager.popMatrix(); GlStateManager.enableLighting(); RenderHelper.enableStandardItemLighting(); renderHoveredToolTip(mouseX, mouseY); }