codechicken.nei.guihook.GuiContainerManager Java Examples

The following examples show how to use codechicken.nei.guihook.GuiContainerManager. 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: DefaultOverlayRenderer.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void renderOverlay(GuiContainerManager gui, Slot slot) {
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);

    GuiContainerManager.setItemRenderColour(0xA0A0A0B0);
    for (PositionedStack stack : ingreds) {
        if (stack.relx == slot.xPos && stack.rely == slot.yPos) {
            GuiContainerManager.drawItem(stack.relx, stack.rely, stack.item);
        }
    }
    GuiContainerManager.setItemRenderColour(-1);

    GlStateManager.disableBlend();
    GlStateManager.enableLighting();
}
 
Example #2
Source File: PneumaticCraftPlugins.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public List<String> handleTooltip(GuiRecipe guiRecipe, List<String> currenttip, int recipe){
    //  super.handleTooltip(guiRecipe, currenttip, recipe);
    MultipleInputOutputRecipe r = (MultipleInputOutputRecipe)arecipes.get(recipe);
    if(GuiContainerManager.shouldShowTooltip(guiRecipe)) {
        Point mouse = GuiDraw.getMousePosition();
        Point offset = guiRecipe.getRecipePosition(recipe);
        Point relMouse = new Point(mouse.x - (guiRecipe.width - 176) / 2 - offset.x, mouse.y - (guiRecipe.height - 166) / 2 - offset.y);

        for(IGuiWidget widget : r.tooltipWidgets) {
            if(widget.getBounds().contains(relMouse)) {
                widget.addTooltip(mouse.x, mouse.y, currenttip, false);
            }
        }
        if(r.tempWidget != null) {
            if(r.tempWidget.getBounds().contains(relMouse)) {
                r.heatExchanger.setTemperature(r.tempWidget.getScales()[0]);
                r.tempWidget.addTooltip(mouse.x, mouse.y, currenttip, false);
            }
        }
    }
    return currenttip;
}
 
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: GuiItemIconDumper.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void drawItems() {
    Dimension d = GuiDraw.displayRes();

    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0, d.width*16D/iconSize, d.height*16D/iconSize, 0, 1000, 3000);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.clearColor(0, 0, 0, 0);
    GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    int rows = d.height / boxSize;
    int cols = d.width / boxSize;
    int fit = rows*cols;

    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    GlStateManager.color(1, 1, 1, 1);

    for(int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) {
        int x = i%cols * 18;
        int y = i/cols * 18;
        GuiContainerManager.drawItem(x+1, y+1, ItemPanel.items.get(drawIndex));
    }

    GL11.glFlush();
}
 
Example #5
Source File: OptionUtilities.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void drawIcons()
{
    int x = buttonX();
    LayoutManager.drawIcon(x+4, 4, new Image(120, 24, 12, 12)); x+=24;
    LayoutManager.drawIcon(x+4, 4, new Image(120, 12, 12, 12)); x+=24;
    LayoutManager.drawIcon(x+4, 4, new Image(168, 24, 12, 12)); x+=24;
    LayoutManager.drawIcon(x+4, 4, new Image(144, 12, 12, 12)); x+=24;
    LayoutManager.drawIcon(x+4, 4, new Image(180, 24, 12, 12)); x+=24;
    LayoutManager.drawIcon(x+4, 4, new Image(132, 12, 12, 12)); x+=24;
    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    ItemStack sword = new ItemStack(Items.diamond_sword);
    sword.addEnchantment(Enchantment.sharpness, 1);
    GuiContainerManager.drawItem(x+2, 2, sword); x+=24;
    GuiContainerManager.drawItem(x+2, 2, new ItemStack(Items.potionitem)); x+=24;
    GuiContainerManager.drawItem(x+2, 2, new ItemStack(Blocks.stone)); x+=24;
}
 
Example #6
Source File: GuiRecipe.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
    GuiContainerManager.enable2DRender();

    IRecipeHandler recipehandler = currenthandlers.get(recipetype);
    String s = recipehandler.getRecipeName();
    fontRendererObj.drawString(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, 5, 0x404040);
    s = NEIClientUtils.translate("recipe.page", page + 1, (currenthandlers.get(recipetype).numRecipes() - 1) / recipehandler.recipiesPerPage() + 1);
    fontRendererObj.drawString(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, ySize - 16, 0x404040);

    GlStateManager.pushMatrix();
    GlStateManager.translate(5, 16, 0);
    for (int i = page * recipehandler.recipiesPerPage(); i < recipehandler.numRecipes() && i < (page + 1) * recipehandler.recipiesPerPage(); i++) {
        recipehandler.drawForeground(i);
        GlStateManager.translate(0, 65, 0);
    }
    GlStateManager.popMatrix();
}
 
