package totemic_commons.pokefenn.ceremony;

import net.minecraft.entity.passive.EntityCow;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import totemic_commons.pokefenn.api.ceremony.Ceremony;
import totemic_commons.pokefenn.api.music.MusicInstrument;
import totemic_commons.pokefenn.entity.animal.EntityBuffalo;
import totemic_commons.pokefenn.util.EntityUtil;

public class CeremonyBuffaloDance extends Ceremony
{
    public CeremonyBuffaloDance(String name, int musicNeeded, int maxStartupTime, MusicInstrument... instruments)
    {
        super(name, musicNeeded, maxStartupTime, instruments);
    }

    @Override
    public void effect(World world, BlockPos pos, int time)
    {
        if(world.isRemote)
            return;

        EntityUtil.getEntitiesInRange(EntityCow.class, world, pos, 8, 8).stream()
            .filter(entity -> !(entity instanceof EntityBuffalo))
            .limit(2)
            .forEach(cow -> {
                EntityBuffalo buffalo = new EntityBuffalo(world);
                float health = cow.getHealth() / cow.getMaxHealth() * buffalo.getMaxHealth();
                buffalo.setHealth(health);
                EntityUtil.spawnEntity(world, cow.posX, cow.posY, cow.posZ, buffalo);
                cow.setDead();
            });
    }
}

@@ -37,16 +37,90 @@
 emony;%0A%0A
+import java.util.List;%0A%0Aimport net.minecraft.entity.passive.EntityAnimal;%0A
 import n
@@ -158,16 +158,16 @@
 ityCow;%0A
-
 import n
@@ -233,16 +233,61 @@
 .World;%0A
+import net.minecraftforge.fml.common.Loader;%0A
 import t
@@ -886,55 +886,16 @@
     
-EntityUtil.getEntitiesInRange(EntityCow.class, 
+getCows(
 worl
@@ -905,11 +905,8 @@
 pos,
- 8,
  8).
@@ -918,74 +918,8 @@
 m()%0A
-            .filter(entity -%3E !(entity instanceof EntityBuffalo))%0A
     
@@ -1282,24 +1282,24 @@
 .setDead();%0A
-
             
@@ -1307,11 +1307,729 @@
 );%0A    %7D
+%0A%0A    private static List%3C? extends EntityAnimal%3E getCows(World world, BlockPos pos, int range)%0A    %7B%0A        if(!Loader.isModLoaded(%22animania%22))%0A            return EntityUtil.getEntitiesInRange(EntityCow.class, world, pos, range, range, entity -%3E !(entity instanceof EntityBuffalo));%0A        else //Animania compatibility%0A            return EntityUtil.getEntitiesInRange(EntityAnimal.class, world, pos, range, range, entity -%3E%0A                  (entity instanceof EntityCow && !(entity instanceof EntityBuffalo))%0A                %7C%7C entity.getClass().getName().startsWith(%22com.animania.entities.cows.EntityBull%22)%0A                %7C%7C entity.getClass().getName().startsWith(%22com.animania.entities.cows.EntityCow%22));%0A    %7D
 %0A%7D%0A

Add compatibility with Animania cows. Closes #45