2021-06-14 08:37:14 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
|
|
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/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
2021-06-16 11:07:43 +00:00
|
|
|
index 5db6b853e61e62e40e55034d5738717664cb9245..4965d6beb0486400f5d28220d6e132e2029cf86e 100644
|
2021-06-14 08:37:14 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2021-06-16 05:36:02 +00:00
|
|
|
@@ -1044,7 +1044,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
2021-06-14 08:37:14 +00:00
|
|
|
AABB axisalignedbb = this.getBoundingBox();
|
|
|
|
CollisionContext voxelshapecollision = CollisionContext.of(this);
|
|
|
|
VoxelShape voxelshape = this.level.getWorldBorder().getCollisionShape();
|
|
|
|
- Stream<VoxelShape> stream = Shapes.joinIsNotEmpty(voxelshape, Shapes.create(axisalignedbb.deflate(1.0E-7D)), BooleanOp.AND) ? Stream.empty() : Stream.of(voxelshape);
|
|
|
|
+ Stream<VoxelShape> stream = !this.level.getWorldBorder().isWithinBounds(axisalignedbb) ? Stream.empty() : Stream.of(voxelshape); // Paper
|
|
|
|
Stream<VoxelShape> stream1 = this.level.getEntityCollisions(this, axisalignedbb.expandTowards(movement), (entity) -> {
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java
|
|
|
|
index 90039d01ef481ba206f2e952c99a755e94201ea3..2e93f33d6c9074c246c2289523b1fda20a2cf0dd 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/level/CollisionSpliterator.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/CollisionSpliterator.java
|
|
|
|
@@ -135,9 +135,10 @@ public class CollisionSpliterator extends AbstractSpliterator<VoxelShape> {
|
|
|
|
WorldBorder worldBorder = this.collisionGetter.getWorldBorder();
|
|
|
|
AABB aABB = this.source.getBoundingBox();
|
|
|
|
if (!isBoxFullyWithinWorldBorder(worldBorder, aABB)) {
|
|
|
|
- VoxelShape voxelShape = worldBorder.getCollisionShape();
|
|
|
|
- if (!isOutsideBorder(voxelShape, aABB) && isCloseToBorder(voxelShape, aABB)) {
|
|
|
|
- action.accept(voxelShape);
|
|
|
|
+ // Paper start
|
|
|
|
+ if (worldBorder.isWithinBounds(aABB.deflate(1.0E-7D)) && !worldBorder.isWithinBounds(aABB.inflate(1.0E-7D))) {
|
|
|
|
+ action.accept(worldBorder.asVoxelShape());
|
|
|
|
+ // Paper end
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
|
|
|
|
index 94f58332bb1408971fe65e5fd0401457ab986441..ceeec68fba8dacdc5b023c8817a6863b28c0e132 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
|
|
|
|
@@ -240,7 +240,7 @@ public final class Shapes {
|
|
|
|
mutableBlockPos.set(axisCycle, q, r, p);
|
|
|
|
BlockState blockState = world.getTypeIfLoaded(mutableBlockPos); // Paper
|
|
|
|
if (blockState == null) return 0.0D; // Paper
|
|
|
|
- if ((s != 1 || blockState.hasLargeCollisionShape()) && (s != 2 || blockState.is(Blocks.MOVING_PISTON))) {
|
|
|
|
+ if (!blockState.isAir() && (s != 1 || blockState.hasLargeCollisionShape()) && (s != 2 || blockState.is(Blocks.MOVING_PISTON))) { // Paper
|
|
|
|
initial = blockState.getCollisionShape(world, mutableBlockPos, context).collide(axis3, box.move((double)(-mutableBlockPos.getX()), (double)(-mutableBlockPos.getY()), (double)(-mutableBlockPos.getZ())), initial);
|
|
|
|
if (Math.abs(initial) < 1.0E-7D) {
|
|
|
|
return 0.0D;
|