Example #7
Source File: GuiRecipe.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void keyTyped(char c, int i) {
    if (i == 1)//esc
    {
        mc.displayGuiScreen(firstGui);
        return;
    }
    if (GuiContainerManager.getManager(this).lastKeyTyped(i, c))
        return;

    IRecipeHandler recipehandler = currenthandlers.get(recipetype);
    for (int recipe = page * recipehandler.recipiesPerPage(); recipe < recipehandler.numRecipes() && recipe < (page + 1) * recipehandler.recipiesPerPage(); recipe++)
        if (recipehandler.keyTyped(this, c, i, recipe))
            return;

    if (i == mc.gameSettings.keyBindInventory.getKeyCode())
        mc.displayGuiScreen(firstGui);
    else if (i == NEIClientConfig.getKeyBinding("gui.back"))
        mc.displayGuiScreen(prevGui);

}
 
Example #8
Source File: SubsetWidget.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
protected void drawSlot(int slot, int x, int y, int mx, int my, float frame) {
    int w = windowBounds().width;
    Rectangle4i r = new Rectangle4i(x, y, w, getSlotHeight(slot));
    if(slot < sorted.size()) {
        SubsetTag tag = sorted.get(slot);
        LayoutManager.getLayoutStyle().drawSubsetTag(tag.displayName(), x, y, r.w, r.h, tag.state.state, r.contains(mx, my));
    }
    else {
        ItemStack stack = state.items.get(slot-sorted.size());
        boolean hidden = SubsetWidget.isHidden(stack);

        int itemx = w/2-8;
        int itemy = 1;

        LayoutManager.getLayoutStyle().drawSubsetTag(null, x, y, r.w, r.h, hidden ? 0 : 2, false);

        GuiContainerManager.drawItem(x+itemx, y+itemy, stack);
        if(new Rectangle4i(itemx, itemy, 16, 16).contains(mx, my))
            SubsetWidget.hoverStack = stack;
    }
}
 
Example #9
Source File: NEIController.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) {
    if (!NEIClientConfig.isEnabled() ||
            GuiInfo.hasCustomSlots(gui) ||
            isSpreading(gui))
        return false;

    Slot slot = GuiContainerManager.getSlotMouseOver(gui);
    if (slot == null)
        return false;

    int slotIndex = slot.slotNumber;

    if (keyCode == Minecraft.getMinecraft().gameSettings.keyBindDrop.getKeyCode() && NEIClientUtils.shiftKey()) {
        FastTransferManager.clickSlot(gui, slotIndex);
        fastTransferManager.throwAll(gui, slotIndex);
        FastTransferManager.clickSlot(gui, slotIndex);

        return true;
    }

    return false;
}
 
Example #10
Source File: ItemPanel.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void draw(int mousex, int mousey) {
    if (itemsPerPage == 0)
        return;

    GuiContainerManager.enableMatrixStackLogging();
    int index = firstIndex;
    for (int i = 0; i < rows * columns && index < items.size(); i++) {
        if (validSlotMap[i]) {
            Rectangle4i rect = getSlotRect(i);
            if (rect.contains(mousex, mousey))
                drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555);//highlight

            GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, items.get(index));

            index++;
        }
    }
    GuiContainerManager.disableMatrixStackLogging();
}
 
Example #11
Source File: RecipeItemInputHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
    ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
    if (stackover == null || !(gui instanceof GuiRecipe)) {
        return false;
    }

    if (button == 0) {
        return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
    }

    if (button == 1) {
        return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
    }

    return false;
}
 
Example #12
Source File: GuiRecipe.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void keyTyped(char c, int i) {
    if (i == 1)//esc
    {
        mc.displayGuiScreen(firstGui);
        return;
    }
    if (GuiContainerManager.getManager(this).lastKeyTyped(c, i)) {
        return;
    }

    IRecipeHandler recipehandler = currenthandlers.get(recipetype);
    for (int recipe = page * recipehandler.recipiesPerPage(); recipe < recipehandler.numRecipes() && recipe < (page + 1) * recipehandler.recipiesPerPage(); recipe++) {
        if (recipehandler.keyTyped(this, c, i, recipe)) {
            return;
        }
    }

    if (mc.gameSettings.keyBindInventory.isActiveAndMatches(i)) {
        mc.displayGuiScreen(firstGui);
    } else if (KeyBindings.get("nei.options.keys.gui.back").isActiveAndMatches(i)) {
        mc.displayGuiScreen(prevGui);
    }

}
 
