<commit_before>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();
            });
    }
}
<commit_msg>Add compatibility with Animania cows. Closes #45<commit_after>package totemic_commons.pokefenn.ceremony;

import java.util.List;

import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader;
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;

        getCows(world, pos, 8).stream()
            .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();
            });
    }

    private static List<? extends EntityAnimal> getCows(World world, BlockPos pos, int range)
    {
        if(!Loader.isModLoaded("animania"))
            return EntityUtil.getEntitiesInRange(EntityCow.class, world, pos, range, range, entity -> !(entity instanceof EntityBuffalo));
        else //Animania compatibility
            return EntityUtil.getEntitiesInRange(EntityAnimal.class, world, pos, range, range, entity ->
                  (entity instanceof EntityCow && !(entity instanceof EntityBuffalo))
                || entity.getClass().getName().startsWith("com.animania.entities.cows.EntityBull")
                || entity.getClass().getName().startsWith("com.animania.entities.cows.EntityCow"));
    }
}

{'fraction_non_alphanumeric': 0.1043731778425656, 'fraction_numerical': 0.0020408163265306124, 'mean_word_length': 3.0893921334922525, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5760374', 'n_tokens_mistral': 1017, 'n_tokens_neox': 1020, 'n_words': 190}