Small moth AI changes

This commit is contained in:
paulevsGitch 2021-11-30 14:48:34 +03:00
parent 9fb0bc9d67
commit a06427c060

View file

@ -208,24 +208,16 @@ public class SilkMothEntity extends DespawnableAnimal implements FlyingAnimal {
public void start() { public void start() {
Vec3 vec3d = null; Vec3 vec3d = null;
if (SilkMothEntity.this.hivePos != null && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.level) { if (SilkMothEntity.this.hivePos != null && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.level) {
if (SilkMothEntity.this.position() if (SilkMothEntity.this.position().distanceToSqr(SilkMothEntity.this.hivePos.getX(), SilkMothEntity.this.hivePos.getY(), SilkMothEntity.this.hivePos.getZ()) > 16) {
.distanceToSqr(SilkMothEntity.this.hivePos.getX(),
SilkMothEntity.this.hivePos.getY(),
SilkMothEntity.this.hivePos.getZ()
) > 16) {
vec3d = SilkMothEntity.this.position().add(random.nextGaussian() * 2, 0, random.nextGaussian() * 2); vec3d = SilkMothEntity.this.position().add(random.nextGaussian() * 2, 0, random.nextGaussian() * 2);
} }
} }
vec3d = vec3d == null ? this.getRandomLocation() : vec3d; vec3d = vec3d == null ? this.getRandomLocation() : vec3d;
if (vec3d != null) { if (vec3d != null) {
try { try {
SilkMothEntity.this.navigation.moveTo(SilkMothEntity.this.navigation.createPath( SilkMothEntity.this.navigation.moveTo(SilkMothEntity.this.navigation.createPath(new BlockPos(vec3d), 1), 1.0D);
new BlockPos(vec3d),
1
), 1.0D);
}
catch (Exception e) {
} }
catch (Exception e) {}
} }
} }
@ -252,16 +244,15 @@ public class SilkMothEntity extends DespawnableAnimal implements FlyingAnimal {
@Override @Override
public boolean canUse() { public boolean canUse() {
return SilkMothEntity.this.hivePos != null && SilkMothEntity.this.hiveWorld == SilkMothEntity.this.level && SilkMothEntity.this.navigation return SilkMothEntity.this.hivePos != null &&
.isDone() && SilkMothEntity.this.random.nextInt(16) == 0 && SilkMothEntity.this.position() SilkMothEntity.this.hiveWorld == SilkMothEntity.this.level &&
.distanceToSqr( SilkMothEntity.this.navigation.isDone() &&
SilkMothEntity.this.hivePos SilkMothEntity.this.random.nextInt(8) == 0 &&
.getX(), SilkMothEntity.this.position().distanceToSqr(
SilkMothEntity.this.hivePos SilkMothEntity.this.hivePos.getX(),
.getY(), SilkMothEntity.this.hivePos.getY(),
SilkMothEntity.this.hivePos SilkMothEntity.this.hivePos.getZ()
.getZ() ) < 256;
) < 64;
} }
@Override @Override