Pet Blaze in 1.9.4

Discussion in 'Spigot Plugin Development' started by nokoa, Jun 25, 2016.

  1. Hey, I am just getting started with NMS and wanted to make a pet Blaze.

    The entity will follow a specific player and will attack players whom harm self or owner and when the owner attacks another player, except the owner it self.

    I tried to use an older method from 1.7 which did not appear to work.

    I am looking to achieve this in 1.9.4.

    How should I do this?
  2. Choco


    Is this there not a PathfinderGoal for this? This is the behaviour that wolves do if I'm not mistaken
  3. I tried to use this:

    Code (Text):

        public static void makePet(LivingEntity e, UUID toFollow) {
            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, toFollow));
                } else {
                    throw new IllegalArgumentException(e.getType().getName() + " is not an instance of an EntityInsentient.");
            } catch (Exception ex) {

        public static class PathfinderGoalWalktoTile extends PathfinderGoal {
            private EntityInsentient entity;
            private PathEntity path;
            private UUID p;

            public PathfinderGoalWalktoTile(EntityInsentient entitycreature, UUID p) {
                this.entity = entitycreature;
                this.p = p;

            public boolean a() {
                if (Bukkit.getPlayer(p) == null) {
                    MessageUtil.d("Player to follow is null");
                    return path != null;
                Location targetLocation = Bukkit.getPlayer(p).getLocation();
                boolean flag = this.entity.getNavigation().n();
                this.path = this.entity.getNavigation().a(targetLocation.getX() + 1, targetLocation.getY(), targetLocation.getZ() + 1);
                if (this.path != null) {
                return this.path != null;

            public void c() {
                this.entity.getNavigation().a(this.path, 1D);
  4. I am trying to set it up a custom entity class but Blaze is not tamable and cannot have an owner. How can I manipulate that action?
  5. Make it artificially tameable, then. Add a listener for right clicking it with whatever item you want, and then set the owner in your custom blaze class to that player. Now that's their owner, and make the pet follow them.
    • Like Like x 2
  6. Okay I think I am having another issue. Where should I set Path Finder Goals, in the constructor of the class which is extending "EntityBlaze" or overriding the method r in that class?
  7. Either one works