SPIGOT-7041: Custom BiomeProvider not used when world set to type FLAT

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2022-06-10 11:08:00 +10:00
parent d9d74754ba
commit 766668f0db
2 changed files with 61 additions and 34 deletions

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/WorldServer.java
+++ b/net/minecraft/server/level/WorldServer.java
@@ -152,6 +152,25 @@
@@ -152,6 +152,26 @@
import net.minecraft.world.ticks.TickListServer;
import org.slf4j.Logger;
@ -8,6 +8,7 @@
+import net.minecraft.world.level.biome.WorldChunkManager;
+import net.minecraft.world.level.dimension.WorldDimension;
+import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract;
+import net.minecraft.world.level.levelgen.ChunkProviderFlat;
+import net.minecraft.world.level.storage.WorldDataServer;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
@ -26,7 +27,7 @@
public class WorldServer extends World implements GeneratorAccessSeed {
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
@@ -169,7 +188,7 @@
@@ -169,7 +189,7 @@
final List<EntityPlayer> players;
private final ChunkProviderServer chunkSource;
private final MinecraftServer server;
@ -35,7 +36,7 @@
final EntityTickList entityTickList;
public final PersistentEntitySectionManager<Entity> entityManager;
public boolean noSave;
@@ -193,11 +212,28 @@
@@ -193,11 +213,28 @@
private final StructureCheck structureCheck;
private final boolean tickTime;
@ -68,7 +69,7 @@
this.players = Lists.newArrayList();
this.entityTickList = new EntityTickList();
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
@@ -212,6 +248,20 @@
@@ -212,6 +249,22 @@
this.customSpawners = list;
this.serverLevelData = iworlddataserver;
ChunkGenerator chunkgenerator = worlddimension.generator();
@ -79,6 +80,8 @@
+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(getWorld(), biomeProvider, server.registryHolder.registryOrThrow(IRegistry.BIOME_REGISTRY));
+ if (chunkgenerator instanceof ChunkGeneratorAbstract cga) {
+ chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, cga.settings);
+ } else if (chunkgenerator instanceof ChunkProviderFlat cpf) {
+ chunkgenerator = new ChunkProviderFlat(cpf.structureSets, cpf.settings(), worldChunkManager);
+ }
+ }
+
@ -89,7 +92,7 @@
boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper();
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
@@ -243,14 +293,15 @@
@@ -243,14 +296,15 @@
long l = minecraftserver.getWorldData().worldGenSettings().seed();
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
@ -107,7 +110,7 @@
}
public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) {
@@ -282,12 +333,20 @@
@@ -282,12 +336,20 @@
long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@ -131,7 +134,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle();
}
@@ -313,7 +372,7 @@
@@ -313,7 +375,7 @@
this.runBlockEvents();
this.handlingTick = false;
gameprofilerfiller.pop();
@ -140,7 +143,7 @@
if (flag) {
this.resetEmptyTime();
@@ -329,7 +388,7 @@
@@ -329,7 +391,7 @@
this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) {
@ -149,7 +152,7 @@
entity.discard();
} else {
gameprofilerfiller.push("checkDespawn");
@@ -403,7 +462,7 @@
@@ -403,7 +465,7 @@
private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers();
@ -158,7 +161,7 @@
entityplayer.stopSleepInBed(false, false);
});
}
@@ -430,14 +489,14 @@
@@ -430,14 +492,14 @@
entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -175,7 +178,7 @@
}
}
@@ -448,12 +507,12 @@
@@ -448,12 +510,12 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value();
if (biomebase.shouldFreeze(this, blockposition1)) {
@ -190,7 +193,7 @@
}
IBlockData iblockdata = this.getBlockState(blockposition1);
@@ -649,6 +708,7 @@
@@ -649,6 +711,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
}
@ -198,7 +201,7 @@
if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
}
@@ -667,14 +727,47 @@
@@ -667,14 +730,47 @@
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
}
@ -248,7 +251,7 @@
}
public void resetEmptyTime() {
@@ -709,6 +802,7 @@
@@ -709,6 +805,7 @@
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick();
@ -256,7 +259,7 @@
this.getProfiler().pop();
Iterator iterator = entity.getPassengers().iterator();
@@ -732,6 +826,7 @@
@@ -732,6 +829,7 @@
});
gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick();
@ -264,7 +267,7 @@
gameprofilerfiller.pop();
Iterator iterator = entity1.getPassengers().iterator();
@@ -756,6 +851,7 @@
@@ -756,6 +854,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) {
@ -272,7 +275,7 @@
if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
}
@@ -773,11 +869,19 @@
@@ -773,11 +872,19 @@
}
}
@ -293,7 +296,7 @@
}
this.getChunkSource().getDataStorage().save();
@@ -823,15 +927,37 @@
@@ -823,15 +930,37 @@
@Override
public boolean addFreshEntity(Entity entity) {
@ -334,7 +337,7 @@
}
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
@@ -862,24 +988,37 @@
@@ -862,24 +991,37 @@
this.entityManager.addNewEntity(entityplayer);
}
@ -376,7 +379,7 @@
return true;
}
}
@@ -893,10 +1032,32 @@
@@ -893,10 +1035,32 @@
entityplayer.remove(entity_removalreason);
}
@ -409,7 +412,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -905,6 +1066,12 @@
@@ -905,6 +1069,12 @@
double d1 = (double) blockposition.getY() - entityplayer.getY();
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
@ -422,7 +425,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
}
@@ -941,6 +1108,14 @@
@@ -941,6 +1111,14 @@
public void gameEvent(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
int i = gameevent.getNotificationRadius();
BlockPosition blockposition = new BlockPosition(vec3d);
@ -437,7 +440,7 @@
int j = SectionPosition.blockToSectionCoord(blockposition.getX() - i);
int k = SectionPosition.blockToSectionCoord(blockposition.getY() - i);
int l = SectionPosition.blockToSectionCoord(blockposition.getZ() - i);
@@ -1013,7 +1188,18 @@
@@ -1013,7 +1191,18 @@
Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) {
@ -457,7 +460,7 @@
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -1069,10 +1255,20 @@
@@ -1069,10 +1258,20 @@
@Override
public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
@ -478,7 +481,7 @@
if (explosion_effect == Explosion.Effect.NONE) {
explosion.clearToBlow();
}
@@ -1144,13 +1340,20 @@
@@ -1144,13 +1343,20 @@
}
public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -501,7 +504,7 @@
++j;
}
}
@@ -1201,7 +1404,7 @@
@@ -1201,7 +1407,7 @@
@Nullable
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
@ -510,7 +513,7 @@
return null;
} else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(IRegistry.STRUCTURE_REGISTRY).getTag(tagkey);
@@ -1243,11 +1446,21 @@
@@ -1243,11 +1449,21 @@
@Nullable
@Override
public WorldMap getMapData(String s) {
@ -533,7 +536,7 @@
this.getServer().overworld().getDataStorage().set(s, worldmap);
}
@@ -1545,6 +1758,11 @@
@@ -1545,6 +1761,11 @@
@Override
public void blockUpdated(BlockPosition blockposition, Block block) {
if (!this.isDebug()) {
@ -545,7 +548,7 @@
this.updateNeighborsAt(blockposition, block);
}
@@ -1564,12 +1782,12 @@
@@ -1564,12 +1785,12 @@
}
public boolean isFlat() {
@ -560,7 +563,7 @@
}
@Nullable
@@ -1592,7 +1810,7 @@
@@ -1592,7 +1813,7 @@
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@ -569,7 +572,7 @@
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -1601,7 +1819,7 @@
@@ -1601,7 +1822,7 @@
object2intopenhashmap.addTo(s, 1);
}
@ -578,7 +581,7 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1612,17 +1830,33 @@
@@ -1612,17 +1833,33 @@
}
public static void makeObsidianPlatform(WorldServer worldserver) {
@ -614,7 +617,7 @@
}
@Override
@@ -1733,6 +1967,7 @@
@@ -1733,6 +1970,7 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@ -622,7 +625,7 @@
}
public void onTrackingEnd(Entity entity) {
@@ -1769,6 +2004,14 @@
@@ -1769,6 +2007,14 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);

