mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 06:30:46 +01:00
Fixup porting issue in vanillaBiomeProvider impl (#11185)
This commit is contained in:
parent
77d5e15846
commit
5b96be4ce6
1 changed files with 44 additions and 4 deletions
|
@ -17,6 +17,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
if (biomeProvider == null && gen != null) {
|
||||
biomeProvider = gen.getDefaultBiomeProvider(worldInfo);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
this.serverLevelData.setWorld(this);
|
||||
|
||||
if (biomeProvider != null) {
|
||||
- BiomeSource worldChunkManager = new CustomWorldChunkManager(this.getWorld(), biomeProvider, this.server.registryAccess().registryOrThrow(Registries.BIOME));
|
||||
+ BiomeSource worldChunkManager = new CustomWorldChunkManager(this.getWorld(), biomeProvider, this.server.registryAccess().registryOrThrow(Registries.BIOME), chunkgenerator.getBiomeSource()); // Paper - add vanillaBiomeProvider
|
||||
if (chunkgenerator instanceof NoiseBasedChunkGenerator cga) {
|
||||
chunkgenerator = new NoiseBasedChunkGenerator(worldChunkManager, cga.settings);
|
||||
} else if (chunkgenerator instanceof FlatLevelSource cpf) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
|
@ -43,16 +56,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ public BiomeProvider vanillaBiomeProvider() {
|
||||
+ net.minecraft.server.level.ServerChunkCache serverCache = this.getHandle().chunkSource;
|
||||
+
|
||||
+ final net.minecraft.world.level.biome.BiomeSource biomeSource = serverCache.getGenerator().getBiomeSource();
|
||||
+ final net.minecraft.world.level.chunk.ChunkGenerator gen = serverCache.getGenerator();
|
||||
+ net.minecraft.world.level.biome.BiomeSource biomeSource;
|
||||
+ if (gen instanceof org.bukkit.craftbukkit.generator.CustomChunkGenerator custom) {
|
||||
+ biomeSource = custom.getDelegate().getBiomeSource();
|
||||
+ } else {
|
||||
+ biomeSource = gen.getBiomeSource();
|
||||
+ }
|
||||
+ if (biomeSource instanceof org.bukkit.craftbukkit.generator.CustomWorldChunkManager customBiomeSource) {
|
||||
+ biomeSource = customBiomeSource.vanillaBiomeSource;
|
||||
+ }
|
||||
+ final net.minecraft.world.level.biome.BiomeSource finalBiomeSource = biomeSource;
|
||||
+ final net.minecraft.world.level.biome.Climate.Sampler sampler = serverCache.randomState().sampler();
|
||||
+
|
||||
+ final List<Biome> possibleBiomes = biomeSource.possibleBiomes().stream()
|
||||
+ .map(biome -> org.bukkit.craftbukkit.block.CraftBiome.minecraftHolderToBukkit(biome))
|
||||
+ final List<Biome> possibleBiomes = finalBiomeSource.possibleBiomes().stream()
|
||||
+ .map(CraftBiome::minecraftHolderToBukkit)
|
||||
+ .toList();
|
||||
+ return new BiomeProvider() {
|
||||
+ @Override
|
||||
+ public Biome getBiome(final org.bukkit.generator.WorldInfo worldInfo, final int x, final int y, final int z) {
|
||||
+ return org.bukkit.craftbukkit.block.CraftBiome.minecraftHolderToBukkit(biomeSource.getNoiseBiome(x >> 2, y >> 2, z >> 2, sampler));
|
||||
+ return CraftBiome.minecraftHolderToBukkit(finalBiomeSource.getNoiseBiome(x >> 2, y >> 2, z >> 2, sampler));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
|
@ -135,3 +158,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java
|
||||
@@ -0,0 +0,0 @@ public class CustomWorldChunkManager extends BiomeSource {
|
||||
return biomeBases;
|
||||
}
|
||||
|
||||
- public CustomWorldChunkManager(WorldInfo worldInfo, BiomeProvider biomeProvider, Registry<net.minecraft.world.level.biome.Biome> registry) {
|
||||
+ // Paper start - add vanillaBiomeProvider
|
||||
+ public final BiomeSource vanillaBiomeSource;
|
||||
+ public CustomWorldChunkManager(WorldInfo worldInfo, BiomeProvider biomeProvider, Registry<net.minecraft.world.level.biome.Biome> registry, BiomeSource vanillaBiomeSource) {
|
||||
+ this.vanillaBiomeSource = vanillaBiomeSource;
|
||||
+ // Paper end - add vanillaBiomeProvider
|
||||
this.worldInfo = worldInfo;
|
||||
this.biomeProvider = biomeProvider;
|
||||
this.registry = registry;
|
||||
|
|
Loading…
Reference in a new issue