From 7c00af18febf6c0b833c7633b4fb60a9a1bb93af Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 16 Oct 2021 15:50:41 -0400 Subject: Code Clean Up (#2) * intellij code clean up * optimize imports * format * intellij suggestions * fix empty catch issues --- .../notenoughupdates/miscgui/StorageOverlay.java | 1220 ++++++++++---------- 1 file changed, 633 insertions(+), 587 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java') 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 enchantGlintRenderLocations = new HashSet<>(); + private final Set 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 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 entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) { + for (Map.Entry 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 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 entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) { + GlScissorStack.push(0, guiTop + 3, width, guiTop + 3 + storageViewSize, scaledResolution); + for (Map.Entry 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> 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= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) { + if (mouseInsideStorages && mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY && mouseY < guiTop + itemY + 18) { boolean allowHover = NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes != 1 || !hasCaches || isPaneCaches[storageId][k] <= 0; - if(storageId != StorageManager.getInstance().getCurrentPageId()) { + if (storageId != StorageManager.getInstance().getCurrentPageId()) { hoveringOtherBackpack = true; whiteOverlay = stackOnMouse == null; - } else if(stack == null || allowHover) { + } else if (stack == null || allowHover) { itemHoverX = itemX; itemHoverY = itemY; } - if(stack != null && allowHover) { + if (stack != null && allowHover) { tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); } } } GlStateManager.disableDepth(); - if(storageId == currentPage) { - if(isPaneCaches[storageId] != null && isPaneCaches[storageId].length == rows*9 && - ctmIndexCaches[storageId] != null && ctmIndexCaches[storageId].length == rows*9) { + if (storageId == currentPage) { + if (isPaneCaches[storageId] != null && isPaneCaches[storageId].length == rows * 9 && + ctmIndexCaches[storageId] != null && ctmIndexCaches[storageId].length == rows * 9) { int[] isPaneCache = isPaneCaches[storageId]; int borderStartY = 0; @@ -820,10 +820,10 @@ public class StorageOverlay extends GuiElement { int borderEndX = storageW; boolean allChroma = true; - for(int y=0; y=0; y--) { - for(int x=0; x<9; x++) { - int index = x+y*9; - if(isPaneCache[index] <= 0 && !shouldLimitBorder[index]) { - borderEndY = y*18+18; //Bottom + for (int y = page.rows - 1; y >= 0; y--) { + for (int x = 0; x < 9; x++) { + int index = x + y * 9; + if (isPaneCache[index] <= 0 && !shouldLimitBorder[index]) { + borderEndY = y * 18 + 18; //Bottom break out; } } } out: - for(int x=0; x<9; x++) { - for(int y=0; y=0; x--) { - for(int y=0; y= 0; x--) { + for (int y = 0; y < page.rows; y++) { + int index = x + y * 9; + if (isPaneCache[index] <= 0 && !shouldLimitBorder[index]) { + borderEndX = x * 18 + 18; //Bottom break out; } } } int borderColour = ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedStorageColour); - Gui.drawRect(storageX+borderStartX+1, storageY+borderStartY, storageX+borderStartX, storageY+borderEndY, borderColour); //Left - Gui.drawRect(storageX+borderEndX-1, storageY+borderStartY, storageX+borderEndX, storageY+borderEndY, borderColour); //Right - Gui.drawRect(storageX+borderStartX, storageY+borderStartY, storageX+borderEndX, storageY+borderStartY+1, borderColour); //Top - Gui.drawRect(storageX+borderStartX, storageY+borderEndY-1, storageX+borderEndX, storageY+borderEndY, borderColour); //Bottom + Gui.drawRect(storageX + borderStartX + 1, storageY + borderStartY, storageX + borderStartX, storageY + borderEndY, borderColour); //Left + Gui.drawRect(storageX + borderEndX - 1, storageY + borderStartY, storageX + borderEndX, storageY + borderEndY, borderColour); //Right + Gui.drawRect(storageX + borderStartX, storageY + borderStartY, storageX + borderEndX, storageY + borderStartY + 1, borderColour); //Top + Gui.drawRect(storageX + borderStartX, storageY + borderEndY - 1, storageX + borderEndX, storageY + borderEndY, borderColour); //Bottom - if(allChroma) { + if (allChroma) { ResourceLocation loc; - if(rollIndex < NOT_RICKROLL_SEQ.length) { + if (rollIndex < NOT_RICKROLL_SEQ.length) { loc = NOT_RICKROLL_SEQ[rollIndex]; } else { - loc = NOT_RICKROLL_SEQ[NOT_RICKROLL_SEQ.length*2-rollIndex-1]; + loc = NOT_RICKROLL_SEQ[NOT_RICKROLL_SEQ.length * 2 - rollIndex - 1]; } Minecraft.getMinecraft().getTextureManager().bindTexture(loc); GlStateManager.color(1, 1, 1, 1); @@ -889,63 +889,63 @@ public class StorageOverlay extends GuiElement { } } else { int borderColour = ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedStorageColour); - Gui.drawRect(storageX+1, storageY, storageX, storageY+storageH, borderColour); //Left - Gui.drawRect(storageX+storageW-1, storageY, storageX+storageW, storageY+storageH, borderColour); //Right - Gui.drawRect(storageX, storageY-1, storageX+storageW, storageY, borderColour); //Top - Gui.drawRect(storageX, storageY+storageH-1, storageX+storageW, storageY+storageH, borderColour); //Bottom + Gui.drawRect(storageX + 1, storageY, storageX, storageY + storageH, borderColour); //Left + Gui.drawRect(storageX + storageW - 1, storageY, storageX + storageW, storageY + storageH, borderColour); //Right + Gui.drawRect(storageX, storageY - 1, storageX + storageW, storageY, borderColour); //Top + Gui.drawRect(storageX, storageY + storageH - 1, storageX + storageW, storageY + storageH, borderColour); //Bottom } - } else if(currentTime - StorageManager.getInstance().storageOpenSwitchMillis < 1000 && + } else if (currentTime - StorageManager.getInstance().storageOpenSwitchMillis < 1000 && StorageManager.getInstance().desiredStoragePage == storageId && StorageManager.getInstance().getCurrentPageId() != storageId) { - Gui.drawRect(storageX, storageY, storageX+storageW, storageY+storageH, 0x30000000); + Gui.drawRect(storageX, storageY, storageX + storageW, storageY + storageH, 0x30000000); Minecraft.getMinecraft().getTextureManager().bindTexture(LOAD_CIRCLE_SEQ[loadCircleIndex]); - GlStateManager.color(loadCircleColour.getRed()/255f, loadCircleColour.getGreen()/255f, - loadCircleColour.getBlue()/255f, 1); + GlStateManager.color(loadCircleColour.getRed() / 255f, loadCircleColour.getGreen() / 255f, + loadCircleColour.getBlue() / 255f, 1); GlStateManager.pushMatrix(); - GlStateManager.translate(storageX+storageW/2, storageY+storageH/2, 0); + GlStateManager.translate(storageX + storageW / 2, storageY + storageH / 2, 0); GlStateManager.rotate(loadCircleRotation, 0, 0, 1); Utils.drawTexturedRect(-10, -10, 20, 20, GL11.GL_LINEAR); GlStateManager.popMatrix(); - } else if(whiteOverlay) { - Gui.drawRect(storageX, storageY, storageX+storageW, storageY+storageH, 0x80ffffff); + } else if (whiteOverlay) { + Gui.drawRect(storageX, storageY, storageX + storageW, storageY + storageH, 0x80ffffff); } else { - if(page.rows <= 0) { - Gui.drawRect(storageX, storageY, storageX+storageW, storageY+storageH, 0x40000000); + if (page.rows <= 0) { + Gui.drawRect(storageX, storageY, storageX + storageW, storageY + storageH, 0x40000000); } else { - for(int i=0; i= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) { + if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY && mouseY < guiTop + itemY + 18) { itemHoverX = itemX; itemHoverY = itemY; - if(playerItems[i] != null) { + if (playerItems[i] != null) { tooltipToDisplay = playerItems[i].getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); } } } - for(int i=0; i<27; i++) { - int itemX = 181+18*(i%9); - int itemY = storageViewSize+18+18*(i/9); + for (int i = 0; i < 27; i++) { + int itemX = 181 + 18 * (i % 9); + int itemY = storageViewSize + 18 + 18 * (i / 9); //Utils.drawItemStack(playerItems[i+9], itemX, itemY); GlStateManager.pushMatrix(); - GlStateManager.translate(181-8, storageViewSize+18-(inventoryStartIndex/9*18+31), 0); - guiChest.drawSlot(containerChest.inventorySlots.get(inventoryStartIndex+9+i)); + GlStateManager.translate(181 - 8, storageViewSize + 18 - (inventoryStartIndex / 9 * 18 + 31), 0); + guiChest.drawSlot(containerChest.inventorySlots.get(inventoryStartIndex + 9 + i)); GlStateManager.popMatrix(); - if(!searchBar.getText().isEmpty()) { - if(playerItems[i+9] == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(playerItems[i+9], searchBar.getText())) { + if (!searchBar.getText().isEmpty()) { + if (playerItems[i + 9] == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(playerItems[i + 9], searchBar.getText())) { GlStateManager.disableDepth(); - Gui.drawRect(itemX, itemY, itemX+16, itemY+16, 0x80000000); + Gui.drawRect(itemX, itemY, itemX + 16, itemY + 16, 0x80000000); GlStateManager.enableDepth(); } } - if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) { + if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY && mouseY < guiTop + itemY + 18) { itemHoverX = itemX; itemHoverY = itemY; - if(playerItems[i+9] != null) { - tooltipToDisplay = playerItems[i+9].getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); + if (playerItems[i + 9] != null) { + tooltipToDisplay = playerItems[i + 9].getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); } } } //Backpack Selector - fontRendererObj.drawString("Ender Chest Pages", 9, storageViewSize+12, textColour); - fontRendererObj.drawString("