aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorBuildTools <james.jenour@protonmail.com>2021-06-06 23:35:32 +0800
committerBuildTools <james.jenour@protonmail.com>2021-06-06 23:35:32 +0800
commit48f309c1676626e0c8d0128220e50e51247c9abb (patch)
tree53cf633aacd4e297de7a3925825af4ed4a1b135f /src/main/java/io
parent87e44e6a9443b51016964a94254875cb9761a604 (diff)
downloadNotEnoughUpdates-48f309c1676626e0c8d0128220e50e51247c9abb.tar.gz
NotEnoughUpdates-48f309c1676626e0c8d0128220e50e51247c9abb.tar.bz2
NotEnoughUpdates-48f309c1676626e0c8d0128220e50e51247c9abb.zip
ironmoon
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java62
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java35
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java1258
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java295
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java62
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java31
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java16
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java56
18 files changed, 1697 insertions, 189 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
index 30f0f722..0c35c56c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -11,6 +11,7 @@ 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.MiscUtils;
+import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.cosmetics.CapeManager;
import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks;
import io.github.moulberry.notenoughupdates.dungeons.DungeonWin;
@@ -142,8 +143,8 @@ public class NEUEventListener {
NotEnoughUpdates.INSTANCE.saveConfig();
}
- private long notificationDisplayMillis = 0;
- private List<String> notificationLines = null;
+ private static long notificationDisplayMillis = 0;
+ private static List<String> notificationLines = null;
private static final Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$");
@@ -163,6 +164,15 @@ public class NEUEventListener {
private String loadedInvName = "";
public static boolean inventoryLoaded = false;
+ public static void displayNotification(List<String> lines, boolean showForever) {
+ if(showForever) {
+ notificationDisplayMillis = -420;
+ } else {
+ notificationDisplayMillis = System.currentTimeMillis();
+ }
+ notificationLines = lines;
+ }
+
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if(event.phase != TickEvent.Phase.START) return;
@@ -213,7 +223,8 @@ public class NEUEventListener {
if(neu.hasSkyblockScoreboard()) {
if(!preloadedItems) {
preloadedItems = true;
- for(JsonObject json : neu.manager.getItemInformation().values()) {
+ List<JsonObject> list = new ArrayList<>(neu.manager.getItemInformation().values());
+ for(JsonObject json : list) {
itemPreloader.submit(() -> {
ItemStack stack = neu.manager.jsonToStack(json, true, true);
if(stack.getItem() == Items.skull) toPreload.add(stack);
@@ -263,6 +274,7 @@ public class NEUEventListener {
ItemCustomizeManager.tick();
BackgroundBlur.markDirty();
NPCRetexturing.getInstance().tick();
+ StorageOverlay.getInstance().markDirty();
if(neu.hasSkyblockScoreboard()) {
for(TextOverlay overlay : OverlayManager.textOverlays) {
@@ -280,7 +292,10 @@ public class NEUEventListener {
DungeonBlocks.tick();
}
- neu.updateSkyblockScoreboard();
+ if(System.currentTimeMillis() - SBInfo.getInstance().joinedWorld > 500 &&
+ System.currentTimeMillis() - SBInfo.getInstance().unloadedWorld > 500) {
+ neu.updateSkyblockScoreboard();
+ }
CapeManager.getInstance().tick();
if(containerName != null) {
@@ -305,15 +320,15 @@ public class NEUEventListener {
if(neu.config.notifications.doRamNotif) {
long maxMemoryMB = Runtime.getRuntime().maxMemory()/1024L/1024L;
- if(maxMemoryMB > 4100) {
+ if(maxMemoryMB > 4100 || true) {
notificationDisplayMillis = System.currentTimeMillis();
notificationLines = new ArrayList<>();
- notificationLines.add(EnumChatFormatting.DARK_RED+"Too much memory allocated!");
+ notificationLines.add(EnumChatFormatting.GRAY+"Too much memory allocated!");
notificationLines.add(String.format(EnumChatFormatting.DARK_GRAY+"NEU has detected %03dMB of memory allocated to Minecraft!", maxMemoryMB));
- notificationLines.add(EnumChatFormatting.DARK_GRAY+"It is recommended to allocated between 2-4GB of memory");
- notificationLines.add(EnumChatFormatting.DARK_GRAY+"More than 4GB MAY cause FPS issues, EVEN if you have 16GB+ available");
+ notificationLines.add(EnumChatFormatting.GRAY+"It is recommended to allocated between 2-4GB of memory");
+ notificationLines.add(EnumChatFormatting.GRAY+"More than 4GB MAY cause FPS issues, EVEN if you have 16GB+ available");
notificationLines.add("");
- notificationLines.add(EnumChatFormatting.DARK_GRAY+"For more information, visit #ram-info in discord.gg/moulberry");
+ notificationLines.add(EnumChatFormatting.GRAY+"For more information, visit #ram-info in discord.gg/moulberry");
}
}
@@ -436,7 +451,6 @@ public class NEUEventListener {
@SubscribeEvent
public void onRenderGameOverlayPost(RenderGameOverlayEvent.Post event) {
- long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis);
if(neu.hasSkyblockScoreboard() && event.type == RenderGameOverlayEvent.ElementType.ALL) {
DungeonWin.render(event.partialTicks);
for(TextOverlay overlay : OverlayManager.textOverlays) {
@@ -447,8 +461,14 @@ public class NEUEventListener {
}
OverlayManager.dontRenderOverlay = null;
}
+
+ if(Keyboard.isKeyDown(Keyboard.KEY_X)) {
+ notificationDisplayMillis = 0;
+ }
+ long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis);
+ boolean display = timeRemaining > 0 || notificationDisplayMillis == -420;
if(event.type == RenderGameOverlayEvent.ElementType.ALL &&
- timeRemaining > 0 && notificationLines != null && notificationLines.size() > 0) {
+ display && notificationLines != null && notificationLines.size() > 0) {
int width = 0;
int height = notificationLines.size()*10+10;
@@ -463,13 +483,20 @@ public class NEUEventListener {
int midX = sr.getScaledWidth()/2;
int topY = sr.getScaledHeight()*3/4-height/2;
- Gui.drawRect(midX-width/2, sr.getScaledHeight()*3/4-height/2,
+ RenderUtils.drawFloatingRectDark(midX-width/2, sr.getScaledHeight()*3/4-height/2, width, height);
+ /*Gui.drawRect(midX-width/2, sr.getScaledHeight()*3/4-height/2,
midX+width/2, sr.getScaledHeight()*3/4+height/2, 0xFF3C3C3C);
Gui.drawRect(midX-width/2+2, sr.getScaledHeight()*3/4-height/2+2,
- midX+width/2-2, sr.getScaledHeight()*3/4+height/2-2, 0xFFC8C8C8);
+ midX+width/2-2, sr.getScaledHeight()*3/4+height/2-2, 0xFFC8C8C8);*/
+
+ int xLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth("[X] Close");
+ Minecraft.getMinecraft().fontRendererObj.drawString("[X] Close", midX+width/2f-3-xLen,
+ topY+3, 0xFFFF5555, false);
- Minecraft.getMinecraft().fontRendererObj.drawString((timeRemaining/1000)+"s", midX-width/2f+3,
- topY+3, 0xFF000000, false);
+ if(notificationDisplayMillis > 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString((timeRemaining/1000)+"s", midX-width/2f+3,
+ topY+3, 0xFFaaaaaa, false);
+ }
Utils.drawStringCentered(notificationLines.get(0), Minecraft.getMinecraft().fontRendererObj,
midX, topY+4+5, false, -1);
@@ -1255,6 +1282,11 @@ public class NEUEventListener {
*/
@SubscribeEvent(priority = EventPriority.LOW)
public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
+ if(Mouse.getEventButtonState() && StorageManager.getInstance().onAnyClick()) {
+ event.setCanceled(true);
+ return;
+ }
+
if(!event.isCanceled()) {
Utils.scrollTooltip(Mouse.getEventDWheel());
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index f0b3fc0e..181b9225 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -690,6 +690,8 @@ public class NEUManager {
internalname += ";3"; break;
case "LEGENDARY":
internalname += ";4"; break;
+ case "MYTHIC":
+ internalname += ";5"; break;
}
}
}
@@ -1304,6 +1306,8 @@ public class NEUManager {
tier = "EPIC"; break;
case "EPIC":
tier = "LEGENDARY"; break;
+ case "LEGENDARY":
+ tier = "MYTHIC"; break;
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 52e4b320..78bb6536 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -1,5 +1,6 @@
package io.github.moulberry.notenoughupdates;
+import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -221,6 +222,19 @@ public class NotEnoughUpdates {
}
});*/
+ SimpleCommand stWhyCommand = new SimpleCommand("neustwhy", new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ NEUEventListener.displayNotification(Lists.newArrayList(
+ "\u00a7eStorage Viewer",
+ "\u00a77Currently, the storage viewer requires you to click twice",
+ "\u00a77in order to switch between pages. This is because Hypixel",
+ "\u00a77has not yet added a shortcut command to go to any enderchest/",
+ "\u00a77storage page.",
+ "\u00a77While it is possible to send the second click",
+ "\u00a77automatically, doing so violates Hypixel's new mod rules."), true);
+ }
+ });
+
SimpleCommand gamemodesCommand = new SimpleCommand("neugamemodes", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
boolean upgradeOverride = args.length == 1 && args[0].equals("upgradeOverride");
@@ -1159,6 +1173,7 @@ public class NotEnoughUpdates {
ClientCommandHandler.instance.registerCommand(cosmeticsCommand);
ClientCommandHandler.instance.registerCommand(linksCommand);
ClientCommandHandler.instance.registerCommand(gamemodesCommand);
+ ClientCommandHandler.instance.registerCommand(stWhyCommand);
ClientCommandHandler.instance.registerCommand(buttonsCommand);
ClientCommandHandler.instance.registerCommand(resetRepoCommand);
ClientCommandHandler.instance.registerCommand(reloadRepoCommand);
@@ -1339,8 +1354,9 @@ public class NotEnoughUpdates {
}
}
}
+
+ hasSkyblockScoreboard = false;
}
- hasSkyblockScoreboard = false;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
index aded91e6..658ab2f2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
@@ -112,6 +112,9 @@ public class GuiElementTextField {
public void setFocus(boolean focus) {
this.focus = focus;
+ if(!focus) {
+ textField.setCursorPosition(textField.getCursorPosition());
+ }
}
public boolean getFocus() {
return focus;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
index 1a266ca8..e7f5c8e6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -183,7 +183,6 @@ public class PetInfoOverlay extends TextOverlay {
private static int getClosestPetIndex(String petType, int petId, String petItem, float petLevel) {
Pet pet = getClosestPet(petType, petId, petItem, petLevel);
if(pet == null) {
- System.out.println("null pet");
return -1;
} else {
return getIdForPet(pet);
@@ -914,10 +913,7 @@ public class PetInfoOverlay extends TextOverlay {
config.petMap.put(config.selectedPet, pet);
}
}
-
}
-
- System.out.println(mouseButtonClicked + ":" + mode);
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java
index 4054c4b2..3c53c735 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java
@@ -553,10 +553,14 @@ public class SlotLocking {
}
public LockedSlot getLockedSlotIndex(int index) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) return null;
+ if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
+ return null;
+ }
LockedSlot[] lockedSlots = getDataForProfile();
- if(lockedSlots == null) return null;
+ if(lockedSlots == null) {
+ return null;
+ }
return getLockedSlot(lockedSlots, index);
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
index 66fede9c..53607fae 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
@@ -6,6 +6,7 @@ import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerChest;
@@ -147,6 +148,7 @@ public class StorageManager {
public static class StoragePage {
public ItemStack[] items = new ItemStack[45];
public ItemStack backpackDisplayStack;
+ public String customTitle;
public int rows = -1;
public transient boolean matchesSearch;
@@ -314,7 +316,9 @@ public class StorageManager {
System.currentTimeMillis() - storageOpenSwitchMillis < 1000) return;
if(getCurrentPageId() == page) return;
- if(getCurrentWindowId() != -1 && onStorageMenu) {
+ if(page == 0) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/enderchest");
+ } else if(getCurrentWindowId() != -1 && onStorageMenu) {
if(page < 9) {
sendMouseClick(getCurrentWindowId(), 9+page);
} else {
@@ -324,13 +328,15 @@ public class StorageManager {
storageOpenSwitchMillis = System.currentTimeMillis();
desiredStoragePage = page;
- NotEnoughUpdates.INSTANCE.sendChatMessage("/storage");
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/storage " + (desiredStoragePage-8));
}
}
private void sendMouseClick(int windowId, int slotIndex) {
- Minecraft.getMinecraft().playerController.windowClick(windowId, slotIndex, 0, 0,
- Minecraft.getMinecraft().thePlayer);
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short short1 = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack itemstack = playerIn.openContainer.getSlot(slotIndex).getStack();
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(windowId, slotIndex, 0, 0, itemstack, short1));
}
public int getDisplayIdForStorageId(int storageId) {
@@ -343,6 +349,19 @@ public class StorageManager {
return -1;
}
+ public boolean onAnyClick() {
+ if(onStorageMenu && desiredStoragePage >= 0) {
+ if(desiredStoragePage < 9) {
+ sendMouseClick(getCurrentWindowId(), 9+desiredStoragePage);
+ } else {
+ sendMouseClick(getCurrentWindowId(), 27+desiredStoragePage-MAX_ENDER_CHEST_PAGES);
+ }
+ desiredStoragePage = -1;
+ return true;
+ }
+ return false;
+ }
+
public void openWindowPacket(S2DPacketOpenWindow packet) {
shouldRenderStorageOverlayCached = false;
if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
@@ -357,14 +376,6 @@ public class StorageManager {
if(windowTitle.trim().equals("Storage")) {
onStorageMenu = true;
-
- if(desiredStoragePage >= 0 && System.currentTimeMillis() - storageOpenSwitchMillis < 1000) {
- if(desiredStoragePage < 9) {
- sendMouseClick(getCurrentWindowId(), 9+desiredStoragePage);
- } else {
- sendMouseClick(getCurrentWindowId(), 27+desiredStoragePage-MAX_ENDER_CHEST_PAGES);
- }
- }
} else if(matcher.matches()) {
int page = Integer.parseInt(matcher.group(1));
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
index 760b7bab..6d0873ed 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
@@ -355,6 +355,7 @@ public class AccessoryBagOverlay {
missingInternal.sort(getItemComparator());
+ Set<String> missingDisplayNames = new HashSet<>();
for(String internal : missingInternal) {
boolean hasDup = false;
@@ -370,6 +371,10 @@ public class AccessoryBagOverlay {
}
ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internal), false);
+
+ if(missingDisplayNames.contains(stack.getDisplayName())) continue;
+ missingDisplayNames.add(stack.getDisplayName());
+
if(hasDup) {
stack.setStackDisplayName(stack.getDisplayName()+"*");
}
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 2fe42cc9..f3cb2ed9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
@@ -1,9 +1,19 @@
package io.github.moulberry.notenoughupdates.miscgui;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.GlScissorStack;
+import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
+import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingFloat;
+import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -17,15 +27,20 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.play.client.C0EPacketClickWindow;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
+import org.apache.commons.lang3.text.WordUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Project;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import java.io.PrintStream;
import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class GuiCustomEnchant extends Gui {
@@ -34,24 +49,98 @@ public class GuiCustomEnchant extends Gui {
private static final ResourceLocation ENCHANTMENT_TABLE_BOOK_TEXTURE = new ResourceLocation("textures/entity/enchanting_table_book.png");
private static final ModelBook MODEL_BOOK = new ModelBook();
+ private static final int EXPERIENCE_ORB_COUNT = 30;
+
+ private static final Pattern XP_COST_PATTERN = Pattern.compile("\\u00a73(\\d+) Exp Levels");
+
private enum EnchantState {
NO_ITEM,
+ ADDING_ENCHANT,
+ SWITCHING_DONT_UPDATE,
INVALID_ITEM,
HAS_ITEM
}
- private static class Enchantment {
+ private class Enchantment {
public int slotIndex;
public String enchantName;
- public int xpCost = 30;
-
- public Enchantment(int slotIndex, String enchantName, int xpCost) {
+ public String enchId;
+ public List<String> displayLore;
+ public int level;
+ public int xpCost = -1;
+ public boolean overMaxLevel = false;
+ public boolean conflicts = false;
+
+ public Enchantment(int slotIndex, String enchantName, String enchId, List<String> displayLore, int level,
+ boolean useMaxLevelForCost, boolean checkConflicts) {
this.slotIndex = slotIndex;
this.enchantName = enchantName;
- this.xpCost = xpCost;
+ this.enchId = enchId;
+ this.displayLore = displayLore;
+ this.level = level;
+
+ 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++) {
+ JsonArray pool = pools.get(i).getAsJsonArray();
+
+ boolean hasThis = false;
+ boolean hasApplied = false;
+
+ for(int j=0; j<pool.size(); j++) {
+ String enchIdPoolElement = pool.get(j).getAsString();
+ if(enchId.equalsIgnoreCase(enchIdPoolElement)) {
+ hasThis = true;
+ } else if(playerEnchantIds.containsKey(enchIdPoolElement)) {
+ hasApplied = true;
+ }
+ if(hasThis && hasApplied) {
+ this.conflicts = true;
+ break out;
+ }
+ }
+ }
+ }
+
+ if(level >= 1 && Constants.ENCHANTS.has("enchants_xp_cost")) {
+ JsonObject allCosts = Constants.ENCHANTS.getAsJsonObject("enchants_xp_cost");
+ 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();
+ } else {
+ overMaxLevel = true;
+ }
+ }
+ }
+
+ }
+ }
}
}
+ public static class ExperienceOrb {
+ public float x;
+ public float y;
+ public float xLast;
+ public float yLast;
+ public float xVel;
+ public float yVel;
+
+ public int type;
+ public int rotationDeg;
+ }
+
+ private List<ExperienceOrb> orbs = new ArrayList<>();
+ private int orbTargetX = 0;
+ private int orbTargetY = 0;
+
private int guiLeft;
private int guiTop;
private boolean shouldOverrideFast = false;
@@ -63,17 +152,48 @@ public class GuiCustomEnchant extends Gui {
public float bookOpen;
public float bookOpenLast;
- private static List<Enchantment> applicable = new ArrayList<>();
- private static List<Enchantment> removable = new ArrayList<>();
+ private int currentPage;
+ private int expectedMaxPage;
+
+ private boolean isScrollingLeft = true;
+
+ private ItemStack enchantingItem = null;
+
+ private int removingEnchantPlayerLevel = -1;
+
+ private GuiElementTextField searchField = new GuiElementTextField("", GuiElementTextField.SCISSOR_TEXT);
+
+ private 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 HashMap<Integer, Enchantment> enchanterEnchLevels = new HashMap<>();
+ private Enchantment enchanterCurrentEnch = null;
public Random random = new Random();
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 LerpingFloat arrowAmount = new LerpingFloat(0, 100);
+