diff options
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java | 4201 |
1 files changed, 2269 insertions, 1932 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java index 664d684b..bce5bfbd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java @@ -29,7 +29,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; - +import net.minecraftforge.client.ClientCommandHandler; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -38,1950 +38,2287 @@ import org.lwjgl.util.vector.Vector2f; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.awt.*; - -import java.util.*; import java.util.List; +import java.util.*; public class StorageOverlay extends GuiElement { + private static final int CHEST_TOP_OFFSET = 17; + private static final int CHEST_SLOT_SIZE = 18; + private static final int CHEST_BOTTOM_OFFSET = 215; - private static final int CHEST_TOP_OFFSET = 17; - private static final int CHEST_SLOT_SIZE = 18; - private static final int CHEST_BOTTOM_OFFSET = 215; + private Framebuffer framebuffer = null; - private Framebuffer framebuffer = null; + private final Set<Vector2f> enchantGlintRenderLocations = new HashSet<>(); - private Set<Vector2f> enchantGlintRenderLocations = new HashSet<>(); + public static final ResourceLocation[] STORAGE_PREVIEW_TEXTURES = new ResourceLocation[4]; + private static final ResourceLocation[] STORAGE_TEXTURES = new ResourceLocation[4]; + private static final ResourceLocation STORAGE_ICONS_TEXTURE = new ResourceLocation( + "notenoughupdates:storage_gui/storage_icons.png"); + private static final ResourceLocation STORAGE_PANE_CTM_TEXTURE = new ResourceLocation( + "notenoughupdates:storage_gui/storage_gui_pane_ctm.png"); + private static final ResourceLocation[] LOAD_CIRCLE_SEQ = new ResourceLocation[11]; + private static final ResourceLocation[] NOT_RICKROLL_SEQ = new ResourceLocation[19]; - public static final ResourceLocation STORAGE_PREVIEW_TEXTURES[] = new ResourceLocation[4]; - private static final ResourceLocation STORAGE_TEXTURES[] = new ResourceLocation[4]; - private static final ResourceLocation STORAGE_ICONS_TEXTURE = new ResourceLocation("notenoughupdates:storage_gui/storage_icons.png"); - private static final ResourceLocation STORAGE_PANE_CTM_TEXTURE = new ResourceLocation("notenoughupdates:storage_gui/storage_gui_pane_ctm.png"); - private static final ResourceLocation[] LOAD_CIRCLE_SEQ = new ResourceLocation[11]; - private static final ResourceLocation[] NOT_RICKROLL_SEQ = new ResourceLocation[19]; - static { - for(int i=0; i<STORAGE_TEXTURES.length; i++) { - STORAGE_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_gui_"+i+".png"); - } - for(int i=0; i<STORAGE_PREVIEW_TEXTURES.length; i++) { - STORAGE_PREVIEW_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_preview_"+i+".png"); - } + static { + for (int i = 0; i < STORAGE_TEXTURES.length; i++) { + STORAGE_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_gui_" + i + ".png"); + } + for (int i = 0; i < STORAGE_PREVIEW_TEXTURES.length; i++) { + STORAGE_PREVIEW_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_preview_" + i + ".png"); + } - for(int i=0; i<NOT_RICKROLL_SEQ.length; i++) { - NOT_RICKROLL_SEQ[i] = new ResourceLocation("notenoughupdates:storage_gui/we_do_a_little_rolling/"+i+".jpg"); - } + for (int i = 0; i < NOT_RICKROLL_SEQ.length; i++) { + NOT_RICKROLL_SEQ[i] = new ResourceLocation("notenoughupdates:storage_gui/we_do_a_little_rolling/" + i + ".jpg"); + } - LOAD_CIRCLE_SEQ[0] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png"); - LOAD_CIRCLE_SEQ[1] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png"); - LOAD_CIRCLE_SEQ[2] = new ResourceLocation("notenoughupdates:loading_circle_seq/2.png"); - for(int i=2; i<=7; i++) { - LOAD_CIRCLE_SEQ[i+1] = new ResourceLocation("notenoughupdates:loading_circle_seq/"+i+".png"); - } - LOAD_CIRCLE_SEQ[9] = new ResourceLocation("notenoughupdates:loading_circle_seq/7.png"); - LOAD_CIRCLE_SEQ[10] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png"); - } + LOAD_CIRCLE_SEQ[0] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png"); + LOAD_CIRCLE_SEQ[1] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png"); + LOAD_CIRCLE_SEQ[2] = new ResourceLocation("notenoughupdates:loading_circle_seq/2.png"); + for (int i = 2; i <= 7; i++) { + LOAD_CIRCLE_SEQ[i + 1] = new ResourceLocation("notenoughupdates:loading_circle_seq/" + i + ".png"); + } + LOAD_CIRCLE_SEQ[9] = new ResourceLocation("notenoughupdates:loading_circle_seq/7.png"); + LOAD_CIRCLE_SEQ[10] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png"); + } - private static final StorageOverlay INSTANCE = new StorageOverlay(); - public static StorageOverlay getInstance() { - return INSTANCE; - } + private static final StorageOverlay INSTANCE = new StorageOverlay(); - private GuiElementTextField searchBar = new GuiElementTextField("", 88, 10, - GuiElementTextField.SCALE_TEXT | GuiElementTextField.DISABLE_BG); - private GuiElementTextField renameStorageField = new GuiElementTextField("", 100, 13, - GuiElementTextField.COLOUR); + public static StorageOverlay getInstance() { + return INSTANCE; + } - private int editingNameId = -1; - - private int guiLeft; - private int guiTop; - - private boolean fastRender = false; - - private int loadCircleIndex = 0; - private int rollIndex = 0; - private int loadCircleRotation = 0; - - private long millisAccumIndex = 0; - private long millisAccumRoll = 0; - private long millisAccumRotation = 0; - - private long lastMillis = 0; - - private int scrollVelocity = 0; - private long lastScroll = 0; - - private int[][] isPaneCaches = new int[40][]; - private int[][] ctmIndexCaches = new int[40][]; - - private int desiredHeightSwitch = -1; - private int desiredHeightMX = -1; - private int desiredHeightMY = -1; - - private boolean dirty = false; - private boolean allowTypingInSearchBar = true; - - private int scrollGrabOffset = -1; - - private LerpingInteger scroll = new LerpingInteger(0, 200); - - private int getMaximumScroll() { - synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) { - - int maxH = 0; - - for(int i=0; i<3; i++) { - int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.size()-1; - int coords = (int)Math.ceil(lastDisplayId/3f)*3+1+i; - - int h = getPageCoords(coords).y+scroll.getValue()-getStorageViewSize()-14; - - if(h > maxH) maxH = h; - } - - return maxH; - } - } - - public void markDirty() { - dirty = true; - } - - private void scrollToY(int y) { - int target = y; - if(target < 0) target = 0; - - int maxY = getMaximumScroll(); - if(target > maxY) target = maxY; - - float factor = (scroll.getValue()-target)/(float)(scroll.getValue()-y+1E-5); - - scroll.setTarget(target); - scroll.setTimeToReachTarget(Math.min(200, Math.max(20, (int)(200*factor)))); - scroll.resetTimer(); - } - - public void scrollToStorage(int displayId, boolean forceScroll) { - if(displayId < 0) return; - - int y = getPageCoords(displayId).y-17; - if(y < 3) { - scrollToY(y + scroll.getValue()); - } else { - int storageViewSize = getStorageViewSize(); - int y2 = getPageCoords(displayId+3).y-17-storageViewSize; - if(y2 > 3) { - if(forceScroll) { - scrollToY(y + scroll.getValue()); - } else { - scrollToY(y2+scroll.getValue()); - } - } - } - } - - private int getStorageViewSize() { - return NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight; - } - - private int getScrollBarHeight() { - return getStorageViewSize() - 21; - } - - @Override - public void render() { - if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return; - GuiChest guiChest = (GuiChest) Minecraft.getMinecraft().currentScreen; - ContainerChest containerChest = (ContainerChest) guiChest.inventorySlots; - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; - - scroll.tick(); - - int displayStyle = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle; - ResourceLocation storageTexture = STORAGE_TEXTURES[displayStyle]; - ResourceLocation storagePreviewTexture = STORAGE_PREVIEW_TEXTURES[displayStyle]; - int textColour = 0x404040; - int searchTextColour = 0xe0e0e0; - if(displayStyle == 2) { - textColour = 0x000000; - searchTextColour = 0xa0a0a0; - } else if(displayStyle == 3) { - textColour = 0xFBCC6C; - } else if(displayStyle == 0) { - textColour = 0x909090; - searchTextColour = 0xa0a0a0; - } - - long currentTime = System.currentTimeMillis(); - if(lastMillis > 0) { - long deltaTime = currentTime - lastMillis; - millisAccumIndex += deltaTime; - loadCircleIndex += millisAccumIndex / (1000/15); - millisAccumIndex %= (1000/15); - - millisAccumRotation += deltaTime; - loadCircleRotation += millisAccumRotation / (1000/107); - millisAccumRotation %= (1000/107); - - millisAccumRoll += deltaTime; - rollIndex += millisAccumRoll/100; - millisAccumRoll %= 100; - } - - lastMillis = currentTime; - loadCircleIndex %= LOAD_CIRCLE_SEQ.length; - rollIndex %= NOT_RICKROLL_SEQ.length*2; - loadCircleRotation %= 360; - - Color loadCircleColour = Color.getHSBColor(loadCircleRotation/360f, 0.3f, 0.9f); - ItemStack stackOnMouse = Minecraft.getMinecraft().thePlayer.inventory.getItemStack(); - if(stackOnMouse != null) { - String stackDisplay = Utils.cleanColour(stackOnMouse.getDisplayName()); - if(stackDisplay.startsWith("Backpack Slot ") || stackDisplay.startsWith("Empty Backpack Slot ") || - stackDisplay.startsWith("Ender Chest Page ")) { - stackOnMouse = null; - } - } - - List<String> tooltipToDisplay = null; - int slotPreview = -1; - - int storageViewSize = getStorageViewSize(); - - int sizeX = 540; - int sizeY = 100+storageViewSize; - int searchNobX = 18; - - int itemHoverX = -1; - int itemHoverY = -1; - - guiLeft = width/2 - (sizeX-searchNobX)/2; - guiTop = height/2 - sizeY/2; - - if(displayStyle == 0) { - BackgroundBlur.renderBlurredBackground(7, width, height, guiLeft, guiTop, sizeX, storageViewSize); - BackgroundBlur.renderBlurredBackground(7, width, height, guiLeft+5, guiTop+storageViewSize, sizeX-searchNobX-10, sizeY-storageViewSize-4); - } - - Utils.drawGradientRect(0, 0, width, height, 0xc0101010, 0xd0101010); - - GL11.glPushMatrix(); - GlStateManager.translate(guiLeft, guiTop, 0); - - boolean hoveringOtherBackpack = false; - - //Gui - Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(0, 0, sizeX, 10, 0, sizeX/600f, 0, 10/400f, GL11.GL_NEAREST); - Utils.drawTexturedRect(0, 10, sizeX, storageViewSize-20, 0, sizeX/600f, 10/400f, 94/400f, GL11.GL_NEAREST); - Utils.drawTexturedRect(0, storageViewSize-10, sizeX, 110, 0, sizeX/600f, 94/400f, 204/400f, GL11.GL_NEAREST); - - int maxScroll = getMaximumScroll(); - if(scroll.getValue() > maxScroll) { - scroll.setValue(maxScroll); - } - if(scroll.getValue() < 0) { - scroll.setValue(0); - } - - //Scroll bar - int scrollBarY = Math.round(getScrollBarHeight()*scroll.getValue()/(float)maxScroll); - float uMin = scrollGrabOffset >= 0 ? 12/600f : 0; - Utils.drawTexturedRect(520, 8+scrollBarY, 12, 15, uMin, uMin+12/600f, 250/400f, 265/400f, GL11.GL_NEAREST); - - int currentPage = StorageManager.getInstance().getCurrentPageId(); - - boolean mouseInsideStorages = mouseY > guiTop+3 && mouseY < guiTop+3+storageViewSize; - - //Storages - boolean doItemRender = true; - boolean doRenderFramebuffer = false; - int startY = getPageCoords(0).y; - if(OpenGlHelper.isFramebufferEnabled()) { - int h; - synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) { - int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.size()-1; - int coords = (int)Math.ceil(lastDisplayId/3f)*3+3; - - h = getPageCoords(coords).y+scroll.getValue(); - } - int w = sizeX; - - //Render from framebuffer - if(framebuffer != null) { - GlScissorStack.push(0, guiTop+3, width, guiTop+3+storageViewSize, scaledResolution); - GlStateManager.enableDepth(); - GlStateManager.translate(0, startY, 107.0001f); - framebuffer.bindFramebufferTexture(); - - GlStateManager.color(1, 1, 1, 1); - - GlStateManager.enableAlpha(); - GlStateManager.alphaFunc(GL11.GL_GREATER, 0F); - Utils.drawTexturedRect(0, 0, w, h, 0, 1, 1, 0, GL11.GL_NEAREST); - GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); - - renderEnchOverlay(enchantGlintRenderLocations); - - GlStateManager.translate(0, -startY, -107.0001f); - GlScissorStack.pop(scaledResolution); - } - - if(dirty || framebuffer == null) { - dirty = false; - - int fw = w*scaledResolution.getScaleFactor(); - int fh = h*scaledResolution.getScaleFactor(); - - if(framebuffer == null) { - framebuffer = new Framebuffer(fw, fh, true); - } else if(framebuffer.framebufferWidth != fw || framebuffer.framebufferHeight != fh) { - framebuffer.createBindFramebuffer(fw, fh); - } - framebuffer.framebufferClear(); - framebuffer.bindFramebuffer(true); - - GlStateManager.matrixMode(GL11.GL_PROJECTION); - GlStateManager.loadIdentity(); - GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D); - GlStateManager.matrixMode(GL11.GL_MODELVIEW); - - GlStateManager.pushMatrix(); - GlStateManager.translate(-guiLeft, -guiTop-startY, 0); - - doRenderFramebuffer = true; - } else { - doItemRender = false; - } - } - - if(doItemRender) { - enchantGlintRenderLocations.clear(); - for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) { - int displayId = entry.getKey(); - int storageId = entry.getValue(); - - IntPair coords = getPageCoords(displayId); - int storageX = coords.x; - int storageY = coords.y; - - if(!doRenderFramebuffer) { - if(coords.y-11 > 3+storageViewSize || coords.y+90 < 3) continue; - } - - StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false); - if(page != null && page.rows > 0) { - int rows = page.rows; - - isPaneCaches[storageId] = new int[page.rows*9]; - ctmIndexCaches[storageId] = new int[page.rows*9]; - int[] isPaneCache = isPaneCaches[storageId]; - int[] ctmIndexCache = ctmIndexCaches[storageId]; - - for(int k=0; k<rows*9; k++) { - ItemStack stack; - - if(storageId == currentPage) { - stack = containerChest.getSlot(k+9).getStack(); - } else { - stack = page.items[k]; - } - - int itemX = storageX+1+18*(k%9); - int itemY = storageY+1+18*(k/9); - - //Render fancy glass - if(stack != null) { - int paneType = getPaneType(stack, k, isPaneCache); - if(paneType > 0) { - GlStateManager.disableAlpha(); - Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000); - GlStateManager.enableAlpha(); - - int ctmIndex = getCTMIndex(page, k, isPaneCache, ctmIndexCache); - int startCTMX = (ctmIndex%12)*19; - int startCTMY = (ctmIndex/12)*19; - - ctmIndexCache[k] = ctmIndex; - - if(paneType != 17) { - int rgb = getRGBFromPane(paneType-1); - { - int a = (rgb >> 24) & 0xFF; - int r = (rgb >> 16) & 0xFF; - int g = (rgb >> 8) & 0xFF; - int b = rgb & 0xFF; - Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE); - GlStateManager.color(r/255f, g/255f, b/255f, a/255f); - Utils.drawTexturedRect(itemX-1, itemY-1, 18, 18, - startCTMX/227f, (startCTMX+18)/227f, startCTMY/75f, (startCTMY+18)/75f, GL11.GL_NEAREST); - } - - /*int[] colours = new int[9]; - - for(int xi=-1; xi<=1; xi++) { - for(int yi=-1; yi<=1; yi++) { - List<Integer> indexes = new ArrayList<>(); - List<Integer> coloursList = new ArrayList<>(); - coloursList.add(rgb); - - if(xi != 0) { - indexes.add(k+xi); - } - if(yi != 0) { - indexes.add(k+yi*9); - } - if(xi != 0 && yi != 0) { - indexes.add(k+yi*9+xi); - } - for(int index : indexes) { - if(index >= 0 && index < rows*9) { - int paneTypeI = getPaneType(page.items[index], index, isPaneCache); - if(shouldConnect(paneType, paneTypeI)) { - coloursList.add(getRGBFromPane(paneTypeI-1)); - } - } - } - Vector4f cv = new Vector4f(); - for(int colour : coloursList) { - float a = (colour >> 24) & 0xFF; - float r = (colour >> 16) & 0xFF; - float g = (colour >> 8) & 0xFF; - float b = colour & 0xFF; - cv.x += a/coloursList.size(); - cv.y += r/coloursList.size(); - cv.z += g/coloursList.size(); - cv.w += b/coloursList.size(); - } - int finalCol = (((int)cv.x) << 24) | (((int)cv.y) << 16) | (((int)cv.z) << 8) | ((int)cv.w); - colours[(xi+1)+(yi+1)*3] = finalCol; - } - } - int[] colours4 = new int[16]; - - for(int x=0; x<4; x++) { - for(int y=0; y<4; y++) { - int ya = y < 2 ? y : y-1; - int xa = x < 2 ? x : x-1; - colours4[x+y*4] = colours[xa+ya*3]; - } - } - - GlStateManager.pushMatrix(); - GlStateManager.translate(itemX-1, itemY-1, 0); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); - float uMinCTM = startCTMX/227f; - float uMaxCTM = (startCTMX+18)/227f; - float vMinCTM = startCTMY/75f; - float vMaxCTM = (startCTMY+18)/75f; - for(int xi=-1; xi<=1; xi++) { - for(int yi = -1; yi <= 1; yi++) { - float x = xi == -1 ? 0 : xi == 0 ? 1 : 17; - float y = yi == -1 ? 0 : yi == 0 ? 1 : 17; - float w = xi == 0 ? 16 : 1; - float h = yi == 0 ? 16 : 1; - - int col1 = colours4[(xi+1)+(yi+1)*4]; - int col2 = colours4[(xi+2)+(yi+1)*4]; - int col3 = colours4[(xi+1)+(yi+2)*4]; - int col4 = colours4[(xi+2)+(yi+2)*4]; - - worldrenderer - .pos(x, y+h, 0.0D) - .tex(uMinCTM + (uMaxCTM - uMinCTM) * x/18f, vMinCTM+(vMaxCTM-vMinCTM)*(y+h)/18f) - .color((col3 >> 16) & 0xFF, (col3 >> 8) & 0xFF, col3 & 0xFF, (col3 >> 24) & 0xFF).endVertex(); - worldrenderer - .pos(x+w, y+h, 0.0D) - .tex(uMinCTM+(uMaxCTM-uMinCTM)*(x+w)/18f, vMinCTM+(vMaxCTM-vMinCTM)*(y+h)/18f) - .color((col4 >> 16) & 0xFF, (col4 >> 8) & 0xFF, col4 & 0xFF, (col4 >> 24) & 0xFF).endVertex(); - worldrenderer - .pos(x+w, y, 0.0D) - .tex(uMinCTM+(uMaxCTM-uMinCTM)*(x+w)/18f, vMinCTM+(vMaxCTM-vMinCTM)*y/18f) - .color((col2 >> 16) & 0xFF, (col2 >> 8) & 0xFF, col2 & 0xFF, (col2 >> 24) & 0xFF).endVertex(); - worldrenderer - .pos(x, y, 0.0D) - .tex(uMinCTM + (uMaxCTM - uMinCTM) * x/18f, vMinCTM+(vMaxCTM-vMinCTM)*y/18f) - .color((col1 >> 16) & 0xFF, (col1 >> 8) & 0xFF, col1 & 0xFF, (col1 >> 24) & 0xFF).endVertex(); - } - } - GlStateManager.disableDepth(); - GlStateManager.color(1, 1, 1, 1); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - tessellator.draw(); - GlStateManager.shadeModel(GL11.GL_FLAT); - GlStateManager.enableDepth(); - GlStateManager.popMatrix();*/ - - RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); - itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, itemX, itemY, null); - GlStateManager.disableLighting(); - } - - page.shouldDarkenIfNotSelected[k] = false; - continue; - } - } - page.shouldDarkenIfNotSelected[k] = true; - - //Render item - GlStateManager.translate(0, 0, 20); - if(doRenderFramebuffer) { - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GL14.glBlendFuncSeparate(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO); - - if(storageId == currentPage) { - Utils.hasEffectOverride = true; - GlStateManager.translate(storageX-7, storageY-17-18, 0); - guiChest.drawSlot(containerChest.getSlot(k+9)); - GlStateManager.translate(-storageX+7, -storageY+17+18, 0); - Utils.hasEffectOverride = false; - } else { - Utils.drawItemStackWithoutGlint(stack, itemX, itemY); - } - - GL14.glBlendFuncSeparate(770, 771, 1, 0); - - if(stack != null && (stack.hasEffect() || stack.getItem() == Items.enchanted_book)) { - enchantGlintRenderLocations.add(new Vector2f(itemX, itemY-startY)); - } - } else if(storageId == currentPage) { - Utils.hasEffectOverride = true; - GlStateManager.translate(storageX-7, storageY-17-18, 0); - guiChest.drawSlot(containerChest.getSlot(k+9)); - GlStateManager.translate(-storageX+7, -storageY+17+18, 0); - Utils.hasEffectOverride = false; - } else { - Utils.drawItemStack(stack, itemX, itemY); - } - GlStateManager.disableLighting(); - GlStateManager.translate(0, 0, -20); - } - - GlStateManager.disableLighting(); - GlStateManager.enableDepth(); - } - } - } - - if(OpenGlHelper.isFramebufferEnabled() && doRenderFramebuffer) { - GlStateManager.popMatrix(); - Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); - - GlStateManager.matrixMode(GL11.GL_PROJECTION); - GlStateManager.loadIdentity(); - GlStateManager.ortho(0.0D, scaledResolution.getScaledWidth_double(), scaledResolution.getScaledHeight_double(), - 0.0D, 1000.0D, 3000.0D); - GlStateManager.matrixMode(GL11.GL_MODELVIEW); - } - - GlScissorStack.push(0, guiTop+3, width, guiTop+3+storageViewSize, scaledResolution); - for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) { - int displayId = entry.getKey(); - int storageId = entry.getValue(); - - IntPair coords = getPageCoords(displayId); - int storageX = coords.x; - int storageY = coords.y; - - if(coords.y-11 > 3+storageViewSize || coords.y+90 < 3) continue; - - StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false); - - if(editingNameId == storageId) { - int len = fontRendererObj.getStringWidth(renameStorageField.getTextDisplay())+10; - renameStorageField.setSize(len, 12); - renameStorageField.render(storageX, storageY-13); - } else { - String pageTitle; - if(page != null && page.customTitle != null && !page.customTitle.isEmpty()) { - pageTitle = Utils.chromaStringByColourCode(page.customTitle); - } else if(entry.getValue() < 9) { - pageTitle = "Ender Chest Page " + (entry.getValue() + 1); - } else { - pageTitle = "Backpack Slot "+(storageId-8); - } - int titleLen = fontRendererObj.getStringWidth(pageTitle); - - if(mouseX >= guiLeft+storageX && mouseX <= guiLeft+storageX+titleLen+15 && - mouseY >= guiTop+storageY-14 && mouseY <= guiTop+storageY+1) { - pageTitle += " \u270E"; - } - fontRendererObj.drawString(pageTitle, storageX, storageY-11, textColour); - } - - if(page == null) { - Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture); - GlStateManager.color(1, 1, 1, 1); - int h = 18*3; - - Utils.drawTexturedRect(storageX, storageY, 162, h, 0, 162 / 600f, 265 / 400f, (265+h) / 400f, GL11.GL_NEAREST); - - Gui.drawRect(storageX, storageY, storageX + 162, storageY + h, 0x80000000); - - if(storageId < 9) { - Utils.drawStringCenteredScaledMaxWidth("Locked Page", fontRendererObj, - storageX+81, storageY+h/2, true, 150, 0xd94c00); - } else { - Utils.drawStringCenteredScaledMaxWidth("Empty Backpack Slot", fontRendererObj, - storageX+81, storageY+h/2, true, 150, 0xd94c00); - } - } else if(page.rows <= 0) { - Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture); - GlStateManager.color(1, 1, 1, 1); - int h = 18*3; - - Utils.drawTexturedRect(storageX, storageY, 162, h, 0, 162 / 600f, 265 / 400f, (265 + h) / 400f, GL11.GL_NEAREST); - - Gui.drawRect(storageX, storageY, storageX + 162, storageY + h, 0x80000000); - - Utils.drawStringCenteredScaledMaxWidth("Click to load items", fontRendererObj, - storageX+81, storageY+h/2, true, 150, 0xffdf00); - } else { - int rows = page.rows; - - int storageW = 162; - int storageH = 18*rows; - - GlStateManager.enableDepth(); - - boolean[] shouldLimitBorder = new boolean[rows*9]; - boolean hasCaches = isPaneCaches[storageId] != null && isPaneCaches[storageId].length == rows*9 && - ctmIndexCaches[storageId] != null && ctmIndexCaches[storageId].length == rows*9; - - //Render item connections - for(int k=0; k<rows*9; k++) { - ItemStack stack = page.items[k]; - - if(stack != null && hasCaches) { - int itemX = storageX+1+18*(k%9); - int itemY = storageY+1+18*(k/9); - - int[] isPaneCache = isPaneCaches[storageId]; - int[] ctmIndexCache = ctmIndexCaches[storageId]; - - if(isPaneCache[k] == 17) { - int ctmIndex = getCTMIndex(page, k, isPaneCache, ctmIndexCache); - int startCTMX = (ctmIndex%12)*19; - int startCTMY = (ctmIndex/12)*19; - - int rgb = getRGBFromPane(isPaneCache[k]-1); - int a = (rgb >> 24) & 0xFF; - int r = (rgb >> 16) & 0xFF; - int g = (rgb >> 8) & 0xFF; - int b = rgb & 0xFF; - Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE); - GlStateManager.color(r/255f, g/255f, b/255f, a/255f); - GlStateManager.translate(0, 0, 110); - Utils.drawTexturedRect(itemX-1, itemY-1, 18, 18, - startCTMX/227f, (startCTMX+18)/227f, startCTMY/75f, (startCTMY+18)/75f, GL11.GL_NEAREST); - GlStateManager.translate(0, 0, -110); - - RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); - itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, itemX, itemY, null); - GlStateManager.enableDepth(); - } else if(isPaneCache[k] < 0) { - boolean hasConnection = false; - - int upIndex = k-9; - int leftIndex = k%9 > 0 ? k-1 : -1; - int rightIndex = k%9 < 8 ? k+1 : -1; - int downIndex = k+9; - - int[] indexArr = {rightIndex, downIndex, leftIndex, upIndex}; - - for(int j=0; j<4; j++) { - int index = indexArr[j]; - int type = index >= 0 && index < isPaneCache.length ? getPaneType(page.items[index], index, isPaneCache) : -1; - if(type > 0) { - int ctmIndex = getCTMIndex(page, index, isPaneCache, ctmIndexCache); - if(ctmIndex < 0) continue; - - boolean renderConnection; - boolean horizontal = ctmIndex == 1 || ctmIndex == 2 || ctmIndex == 3; - boolean vertical = ctmIndex == 12 || ctmIndex == 24 || ctmIndex == 36; - if((k%9 == 0 && index%9 == 0) || (k%9 == 8 && index%9 == 8)) { - renderConnection = horizontal || vertical; - } else if(index == leftIndex || index == rightIndex) { - renderConnection = horizontal; - } else { - renderConnection = vertical; - } - - if(renderConnection) { - shouldLimitBorder[k] = true; - hasConnection = true; - - Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE); - int rgb = getRGBFromPane(type-1); - int a = (rgb >> 24) & 0xFF; - int r = (rgb >> 16) & 0xFF; - int g = (rgb >> 8) & 0xFF; - int b = rgb & 0xFF; - GlStateManager.color(r/255f, g/255f, b/255f, a/255f); - - GlStateManager.pushMatrix(); - GlStateManager.translate(itemX-1+9, itemY-1+9, 10); - GlStateManager.rotate(j*90, 0, 0, 1); - GlStateManager.enableAlpha(); - GlStateManager.disableLighting(); - - boolean horzFlip = false; - boolean vertFlip = false; - - if(index == leftIndex) { - vertFlip = true; - } else if(index == downIndex) { - vertFlip = true; - } - - GlStateManager.enableDepth(); - Utils.drawTexturedRect(0, -9, 8, 18, - !horzFlip ? 209/227f : 219/227f, horzFlip ? 227/227f : 217/227f, - !vertFlip ? 57/75f : 75f/75f, vertFlip ? 57/75f : 75f/75f, GL11.GL_NEAREST); - GlStateManager.translate(0, 0, 120); - Utils.drawTexturedRect(8, -9, 10, 18, - !horzFlip ? 217/227f : 209/227f, horzFlip ? 219/227f : 227/227f, - !vertFlip ? 57/75f : 75f/75f, vertFlip ? 57/75f : 75f/75f, GL11.GL_NEAREST); - GlStateManager.translate(0, 0, -120); - - GlStateManager.popMatrix(); - } - } - } - - if(hasConnection) { - page.shouldDarkenIfNotSelected[k] = false; - - GlStateManager.disableAlpha(); - GlStateManager.translate(0, 0, 10); - Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000); - GlStateManager.translate(0, 0, -10); - GlStateManager.enableAlpha(); - } - } - } - } - - Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(storageX, storageY, storageW, storageH, 0, 162/600f, 265/400f, (265+storageH)/400f, GL11.GL_NEAREST); - - boolean whiteOverlay = false; - - for(int k=0; k<rows*9; k++) { |
