Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-17 12:00:07 +01:00
164 Zeilen
6.4 KiB
Diff
164 Zeilen
6.4 KiB
Diff
From 60f931b9efb9140650ffb140af1dee18f557f8fe Mon Sep 17 00:00:00 2001
|
|
From: Dan Mulloy <dmulloy2@live.com>
|
|
Date: Sun, 22 Dec 2013 18:40:53 -0500
|
|
Subject: [PATCH] Fix Biome Decoration Crashes
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BiomeDecorator.java b/src/main/java/net/minecraft/server/BiomeDecorator.java
|
|
index b048d6c..2a5333a 100644
|
|
--- a/src/main/java/net/minecraft/server/BiomeDecorator.java
|
|
+++ b/src/main/java/net/minecraft/server/BiomeDecorator.java
|
|
@@ -1,5 +1,10 @@
|
|
package net.minecraft.server;
|
|
|
|
+// Spigot Start
|
|
+import java.util.ArrayList;
|
|
+import java.util.Iterator;
|
|
+import java.util.List;
|
|
+// Spigot End
|
|
import java.util.Random;
|
|
|
|
public class BiomeDecorator {
|
|
@@ -39,6 +44,7 @@ public class BiomeDecorator {
|
|
protected int G;
|
|
protected int H;
|
|
public boolean I;
|
|
+ private final List<Chunk> chunksToUnload = new ArrayList<Chunk>(); // Spigot
|
|
|
|
public BiomeDecorator() {
|
|
this.f = new WorldGenSand(Blocks.SAND, 7);
|
|
@@ -147,7 +153,7 @@ public class BiomeDecorator {
|
|
for (j = 0; j < this.z; ++j) {
|
|
k = this.c + this.b.nextInt(16) + 8;
|
|
l = this.d + this.b.nextInt(16) + 8;
|
|
- i1 = this.b.nextInt(this.a.getHighestBlockYAt(k, l) * 2);
|
|
+ i1 = this.b.nextInt(this.getHighestBlockYAt(k, l) * 2); // Spigot
|
|
WorldGenerator worldgenerator = biomebase.b(this.b);
|
|
|
|
worldgenerator.a(this.a, this.b, k, i1, l);
|
|
@@ -156,15 +162,15 @@ public class BiomeDecorator {
|
|
for (j = 0; j < this.A; ++j) {
|
|
k = this.c + this.b.nextInt(16) + 8;
|
|
l = this.d + this.b.nextInt(16) + 8;
|
|
- i1 = this.b.nextInt(this.a.getHighestBlockYAt(k, l) * 2);
|
|
- (new WorldGenDeadBush(Blocks.DEAD_BUSH)).a(this.a, this.b, k, i1, l);
|
|
+ i1 = this.b.nextInt(this.getHighestBlockYAt(k, l) * 2);
|
|
+ (new WorldGenDeadBush(Blocks.DEAD_BUSH)).a(this.a, this.b, k, i1, l); // Spigot
|
|
}
|
|
|
|
for (j = 0; j < this.w; ++j) {
|
|
k = this.c + this.b.nextInt(16) + 8;
|
|
l = this.d + this.b.nextInt(16) + 8;
|
|
|
|
- for (i1 = this.b.nextInt(this.a.getHighestBlockYAt(k, l) * 2); i1 > 0 && this.a.isEmpty(k, i1 - 1, l); --i1) {
|
|
+ for (i1 = this.b.nextInt(this.getHighestBlockYAt(k, l) * 2); i1 > 0 && this.a.isEmpty(k, i1 - 1, l); --i1) { // Spigot
|
|
;
|
|
}
|
|
|
|
@@ -175,14 +181,14 @@ public class BiomeDecorator {
|
|
if (this.b.nextInt(4) == 0) {
|
|
k = this.c + this.b.nextInt(16) + 8;
|
|
l = this.d + this.b.nextInt(16) + 8;
|
|
- i1 = this.a.getHighestBlockYAt(k, l);
|
|
+ i1 = this.getHighestBlockYAt(k, l); // Spigot
|
|
this.q.a(this.a, this.b, k, i1, l);
|
|
}
|
|
|
|
if (this.b.nextInt(8) == 0) {
|
|
k = this.c + this.b.nextInt(16) + 8;
|
|
l = this.d + this.b.nextInt(16) + 8;
|
|
- i1 = this.b.nextInt(this.a.getHighestBlockYAt(k, l) * 2);
|
|
+ i1 = this.b.nextInt(this.getHighestBlockYAt(k, l) * 2); // Spigot
|
|
this.r.a(this.a, this.b, k, i1, l);
|
|
}
|
|
}
|
|
@@ -190,42 +196,42 @@ public class BiomeDecorator {
|
|
if (this.b.nextInt(4) == 0) {
|
|
j = this.c + this.b.nextInt(16) + 8;
|
|
k = this.d + this.b.nextInt(16) + 8;
|
|
- l = this.b.nextInt(this.a.getHighestBlockYAt(j, k) * 2);
|
|
+ l = this.b.nextInt(this.getHighestBlockYAt(j, k) * 2); // Spigot
|
|
this.q.a(this.a, this.b, j, l, k);
|
|
}
|
|
|
|
if (this.b.nextInt(8) == 0) {
|
|
j = this.c + this.b.nextInt(16) + 8;
|
|
k = this.d + this.b.nextInt(16) + 8;
|
|
- l = this.b.nextInt(this.a.getHighestBlockYAt(j, k) * 2);
|
|
+ l = this.b.nextInt(this.getHighestBlockYAt(j, k) * 2); // Spigot
|
|
this.r.a(this.a, this.b, j, l, k);
|
|
}
|
|
|
|
for (j = 0; j < this.C; ++j) {
|
|
k = this.c + this.b.nextInt(16) + 8;
|
|
l = this.d + this.b.nextInt(16) + 8;
|
|
- i1 = this.b.nextInt(this.a.getHighestBlockYAt(k, l) * 2);
|
|
+ i1 = this.b.nextInt(this.getHighestBlockYAt(k, l) * 2); // Spigot
|
|
this.t.a(this.a, this.b, k, i1, l);
|
|
}
|
|
|
|
for (j = 0; j < 10; ++j) {
|
|
k = this.c + this.b.nextInt(16) + 8;
|
|
l = this.d + this.b.nextInt(16) + 8;
|
|
- i1 = this.b.nextInt(this.a.getHighestBlockYAt(k, l) * 2);
|
|
+ i1 = this.b.nextInt(this.getHighestBlockYAt(k, l) * 2); // Spigot
|
|
this.t.a(this.a, this.b, k, i1, l);
|
|
}
|
|
|
|
if (this.b.nextInt(32) == 0) {
|
|
j = this.c + this.b.nextInt(16) + 8;
|
|
k = this.d + this.b.nextInt(16) + 8;
|
|
- l = this.b.nextInt(this.a.getHighestBlockYAt(j, k) * 2);
|
|
+ l = this.b.nextInt(this.getHighestBlockYAt(j, k) * 2); // Spigot
|
|
(new WorldGenPumpkin()).a(this.a, this.b, j, l, k);
|
|
}
|
|
|
|
for (j = 0; j < this.D; ++j) {
|
|
k = this.c + this.b.nextInt(16) + 8;
|
|
l = this.d + this.b.nextInt(16) + 8;
|
|
- i1 = this.b.nextInt(this.a.getHighestBlockYAt(k, l) * 2);
|
|
+ i1 = this.b.nextInt(this.getHighestBlockYAt(k, l) * 2); // Spigot
|
|
this.u.a(this.a, this.b, k, i1, l);
|
|
}
|
|
|
|
@@ -244,6 +250,7 @@ public class BiomeDecorator {
|
|
(new WorldGenLiquids(Blocks.LAVA)).a(this.a, this.b, k, l, i1);
|
|
}
|
|
}
|
|
+ this.unloadChunks(); // Spigot - unload chunks we force loaded
|
|
}
|
|
|
|
protected void a(int i, WorldGenerator worldgenerator, int j, int k) {
|
|
@@ -276,4 +283,28 @@ public class BiomeDecorator {
|
|
this.a(1, this.n, 0, 16);
|
|
this.b(1, this.o, 16, 16);
|
|
}
|
|
+
|
|
+ // Spigot start - force load chunks
|
|
+ private int getHighestBlockYAt(int i, int j)
|
|
+ {
|
|
+ // Make sure the chunk is loaded
|
|
+ if ( !this.a.isChunkLoaded( i >> 4, j >> 4 ) )
|
|
+ {
|
|
+ // If not, load it, then add it to our unload list
|
|
+ this.chunksToUnload.add( this.a.getChunkAt( i >> 4, j >> 4 ) );
|
|
+ }
|
|
+
|
|
+ return this.a.getHighestBlockYAt( i, j );
|
|
+ }
|
|
+
|
|
+ private void unloadChunks()
|
|
+ {
|
|
+ Iterator<Chunk> iter = this.chunksToUnload.iterator();
|
|
+ while ( iter.hasNext() )
|
|
+ {
|
|
+ this.a.getWorld().unloadChunk( iter.next().bukkitChunk );
|
|
+ iter.remove();
|
|
+ }
|
|
+ }
|
|
+ // Spigot end
|
|
}
|
|
--
|
|
1.8.3.2
|
|
|