Example #13
Source File: GuiRecipe.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
    GuiContainerManager.enable2DRender();

    IRecipeHandler recipehandler = currenthandlers.get(recipetype);
    String s = recipehandler.getRecipeName();
    fontRendererObj.drawString(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, 5, 0x404040);
    s = NEIClientUtils.translate("recipe.page", page + 1, (currenthandlers.get(recipetype).numRecipes() - 1) / recipehandler.recipiesPerPage() + 1);
    fontRendererObj.drawString(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, ySize - 16, 0x404040);

    GlStateManager.pushMatrix();
    GlStateManager.translate(5, 16, 0);
    for (int i = page * recipehandler.recipiesPerPage(); i < recipehandler.numRecipes() && i < (page + 1) * recipehandler.recipiesPerPage(); i++) {
        recipehandler.drawForeground(i);
        GlStateManager.translate(0, 65, 0);
    }
    GlStateManager.popMatrix();
}
 
Example #14
Source File: GuiContainer.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public void setWorldAndResolution(Minecraft mc, int i, int j) {
    super.setWorldAndResolution(mc, i, j);
    if (mc.currentScreen == this) {
        manager = new GuiContainerManager(this);
        manager.load();
    }
}
 
Example #15
Source File: GuiContainer.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public void setWorldAndResolution(Minecraft mc, int i, int j)
{
    super.setWorldAndResolution(mc, i, j);
    if(mc.currentScreen == this)
    {
        manager = new GuiContainerManager(this);
        manager.load();
    }
}
 
Example #16
Source File: WailaNBT.java    From wailanbt with MIT License 5 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
@SideOnly(Side.CLIENT)
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event){
    GuiContainerManager.addTooltipHandler(new TooltipHandler());

}
 
Example #17
Source File: RecipeHandlerBase.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(GuiRecipe guiRecipe, List<String> currenttip, int recipe) {
    super.handleTooltip(guiRecipe, currenttip, recipe);
    CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
    if (GuiContainerManager.shouldShowTooltip(guiRecipe)) {
        Point mouse = GuiDraw.getMousePosition();
        Point offset = guiRecipe.getRecipePosition(recipe);
        Point relMouse = new Point(mouse.x - (guiRecipe.width - 176) / 2 - offset.x, mouse.y - (guiRecipe.height - 166) / 2 - offset.y);
        
        currenttip = this.provideTooltip(guiRecipe, currenttip, crecipe, relMouse);
    }
    return currenttip;
}
 
Example #18
Source File: TooltipHandler.java    From OmniOcular with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> handleItemTooltip(GuiContainer guiContainer, ItemStack itemStack, int i, int i2, List<String> currenttip) {
    if (guiContainer != null && GuiContainerManager.shouldShowTooltip(guiContainer) && itemStack != null) {
        NBTTagCompound n = itemStack.getTagCompound();

        //accessor.getTileEntity().writeToNBT(n);
        if (n != null) {
            currenttip.addAll(1, JSHandler.getBody(ConfigHandler.tooltipPattern, n, Item.itemRegistry.getNameForObject(itemStack.getItem()), guiContainer.mc.thePlayer));

        }
    }
    return currenttip;
}
 
Example #19
Source File: LayoutStyleTMIOld.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void drawBackground(GuiContainerManager 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 #20
Source File: ItemPanelDumper.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public Iterable<String[]> dump(int mode) {
    LinkedList<String[]> list = new LinkedList<String[]>();
    for (ItemStack stack : ItemPanel.items)
        list.add(new String[]{
                Item.itemRegistry.getNameForObject(stack.getItem()).toString(),
                Integer.toString(Item.getIdFromItem(stack.getItem())),
                Integer.toString(InventoryUtils.actualDamage(stack)),
                stack.getTagCompound() == null ? "false" : "true",
                EnumChatFormatting.getTextWithoutFormattingCodes(GuiContainerManager.itemDisplayNameShort(stack))
        });

    return list;
}
 
Example #21
Source File: TemplateRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
    if (!canHandle(gui)) {
        return currenttip;
    }

    if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) {
        int[] offset = RecipeInfo.getGuiOffset(gui);
        currenttip = TemplateRecipeHandler.transferRectTooltip(gui, guiMap.get(gui.getClass()), offset[0], offset[1], currenttip);
    }
    return currenttip;
}
 
