@@ -0,0 +1,3509 @@
+package com.infinityraider.infinitylib.utility;%0A%0Aimport com.infinityraider.infinitylib.InfinityLib;%0Aimport net.minecraft.entity.MobEntity;%0Aimport net.minecraft.entity.ai.goal.Goal;%0Aimport net.minecraft.entity.ai.goal.GoalSelector;%0Aimport net.minecraft.entity.ai.goal.PrioritizedGoal;%0Aimport net.minecraftforge.fml.common.ObfuscationReflectionHelper;%0A%0Aimport javax.annotation.Nullable;%0Aimport java.lang.reflect.Field;%0Aimport java.lang.reflect.Modifier;%0Aimport java.util.Set;%0A%0Apublic class EntityHelper %7B%0A    private static final Field goalsField;%0A    private static final Field priorityField;%0A%0A    public static boolean injectGoal(MobEntity entity, Goal goal, int priority) %7B%0A        if(incrementPriorities(entity.goalSelector, priority)) %7B%0A            entity.goalSelector.addGoal(priority, goal);%0A            return true;%0A        %7D%0A        return false;%0A    %7D%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    private static boolean incrementPriorities(GoalSelector selector, int priority) %7B%0A        if(goalsField == null) %7B%0A            InfinityLib.instance.getLogger().error(%22Could not increment priorities, goals field not retrieved%22);%0A            return false;%0A        %7D%0A        if(priorityField == null) %7B%0A            InfinityLib.instance.getLogger().error(%22Could not increment priorities, priority field not retrieved%22);%0A            return false;%0A        %7D%0A        try %7B%0A            Set%3CPrioritizedGoal%3E goals = (Set%3CPrioritizedGoal%3E) goalsField.get(selector);%0A            return goals.stream().filter(goal -%3E goal.getPriority() %3E= priority).allMatch(goal -%3E %7B%0A                try %7B%0A                    priorityField.set(selector, ((int) priorityField.get(selector)) + 1);%0A                    return true;%0A                %7D catch(Exception e) %7B%0A                    InfinityLib.instance.getLogger().error(%22Failed to increment priority%22);%0A                    InfinityLib.instance.getLogger().printStackTrace(e);%0A                    return false;%0A                %7D%0A            %7D);%0A        %7D catch (Exception e) %7B%0A            InfinityLib.instance.getLogger().error(%22Encountered error while getting the goals from the GoalSelector%22);%0A            InfinityLib.instance.getLogger().printStackTrace(e);%0A            return false;%0A        %7D%0A    %7D%0A%0A    static %7B%0A        goalsField = initGoalsField();%0A        priorityField = initPriorityField();%0A    %7D%0A%0A    @Nullable%0A    private static Field initGoalsField() %7B%0A        try %7B%0A            return ObfuscationReflectionHelper.findField(GoalSelector.class, %22field_220892_d%22);%0A        %7D catch (Exception e) %7B%0A            InfinityLib.instance.getLogger().error(%22Could not retrieve Goals field from GoalSelector.class%22);%0A            InfinityLib.instance.getLogger().printStackTrace(e);%0A            return null;%0A        %7D%0A    %7D%0A%0A    private static Field initPriorityField() %7B%0A        try %7B%0A            // Retrieve field%0A            Field field = ObfuscationReflectionHelper.findField(PrioritizedGoal.class, %22field_220775_b%22);%0A            // Remove final modifier%0A            Field modifiersField = Field.class.getDeclaredField(%22modifiers%22);%0A            modifiersField.setAccessible(true);%0A            modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);%0A            // Return the field%0A            return field;%0A        %7D catch (Exception e) %7B%0A            InfinityLib.instance.getLogger().error(%22Could not retrieve Priority field from PrioritizedGoal.class%22);%0A            InfinityLib.instance.getLogger().printStackTrace(e);%0A            return null;%0A        %7D%0A    %7D%0A%7D%0A

Add an EntityHelper utility class