Fix empty/null chunk section check in LevelChunk#getBlockData, rename… (#7039)

… patch and methods to make more sense with Mojang mappings
This commit is contained in:
Jason 2021-12-05 15:32:02 -08:00 committed by GitHub
parent 7c8fdc1fb6
commit fd263ef962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 166 additions and 163 deletions

View file

@ -6026,7 +6026,7 @@ index 3a4f026c73cdd22d30bdadabbcf24bef969b73e4..0d536d72ac918fbd403397ff369d1014
private final String name;
private final Comparator<T> comparator;
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
index d679be6c3ce0d57fa2063a45baec1b108a0a2707..c34dcba5c94a321f236fa8c70021adf3cf190bdc 100644
index d679be6c3ce0d57fa2063a45baec1b108a0a2707..de5e18a331178da8f7e82aa2419a0ee606e801ee 100644
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
@@ -152,6 +152,26 @@ public class WorldGenRegion implements WorldGenLevel {
@ -6041,13 +6041,13 @@ index d679be6c3ce0d57fa2063a45baec1b108a0a2707..c34dcba5c94a321f236fa8c70021adf3
+ }
+
+ @Override
+ public BlockState getTypeIfLoaded(BlockPos blockposition) {
+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) {
+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ return chunk == null ? null : chunk.getBlockState(blockposition);
+ }
+
+ @Override
+ public FluidState getFluidIfLoaded(BlockPos blockposition) {
+ public final FluidState getFluidIfLoaded(BlockPos blockposition) {
+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ return chunk == null ? null : chunk.getFluidState(blockposition);
+ }
@ -6195,7 +6195,7 @@ index 962c942c05fc02befef6c306df51c0b438dd1dab..566f1b8a0acd679b2f776db2e80458b1
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
index 76251b5adf41f8e5bf2c07145abe3108fcde8669..a60b8043540cacfa8cc3baba0872eefd4fc9464d 100644
index 76251b5adf41f8e5bf2c07145abe3108fcde8669..8a979600b49e8a11982577fb6dd79503e2521a0f 100644
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
@@ -9,10 +9,12 @@ import javax.annotation.Nullable;
@ -6216,17 +6216,17 @@ index 76251b5adf41f8e5bf2c07145abe3108fcde8669..a60b8043540cacfa8cc3baba0872eefd
BlockState getBlockState(BlockPos pos);
+ // Paper start - if loaded util
+ @Nullable BlockState getTypeIfLoaded(BlockPos blockposition);
+ default Material getMaterialIfLoaded(BlockPos blockposition) {
+ BlockState type = this.getTypeIfLoaded(blockposition);
+ @Nullable BlockState getBlockStateIfLoaded(BlockPos blockposition);
+ default @Nullable Material getMaterialIfLoaded(BlockPos blockposition) {
+ BlockState type = this.getBlockStateIfLoaded(blockposition);
+ return type == null ? null : type.getMaterial();
+ }
+
+ default Block getBlockIfLoaded(BlockPos blockposition) {
+ BlockState type = this.getTypeIfLoaded(blockposition);
+ default @Nullable Block getBlockIfLoaded(BlockPos blockposition) {
+ BlockState type = this.getBlockStateIfLoaded(blockposition);
+ return type == null ? null : type.getBlock();
+ }
+ FluidState getFluidIfLoaded(BlockPos blockposition);
+ @Nullable FluidState getFluidIfLoaded(BlockPos blockposition);
+ // Paper end
FluidState getFluidState(BlockPos pos);
@ -6273,7 +6273,7 @@ index bd7d159bdc21d7fcb25db1e3f07b9ad9d7eb5157..4c5f8a103b550a681178926096d5f758
}
diff --git a/src/main/java/net/minecraft/world/level/EmptyBlockGetter.java b/src/main/java/net/minecraft/world/level/EmptyBlockGetter.java
index 3c707d6674b2594b09503b959a31c1f4ad3981e6..c7d499bfc22152e0a49f50a2a8133f31a1be20ff 100644
index 3c707d6674b2594b09503b959a31c1f4ad3981e6..db61b6b0158a9bcc0e1d735e34fe3671f8c89e21 100644
--- a/src/main/java/net/minecraft/world/level/EmptyBlockGetter.java
+++ b/src/main/java/net/minecraft/world/level/EmptyBlockGetter.java
@@ -17,6 +17,18 @@ public enum EmptyBlockGetter implements BlockGetter {
@ -6282,13 +6282,13 @@ index 3c707d6674b2594b09503b959a31c1f4ad3981e6..c7d499bfc22152e0a49f50a2a8133f31
+ // Paper start - If loaded util
+ @Override
+ public FluidState getFluidIfLoaded(BlockPos blockposition) {
+ return this.getFluidState(blockposition);
+ public final FluidState getFluidIfLoaded(BlockPos blockposition) {
+ return Fluids.EMPTY.defaultFluidState();
+ }
+
+ @Override
+ public BlockState getTypeIfLoaded(BlockPos blockposition) {
+ return this.getBlockState(blockposition);
+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) {
+ return Blocks.AIR.defaultBlockState();
+ }
+ // Paper end
+
@ -6296,7 +6296,7 @@ index 3c707d6674b2594b09503b959a31c1f4ad3981e6..c7d499bfc22152e0a49f50a2a8133f31
public BlockState getBlockState(BlockPos pos) {
return Blocks.AIR.defaultBlockState();
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index f18ae5b80c930c3a7c2da079b9926ab2657c36a3..9e6a02a05ea20c21aed26ed4bc92488627febd4c 100644
index f18ae5b80c930c3a7c2da079b9926ab2657c36a3..84b462d5f3c9727f8da6d254e67a7a752c4508d3 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -85,6 +85,7 @@ import org.bukkit.craftbukkit.CraftServer;
@ -6333,7 +6333,7 @@ index f18ae5b80c930c3a7c2da079b9926ab2657c36a3..9e6a02a05ea20c21aed26ed4bc924886
+
+ @Override
+ @Nullable
+ public final BlockState getTypeIfLoaded(BlockPos blockposition) {
+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) {
+ // CraftBukkit start - tree generation
+ if (captureTreeGeneration) {
+ CraftBlockState previous = capturedBlockStates.get(blockposition);
@ -6351,15 +6351,15 @@ index f18ae5b80c930c3a7c2da079b9926ab2657c36a3..9e6a02a05ea20c21aed26ed4bc924886
+ }
+
+ @Override
+ public FluidState getFluidIfLoaded(BlockPos blockposition) {
+ public final FluidState getFluidIfLoaded(BlockPos blockposition) {
+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+
+ return chunk == null ? null : chunk.getFluidState(blockposition);
+ }
+ // Paper end
+
+ @Override
+ public final ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { // Paper - final for inline
+ // Paper end
ChunkAccess ichunkaccess = this.getChunkSource().getChunk(chunkX, chunkZ, leastStatus, create);
if (ichunkaccess == null && create) {
@ -6394,7 +6394,7 @@ index a1cb8379ed4062d765659e829ba2262487ce7f8b..aa76f45d18f23997af5a950855981796
ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create);
diff --git a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java
index 47bd74f75f4c49a34a485d1963325a2152756c29..7c921d024205b683c3881c4db9314155359bd9c7 100644
index 47bd74f75f4c49a34a485d1963325a2152756c29..0dcf1c8926e471fa40517a5c92354116dad3c3c2 100644
--- a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java
+++ b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java
@@ -5,6 +5,7 @@ import javax.annotation.Nullable;
@ -6405,36 +6405,46 @@ index 47bd74f75f4c49a34a485d1963325a2152756c29..7c921d024205b683c3881c4db9314155
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
@@ -83,6 +84,29 @@ public class PathNavigationRegion implements BlockGetter, CollisionGetter {
return List.of();
@@ -60,7 +61,7 @@ public class PathNavigationRegion implements BlockGetter, CollisionGetter {
private ChunkAccess getChunk(int chunkX, int chunkZ) {
int i = chunkX - this.centerX;
int j = chunkZ - this.centerZ;
- if (i >= 0 && i < this.chunks.length && j >= 0 && j < this.chunks[i].length) {
+ if (i >= 0 && i < this.chunks.length && j >= 0 && j < this.chunks[i].length) { // Paper - if this changes, update getChunkIfLoaded below
ChunkAccess chunkAccess = this.chunks[i][j];
return (ChunkAccess)(chunkAccess != null ? chunkAccess : new EmptyLevelChunk(this.level, new ChunkPos(chunkX, chunkZ)));
} else {
@@ -68,6 +69,30 @@ public class PathNavigationRegion implements BlockGetter, CollisionGetter {
}
}
+ // Paper start - if loaded util
+ private ChunkAccess getChunkIfLoaded(int x, int z) {
+ int k = x - this.centerX;
+ int l = z - this.centerZ;
+ private @Nullable ChunkAccess getChunkIfLoaded(int x, int z) {
+ // Based on getChunk(int, int)
+ int xx = x - this.centerX;
+ int zz = z - this.centerZ;
+
+ if (k >= 0 && k < this.chunks.length && l >= 0 && l < this.chunks[k].length) { // Paper - if this changes, update getChunkIfLoaded below
+ return this.chunks[k][l];
+ if (xx >= 0 && xx < this.chunks.length && zz >= 0 && zz < this.chunks[xx].length) {
+ return this.chunks[xx][zz];
+ }
+ return null;
+ }
+ @Override
+ public FluidState getFluidIfLoaded(BlockPos blockposition) {
+ public final FluidState getFluidIfLoaded(BlockPos blockposition) {
+ ChunkAccess chunk = getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ return chunk == null ? null : chunk.getFluidState(blockposition);
+ }
+
+ @Override
+ public BlockState getTypeIfLoaded(BlockPos blockposition) {
+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) {
+ ChunkAccess chunk = getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ return chunk == null ? null : chunk.getBlockState(blockposition);
+ }
+ // Paper end
+
@Nullable
@Override
public BlockEntity getBlockEntity(BlockPos pos) {
public WorldBorder getWorldBorder() {
return this.level.getWorldBorder();
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index 0cb0b6143e3307e546c78ecda2c35ac31a8a7001..a3f44e3a44b2ec21ef41f6d598b428448c847c5f 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@ -6511,7 +6521,7 @@ index bfcaaa69991342f71fba4df46f69aea2ec6adca7..0ea0690ab1d45f60a2b13cf8a69e5802
this.levelHeightAccessor = heightLimitView;
this.sections = new LevelChunkSection[heightLimitView.getSectionsCount()];
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 28555314738ba891e0e36d3c85b1623116f743dd..0f8302c8fda85f8fb5cf24974d9013706dcc5a0a 100644
index 28555314738ba891e0e36d3c85b1623116f743dd..f263022e1d15e78b51cfd148cf024b9a8c761898 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -24,6 +24,7 @@ import net.minecraft.nbt.CompoundTag;
@ -6639,12 +6649,12 @@ index 28555314738ba891e0e36d3c85b1623116f743dd..0f8302c8fda85f8fb5cf24974d901370
+ // Paper start - If loaded util
+ @Override
+ public FluidState getFluidIfLoaded(BlockPos blockposition) {
+ public final FluidState getFluidIfLoaded(BlockPos blockposition) {
+ return this.getFluidState(blockposition);
+ }
+
+ @Override
+ public BlockState getTypeIfLoaded(BlockPos blockposition) {
+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) {
+ return this.getBlockState(blockposition);
+ }
+ // Paper end
@ -6710,7 +6720,7 @@ index 28555314738ba891e0e36d3c85b1623116f743dd..0f8302c8fda85f8fb5cf24974d901370
@Override
diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
index 1ea0048e1ee5321a1fd1584ac5371a371de9d45f..b7dbdcb0ce7948c6f98ec67d0cf2033a8e348085 100644
index 1ea0048e1ee5321a1fd1584ac5371a371de9d45f..41530d0b759604716f739d10f41627871f2ba319 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
@@ -73,6 +73,18 @@ public class ProtoChunk extends ChunkAccess {
@ -6719,12 +6729,12 @@ index 1ea0048e1ee5321a1fd1584ac5371a371de9d45f..b7dbdcb0ce7948c6f98ec67d0cf2033a
+ // Paper start - If loaded util
+ @Override
+ public FluidState getFluidIfLoaded(BlockPos blockposition) {
+ public final FluidState getFluidIfLoaded(BlockPos blockposition) {
+ return this.getFluidState(blockposition);
+ }
+
+ @Override
+ public BlockState getTypeIfLoaded(BlockPos blockposition) {
+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) {
+ return this.getBlockState(blockposition);
+ }
+ // Paper end
@ -6992,7 +7002,7 @@ index 9d57eda5d5c16004776c2e23837425cfe9184476..b39819d579c548318f1539702fb2df97
public static byte toLegacyData(BlockState data) {
diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
index 939789831f14621800c6792d20119079fc51b6f1..aff1a282516119e0f6026f1b35d6ee72859e8670 100644
index 939789831f14621800c6792d20119079fc51b6f1..9ab8159975f58a0014edbe3a368490b3590882ea 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
@@ -212,7 +212,23 @@ public class DummyGeneratorAccess implements WorldGenLevel {
@ -7007,7 +7017,7 @@ index 939789831f14621800c6792d20119079fc51b6f1..aff1a282516119e0f6026f1b35d6ee72
+ }
+
+ @Override
+ public BlockState getTypeIfLoaded(BlockPos blockposition) {
+ public BlockState getBlockStateIfLoaded(BlockPos blockposition) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Add World Util Methods
Methods that can be used for other patches to help improve logic.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 032e1e08413f2d0f601cdc32fe12145e2c1fec5f..19c97a14cbf23130db2de80e3f7f6e0c4ff27662 100644
index 7bc41c8546bc665b085cad6c384d0a5fab9f0b8b..51046d9fb37eabdbf76dee23cea81b6ee3406140 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -206,7 +206,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -19,35 +19,29 @@ index 032e1e08413f2d0f601cdc32fe12145e2c1fec5f..19c97a14cbf23130db2de80e3f7f6e0c
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 4060b72729609f66e5ad7b14f4aafa3c6a79a0e1..a4c0b2ee7a5c6a11ed2f93c63106570f1dfb2072 100644
index 731e1cefd2a9c829bfe82ec87038d9333ef21fb3..648642a30b499532f55f80a103f759740d815691 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -314,11 +314,27 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}
@Override
- public FluidState getFluidIfLoaded(BlockPos blockposition) {
+ public final FluidState getFluidIfLoaded(BlockPos blockposition) {
ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
@@ -320,6 +320,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return chunk == null ? null : chunk.getFluidState(blockposition);
}
+
+ public final boolean isLoadedAndInBounds(BlockPos blockposition) { // Paper - final for inline
+ return getWorldBorder().isWithinBounds(blockposition) && getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null;
+ }
+
+ public LevelChunk getChunkIfLoaded(int x, int z) { // Overridden in WorldServer for ABI compat which has final
+ public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { // Overridden in WorldServer for ABI compat which has final
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(x, z);
+ }
+ public final LevelChunk getChunkIfLoaded(BlockPos blockposition) {
+ public final @Nullable LevelChunk getChunkIfLoaded(BlockPos blockposition) {
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ }
+
+ // reduces need to do isLoaded before getType
+ public final BlockState getTypeIfLoadedAndInBounds(BlockPos blockposition) {
+ return getWorldBorder().isWithinBounds(blockposition) ? getTypeIfLoaded(blockposition) : null;
+ public final @Nullable BlockState getBlockStateIfLoadedAndInBounds(BlockPos blockposition) {
+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null;
+ }
// Paper end
+
@Override
public final ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { // Paper - final for inline
// Paper end

View file

@ -1,8 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 02:07:55 -0600
Subject: [PATCH] Optimize isValidLocation, getType and getBlockData for
inlining
Subject: [PATCH] Optimize isInWorldBounds and getBlockState for inlining
Hot methods, so reduce # of instructions for the method.
@ -13,27 +12,24 @@ Replace all calls to the new place to the unnecessary forward.
Optimize getType and getBlockData to manually inline and optimize the calls
diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java
index 543d5a67e76a3114f6eac29a053ff04ceecb6256..c33bac27edfdab4c3ee618c9ed39c629b1513f09 100644
index 543d5a67e76a3114f6eac29a053ff04ceecb6256..cf7cbab325865c8e0d114187a5a15f7345ec7f89 100644
--- a/src/main/java/net/minecraft/core/Vec3i.java
+++ b/src/main/java/net/minecraft/core/Vec3i.java
@@ -33,6 +33,15 @@ public class Vec3i implements Comparable<Vec3i> {
@@ -33,6 +33,12 @@ public class Vec3i implements Comparable<Vec3i> {
return CODEC.flatXmap(checkOffsetAxes(maxAbsValue), checkOffsetAxes(maxAbsValue));
}
+ // Paper start
+ public boolean isValidLocation(net.minecraft.world.level.LevelHeightAccessor levelHeightAccessor) {
+ public final boolean isInsideBuildHeightAndWorldBoundsHorizontal(net.minecraft.world.level.LevelHeightAccessor levelHeightAccessor) {
+ return getX() >= -30000000 && getZ() >= -30000000 && getX() < 30000000 && getZ() < 30000000 && !levelHeightAccessor.isOutsideBuildHeight(getY());
+ }
+ public boolean isInvalidYLocation(net.minecraft.world.level.LevelHeightAccessor levelHeightAccessor) {
+ return levelHeightAccessor.isOutsideBuildHeight(getY());
+ }
+ // Paper end
+
public Vec3i(int x, int y, int z) {
this.x = x;
this.y = y;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index de1bb9ecb8891b66b2c469f2ee52b9eee9d7ddea..7ee958e6a4f16780aa746ce0eb8cb8ee27df08e1 100644
index de1bb9ecb8891b66b2c469f2ee52b9eee9d7ddea..c28285ab7e698a214aea6ff4a5ff6d4f8b8b52bd 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -263,7 +263,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@ -41,32 +37,33 @@ index de1bb9ecb8891b66b2c469f2ee52b9eee9d7ddea..7ee958e6a4f16780aa746ce0eb8cb8ee
public boolean isInWorldBounds(BlockPos pos) {
- return !this.isOutsideBuildHeight(pos) && Level.isInWorldBoundsHorizontal(pos);
+ return pos.isValidLocation(this); // Paper - use better/optimized check
+ return pos.isInsideBuildHeightAndWorldBoundsHorizontal(this); // Paper - use better/optimized check
}
public static boolean isInSpawnableBounds(BlockPos pos) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
index 0ea0690ab1d45f60a2b13cf8a69e580256992cdc..046afe19aa30f466a08461e3a504c9bbf78f7a3c 100644
index 0ea0690ab1d45f60a2b13cf8a69e580256992cdc..b3b3fa7ece66e1ab467c8ed550d150db541fd02a 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -119,6 +119,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
return GameEventDispatcher.NOOP;
}
+ public abstract BlockState getType(final int x, final int y, final int z); // Paper
+ public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper
@Nullable
public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean moved);
diff --git a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
index 31d01f8df394e718f1f2a268ddccee77b6706eb9..25e9cc39d748dfd99d38f504c14f40f9ec7bdd2d 100644
index 31d01f8df394e718f1f2a268ddccee77b6706eb9..7b0da3956be23e974d3bc2f50f9004046923635f 100644
--- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
@@ -18,6 +18,11 @@ public class EmptyLevelChunk extends LevelChunk {
@@ -18,6 +18,12 @@ public class EmptyLevelChunk extends LevelChunk {
super(world, pos);
}
+ // Paper start
+ @Override public BlockState getType(int x, int y, int z) {
+ @Override
+ public BlockState getBlockState(int x, int y, int z) {
+ return Blocks.VOID_AIR.defaultBlockState();
+ }
+ // Paper end
@ -74,26 +71,27 @@ index 31d01f8df394e718f1f2a268ddccee77b6706eb9..25e9cc39d748dfd99d38f504c14f40f9
public BlockState getBlockState(BlockPos pos) {
return Blocks.VOID_AIR.defaultBlockState();
diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
index ef74f37cae96e61d5648fce7bbd793fb67ba9e4a..7c5b3acd299c5b021bd20f17ff0b89c8208a6623 100644
index ef74f37cae96e61d5648fce7bbd793fb67ba9e4a..e15263a152c88371ebc65b47f0be938f7c19a8f2 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
@@ -46,6 +46,11 @@ public class ImposterProtoChunk extends ProtoChunk {
@@ -46,6 +46,12 @@ public class ImposterProtoChunk extends ProtoChunk {
public BlockState getBlockState(BlockPos pos) {
return this.wrapped.getBlockState(pos);
}
+ // Paper start
+ public final BlockState getType(final int x, final int y, final int z) {
+ return this.wrapped.getBlockData(x, y, z);
+ @Override
+ public final BlockState getBlockState(final int x, final int y, final int z) {
+ return this.wrapped.getBlockStateFinal(x, y, z);
+ }
+ // Paper end
@Override
public FluidState getFluidState(BlockPos pos) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index d207e54019360f7f94bfa5301462fe3c8ac6758e..327b513c75e75d4b07d3c3b6deda9d1d00b6cd7f 100644
index f9fbe225cc11b2bafa733e92d9537aaa7c1e007b..78cb2d16654cd679531bba9d7d9d0cb810e689e2 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -288,12 +288,28 @@ public class LevelChunk extends ChunkAccess {
@@ -288,12 +288,29 @@ public class LevelChunk extends ChunkAccess {
});
}
@ -103,16 +101,17 @@ index d207e54019360f7f94bfa5301462fe3c8ac6758e..327b513c75e75d4b07d3c3b6deda9d1d
- int i = pos.getX();
- int j = pos.getY();
- int k = pos.getZ();
+ return this.getBlockData(pos.getX(), pos.getY(), pos.getZ());
+ return this.getBlockStateFinal(pos.getX(), pos.getY(), pos.getZ());
+ }
+
+ public BlockState getType(final int x, final int y, final int z) {
+ return this.getBlockData(x, y, z);
+ @Override
+ public BlockState getBlockState(final int x, final int y, final int z) {
+ return this.getBlockStateFinal(x, y, z);
+ }
+ public final BlockState getBlockData(final int x, final int y, final int z) {
+ public final BlockState getBlockStateFinal(final int x, final int y, final int z) {
+ // Method body / logic copied from below
+ final int i = this.getSectionIndex(y);
+ if (i < 0 || i >= this.sections.length || this.sections[i] == null || this.sections[i].nonEmptyBlockCount == 0) {
+ if (i < 0 || i >= this.sections.length || this.sections[i].nonEmptyBlockCount == 0 || this.sections[i].hasOnlyAir()) {
+ return Blocks.AIR.defaultBlockState();
+ }
+ // Inlined ChunkSection.getType() and DataPaletteBlock.a(int,int,int)
@ -120,7 +119,7 @@ index d207e54019360f7f94bfa5301462fe3c8ac6758e..327b513c75e75d4b07d3c3b6deda9d1d
+ }
+
+ public BlockState getBlockData_unused(int i, int j, int k) {
+ public BlockState getBlockState_unused(int i, int j, int k) {
+ // Paper end
if (this.level.isDebug()) {
BlockState iblockdata = null;
@ -139,7 +138,7 @@ index 6abd3cf0a388b158252628d8031b92bb8a6d65fb..50b6ecfea7a342be0d21e37ae87777a4
private short tickingFluidCount;
public final PalettedContainer<BlockState> states;
diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
index b7dbdcb0ce7948c6f98ec67d0cf2033a8e348085..568dc3c9cbf009a3892766cacdd00667556e27c5 100644
index b7dbdcb0ce7948c6f98ec67d0cf2033a8e348085..150dd90598bbe4057b4e9ad17c87a4c07af3d56d 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
@@ -87,14 +87,18 @@ public class ProtoChunk extends ChunkAccess {
@ -149,9 +148,9 @@ index b7dbdcb0ce7948c6f98ec67d0cf2033a8e348085..568dc3c9cbf009a3892766cacdd00667
- int i = pos.getY();
- if (this.isOutsideBuildHeight(i)) {
+ // Paper start
+ return getType(pos.getX(), pos.getY(), pos.getZ());
+ return getBlockState(pos.getX(), pos.getY(), pos.getZ());
+ }
+ public BlockState getType(final int x, final int y, final int z) {
+ public BlockState getBlockState(final int x, final int y, final int z) {
+ if (this.isOutsideBuildHeight(y)) {
return Blocks.VOID_AIR.defaultBlockState();
} else {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Do not load chunks for Pathfinding
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
index be29c3a361415064c418256d5c0eca9e5a7cefd2..c33fda773ec071d27e924461a30a2938db35c231 100644
index 9e4d43b5846ebebf9169ad906db68804292e7fe0..e23679b8c2bc35de82cb3245f35b53b44058f53d 100644
--- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
@@ -453,7 +453,12 @@ public class WalkNodeEvaluator extends NodeEvaluator {
@ -14,7 +14,7 @@ index be29c3a361415064c418256d5c0eca9e5a7cefd2..c33fda773ec071d27e924461a30a2938
pos.set(i + l, j + m, k + n);
- BlockState blockState = world.getBlockState(pos);
+ // Paper start
+ BlockState blockState = world.getTypeIfLoaded(pos);
+ BlockState blockState = world.getBlockStateIfLoaded(pos);
+ if (blockState == null) {
+ return BlockPathTypes.BLOCKED;
+ } else {
@ -35,7 +35,7 @@ index be29c3a361415064c418256d5c0eca9e5a7cefd2..c33fda773ec071d27e924461a30a2938
protected static BlockPathTypes getBlockPathTypeRaw(BlockGetter world, BlockPos pos) {
- BlockState blockState = world.getBlockState(pos);
+ BlockState blockState = world.getTypeIfLoaded(pos); // Paper
+ BlockState blockState = world.getBlockStateIfLoaded(pos); // Paper
+ if (blockState == null) return BlockPathTypes.BLOCKED; // Paper
Block block = blockState.getBlock();
Material material = blockState.getMaterial();

View file

@ -19,7 +19,7 @@ index d7734fbc6b684b14bc32c94e65947fb41aae126a..80345730b8ccc11d3d0833485d25b03f
+ }
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 2e04012bdea67baee7c541a9006a99cd4f454e79..8ec42170fc72bddba61e3b03612f801e1fd07343 100644
index 614e3255394a0988bcb19afaf066b1c2322ca1f0..6611affe664150139780ac596eab698c8843490c 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -259,7 +259,7 @@ public class LevelChunk extends ChunkAccess {
@ -31,7 +31,7 @@ index 2e04012bdea67baee7c541a9006a99cd4f454e79..8ec42170fc72bddba61e3b03612f801e
this.needsDecoration = true; // CraftBukkit
// CraftBukkit start
this.persistentDataContainer = protoChunk.persistentDataContainer; // SPIGOT-6814: copy PDC to account for 1.17 to 1.18 chunk upgrading.
@@ -581,6 +581,12 @@ public class LevelChunk extends ChunkAccess {
@@ -582,6 +582,12 @@ public class LevelChunk extends ChunkAccess {
"Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16));
e.printStackTrace();
ServerInternalException.reportInternalException(e);

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Prevent Frosted Ice from loading/holding chunks
1.17: Shouldn't be needed as blocks no longer tick without at least 1 radius chunk loaded.
diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
index 48776edab1479b5e861eca8146da04ebee01c46a..e0903ecf7a478d0a341d6ad6d94f06aef9836cc9 100644
index 48776edab1479b5e861eca8146da04ebee01c46a..4f27969196fe21b38e81d070fe5c0a999dd320dc 100644
--- a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
@@ -38,7 +38,8 @@ public class FrostedIceBlock extends IceBlock {
@ -14,7 +14,7 @@ index 48776edab1479b5e861eca8146da04ebee01c46a..e0903ecf7a478d0a341d6ad6d94f06ae
for(Direction direction : Direction.values()) {
mutableBlockPos.setWithOffset(pos, direction);
- BlockState blockState = world.getBlockState(mutableBlockPos);
+ BlockState blockState = world.getTypeIfLoaded(mutableBlockPos); // Paper
+ BlockState blockState = world.getBlockStateIfLoaded(mutableBlockPos); // Paper
+ if (blockState == null) { continue; } // Paper
if (blockState.is(this) && !this.slightlyMelt(blockState, world, mutableBlockPos)) {
world.scheduleTick(mutableBlockPos, this, Mth.nextInt(random, world.paperConfig.frostedIceDelayMin, world.paperConfig.frostedIceDelayMax)); // Paper - use configurable min/max delay
@ -25,7 +25,7 @@ index 48776edab1479b5e861eca8146da04ebee01c46a..e0903ecf7a478d0a341d6ad6d94f06ae
mutableBlockPos.setWithOffset(pos, direction);
- if (world.getBlockState(mutableBlockPos).is(this)) {
+ // Paper start
+ BlockState blockState = world.getTypeIfLoaded(mutableBlockPos);
+ BlockState blockState = world.getBlockStateIfLoaded(mutableBlockPos);
+ if (blockState != null && blockState.is(this)) {
+ // Paper end
++i;

View file

@ -21,10 +21,10 @@ This is based upon conclusions drawn from inspecting the assenmbly generated byt
They had 'callq' (invoke) instead of 'mov' (get from memory) instructions.
diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java
index c33bac27edfdab4c3ee618c9ed39c629b1513f09..6de2ea6641433206027015695a0d10c80fe0e2f5 100644
index 749660a685a6a1e425681c64bbbfef32958a0808..ca9355da97b8569c9168487263977f75e60ab997 100644
--- a/src/main/java/net/minecraft/core/Vec3i.java
+++ b/src/main/java/net/minecraft/core/Vec3i.java
@@ -53,7 +53,7 @@ public class Vec3i implements Comparable<Vec3i> {
@@ -50,7 +50,7 @@ public class Vec3i implements Comparable<Vec3i> {
}
@Override
@ -33,7 +33,7 @@ index c33bac27edfdab4c3ee618c9ed39c629b1513f09..6de2ea6641433206027015695a0d10c8
if (this == object) {
return true;
} else if (!(object instanceof Vec3i)) {
@@ -71,7 +71,7 @@ public class Vec3i implements Comparable<Vec3i> {
@@ -68,7 +68,7 @@ public class Vec3i implements Comparable<Vec3i> {
}
@Override
@ -42,7 +42,7 @@ index c33bac27edfdab4c3ee618c9ed39c629b1513f09..6de2ea6641433206027015695a0d10c8
return (this.getY() + this.getZ() * 31) * 31 + this.getX();
}
@@ -84,15 +84,15 @@ public class Vec3i implements Comparable<Vec3i> {
@@ -81,15 +81,15 @@ public class Vec3i implements Comparable<Vec3i> {
}
}

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Prevent chunk loading from Fluid Flowing
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
index 4be8fbe06ee97d5fe8f99d5d8137ac7302ffec91..18e24f400289fdfca0bf33ea0f93badeef3e46eb 100644
index 4be8fbe06ee97d5fe8f99d5d8137ac7302ffec91..49b8e9a764a868975ec832ea354bb0df99f9721a 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -175,7 +175,8 @@ public abstract class FlowingFluid extends Fluid {
@ -13,7 +13,7 @@ index 4be8fbe06ee97d5fe8f99d5d8137ac7302ffec91..18e24f400289fdfca0bf33ea0f93bade
FluidState fluid1 = (FluidState) entry.getValue();
BlockPos blockposition1 = pos.relative(enumdirection);
- BlockState iblockdata1 = world.getBlockState(blockposition1);
+ BlockState iblockdata1 = world.getTypeIfLoaded(blockposition1); // Paper
+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper
+ if (iblockdata1 == null) continue; // Paper
if (this.canSpreadTo(world, pos, blockState, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
@ -24,7 +24,7 @@ index 4be8fbe06ee97d5fe8f99d5d8137ac7302ffec91..18e24f400289fdfca0bf33ea0f93bade
BlockPos blockposition1 = pos.relative(enumdirection);
- BlockState iblockdata1 = world.getBlockState(blockposition1);
+
+ BlockState iblockdata1 = world.getTypeIfLoaded(blockposition1); // Paper
+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper
+ if (iblockdata1 == null) continue; // Paper
FluidState fluid = iblockdata1.getFluidState();
@ -38,7 +38,7 @@ index 4be8fbe06ee97d5fe8f99d5d8137ac7302ffec91..18e24f400289fdfca0bf33ea0f93bade
+ // Paper start - avoid loading chunks
+ Pair<BlockState, FluidState> pair = short2objectmap.get(short0);
+ if (pair == null) {
+ BlockState iblockdatax = world.getTypeIfLoaded(blockposition2);
+ BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition2);
+ if (iblockdatax == null) {
+ continue;
+ }
@ -64,7 +64,7 @@ index 4be8fbe06ee97d5fe8f99d5d8137ac7302ffec91..18e24f400289fdfca0bf33ea0f93bade
+ // Paper start
+ Pair pair = (Pair) short2objectmap.get(short0);
+ if (pair == null) {
+ BlockState iblockdatax = world.getTypeIfLoaded(blockposition1);
+ BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition1);
+ if (iblockdatax == null) continue;
+
+ pair = Pair.of(iblockdatax, iblockdatax.getFluidState());

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Prevent Mob AI Rules from Loading Chunks
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
index 4a67daa7ee7f8c0fcb37c2a0fdba158485343a1f..a618b50ac8448528ac6ac64b400fa3d0882dbaf9 100644
index 4a67daa7ee7f8c0fcb37c2a0fdba158485343a1f..027ef44d46cb1dda19c5c239f6970c90285fb961 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
@@ -133,7 +133,9 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
@ -13,7 +13,7 @@ index 4a67daa7ee7f8c0fcb37c2a0fdba158485343a1f..a618b50ac8448528ac6ac64b400fa3d0
@Nullable
private BlockPos getPosWithBlock(BlockPos pos, BlockGetter world) {
- if (world.getBlockState(pos).is(this.blockToRemove)) {
+ net.minecraft.world.level.block.state.BlockState block = world.getTypeIfLoaded(pos); // Paper
+ net.minecraft.world.level.block.state.BlockState block = world.getBlockStateIfLoaded(pos); // Paper
+ if (block == null) return null; // Paper
+ if (block.is(this.blockToRemove)) { // Paper
return pos;
@ -24,7 +24,7 @@ index 4a67daa7ee7f8c0fcb37c2a0fdba158485343a1f..a618b50ac8448528ac6ac64b400fa3d0
BlockPos blockposition1 = ablockposition1[j];
- if (world.getBlockState(blockposition1).is(this.blockToRemove)) {
+ net.minecraft.world.level.block.state.BlockState block2 = world.getTypeIfLoaded(blockposition1); // Paper
+ net.minecraft.world.level.block.state.BlockState block2 = world.getBlockStateIfLoaded(blockposition1); // Paper
+ if (block2 != null && block2.is(this.blockToRemove)) { // Paper
return blockposition1;
}

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Prevent mob spawning from loading/generating chunks
also prevents if out of world border bounds
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
index 831799937d4e1f31dbf7caaf0c6b38762ccec127..86cdb9ea888b85424285fc26534dc7a7ad3610ac 100644
index 831799937d4e1f31dbf7caaf0c6b38762ccec127..94d2d83da52ce20f12a4e3f235f75d5c537ae9d1 100644
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
@@ -196,9 +196,9 @@ public final class NaturalSpawner {
@ -14,7 +14,7 @@ index 831799937d4e1f31dbf7caaf0c6b38762ccec127..86cdb9ea888b85424285fc26534dc7a7
ChunkGenerator chunkgenerator = world.getChunkSource().getGenerator();
int i = pos.getY();
- BlockState iblockdata = chunk.getBlockState(pos);
+ BlockState iblockdata = world.getTypeIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn
+ BlockState iblockdata = world.getBlockStateIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn
- if (!iblockdata.isRedstoneConductor(chunk, pos)) {
+ if (iblockdata != null && !iblockdata.isRedstoneConductor(chunk, pos)) { // Paper - don't load chunks for mob spawn

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Don't allow digging into unloaded chunks
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 1d1f355a49e2324902feee10c1717fd772e359c6..44e5ab0b545de41b937c7ce304ce643f78a43734 100644
index 1d1f355a49e2324902feee10c1717fd772e359c6..d0b54ebc05cac6535a023709c76efd802f7150f9 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -118,8 +118,8 @@ public class ServerPlayerGameMode {
@ -14,7 +14,7 @@ index 1d1f355a49e2324902feee10c1717fd772e359c6..44e5ab0b545de41b937c7ce304ce643f
if (this.hasDelayedDestroy) {
- iblockdata = this.level.getBlockState(this.delayedDestroyPos);
- if (iblockdata.isAir()) {
+ iblockdata = this.level.getTypeIfLoaded(this.delayedDestroyPos); // Paper
+ iblockdata = this.level.getBlockStateIfLoaded(this.delayedDestroyPos); // Paper
+ if (iblockdata == null || iblockdata.isAir()) { // Paper
this.hasDelayedDestroy = false;
} else {
@ -25,7 +25,7 @@ index 1d1f355a49e2324902feee10c1717fd772e359c6..44e5ab0b545de41b937c7ce304ce643f
} else if (this.isDestroyingBlock) {
- iblockdata = this.level.getBlockState(this.destroyPos);
+ // Paper start - don't want to do same logic as above, return instead
+ iblockdata = this.level.getTypeIfLoaded(this.destroyPos);
+ iblockdata = this.level.getBlockStateIfLoaded(this.destroyPos);
+ if (iblockdata == null) {
+ this.isDestroyingBlock = false;
+ return;
@ -51,7 +51,7 @@ index 1d1f355a49e2324902feee10c1717fd772e359c6..44e5ab0b545de41b937c7ce304ce643f
ServerPlayerGameMode.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, pos); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
- this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
- this.player.connection.send(new ClientboundBlockBreakAckPacket(this.destroyPos, this.level.getBlockState(this.destroyPos), action, true, "aborted mismatched destroying"));
+ BlockState type = this.level.getTypeIfLoaded(this.destroyPos); // Paper - don't load unloaded chunks for stale records here
+ BlockState type = this.level.getBlockStateIfLoaded(this.destroyPos); // Paper - don't load unloaded chunks for stale records here
+ if (type != null) this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); // Paper
+ if (type != null) this.player.connection.send(new ClientboundBlockBreakAckPacket(this.destroyPos, type, action, true, "aborted mismatched destroying")); // Paper
+ this.destroyPos = BlockPos.ZERO; // Paper
@ -59,7 +59,7 @@ index 1d1f355a49e2324902feee10c1717fd772e359c6..44e5ab0b545de41b937c7ce304ce643f
this.level.destroyBlockProgress(this.player.getId(), pos, -1);
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 26ca0db447a76c3028dacf96bf9afd3b735bda74..25ec1613f4c9ecc59ec5e27717ff7de9ad9e4398 100644
index ab5a6bba572bc27dbf9473cf7042c4cdef6843dc..7960a57c25dc80c6ca762e65c3ef82065cce2b7a 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1550,7 +1550,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser

View file

@ -7,7 +7,7 @@ ray tracing into an unloaded chunk should be treated as a miss
this saves a ton of lag for when AI tries to raytrace near unloaded chunks.
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
index a60b8043540cacfa8cc3baba0872eefd4fc9464d..3bf658ad473ebfcb4f4ca6efff2ee068167b1a62 100644
index 8a979600b49e8a11982577fb6dd79503e2521a0f..bca0838e40bc91d78e9b93df5318642d1c9f341e 100644
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
@@ -75,7 +75,15 @@ public interface BlockGetter extends LevelHeightAccessor {
@ -16,7 +16,7 @@ index a60b8043540cacfa8cc3baba0872eefd4fc9464d..3bf658ad473ebfcb4f4ca6efff2ee068
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
- BlockState iblockdata = this.getBlockState(blockposition);
+ // Paper start - Prevent raytrace from loading chunks
+ BlockState iblockdata = this.getTypeIfLoaded(blockposition);
+ BlockState iblockdata = this.getBlockStateIfLoaded(blockposition);
+ if (iblockdata == null) {
+ // copied the last function parameter (listed below)
+ Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo());

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Prevent Enderman from loading chunks
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index c7714824d8e85087397047cf9bcb0528968b1f93..cfdb631500962ec19007db55bd4453687b91c2f8 100644
index c7714824d8e85087397047cf9bcb0528968b1f93..d47002d45dabd66f38d25d398d8943f4b911cdc5 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -490,7 +490,8 @@ public class EnderMan extends Monster implements NeutralMob {
@ -13,7 +13,7 @@ index c7714824d8e85087397047cf9bcb0528968b1f93..cfdb631500962ec19007db55bd445368
int k = Mth.floor(this.enderman.getZ() - 1.0D + random.nextDouble() * 2.0D);
BlockPos blockposition = new BlockPos(i, j, k);
- BlockState iblockdata = world.getBlockState(blockposition);
+ BlockState iblockdata = world.getTypeIfLoaded(blockposition); // Paper
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper
+ if (iblockdata == null) return; // Paper
BlockPos blockposition1 = blockposition.below();
BlockState iblockdata1 = world.getBlockState(blockposition1);
@ -23,7 +23,7 @@ index c7714824d8e85087397047cf9bcb0528968b1f93..cfdb631500962ec19007db55bd445368
int k = Mth.floor(this.enderman.getZ() - 2.0D + random.nextDouble() * 4.0D);
BlockPos blockposition = new BlockPos(i, j, k);
- BlockState iblockdata = world.getBlockState(blockposition);
+ BlockState iblockdata = world.getTypeIfLoaded(blockposition); // Paper
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper
+ if (iblockdata == null) return; // Paper
Vec3 vec3d = new Vec3((double) this.enderman.getBlockX() + 0.5D, (double) j + 0.5D, (double) this.enderman.getBlockZ() + 0.5D);
Vec3 vec3d1 = new Vec3((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D);

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Prevent sync chunk loads when villagers try to find beds
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/SleepInBed.java b/src/main/java/net/minecraft/world/entity/ai/behavior/SleepInBed.java
index 455774a211c679367c6e7845a11159ad84ca07e2..673b6e60731d440cc02b1e86bfba50e6ebeb0da9 100644
index 455774a211c679367c6e7845a11159ad84ca07e2..ff78092c40197b826863f19cb2e912d96bd68b7e 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/SleepInBed.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/SleepInBed.java
@@ -41,7 +41,8 @@ public class SleepInBed extends Behavior<LivingEntity> {
@ -13,7 +13,7 @@ index 455774a211c679367c6e7845a11159ad84ca07e2..673b6e60731d440cc02b1e86bfba50e6
}
- BlockState blockState = world.getBlockState(globalPos.pos());
+ BlockState blockState = world.getTypeIfLoaded(globalPos.pos()); // Paper
+ BlockState blockState = world.getBlockStateIfLoaded(globalPos.pos()); // Paper
+ if (blockState == null) { return false; } // Paper
return globalPos.pos().closerThan(entity.position(), 2.0D) && blockState.is(BlockTags.BEDS) && !blockState.getValue(BedBlock.OCCUPIED);
}

View file

@ -13,7 +13,7 @@ This of course is undesirable, so just return the loaded side as "primary"
and treat it as a single chest if the other sides are unloaded
diff --git a/src/main/java/net/minecraft/world/level/block/DoubleBlockCombiner.java b/src/main/java/net/minecraft/world/level/block/DoubleBlockCombiner.java
index ff2a7b08fe70adaecdaa508baadcfe40416519e0..7082bb0b28b6a046e3925f69e18b7c319871128f 100644
index ff2a7b08fe70adaecdaa508baadcfe40416519e0..6c334703c816d2a04f97006c5796c658f34a12a4 100644
--- a/src/main/java/net/minecraft/world/level/block/DoubleBlockCombiner.java
+++ b/src/main/java/net/minecraft/world/level/block/DoubleBlockCombiner.java
@@ -25,7 +25,12 @@ public class DoubleBlockCombiner {
@ -22,7 +22,7 @@ index ff2a7b08fe70adaecdaa508baadcfe40416519e0..7082bb0b28b6a046e3925f69e18b7c31
BlockPos blockPos = pos.relative(function.apply(state));
- BlockState blockState = world.getBlockState(blockPos);
+ // Paper start
+ BlockState blockState = world.getTypeIfLoaded(blockPos);
+ BlockState blockState = world.getBlockStateIfLoaded(blockPos);
+ if (blockState == null) {
+ return new DoubleBlockCombiner.NeighborCombineResult.Single<>(blockEntity);
+ }

View file

@ -258,7 +258,7 @@ index 0000000000000000000000000000000000000000..aabad39d13ead83042ec2e4dd7f4ed49
+}
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
new file mode 100644
index 0000000000000000000000000000000000000000..999b39127a42c2ccec0be4110c93453d38bda397
index 0000000000000000000000000000000000000000..ca9ecf27da22a79c588308db2401230391e7b729
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
@@ -0,0 +1,659 @@
@ -882,7 +882,7 @@ index 0000000000000000000000000000000000000000..999b39127a42c2ccec0be4110c93453d
+ }
+
+ private void updateBlock(Level level, BlockPos blockPos) {
+ BlockState blockState = level.getTypeIfLoaded(blockPos);
+ BlockState blockState = level.getBlockStateIfLoaded(blockPos);
+
+ if (blockState != null && obfuscateGlobal[GLOBAL_BLOCKSTATE_PALETTE.idFor(blockState)]) {
+ ((ServerLevel) level).getChunkSource().blockChanged(blockPos);
@ -1192,7 +1192,7 @@ index 66552855fa1d2eacc6e722428993bd5b9c07d960..f2c2f128fdb4d66616078dbae0aa8514
this.convertable = convertable_conversionsession;
this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile());
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 44e5ab0b545de41b937c7ce304ce643f78a43734..a85b89a0d525e623e154c8b1bea55470d2072dcb 100644
index d0b54ebc05cac6535a023709c76efd802f7150f9..d87ee258db769bc072cbdae4298ebc08588b2160 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -48,7 +48,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
@ -1214,7 +1214,7 @@ index 44e5ab0b545de41b937c7ce304ce643f78a43734..a85b89a0d525e623e154c8b1bea55470
public void destroyAndAck(BlockPos pos, ServerboundPlayerActionPacket.Action action, String reason) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 77e58257dc3fb517aeca8f8436a4279aa133b570..8cde961332f4671bdd361e8f88d0eedd595bf745 100644
index 615204f7e3095fcd65099a1b752635fa08d44d25..65bfcc218e50c05d5d1b90081b888f596bfef780 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -167,6 +167,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@ -1251,7 +1251,7 @@ index 77e58257dc3fb517aeca8f8436a4279aa133b570..8cde961332f4671bdd361e8f88d0eedd
if (iblockdata1 == null) {
// CraftBukkit start - remove blockstate if failed (or the same)
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
index 046afe19aa30f466a08461e3a504c9bbf78f7a3c..2fff34e573f57aab374a2cb9117313d2543f0bdc 100644
index b3b3fa7ece66e1ab467c8ed550d150db541fd02a..a657b41263739b454617db5d7cb9e5cdd94f44ec 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -109,7 +109,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
@ -1264,7 +1264,7 @@ index 046afe19aa30f466a08461e3a504c9bbf78f7a3c..2fff34e573f57aab374a2cb9117313d2
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 8ec42170fc72bddba61e3b03612f801e1fd07343..098c7d48c60f174ec2d2a67921e0cba286dd9ec7 100644
index ddd97d7b89d33f1d03de0b00681808e48cedd499..4e2405f416102d744f76384bbfdf051c29f87286 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -93,7 +93,7 @@ public class LevelChunk extends ChunkAccess {

View file

@ -25,7 +25,7 @@ index fe79c0add4f7cb18d487c5bb9415c40c5b551ea2..8d9ddad1879e7616d980ca70de8aecac
poiUnload = Timings.ofSafe(name + "Chunk unload - POI");
chunkUnload = Timings.ofSafe(name + "Chunk unload - Chunk");
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 5a1e82727e4861681736c2bb3ed01637c4c42e4d..2a0319d45de0bfb246313a6e533d26aa24c28df1 100644
index 619f5c11ae8e21b060b52b60d681db6dd9cb5816..88d140a03b6f28070b2f78588ee5ce4d5ac3cf0f 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -613,4 +613,12 @@ public class PaperWorldConfig {
@ -593,7 +593,7 @@ index 8de14a3078017c59b7e3a37894c6c250fa8558b0..262a2182d4d98787d0ae396c5ed0fe79
double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8);
double d1 = (double) SectionPos.sectionToBlockCoord(pos.z, 8);
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 1dc1005142f822c05eb9065b4a5da456ec936ff2..7ffebfa03a2a92d285c837b97d5190a052006e36 100644
index 7b391d6ab84eeaed7bdd27ea70d5e3f9690a0abf..313e1ba78abd6394def9d00ae671b901a6298bd1 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -916,7 +916,22 @@ public class ServerChunkCache extends ChunkSource {
@ -645,7 +645,7 @@ index b193f8dfbe7b61c919ad5eb452d29885982e25e4..01b9edc8aaf472650f171f1b88229807
// Yes, this doesn't match Vanilla, but it's the best we can do for now.
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
index 63deac19b4006c5d64596cd30e6641caaabc7c1d..63ba93538d990fdd4c9e8c491bb715adc8d57986 100644
index 6f63f471c2c9a3b85c6fc92bdee31a5ff9714ff5..c88bd5bc044b5f9722cb5826936e31811a8312c7 100644
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
@@ -65,7 +65,13 @@ public final class NaturalSpawner {
@ -740,7 +740,7 @@ index 63deac19b4006c5d64596cd30e6641caaabc7c1d..63ba93538d990fdd4c9e8c491bb715ad
StructureFeatureManager structuremanager = world.structureFeatureManager();
ChunkGenerator chunkgenerator = world.getChunkSource().getGenerator();
int i = pos.getY();
BlockState iblockdata = world.getTypeIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn
BlockState iblockdata = world.getBlockStateIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn
+ int j = 0; // Paper - moved up
if (iblockdata != null && !iblockdata.isRedstoneConductor(chunk, pos)) { // Paper - don't load chunks for mob spawn

View file

@ -8,10 +8,10 @@ faster on its own, however removing the try catch makes it
easier to inline due to code size
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 098c7d48c60f174ec2d2a67921e0cba286dd9ec7..3d722ad1d61692f83b08d1b0738c590e92a35036 100644
index 3a32f1adac69f1891d8fdbdc17a1f211a1590bf0..520645a8ee50e049e59c21fc57c88203f9a18993 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -372,18 +372,20 @@ public class LevelChunk extends ChunkAccess {
@@ -373,18 +373,20 @@ public class LevelChunk extends ChunkAccess {
}
public FluidState getFluidState(int x, int y, int z) {
@ -38,7 +38,7 @@ index 098c7d48c60f174ec2d2a67921e0cba286dd9ec7..3d722ad1d61692f83b08d1b0738c590e
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Getting fluid state");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Block being got");
@@ -393,6 +395,7 @@ public class LevelChunk extends ChunkAccess {
@@ -394,6 +396,7 @@ public class LevelChunk extends ChunkAccess {
});
throw new ReportedException(crashreport);
}

View file

@ -14,7 +14,7 @@ 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/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 5d4ef973781eac558c1e8d749f751c04a67c4693..33b607227718e08f26d7ab5744bbbff806f33366 100644
index 81aee8c195307fd3cd4a89c29ebb7ebc25436c83..2458619f7f377398322459e00a49f7f49437f9a2 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -791,6 +791,7 @@ public abstract class PlayerList {
@ -26,7 +26,7 @@ index 5d4ef973781eac558c1e8d749f751c04a67c4693..33b607227718e08f26d7ab5744bbbff8
entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ());
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 13e6fd62d7e9026a31455c5e2fa36392c7a0b249..c068e5fad2d9238201cada0d3a77ff2af1b8d8e1 100644
index 497fec66a9bb22ca9e4c8eea6c588bb42f64b320..fa4242cb9bd5b8b5a088585a6709d0b27835a261 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -171,6 +171,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
@ -38,7 +38,7 @@ index 13e6fd62d7e9026a31455c5e2fa36392c7a0b249..c068e5fad2d9238201cada0d3a77ff2a
public net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper
diff --git a/src/main/java/net/minecraft/world/level/BlockCollisions.java b/src/main/java/net/minecraft/world/level/BlockCollisions.java
index 8390ce194ccc692139c0e870c16a7fb76ac8ba68..d40bbc5ae6b87028a6dde400ea714249792da79a 100644
index 8390ce194ccc692139c0e870c16a7fb76ac8ba68..a733c91700a38634806e9155c693b227e6aa16b6 100644
--- a/src/main/java/net/minecraft/world/level/BlockCollisions.java
+++ b/src/main/java/net/minecraft/world/level/BlockCollisions.java
@@ -66,22 +66,41 @@ public class BlockCollisions extends AbstractIterator<VoxelShape> {
@ -72,7 +72,7 @@ index 8390ce194ccc692139c0e870c16a7fb76ac8ba68..d40bbc5ae6b87028a6dde400ea714249
+ } else if ((!far && source instanceof net.minecraft.server.level.ServerPlayer) || (source != null && source.collisionLoadChunks)) {
+ blockState = this.collisionGetter.getBlockState(this.pos);
+ } else {
+ blockState = this.collisionGetter.getTypeIfLoaded(this.pos);
+ blockState = this.collisionGetter.getBlockStateIfLoaded(this.pos);
+ }
+
+ if (blockState == null) {

View file

@ -299,7 +299,7 @@ index 7bf4bf5cb2c1b54a7e2733091f48f3a824336d36..dcce05d2f4ab16424db4ab103a12188e
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 9154f434ab1a1b11d19cef8fc80f351f3eefcb57..5abdb1c0247fde6da03e7689d5e2abab54f116d1 100644
index 2afcad405275ba635a311dde1ec616fa768d7148..d95c81277832edf929c2038fd7fbe67187f179b1 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -834,6 +834,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@ -311,10 +311,10 @@ index 9154f434ab1a1b11d19cef8fc80f351f3eefcb57..5abdb1c0247fde6da03e7689d5e2abab
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level.getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
MinecraftServer.LOGGER.error(msg, throwable);
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 3d722ad1d61692f83b08d1b0738c590e92a35036..fde6405831ed0d90734ac3861939209025baa419 100644
index 520645a8ee50e049e59c21fc57c88203f9a18993..bf0fa8c2b0beec9598bc3efdbe91380e6b4bab50 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -1069,6 +1069,7 @@ public class LevelChunk extends ChunkAccess {
@@ -1070,6 +1070,7 @@ public class LevelChunk extends ChunkAccess {
gameprofilerfiller.pop();
} catch (Throwable throwable) {

View file

@ -711,7 +711,7 @@ index 84dc1e94b4f7b8315d8422634dd49b1f85044d18..451d5e9b5906e662a0c2e04b407068ea
Ticket<ChunkPos> ticket = new Ticket<>(TicketType.FORCED, 31, pos);
long i = pos.toLong();
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index eb0c5ceb05f37bc653ea0cc91cc778866861688a..364375f5da5a3daea200c97c5dca86cbb8be5fb9 100644
index 013c4c428b3cf3c9ad7b9b2ed8b00b410e1804a9..785f07fddb84cf34fbd9d6ca89ff391d451aad17 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -601,6 +601,26 @@ public class ServerChunkCache extends ChunkSource {
@ -796,7 +796,7 @@ index eb0c5ceb05f37bc653ea0cc91cc778866861688a..364375f5da5a3daea200c97c5dca86cb
boolean flag1 = this.chunkMap.promoteChunkMap();
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 4b83617a81db1749faaf49fc3ee77e44846dce1a..968b8180f92066a43f06bff8dd1d49b03bd08f5b 100644
index d2280b9e9f107dca890bc76f0c58e7070ce4b38c..c68b95ef0d4c3e0d942e61bfccf23a00d0d8afd9 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -186,6 +186,7 @@ public class ServerPlayer extends Player {
@ -1164,7 +1164,7 @@ index 96de46b0b1b4bd69b1afa689083ec57ffb07120e..40e8c0b36ec521a8850782f349eb29b4
public float yRotO;
public float xRotO;
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 5e2cf3795415f1f1a54ebbda1e404347cc24fcc2..e9542a4683e1fef470ae37819d6d7a8c72afe4c8 100644
index 9cb5e608ace42acd1a5335b70d049a88f3918de5..b69ce653592575252a58cdd47052ab13fcb80f1c 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -141,7 +141,7 @@ public class LevelChunk extends ChunkAccess {
@ -1176,7 +1176,7 @@ index 5e2cf3795415f1f1a54ebbda1e404347cc24fcc2..e9542a4683e1fef470ae37819d6d7a8c
private long neighbourChunksLoadedBitset;
private final LevelChunk[] loadedNeighbourChunks = new LevelChunk[(NEIGHBOUR_CACHE_RADIUS * 2 + 1) * (NEIGHBOUR_CACHE_RADIUS * 2 + 1)];
@@ -682,6 +682,7 @@ public class LevelChunk extends ChunkAccess {
@@ -683,6 +683,7 @@ public class LevelChunk extends ChunkAccess {
// CraftBukkit start
public void loadCallback() {
@ -1184,7 +1184,7 @@ index 5e2cf3795415f1f1a54ebbda1e404347cc24fcc2..e9542a4683e1fef470ae37819d6d7a8c
// Paper start - neighbour cache
int chunkX = this.chunkPos.x;
int chunkZ = this.chunkPos.z;
@@ -736,6 +737,7 @@ public class LevelChunk extends ChunkAccess {
@@ -737,6 +738,7 @@ public class LevelChunk extends ChunkAccess {
}
public void unloadCallback() {

View file

@ -5,14 +5,14 @@ Subject: [PATCH] Don't mark dirty in invalid locations (SPIGOT-6086)
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 80aae4303e011dad13ce818136f0383e12ab5c41..4b0d87c0534cddcab16d772c16307f3621fc30e9 100644
index 80aae4303e011dad13ce818136f0383e12ab5c41..17a71e2fce455552c0e8af4073c516c21bc3e208 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -229,6 +229,7 @@ public class ChunkHolder {
}
public void blockChanged(BlockPos pos) {
+ if (!pos.isValidLocation(levelHeightAccessor)) return; // Paper - SPIGOT-6086 for all invalid locations; avoid acquiring locks
+ if (!pos.isInsideBuildHeightAndWorldBoundsHorizontal(levelHeightAccessor)) return; // Paper - SPIGOT-6086 for all invalid locations; avoid acquiring locks
LevelChunk chunk = this.getTickingChunk();
if (chunk != null) {

View file

@ -7,7 +7,7 @@ Apparently the abstract block iteration was taking about
75% of the method call.
diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
index afd4dc6f69389f43c1a95069840e01a33ac86b63..5d95f3cce8f5190bc2172a1fe0e83166062f0f3d 100644
index afd4dc6f69389f43c1a95069840e01a33ac86b63..d0720d5e6612d98d1e86e33e8e6564e371595630 100644
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
@@ -139,19 +139,28 @@ public class FarmBlock extends Block {
@ -33,7 +33,7 @@ index afd4dc6f69389f43c1a95069840e01a33ac86b63..5d95f3cce8f5190bc2172a1fe0e83166
+ for (int dy = 0; dy <= 1; ++dy) {
+ int y = dy + yOff;
+ net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)world.getChunk(x >> 4, z >> 4);
+ net.minecraft.world.level.material.FluidState fluid = chunk.getBlockData(x, y, z).getFluidState();
+ net.minecraft.world.level.material.FluidState fluid = chunk.getBlockStateFinal(x, y, z).getFluidState();
+ if (fluid.is(FluidTags.WATER)) {
+ return true;
+ }

View file

@ -4801,7 +4801,7 @@ index ce4848bdd00c091b9eb5fa2d47b03378d43c91b2..1831588b275f11aff37573fead835f6d
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
index e0dd98ddb33c78de0daba47d3ba23b88787ffdd2..7c617fb741c2d9b31dac562b2edcc032e5694e41 100644
index 6d5f867989eb786683e81e2d270ed0b085c1f072..96cb3e8cad9e7a5edd2a448ea88f2447104fbb5a 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -81,6 +81,47 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
@ -4853,7 +4853,7 @@ index e0dd98ddb33c78de0daba47d3ba23b88787ffdd2..7c617fb741c2d9b31dac562b2edcc032
public ChunkAccess(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor heightLimitView, Registry<Biome> biome, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable BlendingData blendingData) {
this.locX = pos.x; this.locZ = pos.z; // Paper - reduce need for field lookups
diff --git a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
index 25e9cc39d748dfd99d38f504c14f40f9ec7bdd2d..d14416f186292f2dda5f6539d285705226b7c699 100644
index 7b0da3956be23e974d3bc2f50f9004046923635f..96009c4dbdf964ce0b695b43b9338a441053daa5 100644
--- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
@@ -18,6 +18,38 @@ public class EmptyLevelChunk extends LevelChunk {
@ -4893,10 +4893,10 @@ index 25e9cc39d748dfd99d38f504c14f40f9ec7bdd2d..d14416f186292f2dda5f6539d2857052
+ public void setBlockEmptinessMap(final boolean[] emptinessMap) {}
+
// Paper start
@Override public BlockState getType(int x, int y, int z) {
return Blocks.VOID_AIR.defaultBlockState();
@Override
public BlockState getBlockState(int x, int y, int z) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
index 7c5b3acd299c5b021bd20f17ff0b89c8208a6623..d29739c3a67e60741a06fb25bcaf7705329804a4 100644
index e15263a152c88371ebc65b47f0be938f7c19a8f2..59c053deb52c9307f1b4c1515384a7c627cfaa49 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
@@ -30,6 +30,48 @@ public class ImposterProtoChunk extends ProtoChunk {
@ -4949,7 +4949,7 @@ index 7c5b3acd299c5b021bd20f17ff0b89c8208a6623..d29739c3a67e60741a06fb25bcaf7705
super(wrapped.getPos(), UpgradeData.EMPTY, wrapped.levelHeightAccessor, wrapped.getLevel().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), wrapped.getBlendingData());
this.wrapped = wrapped;
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index c30204c5daac422eb009a447c1eb4fbc94a84318..37ff1d911db531b6e51aa4234bcdffcce66722cf 100644
index f1fbaf9889cc35510d08deeba72d3c7988c57aa4..8de09ffb835bd08e6a7a3ca86953c9e0312cf300 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -100,6 +100,10 @@ public class LevelChunk extends ChunkAccess {
@ -4990,7 +4990,7 @@ index d850cae1ec024a557e62cd561fbca137dc2be96c..eef1b58cfaf3cfa90f3786785dd94d05
return data.palette.valueFor(data.storage.get(index));
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
index 568dc3c9cbf009a3892766cacdd00667556e27c5..e7676e86c08affa8e730c13f11d4b269ca896ee8 100644
index 150dd90598bbe4057b4e9ad17c87a4c07af3d56d..91550928949f11df9c9732e86c8380c3b3708ff7 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
@@ -54,6 +54,12 @@ public class ProtoChunk extends ChunkAccess {

View file

@ -920,7 +920,7 @@ index 0000000000000000000000000000000000000000..d67a40e7be030142443680c89e1763fc
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index b6f9c99d580d985f2b84efaa655d9ae40073e72b..e0beb35868a564dbcc0369d0a56b94642a23436a 100644
index d626af3879e558cdfbe95b1e70e0b32e0f4d1170..7b23535a680d2a8534dcb8dd87770f66fb982c13 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -415,7 +415,7 @@ public class ServerPlayer extends Player {
@ -955,7 +955,7 @@ index 25b787d1b22e495fb6756e4ee909776ed8699492..042be2cf60a9d01698808d84f2e537a5
}
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 516015eb48900abaf0e2f47de4ffd10e9cf4d9a7..1dd646bb8d1c153a3d034de1c208b3bacebd067f 100644
index 516015eb48900abaf0e2f47de4ffd10e9cf4d9a7..821c34a48127802947e293c4599e0cdaea3c040e 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1076,9 +1076,44 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
@ -992,7 +992,7 @@ index 516015eb48900abaf0e2f47de4ffd10e9cf4d9a7..1dd646bb8d1c153a3d034de1c208b3ba
+ continue;
+ }
+
+ BlockState type = chunk.getType(fx, fy, fz);
+ BlockState type = chunk.getBlockStateFinal(fx, fy, fz);
+ if (type.is((Tag) BlockTags.FIRE) || type.is(Blocks.LAVA)) {
+ noneMatch = false;
+ // can't break, we need to retain vanilla behavior by ensuring ALL chunks are loaded

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Optimise collision checking in player move packet handling
Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index f4f075c678f30d375d15041860fcc5543eedc7fe..eb7ac0b2a774dc7348eb2a94cc6c61792b47dd1d 100644
index f4f075c678f30d375d15041860fcc5543eedc7fe..348cecfe1c3ac1debe98e2fcc756c7e32a3187df 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -581,12 +581,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@ -73,7 +73,7 @@ index f4f075c678f30d375d15041860fcc5543eedc7fe..eb7ac0b2a774dc7348eb2a94cc6c6179
+ for (int z = minZ; z <= maxZ; ++z) {
+ for (int x = minX; x <= maxX; ++x) {
+ pos.set(x, y, z);
+ BlockState type = world.getTypeIfLoaded(pos);
+ BlockState type = world.getBlockStateIfLoaded(pos);
+ if (type != null && !type.isAir()) {
+ return false;
+ }