Fix teleporting onto a chunk line

Obscure detail in that if you teleport right on a chunk line, it
adds +1 to your collision check and will check the unloaded neighbor.

but the call to load the chunk then returned null if it was pending unload, such
as the load we did in Player List

However we want gen=true for players here anyways, so use getType
This commit is contained in:
Aikar 2020-05-10 05:36:35 -04:00
parent 57d6cc0158
commit c894ddfd38
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
3 changed files with 19 additions and 20 deletions

View File

@ -14,10 +14,10 @@ movement will load only the chunk the player enters anyways and avoids loading
massive amounts of surrounding chunks due to large AABB lookups.
diff --git a/src/main/java/net/minecraft/server/ICollisionAccess.java b/src/main/java/net/minecraft/server/ICollisionAccess.java
index f851ed11df14fd9aa8017f44d82fb6cfc3bde345..f817aaf17bee97e5023a1373bb774d94e7073be7 100644
index f851ed11df14fd9aa8017f44d82fb6cfc3bde345..948b86012bc604d3b1ba5a9e0c3b5b10ef529228 100644
--- a/src/main/java/net/minecraft/server/ICollisionAccess.java
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -83,19 +83,36 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -83,19 +83,33 @@ public interface ICollisionAccess extends IBlockAccess {
}
while (cursorposition.a()) {
@ -30,25 +30,24 @@ index f851ed11df14fd9aa8017f44d82fb6cfc3bde345..f817aaf17bee97e5023a1373bb774d94
int j2 = cursorposition.e();
if (j2 != 3) {
+ // Paper start - ensure we don't load chunks
int k2 = k1 >> 4;
int l2 = i2 >> 4;
- int k2 = k1 >> 4;
- int l2 = i2 >> 4;
- IBlockAccess iblockaccess = ICollisionAccess.this.c(k2, l2);
-
- if (iblockaccess != null) {
- blockposition_mutableblockposition.d(k1, l1, i2);
- IBlockData iblockdata = iblockaccess.getType(blockposition_mutableblockposition);
+ boolean far = entity != null && MCUtil.distance(entity.locX(), entity.locY(), entity.locZ(), x, y, z) > 8;
+ // Paper start - ensure we don't load chunks
+ //int k2 = k1 >> 4;
+ //int l2 = i2 >> 4;
+ boolean far = entity != null && MCUtil.distanceSq(entity.locX(), y, entity.locZ(), x, y, z) > 8;
+ blockposition_mutableblockposition.setValues(x, y, z);
+
+ boolean isRegionLimited = ICollisionAccess.this instanceof RegionLimitedWorldAccess;
+ IBlockData iblockdata = !isRegionLimited ? ICollisionAccess.this.getTypeIfLoaded(blockposition_mutableblockposition) : null;
+ if ((isRegionLimited || !far) && iblockdata == null) {
+ IBlockAccess c = ICollisionAccess.this.c(k2, l2);
+ if (c != null) {
+ iblockdata = c.getType(blockposition_mutableblockposition);
+ }
+ }
+ IBlockData iblockdata = isRegionLimited ? Blocks.VOID_AIR.getBlockData() : (!far && entity instanceof EntityPlayer
+ ? ICollisionAccess.this.getType(blockposition_mutableblockposition)
+ : ICollisionAccess.this.getTypeIfLoaded(blockposition_mutableblockposition)
+ );
+ if (iblockdata == null) {
+ if (!(entity instanceof EntityPlayer) || entity.world.paperConfig.preventMovingIntoUnloadedChunks) {
+ VoxelShape voxelshape3 = VoxelShapes.of(far ? entity.getBoundingBox() : new AxisAlignedBB(new BlockPosition(x, y, z)));

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 f817aaf17bee97e5023a1373bb774d94e7073be7..5baae144c598ce6d1c12c292db01d9b25520653e 100644
index e1699528556f5742d907ba4dc4d831e84a5f1287..2974467c2cb4ad9241f005c5a2935251434f7d78 100644
--- a/src/main/java/net/minecraft/server/ICollisionAccess.java
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -116,11 +116,24 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -113,11 +113,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,7 +21,7 @@ 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 5baae144c598ce6d1c12c292db01d9b25520653e..ab242a82493a78a89bbc0ab9113d10fd61864c02 100644
index 2974467c2cb4ad9241f005c5a2935251434f7d78..1270f8823817ef8f995bf73db1816de548cb8c21 100644
--- a/src/main/java/net/minecraft/server/ICollisionAccess.java
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -43,18 +43,39 @@ public interface ICollisionAccess extends IBlockAccess {
@ -94,8 +94,8 @@ index 5baae144c598ce6d1c12c292db01d9b25520653e..ab242a82493a78a89bbc0ab9113d10fd
}
}
@@ -105,9 +126,8 @@ public interface ICollisionAccess extends IBlockAccess {
}
@@ -102,9 +123,8 @@ public interface ICollisionAccess extends IBlockAccess {
);
if (iblockdata == null) {
if (!(entity instanceof EntityPlayer) || entity.world.paperConfig.preventMovingIntoUnloadedChunks) {
- VoxelShape voxelshape3 = VoxelShapes.of(far ? entity.getBoundingBox() : new AxisAlignedBB(new BlockPosition(x, y, z)));
@ -106,7 +106,7 @@ index 5baae144c598ce6d1c12c292db01d9b25520653e..ab242a82493a78a89bbc0ab9113d10fd
}
} else {
//blockposition_mutableblockposition.d(k1, l1, i2); // moved up
@@ -124,14 +144,14 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -121,14 +141,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 +125,7 @@ index 5baae144c598ce6d1c12c292db01d9b25520653e..ab242a82493a78a89bbc0ab9113d10fd
}
// Paper end
}
@@ -140,8 +160,9 @@ public interface ICollisionAccess extends IBlockAccess {
@@ -137,8 +157,9 @@ public interface ICollisionAccess extends IBlockAccess {
}
}