Path fix
This commit is contained in:
parent
886be5bbc6
commit
e2192b2c4b
1 changed files with 40 additions and 35 deletions
|
@ -34,14 +34,14 @@ import ru.betterend.util.BlocksHelper;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class EntityDragonfly extends AnimalEntity implements Flutterer {
|
public class EntityDragonfly extends AnimalEntity implements Flutterer {
|
||||||
public EntityDragonfly(EntityType<EntityDragonfly> entityType, World world) {
|
public EntityDragonfly(EntityType<EntityDragonfly> entityType, World world) {
|
||||||
super(entityType, world);
|
super(entityType, world);
|
||||||
this.moveControl = new FlightMoveControl(this, 20, true);
|
this.moveControl = new FlightMoveControl(this, 20, true);
|
||||||
this.lookControl = new DragonflyLookControl(this);
|
this.lookControl = new DragonflyLookControl(this);
|
||||||
this.setPathfindingPenalty(PathNodeType.WATER, -1.0F);
|
this.setPathfindingPenalty(PathNodeType.WATER, -1.0F);
|
||||||
this.setPathfindingPenalty(PathNodeType.DANGER_FIRE, -1.0F);
|
this.setPathfindingPenalty(PathNodeType.DANGER_FIRE, -1.0F);
|
||||||
this.experiencePoints = 1;
|
this.experiencePoints = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DefaultAttributeContainer.Builder createMobAttributes() {
|
public static DefaultAttributeContainer.Builder createMobAttributes() {
|
||||||
return LivingEntity.createLivingAttributes()
|
return LivingEntity.createLivingAttributes()
|
||||||
|
@ -128,26 +128,31 @@ public class EntityDragonfly extends AnimalEntity implements Flutterer {
|
||||||
}
|
}
|
||||||
|
|
||||||
class WanderAroundGoal extends Goal {
|
class WanderAroundGoal extends Goal {
|
||||||
WanderAroundGoal() {
|
WanderAroundGoal() {
|
||||||
this.setControls(EnumSet.of(Goal.Control.MOVE));
|
this.setControls(EnumSet.of(Goal.Control.MOVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canStart() {
|
public boolean canStart() {
|
||||||
return EntityDragonfly.this.navigation.isIdle() && EntityDragonfly.this.random.nextInt(10) == 0;
|
return EntityDragonfly.this.navigation.isIdle() && EntityDragonfly.this.random.nextInt(10) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldContinue() {
|
public boolean shouldContinue() {
|
||||||
return EntityDragonfly.this.navigation.isFollowingPath();
|
return EntityDragonfly.this.navigation.isFollowingPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
Vec3d vec3d = this.getRandomLocation();
|
Vec3d vec3d = this.getRandomLocation();
|
||||||
if (vec3d != null) {
|
if (vec3d != null) {
|
||||||
Path path = EntityDragonfly.this.navigation.findPathTo(new BlockPos(vec3d), 1);
|
BlockPos pos = new BlockPos(vec3d);
|
||||||
EntityDragonfly.this.navigation.startMovingAlong(path, 1.0D);
|
if (!pos.equals(EntityDragonfly.this.getBlockPos())) {
|
||||||
}
|
Path path = EntityDragonfly.this.navigation.findPathTo(new BlockPos(vec3d), 1);
|
||||||
super.start();
|
if (path != null) {
|
||||||
}
|
EntityDragonfly.this.navigation.startMovingAlong(path, 1.0D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.start();
|
||||||
|
}
|
||||||
|
|
||||||
private Vec3d getRandomLocation() {
|
private Vec3d getRandomLocation() {
|
||||||
int h = BlocksHelper.downRay(EntityDragonfly.this.world, EntityDragonfly.this.getBlockPos(), 16);
|
int h = BlocksHelper.downRay(EntityDragonfly.this.world, EntityDragonfly.this.getBlockPos(), 16);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue