diff options
-rw-r--r-- | src/main/java/ftbsc/bscv/Boscovicino.java | 6 | ||||
-rw-r--r-- | src/main/java/ftbsc/bscv/modules/hud/PlayerList.java | 30 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/main/java/ftbsc/bscv/Boscovicino.java b/src/main/java/ftbsc/bscv/Boscovicino.java index 65c5830..a720cb0 100644 --- a/src/main/java/ftbsc/bscv/Boscovicino.java +++ b/src/main/java/ftbsc/bscv/Boscovicino.java @@ -71,9 +71,13 @@ public class Boscovicino implements ICommons { } public static void log(String message) { + log(message, true); + } + + public static void log(String message, boolean overlay) { LOGGER.info(message); if (MC.player != null) { - MC.player.displayClientMessage(new StringTextComponent(message), true); + MC.player.displayClientMessage(new StringTextComponent(message), overlay); } } diff --git a/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java b/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java index a0cdd6b..1553b5a 100644 --- a/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java +++ b/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java @@ -3,17 +3,37 @@ package ftbsc.bscv.modules.hud; import com.google.auto.service.AutoService; import ftbsc.bscv.api.ILoadable; import ftbsc.bscv.modules.HudModule; +import ftbsc.bscv.tools.Setting; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import static ftbsc.bscv.tools.Text.TextBuilder; +import static ftbsc.bscv.Boscovicino.log; @AutoService(ILoadable.class) public class PlayerList extends HudModule { + public final ForgeConfigSpec.ConfigValue<Boolean> notify; + + public PlayerList() { + super(); + + this.notify = Setting.Bool.builder() + .fallback(false) + .name("notify") + .comment("notify when players enter render distance") + .build(this); + } + + + @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent event) { if (event.getType() != ElementType.TEXT) return; @@ -34,4 +54,14 @@ public class PlayerList extends HudModule { offset += MC.font.lineHeight; } } + + @SubscribeEvent + public void onEntityEntersRenderdistance(EntityJoinWorldEvent event) { + if (!notify.get()) return; + if (event.getEntity() instanceof PlayerEntity){ + PlayerEntity player = (PlayerEntity) event.getEntity(); + if (MC.player != null && player.getId() == MC.player.getId()) return; + log(String.format("%s spotted", player.getDisplayName().getString()), false); + } + } } |