@Override public void onOpened(IGuiLexiconEntry gui) { int yOff = 0; if (multiblock != null) { ItemStack[][][] structure = multiblock; structureHeight = structure.length; structureWidth = 0; structureLength = 0; countPerLevel = new int[structureHeight]; blockCount = 0; for (int h = 0; h < structure.length; h++) { if (structure[h].length - 1 > structureLength) structureLength = structure[h].length - 1; int perLvl = 0; for (int l = 0; l < structure[h].length; l++) { if (structure[h][l].length - 1 > structureWidth) structureWidth = structure[h][l].length - 1; for (ItemStack ss : structure[h][l]) if (ss != null) perLvl++; } countPerLevel[h] = perLvl; blockCount += perLvl; } tick = (showLayer == -1 ? blockCount : countPerLevel[showLayer]) * 40; yOff = (structureHeight - 1) * 12 + structureWidth * 5 + structureLength * 5 + 16; yOff = Math.max(48, yOff); int x = gui.getLeft(); int y = gui.getTop(); gui.getButtonList() .add( new GuiButtonManualNavigation( gui, this, 100, x + 20, y + 10 + yOff / 2 - 5, 10, 10, 4)); if (structureHeight > 1) { gui.getButtonList() .add( new GuiButtonManualNavigation( gui, this, 101, x + 20, y + 10 + yOff / 2 - 8 - 16, 10, 16, 3)); gui.getButtonList() .add( new GuiButtonManualNavigation( gui, this, 102, x + 20, y + 10 + yOff / 2 + 8, 10, 16, 2)); } } super.onOpened(gui); }
@Override public void renderScreen(IGuiLexiconEntry gui, int mx, int my) { int x = gui.getLeft(); int y = gui.getTop(); int yOffPartial = 0; if (multiblock != null) { if (canTick) tick++; ItemStack[][][] structure = multiblock; int prevLayers = 0; if (showLayer != -1) for (int ll = 0; ll < showLayer; ll++) prevLayers += countPerLevel[ll]; int limiter = prevLayers + (tick / 40) % ((showLayer == -1 ? blockCount : countPerLevel[showLayer]) + 4); int xHalf = (structureWidth * 5 - structureLength * 5); yOffPartial = (structureHeight - 1) * 12 + structureWidth * 5 + structureLength * 5 + 16; int yOffTotal = Math.max(48, yOffPartial + 16); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); RenderItem.getInstance().renderWithColor = true; int i = 0; ItemStack highlighted = null; for (int h = 0; h < structure.length; h++) if (showLayer == -1 || h <= showLayer) { ItemStack[][] level = structure[h]; for (int l = level.length - 1; l >= 0; l--) { ItemStack[] row = level[l]; for (int w = row.length - 1; w >= 0; w--) { int xx = 60 + xHalf - 10 * w + 10 * l - 7; int yy = yOffPartial - 5 * w - 5 * l - 12 * h; GL11.glTranslated(0, 0, 1); if (row[w] != null && i <= limiter) { i++; RenderItem.getInstance() .renderItemIntoGUI( Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().renderEngine, row[w], x + xx, y + yy); if (mx >= x + xx && mx < x + xx + 16 && my >= y + yy && my < y + yy + 16) highlighted = row[w]; } } } } GL11.glTranslated(0, 0, -i); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); Minecraft.getMinecraft().fontRenderer.setUnicodeFlag(false); if (highlighted != null) { ((GuiLexiconEntry) gui).renderToolTip(highlighted, mx, my); } RenderHelper.disableStandardItemLighting(); /* Minecraft.getMinecraft().fontRenderer.setUnicodeFlag(true); if(localizedText!=null&&!localizedText.isEmpty()) Minecraft.getMinecraft().fontRenderer.drawSplitString(localizedText, x,y+yOffTotal, 120, 0); */ } int width = gui.getWidth() - 34; x = gui.getLeft() + 16; y = gui.getTop() + 10 + yOffPartial; renderText(x, y, width, getUnlocalizedName()); }