aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-12-11 22:51:09 +0100
committernea <romangraef@gmail.com>2022-12-24 02:52:20 +0100
commit912654c092ad123febf9f22775d8569d85517646 (patch)
treefdad8767d10436704325561947dc448b3e064976 /src/main/java
parent7603f56ca7b2d2654fdde2f7a81bdd97f1b66a61 (diff)
downloadNotEnoughUpdates-912654c092ad123febf9f22775d8569d85517646.tar.gz
NotEnoughUpdates-912654c092ad123febf9f22775d8569d85517646.tar.bz2
NotEnoughUpdates-912654c092ad123febf9f22775d8569d85517646.zip
Museum: Display hydrated items for items taken outside of the repo
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/events/GuiContainerBackgroundDrawnEvent.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java46
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java26
7 files changed, 71 insertions, 55 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index ca0d91d2..5e9bb55c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -103,7 +103,7 @@ public class NEUManager {
private final TreeMap<String, JsonObject> itemMap = new TreeMap<>();
private boolean hasBeenLoadedBefore = false;
- private final TreeMap<String, HashMap<String, List<Integer>>> titleWordMap = new TreeMap<>();
+ public final TreeMap<String, HashMap<String, List<Integer>>> titleWordMap = new TreeMap<>();
private final TreeMap<String, HashMap<String, List<Integer>>> loreWordMap = new TreeMap<>();
public final KeyBinding keybindGive =
@@ -323,7 +323,7 @@ public class NEUManager {
synchronized (titleWordMap) {
int wordIndex = 0;
for (String str : json.get("displayname").getAsString().split(" ")) {
- str = clean(str);
+ str = cleanForTitleMapSearch(str);
if (!titleWordMap.containsKey(str)) {
titleWordMap.put(str, new HashMap<>());
}
@@ -341,7 +341,7 @@ public class NEUManager {
int wordIndex = 0;
for (JsonElement element : json.get("lore").getAsJsonArray()) {
for (String str : element.getAsString().split(" ")) {
- str = clean(str);
+ str = cleanForTitleMapSearch(str);
if (!loreWordMap.containsKey(str)) {
loreWordMap.put(str, new HashMap<>());
}
@@ -469,8 +469,8 @@ public class NEUManager {
int lastStringMatch = -1;
ArrayList<DebugMatch> debugMatches = new ArrayList<>();
- toSearch = clean(toSearch).toLowerCase();
- query = clean(query).toLowerCase();
+ toSearch = cleanForTitleMapSearch(toSearch).toLowerCase();
+ query = cleanForTitleMapSearch(query).toLowerCase();
String[] splitToSearch = toSearch.split(" ");
String[] queryArray = query.split(" ");
@@ -687,7 +687,7 @@ public class NEUManager {
public Set<String> search(String query, TreeMap<String, HashMap<String, List<Integer>>> wordMap) {
HashMap<String, List<Integer>> matches = null;
- query = clean(query).toLowerCase();
+ query = cleanForTitleMapSearch(query).toLowerCase();
for (String queryWord : query.split(" ")) {
HashMap<String, List<Integer>> matchesToKeep = new HashMap<>();
for (HashMap<String, List<Integer>> wordMatches : subMapWithKeysThatAreSuffixes(queryWord, wordMap).values()) {
@@ -862,7 +862,7 @@ public class NEUManager {
return item;
}
- private String clean(String str) {
+ public static String cleanForTitleMapSearch(String str) {
return str.replaceAll("(\u00a7.)|[^0-9a-zA-Z ]", "").toLowerCase().trim();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index bc2666d3..8e50c109 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -67,6 +67,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.WitherCloakChanger;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBlockSounds;
import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.DwarvenMinesTextures;
+import io.github.moulberry.notenoughupdates.miscfeatures.inventory.MuseumItemHighlighter;
import io.github.moulberry.notenoughupdates.miscfeatures.item.enchants.EnchantStyleCustomizer;
import io.github.moulberry.notenoughupdates.miscfeatures.updater.AutoUpdater;
import io.github.moulberry.notenoughupdates.miscfeatures.world.EnderNodeHighlighter;
@@ -349,6 +350,7 @@ public class NotEnoughUpdates {
MinecraftForge.EVENT_BUS.register(FrozenTreasuresHighlighter.getInstance());
MinecraftForge.EVENT_BUS.register(AbiphoneFavourites.getInstance());
MinecraftForge.EVENT_BUS.register(AbiphoneContactHelper.getInstance());
+ MinecraftForge.EVENT_BUS.register(MuseumItemHighlighter.INSTANCE);
if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) {
IReloadableResourceManager manager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/events/GuiContainerBackgroundDrawnEvent.java b/src/main/java/io/github/moulberry/notenoughupdates/events/GuiContainerBackgroundDrawnEvent.java
new file mode 100644
index 00000000..bdb6d1a1
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/events/GuiContainerBackgroundDrawnEvent.java
@@ -0,0 +1,29 @@
+/*
+ * 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 lombok.Value;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+@Value
+public class GuiContainerBackgroundDrawnEvent extends NEUEvent {
+ public GuiContainer container;
+ public float partialTicks;
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java
index ce96b29a..e6a1399d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java
@@ -23,6 +23,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
+import io.github.moulberry.notenoughupdates.events.GuiContainerBackgroundDrawnEvent;
import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent;
import io.github.moulberry.notenoughupdates.events.SlotClickEvent;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
@@ -200,10 +201,11 @@ public class AbiphoneFavourites {
return isAbiphoneShowOnlyFavourites() && !getFavouriteContacts().contains(name);
}
- public void onDrawBackground(GuiScreen screen) {
+ @SubscribeEvent
+ public void onDrawBackground(GuiContainerBackgroundDrawnEvent event) {
if (isWrongInventory()) return;
- GuiContainer container = (GuiContainer) screen;
+ GuiContainer container = event.getContainer();
for (Slot slot : container.inventorySlots.inventorySlots) {
if (slot == null) continue;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
index 91d92091..bd1dff63 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
@@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.NEUOverlay;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.events.GuiContainerBackgroundDrawnEvent;
import io.github.moulberry.notenoughupdates.events.SlotClickEvent;
import io.github.moulberry.notenoughupdates.listener.RenderListener;
import io.github.moulberry.notenoughupdates.miscfeatures.AbiphoneFavourites;
@@ -329,6 +330,6 @@ public abstract class MixinGuiContainer extends GuiScreen {
@Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V", ordinal = 1))
private void drawBackground(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
- AbiphoneFavourites.getInstance().onDrawBackground(this);
+ new GuiContainerBackgroundDrawnEvent(((GuiContainer) (Object) this), partialTicks).post();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java
index 7c2cfcbf..b6e0e45a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java
@@ -25,6 +25,7 @@ import io.github.moulberry.notenoughupdates.core.ChromaColour;
import io.github.moulberry.notenoughupdates.listener.RenderListener;
import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns;
import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager;
+import io.github.moulberry.notenoughupdates.miscfeatures.inventory.MuseumItemHighlighter;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -148,51 +149,6 @@ public abstract class MixinRenderItem {
@Shadow
abstract void renderModel(IBakedModel model, int color);
- /*@Redirect(method="renderEffect",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderModel(Lnet/minecraft/client/resources/model/IBakedModel;I)V"
- )
- )
- public void renderEffect_renderModel(RenderItem renderItem, IBakedModel model, int colour) {
- if(customEnchGlint != null) {
- renderModel(model, ChromaColour.specialToChromaRGB(customEnchGlint));
- } else {
- renderModel(model, colour);
- }
- }
-
- @Redirect(method="renderEffect",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/client/renderer/texture/TextureManager;bindTexture(Lnet/minecraft/util/ResourceLocation;)V"
- )
- )
- public void renderEffect_bindTexture(TextureManager textureManager, ResourceLocation location) {
- if(customEnchGlint != null) {
- textureManager.bindTexture(GlintManager.getCustomGlintTexture());
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
- } else {
- textureManager.bindTexture(location);
- }
- }
-
- @Redirect(method="renderEffect",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/client/renderer/GlStateManager;blendFunc(II)V"
- )
- )
- public void renderEffect_blendFunc(int src, int dst) {
- if(dst != 1) {
- GlStateManager.blendFunc(src, dst);
- } else if(customEnchGlint != null) {
- GlintManager.setCustomBlendFunc(customEnchGlint);
- } else {
- GlStateManager.blendFunc(GL11.GL_SRC_COLOR, 1);
- }
- }*/
@Inject(method = "renderItemIntoGUI", at = @At("HEAD"))
public void renderItemHead(ItemStack stack, int x, int y, CallbackInfo ci) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java
index 11ace314..7266b570 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java
@@ -24,6 +24,7 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccord
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider;
@@ -295,4 +296,29 @@ public class Misc {
@ConfigEditorBoolean
public boolean abiphoneFavourites = true;
+ @ConfigOption(
+ name = "Museum Overlay",
+ desc = "Display items you've taken out of the museum"
+ )
+ @ConfigEditorAccordion(id = 2)
+ public boolean museumAccordion = false;
+
+ @ConfigOption(
+ name = "Show Museum Items",
+ desc = "Show real items instead of green dye in the museum"
+ )
+ @ConfigAccordionId(id = 2)
+ @ConfigEditorBoolean
+ @Expose
+ public boolean museumItemShow = true;
+
+ @ConfigOption(
+ name = "Highlight the virtual museum items",
+ desc = "Highlight virtual museum items"
+ )
+ @ConfigAccordionId(id = 2)
+ @ConfigEditorColour
+ @Expose
+ public String museumItemColor = "0:255:0:255:0";
+
}