mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Remove UpgradeData neighbour ticks outside of range
The lists are only supposed to contain ticks for the 1 radius neighbours of the chunk.
This commit is contained in:
parent
8a4e4f4066
commit
88464f509b
1 changed files with 43 additions and 0 deletions
|
@ -0,0 +1,43 @@
|
|||
--- a/net/minecraft/world/level/chunk/UpgradeData.java
|
||||
+++ b/net/minecraft/world/level/chunk/UpgradeData.java
|
||||
@@ -109,9 +109,28 @@
|
||||
if (nbt.contains(key, 9)) {
|
||||
for (Tag tag : nbt.getList(key, 10)) {
|
||||
SavedTick.loadTick((CompoundTag)tag, nameToType).ifPresent(ticks::add);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - filter out relocated neighbour ticks
|
||||
+ // The lists are only supposed to contain ticks for the 1 radius neighbours of the chunk
|
||||
+ private static <T> void filterTickList(int chunkX, int chunkZ, List<SavedTick<T>> ticks) {
|
||||
+ for (java.util.Iterator<SavedTick<T>> iterator = ticks.iterator(); iterator.hasNext();) {
|
||||
+ SavedTick<T> tick = iterator.next();
|
||||
+ BlockPos tickPos = tick.pos();
|
||||
+ int tickCX = tickPos.getX() >> 4;
|
||||
+ int tickCZ = tickPos.getZ() >> 4;
|
||||
+
|
||||
+ int dist = Math.max(Math.abs(chunkX - tickCX), Math.abs(chunkZ - tickCZ));
|
||||
+
|
||||
+ if (dist != 1) {
|
||||
+ LOGGER.warn("Neighbour tick '" + tick + "' serialized in chunk (" + chunkX + "," + chunkZ + ") is too far (" + tickCX + "," + tickCZ + ")");
|
||||
+ iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
+ // Paper end - filter out relocated neighbour ticks
|
||||
|
||||
public void upgrade(LevelChunk chunk) {
|
||||
this.upgradeInside(chunk);
|
||||
@@ -120,6 +139,11 @@
|
||||
upgradeSides(chunk, direction8);
|
||||
}
|
||||
|
||||
+ // Paper start - filter out relocated neighbour ticks
|
||||
+ filterTickList(chunk.locX, chunk.locZ, this.neighborBlockTicks);
|
||||
+ filterTickList(chunk.locX, chunk.locZ, this.neighborFluidTicks);
|
||||
+ // Paper end - filter out relocated neighbour ticks
|
||||
+
|
||||
Level level = chunk.getLevel();
|
||||
this.neighborBlockTicks.forEach(tick -> {
|
||||
Block block = tick.type() == Blocks.AIR ? level.getBlockState(tick.pos()).getBlock() : tick.type();
|
Loading…
Reference in a new issue