NMS help, Pathfinder

Discussion in 'Plugin Development' started by glory_fades, Feb 2, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    glory_fades

    So im trying to make my zombie walk to a certain location, and all of the generic attributes work but the pathfinders do not

    here is my CustomEntityZombie class
    Code:
    package Main;
    import java.lang.reflect.Field;
    
    import net.minecraft.server.v1_7_R4.EntityHuman;
    import net.minecraft.server.v1_7_R4.EntityInsentient;
    import net.minecraft.server.v1_7_R4.EntitySkeleton;
    import net.minecraft.server.v1_7_R4.EntityZombie;
    import net.minecraft.server.v1_7_R4.GenericAttributes;
    import net.minecraft.server.v1_7_R4.Navigation;
    import net.minecraft.server.v1_7_R4.PathfinderGoalNearestAttackableTarget;
    import net.minecraft.server.v1_7_R4.World;
    
    import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
    import org.bukkit.craftbukkit.v1_7_R4.util.UnsafeList;
    import org.bukkit.entity.EntityType;
    
    import com.avaje.ebean.enhance.asm.Attribute;
    public class CustomEntityZombie extends EntityZombie {
    float speed;
    public CustomEntityZombie(World world) {
    super(world);
    try {
        Field gsa = net.minecraft.server.v1_7_R4.PathfinderGoalSelector.class.getDeclaredField("a");
        gsa.setAccessible(true);
    Field bField = PathfinderGoalSelector.class.getDeclaredField("b");
    bField.setAccessible(true);
    Field cField = PathfinderGoalSelector.class.getDeclaredField("c");
    cField.setAccessible(true);
    bField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
    bField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
    cField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
    cField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
    } catch (Exception exc) {
    exc.printStackTrace();
    }
    this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true));
    this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true));
    this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntitySkeleton.class, 0, false));
    this.goalSelector.a(1, new PathfinderGoalWalktoTile(this, (float) speed));
    
    }
    @Override
    protected void aD() {
    super.aD();
    this.getAttributeInstance(GenericAttributes.b).setValue(40.0D);
    this.getAttributeInstance(GenericAttributes.d).setValue(0.23000000417232513D);
    this.getAttributeInstance(GenericAttributes.e).setValue(3.0D);
    this.getAttributeInstance(GenericAttributes.e).setValue(300.0D);
    }
    }
    PathFinderWalkToTile class

    Code:
    package Main;
    
    import net.minecraft.server.v1_7_R4.EntityCreature;
    import net.minecraft.server.v1_7_R4.PathfinderGoal;
    
    public class PathfinderGoalWalktoTile extends PathfinderGoal{
    float speed;
    private EntityCreature entitycreature;
    public PathfinderGoalWalktoTile(EntityCreature entitycreature, float speed){
    this.speed = speed;
    this.entitycreature = entitycreature;
    }
    @Override
    public boolean a() {
        if(this.entitycreature.ai() >= 100)
        {
        return false;
    }
        return false;
    }
    @Override
    public void c(){
    this.entitycreature.getNavigation().a(103, 80, -41, speed);
    
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page