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

The following examples show how to use net.minecraft.client.gui.inventory.GuiContainer. 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: FastTransferManager.java    From NotEnoughItems with MIT License 6 votes vote down vote up
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 #2
Source File: NEIController.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@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 #3
Source File: TooltipHandler.java    From wailanbt with MIT License 6 votes vote down vote up
@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 #4
Source File: FastTransferManager.java    From NotEnoughItems with MIT License 6 votes vote down vote up
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 #5
Source File: NoLimitBuffs.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@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 #6
Source File: NEISelect.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@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 #7
Source File: LayoutManager.java    From NotEnoughItems with MIT License 6 votes vote down vote up
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 #8
Source File: GuiUsageRecipe.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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 #9
Source File: ItemPanel.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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 File: NEIClientUtils.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static GuiContainer getGuiContainer() {
    if (mc().currentScreen instanceof GuiContainer) {
        return (GuiContainer) mc().currentScreen;
    }

    return null;
}
 
Example #11
Source File: NEIClientConfig.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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 File: DefaultOverlayHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@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 File: ItemDrawHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@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 #14
Source File: DefaultSlotClickHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@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 #15
Source File: NEIColossalChestsConfig.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@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 #16
Source File: LayoutManager.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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 #17
Source File: LayoutManager.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@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 #18
Source File: TemplateRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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 #19
Source File: FastTransferManager.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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 #20
Source File: LayoutManager.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void postRenderObjects(GuiContainer gui, int mousex, int mousey) {
    if (!isHidden() && isEnabled()) {
        for (Widget widget : drawWidgets)
            widget.postDraw(mousex, mousey);
    }
}
 
Example #21
Source File: DefaultOverlayHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@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 #22
Source File: ModulePanetImage.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@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 File: GuiContainerManager.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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 #24
Source File: TemplateRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
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 #25
Source File: LayoutStyleTMIOld.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@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 #26
Source File: GuiRecipe.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public GuiContainer getFirstScreen() {
    return firstGui;
}
 
Example #27
Source File: RecipeItemInputHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) {
}
 
Example #28
Source File: Debug.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
public static GuiContainer getGuiContainer(GuiScreen screen) {
    return screen instanceof GuiContainer ? (GuiContainer) screen : null;
}
 
Example #29
Source File: KeepContainer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@EventTarget
public void onGui(final ScreenEvent event) {
    if(event.getGuiScreen() instanceof GuiContainer && !(event.getGuiScreen() instanceof GuiInventory))
        container = (GuiContainer) event.getGuiScreen();
}
 
Example #30
Source File: ShapedRecipeHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public Class<? extends GuiContainer> getGuiClass() {
    return GuiCrafting.class;
}