diff --git a/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch index 7dfc137ed386..7bf3418a62d6 100644 --- a/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch @@ -31553,7 +31553,7 @@ index d63d745a0220963a297cfedf1e8983aeb471a045..6d565b52552534ce9cacfc35ad1bf4ad public record PackedTicks(List> blocks, List> fluids) { diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java -index b320519578f7e2c52b2116afb247e071b322696e..6ed51cf42b5864194d671b5b56f5b9bdf0291dc0 100644 +index 378e8ddef41c68884f9b29b3b07e23b454bab0c7..b202ba800bd3317abc38bf1c8a4df36ecfe0128c 100644 --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java @@ -116,7 +116,7 @@ public abstract class ChunkGenerator { @@ -31565,7 +31565,7 @@ index b320519578f7e2c52b2116afb247e071b322696e..6ed51cf42b5864194d671b5b56f5b9bd } public abstract void applyCarvers( -@@ -315,7 +315,7 @@ public abstract class ChunkGenerator { +@@ -329,7 +329,7 @@ public abstract class ChunkGenerator { return Pair.of(placement.getLocatePos(chunkPos), holder); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch index b2e3cf1867ad..8ea46be054ba 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch @@ -11,10 +11,17 @@ } public Optional>> getTypeNameForDataFixer() { -@@ -127,6 +_,24 @@ +@@ -127,6 +_,31 @@ public Pair> findNearestMapStructure( ServerLevel level, HolderSet structure, BlockPos pos, int searchRadius, boolean skipKnownStructures ) { ++ // Paper start - fix structures not generating when decorations are disabled ++ org.bukkit.generator.ChunkGenerator generator = level.getMinecraftWorld().getWorld().getGenerator(); ++ if (!level.structureManager().shouldGenerateStructures() || (generator != null && !generator.shouldGenerateStructures())) { ++ return null; ++ } ++ // Paper end - fix structures not generating when decorations are disabled ++ + // Paper start - StructuresLocateEvent + final org.bukkit.World bukkitWorld = level.getWorld(); + final org.bukkit.Location origin = io.papermc.paper.util.MCUtil.toLocation(level, pos); @@ -36,6 +43,20 @@ ChunkGeneratorStructureState generatorState = level.getChunkSource().getGeneratorState(); Map>> map = new Object2ObjectArrayMap<>(); +@@ -213,6 +_,13 @@ + boolean skipKnownStructures, + ConcentricRingsStructurePlacement placement + ) { ++ // Paper start - fix structures not generating when decorations are disabled ++ org.bukkit.generator.ChunkGenerator generator = level.getMinecraftWorld().getWorld().getGenerator(); ++ if (!level.structureManager().shouldGenerateStructures() || (generator != null && !generator.shouldGenerateStructures())) { ++ return null; ++ } ++ // Paper end - fix structures not generating when decorations are disabled ++ + List ringPositionsFor = level.getChunkSource().getGeneratorState().getRingPositionsFor(placement); + if (ringPositionsFor == null) { + throw new IllegalStateException("Somehow tried to find structures for a placement that doesn't exist"); @@ -222,6 +_,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); @@ -73,6 +94,38 @@ ChunkPos pos = chunk.getPos(); if (!SharedConstants.debugVoidTerrain(pos)) { SectionPos sectionPos = SectionPos.of(pos, level.getMinSectionY()); +@@ -338,30 +_,7 @@ + int max = Math.max(GenerationStep.Decoration.values().length, size); + + for (int i = 0; i < max; i++) { +- int i1 = 0; +- if (structureManager.shouldGenerateStructures()) { +- for (Structure structure : map.getOrDefault(i, Collections.emptyList())) { +- worldgenRandom.setFeatureSeed(l, i1, i); +- Supplier supplier = () -> registry.getResourceKey(structure).map(Object::toString).orElseGet(structure::toString); +- +- try { +- level.setCurrentlyGenerating(supplier); +- structureManager.startsForStructure(sectionPos, structure) +- .forEach( +- structureStart -> structureStart.placeInChunk( +- level, structureManager, this, worldgenRandom, getWritableArea(chunk), pos +- ) +- ); +- } catch (Exception var29) { +- CrashReport crashReport = CrashReport.forThrowable(var29, "Feature placement"); +- crashReport.addCategory("Feature").setDetail("Description", supplier::get); +- throw new ReportedException(crashReport); +- } +- +- i1++; +- } +- } +- ++ this.placeStructuresInStep(i, l, level, chunk, structureManager, sectionPos, map, registry, worldgenRandom); // Paper - fix structures not generating when decorations are disabled + if (i < size) { + IntSet set1 = new IntArraySet(); + @@ -385,7 +_,14 @@ int i3 = ints[i2]; PlacedFeature placedFeature = stepFeatureData1.features().get(i3); @@ -89,7 +142,7 @@ try { level.setCurrentlyGenerating(supplier1); -@@ -407,6 +_,32 @@ +@@ -407,6 +_,48 @@ } } } @@ -101,7 +154,23 @@ + public void applyBiomeDecoration(WorldGenLevel level, ChunkAccess chunk, StructureManager structureManager, boolean addVanillaDecorations) { + if (addVanillaDecorations) { + this.addVanillaDecorations(level, chunk, structureManager); ++ } else{ ++ org.bukkit.generator.ChunkGenerator generator = level.getMinecraftWorld().getWorld().getGenerator(); ++ if (structureManager.shouldGenerateStructures() && (generator == null || generator.shouldGenerateStructures())) { // Paper start - fix structures not generating when decorations are disabled ++ ChunkPos pos = chunk.getPos(); ++ SectionPos sectionPos = SectionPos.of(pos, level.getMinSectionY()); ++ Registry registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE); ++ Map> structureStepMap = registry.stream() ++ .collect(Collectors.groupingBy(s -> s.step().ordinal())); ++ List features = this.featuresPerStep.get(); ++ WorldgenRandom rand = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed())); ++ long seed = rand.setDecorationSeed(level.getSeed(), pos.getMinBlockX(), pos.getMinBlockZ()); ++ for (int i = 0; i < features.size(); i++) { ++ this.placeStructuresInStep(i, seed, level, chunk, structureManager, sectionPos, structureStepMap, registry, rand); ++ } ++ } + } ++ // Paper end - fix structures not generating when decorations are disabled + + org.bukkit.World world = level.getMinecraftWorld().getWorld(); + // only call when a populator is present (prevents unnecessary entity conversion) @@ -146,3 +215,46 @@ structureManager.setStartForStructure(sectionPos, structure, structureStart, chunk); return true; } else { +@@ -648,4 +_,42 @@ + public BiomeGenerationSettings getBiomeGenerationSettings(Holder biome) { + return this.generationSettingsGetter.apply(biome); + } ++ ++ // Paper start - fix structures not generating when decorations are disabled ++ private void placeStructuresInStep( ++ int stepIndex, ++ long decorationSeed, ++ WorldGenLevel level, ++ ChunkAccess chunk, ++ StructureManager structureManager, ++ SectionPos sectionPos, ++ Map> structureStepMap, ++ Registry structureRegistry, ++ WorldgenRandom worldgenRandom ++ ) { ++ int i1 = 0; ++ ChunkPos pos = chunk.getPos(); ++ if (structureManager.shouldGenerateStructures()) { ++ for (Structure structure : structureStepMap.getOrDefault(stepIndex, Collections.emptyList())) { ++ worldgenRandom.setFeatureSeed(decorationSeed, i1, stepIndex); ++ Supplier supplier = () -> structureRegistry.getResourceKey(structure).map(Object::toString).orElseGet(structure::toString); ++ ++ try { ++ level.setCurrentlyGenerating(supplier); ++ structureManager.startsForStructure(sectionPos, structure) ++ .forEach( ++ structureStart -> structureStart.placeInChunk( ++ level, structureManager, this, worldgenRandom, getWritableArea(chunk), pos) ++ ); ++ } catch (Exception var29) { ++ CrashReport crashReport = CrashReport.forThrowable(var29, "Feature placement"); ++ crashReport.addCategory("Feature").setDetail("Description", supplier::get); ++ throw new ReportedException(crashReport); ++ } ++ ++ i1++; ++ } ++ } ++ } ++ // Paper end - fix structures not generating when decorations are disabled + }