Only trigger proximity detector when object enters the range, not when he moves within range
java, minecraft
Solution
You'll need to keep track of when the player leaves the range and set a flag, so you'll know when they're transitioning from "out of range" to "in range". Might also want to add a timer so that you can only alert once every N seconds.
Problem
I'm making a text-based radar for Minecraft. If a player comes within 20 blocks of you, it will say in chat. As of now, it spams the chat. How can I get it to only write to chat about that player ONCE? Even if you don't play the game, it should be easy to understand. ``` if (Camb.radar) { for (Entity e: (List < Entity > ) mc.theWorld.loadedEntityList) { if (e instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) e; if (player == mc.thePlayer || mc.thePlayer.getDistanceToEntity(e) > 20.0) continue; mc.thePlayer.addChatMessage("\2479[CAMB] \247e" + player.getEntityName() + " has entered your 20 block radius!"); //Write to chat, only want this line done once for every player } } } ```