aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.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/NEUOverlay.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/NEUOverlay.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java1136
1 files changed, 574 insertions, 562 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 080353a7..f40c60cd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -8,7 +8,10 @@ import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
-import io.github.moulberry.notenoughupdates.infopanes.*;
+import io.github.moulberry.notenoughupdates.infopanes.DevInfoPane;
+import io.github.moulberry.notenoughupdates.infopanes.HTMLInfoPane;
+import io.github.moulberry.notenoughupdates.infopanes.InfoPane;
+import io.github.moulberry.notenoughupdates.infopanes.TextInfoPane;
import io.github.moulberry.notenoughupdates.itemeditor.NEUItemEditor;
import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement;
@@ -16,9 +19,14 @@ import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupAligned;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating;
import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu;
import io.github.moulberry.notenoughupdates.options.NEUConfigEditor;
-import io.github.moulberry.notenoughupdates.util.*;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.LerpingFloat;
+import io.github.moulberry.notenoughupdates.util.SpecialColour;
+import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.*;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.block.model.BakedQuad;
@@ -66,22 +74,22 @@ public class NEUOverlay extends Gui {
private static final ResourceLocation SEARCH_BAR = new ResourceLocation("notenoughupdates:search_bar.png");
private static final ResourceLocation SEARCH_BAR_GOLD = new ResourceLocation("notenoughupdates:search_bar_gold.png");
- private NEUManager manager;
+ private final NEUManager manager;
- private String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
- private String petRegex = ".*?;[0-5]$";
+ private final String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
+ private final String petRegex = ".*?;[0-5]$";
- private ResourceLocation[] sortIcons = new ResourceLocation[] {
- sort_all, sort_mob, sort_pet, sort_tool, sort_armor, sort_accessory
+ private final ResourceLocation[] sortIcons = new ResourceLocation[]{
+ sort_all, sort_mob, sort_pet, sort_tool, sort_armor, sort_accessory
};
- private ResourceLocation[] sortIconsActive = new ResourceLocation[] {
+ private final ResourceLocation[] sortIconsActive = new ResourceLocation[]{
sort_all_active, sort_mob_active, sort_pet_active, sort_tool_active, sort_armor_active, sort_accessory_active
};
- private ResourceLocation[] orderIcons = new ResourceLocation[] {
+ private final ResourceLocation[] orderIcons = new ResourceLocation[]{
order_alphabetical, order_rarity, order_value
};
- private ResourceLocation[] orderIconsActive = new ResourceLocation[] {
+ private final ResourceLocation[] orderIconsActive = new ResourceLocation[]{
order_alphabetical_active, order_rarity_active, order_value_active
};
@@ -95,7 +103,7 @@ public class NEUOverlay extends Gui {
public static final int ITEM_SIZE = 16;
private Color bg = new Color(90, 90, 140, 50);
- private Color fg = new Color(100,100,100, 255);
+ private Color fg = new Color(100, 100, 100, 255);
private InfoPane activeInfoPane = null;
@@ -113,9 +121,9 @@ public class NEUOverlay extends Gui {
private int page = 0;
- private LerpingFloat itemPaneOffsetFactor = new LerpingFloat(1);
- private LerpingInteger itemPaneTabOffset = new LerpingInteger(20, 50);
- private LerpingFloat infoPaneOffsetFactor = new LerpingFloat(0);
+ private final LerpingFloat itemPaneOffsetFactor = new LerpingFloat(1);
+ private final LerpingInteger itemPaneTabOffset = new LerpingInteger(20, 50);
+ private final LerpingFloat infoPaneOffsetFactor = new LerpingFloat(0);
public boolean searchMode = false;
private long millisLastLeftClick = 0;
@@ -131,7 +139,7 @@ public class NEUOverlay extends Gui {
private boolean redrawItems = false;
private boolean searchBarHasFocus = false;
- private GuiTextField textField = new GuiTextField(0, null, 0, 0, 0, 0);
+ private final GuiTextField textField = new GuiTextField(0, null, 0, 0, 0, 0);
private static final int COMPARE_MODE_ALPHABETICAL = 0;
private static final int COMPARE_MODE_RARITY = 1;
@@ -167,27 +175,27 @@ public class NEUOverlay extends Gui {
public int getWidth() {
int paddingUnscaled = getPaddingUnscaled();
- return getSearchBarXSize() + 2*paddingUnscaled;
+ return getSearchBarXSize() + 2 * paddingUnscaled;
}
public int getHeight() {
int paddingUnscaled = getPaddingUnscaled();
- return getSearchBarYSize() + 2*paddingUnscaled;
+ return getSearchBarYSize() + 2 * paddingUnscaled;
}
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
return;
}
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
setSearchBarFocus(true);
- if(Mouse.getEventButton() == 1) { //Right mouse button down
+ if (Mouse.getEventButton() == 1) { //Right mouse button down
textField.setText("");
updateSearch();
} else {
- if(System.currentTimeMillis() - millisLastLeftClick < 300) {
+ if (System.currentTimeMillis() - millisLastLeftClick < 300) {
searchMode = !searchMode;
if (searchMode && NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus) {
NEUEventListener.displayNotification(Lists.newArrayList(
@@ -215,14 +223,14 @@ public class NEUOverlay extends Gui {
@Override
public void render(float x, float y) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
return;
}
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
int paddingUnscaled = getPaddingUnscaled();
GlStateManager.color(1, 1, 1, 1);
- if(searchMode) {
+ if (searchMode) {
Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR_GOLD);
} else {
Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR);
@@ -231,36 +239,36 @@ public class NEUOverlay extends Gui {
int w = getWidth();
int h = getHeight();
- for(int yIndex=0; yIndex<=2; yIndex++) {
- for(int xIndex=0; xIndex<=2; xIndex++) {
+ for (int yIndex = 0; yIndex <= 2; yIndex++) {
+ for (int xIndex = 0; xIndex <= 2; xIndex++) {
float uMin = 0;
- float uMax = 4/20f;
- int partX = (int)x;
+ float uMax = 4 / 20f;
+ int partX = (int) x;
int partW = 4;
- if(xIndex == 1) {
+ if (xIndex == 1) {
partX += 4;
- uMin = 4/20f;
- uMax = 16/20f;
- partW = w-8;
- } else if(xIndex == 2) {
- partX += w-4;
- uMin = 16/20f;
- uMax = 20/20f;
+ uMin = 4 / 20f;
+ uMax = 16 / 20f;
+ partW = w - 8;
+ } else if (xIndex == 2) {
+ partX += w - 4;
+ uMin = 16 / 20f;
+ uMax = 20 / 20f;
}
float vMin = 0;
- float vMax = 4/20f;
- int partY = (int)y;
+ float vMax = 4 / 20f;
+ int partY = (int) y;
int partH = 4;
- if(yIndex == 1) {
+ if (yIndex == 1) {
partY += 4;
- vMin = 4/20f;
- vMax = 16/20f;
- partH = h-8;
- } else if(yIndex == 2) {
- partY += h-4;
- vMin = 16/20f;
- vMax = 20/20f;
+ vMin = 4 / 20f;
+ vMax = 16 / 20f;
+ partH = h - 8;
+ } else if (yIndex == 2) {
+ partY += h - 4;
+ vMin = 16 / 20f;
+ vMax = 20 / 20f;
}
Utils.drawTexturedRect(partX, partY, partW, partH, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
@@ -268,35 +276,35 @@ public class NEUOverlay extends Gui {
}
//Search bar text
- fr.drawString(textField.getText(), (int)x + 5,
- (int) y-4 + getHeight()/2, Color.WHITE.getRGB());
+ fr.drawString(textField.getText(), (int) x + 5,
+ (int) y - 4 + getHeight() / 2, Color.WHITE.getRGB());
//Determines position of cursor. Cursor blinks on and off every 500ms.
- if(searchBarHasFocus && System.currentTimeMillis()%1000>500) {
+ if (searchBarHasFocus && System.currentTimeMillis() % 1000 > 500) {
String textBeforeCursor = textField.getText().substring(0, textField.getCursorPosition());
int textBeforeCursorWidth = fr.getStringWidth(textBeforeCursor);
- drawRect((int)x + 5 + textBeforeCursorWidth,
- (int)y-5 + getHeight()/2,
- (int)x + 5 + textBeforeCursorWidth+1,
- (int)y-4+9 + getHeight()/2, Color.WHITE.getRGB());
+ drawRect((int) x + 5 + textBeforeCursorWidth,
+ (int) y - 5 + getHeight() / 2,
+ (int) x + 5 + textBeforeCursorWidth + 1,
+ (int) y - 4 + 9 + getHeight() / 2, Color.WHITE.getRGB());
}
String selectedText = textField.getSelectedText();
- if(!selectedText.isEmpty()) {
+ if (!selectedText.isEmpty()) {
int selectionWidth = fr.getStringWidth(selectedText);
int leftIndex = Math.min(textField.getCursorPosition(), textField.getSelectionEnd());
String textBeforeSelection = textField.getText().substring(0, leftIndex);
int textBeforeSelectionWidth = fr.getStringWidth(textBeforeSelection);
- drawRect((int)x + 5 + textBeforeSelectionWidth,
- (int)y-5 + getHeight()/2,
- (int)x + 5 + textBeforeSelectionWidth + selectionWidth,
- (int)y-4+9 + getHeight()/2, Color.LIGHT_GRAY.getRGB());
+ drawRect((int) x + 5 + textBeforeSelectionWidth,
+ (int) y - 5 + getHeight() / 2,
+ (int) x + 5 + textBeforeSelectionWidth + selectionWidth,
+ (int) y - 4 + 9 + getHeight() / 2, Color.LIGHT_GRAY.getRGB());
fr.drawString(selectedText,
- (int)x + 5 + textBeforeSelectionWidth,
- (int)y-4 + getHeight()/2, Color.BLACK.getRGB());
+ (int) x + 5 + textBeforeSelectionWidth,
+ (int) y - 4 + getHeight() / 2, Color.BLACK.getRGB());
}
}
@@ -311,7 +319,7 @@ public class NEUOverlay extends Gui {
return new MBGuiElement() {
@Override
public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
+ return getSearchBarYSize() + getPaddingUnscaled() * 2;
}
@Override
@@ -325,10 +333,10 @@ public class NEUOverlay extends Gui {
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
return;
}
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor);
}
}
@@ -342,8 +350,7 @@ public class NEUOverlay extends Gui {
int paddingUnscaled = getPaddingUnscaled();
int searchYSize = getSearchBarYSize();
-
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
return;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
@@ -365,7 +372,7 @@ public class NEUOverlay extends Gui {
return new MBGuiElement() {
@Override
public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
+ return getSearchBarYSize() + getPaddingUnscaled() * 2;
}
@Override
@@ -379,10 +386,10 @@ public class NEUOverlay extends Gui {
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton){
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
return;
}
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
//displayInformationPane(HTMLInfoPane.createFromWikiUrl(overlay, manager, "Help",
// "https://moulberry.github.io/files/neu_help.html"));
//Minecraft.getMinecraft().displayGuiScreen(new HelpGUI());
@@ -400,7 +407,7 @@ public class NEUOverlay extends Gui {
int paddingUnscaled = getPaddingUnscaled();
int searchYSize = getSearchBarYSize();
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
return;
}
@@ -423,7 +430,7 @@ public class NEUOverlay extends Gui {
return new MBGuiElement() {
@Override
public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
+ return getSearchBarYSize() + getPaddingUnscaled() * 2;
}
@Override
@@ -437,16 +444,16 @@ public class NEUOverlay extends Gui {
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
- if((NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType != 0 && Mouse.getEventButtonState()) ||
+ if ((NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType != 0 && Mouse.getEventButtonState()) ||
(NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType == 0 && !Mouse.getEventButtonState() && Mouse.getEventButton() != -1)) {
- if(quickCommandStr.contains(":")) {
+ if (quickCommandStr.contains(":")) {
String command = quickCommandStr.split(":")[0].trim();
- if(command.startsWith("/")) {
+ if (command.startsWith("/")) {
NotEnoughUpdates.INSTANCE.sendChatMessage(command);
} else {
- ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/"+command);
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/" + command);
}
Utils.playPressSound();
}
@@ -459,19 +466,19 @@ public class NEUOverlay extends Gui {
@Override
public void render(float x, float y) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
int paddingUnscaled = getPaddingUnscaled();
int bigItemSize = getSearchBarYSize();
String[] quickCommandStrSplit = quickCommandStr.split(":");
- if(quickCommandStrSplit.length!=3) {
+ if (quickCommandStrSplit.length != 3) {
return;
}
String display = quickCommandStrSplit[2];
ItemStack render = null;
float extraScale = 1;
- if(display.length() > 20) { //Custom head
+ if (display.length() > 20) { //Custom head
render = new ItemStack(Items.skull, 1, 3);
NBTTagCompound nbt = new NBTTagCompound();
NBTTagCompound skullOwner = new NBTTagCompound();
@@ -492,15 +499,15 @@ public class NEUOverlay extends Gui {
render.setTagCompound(nbt);
extraScale = 1.3f;
- } else if(manager.getItemInformation().containsKey(display)) {
+ } else if (manager.getItemInformation().containsKey(display)) {
render = manager.jsonToStack(manager.getItemInformation().get(display), true, true);
} else {
Item item = Item.itemRegistry.getObject(new ResourceLocation(display.toLowerCase()));
- if(item != null) {
+ if (item != null) {
render = new ItemStack(item);
}
}
- if(render != null) {
+ if (render != null) {
NBTTagCompound tag = render.getTagCompound() != null ? render.getTagCompound() : new NBTTagCompound();
tag.setString("qc_id", quickCommandStrSplit[0].toLowerCase().trim());
render.setTagCompound(tag);
@@ -508,24 +515,24 @@ public class NEUOverlay extends Gui {
Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
GlStateManager.color(1, 1, 1, 1);
Utils.drawTexturedRect(x, y,
- bigItemSize + paddingUnscaled*2, bigItemSize + paddingUnscaled*2, GL11.GL_NEAREST);
+ bigItemSize + paddingUnscaled * 2, bigItemSize + paddingUnscaled * 2, GL11.GL_NEAREST);
int mouseX = Mouse.getX() * Utils.peekGuiScale().getScaledWidth() / Minecraft.getMinecraft().displayWidth;
int mouseY = Utils.peekGuiScale().getScaledHeight() - Mouse.getY() * Utils.peekGuiScale().getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1;
- if(mouseX > x && mouseX < x+bigItemSize) {
- if(mouseY > y && mouseY < y+bigItemSize) {
+ if (mouseX > x && mouseX < x + bigItemSize) {
+ if (mouseY > y && mouseY < y + bigItemSize) {
textToDisplay = new ArrayList<>();
- textToDisplay.add(EnumChatFormatting.GRAY+quickCommandStrSplit[1]);
+ textToDisplay.add(EnumChatFormatting.GRAY + quickCommandStrSplit[1]);
}
}
GlStateManager.enableDepth();
- float itemScale = bigItemSize/(float)ITEM_SIZE*extraScale;
+ float itemScale = bigItemSize / (float) ITEM_SIZE * extraScale;
GlStateManager.pushMatrix();
GlStateManager.scale(itemScale, itemScale, 1);
- GlStateManager.translate((x-(extraScale-1)*bigItemSize/2+paddingUnscaled) /itemScale,
- (y-(extraScale-1)*bigItemSize/2+paddingUnscaled)/itemScale, 0f);
+ GlStateManager.translate((x - (extraScale - 1) * bigItemSize / 2 + paddingUnscaled) / itemScale,
+ (y - (extraScale - 1) * bigItemSize / 2 + paddingUnscaled) / itemScale, 0f);
Utils.drawItemStack(render, 0, 0);
GlStateManager.popMatrix();
}
@@ -535,12 +542,12 @@ public class NEUOverlay extends Gui {
private MBGuiGroupAligned createQuickCommandGroup() {
List<MBGuiElement> children = new ArrayList<>();
- for(String quickCommand : NotEnoughUpdates.INSTANCE.config.hidden.quickCommands) {
+ for (String quickCommand : NotEnoughUpdates.INSTANCE.config.hidden.quickCommands) {
children.add(createQuickCommand(quickCommand));
}
return new MBGuiGroupAligned(children, false) {
public int getPadding() {
- return getPaddingUnscaled()*4;
+ return getPaddingUnscaled() * 4;
}
};
}
@@ -549,7 +556,7 @@ public class NEUOverlay extends Gui {
List<MBGuiElement> children = Lists.newArrayList(createSettingsButton(this), createSearchBar(), createHelpButton(this));
return new MBGuiGroupAligned(children, false) {
public int getPadding() {
- return getPaddingUnscaled()*4;
+ return getPaddingUnscaled() * 4;
}
};
}
@@ -564,7 +571,7 @@ public class NEUOverlay extends Gui {
new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
quickCommandAnchor = quickCommandAnchor != null ? quickCommandAnchor :
new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0,
- -searchBarYOffset-getSearchBarYSize()-getPaddingUnscaled()*4));
+ -searchBarYOffset - getSearchBarYSize() - getPaddingUnscaled() * 4));
map.put(createSearchBarGroup(), searchBarAnchor);
map.put(createQuickCommandGroup(), quickCommandAnchor);
@@ -576,32 +583,31 @@ public class NEUOverlay extends Gui {
MBAnchorPoint searchBarAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar);
MBAnchorPoint quickCommandAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand);
- if(onlyIfNull) {
+ if (onlyIfNull) {
searchBarAnchor = searchBarAnchor != null ? null :
new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
quickCommandAnchor = quickCommandAnchor != null ? null :
new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0,
- -searchBarYOffset-getSearchBarYSize()-getPaddingUnscaled()*4));
+ -searchBarYOffset - getSearchBarYSize() - getPaddingUnscaled() * 4));
} else {
searchBarAnchor = searchBarAnchor != null ? searchBarAnchor :
new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
quickCommandAnchor = quickCommandAnchor != null ? quickCommandAnchor :
new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0,
- -searchBarYOffset-getSearchBarYSize()-getPaddingUnscaled()*4));
+ -searchBarYOffset - getSearchBarYSize() - getPaddingUnscaled() * 4));
}
-
int index = 0;
Set<MBGuiElement> set = new LinkedHashSet<>(guiGroup.getChildrenMap().keySet());
- for(MBGuiElement element : set) {
- switch(index) {
+ for (MBGuiElement element : set) {
+ switch (index) {
case 0:
- if(searchBarAnchor == null) continue;
+ if (searchBarAnchor == null) continue;
guiGroup.getChildrenMap().get(element).anchorPoint = searchBarAnchor.anchorPoint;
guiGroup.getChildrenMap().get(element).offset = searchBarAnchor.offset;
break;
case 1:
- if(quickCommandAnchor == null) continue;
+ if (quickCommandAnchor == null) continue;
guiGroup.getChildrenMap().get(element).anchorPoint = quickCommandAnchor.anchorPoint;
guiGroup.getChildrenMap().get(element).offset = quickCommandAnchor.offset;
break;
@@ -615,12 +621,12 @@ public class NEUOverlay extends Gui {
*/
public void reset() {
searchBarHasFocus = false;
- if(!(searchMode || (NotEnoughUpdates.INSTANCE.config.itemlist.keepopen && itemPaneOpen))) {
+ if (!(searchMode || (NotEnoughUpdates.INSTANCE.config.itemlist.keepopen && itemPaneOpen))) {
itemPaneOpen = false;
itemPaneOffsetFactor.setValue(1);
itemPaneTabOffset.setValue(20);
}
- if(activeInfoPane != null) activeInfoPane.reset();
+ if (activeInfoPane != null) activeInfoPane.reset();
guiGroup.recalculate();
}
@@ -628,7 +634,7 @@ public class NEUOverlay extends Gui {
* Calls #displayInformationPane with a HTMLInfoPane created from item.info and item.infoType.
*/
public void showInfo(JsonObject item) {
- if(item.has("info") && item.has("infoType")) {
+ if (item.has("info") && item.has("infoType")) {
JsonArray lore = item.get("info").getAsJsonArray();
String[] loreA = new String[lore.size()];
for (int i = 0; i < lore.size(); i++) loreA[i] = lore.get(i).getAsString();
@@ -636,7 +642,7 @@ public class NEUOverlay extends Gui {
String internalname = item.get("internalname").getAsString();
String name = item.get("displayname").getAsString();
- switch(item.get("infoType").getAsString()) {
+ switch (item.get("infoType").getAsString()) {
case "WIKI_URL":
displayInformationPane(HTMLInfoPane.createFromWikiUrl(this, manager, name, loreS));
return;
@@ -652,13 +658,13 @@ public class NEUOverlay extends Gui {
}
public void mouseInputInv() {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
- if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- Slot slot = Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen);
- if(slot != null) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
+ if (Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode() + 100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ Slot slot = Utils.getSlotUnderMouse((GuiContainer) Minecraft.getMinecraft().currentScreen);
+ if (slot != null) {
ItemStack hover = slot.getStack();
- if(hover != null) {
- textField.setText("id:"+manager.getInternalNameForItem(hover));
+ if (hover != null) {
+ textField.setText("id:" + manager.getInternalNameForItem(hover));
itemPaneOpen = true;
updateSearch();
}
@@ -671,7 +677,7 @@ public class NEUOverlay extends Gui {
* Handles the mouse input, cancelling the forge event if a NEU gui element is clicked.
*/
public boolean mouseInput() {
- if(disabled) {
+ if (disabled) {
return false;
}
@@ -689,30 +695,30 @@ public class NEUOverlay extends Gui {
lastMouseX = mouseX;
lastMouseY = mouseY;
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
mouseDown = true;
- } else if(Mouse.getEventButton() != -1) {
+ } else if (Mouse.getEventButton() != -1) {
mouseDown = false;
}
//Unfocuses the search bar by default. Search bar is focused if the click is on the bar itself.
- if(Mouse.getEventButtonState()) setSearchBarFocus(false);
+ if (Mouse.getEventButtonState()) setSearchBarFocus(false);
guiGroup.mouseClick(0, 0, mouseX, mouseY);
- if(selectedItemGroup != null) {
- int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size());
- if(mouseY > selectedItemGroupY+17 && mouseY < selectedItemGroupY+35) {
- for(int i=0; i<selectedItemGroup.size(); i++) {
- if(mouseX >= selectedX-1+18*i && mouseX <= selectedX+17+18*i) {
+ if (selectedItemGroup != null) {
+ int selectedX = Math.min(selectedItemGroupX, width - getBoxPadding() - 18 * selectedItemGroup.size());
+ if (mouseY > selectedItemGroupY + 17 && mouseY < selectedItemGroupY + 35) {
+ for (int i = 0; i < selectedItemGroup.size(); i++) {
+ if (mouseX >= selectedX - 1 + 18 * i && mouseX <= selectedX + 17 + 18 * i) {
JsonObject item = selectedItemGroup.get(i);
if (item != null) {
- if(Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButton() == 0) {
manager.showRecipe(item);
- } else if(Mouse.getEventButton() == 1) {
+ } else if (Mouse.getEventButton() == 1) {
showInfo(item);
- } else if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- textField.setText("id:"+item.get("internalname").getAsString());
+ } else if (Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode() + 100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ textField.setText("id:" + item.get("internalname").getAsString());
updateSearch();
searchMode = true;
}
@@ -725,8 +731,8 @@ public class NEUOverlay extends Gui {
}
//Item selection (right) gui
- if(mouseX > width*getItemPaneOffsetFactor()) {
- if(!Mouse.getEventButtonState()) {
+ if (mouseX > width * getItemPaneOffsetFactor()) {
+ if (!Mouse.getEventButtonState()) {
Utils.pushGuiScale(-1);
return true; //End early if the mouse isn't pressed, but still cancel event.
}
@@ -734,18 +740,18 @@ public class NEUOverlay extends Gui {
AtomicBoolean clickedItem = new AtomicBoolean(false);
iterateItemSlots(new ItemSlotConsumer() {
public void consume(int x, int y, int id) {
- if(mouseX >= x-1 && mouseX <= x+ITEM_SIZE+1) {
- if(mouseY >= y-1 && mouseY <= y+ITEM_SIZE+1) {
+ if (mouseX >= x - 1 && mouseX <= x + ITEM_SIZE + 1) {
+ if (mouseY >= y - 1 && mouseY <= y + ITEM_SIZE + 1) {
clickedItem.set(true);
JsonObject item = getSearchedItemPage(id);
if (item != null) {
- if(Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButton() == 0) {
manager.showRecipe(item);
- } else if(Mouse.getEventButton() == 1) {
+ } else if (Mouse.getEventButton() == 1) {
showInfo(item);
- } else if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- textField.setText("id:"+item.get("internalname").getAsString());
+ } else if (Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode() + 100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ textField.setText("id:" + item.get("internalname").getAsString());
updateSearch();
searchMode = true;
}
@@ -754,52 +760,52 @@ public class NEUOverlay extends Gui {
}
}
});
- if(!clickedItem.get()) {
- int paneWidth = (int)(width/3*getWidthMult());
- int leftSide = (int)(width*getItemPaneOffsetFactor());
- int rightSide = leftSide+paneWidth-getBoxPadding()-getItemBoxXPadding();
- leftSide = leftSide+getBoxPadding()+getItemBoxXPadding();
+ if (!clickedItem.get()) {
+ int paneWidth = (int) (width / 3 * getWidthMult());
+ int leftSide = (int) (width * getItemPaneOffsetFactor());
+ int rightSide = leftSide + paneWidth - getBoxPadding() - getItemBoxXPadding();
+ leftSide = leftSide + getBoxPadding() + getItemBoxXPadding();
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
int maxPages = getMaxPages();
- String name = Utils.peekGuiScale().getScaleFactor()<4?"Page: ":"";
- float maxStrLen = fr.getStringWidth(EnumChatFormatting.BOLD+name + maxPages + "/" + maxPages);
- float maxButtonXSize = (rightSide-leftSide+2 - maxStrLen*0.5f - 10)/2f;
- int buttonXSize = (int)Math.min(maxButtonXSize, getSearchBarYSize()*480/160f);
- int ySize = (int)(buttonXSize/480f*160);
- int yOffset = (int)((getSearchBarYSize()-ySize)/2f);
- int top = getBoxPadding()+yOffset;
-
- if(mouseY >= top && mouseY <= top+ySize) {
- int leftPrev = leftSide-1;
- if(mouseX > leftPrev && mouseX < leftPrev+buttonXSize) { //"Previous" button
- setPage(page-1);
+ String name = Utils.peekGuiScale().getScaleFactor() < 4 ? "Page: " : "";
+ float maxStrLen = fr.getStringWidth(EnumChatFormatting.BOLD + name + maxPages + "/" + maxPages);
+ float maxButtonXSize = (rightSide - leftSide + 2 - maxStrLen * 0.5f - 10) / 2f;
+ int buttonXSize = (int) Math.min(maxButtonXSize, getSearchBarYSize() * 480 / 160f);
+ int ySize = (int) (buttonXSize / 480f * 160);
+ int yOffset = (int) ((getSearchBarYSize() - ySize) / 2f);
+ int top = getBoxPadding() + yOffset;
+
+ if (mouseY >= top && mouseY <= top + ySize) {
+ int leftPrev = leftSide - 1;
+ if (mouseX > leftPrev && mouseX < leftPrev + buttonXSize) { //"Previous" button
+ setPage(page - 1);
Utils.playPressSound();
}
- int leftNext = rightSide+1-buttonXSize;
- if(mouseX > leftNext && mouseX < leftNext+buttonXSize) { //"Next" button
- setPage(page+1);
+ int leftNext = rightSide + 1 - buttonXSize;
+ if (mouseX > leftNext && mouseX < leftNext + buttonXSize) { //"Next" button
+ setPage(page + 1);
Utils.playPressSound();
}
}
- float sortIconsMinX = (sortIcons.length+orderIcons.length)*(ITEM_SIZE+ITEM_PADDING)+ITEM_SIZE;
- float availableX = rightSide-leftSide;
+ float sortIconsMinX = (sortIcons.length + orderIcons.length) * (ITEM_SIZE + ITEM_PADDING) + ITEM_SIZE;
+ float availableX = rightSide - leftSide;
float sortOrderScaleFactor = Math.min(1, availableX / sortIconsMinX);
- int scaledITEM_SIZE = (int)(ITEM_SIZE*sortOrderScaleFactor);
- int scaledItemPaddedSize = (int)((ITEM_SIZE+ITEM_PADDING)*sortOrderScaleFactor);
- int iconTop = height-getBoxPadding()-(ITEM_SIZE+scaledITEM_SIZE)/2-1;
+ int scaledITEM_SIZE = (int) (ITEM_SIZE * sortOrderScaleFactor);
+ int scaledItemPaddedSize = (int) ((ITEM_SIZE + ITEM_PADDING) * sortOrderScaleFactor);
+ int iconTop = height - getBoxPadding() - (ITEM_SIZE + scaledITEM_SIZE) / 2 - 1;
- if(mouseY >= iconTop && mouseY <= iconTop+scaledITEM_SIZE) {
- for(int i=0; i<orderIcons.length; i++) {
- int orderIconX = leftSide+i*scaledItemPaddedSize;
- if(mouseX >= orderIconX && mouseX <= orderIconX+scaledITEM_SIZE) {
- if(Mouse.getEventButton() == 0) {
+ if (mouseY >= iconTop && mouseY <= iconTop + scaledITEM_SIZE) {
+ for (int i = 0; i < orderIcons.length; i++) {
+ int orderIconX = leftSide + i * scaledItemPaddedSize;
+ if (mouseX >= orderIconX && mouseX <= orderIconX + scaledITEM_SIZE) {
+ if (Mouse.getEventButton() == 0) {
NotEnoughUpdates.INSTANCE.config.hidden.compareMode = i;
updateSearch();
Utils.playPressSound();
- } else if(Mouse.getEventButton() == 1) {
+ } else if (Mouse.getEventButton() == 1) {
NotEnoughUpdates.INSTANCE.config.hidden.compareAscending.set(i,