Commits

Jadon Fowler authored and phase committed 63839165bc6
Fix infinite loop when saving chunks

Running `/save-all flush` would start an infinite loop that prints: ThreadedAnvilChunkStorage (world): All chunks are saved
No tags
master

nms-patches/ChunkRegionLoader.patch

Modified
99 99 + RegionFileCache.d(this.d, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound);
100 100
101 101 + /*
102 102 NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
103 103 dataoutputstream.close();
104 104 + */
105 105 + // CraftBukkit end
106 106 }
107 107
108 108 public void b(World world, Chunk chunk) throws IOException {}
109 -@@ -326,6 +378,13 @@
109 +@@ -149,6 +201,7 @@
110 + if (this.c()) {
111 + continue;
112 + }
113 ++ break; // CraftBukkit - Fix infinite loop when saving chunks
114 + }
115 + } finally {
116 + this.f = false;
117 +@@ -326,6 +379,13 @@
110 118 chunk.a(nbttagcompound.getByteArray("Biomes"));
111 119 }
112 120
113 121 + // CraftBukkit start - End this method here and split off entity loading to another method
114 122 + return chunk;
115 123 + }
116 124 +
117 125 + public void loadEntities(Chunk chunk, NBTTagCompound nbttagcompound, World world) {
118 126 + // CraftBukkit end
119 127 +
120 128 NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
121 129
122 130 if (nbttaglist1 != null) {
123 -@@ -369,7 +428,7 @@
131 +@@ -369,7 +429,7 @@
124 132 }
125 133 }
126 134
127 135 - return chunk;
128 136 + // return chunk; // CraftBukkit
129 137 }
130 138
131 139 @Nullable
132 -@@ -397,14 +456,20 @@
140 +@@ -397,14 +457,20 @@
133 141 }
134 142
135 143 @Nullable
136 144 + // CraftBukkit start
137 145 public static Entity a(NBTTagCompound nbttagcompound, World world, double d0, double d1, double d2, boolean flag) {
138 146 + return spawnEntity(nbttagcompound, world, d0, d1, d2, flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
139 147 + }
140 148 +
141 149 + public static Entity spawnEntity(NBTTagCompound nbttagcompound, World world, double d0, double d1, double d2, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
142 150 + // CraftBukkit end
143 151 Entity entity = a(nbttagcompound, world);
144 152
145 153 if (entity == null) {
146 154 return null;
147 155 } else {
148 156 entity.setPositionRotation(d0, d1, d2, entity.yaw, entity.pitch);
149 157 - if (flag && !world.addEntity(entity)) {
150 158 + if (flag && !world.addEntity(entity, spawnReason)) { // CraftBukkit
151 159 return null;
152 160 } else {
153 161 if (nbttagcompound.hasKeyOfType("Passengers", 9)) {
154 -@@ -433,8 +498,14 @@
162 +@@ -433,8 +499,14 @@
155 163 }
156 164 }
157 165
158 166 + // CraftBukkit start
159 167 public static void a(Entity entity, World world) {
160 168 - if (world.addEntity(entity) && entity.isVehicle()) {
161 169 + a(entity, world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
162 170 + }
163 171 +
164 172 + public static void a(Entity entity, World world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut