2
1
Fork 1
mirror of https://github.com/ACGaming/Spackenmobs synced 2024-06-10 22:48:54 +02:00
Spackenmobs/src/main/java/mod/acgaming/spackenmobs/entities/ai/EntityAISmavaCreeperSwell.java
2020-10-17 13:57:39 +02:00

51 lines
1.4 KiB
Java

package mod.acgaming.spackenmobs.entities.ai;
import mod.acgaming.spackenmobs.entities.EntitySmavaCreeper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
public class EntityAISmavaCreeperSwell extends EntityAIBase
{
EntitySmavaCreeper swellingCreeper;
EntityLivingBase creeperAttackTarget;
public EntityAISmavaCreeperSwell(EntitySmavaCreeper entitycreeperIn)
{
this.swellingCreeper = entitycreeperIn;
this.setMutexBits(1);
}
public boolean shouldExecute()
{
EntityLivingBase entitylivingbase = this.swellingCreeper.getAttackTarget();
return this.swellingCreeper.getCreeperState() > 0 || entitylivingbase != null && this.swellingCreeper.getDistanceSq(entitylivingbase) < 9.0D;
}
public void startExecuting()
{
this.swellingCreeper.getNavigator().clearPath();
this.creeperAttackTarget = this.swellingCreeper.getAttackTarget();
}
public void resetTask()
{
this.creeperAttackTarget = null;
}
public void updateTask()
{
if (this.creeperAttackTarget == null)
{
this.swellingCreeper.setCreeperState(-1);
} else if (this.swellingCreeper.getDistanceSq(this.creeperAttackTarget) > 49.0D)
{
this.swellingCreeper.setCreeperState(-1);
} else if (!this.swellingCreeper.getEntitySenses().canSee(this.creeperAttackTarget))
{
this.swellingCreeper.setCreeperState(-1);
} else
{
this.swellingCreeper.setCreeperState(1);
}
}
}