Esempio n. 1
0
 public static void updateNavigationWorld(
     org.bukkit.entity.Entity entity, org.bukkit.World world) {
   if (NAVIGATION_WORLD_FIELD == null) return;
   Entity en = ((CraftEntity) entity).getHandle();
   if (!(en instanceof EntityInsentient)) return;
   EntityInsentient handle = (EntityInsentient) en;
   World worldHandle = ((CraftWorld) world).getHandle();
   try {
     NAVIGATION_WORLD_FIELD.set(handle.getNavigation(), worldHandle);
   } catch (Exception e) {
     Messaging.logTr(Messages.ERROR_UPDATING_NAVIGATION_WORLD, e.getMessage());
   }
 }
Esempio n. 2
0
 public static void setDestination(
     org.bukkit.entity.Entity entity, double x, double y, double z, float speed) {
   Entity handle = ((CraftEntity) entity).getHandle();
   if (handle instanceof EntityInsentient) {
     ((EntityInsentient) handle).getControllerMove().a(x, y, z, speed);
   } else if (handle instanceof EntityHumanNPC) {
     ((EntityHumanNPC) handle).setMoveDestination(x, y, z, speed);
   }
 }
Esempio n. 3
0
 public static void look(Entity handle, Entity target) {
   if (handle instanceof EntityInsentient) {
     ((EntityInsentient) handle)
         .getControllerLook()
         .a(target, 10.0F, ((EntityInsentient) handle).x());
   } else if (handle instanceof EntityHumanNPC) {
     ((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F);
   }
 }
Esempio n. 4
0
 public static void updatePathfindingRange(NPC npc, float pathfindingRange) {
   if (!npc.isSpawned() || !npc.getEntity().getType().isAlive()) return;
   EntityLiving en = ((CraftLivingEntity) npc.getEntity()).getHandle();
   if (!(en instanceof EntityInsentient)) {
     if (en instanceof EntityHumanNPC) {
       ((EntityHumanNPC) en).updatePathfindingRange(pathfindingRange);
     }
     return;
   }
   if (PATHFINDING_RANGE == null) return;
   EntityInsentient handle = (EntityInsentient) en;
   Navigation navigation = handle.getNavigation();
   try {
     AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
     inst.setValue(pathfindingRange);
   } catch (IllegalArgumentException e) {
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     e.printStackTrace();
   }
 }
Esempio n. 5
0
 public static void updateAI(EntityLiving entity) {
   if (entity instanceof EntityInsentient) {
     EntityInsentient handle = (EntityInsentient) entity;
     handle.getEntitySenses().a();
     NMS.updateNavigation(handle.getNavigation());
     handle.getControllerMove().c();
     handle.getControllerLook().a();
     handle.getControllerJump().b();
   } else if (entity instanceof EntityHumanNPC) {
     ((EntityHumanNPC) entity).updateAI();
   }
 }
Esempio n. 6
0
 public static boolean isEquipment(ItemStack itemstack) {
   int slot = EntityInsentient.b(itemstack);
   if (slot == 0) {
     if (itemstack.getItem() instanceof ItemSword) {
       return true;
     } else if (itemstack.getItem() instanceof ItemAxe) {
       return true;
     } else if (itemstack.getItem() instanceof ItemSpade) {
       return true;
     } else if (itemstack.getItem() instanceof ItemHoe) {
       return true;
     } else if (itemstack.getItem() instanceof ItemPickaxe) {
       return true;
     } else if (itemstack.getItem() instanceof ItemBow) {
       return true;
     }
     return false;
   }
   return true;
 }