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-07-22 20:11:56 +02:00
|
|
|
index 5285a5b16b0b706d9e1728a23628ff12e6b3b55d..df20ac811d673c205695d563f84382d1bf1e82e1 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-07-22 20:11:56 +02:00
|
|
|
@@ -2115,6 +2115,32 @@ public final class CraftServer implements Server {
|
2021-06-11 14:02:28 +02:00
|
|
|
return new CraftChunkData(world);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public ChunkGenerator.ChunkData createVanillaChunkData(World world, int x, int z) {
|
|
|
|
+ // get empty object
|
|
|
|
+ CraftChunkData data = (CraftChunkData) createChunkData(world);
|
|
|
|
+ // 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);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
2021-07-24 04:33:05 +02:00
|
|
|
index 45e5dfeef92e9756b0fa63d8fc66a4cf96ae7d9a..4dc68ff7d2c9775e370e3854e5a8a7eee4e261aa 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
2021-07-24 04:33:05 +02:00
|
|
|
@@ -181,6 +181,12 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
2021-06-14 11:46:59 +02:00
|
|
|
return this.sections;
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ public void setRawChunkData(LevelChunkSection[] sections) {
|
|
|
|
+ this.sections = sections;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
Set<BlockPos> getTiles() {
|
2021-06-14 11:46:59 +02:00
|
|
|
return this.tiles;
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|