Search in sources :

Example 1 with EntityAISit

use of net.minecraft.entity.ai.EntityAISit in project Railcraft by Railcraft.

the class EntityAIMateBreeding method modifyAI.

public static void modifyAI(EntityAnimal animal) {
    boolean tame = animal instanceof EntityTameable;
    int matePriority = -1;
    int sitPriority = -1;
    boolean hasDespawn = false;
    Iterator<EntityAITaskEntry> it = animal.tasks.taskEntries.iterator();
    while (it.hasNext()) {
        EntityAITaskEntry task = it.next();
        if (tame && task.action instanceof EntityAISit) {
            sitPriority = task.priority;
            it.remove();
        } else if (task.action instanceof EntityAIMate) {
            matePriority = task.priority;
            it.remove();
        } else if (task.action instanceof EntityAIDespawn) {
            hasDespawn = true;
        }
    }
    if (tame) {
        ((EntityTameable) animal).setTamed(true);
    }
    if (!hasDespawn) {
        animal.tasks.addTask(0, new EntityAIDespawn(animal));
    }
    if (matePriority > 0) {
        animal.tasks.addTask(matePriority, new EntityAIMateBreeding(animal, 0.25f));
        if (tame) {
            animal.tasks.addTask(6, new EntityAISitRandom((EntityTameable) animal));
        }
    }
    if (sitPriority > 0) {
        EntityAISitBred aiSit = new EntityAISitBred((EntityTameable) animal);
        animal.tasks.addTask(sitPriority, aiSit);
        //            ObfuscationReflectionHelper.setPrivateValue(EntityTameable.class, (EntityTameable)animal, aiSit, "d", "aiSit");
        ObfuscationReflectionHelper.setPrivateValue(EntityTameable.class, (EntityTameable) animal, aiSit, 0);
    }
}
Also used : EntityAISit(net.minecraft.entity.ai.EntityAISit) EntityAIMate(net.minecraft.entity.ai.EntityAIMate) EntityAITaskEntry(net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)

Aggregations

EntityAIMate (net.minecraft.entity.ai.EntityAIMate)1 EntityAISit (net.minecraft.entity.ai.EntityAISit)1 EntityAITaskEntry (net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)1