From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sun, 10 May 2020 22:49:05 -0400 Subject: [PATCH] Optimize WorldBorder collision checks and air diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 759a91f43c9890602f4bb372eb241ebc0128b310..9b5cad1f1137cb6c73f423dada1ae027218086ca 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -854,7 +854,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke AxisAlignedBB axisalignedbb = this.getBoundingBox(); VoxelShapeCollision voxelshapecollision = VoxelShapeCollision.a(this); VoxelShape voxelshape = this.world.getWorldBorder().c(); - Stream stream = VoxelShapes.c(voxelshape, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(voxelshape); + Stream stream = !this.world.getWorldBorder().isInBounds(axisalignedbb) ? Stream.empty() : Stream.of(voxelshape); // Paper Stream stream1 = this.world.c(this, axisalignedbb.b(vec3d), (entity) -> { return true; }); diff --git a/src/main/java/net/minecraft/server/VoxelShapeSpliterator.java b/src/main/java/net/minecraft/server/VoxelShapeSpliterator.java index ed0f3ddbcb7d6ce8a59ae3829f4cb11ae75046cb..e841611bb7c36dffec44bb9e74a0a9657a113263 100644 --- a/src/main/java/net/minecraft/server/VoxelShapeSpliterator.java +++ b/src/main/java/net/minecraft/server/VoxelShapeSpliterator.java @@ -128,10 +128,10 @@ public class VoxelShapeSpliterator extends AbstractSpliterator { AxisAlignedBB axisalignedbb = this.a.getBoundingBox(); if (!a(worldborder, axisalignedbb)) { - VoxelShape voxelshape = worldborder.c(); - - if (!b(voxelshape, axisalignedbb) && a(voxelshape, axisalignedbb)) { - consumer.accept(voxelshape); + // Paper start + if (worldborder.isInBounds(axisalignedbb.shrink(1.0E-7D)) && !worldborder.isInBounds(axisalignedbb.grow(1.0E-7D))) { + consumer.accept(worldborder.asVoxelShape()); + // Paper end return true; } } diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java index aeee4f11828e54ff9e873e452e19299822b1ec86..1fa7061f7adb539b6786fa11a0090f2c188ba9f2 100644 --- a/src/main/java/net/minecraft/server/VoxelShapes.java +++ b/src/main/java/net/minecraft/server/VoxelShapes.java @@ -242,7 +242,7 @@ public final class VoxelShapes { IBlockData iblockdata = iworldreader.getTypeIfLoaded(blockposition_mutableblockposition); // Paper if (iblockdata == null) return 0.0D; // Paper - if ((k2 != 1 || iblockdata.d()) && (k2 != 2 || iblockdata.a(Blocks.MOVING_PISTON))) { + if (!iblockdata.isAir() && (k2 != 1 || iblockdata.d()) && (k2 != 2 || iblockdata.a(Blocks.MOVING_PISTON))) { // Paper d0 = iblockdata.b((IBlockAccess) iworldreader, blockposition_mutableblockposition, voxelshapecollision).a(enumdirection_enumaxis2, axisalignedbb.d((double) (-blockposition_mutableblockposition.getX()), (double) (-blockposition_mutableblockposition.getY()), (double) (-blockposition_mutableblockposition.getZ())), d0); if (Math.abs(d0) < 1.0E-7D) { return 0.0D; diff --git a/src/main/java/net/minecraft/server/WorldBorder.java b/src/main/java/net/minecraft/server/WorldBorder.java index 0ef92a320d132b443e76276b2c34a4626cf187db..b651eb87bb23deeb2a3f4a1c626ddde9b11a7b9e 100644 --- a/src/main/java/net/minecraft/server/WorldBorder.java +++ b/src/main/java/net/minecraft/server/WorldBorder.java @@ -42,6 +42,7 @@ public class WorldBorder { return (double) chunkcoordintpair.f() > this.e() && (double) chunkcoordintpair.d() < this.g() && (double) chunkcoordintpair.g() > this.f() && (double) chunkcoordintpair.e() < this.h(); } + public final boolean isInBounds(AxisAlignedBB aabb) { return this.a(aabb); } // Paper - OBFHELPER public boolean a(AxisAlignedBB axisalignedbb) { return axisalignedbb.maxX > this.e() && axisalignedbb.minX < this.g() && axisalignedbb.maxZ > this.f() && axisalignedbb.minZ < this.h(); }