Example #22
Source File: TemplateRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe) {
    if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) {
        Point offset = gui.getRecipePosition(recipe);
        currenttip = transferRectTooltip(gui, transferRects, offset.x, offset.y, currenttip);
    }
    return currenttip;
}
 
Example #23
Source File: FireworkRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe) {
    currenttip = super.handleTooltip(gui, currenttip, recipe);
    Point mousepos = GuiDraw.getMousePosition();
    Point relMouse = new Point(mousepos.x - gui.guiLeft, mousepos.y - gui.guiTop);
    Point recipepos = gui.getRecipePosition(recipe);
    if (currenttip.isEmpty() && GuiContainerManager.getStackMouseOver(gui) == null &&
            new Rectangle(recipepos.x, recipepos.y, 166, 55).contains(relMouse))
        currenttip.add(NEIClientUtils.translate(
                "recipe.firework.tooltip" + ((CachedFireworkRecipe) arecipes.get(recipe)).recipeType));
    return currenttip;
}
 
Example #24
Source File: RecipeItemInputHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button)
{
    ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
    if(stackover == null || !(gui instanceof GuiRecipe))
        return false;
    
    if(button == 0)
        return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());

    if(button == 1)
        return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
    
    return false;
}
 
Example #25
Source File: RecipeItemInputHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode)
{
    ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
    if(stackover == null)
        return false;
            
    if(keyCode == NEIClientConfig.getKeyBinding("gui.usage") || (keyCode == NEIClientConfig.getKeyBinding("gui.recipe") && NEIClientUtils.shiftKey()))
        return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
    
    if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
        return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
    
    return false;
}
 
Example #26
Source File: TemplateRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe) {
    if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) {
        Point offset = gui.getRecipePosition(recipe);
        currenttip = transferRectTooltip(gui, transferRects, offset.x, offset.y, currenttip);
    }
    return currenttip;
}
 
Example #27
Source File: TemplateRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
    if (!canHandle(gui))
        return currenttip;

    if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) {
        int[] offset = RecipeInfo.getGuiOffset(gui);
        currenttip = TemplateRecipeHandler.transferRectTooltip(gui, guiMap.get(gui.getClass()), offset[0], offset[1], currenttip);
    }
    return currenttip;
}
 
Example #28
Source File: DefaultOverlayRenderer.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void renderOverlay(GuiContainerManager gui, Slot slot) {
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);

    GuiContainerManager.setItemRenderColour(0xA0A0A0B0);
    for (PositionedStack stack : ingreds) {
        if (stack.relx == slot.xDisplayPosition && stack.rely == slot.yDisplayPosition)
            GuiContainerManager.drawItem(stack.relx, stack.rely, stack.item);
    }
    GuiContainerManager.setItemRenderColour(-1);

    GlStateManager.disableBlend();
    GlStateManager.enableLighting();
}
 
Example #29
Source File: ItemInfo.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static String getSearchName(ItemStack stack) {
    String s = itemSearchNames.get(stack);
    if(s == null) {
        s = EnumChatFormatting.getTextWithoutFormattingCodes(GuiContainerManager.concatenatedDisplayName(stack, true).toLowerCase());
        itemSearchNames.put(stack, s);
    }
    return s;
}
 
Example #30
Source File: FireworkRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe) {
    currenttip = super.handleTooltip(gui, currenttip, recipe);
    Point mousepos = GuiDraw.getMousePosition();
    Point relMouse = new Point(mousepos.x - gui.guiLeft, mousepos.y - gui.guiTop);
    Point recipepos = gui.getRecipePosition(recipe);
    if (currenttip.isEmpty() && GuiContainerManager.getStackMouseOver(gui) == null && new Rectangle(recipepos.x, recipepos.y, 166, 55).contains(relMouse)) {
        currenttip.add(NEIClientUtils.translate("recipe.firework.tooltip" + ((CachedFireworkRecipe) arecipes.get(recipe)).recipeType));
    }
    return currenttip;
}