aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.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/miscgui/GuiCustomEnchant.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/miscgui/GuiCustomEnchant.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java961
1 files changed, 480 insertions, 481 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
index 0fbf9406..2b92a86c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
@@ -80,24 +80,24 @@ public class GuiCustomEnchant extends Gui {
this.displayLore = displayLore;
this.level = level;
- if(Constants.ENCHANTS != null) {
- if(checkConflicts && Constants.ENCHANTS.has("enchant_pools")) {
+ if (Constants.ENCHANTS != null) {
+ if (checkConflicts && Constants.ENCHANTS.has("enchant_pools")) {
JsonArray pools = Constants.ENCHANTS.getAsJsonArray("enchant_pools");
out:
- for(int i=0; i<pools.size(); i++) {
+ for (int i = 0; i < pools.size(); i++) {
JsonArray pool = pools.get(i).getAsJsonArray();
boolean hasThis = false;
boolean hasApplied = false;
- for(int j=0; j<pool.size(); j++) {
+ for (int j = 0; j < pool.size(); j++) {
String enchIdPoolElement = pool.get(j).getAsString();
- if(enchId.equalsIgnoreCase(enchIdPoolElement)) {
+ if (enchId.equalsIgnoreCase(enchIdPoolElement)) {
hasThis = true;
- } else if(playerEnchantIds.containsKey(enchIdPoolElement)) {
+ } else if (playerEnchantIds.containsKey(enchIdPoolElement)) {
hasApplied = true;
}
- if(hasThis && hasApplied) {
+ if (hasThis && hasApplied) {
this.conflicts = true;
break out;
}
@@ -105,16 +105,16 @@ public class GuiCustomEnchant extends Gui {
}
}
- if(level >= 1 && Constants.ENCHANTS.has("enchants_xp_cost")) {
+ if (level >= 1 && Constants.ENCHANTS.has("enchants_xp_cost")) {
JsonObject allCosts = Constants.ENCHANTS.getAsJsonObject("enchants_xp_cost");
- if(allCosts.has(enchId)) {
+ if (allCosts.has(enchId)) {
JsonArray costs = allCosts.getAsJsonArray(enchId);
- if(costs.size() >= 1) {
- if(useMaxLevelForCost) {
- this.xpCost = costs.get(costs.size()-1).getAsInt();
- } else if(level-1 < costs.size()) {
- this.xpCost = costs.get(level-1).getAsInt();
+ if (costs.size() >= 1) {
+ if (useMaxLevelForCost) {
+ this.xpCost = costs.get(costs.size() - 1).getAsInt();
+ } else if (level - 1 < costs.size()) {
+ this.xpCost = costs.get(level - 1).getAsInt();
} else {
overMaxLevel = true;
}
@@ -138,7 +138,7 @@ public class GuiCustomEnchant extends Gui {
public int rotationDeg;
}
- private List<ExperienceOrb> orbs = new ArrayList<>();
+ private final List<ExperienceOrb> orbs = new ArrayList<>();
private int orbTargetX = 0;
private int orbTargetY = 0;
@@ -162,16 +162,16 @@ public class GuiCustomEnchant extends Gui {
private int removingEnchantPlayerLevel = -1;
- private GuiElementTextField searchField = new GuiElementTextField("", GuiElementTextField.SCISSOR_TEXT);
+ private final GuiElementTextField searchField = new GuiElementTextField("", GuiElementTextField.SCISSOR_TEXT);
- private HashMap<String, Integer> playerEnchantIds = new HashMap<>();
+ private final HashMap<String, Integer> playerEnchantIds = new HashMap<>();
private boolean searchRemovedFromApplicable = false;
private boolean searchRemovedFromRemovable = false;
- private List<Enchantment> applicable = new ArrayList<>();
- private List<Enchantment> removable = new ArrayList<>();
+ private final List<Enchantment> applicable = new ArrayList<>();
+ private final List<Enchantment> removable = new ArrayList<>();
- private HashMap<Integer, Enchantment> enchanterEnchLevels = new HashMap<>();
+ private final HashMap<Integer, Enchantment> enchanterEnchLevels = new HashMap<>();
private Enchantment enchanterCurrentEnch = null;
public Random random = new Random();
@@ -179,10 +179,10 @@ public class GuiCustomEnchant extends Gui {
private EnchantState currentState = EnchantState.NO_ITEM;
private EnchantState lastState = EnchantState.NO_ITEM;
- private LerpingInteger leftScroll = new LerpingInteger(0, 150);
- private LerpingInteger rightScroll = new LerpingInteger(0, 150);
+ private final LerpingInteger leftScroll = new LerpingInteger(0, 150);
+ private final LerpingInteger rightScroll = new LerpingInteger(0, 150);
- private LerpingFloat arrowAmount = new LerpingFloat(0, 100);
+ private final LerpingFloat arrowAmount = new LerpingFloat(0, 100);
private static final int X_SIZE = 364;
private static final int Y_SIZE = 215;
@@ -204,7 +204,7 @@ public class GuiCustomEnchant extends Gui {
containerName != null &&
NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
containerName.equalsIgnoreCase("Enchant Item");
- if(!shouldOverrideFast) {
+ if (!shouldOverrideFast) {
currentState = EnchantState.NO_ITEM;
applicable.clear();
removable.clear();
@@ -214,8 +214,9 @@ public class GuiCustomEnchant extends Gui {
}
private int tickCounter = 0;
+
public void tick() {
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
ContainerChest cc = (ContainerChest) chest.inventorySlots;
ItemStack stack = cc.getLowerChestInventory().getStackInSlot(23);
@@ -225,51 +226,51 @@ public class GuiCustomEnchant extends Gui {
int lastPage = currentPage;
this.lastState = currentState;
- if(enchantGuideStack != null && enchantGuideStack.getItem() != Items.book && enchantingItem != null) {
+ if (enchantGuideStack != null && enchantGuideStack.getItem() != Items.book && enchantingItem != null) {
currentState = EnchantState.ADDING_ENCHANT;
- } else if(stack == null || enchantingItemStack == null) {
- if(currentState == EnchantState.SWITCHING_DONT_UPDATE || currentState == EnchantState.NO_ITEM) {
+ } else if (stack == null || enchantingItemStack == null) {
+ if (currentState == EnchantState.SWITCHING_DONT_UPDATE || currentState == EnchantState.NO_ITEM) {
currentState = EnchantState.NO_ITEM;
} else {
currentState = EnchantState.SWITCHING_DONT_UPDATE;
}
- } else if(stack.getItem() != Items.dye) {
+ } else if (stack.getItem() != Items.dye) {
ItemStack sanityCheckStack = cc.getLowerChestInventory().getStackInSlot(12);
- if(sanityCheckStack == null || sanityCheckStack.getItem() == Items.enchanted_book) {
+ if (sanityCheckStack == null || sanityCheckStack.getItem() == Items.enchanted_book) {
currentState = EnchantState.HAS_ITEM;
enchantingItem = enchantingItemStack;
} else {
currentState = EnchantState.SWITCHING_DONT_UPDATE;
}
- } else if(stack.getItemDamage() == 1) {
+ } else if (stack.getItemDamage() == 1) {
currentState = EnchantState.INVALID_ITEM;
} else {
currentState = EnchantState.NO_ITEM;
}
- if(currentState == EnchantState.HAS_ITEM) {
+ if (currentState == EnchantState.HAS_ITEM) {
ItemStack pageUpStack = cc.getLowerChestInventory().getStackInSlot(17);
ItemStack pageDownStack = cc.getLowerChestInventory().getStackInSlot(35);
- if(pageUpStack != null && pageDownStack != null) {
+ if (pageUpStack != null && pageDownStack != null) {
currentPage = 0;
boolean upIsGlass = pageUpStack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane);
boolean downIsGlass = pageDownStack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane);
int page = -1;
expectedMaxPage = 1;
- if(!downIsGlass) {
+ if (!downIsGlass) {
try {
- page = Integer.parseInt(Utils.getRawTooltip(pageDownStack).get(1).substring(11))-1;
- expectedMaxPage = page+1;
- } catch(Exception ignored) {}
+ page = Integer.parseInt(Utils.getRawTooltip(pageDownStack).get(1).substring(11)) - 1;
+ expectedMaxPage = page + 1;
+ } catch (Exception ignored) {}
}
- if(page == -1 && !upIsGlass) {
+ if (page == -1 && !upIsGlass) {
try {
- page = Integer.parseInt(Utils.getRawTooltip(pageUpStack).get(1).substring(11))+1;
+ page = Integer.parseInt(Utils.getRawTooltip(pageUpStack).get(1).substring(11)) + 1;
expectedMaxPage = page;
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
}
- if(page == -1) {
+ if (page == -1) {
currentPage = 1;
} else {
currentPage = page;
@@ -278,19 +279,19 @@ public class GuiCustomEnchant extends Gui {
}
List<ExperienceOrb> toRemove = new ArrayList<>();
- for(ExperienceOrb orb : orbs) {
- float targetDeltaX = guiLeft+orbTargetX - orb.x;
- float targetDeltaY = guiTop+orbTargetY - orb.y;
+ for (ExperienceOrb orb : orbs) {
+ float targetDeltaX = guiLeft + orbTargetX - orb.x;
+ float targetDeltaY = guiTop + orbTargetY - orb.y;
- float length = (float)Math.sqrt(targetDeltaX*targetDeltaX + targetDeltaY*targetDeltaY);
+ float length = (float) Math.sqrt(targetDeltaX * targetDeltaX + targetDeltaY * targetDeltaY);
- if(length < 8 && orb.xVel*orb.xVel+orb.yVel*orb.yVel < 20) {
+ if (length < 8 && orb.xVel * orb.xVel + orb.yVel * orb.yVel < 20) {
toRemove.add(orb);
continue;
}
- orb.xVel += targetDeltaX*2/length;
- orb.yVel += targetDeltaY*2/length;
+ orb.xVel += targetDeltaX * 2 / length;
+ orb.yVel += targetDeltaY * 2 / length;
orb.xVel *= 0.90;
orb.yVel *= 0.90;
@@ -302,45 +303,45 @@ public class GuiCustomEnchant extends Gui {
}
orbs.removeAll(toRemove);
- if(++tickCounter >= 20) {
+ if (++tickCounter >= 20) {
tickCounter = 0;
}
boolean updateItems = tickCounter == 0;
- if(currentState == EnchantState.ADDING_ENCHANT) {
- if(arrowAmount.getTarget() != 1) {
+ if (currentState == EnchantState.ADDING_ENCHANT) {
+ if (arrowAmount.getTarget() != 1) {
arrowAmount.setTarget(1);
arrowAmount.resetTimer();
}
} else {
- if(arrowAmount.getTarget() != 0) {
+ if (arrowAmount.getTarget() != 0) {
arrowAmount.setTarget(0);
arrowAmount.resetTimer();
}
}
Set<EnchantState> allowedSwitchStates = Sets.newHashSet(EnchantState.ADDING_ENCHANT, EnchantState.HAS_ITEM, EnchantState.SWITCHING_DONT_UPDATE);
- if(lastState != currentState || lastPage != currentPage) {
- if(!allowedSwitchStates.contains(lastState) || !allowedSwitchStates.contains(currentState)) {
+ if (lastState != currentState || lastPage != currentPage) {
+ if (!allowedSwitchStates.contains(lastState) || !allowedSwitchStates.contains(currentState)) {
leftScroll.setValue(0);
rightScroll.setValue(0);
}
updateItems = true;
}
- if(updateItems && currentState != EnchantState.SWITCHING_DONT_UPDATE) {
+ if (updateItems && currentState != EnchantState.SWITCHING_DONT_UPDATE) {
enchanterEnchLevels.clear();
- if(enchantingItem != null) {
+ if (enchantingItem != null) {
playerEnchantIds.clear();
NBTTagCompound tag = enchantingItem.getTagCompound();
- if(tag != null) {
+ if (tag != null) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea != null) {
+ if (ea != null) {
NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- if(enchantments != null) {
- for(String enchId : enchantments.getKeySet()) {
+ if (enchantments != null) {
+ for (String enchId : enchantments.getKeySet()) {
playerEnchantIds.put(enchId, enchantments.getInteger(enchId));
}
}
@@ -348,46 +349,46 @@ public class GuiCustomEnchant extends Gui {
}
}
- if(currentState == EnchantState.ADDING_ENCHANT) {
+ if (currentState == EnchantState.ADDING_ENCHANT) {
removingEnchantPlayerLevel = -1;
boolean updateLevel = enchanterCurrentEnch == null;
- for(int i=0; i<27; i++) {
+ for (int i = 0; i < 27; i++) {
int slotIndex = 9 + i;
ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex);
- if(book != null && book.getItem() == Items.enchanted_book) {
+ if (book != null && book.getItem() == Items.enchanted_book) {
NBTTagCompound tagBook = book.getTagCompound();
- if(tagBook != null) {
+ if (tagBook != null) {
NBTTagCompound ea = tagBook.getCompoundTag("ExtraAttributes");
- if(ea != null) {
+ if (ea != null) {
NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- if(enchantments != null) {
- for(String enchId : enchantments.getKeySet()) {
+ if (enchantments != null) {
+ for (String enchId : enchantments.getKeySet()) {
String name = Utils.cleanColour(book.getDisplayName());
- if(name.equalsIgnoreCase("Bane of Arthropods")) {
+ if (name.equalsIgnoreCase("Bane of Arthropods")) {
name = "Bane of Arth.";
- } else if(name.equalsIgnoreCase("Projectile Protection")) {
+ } else if (name.equalsIgnoreCase("Projectile Protection")) {
name = "Projectile Prot";
- } else if(name.equalsIgnoreCase("Blast Protection")) {
+ } else if (name.equalsIgnoreCase("Blast Protection")) {
name = "Blast Prot";
}
Enchantment enchantment = new Enchantment(slotIndex, name, enchId,
Utils.getRawTooltip(book), enchantments.getInteger(enchId), false, true);
enchantment.displayLore.remove(0);
- if(removingEnchantPlayerLevel == -1 && playerEnchantIds.containsKey(enchId)) {
+ if (removingEnchantPlayerLevel == -1 && playerEnchantIds.containsKey(enchId)) {
removingEnchantPlayerLevel = playerEnchantIds.get(enchId);
}
- if(removingEnchantPlayerLevel >= 0 && enchantment.level < removingEnchantPlayerLevel) {
+ if (removingEnchantPlayerLevel >= 0 && enchantment.level < removingEnchantPlayerLevel) {
continue;
}
- if(enchanterCurrentEnch == null) {
+ if (enchanterCurrentEnch == null) {
enchanterCurrentEnch = enchantment;
- } else if(updateLevel) {
- if(removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level) {
+ } else if (updateLevel) {
+ if (removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level) {
enchanterCurrentEnch = enchantment;
- } else if(removingEnchantPlayerLevel >= 0 && enchantment.level < enchanterCurrentEnch.level) {
+ } else if (removingEnchantPlayerLevel >= 0 && enchantment.level < enchanterCurrentEnch.level) {
enchanterCurrentEnch = enchantment;
}
}
@@ -399,10 +400,10 @@ public class GuiCustomEnchant extends Gui {
}
}
}
- if(enchanterCurrentEnch != null && removingEnchantPlayerLevel >= 0) {
- for(String line : enchanterCurrentEnch.displayLore) {
+ if (enchanterCurrentEnch != null && removingEnchantPlayerLevel >= 0) {
+ for (String line : enchanterCurrentEnch.displayLore) {
Matcher matcher = XP_COST_PATTERN.matcher(line);
- if(matcher.find()) {
+ if (matcher.find()) {
enchanterCurrentEnch.xpCost = Integer.parseInt(matcher.group(1));
}
}
@@ -415,36 +416,36 @@ public class GuiCustomEnchant extends Gui {
searchRemovedFromApplicable = false;
applicable.clear();
removable.clear();
- if(currentState == EnchantState.HAS_ITEM) {
- for(int i=0; i<15; i++) {
- int slotIndex = 12 + (i%5) + (i/5)*9;
+ if (currentState == EnchantState.HAS_ITEM) {
+ for (int i = 0; i < 15; i++) {
+ int slotIndex = 12 + (i % 5) + (i / 5) * 9;
ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex);
- if(book != null) {
+ if (book != null) {
NBTTagCompound tagBook = book.getTagCompound();
- if(tagBook != null) {
+ if (tagBook != null) {
NBTTagCompound ea = tagBook.getCompoundTag("ExtraAttributes");
- if(ea != null) {
+ if (ea != null) {
NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- if(enchantments != null) {
- for(String enchId : enchantments.getKeySet()) {
+ if (enchantments != null) {
+ for (String enchId : enchantments.getKeySet()) {
String name = Utils.cleanColour(book.getDisplayName());
- if(searchField.getText().trim().isEmpty() ||
+ if (searchField.getText().trim().isEmpty() ||
name.toLowerCase().contains(searchField.getText().trim().toLowerCase())) {
- if(name.equalsIgnoreCase("Bane of Arthropods")) {
+ if (name.equalsIgnoreCase("Bane of Arthropods")) {
name = "Bane of Arth.";
- } else if(name.equalsIgnoreCase("Projectile Protection")) {
+ } else if (name.equalsIgnoreCase("Projectile Protection")) {
name = "Projectile Prot";
- } else if(name.equalsIgnoreCase("Blast Protection")) {
+ } else if (name.equalsIgnoreCase("Blast Protection")) {
name = "Blast Prot";
- } else if(name.equalsIgnoreCase("Luck of the Sea")) {
+ } else if (name.equalsIgnoreCase("Luck of the Sea")) {
name = "Luck of Sea";
}
- if(playerEnchantIds.containsKey(enchId)) {
+ if (playerEnchantIds.containsKey(enchId)) {
Enchantment enchantment = new Enchantment(slotIndex, name, enchId,
Utils.getRawTooltip(book), playerEnchantIds.get(enchId), false, false);
- if(!enchantment.overMaxLevel) {
+ if (!enchantment.overMaxLevel) {
removable.add(enchantment);
}
} else {
@@ -453,7 +454,7 @@ public class GuiCustomEnchant extends Gui {
applicable.add(enchantment);
}
} else {
- if(playerEnchantIds.containsKey(enchId)) {
+ if (playerEnchantIds.containsKey(enchId)) {
searchRemovedFromRemovable = true;
} else {
searchRemovedFromApplicable = true;
@@ -469,8 +470,8 @@ public class GuiCustomEnchant extends Gui {
NEUConfig cfg = NotEnoughUpdates.INSTANCE.config;
int mult = cfg.enchantingSolvers.enchantOrdering == 0 ? 1 : -1;
Comparator<Enchantment> comparator = cfg.enchantingSolvers.enchantSorting == 0 ?
- Comparator.comparingInt(e -> mult*e.xpCost) :
- (c1, c2) -> mult*c1.enchId.toLowerCase().compareTo(c2.enchId.toLowerCase());
+ Comparator.comparingInt(e -> mult * e.xpCost) :
+ (c1, c2) -> mult * c1.enchId.toLowerCase().compareTo(c2.enchId.toLowerCase());
removable.sort(comparator);
applicable.sort(comparator);
}
@@ -480,7 +481,7 @@ public class GuiCustomEnchant extends Gui {
//Update book model state
if (lastState != currentState) {
while (true) {
- this.pageOpenRandom += (float)(this.random.nextInt(4) - this.random.nextInt(4));
+ this.pageOpenRandom += (float) (this.random.nextInt(4) - this.random.nextInt(4));
if (this.pageOpen > this.pageOpenRandom + 1.0F || this.pageOpen < this.pageOpenRandom - 1.0F) {
break;
@@ -504,32 +505,31 @@ public class GuiCustomEnchant extends Gui {
this.pageOpen += this.pageOpenVelocity;
}
-
private List<String> createTooltip(String title, int selectedOption, String... options) {
String selPrefix = EnumChatFormatting.DARK_AQUA + " \u25b6 ";
String unselPrefix = EnumChatFormatting.GRAY.toString();
- for(int i=0; i<options.length; i++) {
- if(i == selectedOption) {
+ for (int i = 0; i < options.length; i++) {
+ if (i == selectedOption) {
options[i] = selPrefix + options[i];
} else {
options[i] = unselPrefix + options[i];
}
}
- List list = Lists.newArrayList(options);
+ List<String> list = Lists.newArrayList(options);
list.add(0, "");
- list.add(0, EnumChatFormatting.GREEN+title);
+ list.add(0, EnumChatFormatting.GREEN + title);
return list;
}
public void render(float partialTicks) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
long currentTime = System.currentTimeMillis();
int playerXpLevel = Minecraft.getMinecraft().thePlayer.experienceLevel;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
ContainerChest cc = (ContainerChest) chest.inventorySlots;
leftScroll.tick();
@@ -542,8 +542,8 @@ public class GuiCustomEnchant extends Gui {
int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
- guiLeft = (width-X_SIZE)/2;
- guiTop = (height-Y_SIZE)/2;
+ guiLeft = (width - X_SIZE) / 2;
+ guiTop = (height - Y_SIZE) / 2;
List<String> tooltipToDisplay = null;
boolean disallowClick = false;
@@ -558,71 +558,71 @@ public class GuiCustomEnchant extends Gui {
Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
GlStateManager.color(1, 1, 1, 1);
Utils.drawTexturedRect(guiLeft, guiTop, X_SIZE, Y_SIZE,
- 0, X_SIZE/512f, 0, Y_SIZE/512f, GL11.GL_NEAREST);
+ 0, X_SIZE / 512f, 0, Y_SIZE / 512f, GL11.GL_NEAREST);
- Minecraft.getMinecraft().fontRendererObj.drawString("Applicable", guiLeft+7, guiTop+7, 0x404040, false);
- Minecraft.getMinecraft().fontRendererObj.drawString("Removable", guiLeft+247, guiTop+7, 0x404040, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString("Removable", guiLeft + 247, guiTop + 7, 0x404040, false);
//Page Text
- if(currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
- String pageStr = "Page: "+currentPage+"/"+expectedMaxPage;
+ if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
+ String pageStr = "Page: " + currentPage + "/" + expectedMaxPage;
int pageStrLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageStr);
Utils.drawStringCentered(pageStr, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2, guiTop+14, false, 0x404040);
+ guiLeft + X_SIZE / 2, guiTop + 14, false, 0x404040);
//Page Arrows
Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+X_SIZE/2-pageStrLen/2-2-15, guiTop+6, 15, 15,
- 0, 15/512f, 372/512f, 387/512f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft+X_SIZE/2+pageStrLen/2+2, guiTop+6, 15, 15,
- 15/512f, 30/512f, 372/512f, 387/512f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - pageStrLen / 2 - 2 - 15, guiTop + 6, 15, 15,
+ 0, 15 / 512f, 372 / 512f, 387 / 512f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + pageStrLen / 2 + 2, guiTop + 6, 15, 15,
+ 15 / 512f, 30 / 512f, 372 / 512f, 387 / 512f, GL11.GL_NEAREST);
}
//Settings Buttons
Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
GlStateManager.color(1, 1, 1, 1);
//On Settings Button
- Utils.drawTexturedRect(guiLeft+295, guiTop+147, 16, 16,
- 0, 16/512f, 387/512f, (387+16)/512f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft + 295, guiTop + 147, 16, 16,
+ 0, 16 / 512f, 387 / 512f, (387 + 16) / 512f, GL11.GL_NEAREST);
//Incompatible Settings Button
- float incompatibleMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.incompatibleEnchants*16/512f;
- Utils.drawTexturedRect(guiLeft+295+18, guiTop+147, 16, 16,
- incompatibleMinU, incompatibleMinU+16/512f, 403/512f, (403+16)/512f, GL11.GL_NEAREST);
+ float incompatibleMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.incompatibleEnchants * 16 / 512f;
+ Utils.drawTexturedRect(guiLeft + 295 + 18, guiTop + 147, 16, 16,
+ incompatibleMinU, incompatibleMinU + 16 / 512f, 403 / 512f, (403 + 16) / 512f, GL11.GL_NEAREST);
//Sorting Settings Button
- float sortingMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting*16/512f;
- Utils.drawTexturedRect(guiLeft+295, guiTop+147+18, 16, 16,
- sortingMinU, sortingMinU+16/512f, 419/512f, (419+16)/512f, GL11.GL_NEAREST);
+ float sortingMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting * 16 / 512f;
+ Utils.drawTexturedRect(guiLeft + 295, guiTop + 147 + 18, 16, 16,
+ sortingMinU, sortingMinU + 16 / 512f, 419 / 512f, (419 + 16) / 512f, GL11.GL_NEAREST);
//Ordering Settings Button
- float orderingMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering*16/512f;
- Utils.drawTexturedRect(guiLeft+295+18, guiTop+147+18, 16, 16,
- orderingMinU, orderingMinU+16/512f, 435/512f, (435+16)/512f, GL11.GL_NEAREST);
+ float orderingMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering * 16 / 512f;
+ Utils.drawTexturedRect(guiLeft + 295 + 18, guiTop + 147 + 18, 16, 16,
+ orderingMinU, orderingMinU + 16 / 512f, 435 / 512f, (435 + 16) / 512f, GL11.GL_NEAREST);
- if(mouseX >= guiLeft+294 && mouseX < guiLeft+294+36 &&
- mouseY >= guiTop+146 && mouseY < guiTop+146+36) {
- int index = (mouseX-(guiLeft+295))/18 + (mouseY-(guiTop+147))/18*2;
+ if (mouseX >= guiLeft + 294 && mouseX < guiLeft + 294 + 36 &&
+ mouseY >= guiTop + 146 && mouseY < guiTop + 146 + 36) {
+ int index = (mouseX - (guiLeft + 295)) / 18 + (mouseY - (guiTop + 147)) / 18 * 2;
switch (index) {
case 0:
- Gui.drawRect(guiLeft+295, guiTop+147, guiLeft+295+16, guiTop+147+16, 0x80ffffff);
+ Gui.drawRect(guiLeft + 295, guiTop + 147, guiLeft + 295 + 16, guiTop + 147 + 16, 0x80ffffff);
tooltipToDisplay = createTooltip("Enable GUI", 0, "On", "Off");
break;
case 1:
- Gui.drawRect(guiLeft+295+18, guiTop+147, guiLeft+295+16+18, guiTop+147+16, 0x80ffffff);
+ Gui.drawRect(guiLeft + 295 + 18, guiTop + 147, guiLeft + 295 + 16 + 18, guiTop + 147 + 16, 0x80ffffff);
tooltipToDisplay = createTooltip("Incompatible Enchants",
NotEnoughUpdates.INSTANCE.config.enchantingSolvers.incompatibleEnchants,
"Highlight", "Hide");
- tooltipToDisplay.add(1, EnumChatFormatting.GRAY+"How to display enchants that are");
- tooltipToDisplay.add(2, EnumChatFormatting.GRAY+"incompatible with your current item,");
- tooltipToDisplay.add(3, EnumChatFormatting.GRAY+"eg. Smite on a sword with Sharpness");
+ tooltipToDisplay.add(1, EnumChatFormatting.GRAY + "How to display enchants that are");
+ tooltipToDisplay.add(2, EnumChatFormatting.GRAY + "incompatible with your current item,");
+ tooltipToDisplay.add(3, EnumChatFormatting.GRAY + "eg. Smite on a sword with Sharpness");
break;
case 2:
- Gui.drawRect(guiLeft+295, guiTop+147+18, guiLeft+295+16, guiTop+147+16+18, 0x80ffffff);
+ Gui.drawRect(guiLeft + 295, guiTop + 147 + 18, guiLeft + 295 + 16, guiTop + 147 + 16 + 18, 0x80ffffff);
tooltipToDisplay = createTooltip("Sort enchants...",
NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting,
"By Cost", "Alphabetically");
break;
case 3:
- Gui.drawRect(guiLeft+295+18, guiTop+147+18, guiLeft+295+16+18, guiTop+147+16+18, 0x80ffffff);
+ Gui.drawRect(guiLeft + 295 + 18, guiTop + 147 + 18, guiLeft + 295 + 16 + 18, guiTop + 147 + 16 + 18, 0x80ffffff);
tooltipToDisplay = createTooltip("Order enchants...",
NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering,
"Ascending", "Descending");
@@ -633,215 +633,215 @@ public class GuiCustomEnchant extends Gui {
//Left scroll bar
{
int offset;
- if(applicable.size() <= 6) {
+ if (applicable.size() <= 6) {
offset = 0;
- } else if(isScrollingLeft && clickedScrollOffset >= 0) {
+ } else if (isScrollingLeft && clickedScrollOffset >= 0) {
offset = mouseY - clickedScrollOffset;
- if(offset < 0) offset = 0;
- if(offset > 96-15) offset = 96-15;
+ if (offset < 0) offset = 0;
+ if (offset > 96 - 15) offset = 96 - 15;
} else {
- offset = Math.round((96-15) * (leftScroll.getValue() / (float)((applicable.size()-6)*16)));
+ offset = Math.round((96 - 15) * (leftScroll.getValue() / (float) ((applicable.size() - 6) * 16)));
}
Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+104, guiTop+18+offset, 12, 15,
- 0, 12/512f, 313/512f, (313+15)/512f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft + 104, guiTop + 18 + offset, 12, 15,
+ 0, 12 / 512f, 313 / 512f, (313 + 15) / 512f, GL11.GL_NEAREST);
}
//Right scroll bar
{
int offset;
- if(removable.size() <= 6) {
+ if (removable.size() <= 6) {
offset = 0;
- } else if(!isScrollingLeft && clickedScrollOffset >= 0) {
+ } else if (!isScrollingLeft && clickedScrollOffset >= 0) {
offset = mouseY - clickedScrollOffset;
- if(offset < 0) offset = 0;
- if(offset > 96-15) offset = 96-15;
+ if (offset < 0) offset = 0;
+ if (offset > 96 - 15) offset = 96 - 15;
} else {
- offset = Math.round((96-15) * (rightScroll.getValue() / (float)((removable.size()-6)*16)));
+ offset = Math.round((96 - 15) * (rightScroll.getValue() / (float) ((removable.size() - 6) * 16)));
}
Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+344, guiTop+18+offset, 12, 15,
- 0, 12/512f, 313/512f, (313+15)/512f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft + 344, guiTop + 18 + offset, 12, 15,
+ 0, 12 / 512f, 313 / 512f, (313 + 15) / 512f, GL11.GL_NEAREST);
}
//Enchant book model
renderEnchantBook(scaledResolution, partialTicks);
//Can't be enchanted text
- if(currentState == EnchantState.INVALID_ITEM) {
+ if (currentState == EnchantState.INVALID_ITEM) {
GlStateManager.disableDepth();
Utils.drawStringCentered("This item can't", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2, guiTop+88, true, 0xffff5555);
+ guiLeft + X_SIZE / 2, guiTop + 88, true, 0xffff5555);
Utils.drawStringCentered("be enchanted", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2, guiTop+98, true, 0xffff5555);
+ guiLeft + X_SIZE / 2, guiTop + 98, true, 0xffff5555);
GlStateManager.enableDepth();
}
//Enchant arrow
- if(arrowAmount.getValue() > 0) {
+ if (arrowAmount.getValue() > 0) {
Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
GlStateManager.color(1, 1, 1, 1);
float w = 22 * arrowAmount.getValue();
- if(removingEnchantPlayerLevel < 0) {
- Utils.drawTexturedRect(guiLeft+134, guiTop+58, w, 16,
- 0, w/512f, 297/512f, (297+16)/512f, GL11.GL_NEAREST);
+ if (removingEnchantPlayerLevel < 0) {
+ Utils.drawTexturedRect(guiLeft + 134, guiTop + 58, w, 16,
+ 0, w / 512f, 297 / 512f, (297 + 16) / 512f, GL11.GL_NEAREST);
} else {
- Utils.drawTexturedRect(guiLeft+230-w, guiTop+58, w, 16,
- (44-w)/512f, 44/512f, 297/512f, (297+16)/512f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft + 230 - w, guiTop + 58, w, 16,
+ (44 - w) / 512f, 44 / 512f, 297 / 512f, (297 + 16) / 512f, GL11.GL_NEAREST);
}
}
//Text if no enchants appear
- if(currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
- if(applicable.isEmpty() && removable.isEmpty() && searchRemovedFromApplicable) {
+ if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
+ if (applicable.isEmpty() && removable.isEmpty() && searchRemovedFromApplicable) {
Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+28, true, 0xffff5555);
+ guiLeft + 8 + 48,