This commit is contained in:
paulevsGitch 2020-10-25 21:54:31 +03:00
parent 886be5bbc6
commit e2192b2c4b

View file

@ -34,14 +34,14 @@ import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class EntityDragonfly extends AnimalEntity implements Flutterer {
public EntityDragonfly(EntityType<EntityDragonfly> entityType, World world) {
super(entityType, world);
this.moveControl = new FlightMoveControl(this, 20, true);
this.lookControl = new DragonflyLookControl(this);
this.setPathfindingPenalty(PathNodeType.WATER, -1.0F);
public EntityDragonfly(EntityType<EntityDragonfly> entityType, World world) {
super(entityType, world);
this.moveControl = new FlightMoveControl(this, 20, true);
this.lookControl = new DragonflyLookControl(this);
this.setPathfindingPenalty(PathNodeType.WATER, -1.0F);
this.setPathfindingPenalty(PathNodeType.DANGER_FIRE, -1.0F);
this.experiencePoints = 1;
}
this.experiencePoints = 1;
}
public static DefaultAttributeContainer.Builder createMobAttributes() {
return LivingEntity.createLivingAttributes()
@ -128,26 +128,31 @@ public class EntityDragonfly extends AnimalEntity implements Flutterer {
}
class WanderAroundGoal extends Goal {
WanderAroundGoal() {
this.setControls(EnumSet.of(Goal.Control.MOVE));
}
WanderAroundGoal() {
this.setControls(EnumSet.of(Goal.Control.MOVE));
}
public boolean canStart() {
return EntityDragonfly.this.navigation.isIdle() && EntityDragonfly.this.random.nextInt(10) == 0;
}
public boolean canStart() {
return EntityDragonfly.this.navigation.isIdle() && EntityDragonfly.this.random.nextInt(10) == 0;
}
public boolean shouldContinue() {
return EntityDragonfly.this.navigation.isFollowingPath();
}
public boolean shouldContinue() {
return EntityDragonfly.this.navigation.isFollowingPath();
}
public void start() {
Vec3d vec3d = this.getRandomLocation();
if (vec3d != null) {
Path path = EntityDragonfly.this.navigation.findPathTo(new BlockPos(vec3d), 1);
EntityDragonfly.this.navigation.startMovingAlong(path, 1.0D);
}
super.start();
}
public void start() {
Vec3d vec3d = this.getRandomLocation();
if (vec3d != null) {
BlockPos pos = new BlockPos(vec3d);
if (!pos.equals(EntityDragonfly.this.getBlockPos())) {
Path path = EntityDragonfly.this.navigation.findPathTo(new BlockPos(vec3d), 1);
if (path != null) {
EntityDragonfly.this.navigation.startMovingAlong(path, 1.0D);
}
}
}
super.start();
}
private Vec3d getRandomLocation() {
int h = BlocksHelper.downRay(EntityDragonfly.this.world, EntityDragonfly.this.getBlockPos(), 16);