more efficient ground detection

This commit is contained in:
batchprogrammer314
2021-06-27 21:45:11 -05:00
parent eaab1c0bc7
commit 86c50f24c7
2 changed files with 10 additions and 14 deletions

View File

@@ -44,9 +44,7 @@ public class Bot extends EntityPlayer {
GameProfile profile = new GameProfile(uuid, name);
PlayerInteractManager interactManager = new PlayerInteractManager(nmsWorld);
if (skin != null) {
setSkin(profile, skin);
}
Bot bot = new Bot(nmsServer, nmsWorld, profile, interactManager);
@@ -130,12 +128,17 @@ public class Bot extends EntityPlayer {
private void updateLocation() {
velocity.setY(velocity.getY() - 0.1);
double y;
if (predictGround()) {
velocity.setY(0);
addFriction();
y = 0;
} else {
y = velocity.getY();
}
this.move(EnumMoveType.SELF, new Vec3D(velocity.getX(), velocity.getY(), velocity.getZ()));
this.move(EnumMoveType.SELF, new Vec3D(velocity.getX(), y, velocity.getZ()));
}
public boolean predictGround() {
@@ -145,8 +148,6 @@ public class Bot extends EntityPlayer {
return false;
}
double m = vy / 20.0;
World world = getBukkitEntity().getWorld();
AxisAlignedBB box = getBoundingBox();
@@ -164,15 +165,11 @@ public class Bot extends EntityPlayer {
for (double z : zVals) {
double i = locY();
for (int n = 0; n < 20; n++) {
Location test = new Location(world, x, i, z);
Location test = new Location(world, x, i - 0.05, z);
if (test.getBlock().getType().isSolid()) {
return true;
}
i += m;
}
}
}

View File

@@ -17,7 +17,6 @@ public class MojangAPI {
.openStream())).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
return new String[] {property.get("value").getAsString(), property.get("signature").getAsString()};
} catch (Exception e) {
e.printStackTrace();
return null;
}
}