Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
SPIGOT-4400: Populators running on existing chunks
Dieser Commit ist enthalten in:
Ursprung
116cb9a1bc
Commit
1cf8b5dc1b
@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
+ public org.bukkit.Chunk bukkitChunk;
|
+ public org.bukkit.Chunk bukkitChunk;
|
||||||
+ public boolean mustSave;
|
+ public boolean mustSave;
|
||||||
+ public boolean newChunk;
|
+ private boolean needsDecoration;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
public Chunk(World world, ProtoChunk protochunk, int i, int j) {
|
public Chunk(World world, ProtoChunk protochunk, int i, int j) {
|
||||||
@ -76,7 +76,7 @@
|
|||||||
|
|
||||||
this.x = true;
|
this.x = true;
|
||||||
this.a(ChunkStatus.FULLCHUNK);
|
this.a(ChunkStatus.FULLCHUNK);
|
||||||
+ this.newChunk = true; // CraftBukkit
|
+ this.needsDecoration = protochunk.needsDecoration; // CraftBukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<BlockPosition> t() {
|
public Set<BlockPosition> t() {
|
||||||
@ -153,7 +153,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,6 +792,17 @@
|
@@ -720,6 +792,40 @@
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,13 +165,36 @@
|
|||||||
+ * the World constructor. We can't reliably alter that, so we have
|
+ * the World constructor. We can't reliably alter that, so we have
|
||||||
+ * no way of creating a CraftWorld/CraftServer at that point.
|
+ * no way of creating a CraftWorld/CraftServer at that point.
|
||||||
+ */
|
+ */
|
||||||
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.newChunk));
|
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration));
|
||||||
|
+
|
||||||
|
+ if (this.needsDecoration) {
|
||||||
|
+ BlockSand.instaFall = true;
|
||||||
|
+ java.util.Random random = new java.util.Random();
|
||||||
|
+ random.setSeed(world.getSeed());
|
||||||
|
+ long xRand = random.nextLong() / 2L * 2L + 1L;
|
||||||
|
+ long zRand = random.nextLong() / 2L * 2L + 1L;
|
||||||
|
+ random.setSeed((long) locX * xRand + (long) locZ * zRand ^ world.getSeed());
|
||||||
|
+
|
||||||
|
+ org.bukkit.World world = this.world.getWorld();
|
||||||
|
+ if (world != null) {
|
||||||
|
+ this.world.populating = true;
|
||||||
|
+ try {
|
||||||
|
+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
||||||
|
+ populator.populate(world, random, bukkitChunk);
|
||||||
|
+ }
|
||||||
|
+ } finally {
|
||||||
|
+ this.world.populating = false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ BlockSand.instaFall = false;
|
||||||
|
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeEntities() {
|
public void removeEntities() {
|
||||||
@@ -736,9 +819,21 @@
|
@@ -736,9 +842,21 @@
|
||||||
int i = aentityslice.length;
|
int i = aentityslice.length;
|
||||||
|
|
||||||
for (int j = 0; j < i; ++j) {
|
for (int j = 0; j < i; ++j) {
|
||||||
@ -195,7 +218,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -800,8 +895,8 @@
|
@@ -800,8 +918,8 @@
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Entity entity = (Entity) iterator.next();
|
Entity entity = (Entity) iterator.next();
|
||||||
|
|
||||||
@ -206,7 +229,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1007,13 +1102,13 @@
|
@@ -1007,13 +1125,13 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public LongSet b(String s) {
|
public LongSet b(String s) {
|
||||||
@ -222,7 +245,7 @@
|
|||||||
return new LongOpenHashSet();
|
return new LongOpenHashSet();
|
||||||
})).add(i);
|
})).add(i);
|
||||||
}
|
}
|
||||||
@@ -1061,18 +1156,18 @@
|
@@ -1061,18 +1179,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.s instanceof ProtoChunkTickList) {
|
if (this.s instanceof ProtoChunkTickList) {
|
||||||
@ -246,7 +269,7 @@
|
|||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Entry entry = (Entry) iterator.next();
|
Entry entry = (Entry) iterator.next();
|
||||||
@@ -1080,6 +1175,8 @@
|
@@ -1080,6 +1198,8 @@
|
||||||
NBTTagCompound nbttagcompound = (NBTTagCompound) entry.getValue();
|
NBTTagCompound nbttagcompound = (NBTTagCompound) entry.getValue();
|
||||||
|
|
||||||
if (this.getTileEntity(blockposition1) == null) {
|
if (this.getTileEntity(blockposition1) == null) {
|
||||||
@ -255,7 +278,7 @@
|
|||||||
TileEntity tileentity;
|
TileEntity tileentity;
|
||||||
|
|
||||||
if ("DUMMY".equals(nbttagcompound.getString("id"))) {
|
if ("DUMMY".equals(nbttagcompound.getString("id"))) {
|
||||||
@@ -1101,15 +1198,43 @@
|
@@ -1101,15 +1221,43 @@
|
||||||
} else {
|
} else {
|
||||||
Chunk.d.warn("Tried to load a block entity for block {} but failed at location {}", this.getType(blockposition1), blockposition1);
|
Chunk.d.warn("Tried to load a block entity for block {} but failed at location {}", this.getType(blockposition1), blockposition1);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/server/ChunkMap.java
|
--- a/net/minecraft/server/ChunkMap.java
|
||||||
+++ b/net/minecraft/server/ChunkMap.java
|
+++ b/net/minecraft/server/ChunkMap.java
|
||||||
@@ -31,6 +31,46 @@
|
@@ -31,6 +31,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,35 +19,12 @@
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ if (chunk.newChunk) {
|
|
||||||
+ BlockSand.instaFall = true;
|
|
||||||
+ java.util.Random random = new java.util.Random();
|
|
||||||
+ random.setSeed(chunk.world.getSeed());
|
|
||||||
+ long xRand = random.nextLong() / 2L * 2L + 1L;
|
|
||||||
+ long zRand = random.nextLong() / 2L * 2L + 1L;
|
|
||||||
+ random.setSeed((long) chunk.locX * xRand + (long) chunk.locZ * zRand ^ chunk.world.getSeed());
|
|
||||||
+
|
|
||||||
+ org.bukkit.World world = chunk.world.getWorld();
|
|
||||||
+ if (world != null) {
|
|
||||||
+ chunk.world.populating = true;
|
|
||||||
+ try {
|
|
||||||
+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
|
||||||
+ populator.populate(world, random, chunk.bukkitChunk);
|
|
||||||
+ }
|
|
||||||
+ } finally {
|
|
||||||
+ chunk.world.populating = false;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ BlockSand.instaFall = false;
|
|
||||||
+ chunk.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk));
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
return chunk1;
|
return chunk1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,23 +109,25 @@
|
@@ -69,23 +86,25 @@
|
||||||
throw new RuntimeException("Not yet implemented");
|
throw new RuntimeException("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
nms-patches/ChunkTaskDecorate.patch
Normale Datei
10
nms-patches/ChunkTaskDecorate.patch
Normale Datei
@ -0,0 +1,10 @@
|
|||||||
|
--- a/net/minecraft/server/ChunkTaskDecorate.java
|
||||||
|
+++ b/net/minecraft/server/ChunkTaskDecorate.java
|
||||||
|
@@ -9,6 +9,7 @@
|
||||||
|
ProtoChunk protochunk = aprotochunk[aprotochunk.length / 2];
|
||||||
|
|
||||||
|
protochunk.a(ChunkStatus.DECORATED);
|
||||||
|
+ protochunk.needsDecoration = true; // CraftBukkit
|
||||||
|
return protochunk;
|
||||||
|
}
|
||||||
|
}
|
79
nms-patches/ProtoChunk.patch
Normale Datei
79
nms-patches/ProtoChunk.patch
Normale Datei
@ -0,0 +1,79 @@
|
|||||||
|
--- a/net/minecraft/server/ProtoChunk.java
|
||||||
|
+++ b/net/minecraft/server/ProtoChunk.java
|
||||||
|
@@ -44,6 +44,7 @@
|
||||||
|
private long s;
|
||||||
|
private final Map<WorldGenStage.Features, BitSet> t;
|
||||||
|
private boolean u;
|
||||||
|
+ public boolean needsDecoration; // CraftBukkit
|
||||||
|
|
||||||
|
public ProtoChunk(int i, int j, ChunkConverter chunkconverter) {
|
||||||
|
this(new ChunkCoordIntPair(i, j), chunkconverter);
|
||||||
|
@@ -64,26 +65,26 @@
|
||||||
|
this.t = Maps.newHashMap();
|
||||||
|
this.b = chunkcoordintpair;
|
||||||
|
this.p = chunkconverter;
|
||||||
|
- Predicate predicate = (block) -> {
|
||||||
|
+ Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile error
|
||||||
|
return block == null || block.getBlockData().isAir();
|
||||||
|
};
|
||||||
|
IRegistry iregistry = IRegistry.BLOCK;
|
||||||
|
|
||||||
|
IRegistry.BLOCK.getClass();
|
||||||
|
Function function = iregistry::getKey;
|
||||||
|
- IRegistry iregistry1 = IRegistry.BLOCK;
|
||||||
|
+ IRegistry<Block> iregistry1 = IRegistry.BLOCK; // CraftBukkit - decompile error
|
||||||
|
|
||||||
|
IRegistry.BLOCK.getClass();
|
||||||
|
- this.q = new ProtoChunkTickList(predicate, function, iregistry1::getOrDefault, chunkcoordintpair);
|
||||||
|
- predicate = (fluidtype) -> {
|
||||||
|
+ this.q = new ProtoChunkTickList<>(predicate, function, iregistry1::getOrDefault, chunkcoordintpair); // CraftBukkit - decompile error
|
||||||
|
+ Predicate<FluidType> predicate2 = (fluidtype) -> { // CraftBukkit - decompile error
|
||||||
|
return fluidtype == null || fluidtype == FluidTypes.a;
|
||||||
|
};
|
||||||
|
iregistry = IRegistry.FLUID;
|
||||||
|
IRegistry.FLUID.getClass();
|
||||||
|
function = iregistry::getKey;
|
||||||
|
- iregistry1 = IRegistry.FLUID;
|
||||||
|
+ IRegistry<FluidType> iregistry2 = IRegistry.FLUID; // CraftBukkit - decompile error
|
||||||
|
IRegistry.FLUID.getClass();
|
||||||
|
- this.r = new ProtoChunkTickList(predicate, function, iregistry1::getOrDefault, chunkcoordintpair);
|
||||||
|
+ this.r = new ProtoChunkTickList<>(predicate2, function, iregistry2::getOrDefault, chunkcoordintpair); // CraftBukkit - decompile error
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShortList a(ShortList[] ashortlist, int i) {
|
||||||
|
@@ -325,8 +326,8 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
private HeightMap c(HeightMap.Type heightmap_type) {
|
||||||
|
- return (HeightMap) this.f.computeIfAbsent(heightmap_type, (heightmap_type) -> {
|
||||||
|
- HeightMap heightmap = new HeightMap(this, heightmap_type);
|
||||||
|
+ return (HeightMap) this.f.computeIfAbsent(heightmap_type, (heightmap_typex) -> { // CraftBukkit - decompile error
|
||||||
|
+ HeightMap heightmap = new HeightMap(this, heightmap_typex); // CraftBukkit - decompile error
|
||||||
|
|
||||||
|
heightmap.a();
|
||||||
|
return heightmap;
|
||||||
|
@@ -372,13 +373,13 @@
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public LongSet b(String s) {
|
||||||
|
- return (LongSet) this.o.computeIfAbsent(s, (s) -> {
|
||||||
|
+ return (LongSet) this.o.computeIfAbsent(s, (sx) -> { // CraftBukkit - decompile error
|
||||||
|
return new LongOpenHashSet();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(String s, long i) {
|
||||||
|
- ((LongSet) this.o.computeIfAbsent(s, (s) -> {
|
||||||
|
+ ((LongSet) this.o.computeIfAbsent(s, (sx) -> { // CraftBukkit - decompile error
|
||||||
|
return new LongOpenHashSet();
|
||||||
|
})).add(i);
|
||||||
|
this.c = true;
|
||||||
|
@@ -493,7 +494,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public BitSet a(WorldGenStage.Features worldgenstage_features) {
|
||||||
|
- return (BitSet) this.t.computeIfAbsent(worldgenstage_features, (worldgenstage_features) -> {
|
||||||
|
+ return (BitSet) this.t.computeIfAbsent(worldgenstage_features, (worldgenstage_featuresx) -> { // CraftBukkit - decompile error
|
||||||
|
return new BitSet(65536);
|
||||||
|
});
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren