diff --git a/.github/workflows/check_build.yml b/.github/workflows/check_build.yml index 67129db..cb45152 100644 --- a/.github/workflows/check_build.yml +++ b/.github/workflows/check_build.yml @@ -18,14 +18,15 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 - name: Setup JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'zulu' java-version: ${{ matrix.java }} - name: Make Gradle wrapper executable if: ${{ runner.os != 'Windows' }} @@ -36,7 +37,7 @@ jobs: run: ./gradlew build --stacktrace -x runDatagen - name: Capture build artifacts if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from LTS java on one OS - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Artifacts path: build/libs/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bead6e2..3076c6e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,15 +19,15 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Create version tag - uses: actions/github-script@v3 + uses: actions/github-script@v7 with: github-token: ${{ github.token }} script: | - github.git.createRef({ + github.rest.git.createRef({ owner: context.repo.owner, repo: context.repo.repo, ref: "refs/tags/v${{ github.event.inputs.version }}", @@ -36,10 +36,11 @@ jobs: - name: Fetch tags run: git fetch --tags - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 - name: Setup JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'zulu' java-version: ${{ matrix.java }} - name: Make Gradle wrapper executable if: ${{ runner.os != 'Windows' }} @@ -58,7 +59,7 @@ jobs: DISCORD_ANNOUNCEMENT_WEBHOOK: ${{ secrets.DISCORD_ANNOUNCEMENT_WEBHOOK }} - name: Capture build artifacts if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from LTS java on one OS - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Artifacts path: build/libs/ diff --git a/build.gradle b/build.gradle index 8bdf783..ecab71b 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'maven-publish' id 'idea' id 'eclipse' - id 'fabric-loom' version '1.4.+' + id 'fabric-loom' version '1.5.+' } apply from: 'https://raw.githubusercontent.com/TerraformersMC/GradleScripts/2.6/ferry.gradle' diff --git a/common/build.gradle b/common/build.gradle index 80a94b2..d636afa 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -3,13 +3,13 @@ archivesBaseName = "traverse-common" loom { runs { datagen { - server() + inherit server name = "Data Generation" runDir = "build/datagen" - vmArg("-Dfabric-api.datagen") - vmArg("-Dfabric-api.datagen.output-dir=${file("src/main/generated")}") + vmArg "-Dfabric-api.datagen" + vmArg "-Dfabric-api.datagen.output-dir=${file("src/main/generated")}" } } } diff --git a/common/src/main/java/com/terraformersmc/traverse/Traverse.java b/common/src/main/java/com/terraformersmc/traverse/Traverse.java index c0bd948..2660d8d 100644 --- a/common/src/main/java/com/terraformersmc/traverse/Traverse.java +++ b/common/src/main/java/com/terraformersmc/traverse/Traverse.java @@ -1,10 +1,7 @@ package com.terraformersmc.traverse; -import com.terraformersmc.traverse.biome.TraverseBiomes; import com.terraformersmc.traverse.block.TraverseBlocks; import com.terraformersmc.traverse.config.TraverseConfigManager; -import com.terraformersmc.traverse.feature.TraverseConfiguredFeatures; -import com.terraformersmc.traverse.feature.TraversePlacedFeatures; import com.terraformersmc.traverse.feature.placer.TraversePlacerTypes; import com.terraformersmc.traverse.init.TraverseTrades; import com.terraformersmc.traverse.item.TraverseBoatTypes; @@ -31,9 +28,6 @@ private static void register() { TraverseBlocks.register(); TraverseItems.register(); TraverseBoatTypes.register(); - TraverseConfiguredFeatures.register(); - TraversePlacedFeatures.register(); - TraverseBiomes.register(); TraverseTrades.register(); TraverseVillagerTypes.register(); TraversePlacerTypes.register(); diff --git a/common/src/main/java/com/terraformersmc/traverse/biome/AutumnalWoodsBiomes.java b/common/src/main/java/com/terraformersmc/traverse/biome/AutumnalWoodsBiomes.java index 706fd32..333832b 100644 --- a/common/src/main/java/com/terraformersmc/traverse/biome/AutumnalWoodsBiomes.java +++ b/common/src/main/java/com/terraformersmc/traverse/biome/AutumnalWoodsBiomes.java @@ -1,21 +1,25 @@ package com.terraformersmc.traverse.biome; import com.terraformersmc.traverse.feature.TraversePlacedFeatures; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryEntryLookup; +import net.minecraft.registry.RegistryKeys; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.carver.ConfiguredCarver; import net.minecraft.world.gen.feature.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.PlacedFeature; import static com.terraformersmc.traverse.biome.TraverseBiomes.addBasicFeatures; public class AutumnalWoodsBiomes { - public static Biome create(FabricDynamicRegistryProvider.Entries entries) { + public static Biome create(Registerable registerable) { return new Biome.Builder() - .generationSettings(createGenerationSettings(entries)) + .generationSettings(createGenerationSettings(registerable)) .spawnSettings(createSpawnSettings()) .precipitation(true) .temperature(0.8F) @@ -28,12 +32,15 @@ public static Biome create(FabricDynamicRegistryProvider.Entries entries) { .build(); } - private static GenerationSettings createGenerationSettings(FabricDynamicRegistryProvider.Entries entries) { - GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(entries.placedFeatures(), entries.configuredCarvers()); + private static GenerationSettings createGenerationSettings(Registerable registerable) { + RegistryEntryLookup> configuredCarvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER); + RegistryEntryLookup placedFeatures = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + + GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(placedFeatures, configuredCarvers); addBasicFeatures(builder); DefaultBiomeFeatures.addDefaultOres(builder); DefaultBiomeFeatures.addDefaultDisks(builder); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.AUTUMNAL_TREES)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.AUTUMNAL_TREES)); DefaultBiomeFeatures.addForestFlowers(builder); DefaultBiomeFeatures.addDefaultFlowers(builder); DefaultBiomeFeatures.addForestGrass(builder); diff --git a/common/src/main/java/com/terraformersmc/traverse/biome/ConiferousForestBiomes.java b/common/src/main/java/com/terraformersmc/traverse/biome/ConiferousForestBiomes.java index ac182c3..8a676ec 100644 --- a/common/src/main/java/com/terraformersmc/traverse/biome/ConiferousForestBiomes.java +++ b/common/src/main/java/com/terraformersmc/traverse/biome/ConiferousForestBiomes.java @@ -1,21 +1,25 @@ package com.terraformersmc.traverse.biome; import com.terraformersmc.traverse.feature.TraversePlacedFeatures; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryEntryLookup; +import net.minecraft.registry.RegistryKeys; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.carver.ConfiguredCarver; import net.minecraft.world.gen.feature.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.PlacedFeature; import static com.terraformersmc.traverse.biome.TraverseBiomes.addBasicFeatures; public class ConiferousForestBiomes { - public static Biome create(FabricDynamicRegistryProvider.Entries entries, boolean snowy) { + public static Biome create(Registerable registerable, boolean snowy) { return new Biome.Builder() - .generationSettings(createGenerationSettings(entries, snowy)) + .generationSettings(createGenerationSettings(registerable, snowy)) .spawnSettings(createSpawnSettings()) .precipitation(true) .temperature(snowy ? -0.5F : 0.6F) @@ -28,13 +32,16 @@ public static Biome create(FabricDynamicRegistryProvider.Entries entries, boolea .build(); } - private static GenerationSettings createGenerationSettings(FabricDynamicRegistryProvider.Entries entries, boolean snowy) { - GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(entries.placedFeatures(), entries.configuredCarvers()); + private static GenerationSettings createGenerationSettings(Registerable registerable, boolean snowy) { + RegistryEntryLookup> configuredCarvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER); + RegistryEntryLookup placedFeatures = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + + GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(placedFeatures, configuredCarvers); addBasicFeatures(builder); DefaultBiomeFeatures.addLargeFerns(builder); DefaultBiomeFeatures.addDefaultOres(builder); DefaultBiomeFeatures.addDefaultDisks(builder); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.CONIFEROUS_TREES)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.CONIFEROUS_TREES)); DefaultBiomeFeatures.addDefaultFlowers(builder); DefaultBiomeFeatures.addTaigaGrass(builder); DefaultBiomeFeatures.addDefaultVegetation(builder); diff --git a/common/src/main/java/com/terraformersmc/traverse/biome/DesertShrublandBiomes.java b/common/src/main/java/com/terraformersmc/traverse/biome/DesertShrublandBiomes.java index e1cb472..010e9f2 100644 --- a/common/src/main/java/com/terraformersmc/traverse/biome/DesertShrublandBiomes.java +++ b/common/src/main/java/com/terraformersmc/traverse/biome/DesertShrublandBiomes.java @@ -1,21 +1,25 @@ package com.terraformersmc.traverse.biome; import com.terraformersmc.traverse.feature.TraversePlacedFeatures; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryEntryLookup; +import net.minecraft.registry.RegistryKeys; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.carver.ConfiguredCarver; import net.minecraft.world.gen.feature.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.PlacedFeature; import static com.terraformersmc.traverse.biome.TraverseBiomes.addBasicFeatures; public class DesertShrublandBiomes { - public static Biome create(FabricDynamicRegistryProvider.Entries entries) { + public static Biome create(Registerable registerable) { return new Biome.Builder() - .generationSettings(createGenerationSettings(entries)) + .generationSettings(createGenerationSettings(registerable)) .spawnSettings(createSpawnSettings()) .precipitation(false) .temperature(2.0F) @@ -28,19 +32,22 @@ public static Biome create(FabricDynamicRegistryProvider.Entries entries) { .build(); } - private static GenerationSettings createGenerationSettings(FabricDynamicRegistryProvider.Entries entries) { - GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(entries.placedFeatures(), entries.configuredCarvers()); + private static GenerationSettings createGenerationSettings(Registerable registerable) { + RegistryEntryLookup> configuredCarvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER); + RegistryEntryLookup placedFeatures = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + + GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(placedFeatures, configuredCarvers); DefaultBiomeFeatures.addFossils(builder); addBasicFeatures(builder); DefaultBiomeFeatures.addDefaultOres(builder); DefaultBiomeFeatures.addDefaultDisks(builder); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.DESERT_SHRUBS)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.DESERT_SHRUBS)); DefaultBiomeFeatures.addDefaultFlowers(builder); DefaultBiomeFeatures.addDefaultGrass(builder); DefaultBiomeFeatures.addDesertDeadBushes(builder); DefaultBiomeFeatures.addDefaultMushrooms(builder); DefaultBiomeFeatures.addDesertVegetation(builder); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.DESERT_EXTRA_CACTUS)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.DESERT_EXTRA_CACTUS)); DefaultBiomeFeatures.addDesertFeatures(builder); return builder.build(); } diff --git a/common/src/main/java/com/terraformersmc/traverse/biome/FlatlandsBiomes.java b/common/src/main/java/com/terraformersmc/traverse/biome/FlatlandsBiomes.java index d11629b..3870ea7 100644 --- a/common/src/main/java/com/terraformersmc/traverse/biome/FlatlandsBiomes.java +++ b/common/src/main/java/com/terraformersmc/traverse/biome/FlatlandsBiomes.java @@ -1,18 +1,22 @@ package com.terraformersmc.traverse.biome; import com.terraformersmc.traverse.feature.TraversePlacedFeatures; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryEntryLookup; +import net.minecraft.registry.RegistryKeys; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.carver.ConfiguredCarver; import net.minecraft.world.gen.feature.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.PlacedFeature; import static com.terraformersmc.traverse.biome.TraverseBiomes.addBasicFeatures; public class FlatlandsBiomes { - public static Biome create(FabricDynamicRegistryProvider.Entries entries) { + public static Biome create(Registerable registerable) { return new Biome.Builder() - .generationSettings(createGenerationSettings(entries)) + .generationSettings(createGenerationSettings(registerable)) .spawnSettings(TraverseBiomes.createDefaultSpawnSettings().build()) .precipitation(true) .temperature(0.8F) @@ -25,14 +29,17 @@ public static Biome create(FabricDynamicRegistryProvider.Entries entries) { .build(); } - private static GenerationSettings createGenerationSettings(FabricDynamicRegistryProvider.Entries entries) { - GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(entries.placedFeatures(), entries.configuredCarvers()); + private static GenerationSettings createGenerationSettings(Registerable registerable) { + RegistryEntryLookup> configuredCarvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER); + RegistryEntryLookup placedFeatures = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + + GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(placedFeatures, configuredCarvers); addBasicFeatures(builder); DefaultBiomeFeatures.addDefaultOres(builder); DefaultBiomeFeatures.addDefaultDisks(builder); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.FLATLANDS_TREES)); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.LUSH_FLOWERS)); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.FLATLANDS_GRASS)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.FLATLANDS_TREES)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.LUSH_FLOWERS)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.FLATLANDS_GRASS)); DefaultBiomeFeatures.addDefaultMushrooms(builder); DefaultBiomeFeatures.addDefaultVegetation(builder); return builder.build(); diff --git a/common/src/main/java/com/terraformersmc/traverse/biome/LushSwampBiomes.java b/common/src/main/java/com/terraformersmc/traverse/biome/LushSwampBiomes.java index 36f6eb8..9b5e320 100644 --- a/common/src/main/java/com/terraformersmc/traverse/biome/LushSwampBiomes.java +++ b/common/src/main/java/com/terraformersmc/traverse/biome/LushSwampBiomes.java @@ -1,22 +1,26 @@ package com.terraformersmc.traverse.biome; import com.terraformersmc.traverse.feature.TraversePlacedFeatures; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryEntryLookup; +import net.minecraft.registry.RegistryKeys; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.carver.ConfiguredCarver; import net.minecraft.world.gen.feature.DefaultBiomeFeatures; import net.minecraft.world.gen.feature.OceanPlacedFeatures; +import net.minecraft.world.gen.feature.PlacedFeature; import static com.terraformersmc.traverse.biome.TraverseBiomes.addBasicFeatures; public class LushSwampBiomes { - public static Biome create(FabricDynamicRegistryProvider.Entries entries) { + public static Biome create(Registerable registerable) { return new Biome.Builder() - .generationSettings(createGenerationSettings(entries)) + .generationSettings(createGenerationSettings(registerable)) .spawnSettings(createSpawnSettings()) .precipitation(true) .temperature(0.8F) @@ -30,14 +34,17 @@ public static Biome create(FabricDynamicRegistryProvider.Entries entries) { .build(); } - public static GenerationSettings createGenerationSettings(FabricDynamicRegistryProvider.Entries entries) { - GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(entries.placedFeatures(), entries.configuredCarvers()); + public static GenerationSettings createGenerationSettings(Registerable registerable) { + RegistryEntryLookup> configuredCarvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER); + RegistryEntryLookup placedFeatures = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + + GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(placedFeatures, configuredCarvers); DefaultBiomeFeatures.addFossils(builder); addBasicFeatures(builder); DefaultBiomeFeatures.addDefaultOres(builder); DefaultBiomeFeatures.addClayDisk(builder); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.SWAMP_FUNGUS)); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.LUSH_SWAMP_TREES)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.SWAMP_FUNGUS)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.LUSH_SWAMP_TREES)); DefaultBiomeFeatures.addSwampFeatures(builder); DefaultBiomeFeatures.addDefaultMushrooms(builder); DefaultBiomeFeatures.addSwampVegetation(builder); diff --git a/common/src/main/java/com/terraformersmc/traverse/biome/TraverseBiomes.java b/common/src/main/java/com/terraformersmc/traverse/biome/TraverseBiomes.java index d08deee..b1ab320 100644 --- a/common/src/main/java/com/terraformersmc/traverse/biome/TraverseBiomes.java +++ b/common/src/main/java/com/terraformersmc/traverse/biome/TraverseBiomes.java @@ -1,9 +1,9 @@ package com.terraformersmc.traverse.biome; import com.terraformersmc.traverse.Traverse; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; +import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; @@ -32,14 +32,14 @@ public class TraverseBiomes { WOODLANDS ); - public static void populate(FabricDynamicRegistryProvider.Entries entries) { - entries.add(AUTUMNAL_WOODS, AutumnalWoodsBiomes.create(entries)); - entries.add(CONIFEROUS_FOREST, ConiferousForestBiomes.create(entries, false)); - entries.add(DESERT_SHRUBLAND, DesertShrublandBiomes.create(entries)); - entries.add(FLATLANDS, FlatlandsBiomes.create(entries)); - entries.add(LUSH_SWAMP, LushSwampBiomes.create(entries)); - entries.add(SNOWY_CONIFEROUS_FOREST, ConiferousForestBiomes.create(entries, true)); - entries.add(WOODLANDS, WoodlandsBiomes.create(entries)); + public static void bootstrap(Registerable registerable) { + registerable.register(AUTUMNAL_WOODS, AutumnalWoodsBiomes.create(registerable)); + registerable.register(CONIFEROUS_FOREST, ConiferousForestBiomes.create(registerable, false)); + registerable.register(DESERT_SHRUBLAND, DesertShrublandBiomes.create(registerable)); + registerable.register(FLATLANDS, FlatlandsBiomes.create(registerable)); + registerable.register(LUSH_SWAMP, LushSwampBiomes.create(registerable)); + registerable.register(SNOWY_CONIFEROUS_FOREST, ConiferousForestBiomes.create(registerable, true)); + registerable.register(WOODLANDS, WoodlandsBiomes.create(registerable)); } static void addBasicFeatures(GenerationSettings.LookupBackedBuilder generationSettings) { @@ -94,8 +94,4 @@ private static int getSkyColor(float temperature) { f = MathHelper.clamp(f, -1.0F, 1.0F); return MathHelper.hsvToRgb(0.62222224F - f * 0.05F, 0.5F + f * 0.1F, 1.0F); } - - public static void register() { - // This just creates the registry keys. Biome objects are requested and consumed by datagen now. - } } diff --git a/common/src/main/java/com/terraformersmc/traverse/biome/WoodlandsBiomes.java b/common/src/main/java/com/terraformersmc/traverse/biome/WoodlandsBiomes.java index b6db655..35366c2 100644 --- a/common/src/main/java/com/terraformersmc/traverse/biome/WoodlandsBiomes.java +++ b/common/src/main/java/com/terraformersmc/traverse/biome/WoodlandsBiomes.java @@ -1,21 +1,25 @@ package com.terraformersmc.traverse.biome; import com.terraformersmc.traverse.feature.TraversePlacedFeatures; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryEntryLookup; +import net.minecraft.registry.RegistryKeys; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.carver.ConfiguredCarver; import net.minecraft.world.gen.feature.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.PlacedFeature; import static com.terraformersmc.traverse.biome.TraverseBiomes.addBasicFeatures; public class WoodlandsBiomes { - public static Biome create(FabricDynamicRegistryProvider.Entries entries) { + public static Biome create(Registerable registerable) { return new Biome.Builder() - .generationSettings(createGenerationSettings(entries)) + .generationSettings(createGenerationSettings(registerable)) .spawnSettings(createSpawnSettings()) .precipitation(true) .temperature(0.8F) @@ -28,12 +32,15 @@ public static Biome create(FabricDynamicRegistryProvider.Entries entries) { .build(); } - private static GenerationSettings createGenerationSettings(FabricDynamicRegistryProvider.Entries entries) { - GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(entries.placedFeatures(), entries.configuredCarvers()); + private static GenerationSettings createGenerationSettings(Registerable registerable) { + RegistryEntryLookup> configuredCarvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER); + RegistryEntryLookup placedFeatures = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + + GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(placedFeatures, configuredCarvers); addBasicFeatures(builder); DefaultBiomeFeatures.addDefaultOres(builder); DefaultBiomeFeatures.addDefaultDisks(builder); - builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, entries.ref(TraversePlacedFeatures.WOODLANDS_TREES)); + builder.feature(GenerationStep.Feature.VEGETAL_DECORATION, placedFeatures.getOrThrow(TraversePlacedFeatures.WOODLANDS_TREES)); DefaultBiomeFeatures.addForestFlowers(builder); DefaultBiomeFeatures.addDefaultFlowers(builder); DefaultBiomeFeatures.addForestGrass(builder); diff --git a/common/src/main/java/com/terraformersmc/traverse/data/TraverseBlockLootTableProvider.java b/common/src/main/java/com/terraformersmc/traverse/data/TraverseBlockLootTableProvider.java index fcde706..eab3355 100644 --- a/common/src/main/java/com/terraformersmc/traverse/data/TraverseBlockLootTableProvider.java +++ b/common/src/main/java/com/terraformersmc/traverse/data/TraverseBlockLootTableProvider.java @@ -3,10 +3,13 @@ import com.terraformersmc.traverse.block.TraverseBlocks; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider; +import net.minecraft.registry.RegistryWrapper; + +import java.util.concurrent.CompletableFuture; public class TraverseBlockLootTableProvider extends FabricBlockLootTableProvider { - protected TraverseBlockLootTableProvider(FabricDataOutput dataOutput) { - super(dataOutput); + protected TraverseBlockLootTableProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); } @Override diff --git a/common/src/main/java/com/terraformersmc/traverse/data/TraverseDatagen.java b/common/src/main/java/com/terraformersmc/traverse/data/TraverseDatagen.java index a9c2514..eeae48a 100644 --- a/common/src/main/java/com/terraformersmc/traverse/data/TraverseDatagen.java +++ b/common/src/main/java/com/terraformersmc/traverse/data/TraverseDatagen.java @@ -2,6 +2,7 @@ import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.minecraft.registry.RegistryBuilder; public class TraverseDatagen implements DataGeneratorEntrypoint { @Override @@ -15,4 +16,9 @@ public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) { pack.addProvider((output, registries) -> new TraverseItemTagProvider(output, registries, blockTagProvider)); pack.addProvider(TraverseRecipeProvider::new); } + + @Override + public void buildRegistry(RegistryBuilder registryBuilder) { + TraverseDynamicRegistryProvider.buildRegistry(registryBuilder); + } } diff --git a/common/src/main/java/com/terraformersmc/traverse/data/TraverseDynamicRegistryProvider.java b/common/src/main/java/com/terraformersmc/traverse/data/TraverseDynamicRegistryProvider.java index 1268663..f9e00f2 100644 --- a/common/src/main/java/com/terraformersmc/traverse/data/TraverseDynamicRegistryProvider.java +++ b/common/src/main/java/com/terraformersmc/traverse/data/TraverseDynamicRegistryProvider.java @@ -1,12 +1,17 @@ package com.terraformersmc.traverse.data; +import com.terraformersmc.traverse.Traverse; import com.terraformersmc.traverse.biome.TraverseBiomes; import com.terraformersmc.traverse.feature.TraverseConfiguredFeatures; import com.terraformersmc.traverse.feature.TraversePlacedFeatures; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import net.minecraft.registry.RegistryBuilder; +import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; +import net.minecraft.registry.entry.RegistryEntry; +import java.util.List; import java.util.concurrent.CompletableFuture; public class TraverseDynamicRegistryProvider extends FabricDynamicRegistryProvider { @@ -14,15 +19,32 @@ protected TraverseDynamicRegistryProvider(FabricDataOutput output, CompletableFu super(output, registriesFuture); } + public static void buildRegistry(RegistryBuilder registryBuilder) { + registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, TraverseConfiguredFeatures::bootstrap); + registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, TraversePlacedFeatures::bootstrap); + registryBuilder.addRegistry(RegistryKeys.BIOME, TraverseBiomes::bootstrap); + } + @Override public void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - TraverseConfiguredFeatures.populate(entries); - TraversePlacedFeatures.populate(entries); - TraverseBiomes.populate(entries); + addAll(entries, registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE), Traverse.MOD_ID); + addAll(entries, registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE), Traverse.MOD_ID); + addAll(entries, registries.getWrapperOrThrow(RegistryKeys.BIOME), Traverse.MOD_ID); } @Override public String getName() { return "Traverse"; } + + /** + * Version of FabricDynamicRegistryProvider.Entries.addAll() using specified mod ID. + */ + @SuppressWarnings("UnusedReturnValue") + public List> addAll(Entries entries, RegistryWrapper.Impl registry, String modId) { + return registry.streamKeys() + .filter(registryKey -> registryKey.getValue().getNamespace().equals(modId)) + .map(key -> entries.add(registry, key)) + .toList(); + } } diff --git a/common/src/main/java/com/terraformersmc/traverse/data/TraverseRecipeProvider.java b/common/src/main/java/com/terraformersmc/traverse/data/TraverseRecipeProvider.java index 83c043d..e093027 100644 --- a/common/src/main/java/com/terraformersmc/traverse/data/TraverseRecipeProvider.java +++ b/common/src/main/java/com/terraformersmc/traverse/data/TraverseRecipeProvider.java @@ -11,11 +11,14 @@ import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.book.RecipeCategory; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.util.Identifier; +import java.util.concurrent.CompletableFuture; + public class TraverseRecipeProvider extends FabricRecipeProvider { - protected TraverseRecipeProvider(FabricDataOutput dataOutput) { - super(dataOutput); + protected TraverseRecipeProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); } @Override diff --git a/common/src/main/java/com/terraformersmc/traverse/feature/TraverseConfiguredFeatures.java b/common/src/main/java/com/terraformersmc/traverse/feature/TraverseConfiguredFeatures.java index 6c7a570..143f74a 100644 --- a/common/src/main/java/com/terraformersmc/traverse/feature/TraverseConfiguredFeatures.java +++ b/common/src/main/java/com/terraformersmc/traverse/feature/TraverseConfiguredFeatures.java @@ -1,72 +1,101 @@ package com.terraformersmc.traverse.feature; +import com.google.common.collect.ImmutableList; import com.terraformersmc.traverse.Traverse; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; import net.minecraft.block.Blocks; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryEntryLookup; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntryList; import net.minecraft.util.Identifier; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.ConfiguredFeatures; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.FeatureConfig; -import net.minecraft.world.gen.feature.SimpleBlockFeatureConfig; +import net.minecraft.world.gen.feature.*; import net.minecraft.world.gen.stateprovider.BlockStateProvider; import java.util.List; public class TraverseConfiguredFeatures { /* Logs and Shrubs */ - static final RegistryKey> FALLEN_OAK_TREE = createRegistryKey("fallen_oak_tree"); - static final RegistryKey> OAK_SHRUB = createRegistryKey("oak_shrub"); + public static final RegistryKey> FALLEN_OAK_TREE = createRegistryKey("fallen_oak_tree"); + public static final RegistryKey> OAK_SHRUB = createRegistryKey("oak_shrub"); + public static final RegistryKey> WOODLANDS_TREES = createRegistryKey("woodlands_trees"); /* Autumnal Trees */ public static final RegistryKey> BROWN_AUTUMNAL_TREE = createRegistryKey("brown_autumnal_tree"); public static final RegistryKey> ORANGE_AUTUMNAL_TREE = createRegistryKey("orange_autumnal_tree"); public static final RegistryKey> RED_AUTUMNAL_TREE = createRegistryKey("red_autumnal_tree"); public static final RegistryKey> YELLOW_AUTUMNAL_TREE = createRegistryKey("yellow_autumnal_tree"); + public static final RegistryKey> AUTUMNAL_TREES = createRegistryKey("autumnal_trees"); /* Fir Trees */ public static final RegistryKey> FIR_TREE = createRegistryKey("fir_tree"); /* Swamp Trees */ - static final RegistryKey> TALL_SWAMP_TREE = createRegistryKey("tall_swamp_tree"); + public static final RegistryKey> TALL_SWAMP_TREE = createRegistryKey("tall_swamp_tree"); + public static final RegistryKey> SWAMP_FUNGUS = createRegistryKey("swamp_fungus"); /* Lush Vegetation */ public static final RegistryKey> FLATLANDS_GRASS = createRegistryKey("flatlands_grass"); public static final RegistryKey> LUSH_FLOWERS = createRegistryKey("lush_flowers"); - public static void populate(FabricDynamicRegistryProvider.Entries entries) { + public static void bootstrap(Registerable> registerable) { + RegistryEntryLookup> configuredFeatures = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE); + RegistryEntryLookup placedFeatures = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + /* Logs and Shrubs */ - entries.add(FALLEN_OAK_TREE, configureFeature(Feature.TREE, TraverseFeatureConfigs.FALLEN_OAK_TREE_CONFIG)); - entries.add(OAK_SHRUB, configureFeature(Feature.TREE, TraverseFeatureConfigs.OAK_SHRUB_CONFIG)); + register(registerable, FALLEN_OAK_TREE, Feature.TREE, TraverseFeatureConfigs.FALLEN_OAK_TREE_CONFIG); + register(registerable, OAK_SHRUB, Feature.TREE, TraverseFeatureConfigs.OAK_SHRUB_CONFIG); + register(registerable, WOODLANDS_TREES, + Feature.RANDOM_SELECTOR, + new RandomFeatureConfig( + ImmutableList.of( + new RandomFeatureEntry(placedFeatures.getOrThrow(TraversePlacedFeatures.WOODLANDS_SHRUB), 0.2F), + new RandomFeatureEntry(placedFeatures.getOrThrow(TraversePlacedFeatures.WOODLANDS_FALLEN_LOG), 0.3F) + ), placedFeatures.getOrThrow(TreePlacedFeatures.OAK_CHECKED) + ) + ); /* Autumnal Trees */ - entries.add(BROWN_AUTUMNAL_TREE, configureFeature(Feature.TREE, TraverseFeatureConfigs.BROWN_AUTUMNAL_TREE_CONFIG)); - entries.add(ORANGE_AUTUMNAL_TREE, configureFeature(Feature.TREE, TraverseFeatureConfigs.ORANGE_AUTUMNAL_TREE_CONFIG)); - entries.add(RED_AUTUMNAL_TREE, configureFeature(Feature.TREE, TraverseFeatureConfigs.RED_AUTUMNAL_TREE_CONFIG)); - entries.add(YELLOW_AUTUMNAL_TREE, configureFeature(Feature.TREE, TraverseFeatureConfigs.YELLOW_AUTUMNAL_TREE_CONFIG)); + register(registerable, BROWN_AUTUMNAL_TREE, Feature.TREE, TraverseFeatureConfigs.BROWN_AUTUMNAL_TREE_CONFIG); + register(registerable, ORANGE_AUTUMNAL_TREE, Feature.TREE, TraverseFeatureConfigs.ORANGE_AUTUMNAL_TREE_CONFIG); + register(registerable, RED_AUTUMNAL_TREE, Feature.TREE, TraverseFeatureConfigs.RED_AUTUMNAL_TREE_CONFIG); + register(registerable, YELLOW_AUTUMNAL_TREE, Feature.TREE, TraverseFeatureConfigs.YELLOW_AUTUMNAL_TREE_CONFIG); + register(registerable, AUTUMNAL_TREES, + Feature.SIMPLE_RANDOM_SELECTOR, + new SimpleRandomFeatureConfig( + RegistryEntryList.of( + placedFeatures.getOrThrow(TraversePlacedFeatures.BROWN_AUTUMNAL_TREE), + placedFeatures.getOrThrow(TraversePlacedFeatures.ORANGE_AUTUMNAL_TREE), + placedFeatures.getOrThrow(TraversePlacedFeatures.RED_AUTUMNAL_TREE), + placedFeatures.getOrThrow(TraversePlacedFeatures.YELLOW_AUTUMNAL_TREE), + placedFeatures.getOrThrow(TreePlacedFeatures.OAK_CHECKED) + ) + ) + ); /* Fir Trees */ - entries.add(FIR_TREE, configureFeature(Feature.TREE, TraverseFeatureConfigs.FIR_TREE_CONFIG)); + register(registerable, FIR_TREE, Feature.TREE, TraverseFeatureConfigs.FIR_TREE_CONFIG); /* Swamp Trees */ - entries.add(TALL_SWAMP_TREE, configureFeature(Feature.TREE, TraverseFeatureConfigs.TALL_SWAMP_TREE_CONFIG)); + register(registerable, TALL_SWAMP_TREE, Feature.TREE, TraverseFeatureConfigs.TALL_SWAMP_TREE_CONFIG); + register(registerable, SWAMP_FUNGUS, + Feature.RANDOM_BOOLEAN_SELECTOR, + new RandomBooleanFeatureConfig( + PlacedFeatures.createEntry(configuredFeatures.getOrThrow(TreeConfiguredFeatures.HUGE_BROWN_MUSHROOM)), + PlacedFeatures.createEntry(configuredFeatures.getOrThrow(TreeConfiguredFeatures.HUGE_RED_MUSHROOM)) + ) + ); /* Lush Vegetation */ - entries.add(FLATLANDS_GRASS, configureFeature(Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig(BlockStateProvider.of(Blocks.SHORT_GRASS)), List.of(), 32))); - entries.add(LUSH_FLOWERS, configureFeature(Feature.FLOWER, TraverseFeatureConfigs.LUSH_FLOWER_CONFIG)); + register(registerable, FLATLANDS_GRASS, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig(BlockStateProvider.of(Blocks.SHORT_GRASS)), List.of(), 32)); + register(registerable, LUSH_FLOWERS, Feature.FLOWER, TraverseFeatureConfigs.LUSH_FLOWER_CONFIG); } public static RegistryKey> createRegistryKey(String name) { return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, Identifier.of(Traverse.MOD_ID, name)); } - public static > ConfiguredFeature configureFeature(F feature, FC config) { - return new ConfiguredFeature<>(feature, config); - } - - public static void register() { - // This just creates the registry keys. Configured Features are requested and consumed by datagen now. + public static > void register(Registerable> registerable, RegistryKey> key, F feature, FC config) { + ConfiguredFeatures.register(registerable, key, feature, config); } } diff --git a/common/src/main/java/com/terraformersmc/traverse/feature/TraversePlacedFeatures.java b/common/src/main/java/com/terraformersmc/traverse/feature/TraversePlacedFeatures.java index 5f7c8f8..6648999 100644 --- a/common/src/main/java/com/terraformersmc/traverse/feature/TraversePlacedFeatures.java +++ b/common/src/main/java/com/terraformersmc/traverse/feature/TraversePlacedFeatures.java @@ -1,13 +1,15 @@ package com.terraformersmc.traverse.feature; -import com.google.common.collect.ImmutableList; import com.terraformersmc.traverse.Traverse; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import com.terraformersmc.traverse.block.TraverseBlocks; +import net.minecraft.block.Blocks; +import net.minecraft.registry.Registerable; +import net.minecraft.registry.RegistryEntryLookup; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.entry.RegistryEntryList; import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.gen.blockpredicate.BlockPredicate; import net.minecraft.world.gen.feature.*; @@ -22,11 +24,10 @@ public class TraversePlacedFeatures { public static final RegistryKey DESERT_SHRUBS = createRegistryKey("desert_shrubs"); /* Autumnal Trees */ - private static final RegistryKey BROWN_AUTUMNAL_TREE = createRegistryKey("brown_autumnal_tree"); - private static final RegistryKey ORANGE_AUTUMNAL_TREE = createRegistryKey("orange_autumnal_tree"); - private static final RegistryKey RED_AUTUMNAL_TREE = createRegistryKey("red_autumnal_tree"); - private static final RegistryKey YELLOW_AUTUMNAL_TREE = createRegistryKey("yellow_autumnal_tree"); - private static final RegistryKey> AUTUMNAL_TREES_CONFIGURED = TraverseConfiguredFeatures.createRegistryKey("autumnal_trees"); + public static final RegistryKey BROWN_AUTUMNAL_TREE = createRegistryKey("brown_autumnal_tree"); + public static final RegistryKey ORANGE_AUTUMNAL_TREE = createRegistryKey("orange_autumnal_tree"); + public static final RegistryKey RED_AUTUMNAL_TREE = createRegistryKey("red_autumnal_tree"); + public static final RegistryKey YELLOW_AUTUMNAL_TREE = createRegistryKey("yellow_autumnal_tree"); public static final RegistryKey AUTUMNAL_TREES = createRegistryKey("autumnal_trees"); /* Fir Trees */ @@ -34,7 +35,6 @@ public class TraversePlacedFeatures { /* Swamp Trees */ public static final RegistryKey LUSH_SWAMP_TREES = createRegistryKey("lush_swamp_trees"); - private static final RegistryKey> SWAMP_FUNGUS_CONFIGURED = TraverseConfiguredFeatures.createRegistryKey("swamp_fungus"); public static final RegistryKey SWAMP_FUNGUS = createRegistryKey("swamp_fungus"); /* Lush Vegetation */ @@ -43,90 +43,52 @@ public class TraversePlacedFeatures { public static final RegistryKey LUSH_FLOWERS = createRegistryKey("lush_flowers"); /* Woodlands */ - private static final RegistryKey WOODLANDS_SHRUB = createRegistryKey("woodlands_shrub"); - private static final RegistryKey WOODLANDS_FALLEN_LOG = createRegistryKey("woodlands_fallen_log"); - private static final RegistryKey> WOODLANDS_TREES_CONFIGURED = TraverseConfiguredFeatures.createRegistryKey("woodlands_trees"); + public static final RegistryKey WOODLANDS_SHRUB = createRegistryKey("woodlands_shrub"); + public static final RegistryKey WOODLANDS_FALLEN_LOG = createRegistryKey("woodlands_fallen_log"); public static final RegistryKey WOODLANDS_TREES = createRegistryKey("woodlands_trees"); - public static void populate(FabricDynamicRegistryProvider.Entries entries) { + public static void bootstrap(Registerable registerable) { + RegistryEntryLookup> configuredFeatures = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE); + /* Shrubs */ - entries.add(DESERT_EXTRA_CACTUS, placeFeature(entries, VegetationConfiguredFeatures.PATCH_CACTUS, RarityFilterPlacementModifier.of(13), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP)); - entries.add(DESERT_SHRUBS, placeFeature(entries, TraverseConfiguredFeatures.OAK_SHRUB, PlacedFeatures.createCountExtraModifier(1, 0.1f, 1), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BlockFilterPlacementModifier.of(BlockPredicate.matchingBlockTag(Direction.DOWN.getVector(), BlockTags.DIRT)))); + register(registerable, DESERT_EXTRA_CACTUS, VegetationConfiguredFeatures.PATCH_CACTUS, RarityFilterPlacementModifier.of(13), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of()); + register(registerable, DESERT_SHRUBS, TraverseConfiguredFeatures.OAK_SHRUB, VegetationPlacedFeatures.treeModifiersWithWouldSurvive(PlacedFeatures.createCountExtraModifier(1, 0.1f, 1), Blocks.OAK_SAPLING)); /* Autumnal Trees */ - entries.add(BROWN_AUTUMNAL_TREE, placeFeatureWithoutBiomeFilter(entries, TraverseConfiguredFeatures.BROWN_AUTUMNAL_TREE)); - entries.add(ORANGE_AUTUMNAL_TREE, placeFeatureWithoutBiomeFilter(entries, TraverseConfiguredFeatures.ORANGE_AUTUMNAL_TREE)); - entries.add(RED_AUTUMNAL_TREE, placeFeatureWithoutBiomeFilter(entries, TraverseConfiguredFeatures.RED_AUTUMNAL_TREE)); - entries.add(YELLOW_AUTUMNAL_TREE, placeFeatureWithoutBiomeFilter(entries, TraverseConfiguredFeatures.YELLOW_AUTUMNAL_TREE)); - entries.add(AUTUMNAL_TREES_CONFIGURED, TraverseConfiguredFeatures.configureFeature( - Feature.SIMPLE_RANDOM_SELECTOR, - new SimpleRandomFeatureConfig( - RegistryEntryList.of( - entries.ref(BROWN_AUTUMNAL_TREE), - entries.ref(ORANGE_AUTUMNAL_TREE), - entries.ref(RED_AUTUMNAL_TREE), - entries.ref(YELLOW_AUTUMNAL_TREE), - entries.ref(TreePlacedFeatures.OAK_CHECKED) - ) - ) - )); - entries.add(AUTUMNAL_TREES, placeFeature(entries, AUTUMNAL_TREES_CONFIGURED, PlacedFeatures.createCountExtraModifier(10, 0.1f, 1), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BlockFilterPlacementModifier.of(BlockPredicate.matchingBlockTag(Direction.DOWN.getVector(), BlockTags.DIRT)))); + register(registerable, BROWN_AUTUMNAL_TREE, TraverseConfiguredFeatures.BROWN_AUTUMNAL_TREE, PlacedFeatures.wouldSurvive(TraverseBlocks.BROWN_AUTUMNAL_SAPLING)); + register(registerable, ORANGE_AUTUMNAL_TREE, TraverseConfiguredFeatures.ORANGE_AUTUMNAL_TREE, PlacedFeatures.wouldSurvive(TraverseBlocks.ORANGE_AUTUMNAL_SAPLING)); + register(registerable, RED_AUTUMNAL_TREE, TraverseConfiguredFeatures.RED_AUTUMNAL_TREE, PlacedFeatures.wouldSurvive(TraverseBlocks.RED_AUTUMNAL_SAPLING)); + register(registerable, YELLOW_AUTUMNAL_TREE, TraverseConfiguredFeatures.YELLOW_AUTUMNAL_TREE, PlacedFeatures.wouldSurvive(TraverseBlocks.YELLOW_AUTUMNAL_SAPLING)); + register(registerable, AUTUMNAL_TREES, TraverseConfiguredFeatures.AUTUMNAL_TREES, VegetationPlacedFeatures.treeModifiers(PlacedFeatures.createCountExtraModifier(10, 0.1f, 1))); /* Fir Trees */ - entries.add(CONIFEROUS_TREES, placeFeature(entries, TraverseConfiguredFeatures.FIR_TREE, PlacedFeatures.createCountExtraModifier(7, 0.1f, 1), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BlockFilterPlacementModifier.of(BlockPredicate.matchingBlockTag(Direction.DOWN.getVector(), BlockTags.DIRT)))); + register(registerable, CONIFEROUS_TREES, TraverseConfiguredFeatures.FIR_TREE, VegetationPlacedFeatures.treeModifiersWithWouldSurvive(PlacedFeatures.createCountExtraModifier(7, 0.1f, 1), TraverseBlocks.FIR_SAPLING)); /* Swamp Trees */ - entries.add(LUSH_SWAMP_TREES, placeFeature(entries, TraverseConfiguredFeatures.TALL_SWAMP_TREE, PlacedFeatures.createCountExtraModifier(2, 0.1f, 1), SquarePlacementModifier.of(), PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP, SurfaceWaterDepthFilterPlacementModifier.of(3), BlockFilterPlacementModifier.of(BlockPredicate.matchingBlockTag(Direction.DOWN.getVector(), BlockTags.DIRT)))); - entries.add(SWAMP_FUNGUS_CONFIGURED, TraverseConfiguredFeatures.configureFeature( - Feature.RANDOM_BOOLEAN_SELECTOR, - new RandomBooleanFeatureConfig( - PlacedFeatures.createEntry(entries.ref(TreeConfiguredFeatures.HUGE_RED_MUSHROOM)), - PlacedFeatures.createEntry(entries.ref(TreeConfiguredFeatures.HUGE_BROWN_MUSHROOM)) - ) - )); - entries.add(SWAMP_FUNGUS, placeFeature(entries, SWAMP_FUNGUS_CONFIGURED, PlacedFeatures.createCountExtraModifier(0, 0.1f, 1), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BlockFilterPlacementModifier.of(BlockPredicate.matchingBlockTag(Direction.DOWN.getVector(), BlockTags.DIRT)))); + register(registerable, LUSH_SWAMP_TREES, TraverseConfiguredFeatures.TALL_SWAMP_TREE, PlacedFeatures.createCountExtraModifier(2, 0.1f, 1), SquarePlacementModifier.of(), SurfaceWaterDepthFilterPlacementModifier.of(3), PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP, BiomePlacementModifier.of(), BlockFilterPlacementModifier.of(BlockPredicate.wouldSurvive(Blocks.OAK_SAPLING.getDefaultState(), BlockPos.ORIGIN))); + register(registerable, SWAMP_FUNGUS, TraverseConfiguredFeatures.SWAMP_FUNGUS, PlacedFeatures.createCountExtraModifier(0, 0.1f, 1), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of()); /* Lush Vegetation */ - entries.add(FLATLANDS_GRASS, placeFeature(entries, TraverseConfiguredFeatures.FLATLANDS_GRASS, VegetationPlacedFeatures.modifiers(15))); - entries.add(FLATLANDS_TREES, placeFeature(entries, TreeConfiguredFeatures.OAK_BEES_005, PlacedFeatures.createCountExtraModifier(0, 0.2F, 1), BlockFilterPlacementModifier.of(BlockPredicate.matchingBlockTag(Direction.DOWN.getVector(), BlockTags.DIRT)))); - entries.add(LUSH_FLOWERS, placeFeature(entries, TraverseConfiguredFeatures.LUSH_FLOWERS, RarityFilterPlacementModifier.of(32), CountPlacementModifier.of(10), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BlockFilterPlacementModifier.of(BlockPredicate.matchingBlockTag(Direction.DOWN.getVector(), BlockTags.DIRT)))); + register(registerable, FLATLANDS_GRASS, TraverseConfiguredFeatures.FLATLANDS_GRASS, VegetationPlacedFeatures.modifiers(15)); + register(registerable, FLATLANDS_TREES, TreeConfiguredFeatures.OAK_BEES_005, PlacedFeatures.createCountExtraModifier(0, 0.2F, 1), SquarePlacementModifier.of(), SurfaceWaterDepthFilterPlacementModifier.of(0), PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP, BlockFilterPlacementModifier.of(BlockPredicate.wouldSurvive(Blocks.OAK_SAPLING.getDefaultState(), BlockPos.ORIGIN)), BiomePlacementModifier.of()); + register(registerable, LUSH_FLOWERS, TraverseConfiguredFeatures.LUSH_FLOWERS, RarityFilterPlacementModifier.of(32), CountPlacementModifier.of(10), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BlockFilterPlacementModifier.of(BlockPredicate.matchingBlockTag(Direction.DOWN.getVector(), BlockTags.DIRT)), BiomePlacementModifier.of()); /* Woodlands */ - entries.add(WOODLANDS_SHRUB, placeFeatureWithoutBiomeFilter(entries, TraverseConfiguredFeatures.OAK_SHRUB)); - entries.add(WOODLANDS_FALLEN_LOG, placeFeatureWithoutBiomeFilter(entries, TraverseConfiguredFeatures.FALLEN_OAK_TREE)); - entries.add(WOODLANDS_TREES_CONFIGURED, TraverseConfiguredFeatures.configureFeature( - Feature.RANDOM_SELECTOR, - new RandomFeatureConfig( - ImmutableList.of( - new RandomFeatureEntry(entries.ref(WOODLANDS_SHRUB), 0.2F), - new RandomFeatureEntry(entries.ref(WOODLANDS_FALLEN_LOG), 0.3F) - ), entries.ref(TreePlacedFeatures.OAK_CHECKED) - ) - )); - entries.add(WOODLANDS_TREES, placeFeature(entries, WOODLANDS_TREES_CONFIGURED, CountPlacementModifier.of(7), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BlockFilterPlacementModifier.of(BlockPredicate.matchingBlockTag(Direction.DOWN.getVector(), BlockTags.DIRT)))); + register(registerable, WOODLANDS_SHRUB, TraverseConfiguredFeatures.OAK_SHRUB, PlacedFeatures.wouldSurvive(Blocks.OAK_SAPLING)); + register(registerable, WOODLANDS_FALLEN_LOG, TraverseConfiguredFeatures.FALLEN_OAK_TREE, PlacedFeatures.wouldSurvive(Blocks.OAK_SAPLING)); + register(registerable, WOODLANDS_TREES, TraverseConfiguredFeatures.WOODLANDS_TREES, CountPlacementModifier.of(7), SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of()); } public static RegistryKey createRegistryKey(String name) { return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier.of(Traverse.MOD_ID, name)); } - private static PlacedFeature placeFeature(FabricDynamicRegistryProvider.Entries entries, RegistryKey> feature, PlacementModifier... placementModifiers) { + private static void register(Registerable registerable, RegistryKey key, RegistryKey> feature, PlacementModifier... placementModifiers) { List list = new ArrayList<>(List.of(placementModifiers)); - list.add(BiomePlacementModifier.of()); - return placeFeature(entries, feature, list); - - } - - private static PlacedFeature placeFeatureWithoutBiomeFilter(FabricDynamicRegistryProvider.Entries entries, RegistryKey> feature, PlacementModifier... placementModifiers) { - List list = new ArrayList<>(List.of(placementModifiers)); - return placeFeature(entries, feature, list); - } - - private static PlacedFeature placeFeature(FabricDynamicRegistryProvider.Entries entries, RegistryKey> feature, List list) { - return new PlacedFeature(entries.ref(feature), list); + register(registerable, key, feature, list); } - public static void register() { - // This just creates the registry keys. Placed Features are requested and consumed by datagen now. + private static void register(Registerable registerable, RegistryKey key, RegistryKey> feature, List list) { + PlacedFeatures.register(registerable, key, registerable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE).getOrThrow(feature), list); } } diff --git a/gradle.properties b/gradle.properties index ceedf88..eba408f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,21 +4,21 @@ fabric.loom.multiProjectOptimisation=true maven_group=com.terraformersmc archive_name=traverse -minecraft_version=23w51b -yarn_mappings=23w51b+build.4 -loader_version=0.15.3 -fabric_version=0.93.1+1.20.5 -terraform_biome_remapper_api_version=9.0.0 -terraform_config_api_version=9.0.0 -terraform_surfaces_api_version=9.0.0 -terraform_tree_api_version=9.0.0 -terraform_wood_api_version=9.0.0 +minecraft_version=24w07a +yarn_mappings=24w07a+build.4 +loader_version=0.15.7 +fabric_version=0.96.3+1.20.5 +terraform_biome_remapper_api_version=10.0.0-alpha.6 +terraform_config_api_version=10.0.0-alpha.6 +terraform_surfaces_api_version=10.0.0-alpha.6 +terraform_tree_api_version=10.0.0-alpha.6 +terraform_wood_api_version=10.0.0-alpha.6 # Biolith for worldgen module and testing -biolith_version=1.2.0-beta.1 +biolith_version=1.3.0-alpha.1 # TerraBlender for worldgen module and testing -terrablender_version=1.20.4-3.3.0.5 +terrablender_version=1.20.4-3.3.0.12 # Project Metadata project_name=Traverse @@ -38,7 +38,7 @@ curseforge_optional_dependencies= # Modrinth Metadata modrinth_slug=traverse modrinth_id=kXygSBVI -modrinth_game_versions=23w51b +modrinth_game_versions=24w07a modrinth_mod_loaders=fabric, quilt modrinth_required_dependencies=fabric-api #modrinth_embedded_dependencies=biolith diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db9a6b8..a595206 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fd0583a..69a32c5 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -14,7 +14,7 @@ "depends": { "fabricloader": ">=0.15", "fabric-api": ">=0.77.0", - "minecraft": ">=1.20.4 <1.21", + "minecraft": ">1.20.4 <1.21", "java": ">=17" }, "authors": [ diff --git a/worldgen/build.gradle b/worldgen/build.gradle index 7633c76..5f0ac74 100644 --- a/worldgen/build.gradle +++ b/worldgen/build.gradle @@ -7,7 +7,7 @@ loom { dependencies { // Biolith and TerraBlender for the worldgen API modules modImplementation "com.terraformersmc:biolith-fabric:${biolith_version}" - modCompileOnlyApi "com.github.glitchfiend:TerraBlender-fabric:${terrablender_version}" + modCompileOnly "com.github.glitchfiend:TerraBlender-fabric:${terrablender_version}" implementation project(path: ':traverse-common') }