From 7422c6e16238148fbd36893854e00d235e40acbd Mon Sep 17 00:00:00 2001 From: Richard Gonlag Date: Thu, 13 Aug 2020 12:49:44 +0200 Subject: [PATCH] Added config option to disable custom item search --- src/main/java/at/feldim2425/moreoverlays/config/Config.java | 6 ++++++ .../at/feldim2425/moreoverlays/itemsearch/GuiRenderer.java | 4 +++- src/main/resources/assets/moreoverlays/lang/de_de.json | 1 + src/main/resources/assets/moreoverlays/lang/en_us.json | 1 + src/main/resources/assets/moreoverlays/lang/nl_nl.json | 3 ++- src/main/resources/assets/moreoverlays/lang/ru_ru.json | 1 + 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/feldim2425/moreoverlays/config/Config.java b/src/main/java/at/feldim2425/moreoverlays/config/Config.java index 363bad4..4c9d19b 100644 --- a/src/main/java/at/feldim2425/moreoverlays/config/Config.java +++ b/src/main/java/at/feldim2425/moreoverlays/config/Config.java @@ -23,6 +23,8 @@ public class Config { public static ForgeConfigSpec.IntValue render_spawnAColor; public static ForgeConfigSpec.IntValue render_spawnNColor; public static ForgeConfigSpec.DoubleValue render_spawnLineWidth; + + public static ForgeConfigSpec.BooleanValue search_searchCustom; public static void initialize() { @@ -52,6 +54,10 @@ public static void initialize() { render_spawnNColor = builder.comment("Color the X that marks \"Spawns at night possible\"").defineInRange("spawn_night_color", 0xFFFF00, 0, 0xFFFFFF); render_spawnLineWidth = builder.comment("Line width for spawn indication").defineInRange("spawn_line_width", 2, 0, Double.MAX_VALUE); builder.pop(); + + builder.comment("Settings for the search overlay").push("searchoverlay"); + search_searchCustom = builder.comment("Also searches for the custom name of an item in user inventory (for example items named in anvil)\nSetting this to false will increase performance but will not find custom named items.").define("custom_search", true); + builder.pop(); config_client = builder.build(); } diff --git a/src/main/java/at/feldim2425/moreoverlays/itemsearch/GuiRenderer.java b/src/main/java/at/feldim2425/moreoverlays/itemsearch/GuiRenderer.java index 66dd79e..7bfd094 100644 --- a/src/main/java/at/feldim2425/moreoverlays/itemsearch/GuiRenderer.java +++ b/src/main/java/at/feldim2425/moreoverlays/itemsearch/GuiRenderer.java @@ -1,5 +1,6 @@ package at.feldim2425.moreoverlays.itemsearch; +import java.util.Arrays; import java.util.Map; import com.google.common.collect.BiMap; @@ -10,6 +11,7 @@ import at.feldim2425.moreoverlays.api.itemsearch.SlotHandler; import at.feldim2425.moreoverlays.api.itemsearch.SlotViewWrapper; +import at.feldim2425.moreoverlays.config.Config; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.inventory.ContainerScreen; @@ -197,7 +199,7 @@ private void checkSlots(ContainerScreen container) { } private boolean isSearchedItem(ItemStack stack) { - if(stack.getDisplayName().getString().toLowerCase().contains(JeiModule.getJEITextField().getText().toLowerCase())) { + if(Config.search_searchCustom.get() && Arrays.stream(JeiModule.getJEITextField().getText().toLowerCase().split(" ", -1)).anyMatch(stack.getDisplayName().getString().toLowerCase()::contains)) { return true; } if (emptyFilter) return true; diff --git a/src/main/resources/assets/moreoverlays/lang/de_de.json b/src/main/resources/assets/moreoverlays/lang/de_de.json index 0183b08..517f224 100644 --- a/src/main/resources/assets/moreoverlays/lang/de_de.json +++ b/src/main/resources/assets/moreoverlays/lang/de_de.json @@ -11,5 +11,6 @@ "config.moreoverlays.category.lightoverlay": "Licht-Overlay", "config.moreoverlays.category.chunkbounds": "Chunk Grenzen", "config.moreoverlays.category.itemsearch": "Item Suche", + "config.moreoverlays.category.searchoverlay": "Item Suche", "config.moreoverlays.category.rendersettings" : "Render Einstellungen" } diff --git a/src/main/resources/assets/moreoverlays/lang/en_us.json b/src/main/resources/assets/moreoverlays/lang/en_us.json index 2f60e09..29e54c5 100644 --- a/src/main/resources/assets/moreoverlays/lang/en_us.json +++ b/src/main/resources/assets/moreoverlays/lang/en_us.json @@ -11,5 +11,6 @@ "config.moreoverlays.category.lightoverlay": "Lightoverlay", "config.moreoverlays.category.chunkbounds": "Chunk bounds", "config.moreoverlays.category.itemsearch": "Item Search", + "config.moreoverlays.category.searchoverlay": "Item Search", "config.moreoverlays.category.rendersettings": "Render Settings" } \ No newline at end of file diff --git a/src/main/resources/assets/moreoverlays/lang/nl_nl.json b/src/main/resources/assets/moreoverlays/lang/nl_nl.json index d070bb2..7364e19 100644 --- a/src/main/resources/assets/moreoverlays/lang/nl_nl.json +++ b/src/main/resources/assets/moreoverlays/lang/nl_nl.json @@ -4,12 +4,13 @@ "key.moreoverlays.lightoverlay.desc": "Tonen/Verbergen Donkere Plekken", "gui.config.moreoverlays.tile": "MoreOverlays Instellingen", - "gui.config.moreoverlays.reset_config": "Instellingen Resetten", + "gui.config.moreoverlays.reset_config": "Instellingen resetten", "gui.config.moreoverlays.undo": "Wijzigingen resetten", "gui.config.moreoverlays.save": "Opslaan", "config.moreoverlays.category.lightoverlay": "Licht-Overlay", "config.moreoverlays.category.chunkbounds": "Chunk Grenzen", "config.moreoverlays.category.itemsearch": "Item Zoeken", + "config.moreoverlays.category.searchoverlay": "Item Zoeken", "config.moreoverlays.category.rendersettings": "Render Instellingen" } \ No newline at end of file diff --git a/src/main/resources/assets/moreoverlays/lang/ru_ru.json b/src/main/resources/assets/moreoverlays/lang/ru_ru.json index be040e6..195aab5 100644 --- a/src/main/resources/assets/moreoverlays/lang/ru_ru.json +++ b/src/main/resources/assets/moreoverlays/lang/ru_ru.json @@ -8,5 +8,6 @@ "config.moreoverlays.category.chunkbounds": "Границы чанков", "config.moreoverlays.category.lightoverlay": "Метки темноты", "config.moreoverlays.category.itemsearch": "Поиск предметов", + "config.moreoverlays.category.searchoverlay": "Поиск предметов", "config.moreoverlays.category.rendersettings": "Настройки графики" } \ No newline at end of file