Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getNearestMob(range, minRange) {
- let mobs = Entity.getAll();
- if(targetMobsSetting == "on") {
- for(let i = 0; i < mobs.length; i++) {
- let ent = mobs[i];
- let x = Entity.getX(ent) - getPlayerX();
- let y = Entity.getY(ent) - getPlayerY();
- let z = Entity.getZ(ent) - getPlayerZ();
- if(x*x+y*y+z*z>range*range) {
- continue;
- }
- if(minRange != null) {
- if(x*x+y*y+z*z<=minRange*minRange) {
- continue;
- }
- }
- if(Entity.getEntityTypeId(ent) != EntityType.ARROW && Entity.getEntityTypeId(ent) != EntityType.BOAT && Entity.getEntityTypeId(ent) != EntityType.EGG && Entity.getEntityTypeId(ent) != EntityType.ENDER_PEARL && Entity.getEntityTypeId(ent) != EntityType.EXPERIENCE_ORB && Entity.getEntityTypeId(ent) != EntityType.EXPERIENCE_POTION && Entity.getEntityTypeId(ent) != EntityType.FALLING_BLOCK && Entity.getEntityTypeId(ent) != EntityType.FIREBALL && Entity.getEntityTypeId(ent) != EntityType.FISHING_HOOK && Entity.getEntityTypeId(ent) != EntityType.ITEM && Entity.getEntityTypeId(ent) != EntityType.LIGHTNING_BOLT && Entity.getEntityTypeId(ent) != EntityType.MINECART && Entity.getEntityTypeId(ent) != EntityType.PAINTING && Entity.getEntityTypeId(ent) != EntityType.PRIMED_TNT && Entity.getEntityTypeId(ent) != EntityType.SMALL_FIREBALL && Entity.getEntityTypeId(ent) != EntityType.SNOWBALL && Entity.getEntityTypeId(ent) != EntityType.THROWN_POTION && ent != getPlayerEnt()) {
- return ent;
- }
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement