<commit_before>package derpatiel.progressivediff.controls;

import derpatiel.progressivediff.DifficultyControl;
import derpatiel.progressivediff.DifficultyManager;
import derpatiel.progressivediff.MultiplePlayerCombineType;
import derpatiel.progressivediff.SpawnEventDetails;
import derpatiel.progressivediff.util.LOG;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatList;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.fml.common.registry.EntityRegistry;

import java.util.List;

public class SpecificMobKilledControl extends DifficultyControl {

    private static final String IDENTIFIER = "CONTROL_KILLED_SPECIFIC_MOB";

    private MultiplePlayerCombineType type;
    private double difficultyPerHundredKills;

    public SpecificMobKilledControl(MultiplePlayerCombineType type, double difficultyPerHundredKills){
        this.type = type;
        this.difficultyPerHundredKills = difficultyPerHundredKills;
    }

    @Override
    public int getChangeForSpawn(SpawnEventDetails details) {
        List<EntityPlayerMP> playersInRange = details.entity.getEntityWorld().getEntitiesWithinAABB(EntityPlayerMP.class, details.entity.getEntityBoundingBox().expand(128,128,128));
        int killedMobs = 0;
        EntityList.EntityEggInfo eggInfo = EntityRegistry.getEntry(details.entity.getClass()).getEgg();
        StatBase stat = eggInfo.killEntityStat;
        if(playersInRange.size()>0) {
            switch (type) {
                case AVERAGE:
                    int avgSum = 0;
                    for (EntityPlayerMP player : playersInRange) {

                        int killed = player.getStatFile().readStat(stat);
                        avgSum += killed;
                    }
                    killedMobs = avgSum / playersInRange.size();
                    break;
                case CLOSEST:
                    EntityPlayerMP closestPlayer = (EntityPlayerMP) details.entity.getEntityWorld().getClosestPlayerToEntity(details.entity, 128.0d);
                    killedMobs = closestPlayer.getStatFile().readStat(stat);
                    break;
                case MAX:
                    int max = 0;
                    for (EntityPlayerMP player : playersInRange) {
                        int killed = player.getStatFile().readStat(stat);
                        if (killed > max) {
                            max = killed;
                        }
                    }
                    killedMobs = max;
                    break;<commit_msg>fix crash if an entity doesn't have a spawn egg<commit_after>package derpatiel.progressivediff.controls;

import derpatiel.progressivediff.DifficultyControl;
import derpatiel.progressivediff.DifficultyManager;
import derpatiel.progressivediff.MultiplePlayerCombineType;
import derpatiel.progressivediff.SpawnEventDetails;
import derpatiel.progressivediff.util.LOG;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatList;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.fml.common.registry.EntityRegistry;

import java.util.List;

public class SpecificMobKilledControl extends DifficultyControl {

    private static final String IDENTIFIER = "CONTROL_KILLED_SPECIFIC_MOB";

    private MultiplePlayerCombineType type;
    private double difficultyPerHundredKills;

    public SpecificMobKilledControl(MultiplePlayerCombineType type, double difficultyPerHundredKills){
        this.type = type;
        this.difficultyPerHundredKills = difficultyPerHundredKills;
    }

    @Override
    public int getChangeForSpawn(SpawnEventDetails details) {
        List<EntityPlayerMP> playersInRange = details.entity.getEntityWorld().getEntitiesWithinAABB(EntityPlayerMP.class, details.entity.getEntityBoundingBox().expand(128,128,128));
        int killedMobs = 0;
        EntityList.EntityEggInfo eggInfo = EntityRegistry.getEntry(details.entity.getClass()).getEgg();
        if(eggInfo==null)
            return 0;
        StatBase stat = eggInfo.killEntityStat;
        if(playersInRange.size()>0) {
            switch (type) {
                case AVERAGE:
                    int avgSum = 0;
                    for (EntityPlayerMP player : playersInRange) {

                        int killed = player.getStatFile().readStat(stat);
                        avgSum += killed;
                    }
                    killedMobs = avgSum / playersInRange.size();
                    break;
                case CLOSEST:
                    EntityPlayerMP closestPlayer = (EntityPlayerMP) details.entity.getEntityWorld().getClosestPlayerToEntity(details.entity, 128.0d);
                    killedMobs = closestPlayer.getStatFile().readStat(stat);
                    break;
                case MAX:
                    int max = 0;
                    for (EntityPlayerMP player : playersInRange) {
                        int killed = player.getStatFile().readStat(stat);
                        if (killed > max) {
                            max = killed;
                        }
                    }
                    killedMobs = max;
                    break;
{'fraction_non_alphanumeric': 0.07734204793028322, 'fraction_numerical': 0.0063543936092955704, 'mean_word_length': 2.419615145872129, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4743457', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1423, 'n_words': 261}