geforkt von Mirrors/Paper
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
105 Zeilen
5.9 KiB
Diff
105 Zeilen
5.9 KiB
Diff
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/net/minecraft/world/level/chunk/UpgradeData.java b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java
|
|
index aaa8d78b131c4095b36c6db6078f57f927c15374..54e560348836498f16dde017c6e7e3fcc263eeea 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java
|
|
@@ -36,7 +36,7 @@ import org.apache.logging.log4j.Logger;
|
|
public class UpgradeData {
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
- public static final UpgradeData EMPTY = new UpgradeData();
|
|
+ public static final UpgradeData EMPTY = new UpgradeData(); public static UpgradeData getEmptyConverter() { return EMPTY; } // Paper - obfhelper
|
|
private static final Direction8[] DIRECTIONS = Direction8.values();
|
|
private final EnumSet<Direction8> sides;
|
|
private final int[][] index;
|
|
@@ -322,7 +322,7 @@ public class UpgradeData {
|
|
if ((Integer) iblockdata.getValue(BlockStateProperties.DISTANCE) >= j) {
|
|
world.setBlock(blockposition, (BlockState) iblockdata.setValue(BlockStateProperties.DISTANCE, j), 18);
|
|
if (i != 7) {
|
|
- Direction[] aenumdirection = null.f;
|
|
+ Direction[] aenumdirection = DIRECTIONS; // Paper - decomp fix
|
|
int k = aenumdirection.length;
|
|
|
|
for (int l = 0; l < k; ++l) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 2ec41cb87cec97780f1fa8abfbb756fca4dba1bf..e301aee53b19fc3f93a36d0ed03a649741123bfa 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -2032,6 +2032,32 @@ public final class CraftServer implements Server {
|
|
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();
|
|
+ net.minecraft.world.level.chunk.ProtoChunk protoChunk = new net.minecraft.world.level.chunk.ProtoChunk(new net.minecraft.world.level.ChunkPos(x, z), net.minecraft.world.level.chunk.UpgradeData.getEmptyConverter(), nmsWorld);
|
|
+ List<net.minecraft.world.level.chunk.ChunkAccess> list = new ArrayList<>();
|
|
+ list.add(protoChunk);
|
|
+ net.minecraft.server.level.WorldGenRegion genRegion = new net.minecraft.server.level.WorldGenRegion(nmsWorld, list);
|
|
+ // 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);
|
|
+ chunkGenerator.fillFromNoise(genRegion, nmsWorld.structureFeatureManager(), protoChunk);
|
|
+ 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
|
|
index 8d72cd6a44cf462cfe3adac9bf99a16883a587df..fd2cb2a584fea360fcf8180338708f35c4e3dc1f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
|
@@ -19,7 +19,7 @@ import org.bukkit.material.MaterialData;
|
|
*/
|
|
public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
|
private final int maxHeight;
|
|
- private final LevelChunkSection[] sections;
|
|
+ private LevelChunkSection[] sections; // Paper - remove final
|
|
private Set<BlockPos> tiles;
|
|
private World world; // Paper - Anti-Xray - Add world
|
|
|
|
@@ -168,6 +168,12 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
|
return sections;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public void setRawChunkData(LevelChunkSection[] sections) {
|
|
+ this.sections = sections;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
Set<BlockPos> getTiles() {
|
|
return tiles;
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
|
index eba3a6a2467116d93945ab2d5dc0a6f41d76f547..e25dc1c87752fcf73181cb02ddaf84b258ac4e9d 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
|
@@ -32,7 +32,7 @@ import org.bukkit.generator.ChunkGenerator.ChunkData;
|
|
|
|
public class CustomChunkGenerator extends InternalChunkGenerator {
|
|
|
|
- private final net.minecraft.world.level.chunk.ChunkGenerator delegate;
|
|
+ public final net.minecraft.world.level.chunk.ChunkGenerator delegate; // Paper - public
|
|
private final ChunkGenerator generator;
|
|
private final ServerLevel world;
|
|
private final Random random = new Random();
|