aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-16 15:50:41 -0400
committerGitHub <noreply@github.com>2021-10-16 15:50:41 -0400
commit7c00af18febf6c0b833c7633b4fb60a9a1bb93af (patch)
treef02de145362d6a1399651ade4a130d565d7f0ba3 /src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java
parentb11742988dec635b5c5da7c2363803cbfafb37b1 (diff)
downloadnotenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.gz
notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.bz2
notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.zip
Code Clean Up (#2)
* intellij code clean up * optimize imports * format * intellij suggestions * fix empty catch issues
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java
index 8a972f78..8a25124f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java
@@ -1,8 +1,8 @@
package io.github.moulberry.notenoughupdates.mbgui;
-import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
+import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
@@ -15,10 +15,10 @@ import java.util.*;
public class MBGuiGroupFloating extends MBGuiGroup {
private GuiScreen lastScreen = null;
- private HashMap<MBGuiElement, Vector2f> childrenPositionOffset = new HashMap<>();
+ private final HashMap<MBGuiElement, Vector2f> childrenPositionOffset = new HashMap<>();
//Serialized
- private LinkedHashMap<MBGuiElement, MBAnchorPoint> children;
+ private final LinkedHashMap<MBGuiElement, MBAnchorPoint> children;
public MBGuiGroupFloating(int width, int height, LinkedHashMap<MBGuiElement, MBAnchorPoint> children) {
this.width = width;
@@ -35,10 +35,10 @@ public class MBGuiGroupFloating extends MBGuiGroup {
public Map<MBGuiElement, Vector2f> getChildrenPosition() {
GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
- if(currentScreen instanceof GuiContainer || currentScreen instanceof GuiItemRecipe
- || currentScreen instanceof CustomAHGui || NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.isRenderOverAuctionView()) {
+ if (currentScreen instanceof GuiContainer || currentScreen instanceof GuiItemRecipe
+ || currentScreen instanceof CustomAHGui || NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.isRenderOverAuctionView()) {
- if(lastScreen != currentScreen) {
+ if (lastScreen != currentScreen) {
lastScreen = currentScreen;
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -50,7 +50,7 @@ public class MBGuiGroupFloating extends MBGuiGroup {
int guiLeft = -1;
int guiTop = -1;
- if(currentScreen instanceof GuiContainer) {
+ if (currentScreen instanceof GuiContainer) {
GuiContainer currentContainer = (GuiContainer) currentScreen;
try {
@@ -58,14 +58,14 @@ public class MBGuiGroupFloating extends MBGuiGroup {
ySize = (int) Utils.getField(GuiContainer.class, currentContainer, "ySize", "field_147000_g");
guiLeft = (int) Utils.getField(GuiContainer.class, currentContainer, "guiLeft", "field_147003_i");
guiTop = (int) Utils.getField(GuiContainer.class, currentContainer, "guiTop", "field_147009_r");
- } catch(Exception ignored) {
+ } catch (Exception ignored) {
}
- } else if(currentScreen instanceof GuiItemRecipe) {
- xSize = ((GuiItemRecipe)currentScreen).xSize;
- ySize = ((GuiItemRecipe)currentScreen).ySize;
- guiLeft = ((GuiItemRecipe)currentScreen).guiLeft;
- guiTop = ((GuiItemRecipe)currentScreen).guiTop;
- } else if(currentScreen instanceof CustomAHGui ||
+ } else if (currentScreen instanceof GuiItemRecipe) {
+ xSize = ((GuiItemRecipe) currentScreen).xSize;
+ ySize = ((GuiItemRecipe) currentScreen).ySize;
+ guiLeft = ((GuiItemRecipe) currentScreen).guiLeft;
+ guiTop = ((GuiItemRecipe) currentScreen).guiTop;
+ } else if (currentScreen instanceof CustomAHGui ||
NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.isRenderOverAuctionView()) {
xSize = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.getXSize();
ySize = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.getYSize();
@@ -73,28 +73,28 @@ public class MBGuiGroupFloating extends MBGuiGroup {
guiTop = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.guiTop;
}
- if(xSize <= 0 && ySize <= 0 && guiLeft <= 0 && guiTop <= 0) {
+ if (xSize <= 0 && ySize <= 0 && guiLeft <= 0 && guiTop <= 0) {
lastScreen = null;
return Collections.unmodifiableMap(childrenPosition);
}
- for(Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
+ for (Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
MBGuiElement child = entry.getKey();
MBAnchorPoint anchorPoint = entry.getValue();
Vector2f childPos;
- if(childrenPosition.containsKey(child)) {
+ if (childrenPosition.containsKey(child)) {
childPos = new Vector2f(childrenPosition.get(child));
} else {
childPos = new Vector2f();
}
- if(anchorPoint.inventoryRelative) {
+ if (anchorPoint.inventoryRelative) {
int defGuiLeft = (screenWidth - xSize) / 2;
int defGuiTop = (screenHeight - ySize) / 2;
- childPos.x += guiLeft-defGuiLeft + (0.5f-anchorPoint.anchorPoint.x)*xSize;
- childPos.y += guiTop-defGuiTop + (0.5f-anchorPoint.anchorPoint.y)*ySize;
+ childPos.x += guiLeft - defGuiLeft + (0.5f - anchorPoint.anchorPoint.x) * xSize;
+ childPos.y += guiTop - defGuiTop + (0.5f - anchorPoint.anchorPoint.y) * ySize;
}
childrenPositionOffset.put(child, childPos);
@@ -110,19 +110,19 @@ public class MBGuiGroupFloating extends MBGuiGroup {
public void recalculate() {
lastScreen = null;
- for(MBGuiElement child : children.keySet()) {
+ for (MBGuiElement child : children.keySet()) {
child.recalculate();
}
- for(Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
+ for (Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
MBGuiElement child = entry.getKey();
MBAnchorPoint anchorPoint = entry.getValue();
float x = anchorPoint.anchorPoint.x * width - anchorPoint.anchorPoint.x * child.getWidth() + anchorPoint.offset.x;
float y = anchorPoint.anchorPoint.y * height - anchorPoint.anchorPoint.y * child.getHeight() + anchorPoint.offset.y;
- if(anchorPoint.inventoryRelative) {
- x = width*0.5f + anchorPoint.offset.x;
- y = height*0.5f + anchorPoint.offset.y;
+ if (anchorPoint.inventoryRelative) {
+ x = width * 0.5f + anchorPoint.offset.x;
+ y = height * 0.5f + anchorPoint.offset.y;
}
childrenPosition.put(child, new Vector2f(x, y));