-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from Fi0x/featureEntity
Feature entity
- Loading branch information
Showing
13 changed files
with
191 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/com/fi0x/deepmagic/entities/ai/EntityAIRandomFly.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.fi0x.deepmagic.entities.ai; | ||
|
||
import net.minecraft.entity.EntityCreature; | ||
import net.minecraft.entity.EntityLiving; | ||
import net.minecraft.entity.ai.EntityAIWanderAvoidWater; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
public class EntityAIRandomFly extends EntityAIWanderAvoidWater | ||
{ | ||
private final EntityLiving entity; | ||
|
||
public EntityAIRandomFly(EntityLiving entity, double speed) | ||
{ | ||
super((EntityCreature) entity, speed); | ||
this.entity = entity; | ||
this.executionChance = 50; | ||
this.setMutexBits(1); | ||
} | ||
|
||
@Override | ||
public boolean shouldExecute() | ||
{ | ||
if (!this.mustUpdate) | ||
{ | ||
if (this.entity.getIdleTime() >= 100) | ||
{ | ||
return false; | ||
} | ||
|
||
if (this.entity.getRNG().nextInt(this.executionChance) != 0) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
Vec3d vec3d = this.getPosition(); | ||
|
||
if (vec3d == null) | ||
{ | ||
return false; | ||
} | ||
else | ||
{ | ||
this.x = vec3d.x; | ||
this.y = vec3d.y; | ||
this.z = vec3d.z; | ||
this.mustUpdate = false; | ||
return true; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean shouldContinueExecuting() | ||
{ | ||
return super.shouldContinueExecuting(); | ||
} | ||
|
||
public void startExecuting() | ||
{ | ||
this.entity.getNavigator().tryMoveToXYZ(this.x, this.y, this.z, this.speed); | ||
} | ||
} |
Oops, something went wrong.