aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorefefury <69400149+efefury@users.noreply.github.com>2022-09-11 09:31:27 +0000
committerGitHub <noreply@github.com>2022-09-11 11:31:27 +0200
commit47af0b3eee70a5c8d7c86fff19155a97a9204708 (patch)
treed0716683e3dc534ff75e71208650aa3a647ea766 /src
parentd203640d5296bde151596388aa6df332393d0a1c (diff)
downloadNotEnoughUpdates-47af0b3eee70a5c8d7c86fff19155a97a9204708.tar.gz
NotEnoughUpdates-47af0b3eee70a5c8d7c86fff19155a97a9204708.tar.bz2
NotEnoughUpdates-47af0b3eee70a5c8d7c86fff19155a97a9204708.zip
cleaned up neu overlay (#241)
* made equipment overlay own class lmk if there's any bugs * fix infer (i think) * fuck infer * First refactoringering * Fix more stuff * itemlisting * NEU 3.0 release notes * fixed nea bug https://imgur.com/a/Sg3iw74 * whitespace * fixed equipment overlay not working ? and caching * nopoing idk what im doing * FHJNX GHD trwsmokürtsew tze jiozterdgjjiüzetr jipztr * Revert "FHJNX GHD" This reverts commit 24eceba3db5e500be296f5a96412bd8b95647a22. * Revert "nopoing" This reverts commit bee07cb98f8b9672c2e1bc192c6c3e5ae8b02b95. * Revert "fixed equipment overlay" This reverts commit b15376f934a738900e2dd98efdb0d4a7ec131dfa. * idk i think this works maybe * ??? ????????? * no more black lines * equipment cache * Fix lag with optifine and removal of unused field. Removed onMouseClick as it was triggered more than once per tick when optifine is installed. Removed tooltipsToDisplay field (as it was replaced by a local variable). * this should be true by default to keep old behaviour * itemList now doesn't close when clicking the searchbar itemList will now only close when searchMode is triggered. * Infer moment hoping this doesn't trigger it. Co-authored-by: nea <romangraef@gmail.com> Co-authored-by: Lulonaut <lulonaut@tutanota.de> Co-authored-by: Ascynx <78341107+Ascynx@users.noreply.github.com> Co-authored-by: nopo <noahogno@gmail.com> Co-authored-by: Ascynx <miaoum2128@gmail.com> Co-authored-by: Roman / Linnea Gräf <roman.graef@gmail.com> Co-authored-by: Lorenz <lo.scherf@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java440
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/events/GuiInventoryBackgroundDrawnEvent.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java13
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java36
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java431
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java7
9 files changed, 542 insertions, 451 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 18be69e6..308bd63e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -23,7 +23,6 @@ import com.google.common.collect.Lists;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper;
@@ -37,7 +36,6 @@ import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupAligned;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating;
import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers;
-import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu;
import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph;
import io.github.moulberry.notenoughupdates.miscgui.NeuSearchCalculator;
@@ -46,17 +44,13 @@ import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.GuiTextures;
import io.github.moulberry.notenoughupdates.util.LerpingFloat;
import io.github.moulberry.notenoughupdates.util.NotificationHandler;
-import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
-import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiContainer;
-import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
@@ -72,8 +66,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Items;
-import net.minecraft.inventory.ContainerChest;
-import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -101,7 +93,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
@@ -120,48 +111,6 @@ 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 static final ResourceLocation ARMOR_DISPLAY = new ResourceLocation(
- "notenoughupdates:armordisplay/armordisplay.png");
- private static final ResourceLocation ARMOR_DISPLAY_GREY = new ResourceLocation(
- "notenoughupdates:armordisplay/armordisplay_grey.png");
- private static final ResourceLocation ARMOR_DISPLAY_DARK = new ResourceLocation(
- "notenoughupdates:armordisplay/armordisplay_phq_dark.png");
- private static final ResourceLocation ARMOR_DISPLAY_FSR = new ResourceLocation(
- "notenoughupdates:armordisplay/armordisplay_fsr.png");
- private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT = new ResourceLocation(
- "notenoughupdates:armordisplay/armordisplay_transparent.png");
- private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT_PET = new ResourceLocation(
- "notenoughupdates:armordisplay/armordisplay_transparent_pet.png");
-
- private static final ResourceLocation QUESTION_MARK = new ResourceLocation("notenoughupdates:pv_unknown.png");
-
- private static final ResourceLocation PET_DISPLAY = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplaysolo.png");
- private static final ResourceLocation PET_DISPLAY_GREY = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplaysolo_dark.png");
- private static final ResourceLocation PET_DISPLAY_DARK = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplaysolo_phqdark.png");
- private static final ResourceLocation PET_DISPLAY_FSR = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplaysolo_fsr.png");
- private static final ResourceLocation PET_DISPLAY_TRANSPARENT = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplaysolo_transparent.png");
-
- private static final ResourceLocation PET_ARMOR_DISPLAY = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplayarmor.png");
- private static final ResourceLocation PET_ARMOR_DISPLAY_GREY = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplayarmor_dark.png");
- private static final ResourceLocation PET_ARMOR_DISPLAY_DARK = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplayarmor_phqdark.png");
- private static final ResourceLocation PET_ARMOR_DISPLAY_FSR = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplayarmor_fsr.png");
- private static final ResourceLocation PET_ARMOR_DISPLAY_TRANSPARENT = new ResourceLocation(
- "notenoughupdates:petdisplay/petdisplayarmor_transparent.png");
-
- private static boolean renderingArmorHud;
- private static boolean renderingPetHud;
- public static boolean shouldUseCachedPet;
- public static long cachedPetTimer;
-
private final NEUManager manager;
private final String mobRegex = ".*?((_MONSTER)|(_NPC)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
@@ -217,6 +166,7 @@ public class NEUOverlay extends Gui {
private List<JsonObject> selectedItemGroup = null;
private boolean itemPaneOpen = false;
+ private long itemPaneShouldOpen = -1;
private int page = 0;
@@ -292,12 +242,14 @@ public class NEUOverlay extends Gui {
}
if (Mouse.getEventButtonState()) {
setSearchBarFocus(true);
+
if (Mouse.getEventButton() == 1) { //Right mouse button down
textField.setText("");
updateSearch();
} else {
if (System.currentTimeMillis() - millisLastLeftClick < 300) {
searchMode = !searchMode;
+ itemPaneShouldOpen = -1;
lastSearchMode = System.currentTimeMillis();
if (searchMode && NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus) {
NotificationHandler.displayNotification(Lists.newArrayList(
@@ -1836,85 +1788,6 @@ public class NEUOverlay extends Gui {
int guiScaleLast = 0;
private boolean showVanillaLast = false;
-
- private boolean wardrobeOpen = false;
-
- private boolean isInNamedGui(String guiName) {
- GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
- if (guiScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
- String containerName = lower.getDisplayName().getUnformattedText();
- wardrobeOpen = containerName.contains(guiName);
- }
- if (guiScreen instanceof GuiInventory) {
- wardrobeOpen = false;
- }
- return wardrobeOpen;
- }
-
- private ItemStack getChestSlotsAsItemStack(int slot) {
- GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
- if (guiScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- return chest.inventorySlots.getSlot(slot).getStack();
- } else {
- return null;
- }
- }
-
- public ItemStack slot1 = null;
- public ItemStack slot2 = null;
- public ItemStack slot3 = null;
- public ItemStack slot4 = null;
- public ItemStack petSlot = null;
- private String lastProfile;
-
- private ItemStack getWardrobeSlot(int armourSlot) {
- if (SBInfo.getInstance().currentProfile == null) {
- return null;
- }
-
- if (!Objects.equals(SBInfo.getInstance().currentProfile, lastProfile)) {
- lastProfile = SBInfo.getInstance().currentProfile;
- slot1 = null;
- slot2 = null;
- slot3 = null;
- slot4 = null;
- petSlot = null;
- }
-
- if (isInNamedGui("Your Equipment")) {
- ItemStack itemStack = getChestSlotsAsItemStack(armourSlot);
- if (itemStack != null) {
- JsonObject itemToSave = NotEnoughUpdates.INSTANCE.manager.getJsonForItem(itemStack);
- if (!itemToSave.has("internalname")) {
- //would crash without internalName when trying to construct the ItemStack again
- itemToSave.add("internalname", new JsonPrimitive("_"));
- }
- NotEnoughUpdates.INSTANCE.config.getProfileSpecific().savedEquipment.put(armourSlot, itemToSave);
- return itemStack;
- }
- } else {
- if (NotEnoughUpdates.INSTANCE.config.getProfileSpecific().savedEquipment.containsKey(armourSlot)) {
- //don't use cache since the internalName is identical in most cases
- return NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.config.getProfileSpecific().savedEquipment
- .get(armourSlot)
- .getAsJsonObject(), false);
- }
- }
- return null;
- }
-
- public static boolean isRenderingArmorHud() {
- return renderingArmorHud;
- }
-
- public static boolean isRenderingPetHud() {
- return renderingPetHud;
- }
-
/**
* Renders the search bar, quick commands, item selection (right), item info (left) and armor hud gui elements.
*/
@@ -1922,8 +1795,6 @@ public class NEUOverlay extends Gui {
if (disabled) {
return;
}
- renderingArmorHud = false;
- renderingPetHud = false;
GlStateManager.enableDepth();
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
@@ -1984,6 +1855,13 @@ public class NEUOverlay extends Gui {
(int) (fgFavourite2.getBlue() * 0.8f), fgFavourite2.getAlpha()
);
+ if (!NotEnoughUpdates.INSTANCE.config.itemlist.openWhenSearching && searchMode) {
+ itemPaneOpen = false;
+ }
+ if (itemPaneShouldOpen != -1 && System.currentTimeMillis() > itemPaneShouldOpen) {
+ itemPaneOpen = true;
+ itemPaneShouldOpen = -1;
+ }
if (itemPaneOpen) {
if (itemPaneTabOffset.getValue() == 0) {
if (itemPaneOffsetFactor.getTarget() != 2 / 3f) {
@@ -2321,7 +2199,6 @@ public class NEUOverlay extends Gui {
GlStateManager.enableAlpha();
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.disableLighting();
- renderInfoHuds();
Utils.pushGuiScale(-1);
if (System.currentTimeMillis() - lastSearchMode > 120000 &&
@@ -2331,303 +2208,6 @@ public class NEUOverlay extends Gui {
}
}
- void renderInfoHuds() {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- Utils.resetGuiScale();
- Utils.pushGuiScale(Minecraft.getMinecraft().gameSettings.guiScale);
-
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
- GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
-
- if (NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud &&
- NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect
- && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- if (getWardrobeSlot(10) != null) {
- slot1 = getWardrobeSlot(10);
- slot2 = getWardrobeSlot(19);
- slot3 = getWardrobeSlot(28);
- slot4 = getWardrobeSlot(37);
- }
- if (guiScreen instanceof GuiInventory) {
- renderingArmorHud = true;
-
- List<String> tooltipToDisplay = null;
- if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 0) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY);
- }
- if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 1) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_GREY);
- }
- if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 2) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_DARK);
- }
- if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 3) {
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 3 &&
- NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay && petSlot != null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_TRANSPARENT_PET);
- } else {
- Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_TRANSPARENT);
- }
- }
- if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 4) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_FSR);
- }
-
- GlStateManager.color(1, 1, 1, 1);
- GL11.glTranslatef(0, 0, 401);
- float yNumber = (float) (height - 167) / 2f;
- Utils.drawTexturedRect((float) ((width - 224.1) / 2f), yNumber, 31, 86, GL11.GL_NEAREST);
- GlStateManager.bindTexture(0);
-
- Utils.drawItemStack(slot1, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105), true);
- Utils.drawItemStack(slot2, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105) + 18, true);
- Utils.drawItemStack(slot3, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105) + 36, true);
- Utils.drawItemStack(slot4, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105) + 54, true);
- if (slot1 == null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(QUESTION_MARK);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(((width - 208) / 2f), ((height + 60) / 2f - 105), 16, 16, GL11.GL_NEAREST);
- GlStateManager.bindTexture(0);
-
- tooltipToDisplay = Lists.newArrayList(
- EnumChatFormatting.RED + "Warning",
- EnumChatFormatting.GREEN + "You need to open /equipment",
- EnumChatFormatting.GREEN + "To cache your armour"
- );
- if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) {
- if (mouseY >= ((height + 60) / 2f - 105) && mouseY <= ((height + 60) / 2f - 105) + 70 &&
- NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand) {
- if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
- if (Mouse.getEventButtonState()) {
- if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/equipment") ==
- 0) {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/equipment");
- }
- }
- }
- }
- if (mouseY >= ((height + 60) / 2f - 105) && mouseY <= ((height + 60) / 2f - 105) + 16) {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
- }
- }
- GL11.glTranslatef(0, 0, -401);
- }
- if (slot1 != null && slot2 != null && slot3 != null && slot4 != null) {
- if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) {
- if (mouseY >= ((height + 60) / 2f - 105) && mouseY <= ((height + 60) / 2f - 105) + 70 &&
- NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand) {
- if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
- if (Mouse.getEventButtonState()) {
- if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/equipment") ==
- 0) {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/equipment");
- }
- }
- }
- }
-
- if (mouseY >= ((height + 60) / 2f - 105) && mouseY <= ((height + 60) / 2f - 105) + 16) {
- tooltipToDisplay = slot1.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- if (shouldShowEquipmentTooltip(tooltipToDisplay)) {
- Utils.drawHoveringText(
- tooltipToDisplay,
- mouseX - calculateTooltipXOffset(tooltipToDisplay, fr),
- mouseY,
- width,
- height,
- -1,
- fr
- );
- }
- }
- if (mouseY >= ((height + 60) / 2f - 105) + 18 && mouseY <= ((height + 60) / 2f - 105) + 34) {
- tooltipToDisplay = slot2.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- if (shouldShowEquipmentTooltip(tooltipToDisplay)) {
- Utils.drawHoveringText(
- tooltipToDisplay,
- mouseX - calculateTooltipXOffset(tooltipToDisplay, fr),
- mouseY,
- width,
- height,
- -1,
- fr
- );
- }
- }
- if (mouseY >= ((height + 60) / 2f - 105) + 36 && mouseY <= ((height + 60) / 2f - 105) + 52) {
- tooltipToDisplay = slot3.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- if (shouldShowEquipmentTooltip(tooltipToDisplay)) {
- Utils.drawHoveringText(
- tooltipToDisplay,
- mouseX - calculateTooltipXOffset(tooltipToDisplay, fr),
- mouseY,
- width,
- height,
- -1,
- fr
- );
- }
- }
- if (mouseY >= ((height + 60) / 2f - 105) + 54 && mouseY <= ((height + 60) / 2f - 105) + 70) {
- tooltipToDisplay = slot4.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- if (shouldShowEquipmentTooltip(tooltipToDisplay)) {
- Utils.drawHoveringText(
- tooltipToDisplay,
- mouseX - calculateTooltipXOffset(tooltipToDisplay, fr),
- mouseY,
- width,
- height,
- -1,
- fr
- );
- }
- }
- }
- GL11.glTranslatef(0, 0, -401);
- }
- }
- }
- if (PetInfoOverlay.getCurrentPet() != null) {
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay
- && (NotEnoughUpdates.INSTANCE.manager
- .jsonToStack(NotEnoughUpdates.INSTANCE.manager
- .getItemInformation()
- .get(PetInfoOverlay.getCurrentPet().petType + ";" + PetInfoOverlay.getCurrentPet().rarity.petId))
- .hasDisplayName()
- || NotEnoughUpdates.INSTANCE.manager
- .jsonToStack(NotEnoughUpdates.INSTANCE.manager
- .getItemInformation()
- .get(PetInfoOverlay.getCurrentPet().petType + ";" + (PetInfoOverlay.getCurrentPet().rarity.petId - 1)))
- .hasDisplayName())
- && NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect &&
- NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- if (!NotEnoughUpdates.INSTANCE.manager
- .jsonToStack(
- NotEnoughUpdates.INSTANCE.manager
- .getItemInformation()
- .get(PetInfoOverlay.getCurrentPet().petType + ";" + PetInfoOverlay.getCurrentPet().rarity.petId))
- .hasDisplayName()) {
- petSlot = NotEnoughUpdates.INSTANCE.manager.jsonToStack(
- NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(
- PetInfoOverlay.getCurrentPet().petType + ";" + (PetInfoOverlay.getCurrentPet().rarity.petId - 1)));
- } else {
- petSlot = NotEnoughUpdates.INSTANCE.manager.jsonToStack(
- NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(
- PetInfoOverlay.getCurrentPet().petType + ";" + PetInfoOverlay.getCurrentPet().rarity.petId));
- }
- if (petSlot == null) {
- return;
- }
- petSlot.getTagCompound().setBoolean(
- "NEUHIDEPETTOOLTIP",
- NotEnoughUpdates.INSTANCE.config.petOverlay.hidePetTooltip
- );
- ItemStack petInfo = petSlot;
-
- if (guiScreen instanceof GuiInventory) {
- GL11.glTranslatef(0, 0, 401);
- if (!NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud) {
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 0) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY);
- }
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 1) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY_GREY);
- }
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 2) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY_DARK);
- }
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 3) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY_TRANSPARENT);
- }
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 4) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY_FSR);
- }
- } else {
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 0) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY);
- }
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 1) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY_GREY);
- }
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 2) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY_DARK);
- }
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 3) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY_TRANSPARENT);
- }
- if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 4) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY_FSR);
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- float yNumber = (float) (height - 23) / 2f;
- Utils.drawTexturedRect((float) ((width - 224.1) / 2f), yNumber, 31, 32, GL11.GL_NEAREST);
- GlStateManager.bindTexture(0);
-
- Utils.drawItemStack(petInfo, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105) + 72, true);
- renderingPetHud = true;
-
- List<String> tooltipToDisplay = null;
- if (petInfo != null) {
- if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) {
- if (mouseY >= ((height + 60) / 2f - 105) + 72 && mouseY <= ((height + 60) / 2f - 105) + 88 &&
- NotEnoughUpdates.INSTANCE.config.petOverlay.sendPetsCommand) {
- if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
- if (Mouse.getEventButtonState()) {
- if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/pets") ==
- 0) {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/pets");
- }
- }
- }
- tooltipToDisplay = petInfo.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- Utils.drawHoveringText(
- tooltipToDisplay,
- mouseX - calculateTooltipXOffset(tooltipToDisplay, fr),
- mouseY,
- width,
- height,
- -1,
- fr
- );
- GL11.glTranslatef(0, 0, -80);
- }
- }
-
- }
- }
- }
- }
- }
-
- /**
- * Calculates the width of the longest String in the tooltip, which can be used to offset the entire tooltip to the left more precisely
- *
- * @param tooltipToDisplay tooltip
- * @param fr FontRenderer object
- * @return offset to apply
- */
- private int calculateTooltipXOffset(List<String> tooltipToDisplay, FontRenderer fr) {
- int offset = 0;
- if (tooltipToDisplay != null) {
- for (String line : tooltipToDisplay) {
- int lineWidth = fr.getStringWidth(line);
- if (lineWidth > offset) {
- offset = lineWidth;
- }
- }
- }
- return offset + 20;
- }
-
- private boolean shouldShowEquipmentTooltip(List<String> toolTip) {
- return !toolTip.get(0).equals("§o§7Empty Equipment Slot§r");
- }
/**
* Used in SettingsInfoPane to redraw the items when a setting changes.
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 6732336c..c4b1bd77 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -66,6 +66,7 @@ import io.github.moulberry.notenoughupdates.miscgui.SignCalculator;
import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay;
import io.github.moulberry.notenoughupdates.mixins.AccessorMinecraft;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
+import io.github.moulberry.notenoughupdates.overlays.EquipmentOverlay;
import io.github.moulberry.notenoughupdates.overlays.FuelBar;
import io.github.moulberry.notenoughupdates.overlays.OverlayManager;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
@@ -89,6 +90,7 @@ import net.minecraft.world.biome.BiomeGenHell;
import net.minecraft.world.biome.BiomeGenJungle;
import net.minecraft.world.biome.BiomeGenMesa;
import net.minecraft.world.biome.BiomeGenSnow;
+import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry;
@@ -243,7 +245,6 @@ public class NotEnoughUpdates {
config.apiKey = null;
}
-
//add the trophy fishing tab to the config
if (config.profileViewer.pageLayout.size() == 8) {
config.profileViewer.pageLayout.add(8);
@@ -282,6 +283,7 @@ public class NotEnoughUpdates {
MinecraftForge.EVENT_BUS.register(FishingHelper.getInstance());
MinecraftForge.EVENT_BUS.register(CrystalWishingCompassSolver.getInstance());
MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures());
+ MinecraftForge.EVENT_BUS.register(EquipmentOverlay.INSTANCE);
MinecraftForge.EVENT_BUS.register(CustomBiomes.INSTANCE);
MinecraftForge.EVENT_BUS.register(new ChatListener(this));
MinecraftForge.EVENT_BUS.register(new ItemTooltipListener(this));
@@ -380,6 +382,12 @@ public class NotEnoughUpdates {
}
}
+ public void trySendCommand(String message) {
+ if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, message) == 0) {
+ sendChatMessage(message);
+ }
+ }
+
public void displayLinks(JsonObject update, int totalWidth) {
String discord_link = update.get("discord_link").getAsString();
String youtube_link = update.get("youtube_link").getAsString();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/events/GuiInventoryBackgroundDrawnEvent.java b/src/main/java/io/github/moulberry/notenoughupdates/events/GuiInventoryBackgroundDrawnEvent.java
new file mode 100644
index 00000000..0b8bf126
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/events/GuiInventoryBackgroundDrawnEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2022 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.events;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+public class GuiInventoryBackgroundDrawnEvent extends NEUEvent {
+ private final GuiContainer container;
+ private final float partialTicks;
+
+ public GuiInventoryBackgroundDrawnEvent(GuiContainer container, float partialTicks) {
+ this.container = container;
+ this.partialTicks = partialTicks;
+ }
+
+ public GuiContainer getContainer() {
+ return container;
+ }
+
+ public float getPartialTicks() {
+ return partialTicks;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
index 166e46d0..d4df7bfd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java
@@ -53,6 +53,7 @@ import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay;
import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay;
+import io.github.moulberry.notenoughupdates.overlays.EquipmentOverlay;
import io.github.moulberry.notenoughupdates.overlays.BazaarSearchOverlay;
import io.github.moulberry.notenoughupdates.overlays.OverlayManager;
import io.github.moulberry.notenoughupdates.overlays.RancherBootOverlay;
@@ -534,12 +535,12 @@ public class RenderListener {
x -= 68 - 200;
}
}
- if (NEUOverlay.isRenderingArmorHud()) {
+ if (EquipmentOverlay.isRenderingArmorHud()) {
if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) {
x -= 25;
}
}
- if (NEUOverlay.isRenderingPetHud()) {
+ if (EquipmentOverlay.isRenderingPetHud()) {
if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) {
x -= 25;
}
@@ -661,12 +662,12 @@ public class RenderListener {
x -= 68 - 200;
}
}
- if (NEUOverlay.isRenderingArmorHud()) {
+ if (EquipmentOverlay.isRenderingArmorHud()) {
if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) {
x -= 25;
}
}
- if (NEUOverlay.isRenderingPetHud()) {
+ if (EquipmentOverlay.isRenderingPetHud()) {
if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) {
x -= 25;
}
@@ -1126,12 +1127,12 @@ public class RenderListener {
x -= 68 - 200;
}
}
- if (NEUOverlay.isRenderingArmorHud()) {
+ if (EquipmentOverlay.isRenderingArmorHud()) {
if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) {
x -= 25;
}
}
- if (NEUOverlay.isRenderingPetHud()) {
+ if (EquipmentOverlay.isRenderingPetHud()) {
if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) {
x -= 25;
}
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 90300bbc..f58ced51 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -26,13 +26,13 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import io.github.moulberry.notenoughupdates.NEUOverlay;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.Position;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
import io.github.moulberry.notenoughupdates.listener.RenderListener;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
+import io.github.moulberry.notenoughupdates.overlays.EquipmentOverlay;
import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
@@ -134,6 +134,12 @@ public class PetInfoOverlay extends TextOverlay {
public String petXpType;
public String petItem;
public String skin;
+
+ public String getPetId(boolean withoutBoost) {
+ return petType + ";" + (withoutBoost ? rarity.petId - 1 : rarity.petId);
+
+ }
+
}
public static class PetConfig {
@@ -243,7 +249,8 @@ public class PetInfoOverlay extends TextOverlay {
}
private static Pet getClosestPet(String petType, int petId, String petItem, float petLevel) {
- Set<Pet> pets = config.petMap.values().stream().filter(pet -> pet.petType.equals(petType) && pet.rarity.petId == petId).collect(
+ Set<Pet> pets = config.petMap.values().stream().filter(pet -> pet.petType.equals(petType) &&
+ pet.rarity.petId == petId).collect(
Collectors.toSet());
if (pets.isEmpty()) {
@@ -254,7 +261,10 @@ public class PetInfoOverlay extends TextOverlay {
return pets.iterator().next();
}
- Set<Pet> itemMatches = pets.stream().filter(pet -> Objects.equals(petItem, pet.petItem)).collect(Collectors.toSet());
+ Set<Pet> itemMatches = pets
+ .stream()
+ .filter(pet -> Objects.equals(petItem, pet.petItem))
+ .collect(Collectors.toSet());
if (itemMatches.size() == 1) {
return itemMatches.iterator().next();
@@ -452,11 +462,12 @@ public class PetInfoOverlay extends TextOverlay {
}
}
- if (currentPet.petLevel.level < (currentPet.petLevel.maxLevel - 1) || !NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText.contains(6)) {
+ if (currentPet.petLevel.level < (currentPet.petLevel.maxLevel - 1) ||
+ !NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText.contains(6)) {
float remainingMax = currentPet.petLevel.maxXP - currentPet.petLevel.totalXp;
if (remaining > 0) {
if (xpGain < 1000) {
- etaMaxStr = EnumChatFormatting.AQUA + "Until L" + currentPet.petLevel.maxLevel + ": " +
+ etaMaxStr = EnumChatFormatting.AQUA + "Until L" + currentPet.petLevel.maxLevel + ": " +
EnumChatFormatting.YELLOW + "N/A";
} else {
etaMaxStr = EnumChatFormatting.AQUA + "Until L" + currentPet.petLevel.maxLevel + ": " +
@@ -563,7 +574,7 @@ public class PetInfoOverlay extends TextOverlay {
JsonObject petInfo = new JsonParser().parse(ea.getString("petInfo")).getAsJsonObject();
petType = petInfo.get("type").getAsString();
rarity = Rarity.valueOf(petInfo.get("tier").getAsString());
- level = GuiProfileViewer. getPetLevel(
+ level = GuiProfileViewer.getPetLevel(
petType,
rarity.name(),
Utils.getElementAsFloat(petInfo.get("exp"), 0) // Should only default if from item list and repo missing exp:0
@@ -782,7 +793,8 @@ public class PetInfoOverlay extends TextOverlay {
if (currentPet.rarity.petId == 5) {
mythicRarity = 4;
}
- JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet.skin != null ? currentPet.skin : (currentPet.petType + ";" + mythicRarity));
+ JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(
+ currentPet.skin != null ? currentPet.skin : (currentPet.petType + ";" + mythicRarity));
if (petItem != null) {
Vector2f position = getPosition(overlayWidth, overlayHeight);
int x = (int) position.x;
@@ -799,7 +811,8 @@ public class PetInfoOverlay extends TextOverlay {
Pet currentPet2 = getCurrentPet2();
if (currentPet2 != null) {
- JsonObject petItem2 = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet2.skin != null ? currentPet2.skin : (currentPet2.petType + ";" + currentPet2.rarity.petId));
+ JsonObject petItem2 = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(
+ currentPet2.skin != null ? currentPet2.skin : (currentPet2.petType + ";" + currentPet2.rarity.petId));
if (petItem2 != null) {
Vector2f position = getPosition(overlayWidth, overlayHeight);
int x = (int) position.x;
@@ -1037,12 +1050,7 @@ public class PetInfoOverlay extends TextOverlay {
String chatMessage = Utils.cleanColour(event.message.getUnformattedText());
Matcher autopetMatcher = AUTOPET_EQUIP.matcher(event.message.getFormattedText());
- if (event.message.getUnformattedText().startsWith("You summoned your") ||
- System.currentTimeMillis() - NEUOverlay.cachedPetTimer < 500) {
- NEUOverlay.cachedPetTimer = System.currentTimeMillis();
- NEUOverlay.shouldUseCachedPet = false;
- } else if (autopetMatcher.matches()) {
- NEUOverlay.shouldUseCachedPet = false;
+ if (autopetMatcher.matches()) {
try {
lastLevelHovered = Integer.parseInt(autopetMatcher.group(1));
} catch (NumberFormatException ignored) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java
index bd712ec7..86ed9b8f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java
@@ -20,7 +20,9 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.events.GuiInventoryBackgroundDrawnEvent;
import io.github.moulberry.notenoughupdates.listener.RenderListener;
+import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiInventory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -36,4 +38,9 @@ public class MixinGuiInventory {
ci.cancel();
}
}
+
+ @Inject(method = "drawGuiContainerBackgroundLayer", at = @At("TAIL"))
+ public void onDrawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY, CallbackInfo ci) {
+ new GuiInventoryBackgroundDrawnEvent((GuiContainer) (Object) this, partialTicks).post();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java
index c83f370f..72a45930 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java
@@ -53,6 +53,15 @@ public class Itemlist {
@Expose
@ConfigOption(
+ name = "Open when searching",
+ desc = "Open the Itemlist when in container search mode by double clicking the search bar"
+ )
+ @ConfigEditorBoolean
+ public boolean openWhenSearching = true;
+
+
+ @Expose
+ @ConfigOption(
name = "Item Style",
desc = "Sets the style of the background behind items"
)
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java
new file mode 100644
index 00000000..1bf61ad8
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java
@@ -0,0 +1,431 @@
+/*
+ * Copyright (C) 2022 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.overlays;
+
+import com.google.common.collect.Lists;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.events.GuiInventoryBackgroundDrawnEvent;
+import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
+import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer;
+import io.github.moulberry.notenoughupdates.options.NEUConfig;
+import io.github.moulberry.notenoughupdates.util.ItemUtils;
+import io.github.moulberry.notenoughupdates.util.SBInfo;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.client.gui.inventory.GuiInventory;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.event.GuiScreenEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.fml.relauncher.Side;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+public class EquipmentOverlay {
+ public static EquipmentOverlay INSTANCE = new EquipmentOverlay();
+
+ // <editor-fold desc="resources">
+ private static final ResourceLocation ARMOR_DISPLAY = new ResourceLocation(
+ "notenoughupdates:armordisplay/armordisplay.png");
+ private static final ResourceLocation ARMOR_DISPLAY_GREY = new ResourceLocation(
+ "notenoughupdates:armordisplay/armordisplay_grey.png");
+ private static final ResourceLocation ARMOR_DISPLAY_DARK = new ResourceLocation(
+ "notenoughupdates:armordisplay/armordisplay_phq_dark.png");
+ private static final ResourceLocation ARMOR_DISPLAY_FSR = new ResourceLocation(
+ "notenoughupdates:armordisplay/armordisplay_fsr.png");
+ private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT = new ResourceLocation(
+ "notenoughupdates:armordisplay/armordisplay_transparent.png");
+ private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT_PET = new ResourceLocation(
+ "notenoughupdates:armordisplay/armordisplay_transparent_pet.png");
+
+ private static final ResourceLocation QUESTION_MARK = new ResourceLocation("notenoughupdates:pv_unknown.png");
+
+ private static final ResourceLocation PET_DISPLAY = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplaysolo.png");
+ private static final ResourceLocation PET_DISPLAY_GREY = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplaysolo_dark.png");
+ private static final ResourceLocation PET_DISPLAY_DARK = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplaysolo_phqdark.png");
+ private static final ResourceLocation PET_DISPLAY_FSR = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplaysolo_fsr.png");
+ private static final ResourceLocation PET_DISPLAY_TRANSPARENT = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplaysolo_transparent.png");
+
+ private static final ResourceLocation PET_ARMOR_DISPLAY = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplayarmor.png");
+ private static final ResourceLocation PET_ARMOR_DISPLAY_GREY = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplayarmor_dark.png");
+ private static final ResourceLocation PET_ARMOR_DISPLAY_DARK = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplayarmor_phqdark.png");
+ private static final ResourceLocation PET_ARMOR_DISPLAY_FSR = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplayarmor_fsr.png");
+ private static final ResourceLocation PET_ARMOR_DISPLAY_TRANSPARENT = new ResourceLocation(
+ "notenoughupdates:petdisplay/petdisplayarmor_transparent.png");
+ //</editor-fold>
+
+ //<editor-fold desc="dynamic resources">
+ public ResourceLocation getCustomEquipmentTexture(boolean isPetRendering) {
+ switch (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle) {
+ case 0:
+ return ARMOR_DISPLAY;
+ case 1:
+ return ARMOR_DISPLAY_GREY;
+ case 2:
+ return ARMOR_DISPLAY_DARK;
+ case 3:
+ return isPetRendering ? ARMOR_DISPLAY_TRANSPARENT_PET : ARMOR_DISPLAY_TRANSPARENT;
+ case 4:
+ return ARMOR_DISPLAY_FSR;
+ }
+ return null;
+ }
+
+ public ResourceLocation getCustomPetTexture(boolean isArmorRendering) {
+ switch (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle) {
+ case 0:
+ return isArmorRendering ? PET_ARMOR_DISPLAY : PET_DISPLAY;
+ case 1:
+ return isArmorRendering ? PET_ARMOR_DISPLAY_GREY : PET_DISPLAY_GREY;
+ case 2:
+ return isArmorRendering ? PET_ARMOR_DISPLAY_DARK : PET_DISPLAY_DARK;
+ case 3:
+ return isArmorRendering ? PET_ARMOR_DISPLAY_TRANSPARENT : PET_DISPLAY_TRANSPARENT;
+ case 4:
+ return isArmorRendering ? PET_ARMOR_DISPLAY_FSR : PET_DISPLAY_FSR;
+ }
+ return null;
+ }
+ //</editor-fold>
+
+ //<editor-fold desc="pixel constants">
+ public static final int EQUIPMENT_SLOT_OFFSET_Y = 8;
+ public static final int ARMOR_OVERLAY_OVERHAND_WIDTH = 24;
+ public static final int ARMOR_OVERLAY_HEIGHT = 86;
+ public static final int ARMOR_OVERLAY_WIDTH = 31;
+ public static final int PET_OVERLAY_OFFSET_Y = ARMOR_OVERLAY_HEIGHT - 14 /* overlaying pixels */;
+ //</editor-fold>
+
+ public boolean isRenderingPet;
+
+ public boolean shouldRenderPets;
+ public boolean shouldRenderArmorHud;
+
+ public ItemStack petStack;
+
+ //<editor-fold desc="events">
+
+ @SubscribeEvent
+ public void onGuiTick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.START || event.side != Side.CLIENT) return;
+ updateGuiInfo(Minecraft.getMinecraft().currentScreen);
+ }
+
+ @SubscribeEvent
+ public void onGuiInit(GuiScreenEvent.InitGuiEvent event) {
+ updateGuiInfo(event.gui);
+ }
+
+ @SubscribeEvent
+ public void onRenderGuiPost(GuiInventoryBackgroundDrawnEvent event) {
+ if (!(event.getContainer() instanceof GuiInventory)) return;
+ GuiInventory inventory = ((GuiInventory) event.getContainer());
+ renderGuis(inventory);
+ }
+
+ //</editor-fold>
+
+ public void renderGuis(GuiInventory inventory) {
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ GL11.glColor4f(1F, 1F, 1F, 1F);
+ if (shouldRenderArmorHud) {
+ renderEquipmentGui(inventory, mouseX, mouseY, width, height);
+ }
+
+ if (shouldRenderPets) {
+ renderPets(inventory, mouseX, mouseY, width, height);
+ }
+ }
+
+ public void renderEquipmentGui(GuiInventory guiScreen, int mouseX, int mouseY, int width, int height) {
+ AccessorGuiContainer container = ((AccessorGuiContainer) guiScreen);
+
+ int overlayLeft = container.getGuiLeft() - ARMOR_OVERLAY_OVERHAND_WIDTH;
+ int overlayTop = container.getGuiTop();
+
+ ResourceLocation equipmentTexture = getCustomEquipmentTexture(isRenderingPet);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(equipmentTexture);
+
+ Utils.drawTexturedRect(overlayLeft, overlayTop, ARMOR_OVERLAY_WIDTH, ARMOR_OVERLAY_HEIGHT, GL11.GL_NEAREST);
+
+ List<String> tooltipToDisplay = new ArrayList<>();
+ drawSlot(slot1, overlayLeft + 8, overlayTop + EQUIPMENT_SLOT_OFFSET_Y, mouseX, mouseY, tooltipToDisplay);
+ drawSlot(slot2, overlayLeft + 8, overlayTop + EQUIPMENT_SLOT_OFFSET_Y + 18, mouseX, mouseY, tooltipToDisplay);
+ drawSlot(slot3, overlayLeft + 8, overlayTop + EQUIPMENT_SLOT_OFFSET_Y + 36, mouseX, mouseY, tooltipToDisplay);
+ drawSlot(slot4, overlayLeft + 8, overlayTop + EQUIPMENT_SLOT_OFFSET_Y + 54, mouseX, mouseY, tooltipToDisplay);
+
+ if (slot1 == null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(QUESTION_MARK);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(overlayLeft + 8, overlayTop + EQUIPMENT_SLOT_OFFSET_Y, 16, 16, GL11.GL_NEAREST);
+
+ tooltipToDisplay = Lists.newArrayList(
+ EnumChatFormatting.RED + "Warning",
+ EnumChatFormatting.GREEN + "You need to open /equipment",
+ EnumChatFormatting.GREEN + "to cache your armour"
+ );
+ if (Utils.isWithinRect(mouseX, mouseY, overlayLeft + 8, overlayTop + 8, 16, 16)
+ && NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand
+ && Mouse.getEventButtonState()
+ && Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
+ NotEnoughUpdates.INSTANCE.trySendCommand("/equipment");
+ }
+
+ }
+ if (tooltipToDisplay.size() > 0 &&
+ Utils.isWithinRect(
+ mouseX, mouseY,
+ overlayLeft, overlayTop,
+ ARMOR_OVERLAY_OVERHAND_WIDTH, ARMOR_OVERLAY_HEIGHT
+ )) {
+ Utils.drawHoveringText(
+ tooltipToDisplay,
+ mouseX - calculateTooltipXOffset(tooltipToDisplay, Minecraft.getMinecraft().fontRendererObj),
+ mouseY,
+ width,
+ height,
+ -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+
+ }
+
+ private ItemStack getRepoPetStack() {
+ NEUManager manager = NotEnoughUpdates.INSTANCE.manager;
+ PetInfoOverlay.Pet currentPet = PetInfoOverlay.getCurrentPet();
+ if (currentPet == null) return null;
+ ItemStack item = manager.createItem(currentPet.getPetId(false));
+ if (item != null) {
+ return item;
+ }
+ item = manager.createItem(currentPet.getPetId(true));
+ return item;
+ }
+
+ private void updateGuiInfo(GuiScreen screen) {
+ if (getWardrobeSlot(10) != null) {
+ slot1 = getWardrobeSlot(10);
+ slot2 = getWardrobeSlot(19);
+ slot3 = getWardrobeSlot(28);
+ slot4 = getWardrobeSlot(37);
+ }
+
+ if (screen instanceof GuiChest) {
+ petStack = getRepoPetStack();
+ }
+ if (!(screen instanceof GuiInventory)
+ || !NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect
+ || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ shouldRenderPets = shouldRenderArmorHud = false;
+ return;
+ }
+ shouldRenderPets = NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay && petStack != null;
+ shouldRenderArmorHud = NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud;
+ }
+
+ private void drawSlot(ItemStack stack, int x, int y, int mouseX, int mouseY, List<String> tooltip) {
+ if (stack == null) return;
+ Utils.drawItemStack(stack, x, y, true);
+ if (Utils.isWithinRect(mouseX, mouseY, x, y, 16, 16)) {
+ List<String> tt = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ if (shouldShowEquipmentTooltip(tt))
+ tooltip.addAll(tt);
+ if (NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand
+ && Mouse.getEventButtonState()) {
+ NotEnoughUpdates.INSTANCE.trySendCommand("/equipment");
+ }
+ }
+ }
+
+ public void renderPets(GuiInventory inventory, int mouseX, int mouseY, int width, int height) {
+ ItemUtils.getOrCreateTag(petStack).setBoolean(
+ "NEUHIDEPETTOOLTIP",
+ NotEnoughUpdates.INSTANCE.config.petOverlay.hidePetTooltip
+ );
+ ItemStack petInfo = petStack;
+
+ ResourceLocation customPetTexture = getCustomPetTexture(isRenderingArmorHud());
+ Minecraft.getMinecraft().getTextureManager().bindTexture(customPetTexture);
+ GlStateManager.color(1, 1, 1, 1);
+
+ AccessorGuiContainer container = ((AccessorGuiContainer) inventory);
+
+ int overlayLeft = container.getGuiLeft() - ARMOR_OVERLAY_OVERHAND_WIDTH;
+ int overlayTop = container.getGuiTop() + PET_OVERLAY_OFFSET_Y;
+
+ Utils.drawTexturedRect(overlayLeft, overlayTop, 31, 32, GL11.GL_NEAREST);
+ GlStateManager.bindTexture(0);
+
+ Utils.drawItemStack(petInfo, overlayLeft + 8, overlayTop + 8, true);
+
+ List<String> tooltipToDisplay;
+ if (Utils.isWithinRect(mouseX, mouseY, overlayLeft + 8, overlayTop + 8, 16, 16)) {
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.sendPetsCommand
+ && Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null
+ && Mouse.getEventButtonState()) {
+ NotEnoughUpdates.INSTANCE.trySendCommand("/pets");
+ }
+ tooltipToDisplay = petInfo.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ Utils.drawHoveringText(
+ tooltipToDisplay,
+ mouseX - calculateTooltipXOffset(tooltipToDisplay, Minecraft.getMinecraft().fontRendererObj),
+ mouseY,
+ width,
+ height,
+ -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ }
+
+ private ItemStack getWardrobeSlot(int armourSlot) {
+ if (SBInfo.getInstance().currentProfile == null) {
+ return null;
+ }
+
+ if (!Objects.equals(SBInfo.getInstance().currentProfile, lastProfile)) {
+ lastProfile = SBInfo.getInstance().currentProfile;
+ slot1 = null;
+ slot2 = null;
+ slot3 = null;
+ slot4 = null;
+ }
+
+ NEUConfig.HiddenProfileSpecific profileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (profileSpecific == null) return null;
+
+ if (isInNamedGui("Your Equipment")) {
+ ItemStack itemStack = getChestSlotsAsItemStack(armourSlot);
+ if (itemStack != null) {
+ JsonObject itemToSave = NotEnoughUpdates.INSTANCE.manager.getJsonForItem(itemStack);
+ if (!itemToSave.has("internalname")) {
+ //would crash without internalName when trying to construct the ItemStack again
+ itemToSave.add("internalname", new JsonPrimitive("_"));
+ }
+ profileSpecific.savedEquipment.put(armourSlot, itemToSave);
+ return itemStack;
+ }
+ } else {
+ if (profileSpecific.savedEquipment.containsKey(armourSlot)) {
+ //don't use cache since the internalName is identical in most cases
+ JsonObject jsonObject = profileSpecific.savedEquipment
+ .get(armourSlot);
+ if (jsonObject != null) return NotEnoughUpdates.INSTANCE.manager.jsonToStack(jsonObject
+ .getAsJsonObject(), false);
+ }
+ }
+ return null;
+ }
+
+ private boolean wardrobeOpen = false;
+
+ private boolean isInNamedGui(String guiName) {
+ GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
+ if (guiScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+ String containerName = lower.getDisplayName().getUnformattedText();
+ wardrobeOpen = containerName.contains(guiName);
+ }
+ if (guiScreen instanceof GuiInventory) {
+ wardrobeOpen = false;
+ }
+ return wardrobeOpen;
+ }
+
+ private ItemStack getChestSlotsAsItemStack(int slot) {
+ GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
+ if (guiScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ return chest.inventorySlots.getSlot(slot).getStack();
+ } else {
+ return null;
+ }
+ }
+
+ public static boolean isRenderingArmorHud() {
+ return INSTANCE.shouldRenderArmorHud;
+ }
+
+ public static boolean isRenderingPetHud() {
+ return INSTANCE.shouldRenderPets;
+ }
+
+ private boolean shouldShowEquipmentTooltip(List<String> toolTip) {
+ return !toolTip.get(0).equals("§o§7Empty Equipment Slot§r");
+ }
+
+ /**
+ * Calculates the width of the longest String in the tooltip, which can be used to offset the entire tooltip to the left more precisely
+ *
+ * @param tooltipToDisplay tooltip
+ * @param fr FontRenderer object
+ * @return offset to apply
+ */
+ private int calculateTooltipXOffset(List<String> tooltipToDisplay, FontRenderer fr) {
+ int offset = 0;
+ if (tooltipToDisplay != null) {
+ for (String line : tooltipToDisplay) {
+ int lineWidth = fr.getStringWidth(line);
+ if (lineWidth > offset) {
+ offset = lineWidth;
+ }
+ }
+ }
+ return offset + 20;
+ }
+
+ public ItemStack slot1 = null;
+ public ItemStack slot2 = null;
+ public ItemStack slot3 = null;
+ public ItemStack slot4 = null;
+ private String lastProfile;
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
index cffdd164..ad8a6c98 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java
@@ -57,6 +57,13 @@ public class ItemUtils {
return skull;
}
+ public static NBTTagCompound getOrCreateTag(ItemStack is) {
+ if (is.hasTagCompound()) return is.getTagCompound();
+ NBTTagCompound nbtTagCompound = new NBTTagCompound();
+ is.setTagCompound(nbtTagCompound);
+ return nbtTagCompound;
+ }
+
public static void appendLore(ItemStack is, List<String> moreLore) {
NBTTagCompound tagCompound = is.getTagCompound();
if (tagCompound == null) {