Ensure we load chunks for Entity getCubes

Was some other code paths missing the set for loading chunks

Fixes #3582
Fixes #3368

Probably helps with "falling through world" issues too.
This commit is contained in:
Aikar 2020-06-20 05:22:09 -04:00
parent 2a3cb3753f
commit 1f181040dd
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
4 changed files with 23 additions and 26 deletions

View File

@ -26,24 +26,20 @@ index 7434f859f7f9acff0f881ff594c8dffdfa249c76..7fb34a86dc35cb4bf51e1ce5220e5664
public CraftEntity getBukkitEntity() {
if (bukkitEntity == null) {
diff --git a/src/main/java/net/minecraft/server/ICollisionAccess.java b/src/main/java/net/minecraft/server/ICollisionAccess.java
index f851ed11df14fd9aa8017f44d82fb6cfc3bde345..667e6c8f94162b620a7157c7d3caba9369c37de1 100644
index f851ed11df14fd9aa8017f44d82fb6cfc3bde345..3eefbf4d5f10b53f930759a0afa5661253b92c60 100644
--- a/src/main/java/net/minecraft/server/ICollisionAccess.java
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -39,7 +39,12 @@ public interface ICollisionAccess extends IBlockAccess {
}
default boolean getCubes(Entity entity, AxisAlignedBB axisalignedbb) {
- return this.a(entity, axisalignedbb, Collections.emptySet());
+ // Paper start - load chunks for getCubes
+ entity.collisionLoadChunks = true;
+ boolean result = this.a(entity, axisalignedbb, Collections.emptySet());
+ entity.collisionLoadChunks = false;
+ return result;
+ // Paper end
@@ -43,7 +43,9 @@ public interface ICollisionAccess extends IBlockAccess {
}
default boolean a(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set) {
@@ -83,19 +88,33 @@ public interface ICollisionAccess extends IBlockAccess {
+ try { if (entity != null) entity.collisionLoadChunks = true; // Paper
return this.c(entity, axisalignedbb, set).allMatch(VoxelShape::isEmpty);
+ } finally { if (entity != null) entity.collisionLoadChunks = false; } // Paper
}
default Stream<VoxelShape> b(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set) {
@@ -83,19 +85,33 @@ public interface ICollisionAccess extends IBlockAccess {
}
while (cursorposition.a()) {
@ -88,7 +84,7 @@ index f851ed11df14fd9aa8017f44d82fb6cfc3bde345..667e6c8f94162b620a7157c7d3caba93
if ((j2 != 1 || iblockdata.f()) && (j2 != 2 || iblockdata.getBlock() == Blocks.MOVING_PISTON)) {
VoxelShape voxelshape2 = iblockdata.b((IBlockAccess) ICollisionAccess.this, blockposition_mutableblockposition, voxelshapecollision);
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index e479dedc889bdfabda99d9c2b36f6c4b7ce87a99..32d8cc7f22aaddef2e68506eeb44e01795f2aff5 100644
index 0ba103a5c60d8f5b8f332fe63364c597925a6450..157738f452493aabdefb228cd527ba85400baad5 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -677,6 +677,7 @@ public abstract class PlayerList {

View File

@ -9,10 +9,10 @@ Original code by JellySquid, licensed under GNU Lesser General Public License v3
you can find the original code on https://github.com/jellysquid3/lithium-fabric/tree/1.15.x/fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/server/ICollisionAccess.java b/src/main/java/net/minecraft/server/ICollisionAccess.java
index 667e6c8f94162b620a7157c7d3caba9369c37de1..ace1bb5bb89be256a7dc716f97429ee64b3c575f 100644
index 3eefbf4d5f10b53f930759a0afa5661253b92c60..5e20dba0d011d20b714d784cb4a545a05bbf6f9c 100644
--- a/src/main/java/net/minecraft/server/ICollisionAccess.java
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -118,11 +118,24 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -115,11 +115,24 @@ public interface ICollisionAccess extends IBlockAccess {
if ((j2 != 1 || iblockdata.f()) && (j2 != 2 || iblockdata.getBlock() == Blocks.MOVING_PISTON)) {
VoxelShape voxelshape2 = iblockdata.b((IBlockAccess) ICollisionAccess.this, blockposition_mutableblockposition, voxelshapecollision);

View File

@ -21,13 +21,13 @@ index e865a5694f78fb9273a0625ab2c30b87d0711a90..5648ba73c533f622c35c808decdb305f
default Stream<VoxelShape> b(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set) {
return IEntityAccess.super.b(entity, axisalignedbb, set);
diff --git a/src/main/java/net/minecraft/server/ICollisionAccess.java b/src/main/java/net/minecraft/server/ICollisionAccess.java
index ace1bb5bb89be256a7dc716f97429ee64b3c575f..0295e563aa027be5ca1a7eb78727aacf18729025 100644
index 5e20dba0d011d20b714d784cb4a545a05bbf6f9c..5a21205a49606b294de4cd27b60438c6a5b3c526 100644
--- a/src/main/java/net/minecraft/server/ICollisionAccess.java
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -48,18 +48,39 @@ public interface ICollisionAccess extends IBlockAccess {
}
@@ -44,19 +44,40 @@ public interface ICollisionAccess extends IBlockAccess {
default boolean a(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set) {
try { if (entity != null) entity.collisionLoadChunks = true; // Paper
- return this.c(entity, axisalignedbb, set).allMatch(VoxelShape::isEmpty);
+ // Paper start - reduce stream usage
+ java.util.List<VoxelShape> blockCollisions = getBlockCollision(entity, axisalignedbb, true);
@ -39,6 +39,7 @@ index ace1bb5bb89be256a7dc716f97429ee64b3c575f..0295e563aa027be5ca1a7eb78727aacf
+ }
+ return getEntityCollisions(entity, axisalignedbb, set, true).isEmpty();
+ // Paper end
} finally { if (entity != null) entity.collisionLoadChunks = false; } // Paper
}
+ default java.util.List<VoxelShape> getEntityCollisions(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set, boolean returnFast) { return java.util.Collections.emptyList(); } // Paper
@ -66,7 +67,7 @@ index ace1bb5bb89be256a7dc716f97429ee64b3c575f..0295e563aa027be5ca1a7eb78727aacf
int i = MathHelper.floor(axisalignedbb.minX - 1.0E-7D) - 1;
int j = MathHelper.floor(axisalignedbb.maxX + 1.0E-7D) + 1;
int k = MathHelper.floor(axisalignedbb.minY - 1.0E-7D) - 1;
@@ -71,19 +92,19 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -68,19 +89,19 @@ public interface ICollisionAccess extends IBlockAccess {
final BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
final VoxelShape voxelshape = VoxelShapes.a(axisalignedbb);
@ -94,7 +95,7 @@ index ace1bb5bb89be256a7dc716f97429ee64b3c575f..0295e563aa027be5ca1a7eb78727aacf
}
}
@@ -107,9 +128,8 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -104,9 +125,8 @@ public interface ICollisionAccess extends IBlockAccess {
);
if (iblockdata == null) {
if (!(entity instanceof EntityPlayer) || entity.world.paperConfig.preventMovingIntoUnloadedChunks) {
@ -106,7 +107,7 @@ index ace1bb5bb89be256a7dc716f97429ee64b3c575f..0295e563aa027be5ca1a7eb78727aacf
}
} else {
//blockposition_mutableblockposition.d(k1, l1, i2); // moved up
@@ -126,14 +146,14 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -123,14 +143,14 @@ public interface ICollisionAccess extends IBlockAccess {
if (voxelshape2 == VoxelShapes.fullCube()) {
if (axisalignedbb.intersects(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D)) {
@ -125,7 +126,7 @@ index ace1bb5bb89be256a7dc716f97429ee64b3c575f..0295e563aa027be5ca1a7eb78727aacf
}
// Paper end
}
@@ -142,8 +162,9 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -139,8 +159,9 @@ public interface ICollisionAccess extends IBlockAccess {
}
}

View File

@ -18,10 +18,10 @@ index c81b9d814d50a026872d2711f76649c00d65888b..e0ab058bf947ea10b37eadf6122292e7
StreamAccumulator<VoxelShape> streamaccumulator = new StreamAccumulator<>(Stream.concat(stream1, stream));
Vec3D vec3d1 = vec3d.g() == 0.0D ? vec3d : a(this, vec3d, axisalignedbb, this.world, voxelshapecollision, streamaccumulator);
diff --git a/src/main/java/net/minecraft/server/ICollisionAccess.java b/src/main/java/net/minecraft/server/ICollisionAccess.java
index 0295e563aa027be5ca1a7eb78727aacf18729025..dae8dd67bb7a94132ff421eff40fed73aa649c67 100644
index 5a21205a49606b294de4cd27b60438c6a5b3c526..63dd5e98b6af1d9a9fa9d01621ce5bc33c0d7502 100644
--- a/src/main/java/net/minecraft/server/ICollisionAccess.java
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -98,12 +98,12 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -95,12 +95,12 @@ public interface ICollisionAccess extends IBlockAccess {
if (true) { //public boolean tryAdvance(Consumer<? super VoxelShape> consumer) {*/ // Paper
if (entity != null) {
// Paper end
@ -38,7 +38,7 @@ index 0295e563aa027be5ca1a7eb78727aacf18729025..dae8dd67bb7a94132ff421eff40fed73
if (returnFast) return collisions;
}
}
@@ -136,7 +136,7 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -133,7 +133,7 @@ public interface ICollisionAccess extends IBlockAccess {
//IBlockData iblockdata = iblockaccess.getType(blockposition_mutableblockposition); // moved up
// Paper end