View file

@ -0,0 +1,24 @@
--- a/net/minecraft/world/level/levelgen/ChunkProviderFlat.java
+++ b/net/minecraft/world/level/levelgen/ChunkProviderFlat.java
@@ -32,11 +32,17 @@
private final GeneratorSettingsFlat settings;
public ChunkProviderFlat(IRegistry<StructureSet> iregistry, GeneratorSettingsFlat generatorsettingsflat) {
- Optional optional = generatorsettingsflat.structureOverrides();
- WorldChunkManagerHell worldchunkmanagerhell = new WorldChunkManagerHell(generatorsettingsflat.getBiome());
+ // CraftBukkit start
+ // Optional optional = generatorsettingsflat.structureOverrides();
+ // WorldChunkManagerHell worldchunkmanagerhell = new WorldChunkManagerHell(generatorsettingsflat.getBiome());
- Objects.requireNonNull(generatorsettingsflat);
- super(iregistry, optional, worldchunkmanagerhell, SystemUtils.memoize(generatorsettingsflat::adjustGenerationSettings));
+ // Objects.requireNonNull(generatorsettingsflat);
+ this(iregistry, generatorsettingsflat, new WorldChunkManagerHell(generatorsettingsflat.getBiome()));
+ }
+
+ public ChunkProviderFlat(IRegistry<StructureSet> iregistry, GeneratorSettingsFlat generatorsettingsflat, net.minecraft.world.level.biome.WorldChunkManager worldchunkmanager) {
+ super(iregistry, generatorsettingsflat.structureOverrides(), worldchunkmanager, SystemUtils.memoize(generatorsettingsflat::adjustGenerationSettings));
+ // CraftBukkit end
this.settings = generatorsettingsflat;
}