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 ee714e312d
commit a26aabf9d0
2 changed files with 11 additions and 12 deletions

View file

@ -30,25 +30,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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

@ -95,7 +95,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
@@ -0,0 +0,0 @@ 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)));