diff options
-rw-r--r-- | src/main/java/ftbsc/bscv/BoSCoVicino.java | 3 | ||||
-rw-r--r-- | src/main/java/ftbsc/bscv/modules/hud/PlayerList.java | 42 |
2 files changed, 43 insertions, 2 deletions
diff --git a/src/main/java/ftbsc/bscv/BoSCoVicino.java b/src/main/java/ftbsc/bscv/BoSCoVicino.java index 6c06c42..cad15d2 100644 --- a/src/main/java/ftbsc/bscv/BoSCoVicino.java +++ b/src/main/java/ftbsc/bscv/BoSCoVicino.java @@ -1,6 +1,5 @@ package ftbsc.bscv; -import net.minecraft.block.Block; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.gui.screen.IngameMenuScreen; import net.minecraft.client.gui.widget.button.Button; @@ -12,7 +11,6 @@ import net.minecraftforge.client.event.ClientChatEvent; import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; @@ -67,6 +65,7 @@ public class BoSCoVicino implements ICommons { BoSCoVicino.mods.add(new InfoDisplay(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new Coordinates(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new EntityList(cfg, dp).done(cfg)); + BoSCoVicino.mods.add(new PlayerList(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new Fullbright(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new AntiHunger(cfg, dp).done(cfg)); BoSCoVicino.mods.add(new PortalGui(cfg, dp).done(cfg)); diff --git a/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java b/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java new file mode 100644 index 0000000..6928e31 --- /dev/null +++ b/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java @@ -0,0 +1,42 @@ +package ftbsc.bscv.modules.hud; + +import static ftbsc.bscv.tools.Text.TextBuilder; + +import com.mojang.brigadier.CommandDispatcher; + +import ftbsc.bscv.ICommons; +import ftbsc.bscv.modules.HudModule; +import net.minecraft.command.CommandSource; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.eventbus.api.SubscribeEvent; + +public class PlayerList extends HudModule implements ICommons { + + public PlayerList(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) { + super("PlayerList", builder, dispatcher); + } + + @SubscribeEvent + public void onRenderOverlay(RenderGameOverlayEvent event) { + if (event.getType() != ElementType.TEXT) return; + + int offset = 0; + for (Entity e : MC.level.entitiesForRendering()) { + if (e.equals(MC.player)) continue; + if (!(e instanceof PlayerEntity)) continue; + PlayerEntity player = (PlayerEntity) e; + TextBuilder() + .txt(String.format("[%.1f] %s (%.0f hp)", player.distanceTo(MC.player), player.getDisplayName().getString(), player.getHealth())) + .anchor(this.anchor.get()) + .x(this.x.get()) + .y(this.y.get() + offset) + .scale(this.scale.get()) + .render(event.getMatrixStack(), event.getWindow()); + offset += MC.font.lineHeight; + } + } +} |