mirror of
https://github.com/allaryin/FairyFactions.git
synced 2026-04-25 08:04:06 -05:00
parent
1b415df928
commit
2a78dd6d04
|
|
@ -1,13 +1,82 @@
|
|||
package fairies.ai;
|
||||
|
||||
import fairies.FairyConfig;
|
||||
import fairies.FairyFactions;
|
||||
import fairies.entity.EntityFairy;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.pathfinding.PathEntity;
|
||||
|
||||
public class FairyAIFear extends EntityAIBase {
|
||||
|
||||
private EntityFairy theFairy;
|
||||
protected double speed;
|
||||
|
||||
public FairyAIFear(EntityFairy fairy, double speedIn) {
|
||||
this.theFairy = fairy;
|
||||
this.speed = speedIn;
|
||||
|
||||
this.setMutexBits(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
EntityLivingBase entityFear = this.theFairy.getEntityFear();
|
||||
if( entityFear == null ) {
|
||||
return false;
|
||||
} else if( entityFear.isDead ) {
|
||||
this.theFairy.setEntityFear(null);
|
||||
return false;
|
||||
} else if( !this.theFairy.hasPath()
|
||||
&& this.theFairy.canEntityBeSeen(entityFear)
|
||||
&& this.theFairy.willCower() ) {
|
||||
|
||||
float dist = this.theFairy.getDistanceToEntity(entityFear);
|
||||
if( dist > FairyConfig.BEHAVIOR_FEAR_RANGE ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting() {
|
||||
FairyFactions.LOGGER.debug(this.theFairy.toString()+": starting fear");
|
||||
final PathEntity dest = this.theFairy.roam(this.theFairy.getEntityFear(), this.theFairy, EntityFairy.PATH_AWAY);
|
||||
this.theFairy.setCryTime( this.theFairy.getCryTime() + 120 );
|
||||
this.theFairy.getNavigator().setPath(dest, this.speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueExecuting() {
|
||||
return !this.theFairy.getNavigator().noPath();
|
||||
}
|
||||
|
||||
/*
|
||||
* Original fear handler method from EntityFairy
|
||||
*
|
||||
private void handleFear() {
|
||||
if (getEntityFear() != null) {
|
||||
if (getEntityFear().isDead) {
|
||||
// Don't fear the dead.
|
||||
setEntityFear(null);
|
||||
} else if (!hasPath() && canEntityBeSeen(getEntityFear())
|
||||
&& willCower()) {
|
||||
float dist = getDistanceToEntity(getEntityFear());
|
||||
|
||||
// Run from entityFear if you can see it and it is close.
|
||||
if (dist < FairyConfig.BEHAVIOR_FEAR_RANGE) {
|
||||
PathEntity dest = roam(getEntityFear(), this, PATH_AWAY);
|
||||
|
||||
if (dest != null) {
|
||||
// setPathToEntity(dest);
|
||||
this.getNavigator().setPath(dest, this.getAIMoveSpeed());
|
||||
setCryTime(getCryTime() + 120);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import fairies.FairyConfig;
|
|||
import fairies.FairyFactions;
|
||||
import fairies.Loc;
|
||||
import fairies.Version;
|
||||
import fairies.ai.FairyAIFear;
|
||||
import fairies.ai.FairyJob;
|
||||
import fairies.world.FairyGroupGenerator;
|
||||
import net.minecraft.block.Block;
|
||||
|
|
@ -105,12 +106,10 @@ public class EntityFairy extends EntityAnimal {
|
|||
public float sinage; // what does this mean?
|
||||
//private boolean flag; // flagged for what, precisely?
|
||||
private boolean createGroup;
|
||||
private int listActions;
|
||||
public int witherTime;
|
||||
private ItemStack tempItem;
|
||||
private boolean isSwinging;
|
||||
private int particleCount;
|
||||
private boolean flyBlocked;
|
||||
|
||||
public EntityFairy(World world) {
|
||||
super(world);
|
||||
|
|
@ -141,6 +140,8 @@ public class EntityFairy extends EntityAnimal {
|
|||
}));
|
||||
this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntitySkeleton.class, false));
|
||||
*/
|
||||
|
||||
this.tasks.addTask(2, new FairyAIFear(this, 2.0D));
|
||||
|
||||
// fairy-specific init
|
||||
setSkin(rand.nextInt(4));
|
||||
|
|
@ -923,29 +924,6 @@ public class EntityFairy extends EntityAnimal {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleFear() {
|
||||
if (getEntityFear() != null) {
|
||||
if (getEntityFear().isDead) {
|
||||
// Don't fear the dead.
|
||||
setEntityFear(null);
|
||||
} else if (!hasPath() && canEntityBeSeen(getEntityFear())
|
||||
&& willCower()) {
|
||||
float dist = getDistanceToEntity(getEntityFear());
|
||||
|
||||
// Run from entityFear if you can see it and it is close.
|
||||
if (dist < FairyConfig.BEHAVIOR_FEAR_RANGE) {
|
||||
PathEntity dest = roam(getEntityFear(), this, PATH_AWAY);
|
||||
|
||||
if (dest != null) {
|
||||
// setPathToEntity(dest);
|
||||
this.getNavigator().setPath(dest, this.getAIMoveSpeed());
|
||||
setCryTime(getCryTime() + 120);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRuler() {
|
||||
// TODO: create constants for all of these ranges and time limits
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user