Added a corrupted chicken, which hits very hard but stealths itself in between attacks.
This commit is contained in:
parent
6f5e96bd52
commit
9538e9aa0d
12 changed files with 672 additions and 2 deletions
|
@ -0,0 +1,53 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIAttackMelee;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
|
||||
|
||||
public class EntityAIAttackStealthMelee extends EntityAIAttackMelee
|
||||
{
|
||||
protected EntityCorruptedChicken chicken;
|
||||
|
||||
public EntityAIAttackStealthMelee(EntityCorruptedChicken creature, double speedIn, boolean useLongMemory)
|
||||
{
|
||||
super(creature, speedIn, useLongMemory);
|
||||
chicken = creature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
return chicken.attackStateMachine == 1 && super.shouldExecute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return chicken.attackStateMachine == 1 && super.continueExecuting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTask()
|
||||
{
|
||||
if (chicken.attackStateMachine == 1)
|
||||
{
|
||||
chicken.attackStateMachine = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_190102_a(EntityLivingBase attacked, double distance)
|
||||
{
|
||||
double d0 = this.getAttackReachSqr(attacked);
|
||||
|
||||
if (distance <= d0 && this.attackTick <= 0)
|
||||
{
|
||||
this.attackTick = 20;
|
||||
this.attacker.swingArm(EnumHand.MAIN_HAND);
|
||||
this.attacker.attackEntityAsMob(attacked);
|
||||
|
||||
chicken.attackStateMachine = 2;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.RandomPositionGenerator;
|
||||
import net.minecraft.pathfinding.Path;
|
||||
import net.minecraft.pathfinding.PathNavigate;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
|
||||
|
||||
public class EntityAIStealthRetreat extends EntityAIBase
|
||||
{
|
||||
/** The entity we are attached to */
|
||||
protected EntityCorruptedChicken entity;
|
||||
private final double farSpeed;
|
||||
private final double nearSpeed;
|
||||
private final float avoidDistance;
|
||||
/** The PathEntity of our entity */
|
||||
private Path entityPathEntity;
|
||||
/** The PathNavigate of our entity */
|
||||
private final PathNavigate entityPathNavigate;
|
||||
|
||||
private int ticksLeft = 0;
|
||||
|
||||
public EntityAIStealthRetreat(EntityCorruptedChicken theEntityIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn)
|
||||
{
|
||||
this.entity = theEntityIn;
|
||||
this.avoidDistance = avoidDistanceIn;
|
||||
this.farSpeed = farSpeedIn;
|
||||
this.nearSpeed = nearSpeedIn;
|
||||
this.entityPathNavigate = theEntityIn.getNavigator();
|
||||
this.setMutexBits(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (this.entity.attackStateMachine == 2)
|
||||
{
|
||||
EntityLivingBase attacked = this.entity.getAttackTarget();
|
||||
if (attacked == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.entity, 16, 7, new Vec3d(attacked.posX, attacked.posY, attacked.posZ));
|
||||
|
||||
if (vec3d == null)
|
||||
{
|
||||
return false;
|
||||
} else if (attacked.getDistanceSq(vec3d.xCoord, vec3d.yCoord, vec3d.zCoord) < attacked.getDistanceSqToEntity(this.entity))
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.xCoord, vec3d.yCoord, vec3d.zCoord);
|
||||
return this.entityPathEntity != null;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
if (this.entityPathNavigate.noPath())
|
||||
{
|
||||
this.entity.attackStateMachine = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.entity.attackStateMachine == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTask()
|
||||
{
|
||||
ticksLeft = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
ticksLeft = this.entity.worldObj.rand.nextInt(100) + 100;
|
||||
this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask()
|
||||
{
|
||||
ticksLeft--;
|
||||
if (ticksLeft <= 0)
|
||||
{
|
||||
this.entity.attackStateMachine = 0;
|
||||
}
|
||||
|
||||
if (this.entity.getDistanceSqToEntity(this.entity.getAttackTarget()) < 49.0D)
|
||||
{
|
||||
this.entity.getNavigator().setSpeed(this.nearSpeed);
|
||||
} else
|
||||
{
|
||||
this.entity.getNavigator().setSpeed(this.farSpeed);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.RandomPositionGenerator;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
|
||||
|
||||
public class EntityAIStealthTowardsTarget extends EntityAIBase
|
||||
{
|
||||
private final EntityCorruptedChicken entity;
|
||||
private double xPosition;
|
||||
private double yPosition;
|
||||
private double zPosition;
|
||||
private final double speed;
|
||||
|
||||
private int ticksLeft = 0;
|
||||
|
||||
public EntityAIStealthTowardsTarget(EntityCorruptedChicken creatureIn, double speedIn)
|
||||
{
|
||||
this.entity = creatureIn;
|
||||
this.speed = speedIn;
|
||||
this.setMutexBits(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (this.entity.attackStateMachine != 0 || this.entity.getAttackTarget() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityLivingBase target = this.entity.getAttackTarget();
|
||||
Vec3d vec3d = null;
|
||||
if (target instanceof EntityCreature)
|
||||
{
|
||||
vec3d = RandomPositionGenerator.findRandomTarget((EntityCreature) target, 10, 7);
|
||||
} else
|
||||
{
|
||||
vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);
|
||||
}
|
||||
|
||||
if (vec3d == null)
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
ticksLeft = this.entity.worldObj.rand.nextInt(200) + 100;
|
||||
this.xPosition = vec3d.xCoord;
|
||||
this.yPosition = vec3d.yCoord;
|
||||
this.zPosition = vec3d.zCoord;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTask()
|
||||
{
|
||||
ticksLeft = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
ticksLeft--;
|
||||
if (ticksLeft <= 0)
|
||||
{
|
||||
this.entity.attackStateMachine = 1;
|
||||
}
|
||||
|
||||
this.entity.cloak();
|
||||
|
||||
if (this.entity.getNavigator().noPath())
|
||||
{
|
||||
EntityLivingBase target = this.entity.getAttackTarget();
|
||||
Vec3d vec3d = null;
|
||||
if (target instanceof EntityCreature)
|
||||
{
|
||||
vec3d = RandomPositionGenerator.findRandomTarget((EntityCreature) target, 10, 7);
|
||||
} else
|
||||
{
|
||||
vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);
|
||||
}
|
||||
|
||||
if (vec3d != null)
|
||||
{
|
||||
this.xPosition = vec3d.xCoord;
|
||||
this.yPosition = vec3d.yCoord;
|
||||
this.zPosition = vec3d.zCoord;
|
||||
this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed);
|
||||
}
|
||||
}
|
||||
|
||||
return this.entity.attackStateMachine == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue