2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: MiniDigger <admin@minidigger.me>
|
|
|
|
Date: Wed, 29 Apr 2020 02:10:32 +0200
|
|
|
|
Subject: [PATCH] Allow delegation to vanilla chunk gen
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2021-09-09 18:57:16 +02:00
|
|
|
index 3a0338f3f02686f6497b5bf7156131c54d8fd2cd..31007c49f0fd627024307fd67b121e9a1f657aa2 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2021-09-09 18:57:16 +02:00
|
|
|
@@ -2176,6 +2176,32 @@ public final class CraftServer implements Server {
|
2021-08-25 09:59:26 +02:00
|
|
|
return new OldCraftChunkData(world);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public ChunkGenerator.ChunkData createVanillaChunkData(World world, int x, int z) {
|
|
|
|
+ // get empty object
|
2021-08-25 09:59:26 +02:00
|
|
|
+ OldCraftChunkData data = (OldCraftChunkData) createChunkData(world);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // do bunch of vanilla shit
|
|
|
|
+ net.minecraft.server.level.ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
|
2021-07-10 22:17:47 +02:00
|
|
|
+ net.minecraft.world.level.chunk.ProtoChunk protoChunk = new net.minecraft.world.level.chunk.ProtoChunk(new net.minecraft.world.level.ChunkPos(x, z), null, nmsWorld, nmsWorld);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ List<net.minecraft.world.level.chunk.ChunkAccess> list = new ArrayList<>();
|
|
|
|
+ list.add(protoChunk);
|
2021-06-14 16:41:34 +02:00
|
|
|
+ net.minecraft.server.level.WorldGenRegion genRegion = new net.minecraft.server.level.WorldGenRegion(nmsWorld, list, net.minecraft.world.level.chunk.ChunkStatus.EMPTY, -1);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // call vanilla generator, one feature after another. Order here is important!
|
|
|
|
+ net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator = nmsWorld.getChunkSource().generator;
|
|
|
|
+ if (chunkGenerator instanceof org.bukkit.craftbukkit.generator.CustomChunkGenerator) {
|
|
|
|
+ chunkGenerator = ((org.bukkit.craftbukkit.generator.CustomChunkGenerator) chunkGenerator).delegate;
|
|
|
|
+ }
|
|
|
|
+ chunkGenerator.createBiomes(nmsWorld.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), protoChunk);
|
2021-06-14 16:41:34 +02:00
|
|
|
+ chunkGenerator.fillFromNoise((runnable) -> {}, nmsWorld.structureFeatureManager(), protoChunk);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ chunkGenerator.buildSurfaceAndBedrock(genRegion, protoChunk);
|
|
|
|
+ // copy over generated sections
|
|
|
|
+ data.setRawChunkData(protoChunk.getSections());
|
|
|
|
+ // hooray!
|
|
|
|
+ return data;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) {
|
|
|
|
return new CraftBossBar(title, color, style, flags);
|
2021-08-25 09:59:26 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
|
|
|
|
index a48c659c02c6c33a8efdac6daf9c9a0708f05071..932bd3334b5852c8f209678b1444fc0e43a637f0 100644
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
|
|
|
|
@@ -22,7 +22,7 @@ import org.bukkit.material.MaterialData;
|
|
|
|
public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
|
|
|
|
private final int minHeight;
|
|
|
|
private final int maxHeight;
|
|
|
|
- private final LevelChunkSection[] sections;
|
|
|
|
+ private LevelChunkSection[] sections;
|
|
|
|
private Set<BlockPos> tiles;
|
|
|
|
private final Set<BlockPos> lights = new HashSet<>();
|
|
|
|
private World world; // Paper - Anti-Xray - Add parameters
|
|
|
|
@@ -195,4 +195,10 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
|
|
|
|
Set<BlockPos> getLights() {
|
|
|
|
return this.lights;
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2021-08-25 09:59:26 +02:00
|
|
|
+
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ public void setRawChunkData(LevelChunkSection[] sections) {
|
|
|
|
+ this.sections = sections;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2021-08-25 09:59:26 +02:00
|
|
|
}
|