3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 19:10:09 +01:00

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

Dieser Commit ist enthalten in:
Owen 2022-06-08 09:57:04 -04:00 committet von GitHub
Ursprung b1f5e70075
Commit 7ece9454f7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 14 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -31,30 +31,29 @@ index 46ff259c64560ac7371e138627bf1b71227d308b..ebf70b414c63cdb715d739c3333adbaf
biomeProvider = generator.getDefaultBiomeProvider(worldInfo);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 58f6348b04d776d510c0ede4e36a202e2fcb765c..425e0940159e335f3919a6f623a56968864b8fc1 100644
index 58f6348b04d776d510c0ede4e36a202e2fcb765c..17828c924fa20ebc1d72f73adf62f1c0cb078a68 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -195,6 +195,31 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -195,6 +195,30 @@ public class CraftWorld extends CraftRegionAccessor implements World {
public int getPlayerCount() {
return world.players().size();
}
+
+ @Override
+ public BiomeProvider vanillaBiomeProvider() {
+ final net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator;
+ if (this.getHandle().chunkSource.getGenerator() instanceof org.bukkit.craftbukkit.generator.CustomChunkGenerator bukkit) {
+ chunkGenerator = bukkit.delegate;
+ } else {
+ chunkGenerator = this.getHandle().chunkSource.getGenerator();
+ }
+ 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.biome.Climate.Sampler sampler = serverCache.randomState().sampler();
+ 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))
+ .toList();
+ return new BiomeProvider() {
+ @Override
+ 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

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Implement regenerateChunk
Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 425e0940159e335f3919a6f623a56968864b8fc1..ee0ae10b555cf21e1e618bb3bc173c3be0e4ff2c 100644
index 17828c924fa20ebc1d72f73adf62f1c0cb078a68..2e9b782e34ae25e982b45011a36c3b08ab298648 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -133,6 +133,7 @@ import org.bukkit.util.Vector;
@ -17,7 +17,7 @@ index 425e0940159e335f3919a6f623a56968864b8fc1..ee0ae10b555cf21e1e618bb3bc173c3b
private final ServerLevel world;
private WorldBorder worldBorder;
@@ -426,27 +427,61 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -425,27 +426,61 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean regenerateChunk(int x, int z) {
org.spigotmc.AsyncCatcher.catchOp("chunk regenerate"); // Spigot

Datei anzeigen

@ -21,10 +21,10 @@ index d1fca0e3227b5f37c11367548be362f5a49b6a71..5628940cd3c3566c5db2beda506d4f20
if (Snowball.class.isAssignableFrom(clazz)) {
entity = new net.minecraft.world.entity.projectile.Snowball(world, x, y, z);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index ee0ae10b555cf21e1e618bb3bc173c3be0e4ff2c..105869020cd5b056b984c57f7196e9256e07b83e 100644
index 2e9b782e34ae25e982b45011a36c3b08ab298648..e30cd412f30e26aa4c59f367b3cc26ba47e1b21c 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1411,7 +1411,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -1410,7 +1410,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Validate.notNull(material, "Material cannot be null");
Validate.isTrue(material.isBlock(), "Material must be a block");
@ -38,7 +38,7 @@ index ee0ae10b555cf21e1e618bb3bc173c3be0e4ff2c..105869020cd5b056b984c57f7196e925
return (FallingBlock) entity.getBukkitEntity();
}
@@ -1420,7 +1425,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -1419,7 +1424,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Validate.notNull(location, "Location cannot be null");
Validate.notNull(data, "BlockData cannot be null");