Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -1,25 +1,23 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
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.EntityDemonBase;
|
||||
|
||||
public class EntityAIAttackRangedBow extends EntityAIBase
|
||||
{
|
||||
public class EntityAIAttackRangedBow extends EntityAIBase {
|
||||
private final EntityDemonBase entity;
|
||||
private final double moveSpeedAmp;
|
||||
private int attackCooldown;
|
||||
private final float maxAttackDistance;
|
||||
private int attackCooldown;
|
||||
private int attackTime = -1;
|
||||
private int seeTime;
|
||||
private boolean strafingClockwise;
|
||||
private boolean strafingBackwards;
|
||||
private int strafingTime = -1;
|
||||
|
||||
public EntityAIAttackRangedBow(EntityDemonBase entityDemonBase, double speedAmplifier, int delay, float maxDistance)
|
||||
{
|
||||
public EntityAIAttackRangedBow(EntityDemonBase entityDemonBase, double speedAmplifier, int delay, float maxDistance) {
|
||||
this.entity = entityDemonBase;
|
||||
this.moveSpeedAmp = speedAmplifier;
|
||||
this.attackCooldown = delay;
|
||||
|
@ -27,45 +25,39 @@ public class EntityAIAttackRangedBow extends EntityAIBase
|
|||
this.setMutexBits(3);
|
||||
}
|
||||
|
||||
public void setAttackCooldown(int p_189428_1_)
|
||||
{
|
||||
public void setAttackCooldown(int p_189428_1_) {
|
||||
this.attackCooldown = p_189428_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
return this.entity.getAttackTarget() != null && this.isBowInMainhand();
|
||||
}
|
||||
|
||||
protected boolean isBowInMainhand()
|
||||
{
|
||||
protected boolean isBowInMainhand() {
|
||||
return this.entity.getHeldItemMainhand().getItem() instanceof ItemBow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
public boolean continueExecuting() {
|
||||
return (this.shouldExecute() || !this.entity.getNavigator().noPath()) && this.isBowInMainhand();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
super.startExecuting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
super.startExecuting();
|
||||
this.seeTime = 0;
|
||||
this.attackTime = -1;
|
||||
|
@ -75,89 +67,70 @@ public class EntityAIAttackRangedBow extends EntityAIBase
|
|||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
public void updateTask() {
|
||||
EntityLivingBase entitylivingbase = this.entity.getAttackTarget();
|
||||
|
||||
if (entitylivingbase != null)
|
||||
{
|
||||
if (entitylivingbase != null) {
|
||||
double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
|
||||
boolean flag = this.entity.getEntitySenses().canSee(entitylivingbase);
|
||||
boolean flag1 = this.seeTime > 0;
|
||||
|
||||
if (flag != flag1)
|
||||
{
|
||||
if (flag != flag1) {
|
||||
this.seeTime = 0;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
++this.seeTime;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
--this.seeTime;
|
||||
}
|
||||
|
||||
if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20)
|
||||
{
|
||||
if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20) {
|
||||
this.entity.getNavigator().clearPathEntity();
|
||||
++this.strafingTime;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.moveSpeedAmp);
|
||||
this.strafingTime = -1;
|
||||
}
|
||||
|
||||
if (this.strafingTime >= 20)
|
||||
{
|
||||
if ((double) this.entity.getRNG().nextFloat() < 0.3D)
|
||||
{
|
||||
if (this.strafingTime >= 20) {
|
||||
if ((double) this.entity.getRNG().nextFloat() < 0.3D) {
|
||||
this.strafingClockwise = !this.strafingClockwise;
|
||||
}
|
||||
|
||||
if ((double) this.entity.getRNG().nextFloat() < 0.3D)
|
||||
{
|
||||
if ((double) this.entity.getRNG().nextFloat() < 0.3D) {
|
||||
this.strafingBackwards = !this.strafingBackwards;
|
||||
}
|
||||
|
||||
this.strafingTime = 0;
|
||||
}
|
||||
|
||||
if (this.strafingTime > -1)
|
||||
{
|
||||
if (d0 > (double) (this.maxAttackDistance * 0.75F))
|
||||
{
|
||||
if (this.strafingTime > -1) {
|
||||
if (d0 > (double) (this.maxAttackDistance * 0.75F)) {
|
||||
this.strafingBackwards = false;
|
||||
} else if (d0 < (double) (this.maxAttackDistance * 0.25F))
|
||||
{
|
||||
} else if (d0 < (double) (this.maxAttackDistance * 0.25F)) {
|
||||
this.strafingBackwards = true;
|
||||
}
|
||||
|
||||
this.entity.getMoveHelper().strafe(this.strafingBackwards ? -0.5F : 0.5F, this.strafingClockwise ? 0.5F : -0.5F);
|
||||
this.entity.faceEntity(entitylivingbase, 30.0F, 30.0F);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.entity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
|
||||
}
|
||||
|
||||
if (this.entity.isHandActive())
|
||||
{
|
||||
if (!flag && this.seeTime < -60)
|
||||
{
|
||||
if (this.entity.isHandActive()) {
|
||||
if (!flag && this.seeTime < -60) {
|
||||
this.entity.resetActiveHand();
|
||||
} else if (flag)
|
||||
{
|
||||
} else if (flag) {
|
||||
int i = this.entity.getItemInUseMaxCount();
|
||||
|
||||
if (i >= 20)
|
||||
{
|
||||
if (i >= 20) {
|
||||
this.entity.resetActiveHand();
|
||||
this.entity.attackEntityWithRangedAttack(entitylivingbase, ItemBow.getArrowVelocity(i));
|
||||
this.attackTime = this.attackCooldown;
|
||||
}
|
||||
}
|
||||
} else if (--this.attackTime <= 0 && this.seeTime >= -60)
|
||||
{
|
||||
} else if (--this.attackTime <= 0 && this.seeTime >= -60) {
|
||||
this.entity.setActiveHand(EnumHand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,42 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.pathfinding.Path;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
|
||||
|
||||
public class EntityAIAttackStealthMelee extends EntityAIBase
|
||||
{
|
||||
public class EntityAIAttackStealthMelee extends EntityAIBase {
|
||||
protected final int attackInterval = 20;
|
||||
protected EntityCorruptedChicken chicken;
|
||||
|
||||
World worldObj;
|
||||
/**
|
||||
* An amount of decrementing ticks that allows the entity to attack once the
|
||||
* tick reaches 0.
|
||||
*/
|
||||
protected int attackTick;
|
||||
/** The speed with which the mob will approach the target */
|
||||
World worldObj;
|
||||
/**
|
||||
* The speed with which the mob will approach the target
|
||||
*/
|
||||
double speedTowardsTarget;
|
||||
/**
|
||||
* When true, the mob will continue chasing its target, even if it can't
|
||||
* find a path to them right now.
|
||||
*/
|
||||
boolean longMemory;
|
||||
/** The PathEntity of our entity. */
|
||||
/**
|
||||
* The PathEntity of our entity.
|
||||
*/
|
||||
Path entityPathEntity;
|
||||
private int delayCounter;
|
||||
private double targetX;
|
||||
private double targetY;
|
||||
private double targetZ;
|
||||
protected final int attackInterval = 20;
|
||||
private int failedPathFindingPenalty = 0;
|
||||
private boolean canPenalize = false;
|
||||
|
||||
public EntityAIAttackStealthMelee(EntityCorruptedChicken creature, double speedIn, boolean useLongMemory)
|
||||
{
|
||||
public EntityAIAttackStealthMelee(EntityCorruptedChicken creature, double speedIn, boolean useLongMemory) {
|
||||
this.chicken = creature;
|
||||
this.worldObj = creature.getEntityWorld();
|
||||
this.speedTowardsTarget = speedIn;
|
||||
|
@ -44,32 +45,24 @@ public class EntityAIAttackStealthMelee extends EntityAIBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (chicken.attackStateMachine != 1)
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
if (chicken.attackStateMachine != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityLivingBase entitylivingbase = this.chicken.getAttackTarget();
|
||||
|
||||
if (entitylivingbase == null)
|
||||
{
|
||||
if (entitylivingbase == null) {
|
||||
return false;
|
||||
} else if (!entitylivingbase.isEntityAlive())
|
||||
{
|
||||
} else if (!entitylivingbase.isEntityAlive()) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
if (canPenalize)
|
||||
{
|
||||
if (--this.delayCounter <= 0)
|
||||
{
|
||||
} else {
|
||||
if (canPenalize) {
|
||||
if (--this.delayCounter <= 0) {
|
||||
this.entityPathEntity = this.chicken.getNavigator().getPathToEntityLiving(entitylivingbase);
|
||||
this.delayCounter = 4 + this.chicken.getRNG().nextInt(7);
|
||||
return this.entityPathEntity != null;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -79,61 +72,50 @@ public class EntityAIAttackStealthMelee extends EntityAIBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldContinueExecuting()
|
||||
{
|
||||
public boolean shouldContinueExecuting() {
|
||||
return chicken.attackStateMachine == 1 && super.shouldContinueExecuting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTask()
|
||||
{
|
||||
if (chicken.attackStateMachine == 1)
|
||||
{
|
||||
public void resetTask() {
|
||||
if (chicken.attackStateMachine == 1) {
|
||||
chicken.attackStateMachine = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask()
|
||||
{
|
||||
public void updateTask() {
|
||||
EntityLivingBase entitylivingbase = this.chicken.getAttackTarget();
|
||||
this.chicken.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
|
||||
double d0 = this.chicken.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
|
||||
--this.delayCounter;
|
||||
|
||||
if ((this.longMemory || this.chicken.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.chicken.getRNG().nextFloat() < 0.05F))
|
||||
{
|
||||
if ((this.longMemory || this.chicken.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.chicken.getRNG().nextFloat() < 0.05F)) {
|
||||
this.targetX = entitylivingbase.posX;
|
||||
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
|
||||
this.targetZ = entitylivingbase.posZ;
|
||||
this.delayCounter = 4 + this.chicken.getRNG().nextInt(7);
|
||||
|
||||
if (this.canPenalize)
|
||||
{
|
||||
if (this.canPenalize) {
|
||||
this.delayCounter += failedPathFindingPenalty;
|
||||
if (this.chicken.getNavigator().getPath() != null)
|
||||
{
|
||||
if (this.chicken.getNavigator().getPath() != null) {
|
||||
net.minecraft.pathfinding.PathPoint finalPathPoint = this.chicken.getNavigator().getPath().getFinalPathPoint();
|
||||
if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1)
|
||||
failedPathFindingPenalty = 0;
|
||||
else
|
||||
failedPathFindingPenalty += 10;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
failedPathFindingPenalty += 10;
|
||||
}
|
||||
}
|
||||
|
||||
if (d0 > 1024.0D)
|
||||
{
|
||||
if (d0 > 1024.0D) {
|
||||
this.delayCounter += 10;
|
||||
} else if (d0 > 256.0D)
|
||||
{
|
||||
} else if (d0 > 256.0D) {
|
||||
this.delayCounter += 5;
|
||||
}
|
||||
|
||||
if (!this.chicken.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
|
||||
{
|
||||
if (!this.chicken.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) {
|
||||
this.delayCounter += 15;
|
||||
}
|
||||
}
|
||||
|
@ -142,12 +124,10 @@ public class EntityAIAttackStealthMelee extends EntityAIBase
|
|||
this.attackEntity(entitylivingbase, d0);
|
||||
}
|
||||
|
||||
protected void attackEntity(EntityLivingBase attacked, double distance)
|
||||
{
|
||||
protected void attackEntity(EntityLivingBase attacked, double distance) {
|
||||
double d0 = this.getAttackReachSqr(attacked);
|
||||
|
||||
if (distance <= d0 && this.attackTick <= 0)
|
||||
{
|
||||
if (distance <= d0 && this.attackTick <= 0) {
|
||||
this.attackTick = 20;
|
||||
this.chicken.swingArm(EnumHand.MAIN_HAND);
|
||||
this.chicken.attackEntityAsMob(attacked);
|
||||
|
@ -156,8 +136,7 @@ public class EntityAIAttackStealthMelee extends EntityAIBase
|
|||
}
|
||||
}
|
||||
|
||||
protected double getAttackReachSqr(EntityLivingBase attackTarget)
|
||||
{
|
||||
protected double getAttackReachSqr(EntityLivingBase attackTarget) {
|
||||
return (double) (this.chicken.width * 2.0F * this.chicken.width * 2.0F + attackTarget.width);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,28 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
|
||||
import WayofTime.bloodmagic.inversion.CorruptionHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
|
||||
import WayofTime.bloodmagic.inversion.CorruptionHandler;
|
||||
|
||||
public class EntityAIEatAndCorruptBlock extends EntityAIBase
|
||||
{
|
||||
/** The entity owner of this AITask */
|
||||
public class EntityAIEatAndCorruptBlock extends EntityAIBase {
|
||||
/**
|
||||
* The entity owner of this AITask
|
||||
*/
|
||||
private final EntityAspectedDemonBase grassEaterEntity;
|
||||
/** The world the grass eater entity is eating from */
|
||||
/**
|
||||
* The world the grass eater entity is eating from
|
||||
*/
|
||||
private final World world;
|
||||
/** Number of ticks since the entity started to eat grass */
|
||||
/**
|
||||
* Number of ticks since the entity started to eat grass
|
||||
*/
|
||||
int eatingGrassTimer;
|
||||
|
||||
public EntityAIEatAndCorruptBlock(EntityAspectedDemonBase entity)
|
||||
{
|
||||
public EntityAIEatAndCorruptBlock(EntityAspectedDemonBase entity) {
|
||||
this.grassEaterEntity = entity;
|
||||
this.world = entity.getEntityWorld();
|
||||
this.setMutexBits(7);
|
||||
|
@ -27,13 +31,10 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase
|
|||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (this.grassEaterEntity.getRNG().nextInt(50) != 0)
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
if (this.grassEaterEntity.getRNG().nextInt(50) != 0) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
BlockPos pos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ).down();
|
||||
IBlockState offsetState = world.getBlockState(pos);
|
||||
Block offsetBlock = offsetState.getBlock();
|
||||
|
@ -44,8 +45,7 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase
|
|||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
this.eatingGrassTimer = 40;
|
||||
this.world.setEntityState(this.grassEaterEntity, (byte) 10);
|
||||
this.grassEaterEntity.getNavigator().clearPathEntity();
|
||||
|
@ -54,44 +54,38 @@ public class EntityAIEatAndCorruptBlock extends EntityAIBase
|
|||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
this.eatingGrassTimer = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
public boolean continueExecuting() {
|
||||
return this.eatingGrassTimer > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of ticks since the entity started to eat grass
|
||||
*/
|
||||
public int getEatingGrassTimer()
|
||||
{
|
||||
public int getEatingGrassTimer() {
|
||||
return this.eatingGrassTimer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
public void updateTask() {
|
||||
this.eatingGrassTimer = Math.max(0, this.eatingGrassTimer - 1);
|
||||
|
||||
if (this.eatingGrassTimer == 4)
|
||||
{
|
||||
if (this.eatingGrassTimer == 4) {
|
||||
BlockPos blockpos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ);
|
||||
|
||||
BlockPos offsetPos = blockpos.down();
|
||||
IBlockState offsetState = world.getBlockState(offsetPos);
|
||||
Block offsetBlock = offsetState.getBlock();
|
||||
|
||||
if (CorruptionHandler.isBlockCorruptible(world, grassEaterEntity.getType(), offsetPos, offsetState, offsetBlock))
|
||||
{
|
||||
if (CorruptionHandler.isBlockCorruptible(world, grassEaterEntity.getType(), offsetPos, offsetState, offsetBlock)) {
|
||||
// if (this.world.getGameRules().getBoolean("mobGriefing"))
|
||||
{
|
||||
this.world.playEvent(2001, offsetPos, Block.getIdFromBlock(offsetBlock));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -12,22 +13,19 @@ 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.EntityDemonBase;
|
||||
|
||||
public class EntityAIFollowOwner extends EntityAIBase
|
||||
{
|
||||
public class EntityAIFollowOwner extends EntityAIBase {
|
||||
World theWorld;
|
||||
float maxDist;
|
||||
float minDist;
|
||||
private EntityDemonBase thePet;
|
||||
private EntityLivingBase theOwner;
|
||||
World theWorld;
|
||||
private double followSpeed;
|
||||
private PathNavigate petPathfinder;
|
||||
private int timeToRecalcPath;
|
||||
float maxDist;
|
||||
float minDist;
|
||||
private float oldWaterCost;
|
||||
|
||||
public EntityAIFollowOwner(EntityDemonBase thePetIn, double followSpeedIn, float minDistIn, float maxDistIn)
|
||||
{
|
||||
public EntityAIFollowOwner(EntityDemonBase thePetIn, double followSpeedIn, float minDistIn, float maxDistIn) {
|
||||
this.thePet = thePetIn;
|
||||
this.theWorld = thePetIn.getEntityWorld();
|
||||
this.followSpeed = followSpeedIn;
|
||||
|
@ -36,8 +34,7 @@ public class EntityAIFollowOwner extends EntityAIBase
|
|||
this.maxDist = maxDistIn;
|
||||
this.setMutexBits(3);
|
||||
|
||||
if (!(thePetIn.getNavigator() instanceof PathNavigateGround))
|
||||
{
|
||||
if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) {
|
||||
throw new IllegalArgumentException("Unsupported mob type for FollowOwnerGoal");
|
||||
}
|
||||
}
|
||||
|
@ -45,24 +42,18 @@ public class EntityAIFollowOwner extends EntityAIBase
|
|||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
EntityLivingBase entitylivingbase = this.thePet.getOwner();
|
||||
|
||||
if (entitylivingbase == null)
|
||||
{
|
||||
if (entitylivingbase == null) {
|
||||
return false;
|
||||
} else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator())
|
||||
{
|
||||
} else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator()) {
|
||||
return false;
|
||||
} else if (this.thePet.isStationary())
|
||||
{
|
||||
} else if (this.thePet.isStationary()) {
|
||||
return false;
|
||||
} else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double) (this.minDist * this.minDist))
|
||||
{
|
||||
} else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double) (this.minDist * this.minDist)) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.theOwner = entitylivingbase;
|
||||
return true;
|
||||
}
|
||||
|
@ -71,16 +62,14 @@ public class EntityAIFollowOwner extends EntityAIBase
|
|||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
public boolean continueExecuting() {
|
||||
return !this.petPathfinder.noPath() && this.thePet.getDistanceSqToEntity(this.theOwner) > (double) (this.maxDist * this.maxDist) && !this.thePet.isStationary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
this.timeToRecalcPath = 0;
|
||||
this.oldWaterCost = this.thePet.getPathPriority(PathNodeType.WATER);
|
||||
this.thePet.setPathPriority(PathNodeType.WATER, 0.0F);
|
||||
|
@ -89,15 +78,13 @@ public class EntityAIFollowOwner extends EntityAIBase
|
|||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
this.theOwner = null;
|
||||
this.petPathfinder.clearPathEntity();
|
||||
this.thePet.setPathPriority(PathNodeType.WATER, this.oldWaterCost);
|
||||
}
|
||||
|
||||
private boolean isEmptyBlock(BlockPos pos)
|
||||
{
|
||||
private boolean isEmptyBlock(BlockPos pos) {
|
||||
IBlockState iblockstate = this.theWorld.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
return block == Blocks.AIR || !iblockstate.isFullCube();
|
||||
|
@ -106,32 +93,23 @@ public class EntityAIFollowOwner extends EntityAIBase
|
|||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
public void updateTask() {
|
||||
this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float) this.thePet.getVerticalFaceSpeed());
|
||||
|
||||
if (!this.thePet.isStationary())
|
||||
{
|
||||
if (--this.timeToRecalcPath <= 0)
|
||||
{
|
||||
if (!this.thePet.isStationary()) {
|
||||
if (--this.timeToRecalcPath <= 0) {
|
||||
this.timeToRecalcPath = 10;
|
||||
|
||||
if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed))
|
||||
{
|
||||
if (!this.thePet.getLeashed())
|
||||
{
|
||||
if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D)
|
||||
{
|
||||
if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed)) {
|
||||
if (!this.thePet.getLeashed()) {
|
||||
if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) {
|
||||
int i = MathHelper.floor(this.theOwner.posX) - 2;
|
||||
int j = MathHelper.floor(this.theOwner.posZ) - 2;
|
||||
int k = MathHelper.floor(this.theOwner.getEntityBoundingBox().minY);
|
||||
|
||||
for (int l = 0; l <= 4; ++l)
|
||||
{
|
||||
for (int i1 = 0; i1 <= 4; ++i1)
|
||||
{
|
||||
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1)))
|
||||
{
|
||||
for (int l = 0; l <= 4; ++l) {
|
||||
for (int i1 = 0; i1 <= 4; ++i1) {
|
||||
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1))) {
|
||||
this.thePet.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch);
|
||||
this.petPathfinder.clearPathEntity();
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -12,25 +13,22 @@ 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;
|
||||
|
||||
public class EntityAIGrabEffectsFromOwner extends EntityAIBase
|
||||
{
|
||||
public class EntityAIGrabEffectsFromOwner extends EntityAIBase {
|
||||
World theWorld;
|
||||
float minDist;
|
||||
private EntitySentientSpecter thePet;
|
||||
private EntityLivingBase theOwner;
|
||||
World theWorld;
|
||||
private double followSpeed;
|
||||
private PathNavigate petPathfinder;
|
||||
private int timeToRecalcPath;
|
||||
float minDist;
|
||||
private float oldWaterCost;
|
||||
|
||||
/**
|
||||
* In order to steal effects from the owner, the mob has to be close to the
|
||||
* owner.
|
||||
*/
|
||||
public EntityAIGrabEffectsFromOwner(EntitySentientSpecter thePetIn, double followSpeedIn, float minDistIn)
|
||||
{
|
||||
public EntityAIGrabEffectsFromOwner(EntitySentientSpecter thePetIn, double followSpeedIn, float minDistIn) {
|
||||
this.thePet = thePetIn;
|
||||
this.theWorld = thePetIn.getEntityWorld();
|
||||
this.followSpeed = followSpeedIn;
|
||||
|
@ -38,8 +36,7 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
|
|||
this.minDist = minDistIn;
|
||||
this.setMutexBits(3);
|
||||
|
||||
if (!(thePetIn.getNavigator() instanceof PathNavigateGround))
|
||||
{
|
||||
if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) {
|
||||
throw new IllegalArgumentException("Unsupported mob type for FollowOwnerGoal");
|
||||
}
|
||||
}
|
||||
|
@ -47,27 +44,21 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
|
|||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
EntityLivingBase entitylivingbase = this.thePet.getOwner();
|
||||
|
||||
if (entitylivingbase == null)
|
||||
{
|
||||
if (entitylivingbase == null) {
|
||||
return false;
|
||||
} else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator())
|
||||
{
|
||||
} else if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer) entitylivingbase).isSpectator()) {
|
||||
return false;
|
||||
} else if (this.thePet.isStationary())
|
||||
{
|
||||
} else if (this.thePet.isStationary()) {
|
||||
return false;
|
||||
// } else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double) (this.minDist * this.minDist))
|
||||
// {
|
||||
// return false;
|
||||
} else if (!this.thePet.canStealEffectFromOwner(entitylivingbase))
|
||||
{
|
||||
} else if (!this.thePet.canStealEffectFromOwner(entitylivingbase)) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.theOwner = entitylivingbase;
|
||||
return true;
|
||||
}
|
||||
|
@ -76,16 +67,14 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
|
|||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
public boolean continueExecuting() {
|
||||
return this.thePet.canStealEffectFromOwner(theOwner);// || !this.petPathfinder.noPath() && this.thePet.getDistanceSqToEntity(this.theOwner) > (double) (this.minDist * this.minDist) && !this.thePet.isStationary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
this.timeToRecalcPath = 0;
|
||||
this.oldWaterCost = this.thePet.getPathPriority(PathNodeType.WATER);
|
||||
this.thePet.setPathPriority(PathNodeType.WATER, 0.0F);
|
||||
|
@ -94,15 +83,13 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
|
|||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
this.theOwner = null;
|
||||
this.petPathfinder.clearPathEntity();
|
||||
this.thePet.setPathPriority(PathNodeType.WATER, this.oldWaterCost);
|
||||
}
|
||||
|
||||
private boolean isEmptyBlock(BlockPos pos)
|
||||
{
|
||||
private boolean isEmptyBlock(BlockPos pos) {
|
||||
IBlockState iblockstate = this.theWorld.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
return block == Blocks.AIR || !iblockstate.isFullCube();
|
||||
|
@ -111,40 +98,29 @@ public class EntityAIGrabEffectsFromOwner extends EntityAIBase
|
|||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
public void updateTask() {
|
||||
this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float) this.thePet.getVerticalFaceSpeed());
|
||||
|
||||
if (this.thePet.getDistanceSqToEntity(theOwner) < this.minDist * this.minDist)
|
||||
{
|
||||
if (this.thePet.stealEffectsFromOwner(theOwner))
|
||||
{
|
||||
if (this.thePet.getDistanceSqToEntity(theOwner) < this.minDist * this.minDist) {
|
||||
if (this.thePet.stealEffectsFromOwner(theOwner)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.thePet.isStationary())
|
||||
{
|
||||
if (--this.timeToRecalcPath <= 0)
|
||||
{
|
||||
if (!this.thePet.isStationary()) {
|
||||
if (--this.timeToRecalcPath <= 0) {
|
||||
this.timeToRecalcPath = 10;
|
||||
|
||||
if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed))
|
||||
{
|
||||
if (!this.thePet.getLeashed())
|
||||
{
|
||||
if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D)
|
||||
{
|
||||
if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed)) {
|
||||
if (!this.thePet.getLeashed()) {
|
||||
if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) {
|
||||
int i = MathHelper.floor(this.theOwner.posX) - 2;
|
||||
int j = MathHelper.floor(this.theOwner.posZ) - 2;
|
||||
int k = MathHelper.floor(this.theOwner.getEntityBoundingBox().minY);
|
||||
|
||||
for (int l = 0; l <= 4; ++l)
|
||||
{
|
||||
for (int i1 = 0; i1 <= 4; ++i1)
|
||||
{
|
||||
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1)))
|
||||
{
|
||||
for (int l = 0; l <= 4; ++l) {
|
||||
for (int i1 = 0; i1 <= 4; ++i1) {
|
||||
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.theWorld.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1))) {
|
||||
this.thePet.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch);
|
||||
this.petPathfinder.clearPathEntity();
|
||||
return;
|
||||
|
|
|
@ -1,28 +1,23 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.IEntityOwnable;
|
||||
import net.minecraft.entity.ai.EntityAIHurtByTarget;
|
||||
|
||||
public class EntityAIHurtByTargetIgnoreTamed extends EntityAIHurtByTarget
|
||||
{
|
||||
public EntityAIHurtByTargetIgnoreTamed(EntityCreature creatureIn, boolean entityCallsForHelpIn, Class<?>... targetClassesIn)
|
||||
{
|
||||
import java.util.UUID;
|
||||
|
||||
public class EntityAIHurtByTargetIgnoreTamed extends EntityAIHurtByTarget {
|
||||
public EntityAIHurtByTargetIgnoreTamed(EntityCreature creatureIn, boolean entityCallsForHelpIn, Class<?>... targetClassesIn) {
|
||||
super(creatureIn, true, targetClassesIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles)
|
||||
{
|
||||
if (this.taskOwner instanceof IEntityOwnable && target instanceof IEntityOwnable)
|
||||
{
|
||||
public boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles) {
|
||||
if (this.taskOwner instanceof IEntityOwnable && target instanceof IEntityOwnable) {
|
||||
UUID thisId = ((IEntityOwnable) this.taskOwner).getOwnerId();
|
||||
UUID targetId = ((IEntityOwnable) target).getOwnerId();
|
||||
if (thisId != null && targetId != null && thisId.equals(targetId))
|
||||
{
|
||||
if (thisId != null && targetId != null && thisId.equals(targetId)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,26 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityMimic;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityMimic;
|
||||
|
||||
public class EntityAIMimicReform extends EntityAIBase
|
||||
{
|
||||
public class EntityAIMimicReform extends EntityAIBase {
|
||||
private final EntityMimic theEntity;
|
||||
|
||||
public EntityAIMimicReform(EntityMimic creatureIn)
|
||||
{
|
||||
public EntityAIMimicReform(EntityMimic creatureIn) {
|
||||
this.theEntity = creatureIn;
|
||||
this.setMutexBits(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
return this.theEntity.ticksExisted > 100 && this.theEntity.hasHome() && this.theEntity.isWithinHomeDistanceCurrentPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
BlockPos homePos = this.theEntity.getHomePosition();
|
||||
if (theEntity.reformIntoMimicBlock(homePos))
|
||||
{
|
||||
if (theEntity.reformIntoMimicBlock(homePos)) {
|
||||
this.theEntity.setDead();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAITarget;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
|
||||
public class EntityAIOwnerHurtByTarget extends EntityAITarget
|
||||
{
|
||||
public class EntityAIOwnerHurtByTarget extends EntityAITarget {
|
||||
EntityDemonBase theDefendingTameable;
|
||||
EntityLivingBase theOwnerAttacker;
|
||||
private int timestamp;
|
||||
|
||||
public EntityAIOwnerHurtByTarget(EntityDemonBase theDefendingTameableIn)
|
||||
{
|
||||
public EntityAIOwnerHurtByTarget(EntityDemonBase theDefendingTameableIn) {
|
||||
super(theDefendingTameableIn, false);
|
||||
this.theDefendingTameable = theDefendingTameableIn;
|
||||
this.setMutexBits(1);
|
||||
|
@ -20,20 +18,15 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget
|
|||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (!this.theDefendingTameable.isTamed())
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
if (!this.theDefendingTameable.isTamed()) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
EntityLivingBase owner = this.theDefendingTameable.getOwner();
|
||||
|
||||
if (owner == null)
|
||||
{
|
||||
if (owner == null) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.theOwnerAttacker = owner.getRevengeTarget();
|
||||
int i = owner.getRevengeTimer();
|
||||
return i != this.timestamp && this.isSuitableTarget(this.theOwnerAttacker, false) && this.theDefendingTameable.shouldAttackEntity(this.theOwnerAttacker, owner);
|
||||
|
@ -44,13 +37,11 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget
|
|||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
this.taskOwner.setAttackTarget(this.theOwnerAttacker);
|
||||
EntityLivingBase owner = this.theDefendingTameable.getOwner();
|
||||
|
||||
if (owner != null)
|
||||
{
|
||||
if (owner != null) {
|
||||
this.timestamp = owner.getRevengeTimer();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAITarget;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
|
||||
public class EntityAIOwnerHurtTarget extends EntityAITarget
|
||||
{
|
||||
public class EntityAIOwnerHurtTarget extends EntityAITarget {
|
||||
EntityDemonBase theEntityDemonBase;
|
||||
EntityLivingBase theTarget;
|
||||
private int timestamp;
|
||||
|
||||
public EntityAIOwnerHurtTarget(EntityDemonBase theEntityDemonBaseIn)
|
||||
{
|
||||
public EntityAIOwnerHurtTarget(EntityDemonBase theEntityDemonBaseIn) {
|
||||
super(theEntityDemonBaseIn, false);
|
||||
this.theEntityDemonBase = theEntityDemonBaseIn;
|
||||
this.setMutexBits(1);
|
||||
|
@ -20,20 +18,15 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget
|
|||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (!this.theEntityDemonBase.isTamed())
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
if (!this.theEntityDemonBase.isTamed()) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner();
|
||||
|
||||
if (entitylivingbase == null)
|
||||
{
|
||||
if (entitylivingbase == null) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.theTarget = entitylivingbase.getLastAttackedEntity();
|
||||
int i = entitylivingbase.getLastAttackedEntityTime();
|
||||
return i != this.timestamp && this.isSuitableTarget(this.theTarget, false) && this.theEntityDemonBase.shouldAttackEntity(this.theTarget, entitylivingbase);
|
||||
|
@ -44,13 +37,11 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget
|
|||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
this.taskOwner.setAttackTarget(this.theTarget);
|
||||
EntityLivingBase entitylivingbase = this.theEntityDemonBase.getOwner();
|
||||
|
||||
if (entitylivingbase != null)
|
||||
{
|
||||
if (entitylivingbase != null) {
|
||||
this.timestamp = entitylivingbase.getLastAttackedEntityTime();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,44 +1,46 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.pathfinding.Path;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
|
||||
|
||||
public class EntityAIPickUpAlly extends EntityAIBase
|
||||
{
|
||||
World worldObj;
|
||||
import java.util.List;
|
||||
|
||||
public class EntityAIPickUpAlly extends EntityAIBase {
|
||||
protected final int attackInterval = 20;
|
||||
protected EntityAspectedDemonBase entity;
|
||||
/**
|
||||
* An amount of decrementing ticks that allows the entity to attack once the
|
||||
* tick reaches 0.
|
||||
*/
|
||||
protected int attackTick;
|
||||
/** The speed with which the mob will approach the target */
|
||||
World worldObj;
|
||||
/**
|
||||
* The speed with which the mob will approach the target
|
||||
*/
|
||||
double speedTowardsTarget;
|
||||
/**
|
||||
* When true, the mob will continue chasing its target, even if it can't
|
||||
* find a path to them right now.
|
||||
*/
|
||||
boolean longMemory;
|
||||
/** The PathEntity of our entity. */
|
||||
/**
|
||||
* The PathEntity of our entity.
|
||||
*/
|
||||
Path entityPathEntity;
|
||||
private int delayCounter;
|
||||
private double targetX;
|
||||
private double targetY;
|
||||
private double targetZ;
|
||||
protected final int attackInterval = 20;
|
||||
private int failedPathFindingPenalty = 0;
|
||||
private boolean canPenalize = false;
|
||||
|
||||
private EntityLivingBase pickupTarget = null;
|
||||
|
||||
public EntityAIPickUpAlly(EntityAspectedDemonBase creature, double speedIn, boolean useLongMemory)
|
||||
{
|
||||
public EntityAIPickUpAlly(EntityAspectedDemonBase creature, double speedIn, boolean useLongMemory) {
|
||||
this.entity = creature;
|
||||
this.worldObj = creature.getEntityWorld();
|
||||
this.speedTowardsTarget = speedIn;
|
||||
|
@ -49,22 +51,17 @@ public class EntityAIPickUpAlly extends EntityAIBase
|
|||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (this.entity.getRidingEntity() != null)
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
if (this.entity.getRidingEntity() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = new AxisAlignedBB(entity.posX - 0.5, entity.posY - 0.5, entity.posZ - 0.5, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5).grow(5);
|
||||
List<EntityLivingBase> list = this.entity.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType()));
|
||||
for (EntityLivingBase testEntity : list)
|
||||
{
|
||||
if (testEntity != this.entity)
|
||||
{
|
||||
for (EntityLivingBase testEntity : list) {
|
||||
if (testEntity != this.entity) {
|
||||
Path path = this.entity.getNavigator().getPathToEntityLiving(testEntity);
|
||||
if (path != null)
|
||||
{
|
||||
if (path != null) {
|
||||
this.entityPathEntity = path;
|
||||
this.pickupTarget = testEntity;
|
||||
return true;
|
||||
|
@ -78,16 +75,14 @@ public class EntityAIPickUpAlly extends EntityAIBase
|
|||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
public boolean continueExecuting() {
|
||||
return this.entity.getRidingEntity() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
this.entity.getNavigator().setPath(this.entityPathEntity, this.speedTowardsTarget);
|
||||
this.delayCounter = 0;
|
||||
}
|
||||
|
@ -95,8 +90,7 @@ public class EntityAIPickUpAlly extends EntityAIBase
|
|||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
this.entity.getNavigator().clearPathEntity();
|
||||
this.pickupTarget = null;
|
||||
}
|
||||
|
@ -104,46 +98,38 @@ public class EntityAIPickUpAlly extends EntityAIBase
|
|||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
public void updateTask() {
|
||||
EntityLivingBase entitylivingbase = this.pickupTarget;
|
||||
this.entity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
|
||||
double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
|
||||
--this.delayCounter;
|
||||
|
||||
if ((this.longMemory || this.entity.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.entity.getRNG().nextFloat() < 0.05F))
|
||||
{
|
||||
if ((this.longMemory || this.entity.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.entity.getRNG().nextFloat() < 0.05F)) {
|
||||
this.targetX = entitylivingbase.posX;
|
||||
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
|
||||
this.targetZ = entitylivingbase.posZ;
|
||||
this.delayCounter = 4 + this.entity.getRNG().nextInt(7);
|
||||
|
||||
if (this.canPenalize)
|
||||
{
|
||||
if (this.canPenalize) {
|
||||
this.delayCounter += failedPathFindingPenalty;
|
||||
if (this.entity.getNavigator().getPath() != null)
|
||||
{
|
||||
if (this.entity.getNavigator().getPath() != null) {
|
||||
net.minecraft.pathfinding.PathPoint finalPathPoint = this.entity.getNavigator().getPath().getFinalPathPoint();
|
||||
if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1)
|
||||
failedPathFindingPenalty = 0;
|
||||
else
|
||||
failedPathFindingPenalty += 10;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
failedPathFindingPenalty += 10;
|
||||
}
|
||||
}
|
||||
|
||||
if (d0 > 1024.0D)
|
||||
{
|
||||
if (d0 > 1024.0D) {
|
||||
this.delayCounter += 10;
|
||||
} else if (d0 > 256.0D)
|
||||
{
|
||||
} else if (d0 > 256.0D) {
|
||||
this.delayCounter += 5;
|
||||
}
|
||||
|
||||
if (!this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
|
||||
{
|
||||
if (!this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) {
|
||||
this.delayCounter += 15;
|
||||
}
|
||||
}
|
||||
|
@ -152,19 +138,16 @@ public class EntityAIPickUpAlly extends EntityAIBase
|
|||
this.pickUpEntity(entitylivingbase, d0);
|
||||
}
|
||||
|
||||
protected void pickUpEntity(EntityLivingBase potentialPickup, double distance)
|
||||
{
|
||||
protected void pickUpEntity(EntityLivingBase potentialPickup, double distance) {
|
||||
double d0 = this.getAttackReachSqr(potentialPickup);
|
||||
|
||||
if (distance <= d0 && this.attackTick <= 0 && !potentialPickup.isRiding())
|
||||
{
|
||||
if (distance <= d0 && this.attackTick <= 0 && !potentialPickup.isRiding()) {
|
||||
System.out.println("Hai!");
|
||||
potentialPickup.startRiding(this.entity, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected double getAttackReachSqr(EntityLivingBase attackTarget)
|
||||
{
|
||||
protected double getAttackReachSqr(EntityLivingBase attackTarget) {
|
||||
return (double) (this.entity.width * 2.0F * this.entity.width * 2.0F + attackTarget.width);
|
||||
}
|
||||
}
|
|
@ -1,32 +1,35 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityAspectedDemonBase;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep;
|
||||
|
||||
public class EntityAIProtectAlly extends EntityAIBase
|
||||
{
|
||||
/** The entity owner of this AITask */
|
||||
import java.util.List;
|
||||
|
||||
public class EntityAIProtectAlly extends EntityAIBase {
|
||||
/**
|
||||
* The entity owner of this AITask
|
||||
*/
|
||||
private final EntityCorruptedSheep entity;
|
||||
/** The world the grass eater entity is eating from */
|
||||
/**
|
||||
* The world the grass eater entity is eating from
|
||||
*/
|
||||
private final World world;
|
||||
/** Number of ticks since the entity started to eat grass */
|
||||
/**
|
||||
* Number of ticks since the entity started to eat grass
|
||||
*/
|
||||
int castTimer;
|
||||
|
||||
public EntityAIProtectAlly(EntityCorruptedSheep entity)
|
||||
{
|
||||
public EntityAIProtectAlly(EntityCorruptedSheep entity) {
|
||||
this.entity = entity;
|
||||
this.world = entity.getEntityWorld();
|
||||
this.setMutexBits(7);
|
||||
}
|
||||
|
||||
public int getCastTimer()
|
||||
{
|
||||
public int getCastTimer() {
|
||||
return this.castTimer;
|
||||
}
|
||||
|
||||
|
@ -34,16 +37,12 @@ public class EntityAIProtectAlly extends EntityAIBase
|
|||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
AxisAlignedBB bb = new AxisAlignedBB(entity.posX - 0.5, entity.posY - 0.5, entity.posZ - 0.5, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5).grow(5);
|
||||
List<EntityLivingBase> list = world.getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType()));
|
||||
for (EntityLivingBase testEntity : list)
|
||||
{
|
||||
if (testEntity != this.entity)
|
||||
{
|
||||
if (this.entity.canProtectAlly(testEntity))
|
||||
{
|
||||
for (EntityLivingBase testEntity : list) {
|
||||
if (testEntity != this.entity) {
|
||||
if (this.entity.canProtectAlly(testEntity)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +55,7 @@ public class EntityAIProtectAlly extends EntityAIBase
|
|||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
this.castTimer = 100;
|
||||
this.world.setEntityState(this.entity, (byte) 53);
|
||||
this.entity.getNavigator().clearPathEntity();
|
||||
|
@ -67,8 +65,7 @@ public class EntityAIProtectAlly extends EntityAIBase
|
|||
* Resets the task
|
||||
*/
|
||||
@Override
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
this.castTimer = 0;
|
||||
}
|
||||
|
||||
|
@ -76,8 +73,7 @@ public class EntityAIProtectAlly extends EntityAIBase
|
|||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldContinueExecuting()
|
||||
{
|
||||
public boolean shouldContinueExecuting() {
|
||||
return castTimer > 0;
|
||||
}
|
||||
|
||||
|
@ -85,19 +81,14 @@ public class EntityAIProtectAlly extends EntityAIBase
|
|||
* Updates the task
|
||||
*/
|
||||
@Override
|
||||
public void updateTask()
|
||||
{
|
||||
public void updateTask() {
|
||||
this.castTimer = Math.max(0, this.castTimer - 1);
|
||||
if (castTimer == 0)
|
||||
{
|
||||
if (castTimer == 0) {
|
||||
AxisAlignedBB bb = new AxisAlignedBB(entity.posX - 0.5, entity.posY - 0.5, entity.posZ - 0.5, entity.posX + 0.5, entity.posY + 0.5, entity.posZ + 0.5).grow(5);
|
||||
List<EntityLivingBase> list = world.getEntitiesWithinAABB(EntityLivingBase.class, bb, new EntityAspectedDemonBase.WillTypePredicate(entity.getType()));
|
||||
for (EntityLivingBase testEntity : list)
|
||||
{
|
||||
if (testEntity != this.entity)
|
||||
{
|
||||
if (this.entity.applyProtectionToAlly(testEntity))
|
||||
{
|
||||
for (EntityLivingBase testEntity : list) {
|
||||
if (testEntity != this.entity) {
|
||||
if (this.entity.applyProtectionToAlly(testEntity)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.RandomPositionGenerator;
|
||||
|
@ -11,35 +10,36 @@ 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.EntityDemonBase;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import java.util.List;
|
||||
|
||||
public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
||||
{
|
||||
public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase {
|
||||
private final Predicate<Entity> canBeSeenSelector;
|
||||
/** The entity we are attached to */
|
||||
/**
|
||||
* The entity we are attached to
|
||||
*/
|
||||
protected EntityDemonBase theEntity;
|
||||
protected T closestLivingEntity;
|
||||
private double farSpeed;
|
||||
private double nearSpeed;
|
||||
private double safeHealDistance = 3;
|
||||
protected T closestLivingEntity;
|
||||
private float avoidDistance;
|
||||
/** The PathEntity of our entity */
|
||||
/**
|
||||
* The PathEntity of our entity
|
||||
*/
|
||||
private Path entityPathEntity;
|
||||
/** The PathNavigate of our entity */
|
||||
/**
|
||||
* The PathNavigate of our entity
|
||||
*/
|
||||
private PathNavigate entityPathNavigate;
|
||||
private Class<T> classToAvoid;
|
||||
private Predicate<? super T> avoidTargetSelector;
|
||||
|
||||
public EntityAIRetreatToHeal(EntityDemonBase 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(EntityDemonBase 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 = p_apply_1_ -> p_apply_1_.isEntityAlive() && EntityAIRetreatToHeal.this.theEntity.getEntitySenses().canSee(p_apply_1_);
|
||||
this.theEntity = theEntityIn;
|
||||
this.classToAvoid = classToAvoidIn;
|
||||
|
@ -55,32 +55,25 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
|||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (!this.theEntity.shouldEmergencyHeal())
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
if (!this.theEntity.shouldEmergencyHeal()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//This part almost doesn't matter
|
||||
List<T> list = this.theEntity.getEntityWorld().getEntitiesWithinAABB(this.classToAvoid, this.theEntity.getEntityBoundingBox().expand((double) this.avoidDistance, 3.0D, (double) this.avoidDistance), Predicates.and(EntitySelectors.CAN_AI_TARGET, this.canBeSeenSelector, this.avoidTargetSelector));
|
||||
|
||||
if (list.isEmpty())
|
||||
{
|
||||
if (list.isEmpty()) {
|
||||
return true; //No entities nearby, so I can freely heal
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.closestLivingEntity = list.get(0);
|
||||
Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, new Vec3d(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
|
||||
|
||||
if (vec3d == null)
|
||||
{
|
||||
if (vec3d == null) {
|
||||
return false; //Nowhere to run, gotta fight!
|
||||
} else if (this.closestLivingEntity.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity))
|
||||
{
|
||||
} else if (this.closestLivingEntity.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) {
|
||||
return false; //I'll be headed off if I choose this direction.
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z);
|
||||
return this.entityPathEntity != null;
|
||||
}
|
||||
|
@ -91,8 +84,7 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
|||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldContinueExecuting()
|
||||
{
|
||||
public boolean shouldContinueExecuting() {
|
||||
return this.theEntity.shouldEmergencyHeal();//!this.entityPathNavigate.noPath();
|
||||
}
|
||||
|
||||
|
@ -100,10 +92,8 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
|||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
if (this.entityPathEntity != null)
|
||||
{
|
||||
public void startExecuting() {
|
||||
if (this.entityPathEntity != null) {
|
||||
this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed);
|
||||
}
|
||||
}
|
||||
|
@ -112,8 +102,7 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
|||
* Resets the task
|
||||
*/
|
||||
@Override
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
this.closestLivingEntity = null;
|
||||
}
|
||||
|
||||
|
@ -121,33 +110,26 @@ public class EntityAIRetreatToHeal<T extends Entity> extends EntityAIBase
|
|||
* Updates the task
|
||||
*/
|
||||
@Override
|
||||
public void updateTask()
|
||||
{
|
||||
if (this.closestLivingEntity != null)
|
||||
{
|
||||
if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D)
|
||||
{
|
||||
public void updateTask() {
|
||||
if (this.closestLivingEntity != null) {
|
||||
if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D) {
|
||||
this.theEntity.getNavigator().setSpeed(this.nearSpeed);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.theEntity.getNavigator().setSpeed(this.farSpeed);
|
||||
}
|
||||
|
||||
if (this.theEntity.ticksExisted % 20 == 0 && this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) >= safeHealDistance * safeHealDistance)
|
||||
{
|
||||
if (this.theEntity.ticksExisted % 20 == 0 && this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) >= safeHealDistance * safeHealDistance) {
|
||||
healEntity();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.theEntity.ticksExisted % 20 == 0)
|
||||
{
|
||||
if (this.theEntity.ticksExisted % 20 == 0) {
|
||||
healEntity();
|
||||
}
|
||||
}
|
||||
|
||||
public void healEntity()
|
||||
{
|
||||
public void healEntity() {
|
||||
this.theEntity.performEmergencyHeal(2);
|
||||
}
|
||||
}
|
|
@ -1,29 +1,32 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
|
||||
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;
|
||||
public class EntityAIStealthRetreat extends EntityAIBase {
|
||||
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 */
|
||||
/**
|
||||
* The PathNavigate of our entity
|
||||
*/
|
||||
private final PathNavigate entityPathNavigate;
|
||||
|
||||
/**
|
||||
* The entity we are attached to
|
||||
*/
|
||||
protected EntityCorruptedChicken entity;
|
||||
/**
|
||||
* The PathEntity of our entity
|
||||
*/
|
||||
private Path entityPathEntity;
|
||||
private int ticksLeft = 0;
|
||||
|
||||
public EntityAIStealthRetreat(EntityCorruptedChicken theEntityIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn)
|
||||
{
|
||||
public EntityAIStealthRetreat(EntityCorruptedChicken theEntityIn, float avoidDistanceIn, double farSpeedIn, double nearSpeedIn) {
|
||||
this.entity = theEntityIn;
|
||||
this.avoidDistance = avoidDistanceIn;
|
||||
this.farSpeed = farSpeedIn;
|
||||
|
@ -33,26 +36,20 @@ public class EntityAIStealthRetreat extends EntityAIBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (this.entity.attackStateMachine == 2)
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
if (this.entity.attackStateMachine == 2) {
|
||||
EntityLivingBase attacked = this.entity.getAttackTarget();
|
||||
if (attacked == null)
|
||||
{
|
||||
if (attacked == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.entity, 16, 7, new Vec3d(attacked.posX, attacked.posY, attacked.posZ));
|
||||
|
||||
if (vec3d == null)
|
||||
{
|
||||
if (vec3d == null) {
|
||||
return false;
|
||||
} else if (attacked.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < attacked.getDistanceSqToEntity(this.entity))
|
||||
{
|
||||
} else if (attacked.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) < attacked.getDistanceSqToEntity(this.entity)) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z);
|
||||
return this.entityPathEntity != null;
|
||||
}
|
||||
|
@ -62,10 +59,8 @@ public class EntityAIStealthRetreat extends EntityAIBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldContinueExecuting()
|
||||
{
|
||||
if (this.entityPathNavigate.noPath())
|
||||
{
|
||||
public boolean shouldContinueExecuting() {
|
||||
if (this.entityPathNavigate.noPath()) {
|
||||
this.entity.attackStateMachine = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -74,33 +69,27 @@ public class EntityAIStealthRetreat extends EntityAIBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
ticksLeft = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
ticksLeft = this.entity.getEntityWorld().rand.nextInt(100) + 100;
|
||||
this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask()
|
||||
{
|
||||
public void updateTask() {
|
||||
ticksLeft--;
|
||||
if (ticksLeft <= 0 || this.entity.getAttackTarget() == null)
|
||||
{
|
||||
if (ticksLeft <= 0 || this.entity.getAttackTarget() == null) {
|
||||
this.entity.attackStateMachine = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.entity.getDistanceSqToEntity(this.entity.getAttackTarget()) < 49.0D)
|
||||
{
|
||||
if (this.entity.getDistanceSqToEntity(this.entity.getAttackTarget()) < 49.0D) {
|
||||
this.entity.getNavigator().setSpeed(this.nearSpeed);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.entity.getNavigator().setSpeed(this.farSpeed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,52 +1,43 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken;
|
||||
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
|
||||
{
|
||||
public class EntityAIStealthTowardsTarget extends EntityAIBase {
|
||||
private final EntityCorruptedChicken entity;
|
||||
private final double speed;
|
||||
private double xPosition;
|
||||
private double yPosition;
|
||||
private double zPosition;
|
||||
private final double speed;
|
||||
|
||||
private int ticksLeft = 0;
|
||||
|
||||
public EntityAIStealthTowardsTarget(EntityCorruptedChicken creatureIn, double speedIn)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (target instanceof EntityCreature) {
|
||||
vec3d = RandomPositionGenerator.findRandomTarget((EntityCreature) target, 10, 7);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);
|
||||
}
|
||||
|
||||
if (vec3d == null)
|
||||
{
|
||||
if (vec3d == null) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ticksLeft = this.entity.getEntityWorld().rand.nextInt(200) + 100;
|
||||
this.xPosition = vec3d.x;
|
||||
this.yPosition = vec3d.y;
|
||||
|
@ -56,36 +47,29 @@ public class EntityAIStealthTowardsTarget extends EntityAIBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
ticksLeft = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldContinueExecuting()
|
||||
{
|
||||
public boolean shouldContinueExecuting() {
|
||||
ticksLeft--;
|
||||
if (ticksLeft <= 0)
|
||||
{
|
||||
if (ticksLeft <= 0) {
|
||||
this.entity.attackStateMachine = 1;
|
||||
}
|
||||
|
||||
this.entity.cloak();
|
||||
|
||||
if (this.entity.getNavigator().noPath())
|
||||
{
|
||||
if (this.entity.getNavigator().noPath()) {
|
||||
EntityLivingBase target = this.entity.getAttackTarget();
|
||||
Vec3d vec3d;
|
||||
if (target instanceof EntityCreature)
|
||||
{
|
||||
if (target instanceof EntityCreature) {
|
||||
vec3d = RandomPositionGenerator.findRandomTarget((EntityCreature) target, 10, 7);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);
|
||||
}
|
||||
|
||||
if (vec3d != null)
|
||||
{
|
||||
if (vec3d != null) {
|
||||
this.xPosition = vec3d.x;
|
||||
this.yPosition = vec3d.y;
|
||||
this.zPosition = vec3d.z;
|
||||
|
@ -97,8 +81,7 @@ public class EntityAIStealthTowardsTarget extends EntityAIBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
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