summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-02-20 02:29:50 +0100
committer alemi <me@alemi.dev>2023-02-20 02:29:50 +0100
commit385797718d69f6f485fa79bb25a4990ab39a3ca8 (patch)
tree09d9b6cbd958d4eb6dd9ff131f447732e0a5d2b9 /src
parenta3491632e70dae1e812e12db6ed3a637c51936ad (diff)
feat: added search filter to entitylist0.3.1
Diffstat (limited to 'src')
-rw-r--r--src/main/java/ftbsc/bscv/modules/hud/EntityList.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/hud/EntityList.java b/src/main/java/ftbsc/bscv/modules/hud/EntityList.java
index 335aec5..c48b546 100644
--- a/src/main/java/ftbsc/bscv/modules/hud/EntityList.java
+++ b/src/main/java/ftbsc/bscv/modules/hud/EntityList.java
@@ -8,11 +8,15 @@ import java.util.List;
import java.util.stream.Collectors;
import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.arguments.StringArgumentType;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.modules.HudModule;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
+import net.minecraft.util.text.Color;
+import net.minecraft.util.text.Style;
+import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.common.ForgeConfigSpec;
@@ -20,8 +24,16 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class EntityList extends HudModule implements ICommons {
+ public final ForgeConfigSpec.ConfigValue<String> search;
+
public EntityList(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
super("EntityList", builder, dispatcher);
+
+ this.search = this.option(
+ "search", "highlight names containing this text", "",
+ StringArgumentType.string(), String.class,
+ builder, dispatcher
+ );
}
@SubscribeEvent
@@ -52,6 +64,11 @@ public class EntityList extends HudModule implements ICommons {
.x(this.x.get())
.y(this.y.get() + offset)
.scale(this.scale.get())
+ .style(
+ this.search.get().length() > 0 && u.toLowerCase().contains(this.search.get().toLowerCase())
+ ? Style.EMPTY.withBold(true).withColor(Color.fromLegacyFormat(TextFormatting.GOLD))
+ : Style.EMPTY.withColor(Color.fromLegacyFormat(TextFormatting.WHITE))
+ )
.render(event.getMatrixStack(), event.getWindow());
offset += MC.font.lineHeight;
}