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 | 1220 |
1 files changed, 633 insertions, 587 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..abef4db6 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,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; - import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -38,9 +37,8 @@ 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 { @@ -50,44 +48,46 @@ public class StorageOverlay extends GuiElement { private Framebuffer framebuffer = null; - private Set<Vector2f> enchantGlintRenderLocations = new HashSet<>(); + private final Set<Vector2f> enchantGlintRenderLocations = new HashSet<>(); - public static final ResourceLocation STORAGE_PREVIEW_TEXTURES[] = new ResourceLocation[4]; - private static final ResourceLocation STORAGE_TEXTURES[] = new ResourceLocation[4]; + 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_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 < 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"); + 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 GuiElementTextField searchBar = new GuiElementTextField("", 88, 10, - GuiElementTextField.SCALE_TEXT | GuiElementTextField.DISABLE_BG); - private GuiElementTextField renameStorageField = new GuiElementTextField("", 100, 13, + private final GuiElementTextField searchBar = new GuiElementTextField("", 88, 10, + GuiElementTextField.SCALE_TEXT | GuiElementTextField.DISABLE_BG); + private final GuiElementTextField renameStorageField = new GuiElementTextField("", 100, 13, GuiElementTextField.COLOUR); private int editingNameId = -1; @@ -110,8 +110,8 @@ public class StorageOverlay extends GuiElement { private int scrollVelocity = 0; private long lastScroll = 0; - private int[][] isPaneCaches = new int[40][]; - private int[][] ctmIndexCaches = new int[40][]; + private final int[][] isPaneCaches = new int[40][]; + private final int[][] ctmIndexCaches = new int[40][]; private int desiredHeightSwitch = -1; private int desiredHeightMX = -1; @@ -122,20 +122,20 @@ public class StorageOverlay extends GuiElement { private int scrollGrabOffset = -1; - private LerpingInteger scroll = new LerpingInteger(0, 200); + private final LerpingInteger scroll = new LerpingInteger(0, 200); private int getMaximumScroll() { - synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) { + 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; + 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; + int h = getPageCoords(coords).y + scroll.getValue() - getStorageViewSize() - 14; - if(h > maxH) maxH = h; + if (h > maxH) maxH = h; } return maxH; @@ -148,32 +148,32 @@ public class StorageOverlay extends GuiElement { private void scrollToY(int y) { int target = y; - if(target < 0) target = 0; + if (target < 0) target = 0; int maxY = getMaximumScroll(); - if(target > maxY) target = maxY; + if (target > maxY) target = maxY; - float factor = (scroll.getValue()-target)/(float)(scroll.getValue()-y+1E-5); + 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.setTimeToReachTarget(Math.min(200, Math.max(20, (int) (200 * factor)))); scroll.resetTimer(); } public void scrollToStorage(int displayId, boolean forceScroll) { - if(displayId < 0) return; + if (displayId < 0) return; - int y = getPageCoords(displayId).y-17; - if(y < 3) { + 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) { + int y2 = getPageCoords(displayId + 3).y - 17 - storageViewSize; + if (y2 > 3) { + if (forceScroll) { scrollToY(y + scroll.getValue()); } else { - scrollToY(y2+scroll.getValue()); + scrollToY(y2 + scroll.getValue()); } } } @@ -189,7 +189,7 @@ public class StorageOverlay extends GuiElement { @Override public void render() { - if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return; + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return; GuiChest guiChest = (GuiChest) Minecraft.getMinecraft().currentScreen; ContainerChest containerChest = (ContainerChest) guiChest.inventorySlots; @@ -207,42 +207,42 @@ public class StorageOverlay extends GuiElement { ResourceLocation storagePreviewTexture = STORAGE_PREVIEW_TEXTURES[displayStyle]; int textColour = 0x404040; int searchTextColour = 0xe0e0e0; - if(displayStyle == 2) { + if (displayStyle == 2) { textColour = 0x000000; searchTextColour = 0xa0a0a0; - } else if(displayStyle == 3) { + } else if (displayStyle == 3) { textColour = 0xFBCC6C; - } else if(displayStyle == 0) { + } else if (displayStyle == 0) { textColour = 0x909090; searchTextColour = 0xa0a0a0; } long currentTime = System.currentTimeMillis(); - if(lastMillis > 0) { + if (lastMillis > 0) { long deltaTime = currentTime - lastMillis; millisAccumIndex += deltaTime; - loadCircleIndex += millisAccumIndex / (1000/15); - millisAccumIndex %= (1000/15); + loadCircleIndex += millisAccumIndex / (1000 / 15); + millisAccumIndex %= (1000 / 15); millisAccumRotation += deltaTime; - loadCircleRotation += millisAccumRotation / (1000/107); - millisAccumRotation %= (1000/107); + loadCircleRotation += millisAccumRotation / (1000 / 107); + millisAccumRotation %= (1000 / 107); millisAccumRoll += deltaTime; - rollIndex += millisAccumRoll/100; + rollIndex += millisAccumRoll / 100; millisAccumRoll %= 100; } lastMillis = currentTime; loadCircleIndex %= LOAD_CIRCLE_SEQ.length; - rollIndex %= NOT_RICKROLL_SEQ.length*2; + rollIndex %= NOT_RICKROLL_SEQ.length * 2; loadCircleRotation %= 360; - Color loadCircleColour = Color.getHSBColor(loadCircleRotation/360f, 0.3f, 0.9f); + Color loadCircleColour = Color.getHSBColor(loadCircleRotation / 360f, 0.3f, 0.9f); ItemStack stackOnMouse = Minecraft.getMinecraft().thePlayer.inventory.getItemStack(); - if(stackOnMouse != null) { + if (stackOnMouse != null) { String stackDisplay = Utils.cleanColour(stackOnMouse.getDisplayName()); - if(stackDisplay.startsWith("Backpack Slot ") || stackDisplay.startsWith("Empty Backpack Slot ") || + if (stackDisplay.startsWith("Backpack Slot ") || stackDisplay.startsWith("Empty Backpack Slot ") || stackDisplay.startsWith("Ender Chest Page ")) { stackOnMouse = null; } @@ -254,18 +254,18 @@ public class StorageOverlay extends GuiElement { int storageViewSize = getStorageViewSize(); int sizeX = 540; - int sizeY = 100+storageViewSize; + int sizeY = 100 + storageViewSize; int searchNobX = 18; int itemHoverX = -1; int itemHoverY = -1; - guiLeft = width/2 - (sizeX-searchNobX)/2; - guiTop = height/2 - sizeY/2; + guiLeft = width / 2 - (sizeX - searchNobX) / 2; + guiTop = height / 2 - sizeY / 2; - if(displayStyle == 0) { + 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); + BackgroundBlur.renderBlurredBackground(7, width, height, guiLeft + 5, guiTop + storageViewSize, sizeX - searchNobX - 10, sizeY - storageViewSize - 4); } Utils.drawGradientRect(0, 0, width, height, 0xc0101010, 0xd0101010); @@ -278,44 +278,44 @@ public class StorageOverlay extends GuiElement { //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); + 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) { + if (scroll.getValue() > maxScroll) { scroll.setValue(maxScroll); } - if(scroll.getValue() < 0) { + 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 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; + boolean mouseInsideStorages = mouseY > guiTop + 3 && mouseY < guiTop + 3 + storageViewSize; //Storages boolean doItemRender = true; boolean doRenderFramebuffer = false; int startY = getPageCoords(0).y; - if(OpenGlHelper.isFramebufferEnabled()) { + 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; + 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(); + 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); + if (framebuffer != null) { + GlScissorStack.push(0, guiTop + 3, width, guiTop + 3 + storageViewSize, scaledResolution); GlStateManager.enableDepth(); GlStateManager.translate(0, startY, 107.0001f); framebuffer.bindFramebufferTexture(); @@ -333,15 +333,15 @@ public class StorageOverlay extends GuiElement { GlScissorStack.pop(scaledResolution); } - if(dirty || framebuffer == null) { + if (dirty || framebuffer == null) { dirty = false; - int fw = w*scaledResolution.getScaleFactor(); - int fh = h*scaledResolution.getScaleFactor(); + int fw = w * scaledResolution.getScaleFactor(); + int fh = h * scaledResolution.getScaleFactor(); - if(framebuffer == null) { + if (framebuffer == null) { framebuffer = new Framebuffer(fw, fh, true); - } else if(framebuffer.framebufferWidth != fw || framebuffer.framebufferHeight != fh) { + } else if (framebuffer.framebufferWidth != fw || framebuffer.framebufferHeight != fh) { framebuffer.createBindFramebuffer(fw, fh); } framebuffer.framebufferClear(); @@ -353,7 +353,7 @@ public class StorageOverlay extends GuiElement { GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.pushMatrix(); - GlStateManager.translate(-guiLeft, -guiTop-startY, 0); + GlStateManager.translate(-guiLeft, -guiTop - startY, 0); doRenderFramebuffer = true; } else { @@ -361,9 +361,9 @@ public class StorageOverlay extends GuiElement { } } - if(doItemRender) { + if (doItemRender) { enchantGlintRenderLocations.clear(); - for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) { + for (Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) { int displayId = entry.getKey(); int storageId = entry.getValue(); @@ -371,56 +371,56 @@ public class StorageOverlay extends GuiElement { int storageX = coords.x; int storageY = coords.y; - if(!doRenderFramebuffer) { - if(coords.y-11 > 3+storageViewSize || coords.y+90 < 3) continue; + 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) { + if (page != null && page.rows > 0) { int rows = page.rows; - isPaneCaches[storageId] = new int[page.rows*9]; - ctmIndexCaches[storageId] = new int[page.rows*9]; + 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++) { + for (int k = 0; k < rows * 9; k++) { ItemStack stack; - if(storageId == currentPage) { - stack = containerChest.getSlot(k+9).getStack(); + 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); + int itemX = storageX + 1 + 18 * (k % 9); + int itemY = storageY + 1 + 18 * (k / 9); //Render fancy glass - if(stack != null) { + if (stack != null) { int paneType = getPaneType(stack, k, isPaneCache); - if(paneType > 0) { + if (paneType > 0) { GlStateManager.disableAlpha(); - Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000); + 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; + int startCTMX = (ctmIndex % 12) * 19; + int startCTMY = (ctmIndex / 12) * 19; ctmIndexCache[k] = ctmIndex; - if(paneType != 17) { - int rgb = getRGBFromPane(paneType-1); + 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); + 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]; @@ -533,15 +533,15 @@ public class StorageOverlay extends GuiElement { //Render item GlStateManager.translate(0, 0, 20); - if(doRenderFramebuffer) { + 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) { + + 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); + 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); @@ -549,14 +549,14 @@ public class StorageOverlay extends GuiElement { GL14.glBlendFuncSeparate(770, 771, 1, 0); - if(stack != null && (stack.hasEffect() || stack.getItem() == Items.enchanted_book)) { - enchantGlintRenderLocations.add(new Vector2f(itemX, itemY-startY)); + if (stack != null && (stack.hasEffect() || stack.getItem() == Items.enchanted_book)) { + enchantGlintRenderLocations.add(new Vector2f(itemX, itemY - startY)); } - } else if(storageId == currentPage) { + } 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); + 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); @@ -571,7 +571,7 @@ public class StorageOverlay extends GuiElement { } } - if(OpenGlHelper.isFramebufferEnabled() && doRenderFramebuffer) { + if (OpenGlHelper.isFramebufferEnabled() && doRenderFramebuffer) { GlStateManager.popMatrix(); Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); @@ -582,8 +582,8 @@ public class StorageOverlay extends GuiElement { 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()) { + 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(); @@ -591,165 +591,165 @@ public class StorageOverlay extends GuiElement { int storageX = coords.x; int storageY = coords.y; - if(coords.y-11 > 3+storageViewSize || coords.y+90 < 3) continue; + 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; + + if (editingNameId == storageId) { + int len = fontRendererObj.getStringWidth(renameStorageField.getTextDisplay()) + 10; renameStorageField.setSize(len, 12); - renameStorageField.render(storageX, storageY-13); + renameStorageField.render(storageX, storageY - 13); } else { String pageTitle; - if(page != null && page.customTitle != null && !page.customTitle.isEmpty()) { + if (page != null && page.customTitle != null && !page.customTitle.isEmpty()) { pageTitle = Utils.chromaStringByColourCode(page.customTitle); - } else if(entry.getValue() < 9) { + } else if (entry.getValue() < 9) { pageTitle = "Ender Chest Page " + (entry.getValue() + 1); } else { - pageTitle = "Backpack Slot "+(storageId-8); + 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) { + 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); + fontRendererObj.drawString(pageTitle, storageX, storageY - 11, textColour); } - if(page == null) { + if (page == null) { Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture); GlStateManager.color(1, 1, 1, 1); - int h = 18*3; + int h = 18 * 3; - Utils.drawTexturedRect(storageX, storageY, 162, h, 0, 162 / 600f, 265 / 400f, (265+h) / 400f, GL11.GL_NEAREST); + 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) { + if (storageId < 9) { Utils.drawStringCenteredScaledMaxWidth("Locked Page", fontRendererObj, - storageX+81, storageY+h/2, true, 150, 0xd94c00); + storageX + 81, storageY + h / 2, true, 150, 0xd94c00); } else { Utils.drawStringCenteredScaledMaxWidth("Empty Backpack Slot", fontRendererObj, - storageX+81, storageY+h/2, true, 150, 0xd94c00); + storageX + 81, storageY + h / 2, true, 150, 0xd94c00); } - } else if(page.rows <= 0) { + } else if (page.rows <= 0) { Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture); GlStateManager.color(1, 1, 1, 1); - int h = 18*3; + 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); + storageX + 81, storageY + h / 2, true, 150, 0xffdf00); } else { int rows = page.rows; int storageW = 162; - int storageH = 18*rows; + 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; + 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++) { + 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); + 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) { + if (isPaneCache[k] == 17) { int ctmIndex = getCTMIndex(page, k, isPaneCache, ctmIndexCache); - int startCTMX = (ctmIndex%12)*19; - int startCTMY = (ctmIndex/12)*19; + int startCTMX = (ctmIndex % 12) * 19; + int startCTMY = (ctmIndex / 12) * 19; - int rgb = getRGBFromPane(isPaneCache[k]-1); + 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.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); + 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) { + } 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 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++) { + 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) { + if (type > 0) { int ctmIndex = getCTMIndex(page, index, isPaneCache, ctmIndexCache); - if(ctmIndex < 0) continue; + 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)) { + if ((k % 9 == 0 && index % 9 == 0) || (k % 9 == 8 && index % 9 == 8)) { renderConnection = horizontal || vertical; - } else if(index == leftIndex || index == rightIndex) { + } else if (index == leftIndex || index == rightIndex) { renderConnection = horizontal; } else { renderConnection = vertical; } - if(renderConnection) { + if (renderConnection) { shouldLimitBorder[k] = true; hasConnection = true; Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE); - int rgb = getRGBFromPane(type-1); + 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.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.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) { + if (index == leftIndex) { vertFlip = true; - } else if(index == downIndex) { + } 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); + !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); + !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(); @@ -757,12 +757,12 @@ public class StorageOverlay extends GuiElement { } } - if(hasConnection) { + if (hasConnection) { page.shouldDarkenIfNotSelected[k] = false; GlStateManager.disableAlpha(); GlStateManager.translate(0, 0, 10); - Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000); + Gui.drawRect(itemX - 1, itemY - 1, itemX + 17, itemY + 17, 0x01000000); GlStateManager.translate(0, 0, -10); GlStateManager.enableAlpha(); } @@ -772,46 +772,46 @@ public class StorageOverlay extends GuiElement { 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); + 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++) { + for (int k = |
