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.RenderOverlay; 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 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 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(RenderOverlay 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); } } }