13
0
geforkt von Mirrors/Paper

Use biome source method to prevent loading chunks (#7885)

Dieser Commit ist enthalten in:
Owen1212055 2022-06-08 09:57:04 -04:00
Ursprung 88ca48c121
Commit 92f5ec1d15

Datei anzeigen

@ -41,20 +41,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Override + @Override
+ public BiomeProvider vanillaBiomeProvider() { + public BiomeProvider vanillaBiomeProvider() {
+ final net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator; + net.minecraft.server.level.ServerChunkCache serverCache = this.getHandle().chunkSource;
+ if (this.getHandle().chunkSource.getGenerator() instanceof org.bukkit.craftbukkit.generator.CustomChunkGenerator bukkit) { +
+ chunkGenerator = bukkit.delegate; + final net.minecraft.world.level.biome.BiomeSource biomeSource = serverCache.getGenerator().getBiomeSource();
+ } else { + final net.minecraft.world.level.biome.Climate.Sampler sampler = serverCache.randomState().sampler();
+ chunkGenerator = this.getHandle().chunkSource.getGenerator();
+ }
+ final net.minecraft.core.Registry<net.minecraft.world.level.biome.Biome> biomeRegistry = this.getHandle().registryAccess().registryOrThrow(net.minecraft.core.Registry.BIOME_REGISTRY); + final net.minecraft.core.Registry<net.minecraft.world.level.biome.Biome> biomeRegistry = this.getHandle().registryAccess().registryOrThrow(net.minecraft.core.Registry.BIOME_REGISTRY);
+ final List<Biome> possibleBiomes = chunkGenerator.getBiomeSource().possibleBiomes().stream() +
+ final List<Biome> possibleBiomes = biomeSource.possibleBiomes().stream()
+ .map(biome -> CraftBlock.biomeBaseToBiome(biomeRegistry, biome)) + .map(biome -> CraftBlock.biomeBaseToBiome(biomeRegistry, biome))
+ .toList(); + .toList();
+ return new BiomeProvider() { + return new BiomeProvider() {
+ @Override + @Override
+ public Biome getBiome(final org.bukkit.generator.WorldInfo worldInfo, final int x, final int y, final int z) { + public Biome getBiome(final org.bukkit.generator.WorldInfo worldInfo, final int x, final int y, final int z) {
+ return CraftBlock.biomeBaseToBiome(biomeRegistry, CraftWorld.this.getHandle().getNoiseBiome(x >> 2, y >> 2, z >> 2)); + return CraftBlock.biomeBaseToBiome(biomeRegistry, biomeSource.getNoiseBiome(x >> 2, y >> 2, z >> 2, sampler));
+ } + }
+ +
+ @Override + @Override