Java Code Examples for net.minecraft.client.gui.inventory.GuiContainer
The following examples show how to use
net.minecraft.client.gui.inventory.GuiContainer. These examples are extracted from open source projects.
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 Project: ehacks-pro Source File: NEISelect.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onTicks() { boolean newState = Keyboard.isKeyDown(NEISelectKeybind.getKey()); if (newState && !prevState) { prevState = newState; try { GuiContainer container = Wrapper.INSTANCE.mc().currentScreen instanceof GuiContainer ? ((GuiContainer) Wrapper.INSTANCE.mc().currentScreen) : null; if (container == null) { return; } Object checkItem = Class.forName("codechicken.nei.guihook.GuiContainerManager").getDeclaredMethod("getStackMouseOver", GuiContainer.class).invoke(null, container); if (checkItem instanceof ItemStack) { ItemStack item = (ItemStack) checkItem; int count = GuiContainer.isShiftKeyDown() ? item.getMaxStackSize() : 1; Statics.STATIC_ITEMSTACK = item.copy().splitStack(count); Statics.STATIC_NBT = Statics.STATIC_ITEMSTACK.getTagCompound() == null ? new NBTTagCompound() : Statics.STATIC_ITEMSTACK.getTagCompound(); } InteropUtils.log("ItemStack selected", this); } catch (Exception ignored) { } } prevState = newState; }
Example 2
Source Project: ehacks-pro Source File: NoLimitBuffs.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onTicks() { try { Object currentScreen = Wrapper.INSTANCE.mc().currentScreen; if (currentScreen != null && Class.forName("am2.guis.GuiInscriptionTable").isInstance(currentScreen)) { Object container = ((GuiContainer) currentScreen).inventorySlots; Object tileEntity = getFinalStatic(Class.forName("am2.containers.ContainerInscriptionTable").getDeclaredField("table"), container); HashMap<Object, Integer> modCounts = (HashMap<Object, Integer>) getFinalStatic(Class.forName("am2.blocks.tileentities.TileEntityInscriptionTable").getDeclaredField("modifierCount"), tileEntity); modCounts.entrySet().forEach((entry) -> { entry.setValue(0); }); } } catch (Exception e) { InteropUtils.log("&cError", this); } }
Example 3
Source Project: NotEnoughItems Source File: FastTransferManager.java License: MIT License | 6 votes |
public void throwAll(GuiContainer window, int pickedUpFromSlot) { ItemStack held = NEIClientUtils.getHeldItem(); if (held == null) return; clickSlot(window, -999); generateSlotMap(window.inventorySlots, held); Integer zone = slotZoneMap.get(pickedUpFromSlot); if(zone == null) //something went wrong and we can't work out where the item was picked up from return; for (int slotIndex : slotZones.get(zone)) { Slot slot = window.inventorySlots.getSlot(slotIndex); if (areStacksSameType(held, slot.getStack())) { clickSlot(window, slotIndex); clickSlot(window, -999); } } }
Example 4
Source Project: wailanbt Source File: TooltipHandler.java License: MIT License | 6 votes |
@Override public List<String> handleItemTooltip(GuiContainer guiContainer, ItemStack itemStack, int i, int i2, List<String> strings) { if (guiContainer != null && GuiContainerManager.shouldShowTooltip(guiContainer) && itemStack != null) { NBTTagCompound n = itemStack.getTagCompound(); if (n != null) { NBTHandler.flag = 2; NBTHandler.id = Item.itemRegistry.getNameForObject(itemStack.getItem()); List<String> tips = NBTHandler.getTipsFromNBT(n, "tooltip"); for (String tip:tips){ strings.add(1, "\u00a77" + tip); } return strings; } } return strings; }
Example 5
Source Project: NotEnoughItems Source File: NEIController.java License: MIT License | 6 votes |
@Override public boolean lastKeyTyped(GuiScreen gui, char keyChar, int keyCode) { if (gui instanceof GuiContainer) { GuiContainer container = ((GuiContainer) gui); if (!NEIClientConfig.isEnabled() || GuiInfo.hasCustomSlots(container) || isSpreading(container)) { return false; } Slot slot = GuiHelper.getSlotMouseOver(container); if (slot == null) { return false; } int slotIndex = slot.slotNumber; if (keyCode == Minecraft.getMinecraft().gameSettings.keyBindDrop.getKeyCode() && NEIClientUtils.shiftKey() && !ItemInfo.fastTransferContainerExemptions.contains(container.getClass())) { FastTransferManager.clickSlot(container, slotIndex); fastTransferManager.throwAll(container, slotIndex); FastTransferManager.clickSlot(container, slotIndex); return true; } } return false; }
Example 6
Source Project: NotEnoughItems Source File: LayoutManager.java License: MIT License | 6 votes |
public static void layout(GuiContainer gui) { VisibilityData visiblity = new VisibilityData(); if (isHidden()) { //showItemPanel = false; visiblity.showNEI = false; } if (gui.height - gui.getYSize() <= 40) { visiblity.showSearchSection = false; } if (gui.getGuiLeft() - 4 < 76) { visiblity.showWidgets = false; } for (INEIGuiHandler handler : GuiInfo.guiHandlers) { handler.modifyVisibility(gui, visiblity); } visiblity.translateDependencies(); getLayoutStyle().layout(gui, visiblity); updateWidgetVisiblities(gui, visiblity); }
Example 7
Source Project: NotEnoughItems Source File: GuiUsageRecipe.java License: MIT License | 6 votes |
public static boolean openRecipeGui(String inputId, Object... ingredients) { Minecraft mc = Minecraft.getMinecraft(); GuiContainer prevscreen = mc.currentScreen instanceof GuiContainer ? (GuiContainer) mc.currentScreen : null; TaskProfiler profiler = ProfilerRecipeHandler.getProfiler(); ArrayList<IUsageHandler> handlers = new ArrayList<>(); for (IUsageHandler usagehandler : usagehandlers) { profiler.start(usagehandler.getRecipeName()); IUsageHandler handler = usagehandler.getUsageHandler(inputId, ingredients); if (handler.numRecipes() > 0) { handlers.add(handler); } } profiler.end(); if (handlers.isEmpty()) { return false; } mc.displayGuiScreen(new GuiUsageRecipe(prevscreen, handlers)); return true; }
Example 8
Source Project: NotEnoughItems Source File: FastTransferManager.java License: MIT License | 6 votes |
public void throwAll(GuiContainer window, int pickedUpFromSlot) { ItemStack held = NEIClientUtils.getHeldItem(); if (held.isEmpty()) { return; } clickSlot(window, -999); generateSlotMap(window.inventorySlots, held); Integer zone = slotZoneMap.get(pickedUpFromSlot); if (zone == null) //something went wrong and we can't work out where the item was picked up from { return; } for (int slotIndex : slotZones.get(zone)) { Slot slot = window.inventorySlots.getSlot(slotIndex); if (areStacksSameType(held, slot.getStack())) { clickSlot(window, slotIndex); clickSlot(window, -999); } } }
Example 9
Source Project: NotEnoughItems Source File: ItemPanel.java License: MIT License | 5 votes |
private boolean slotValid(GuiContainer gui, int i) { Rectangle4i rect = getSlotRect(i); for (INEIGuiHandler handler : GuiInfo.guiHandlers) if (handler.hideItemPanelSlot(gui, rect.x, rect.y, rect.w, rect.h)) return false; return true; }
Example 10
Source Project: NotEnoughItems Source File: NEIClientUtils.java License: MIT License | 5 votes |
public static GuiContainer getGuiContainer() { if (mc().currentScreen instanceof GuiContainer) { return (GuiContainer) mc().currentScreen; } return null; }
Example 11
Source Project: NotEnoughItems Source File: NEIClientConfig.java License: MIT License | 5 votes |
public static void saveState(int state) { NBTTagCompound statesave = global.nbt.getCompoundTag("save" + state); GuiContainer currentContainer = NEIClientUtils.getGuiContainer(); LinkedList<TaggedInventoryArea> saveAreas = new LinkedList<TaggedInventoryArea>(); saveAreas.add(new TaggedInventoryArea(Minecraft.getMinecraft().thePlayer.inventory)); for (INEIGuiHandler handler : GuiInfo.guiHandlers) { List<TaggedInventoryArea> areaList = handler.getInventoryAreas(currentContainer); if (areaList != null) saveAreas.addAll(areaList); } for (TaggedInventoryArea area : saveAreas) { NBTTagList areaTag = new NBTTagList(); for (int i : area.slots) { ItemStack stack = area.getStackInSlot(i); if (stack == null) continue; NBTTagCompound stacksave = new NBTTagCompound(); stacksave.setByte("Slot", (byte) i); stack.writeToNBT(stacksave); areaTag.appendTag(stacksave); } statesave.setTag(area.tagName, areaTag); } global.nbt.setTag("save" + state, statesave); global.saveNBT(); statesSaved[state] = true; }
Example 12
Source Project: NotEnoughItems Source File: DefaultOverlayHandler.java License: MIT License | 5 votes |
@SuppressWarnings("unchecked") private void findInventoryQuantities(GuiContainer gui, List<DistributedIngred> ingredStacks) { for(Slot slot : (List<Slot>)gui.inventorySlots.inventorySlots)//work out how much we have to go round { if(slot.getHasStack() && canMoveFrom(slot, gui)) { ItemStack pstack = slot.getStack(); DistributedIngred istack = findIngred(ingredStacks, pstack); if(istack != null) istack.invAmount+=pstack.stackSize; } } }
Example 13
Source Project: NotEnoughItems Source File: DefaultSlotClickHandler.java License: MIT License | 5 votes |
@Override public boolean handleSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, ClickType clickType, boolean eventConsumed) { if (!eventConsumed) { callHandleMouseClick(gui, slot, slotIndex, button, clickType); } return true; }
Example 14
Source Project: NotEnoughItems Source File: NEIColossalChestsConfig.java License: MIT License | 5 votes |
@Override public void loadConfig() { try { Class<?> clazz = null; try { clazz = ReflectionManager.findClass("org.cyclops.colossalchests.client.gui.container.GuiColossalChest"); } catch (Exception ignored) { } if (clazz != null) { API.addFastTransferExemptContainer((Class<? extends GuiContainer>) clazz); } } catch (Exception e) { LogHelper.fatalError("Something went wring trying to enable ColossalChests ingegration.", e); } }
Example 15
Source Project: NotEnoughItems Source File: LayoutManager.java License: MIT License | 5 votes |
public void renderObjects(GuiContainer gui, int mousex, int mousey) { if (!isHidden()) { layout(gui); if (isEnabled()) { getLayoutStyle().drawBackground(GuiContainerManager.getManager(gui)); for (Widget widget : drawWidgets) widget.draw(mousex, mousey); } else { options.draw(mousex, mousey); } GlStateManager.enableLighting(); GlStateManager.disableDepth(); } }
Example 16
Source Project: NotEnoughItems Source File: LayoutManager.java License: MIT License | 5 votes |
@Override public ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) { if (!isHidden() && isEnabled()) { for (Widget widget : controlWidgets) { ItemStack stack = widget.getStackMouseOver(mousex, mousey); if (!stack.isEmpty()) { return stack; } } } return ItemStack.EMPTY; }
Example 17
Source Project: PneumaticCraft Source File: ItemDrawHandler.java License: GNU General Public License v3.0 | 5 votes |
@Override public void renderSlotUnderlay(GuiContainer gui, Slot slot){ if(slot.getHasStack() && searchStack != null && RenderSearchItemBlock.getSearchedItemCount(slot.getStack(), searchStack) > 0) { GL11.glEnable(GL11.GL_BLEND); FMLClientHandler.instance().getClient().getTextureManager().bindTexture(Textures.ITEM_SEARCH_OVERLAY); Gui.func_146110_a(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16); } }
Example 18
Source Project: NotEnoughItems Source File: LayoutManager.java License: MIT License | 5 votes |
@Override public void postRenderObjects(GuiContainer gui, int mousex, int mousey) { if (!isHidden() && isEnabled()) { for (Widget widget : drawWidgets) widget.postDraw(mousex, mousey); } }
Example 19
Source Project: NotEnoughItems Source File: GuiContainerManager.java License: MIT License | 5 votes |
public GuiContainerManager(GuiContainer screen) { window = screen; if (screen instanceof IContainerTooltipHandler) { instanceTooltipHandlers = new LinkedList<IContainerTooltipHandler>(); instanceTooltipHandlers.add((IContainerTooltipHandler) screen); instanceTooltipHandlers.addAll(tooltipHandlers); } else instanceTooltipHandlers = tooltipHandlers; }
Example 20
Source Project: NotEnoughItems Source File: TemplateRecipeHandler.java License: MIT License | 5 votes |
private static boolean transferRect(GuiContainer gui, Collection<RecipeTransferRect> transferRects, int offsetx, int offsety, boolean usage) { Point pos = getMousePosition(); Point relMouse = new Point(pos.x - gui.guiLeft - offsetx, pos.y - gui.guiTop - offsety); for (RecipeTransferRect rect : transferRects) { if (rect.rect.contains(relMouse) && (usage ? GuiUsageRecipe.openRecipeGui(rect.outputId, rect.results) : GuiCraftingRecipe.openRecipeGui(rect.outputId, rect.results))) { return true; } } return false; }
Example 21
Source Project: NotEnoughItems Source File: LayoutStyleTMIOld.java License: MIT License | 5 votes |
@Override public void drawBackground(GuiContainer gui) { if (clickButtonCount == 0 && stateButtonCount == 0) { return; } int maxx = Math.max(stateButtonCount, clickButtonCount); if (maxx > 4) { maxx = 4; } int maxy = clickButtonCount == 0 ? 1 : (clickButtonCount / 4 + 2); drawRect(0, 0, 2 + 22 * maxx, 1 + maxy * 17, 0xFF000000); }
Example 22
Source Project: AdvancedRocketry Source File: ModulePanetImage.java License: MIT License | 5 votes |
@Override public void renderBackground(GuiContainer gui, int x, int y, int mouseX, int mouseY, FontRenderer font) { super.renderBackground(gui, x, y, mouseX, mouseY, font); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexbuffer = tessellator.getBuffer(); GL11.glPushMatrix(); GL11.glRotated(90, -1, 0, 0); //GL11.glTranslatef(xPosition, 100 + this.zLevel, yPosition); float newWidth = width/2f; RenderPlanetarySky.renderPlanetPubHelper(vertexbuffer, properties.getPlanetIcon(), (int)(x + this.offsetX + newWidth), (int)(y + this.offsetY + newWidth), (double)-0.1, newWidth, 1f, properties.getSolarTheta(), properties.hasAtmosphere(), properties.skyColor, properties.ringColor, properties.isGasGiant(), properties.hasRings()); GL11.glPopMatrix(); }
Example 23
Source Project: NotEnoughItems Source File: DefaultOverlayHandler.java License: MIT License | 5 votes |
@SuppressWarnings ("unchecked") private void findInventoryQuantities(GuiContainer gui, List<DistributedIngred> ingredStacks) { for (Slot slot : gui.inventorySlots.inventorySlots)//work out how much we have to go round { if (slot.getHasStack() && canMoveFrom(slot, gui)) { ItemStack pstack = slot.getStack(); DistributedIngred istack = findIngred(ingredStacks, pstack); if (istack != null) { istack.invAmount += pstack.getCount(); } } } }
Example 24
Source Project: NotEnoughItems Source File: FastTransferManager.java License: MIT License | 5 votes |
public void retrieveItem(GuiContainer window, int toSlot) { Slot slot = window.inventorySlots.getSlot(toSlot); ItemStack slotStack = slot.getStack(); if (slotStack == null || slotStack.stackSize == slot.getSlotStackLimit() || slotStack.stackSize == slotStack.getMaxStackSize()) return; generateSlotMap(window.inventorySlots, slotStack); Integer destZone = slotZoneMap.get(toSlot); if (destZone == null)//slots that don't accept return; int firstZoneSlot = findShiftClickDestinationSlot(window.inventorySlots, toSlot); int firstZone = -1; if (firstZoneSlot != -1) { Integer integer = slotZoneMap.get(firstZoneSlot); if (integer != null) { firstZone = integer; if (retrieveItemFromZone(window, firstZone, toSlot)) return; } } for (int zone = 0; zone < slotZones.size(); zone++) { if (zone == destZone || zone == firstZone) continue; if (retrieveItemFromZone(window, zone, toSlot)) return; } retrieveItemFromZone(window, destZone, toSlot); }
Example 25
Source Project: NotEnoughItems Source File: TemplateRecipeHandler.java License: MIT License | 5 votes |
private static boolean transferRect(GuiContainer gui, Collection<RecipeTransferRect> transferRects, int offsetx, int offsety, boolean usage) { Point pos = getMousePosition(); Point relMouse = new Point(pos.x - gui.guiLeft - offsetx, pos.y - gui.guiTop - offsety); for (RecipeTransferRect rect : transferRects) { if (rect.rect.contains(relMouse) && (usage ? GuiUsageRecipe.openRecipeGui(rect.outputId, rect.results) : GuiCraftingRecipe.openRecipeGui(rect.outputId, rect.results))) return true; } return false; }
Example 26
Source Project: GardenCollection Source File: NEIIntegration.java License: MIT License | 4 votes |
@Override public Class<? extends GuiContainer> getGuiClass () { return GuiCompostBin.class; }
Example 27
Source Project: NotEnoughItems Source File: TemplateRecipeHandler.java License: MIT License | 4 votes |
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe) { IStackPositioner positioner = RecipeInfo.getStackPositioner(gui, getOverlayIdentifier()); if (positioner == null) return null; return new DefaultOverlayRenderer(getIngredientStacks(recipe), positioner); }
Example 28
Source Project: NotEnoughItems Source File: TemplateRecipeHandler.java License: MIT License | 4 votes |
@Override public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List<String> currenttip) { return currenttip; }
Example 29
Source Project: LiquidBounce Source File: KeepContainer.java License: GNU General Public License v3.0 | 4 votes |
@EventTarget public void onGui(final ScreenEvent event) { if(event.getGuiScreen() instanceof GuiContainer && !(event.getGuiScreen() instanceof GuiInventory)) container = (GuiContainer) event.getGuiScreen(); }
Example 30
Source Project: NotEnoughItems Source File: RecipeItemInputHandler.java License: MIT License | 4 votes |
@Override public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { }