mirror of
https://github.com/FatherToast/SpecialMobs.git
synced 2025-04-25 14:55:03 +00:00
AI helper + related AT entries
This commit is contained in:
parent
9c6eb7bbfb
commit
dd71999fd5
3 changed files with 41 additions and 1 deletions
|
@ -0,0 +1,35 @@
|
|||
package fathertoast.specialmobs.common.entity.ai;
|
||||
|
||||
import net.minecraft.entity.ai.goal.Goal;
|
||||
import net.minecraft.entity.ai.goal.GoalSelector;
|
||||
import net.minecraft.entity.ai.goal.PrioritizedGoal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Provides helper methods for adjusting pre-defined AI goals.
|
||||
*/
|
||||
public final class AIHelper {
|
||||
|
||||
/** Inserts an AI goal at the specified priority. Existing goals have their priority adjusted accordingly. */
|
||||
public static void insertGoal( GoalSelector ai, int priority, Goal goal ) {
|
||||
for( PrioritizedGoal task : new ArrayList<>( ai.availableGoals ) ) {
|
||||
if( task.getPriority() >= priority ) task.priority++;
|
||||
}
|
||||
ai.addGoal( priority, goal );
|
||||
}
|
||||
|
||||
/** Removes all goals with the specified priority. */
|
||||
public static void removeGoals( GoalSelector ai, int priority ) {
|
||||
for( PrioritizedGoal task : new ArrayList<>( ai.availableGoals ) ) {
|
||||
if( task.getPriority() == priority ) ai.removeGoal( task.getGoal() );
|
||||
}
|
||||
}
|
||||
|
||||
/** Removes all goals of the specified type. */
|
||||
public static void removeGoals( GoalSelector ai, Class<? extends Goal> goalType ) {
|
||||
for( PrioritizedGoal task : new ArrayList<>( ai.availableGoals ) ) {
|
||||
if( task.getGoal().getClass().equals( goalType ) ) ai.removeGoal( task.getGoal() );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package fathertoast.specialmobs.common.entity.creeper;
|
|||
|
||||
import fathertoast.specialmobs.common.bestiary.BestiaryInfo;
|
||||
import fathertoast.specialmobs.common.bestiary.SpecialMob;
|
||||
import fathertoast.specialmobs.common.entity.ai.AIHelper;
|
||||
import fathertoast.specialmobs.common.entity.ai.SpecialLeapAtTargetGoal;
|
||||
import fathertoast.specialmobs.common.util.AttributeHelper;
|
||||
import fathertoast.specialmobs.common.util.References;
|
||||
|
@ -62,7 +63,7 @@ public class JumpingCreeperEntity extends _SpecialCreeperEntity {
|
|||
/** Override to change this entity's AI goals. */
|
||||
@Override
|
||||
protected void registerVariantGoals() {
|
||||
goalSelector.addGoal( 3, new SpecialLeapAtTargetGoal(
|
||||
AIHelper.insertGoal( goalSelector, 4, new SpecialLeapAtTargetGoal(
|
||||
this, 10, 6.0F, 10.0F, 1.3F, 2.0F ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
public net.minecraft.entity.EntityType field_233593_bg_ # immuneTo
|
||||
public net.minecraft.entity.ai.attributes.AttributeModifierMap$MutableAttribute field_233811_a_ # builder
|
||||
|
||||
# AI Goals
|
||||
public net.minecraft.entity.ai.goal.GoalSelector field_220892_d #availableGoals
|
||||
public-f net.minecraft.entity.ai.goal.PrioritizedGoal field_220775_b #priority
|
||||
|
||||
# Creepers
|
||||
protected net.minecraft.entity.monster.CreeperEntity field_184714_b # DATA_IS_POWERED
|
||||
protected net.minecraft.entity.monster.CreeperEntity field_184715_c # DATA_IS_IGNITED
|
||||
|
|
Loading…
Add table
Reference in a new issue