Heavily improved Valkyrie battle
This commit is contained in:
parent
08a855f83e
commit
f534ebf8d5
|
@ -4,31 +4,26 @@ import net.minecraft.entity.EntityCreature;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.pathfinding.Path;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityAIAttackContinuously extends EntityAIBase
|
||||
{
|
||||
|
||||
World worldObj;
|
||||
protected EntityCreature attacker;
|
||||
protected int attackTick;
|
||||
private EntityCreature attacker;
|
||||
|
||||
private int attackTick;
|
||||
|
||||
double speedTowardsTarget;
|
||||
boolean longMemory;
|
||||
Path entityPathEntity;
|
||||
|
||||
private double targetX;
|
||||
private double targetY;
|
||||
private double targetZ;
|
||||
protected final int attackInterval = 20;
|
||||
|
||||
public EntityAIAttackContinuously(EntityCreature creature, double speedIn, boolean useLongMemory)
|
||||
public EntityAIAttackContinuously(EntityCreature creature, double speedIn)
|
||||
{
|
||||
this.attacker = creature;
|
||||
this.worldObj = creature.worldObj;
|
||||
this.speedTowardsTarget = speedIn;
|
||||
this.longMemory = useLongMemory;
|
||||
|
||||
this.setMutexBits(3);
|
||||
}
|
||||
|
||||
|
@ -47,8 +42,7 @@ public class EntityAIAttackContinuously extends EntityAIBase
|
|||
}
|
||||
else
|
||||
{
|
||||
this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
|
||||
return this.entityPathEntity != null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,13 +50,13 @@ public class EntityAIAttackContinuously extends EntityAIBase
|
|||
public boolean continueExecuting()
|
||||
{
|
||||
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
|
||||
return entitylivingbase == null ? false : (!entitylivingbase.isEntityAlive() ? false : (!this.longMemory ? !this.attacker.getNavigator().noPath() : (!this.attacker.isWithinHomeDistanceFromPosition(new BlockPos(entitylivingbase)) ? false : !(entitylivingbase instanceof EntityPlayer) || !((EntityPlayer)entitylivingbase).isSpectator() && !((EntityPlayer)entitylivingbase).isCreative())));
|
||||
return entitylivingbase != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting()
|
||||
{
|
||||
this.attacker.getNavigator().setPath(this.entityPathEntity, this.speedTowardsTarget);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,18 +68,19 @@ public class EntityAIAttackContinuously extends EntityAIBase
|
|||
{
|
||||
this.attacker.setAttackTarget((EntityLivingBase)null);
|
||||
}
|
||||
|
||||
this.attacker.getNavigator().clearPathEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask()
|
||||
{
|
||||
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
|
||||
this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
|
||||
|
||||
this.attacker.getNavigator().setPath(this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase), this.speedTowardsTarget);
|
||||
this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 360.0F, 360.0F);
|
||||
|
||||
double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
|
||||
|
||||
if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
|
||||
if (this.attacker.getEntitySenses().canSee(entitylivingbase) && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
|
||||
{
|
||||
this.targetX = entitylivingbase.posX;
|
||||
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.EntityAISwimming;
|
||||
import net.minecraft.entity.ai.EntityAIWatchClosest;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -47,7 +48,7 @@ public class EntityValkyrieQueen extends EntityMob
|
|||
|
||||
public static final DataParameter<Boolean> VALKYRIE_READY = EntityDataManager.<Boolean>createKey(EntityValkyrieQueen.class, DataSerializers.BOOLEAN);
|
||||
|
||||
private EntityAIAttackContinuously enhancedCombat = new EntityAIAttackContinuously(this, 0.65D, false);
|
||||
private EntityAIAttackContinuously enhancedCombat = new EntityAIAttackContinuously(this, 0.65D);
|
||||
|
||||
public int angerLevel;
|
||||
|
||||
|
@ -85,8 +86,9 @@ public class EntityValkyrieQueen extends EntityMob
|
|||
public void registerEntityAI()
|
||||
{
|
||||
this.targetTasks.addTask(0, this.enhancedCombat);
|
||||
this.tasks.addTask(0, new EntityAISwimming(this));
|
||||
this.tasks.addTask(1, new EntityAISwimming(this));
|
||||
this.tasks.addTask(2, new ValkyrieQueenAIWander(this, 0.5D));
|
||||
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F, 200.0F));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -259,8 +261,6 @@ public class EntityValkyrieQueen extends EntityMob
|
|||
}
|
||||
else
|
||||
{
|
||||
super.onEntityUpdate();
|
||||
|
||||
if (this.getAttackTarget() instanceof EntityPlayer)
|
||||
{
|
||||
if (this.timeUntilTeleport++ >= 450)
|
||||
|
@ -475,7 +475,7 @@ public class EntityValkyrieQueen extends EntityMob
|
|||
boolean flag = false;
|
||||
|
||||
this.swingArm();
|
||||
flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), 7);
|
||||
flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), 8);
|
||||
|
||||
if (entity != null && this.getAttackTarget() != null && entity == this.getAttackTarget() && entity instanceof EntityPlayer)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue