Created
December 9, 2017 21:52
-
-
Save rafaeltab/48d2f8e71ea1092939d5226ba5ec6502 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
import org.bukkit.entity.Entity; | |
import org.bukkit.entity.Player; | |
public class Sort { | |
//Sorry ik ben eigenwijs geweest en heb ook nog een range toegevoegd | |
public Map<Entity, Double> findNear(int range, Player player){ | |
Map<Entity, Double> map = new HashMap<Entity, Double>(); | |
for(Entity entity : player.getWorld().getEntities()) { | |
float distance = (float)Math.sqrt(((float) Math.pow((player.getLocation().getX() - entity.getLocation().getX()), 2) + Math.pow((player.getLocation().getY() - entity.getLocation().getY()), 2) + Math.pow((player.getLocation().getZ() - entity.getLocation().getZ()), 2))); | |
if(distance < range) { | |
map.put(entity, (double) distance); | |
} | |
} | |
return map; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment