From 0cd671108591fd6f16696379280b235fdbb7dca8 Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Sun, 6 Mar 2016 23:49:28 +0000 Subject: [PATCH] Fix regenerating chunks not updating visually --- nms-patches/PlayerChunk.patch | 8 +++++--- .../org/bukkit/craftbukkit/CraftWorld.java | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/nms-patches/PlayerChunk.patch b/nms-patches/PlayerChunk.patch index 47fee211cc..312df273b9 100644 --- a/nms-patches/PlayerChunk.patch +++ b/nms-patches/PlayerChunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerChunk.java +++ b/net/minecraft/server/PlayerChunk.java -@@ -4,16 +4,18 @@ +@@ -4,35 +4,48 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import java.util.ArrayList; @@ -19,8 +19,10 @@ + public final List c = Lists.newArrayList(); // CraftBukkit - public private final ChunkCoordIntPair location; private final short[] dirtyBlocks = new short[64]; - private Chunk chunk; -@@ -22,17 +24,28 @@ +- private Chunk chunk; ++ public Chunk chunk; // CraftBukkit - public + private int dirtyCount; + private int h; private long i; private boolean done; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index f22885fe2d..4878ef83f4 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -195,6 +195,21 @@ public class CraftWorld implements World { world.getChunkProviderServer().unloadQueue.remove(x, z); world.getChunkProviderServer().chunks.remove(LongHash.toLong(x, z)); + // Update neighbor counts + for (int xx = -2; xx < 3; xx++) { + for (int zz = -2; zz < 3; zz++) { + if (xx == 0 && zz == 0) { + continue; + } + + net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); + if (neighbor != null) { + neighbor.setNeighborUnloaded(-xx, -zz); + chunk.setNeighborUnloaded(xx, zz); + } + } + } + return true; } @@ -206,6 +221,10 @@ public class CraftWorld implements World { net.minecraft.server.Chunk chunk = null; chunk = world.getChunkProviderServer().chunkGenerator.getOrCreateChunk(x, z); + PlayerChunk playerChunk = world.getPlayerChunkMap().b/*PAIL: Rename*/(x, z); + if (playerChunk != null) { + playerChunk.chunk = chunk; + } chunkLoadPostProcess(chunk, x, z);