aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/TetherDisplay.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/Danker/features/TetherDisplay.java')
-rw-r--r--src/main/java/me/Danker/features/TetherDisplay.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/features/TetherDisplay.java b/src/main/java/me/Danker/features/TetherDisplay.java
new file mode 100644
index 0000000..1af3a0f
--- /dev/null
+++ b/src/main/java/me/Danker/features/TetherDisplay.java
@@ -0,0 +1,60 @@
+package me.Danker.features;
+
+import me.Danker.DankersSkyblockMod;
+import me.Danker.commands.MoveCommand;
+import me.Danker.commands.ScaleCommand;
+import me.Danker.commands.ToggleCommand;
+import me.Danker.events.RenderOverlayEvent;
+import me.Danker.handlers.TextRenderer;
+import me.Danker.utils.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityOtherPlayerMP;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TetherDisplay {
+
+ static List<String> playersInRadius = new ArrayList<>();
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.START) return;
+
+ Minecraft mc = Minecraft.getMinecraft();
+ EntityPlayer player = mc.thePlayer;
+ World world = mc.theWorld;
+ if (DankersSkyblockMod.tickAmount % 10 == 0) {
+ if (ToggleCommand.teammatesInRadius && Utils.inDungeons && player != null && world != null) {
+ playersInRadius.clear();
+ List<EntityPlayer> teammates = world.getEntitiesWithinAABB(EntityOtherPlayerMP.class, new AxisAlignedBB(player.posX - 30, player.posY - 30, player.posZ - 30, player.posX + 30, player.posY + 30, player.posZ + 30));
+
+ for (EntityPlayer teammate : teammates) {
+ if (Utils.isRealPlayer(teammate) && !teammate.isInvisible() && player.getDistanceToEntity(teammate) <= 30F) {
+ playersInRadius.add(teammate.getDisplayName().getSiblings().get(0).getFormattedText());
+ }
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void renderPlayerInfo(RenderOverlayEvent event) {
+ if (ToggleCommand.teammatesInRadius && Utils.inDungeons) {
+ String teammates;
+ if (playersInRadius.size() > 0) {
+ teammates = String.join("\n", playersInRadius);
+ } else {
+ teammates = EnumChatFormatting.RED + "NONE";
+ }
+ new TextRenderer(Minecraft.getMinecraft(), EnumChatFormatting.AQUA + "Teammates In Radius:\n" + teammates, MoveCommand.teammatesInRadiusXY[0], MoveCommand.teammatesInRadiusXY[1], ScaleCommand.teammatesInRadiusScale);
+ }
+ }
+
+}