Advertisement
peacestorm

Player close to an entity

Nov 26th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. function modTick() {
  2. closeToEntity();
  3. }
  4.  
  5. function closeToEntity() {
  6. var mobs = Entity.getAll();
  7.  
  8. for(var i=0; i<mobs.length; i++){
  9.  
  10.  
  11. /* now the variable "mobs" is now "mobs[i]",
  12. if you are asking why they are they now like this, it is because we split all gotten entities as their own, that means you can personalize them, (that is very useful when you are using Entity.get() scripts. So I can give all entities a personalized (as example) nametag which shows their own health. */
  13.  
  14.  
  15. var xq = Entity.getX(mobs[i])-getPlayerX();
  16.  
  17. var yq = Entity.getY(mobs[i])-getPlayerY();
  18.  
  19. var zq = Entity.getZ(mobs[i])-getPlayerZ();
  20.  
  21.  
  22.  
  23. if(xq*xq+yq*yq+zq*zq<=14*14 && mobs[i] != getPlayerEnt()){
  24.  
  25. /* the 14 stands for, that the entities you want to give (as example) a nametag need to be in a radius of 14 blocks */
  26.  
  27. /* You can disable it by removing the above script. */
  28. if(Entity.getEntityTypeId(mobs[i])==10) {
  29. //Do something when player is less than 14 blocks away from an entity, to target the entity use mobs[i]
  30. }}}}
  31.  
  32. //Example by @MyNameIsTriXz, edited by @AgameR_Modder
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement