Search in sources :

Example 6 with PathfinderGoalSelector

use of net.minecraft.server.v1_12_R1.PathfinderGoalSelector in project UltraCosmetics by iSach.

the class MountCustomEntity method removeAI.

private void removeAI(EntityInsentient entity) {
    try {
        Field bField = PathfinderGoalSelector.class.getDeclaredField("b");
        bField.setAccessible(true);
        Field cField = PathfinderGoalSelector.class.getDeclaredField("c");
        cField.setAccessible(true);
        bField.set(entity.goalSelector, new UnsafeList<PathfinderGoalSelector>());
        bField.set(entity.targetSelector, new UnsafeList<PathfinderGoalSelector>());
        cField.set(entity.goalSelector, new UnsafeList<PathfinderGoalSelector>());
        cField.set(entity.targetSelector, new UnsafeList<PathfinderGoalSelector>());
    } catch (ReflectiveOperationException exc) {
        exc.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) PathfinderGoalSelector(net.minecraft.server.v1_8_R3.PathfinderGoalSelector)

Example 7 with PathfinderGoalSelector

use of net.minecraft.server.v1_12_R1.PathfinderGoalSelector in project UltraCosmetics by iSach.

the class EntityUtil method clearPathfinders.

@Override
public void clearPathfinders(Entity entity) {
    EntityInsentient entitySheep = (EntityInsentient) ((CraftEntity) entity).getHandle();
    try {
        Field bField = PathfinderGoalSelector.class.getDeclaredField("b");
        bField.setAccessible(true);
        Field cField = PathfinderGoalSelector.class.getDeclaredField("c");
        cField.setAccessible(true);
        bField.set(entitySheep.goalSelector, new UnsafeList<PathfinderGoalSelector>());
        bField.set(entitySheep.targetSelector, new UnsafeList<PathfinderGoalSelector>());
        cField.set(entitySheep.goalSelector, new UnsafeList<PathfinderGoalSelector>());
        cField.set(entitySheep.targetSelector, new UnsafeList<PathfinderGoalSelector>());
    } catch (Exception exc) {
        exc.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) EntityInsentient(net.minecraft.server.v1_8_R3.EntityInsentient) PathfinderGoalSelector(net.minecraft.server.v1_8_R3.PathfinderGoalSelector)

Example 8 with PathfinderGoalSelector

use of net.minecraft.server.v1_12_R1.PathfinderGoalSelector in project PaperDev by Kamillaova.

the class CraftRabbit method setRabbitType.

@Override
public void setRabbitType(Type type) {
    EntityRabbit entity = getHandle();
    if (getRabbitType() == Type.THE_KILLER_BUNNY) {
        // Reset goals and target finders.
        World world = ((CraftWorld) this.getWorld()).getHandle();
        entity.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
        entity.targetSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
        entity.initializePathFinderGoals();
    }
    entity.setRabbitType(CraftMagicMapping.toMagic(type));
}
Also used : EntityRabbit(net.minecraft.server.v1_12_R1.EntityRabbit) PathfinderGoalSelector(net.minecraft.server.v1_12_R1.PathfinderGoalSelector) World(net.minecraft.server.v1_12_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 9 with PathfinderGoalSelector

use of net.minecraft.server.v1_12_R1.PathfinderGoalSelector in project Citizens2 by CitizensDev.

the class NMSImpl method clearGoals.

public static void clearGoals(PathfinderGoalSelector... goalSelectors) {
    if (GOAL_FIELD == null || goalSelectors == null)
        return;
    for (PathfinderGoalSelector selector : goalSelectors) {
        try {
            Collection<?> list = (Collection<?>) GOAL_FIELD.get(selector);
            list.clear();
        } catch (Exception e) {
            Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
        }
    }
}
Also used : Collection(java.util.Collection) PathfinderGoalSelector(net.minecraft.server.v1_8_R3.PathfinderGoalSelector) ReportedException(net.minecraft.server.v1_8_R3.ReportedException) CommandException(net.citizensnpcs.api.command.exception.CommandException)

Example 10 with PathfinderGoalSelector

use of net.minecraft.server.v1_12_R1.PathfinderGoalSelector in project Citizens2 by CitizensDev.

the class NMSImpl method clearGoals.

public static void clearGoals(PathfinderGoalSelector... goalSelectors) {
    if (GOAL_FIELD == null || goalSelectors == null)
        return;
    for (PathfinderGoalSelector selector : goalSelectors) {
        try {
            Collection<?> list = (Collection<?>) GOAL_FIELD.get(selector);
            list.clear();
        } catch (Exception e) {
            Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
        }
    }
}
Also used : Collection(java.util.Collection) PathfinderGoalSelector(net.minecraft.server.v1_10_R1.PathfinderGoalSelector) ReportedException(net.minecraft.server.v1_10_R1.ReportedException) CommandException(net.citizensnpcs.api.command.exception.CommandException)

Aggregations

Collection (java.util.Collection)10 CommandException (net.citizensnpcs.api.command.exception.CommandException)10 Field (java.lang.reflect.Field)3 PathfinderGoalSelector (net.minecraft.server.v1_8_R3.PathfinderGoalSelector)3 PathfinderGoalSelector (net.minecraft.server.v1_12_R1.PathfinderGoalSelector)2 PathPoint (net.minecraft.server.v1_15_R1.PathPoint)2 PathfinderGoalSelector (net.minecraft.server.v1_15_R1.PathfinderGoalSelector)2 ReportedException (net.minecraft.server.v1_15_R1.ReportedException)2 PathPoint (net.minecraft.server.v1_16_R3.PathPoint)2 PathfinderGoalSelector (net.minecraft.server.v1_16_R3.PathfinderGoalSelector)2 ReportedException (net.minecraft.server.v1_16_R3.ReportedException)2 ISoliniaClass (com.solinia.solinia.Interfaces.ISoliniaClass)1 Set (java.util.Set)1 PathfinderGoalSelector (net.minecraft.server.v1_10_R1.PathfinderGoalSelector)1 ReportedException (net.minecraft.server.v1_10_R1.ReportedException)1 PathfinderGoalSelector (net.minecraft.server.v1_11_R1.PathfinderGoalSelector)1 ReportedException (net.minecraft.server.v1_11_R1.ReportedException)1 EntityCreature (net.minecraft.server.v1_12_R1.EntityCreature)1 EntityRabbit (net.minecraft.server.v1_12_R1.EntityRabbit)1 EntityTameableAnimal (net.minecraft.server.v1_12_R1.EntityTameableAnimal)1