mirror of https://github.com/cabaletta/baritone
Block lookup optimization
This commit is contained in:
parent
5a48f4119e
commit
3eb7610f89
|
@ -870,13 +870,10 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||||
clear = ctx.world().rayTraceBlocks(start, dest, false, false, false) == null;
|
clear = ctx.world().rayTraceBlocks(start, dest, false, false, false) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clear) {
|
if (Baritone.settings().renderRaytraces.value) {
|
||||||
this.clearLines.add(new Pair<>(start, dest));
|
(clear ? this.clearLines : this.blockedLines).add(new Pair<>(start, dest));
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
this.blockedLines.add(new Pair<>(start, dest));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return clear;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FloatArrayList pitchesToSolveFor(final float goodPitch, final boolean desperate) {
|
private static FloatArrayList pitchesToSolveFor(final float goodPitch, final boolean desperate) {
|
||||||
|
@ -1035,7 +1032,7 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||||
displacement.add(Vec3d.ZERO);
|
displacement.add(Vec3d.ZERO);
|
||||||
|
|
||||||
for (int i = 0; i < ticks; i++) {
|
for (int i = 0; i < ticks; i++) {
|
||||||
if (MC_1_12_Collision_Fix.bonk(ctx, hitbox)) {
|
if (MC_1_12_Collision_Fix.bonk(ctx, this.bsi, hitbox)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (delta.lengthSquared() < 1) {
|
if (delta.lengthSquared() < 1) {
|
||||||
|
@ -1132,32 +1129,35 @@ public final class ElytraBehavior extends Behavior implements IElytraBehavior, H
|
||||||
*/
|
*/
|
||||||
private static final class MC_1_12_Collision_Fix {
|
private static final class MC_1_12_Collision_Fix {
|
||||||
|
|
||||||
public static boolean bonk(final IPlayerContext ctx, final AxisAlignedBB aabb) {
|
public static boolean bonk(final IPlayerContext ctx, final BlockStateInterface bsi, final AxisAlignedBB aabb) {
|
||||||
final Vec3d center = aabb.getCenter();
|
final Vec3d center = aabb.getCenter();
|
||||||
final double width = (double) ctx.player().width * 0.35D;
|
final double width = (double) ctx.player().width * 0.35D;
|
||||||
final double x = center.x;
|
final double x = center.x;
|
||||||
final double y = aabb.minY + 0.5D;
|
final double y = aabb.minY + 0.5D;
|
||||||
final double z = center.z;
|
final double z = center.z;
|
||||||
|
|
||||||
return pushOutOfBlocks(ctx, x - width, y, z + width)
|
return pushOutOfBlocks(bsi, x - width, y, z + width)
|
||||||
|| pushOutOfBlocks(ctx, x - width, y, z - width)
|
|| pushOutOfBlocks(bsi, x - width, y, z - width)
|
||||||
|| pushOutOfBlocks(ctx, x + width, y, z - width)
|
|| pushOutOfBlocks(bsi, x + width, y, z - width)
|
||||||
|| pushOutOfBlocks(ctx, x + width, y, z + width);
|
|| pushOutOfBlocks(bsi, x + width, y, z + width);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean pushOutOfBlocks(final IPlayerContext ctx, final double x, final double y, final double z) {
|
private static boolean pushOutOfBlocks(final BlockStateInterface bsi,
|
||||||
final BlockPos pos = new BlockPos(x, y, z);
|
final double xIn, final double yIn, final double zIn) {
|
||||||
if (isOpenBlockSpace(ctx, pos)) {
|
final int x = MathHelper.floor(xIn);
|
||||||
|
final int y = MathHelper.floor(yIn);
|
||||||
|
final int z = MathHelper.floor(zIn);
|
||||||
|
if (isOpenBlockSpace(bsi, x, y, z)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isOpenBlockSpace(ctx, pos.west())
|
return isOpenBlockSpace(bsi, x - 1, y, z)
|
||||||
|| isOpenBlockSpace(ctx, pos.east())
|
|| isOpenBlockSpace(bsi, x + 1, y, z)
|
||||||
|| isOpenBlockSpace(ctx, pos.north())
|
|| isOpenBlockSpace(bsi, x, y, z - 1)
|
||||||
|| isOpenBlockSpace(ctx, pos.south());
|
|| isOpenBlockSpace(bsi, x, y, z + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isOpenBlockSpace(IPlayerContext ctx, BlockPos pos) {
|
private static boolean isOpenBlockSpace(BlockStateInterface bsi, final int x, final int y, final int z) {
|
||||||
return !ctx.world().getBlockState(pos).isNormalCube() && !ctx.world().getBlockState(pos.up()).isNormalCube();
|
return !bsi.get0(x, y, z).isNormalCube() && !bsi.get0(x, y + 1, z).isNormalCube();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue