From 385797718d69f6f485fa79bb25a4990ab39a3ca8 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 20 Feb 2023 02:29:50 +0100 Subject: [PATCH] feat: added search filter to entitylist --- .../java/ftbsc/bscv/modules/hud/EntityList.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 search; + public EntityList(ForgeConfigSpec.Builder builder, CommandDispatcher 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; }