feat: added PlayerList module
This commit is contained in:
parent
36dfda2d4c
commit
ae65fb2593
2 changed files with 43 additions and 2 deletions
|
@ -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));
|
||||
|
|
42
src/main/java/ftbsc/bscv/modules/hud/PlayerList.java
Normal file
42
src/main/java/ftbsc/bscv/modules/hud/PlayerList.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue