Generalized the demon entity AI logic. Also improved the behaviour of the mimic entities.
This commit is contained in:
parent
043c4cab6a
commit
7d690ad598
11 changed files with 457 additions and 270 deletions
|
@ -4,11 +4,11 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.item.ItemBow;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
|
||||
public class EntityAIAttackRangedBow extends EntityAIBase
|
||||
{
|
||||
private final EntitySentientSpecter entity;
|
||||
private final EntityDemonBase entity;
|
||||
private final double moveSpeedAmp;
|
||||
private int attackCooldown;
|
||||
private final float maxAttackDistance;
|
||||
|
@ -18,9 +18,9 @@ public class EntityAIAttackRangedBow extends EntityAIBase
|
|||
private boolean strafingBackwards;
|
||||
private int strafingTime = -1;
|
||||
|
||||
public EntityAIAttackRangedBow(EntitySentientSpecter specter, double speedAmplifier, int delay, float maxDistance)
|
||||
public EntityAIAttackRangedBow(EntityDemonBase entityDemonBase, double speedAmplifier, int delay, float maxDistance)
|
||||
{
|
||||
this.entity = specter;
|
||||
this.entity = entityDemonBase;
|
||||
this.moveSpeedAmp = speedAmplifier;
|
||||
this.attackCooldown = delay;
|
||||
this.maxAttackDistance = maxDistance * maxDistance;
|
||||
|
|
|
@ -12,11 +12,11 @@ import net.minecraft.pathfinding.PathNodeType;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
|
||||
public class EntityAIFollowOwner extends EntityAIBase
|
||||
{
|
||||
private EntitySentientSpecter thePet;
|
||||
private EntityDemonBase thePet;
|
||||
private EntityLivingBase theOwner;
|
||||
World theWorld;
|
||||
private double followSpeed;
|
||||
|
@ -26,7 +26,7 @@ public class EntityAIFollowOwner extends EntityAIBase
|
|||
float minDist;
|
||||
private float oldWaterCost;
|
||||
|
||||
public EntityAIFollowOwner(EntitySentientSpecter thePetIn, double followSpeedIn, float minDistIn, float maxDistIn)
|
||||
public EntityAIFollowOwner(EntityDemonBase thePetIn, double followSpeedIn, float minDistIn, float maxDistIn)
|
||||
{
|
||||
this.thePet = thePetIn;
|
||||
this.theWorld = thePetIn.worldObj;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityMimic;
|
||||
|
||||
public class EntityAIMimicReform extends EntityAIBase
|
||||
{
|
||||
private final EntityMimic theEntity;
|
||||
|
||||
public EntityAIMimicReform(EntityMimic creatureIn)
|
||||
{
|
||||
this.theEntity = creatureIn;
|
||||
this.setMutexBits(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
return this.theEntity.ticksExisted > 100 && this.theEntity.hasHome() && this.theEntity.isWithinHomeDistanceCurrentPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
BlockPos homePos = this.theEntity.getHomePosition();
|
||||
if (theEntity.reformIntoMimicBlock(homePos))
|
||||
{
|
||||
this.theEntity.setDead();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,15 +2,15 @@ package WayofTime.bloodmagic.entity.ai;
|
|||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAITarget;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
|
||||
public class EntityAIOwnerHurtByTarget extends EntityAITarget
|
||||
{
|
||||
EntitySentientSpecter theDefendingTameable;
|
||||
EntityDemonBase theDefendingTameable;
|
||||
EntityLivingBase theOwnerAttacker;
|
||||
private int timestamp;
|
||||
|
||||
public EntityAIOwnerHurtByTarget(EntitySentientSpecter theDefendingTameableIn)
|
||||
public EntityAIOwnerHurtByTarget(EntityDemonBase theDefendingTameableIn)
|
||||
{
|
||||
super(theDefendingTameableIn, false);
|
||||
this.theDefendingTameable = theDefendingTameableIn;
|
||||
|
|
|
@ -2,18 +2,18 @@ package WayofTime.bloodmagic.entity.ai;
|
|||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAITarget;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
|
||||
public class EntityAIOwnerHurtTarget extends EntityAITarget
|
||||
{
|
||||
EntitySentientSpecter theEntitySentientSpecter;
|
||||
EntityDemonBase theEntityDemonBase;
|
||||
EntityLivingBase theTarget;
|
||||
private int timestamp;
|
||||
|
||||
public EntityAIOwnerHurtTarget(EntitySentientSpecter theEntitySentientSpecterIn)
|
||||
public EntityAIOwnerHurtTarget(EntityDemonBase theEntityDemonBaseIn)
|
||||
{
|
||||
super(theEntitySentientSpecterIn, false);
|
||||
this.theEntitySentientSpecter = theEntitySentientSpecterIn;
|
||||
super(theEntityDemonBaseIn, false);
|
||||
this.theEntityDemonBase = theEntityDemonBaseIn;
|
||||
this.setMutexBits(1);
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,12 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget
|
|||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (!this.theEntitySentientSpecter.isTamed())
|
||||
if (!this.theEntityDemonBase.isTamed())
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
EntityLivingBase entitylivingbase = this.theEntitySentientSpecter.getOwner();
|
||||
EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner();
|
||||
|
||||
if (entitylivingbase == null)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget
|
|||
{
|
||||
this.theTarget = entitylivingbase.getLastAttacker();
|
||||
int i = entitylivingbase.getLastAttackerTime();
|
||||
return i != this.timestamp && this.isSuitableTarget(this.theTarget, false) && this.theEntitySentientSpecter.shouldAttackEntity(this.theTarget, entitylivingbase);
|
||||
return i != this.timestamp && this.isSuitableTarget(this.theTarget, false) && this.theEntityDemonBase.shouldAttackEntity(this.theTarget, entitylivingbase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget
|
|||
public void startExecuting()
|
||||
{
|
||||
this.taskOwner.setAttackTarget(this.theTarget);
|
||||
EntityLivingBase entitylivingbase = this.theEntitySentientSpecter.getOwner();
|
||||
EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner();
|
||||
|
||||
if (entitylivingbase != null)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.pathfinding.Path;
|
|||
import net.minecraft.pathfinding.PathNavigate;
|
||||
import net.minecraft.util.EntitySelectors;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
|
@ -20,7 +20,7 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
|||
{
|
||||
private final Predicate<Entity> canBeSeenSelector;
|
||||
/** The entity we are attached to */
|
||||
protected EntitySentientSpecter theEntity;
|
||||
protected EntityDemonBase theEntity;
|
||||
private double farSpeed;
|
||||
private double nearSpeed;
|
||||
private double safeHealDistance = 3;
|
||||
|
@ -33,12 +33,12 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
|||
private Class<T> classToAvoid;
|
||||
private Predicate<? super T> avoidTargetSelector;
|
||||
|
||||
public EntityAIRetreatToHeal(EntitySentientSpecter theEntityIn, Class<T> classToAvoidIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn)
|
||||
public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class<T> classToAvoidIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn)
|
||||
{
|
||||
this(theEntityIn, classToAvoidIn, Predicates.<T>alwaysTrue(), avoidDistanceIn, farSpeedIn, nearSpeedIn);
|
||||
}
|
||||
|
||||
public EntityAIRetreatToHeal(EntitySentientSpecter theEntityIn, Class<T> classToAvoidIn, Predicate<? super T> avoidTargetSelectorIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn)
|
||||
public EntityAIRetreatToHeal(EntityDemonBase theEntityIn, Class<T> classToAvoidIn, Predicate<? super T> avoidTargetSelectorIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn)
|
||||
{
|
||||
this.canBeSeenSelector = new Predicate<Entity>()
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
|||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (!this.theEntity.shouldSelfHeal())
|
||||
if (!this.theEntity.shouldEmergencyHeal())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
|||
@Override
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return this.theEntity.shouldSelfHeal();//!this.entityPathNavigate.noPath();
|
||||
return this.theEntity.shouldEmergencyHeal();//!this.entityPathNavigate.noPath();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue