<commit_before>package derpatiel.progressivediff;

import com.google.common.collect.Maps;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.world.World;

import java.util.Map;

public class MobUpkeepController {

    private static final int UPKEEP_INTERVAL = 10;
    public static final int POTION_EFFECT_LENGTH = 15;

    private static final Map<Integer,Map<String,Integer>> storedChangeMap = Maps.newHashMap();

    private static int upkeepCount=0;

    public static void register(EntityLiving mob, Map<String,Integer> changes){
        storedChangeMap.put(mob.getEntityId(),changes);
    }

    public static void tick(World world){
        upkeepCount++;
        if(upkeepCount>=UPKEEP_INTERVAL){
            upkeepCount=0;
            doUpkeep(world);
        }
    }

    private static void doUpkeep(World world){
        for(int entityId : storedChangeMap.keySet()) {
            Entity entity = world.getEntityByID(entityId);
            if(entity==null || entity.isDead || !(entity instanceof EntityLiving)){
                continue;
            }
            Map<String,Integer> changes = storedChangeMap.get(entityId);
            for(String change : changes.keySet()){
                DifficultyModifier modifier = DifficultyManager.getModifierById(change);
                modifier.makeChange(changes.get(change),(EntityLiving)entity,true);
            }
        }
    }
}<commit_msg>add note to self about a bug<commit_after>package derpatiel.progressivediff;

import com.google.common.collect.Maps;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.world.World;

import java.util.Map;

public class MobUpkeepController {

    private static final int UPKEEP_INTERVAL = 10;
    public static final int POTION_EFFECT_LENGTH = 15;

    private static final Map<Integer,Map<String,Integer>> storedChangeMap = Maps.newHashMap();

    private static int upkeepCount=0;

    public static void register(EntityLiving mob, Map<String,Integer> changes){
        storedChangeMap.put(mob.getEntityId(),changes);
    }

    public static void tick(World world){
        upkeepCount++;
        if(upkeepCount>=UPKEEP_INTERVAL){
            upkeepCount=0;
            doUpkeep(world);
        }
    }

    private static void doUpkeep(World world){
        for(int entityId : storedChangeMap.keySet()) {
            Entity entity = world.getEntityByID(entityId);
            if(entity==null || entity.isDead || !(entity instanceof EntityLiving)){
                continue;//TODO: remove entry, because it's no longer valid
                //also todo: what about unload/reload?
            }
            Map<String,Integer> changes = storedChangeMap.get(entityId);
            for(String change : changes.keySet()){
                DifficultyModifier modifier = DifficultyManager.getModifierById(change);
                modifier.makeChange(changes.get(change),(EntityLiving)entity,true);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09722222222222222, 'fraction_numerical': 0.003968253968253968, 'mean_word_length': 2.8981958762886597, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '5325091', 'n_tokens_mistral': 857, 'n_tokens_neox': 829, 'n_words': 180}