How could I make a hostile mob able to acquire and track targets that are further than the default limit of 16 blocks?
Plugers11 There was a similar thread a while ago: https://forums.bukkit.org/threads/extending-a-hostile-mobs-awareness.71000/
2012 ? :F I have question GameplayJDK That : https://forums.bukkit.org/threads/tutorial-increasing-pathfinding-range-of-an-entity.177678/ Could work to get more range to go specific location?
Plugers11 Hmm... It's 1.6 code, possibly some classes and fields got renamed.. But it should do the thing I don't know if this code is still working, it's from 2012 too :/ Code:java private boolean livingEntityMoveTo(LivingEntity livingEntity, double x, double y, double z, float speed) {return ((org.bukkit.craftbukkit.entity.CraftLivingEntity)livingEntity).getHandle().getNavigation().a(x, y, z, speed);}
Plugers11 Possibly you can try to navigate the mob step by step.. calculate the next position within 16 blocks, then the next and than the next again..
Plugers11 I have ever been someone who trys to avoid working with nms too much because the resulting solutions are not very version persistent and cause a lot of updating work, so I'm not that familiar with the possibilities.. :/
zombiekiller753 How to set to go on location ? I have this: But how do this for my creeper? Code: import java.lang.reflect.Field; import net.minecraft.server.v1_7_R3.EntityInsentient; import net.minecraft.server.v1_7_R3.PathEntity; import net.minecraft.server.v1_7_R3.PathfinderGoal; import net.minecraft.server.v1_7_R3.PathfinderGoalFloat; import net.minecraft.server.v1_7_R3.PathfinderGoalSelector; import org.bukkit.craftbukkit.v1_7_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_7_R3.util.UnsafeList; import org.bukkit.entity.LivingEntity; public class WalkToLocation { private static Field gsa; private static Field goalSelector; private static Field targetSelector; static { try { gsa = PathfinderGoalSelector.class.getDeclaredField("b"); gsa.setAccessible(true); goalSelector = EntityInsentient.class.getDeclaredField("goalSelector"); goalSelector.setAccessible(true); targetSelector = EntityInsentient.class.getDeclaredField("targetSelector"); targetSelector.setAccessible(true); } catch (Exception e) { e.printStackTrace(); } } @SuppressWarnings("deprecation") public static void gotoLoc(LivingEntity e) { try { Object nms_entity = ((CraftLivingEntity) e).getHandle(); if (nms_entity instanceof EntityInsentient) { PathfinderGoalSelector goal = (PathfinderGoalSelector) goalSelector.get(nms_entity); PathfinderGoalSelector target = (PathfinderGoalSelector) targetSelector.get(nms_entity); gsa.set(goal, new UnsafeList<Object>()); gsa.set(target, new UnsafeList<Object>()); goal.a(0, new PathfinderGoalFloat((EntityInsentient) nms_entity)); goal.a(1, new PathfinderGoalWalktoTile((EntityInsentient) nms_entity)); } else { throw new IllegalArgumentException(e.getType().getName() + " is not an instance of an EntityInsentient."); } } catch (Exception ex) { ex.printStackTrace(); } } public static void gotoLocCreep(CustomCreeper e) { try { Object nms_entity = e.getBukkitEntity(); if (nms_entity instanceof EntityInsentient) { PathfinderGoalSelector goal = (PathfinderGoalSelector) goalSelector.get(nms_entity); PathfinderGoalSelector target = (PathfinderGoalSelector) targetSelector.get(nms_entity); gsa.set(goal, new UnsafeList<Object>()); gsa.set(target, new UnsafeList<Object>()); goal.a(0, new PathfinderGoalFloat((EntityInsentient) nms_entity)); goal.a(1, new PathfinderGoalWalktoTile((EntityInsentient) nms_entity)); } } catch (Exception ex) { ex.printStackTrace(); } } public static class PathfinderGoalWalktoTile extends PathfinderGoal { public EntityInsentient entity; public PathEntity path; public PathfinderGoalWalktoTile(EntityInsentient entitycreature) { this.entity = entitycreature; } @Override public boolean a() { boolean flag = this.entity.getNavigation().c(); this.entity.getNavigation().b(false); this.path = this.entity.getNavigation().a(425 , 83, 402); System.out.println(path); this.entity.getNavigation().b(flag); if (this.path != null) { this.c(); } return this.path != null; } @Override public void c() { this.entity.getNavigation().a(this.path, 0.8D); } } } This can be for walk to location of mob ? Code: import net.minecraft.server.v1_7_R3.EntityInsentient; import net.minecraft.server.v1_7_R3.Navigation; import net.minecraft.server.v1_7_R3.PathEntity; import net.minecraft.server.v1_7_R3.PathfinderGoal; import org.bukkit.Location; public class PathfinderGoalWalkToLoc extends PathfinderGoal { private double speed; private EntityInsentient entity; private Location loc; private Navigation navigation; public PathfinderGoalWalkToLoc(EntityInsentient entity, Location loc, double speed) { this.entity = entity; this.loc = loc; this.navigation = this.entity.getNavigation(); this.speed = speed; } public boolean a() { return true; } public void c() { PathEntity pathEntity = this.navigation.a(loc.getX(), loc.getY(), loc.getZ()); this.navigation.a(pathEntity, speed); } } Code: public CustomCreeper(net.minecraft.server.v1_7_R3.World world) { super(world); this.getAttributeInstance(GenericAttributes.a).setValue(48.0D); this.goalSelector.a(1, new PathfinderGoalWalkToLoc(this, getToLocation(), 2D)); } Ok i solved go to location but now i'm waiting for this range @zombiekiller753 I think it's done :3 I must do attribute protected void aC() { super.aC(); this.getAttributeInstance(GenericAttributes.b).setValue(100.0D); } EDIT by Moderator: merged posts, please use the edit button instead of double posting.