diff --git a/.github/workflows/check_build.yml b/.github/workflows/check_build.yml index 3668b106..b1ed3773 100644 --- a/.github/workflows/check_build.yml +++ b/.github/workflows/check_build.yml @@ -11,15 +11,14 @@ on: jobs: build: - if: github.event.pull_request.draft == false + name: Build the project (using Java ${{ matrix.java }} on ${{ matrix.os }}) + runs-on: ${{ matrix.os }} strategy: matrix: java: [ 21 ] os: [ ubuntu-latest ] - name: Build the project (Java ${{ matrix.java }}, on ${{ matrix.os }})) - runs-on: ${{ matrix.os }} + if: github.event.pull_request.draft == false steps: - - name: Checkout repository uses: actions/checkout@v2 @@ -35,6 +34,9 @@ jobs: if: ${{ runner.os != 'Windows' }} run: chmod +x ./gradlew + - name: Run Spotless check + run: ./gradlew spotlessCheck + - name: Generate data files run: ./gradlew runDatagen diff --git a/HEADER b/HEADER new file mode 100644 index 00000000..1dec8e08 --- /dev/null +++ b/HEADER @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ diff --git a/build.gradle b/build.gradle index 1bb1acce..3c3ca61b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,92 +1,118 @@ plugins { - id 'fabric-loom' version "${loom_version}" - id 'org.moddedmc.wiki.toolkit' version '0.2.7' + id 'fabric-loom' version "${loom_version}" + id 'org.moddedmc.wiki.toolkit' version '0.2.7' + id "com.diffplug.spotless" version "8.0.0" } group = "com.github.hugman" base { - archivesName = project.mod_id + archivesName = project.mod_id } repositories { - maven { url 'https://maven.terraformersmc.com/' } // Required for Biolith + maven { url 'https://maven.terraformersmc.com/' } // Required for Biolith } dependencies { - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modApi include ("com.terraformersmc:biolith-fabric:${biolith_version}") { - exclude(group: "net.fabricmc.fabric-api") - } + modApi include("com.terraformersmc:biolith-fabric:${biolith_version}") { + exclude(group: "net.fabricmc.fabric-api") + } - compileOnly "com.google.code.findbugs:jsr305:3.0.2" + compileOnly "com.google.code.findbugs:jsr305:3.0.2" - // Version list: https://maven.sinytra.org/org/sinytra/item-asset-export-fabric - //modRuntimeOnly "org.sinytra:item-asset-export-fabric:1.1.0+1.21.4" FIXME not updated for 1.21.5 yet + // Version list: https://maven.sinytra.org/org/sinytra/item-asset-export-fabric + //modRuntimeOnly "org.sinytra:item-asset-export-fabric:1.1.0+1.21.4" FIXME not updated for 1.21.5 yet } loom { - accessWidenerPath = file("src/main/resources/promenade.accesswidener") + accessWidenerPath = file("src/main/resources/promenade.accesswidener") - splitEnvironmentSourceSets() + splitEnvironmentSourceSets() - mods { - "promenade" { - sourceSet sourceSets.main - sourceSet sourceSets.client - } - } + mods { + "promenade" { + sourceSet sourceSets.main + sourceSet sourceSets.client + } + } } fabricApi { - configureDataGeneration() { - modId = "promenade-datagen" - createSourceSet = true - client = true - } + configureDataGeneration() { + modId = "promenade-datagen" + createSourceSet = true + client = true + } } processResources { - inputs.property "version", project.version + inputs.property "version", project.version - filesMatching("fabric.mod.json") { - expand "version": project.version - } + filesMatching("fabric.mod.json") { + expand "version": project.version + } } tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - it.options.release = 21 + it.options.encoding = "UTF-8" + it.options.release = 21 } java { - withSourcesJar() + withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}" } - } + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}" } + } } // for JitPack configurations.configureEach { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } wiki { - docs { - promenade { - root = file('docs') - exportedAssetNamespaces = ['promenade'] - } - } + docs { + promenade { + root = file('docs') + exportedAssetNamespaces = ['promenade'] + } + } +} + +// Spotless - Java CodeStyle +spotless { + lineEndings = com.diffplug.spotless.LineEnding.UNIX + + java { + licenseHeaderFile(rootProject.file("HEADER")) + removeUnusedImports() + importOrder('java', 'javax', '', 'net.minecraft', 'net.fabricmc', 'fr.hugman') + leadingSpacesToTabs() + trimTrailingWhitespace() + } + + groovyGradle { + target 'src/**/*.gradle', '*.gradle', 'gradle/*.gradle' + greclipse() + } + + // Sort the en_us translation files + json { + target 'src/**/lang/en_us.json' + targetExclude 'src/**/generated/**' + gson().indentWithSpaces(2) + } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/PromenadeClient.java b/src/client/java/fr/hugman/promenade/client/PromenadeClient.java index 7b082be4..756fd7e0 100644 --- a/src/client/java/fr/hugman/promenade/client/PromenadeClient.java +++ b/src/client/java/fr/hugman/promenade/client/PromenadeClient.java @@ -1,19 +1,31 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client; +import net.fabricmc.api.ClientModInitializer; + import fr.hugman.promenade.client.color.PromenadeBlockColors; import fr.hugman.promenade.client.particle.PromenadeParticleFactories; import fr.hugman.promenade.client.render.block.PromenadeBlockRenderLayers; import fr.hugman.promenade.client.render.entity.PromenadeEntityRenderers; import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; -import net.fabricmc.api.ClientModInitializer; public class PromenadeClient implements ClientModInitializer { - @Override - public void onInitializeClient() { - PromenadeEntityModelLayers.register(); - PromenadeBlockRenderLayers.register(); - PromenadeBlockColors.register(); - PromenadeEntityRenderers.register(); - PromenadeParticleFactories.register(); - } + @Override + public void onInitializeClient() { + PromenadeEntityModelLayers.register(); + PromenadeBlockRenderLayers.register(); + PromenadeBlockColors.register(); + PromenadeEntityRenderers.register(); + PromenadeParticleFactories.register(); + } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/color/PromenadeBlockColors.java b/src/client/java/fr/hugman/promenade/client/color/PromenadeBlockColors.java index be6ba9ea..f44018cc 100644 --- a/src/client/java/fr/hugman/promenade/client/color/PromenadeBlockColors.java +++ b/src/client/java/fr/hugman/promenade/client/color/PromenadeBlockColors.java @@ -1,24 +1,37 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.color; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.world.biome.PromenadeFoliageColors; +import net.minecraft.client.color.world.BiomeColors; +import net.minecraft.world.biome.FoliageColors; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; -import net.minecraft.client.color.world.BiomeColors; -import net.minecraft.world.biome.FoliageColors; + +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.world.biome.PromenadeFoliageColors; @Environment(EnvType.CLIENT) public final class PromenadeBlockColors { - public static void register() { - ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> PromenadeFoliageColors.PALM, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_HANGING_LEAVES, PromenadeBlocks.PALM_LEAF_PILE); - ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> pos != null && world != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.DEFAULT, - PromenadeBlocks.SNOWY_OAK_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES, - PromenadeBlocks.OAK_LEAF_PILE, PromenadeBlocks.JUNGLE_LEAF_PILE, PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeBlocks.DARK_OAK_LEAF_PILE, PromenadeBlocks.MANGROVE_LEAF_PILE, - PromenadeBlocks.SAP_MAPLE_LEAVES, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_OAK_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES - ); - ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> FoliageColors.SPRUCE, PromenadeBlocks.SPRUCE_LEAF_PILE, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); - ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> FoliageColors.BIRCH, PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeBlocks.SNOWY_BIRCH_LEAVES); - } + public static void register() { + ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> PromenadeFoliageColors.PALM, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_HANGING_LEAVES, PromenadeBlocks.PALM_LEAF_PILE); + ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> pos != null && world != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.DEFAULT, + PromenadeBlocks.SNOWY_OAK_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES, + PromenadeBlocks.OAK_LEAF_PILE, PromenadeBlocks.JUNGLE_LEAF_PILE, PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeBlocks.DARK_OAK_LEAF_PILE, PromenadeBlocks.MANGROVE_LEAF_PILE, + PromenadeBlocks.SAP_MAPLE_LEAVES, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, + PromenadeBlocks.SNOWY_OAK_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES + ); + ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> FoliageColors.SPRUCE, PromenadeBlocks.SPRUCE_LEAF_PILE, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); + ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> FoliageColors.BIRCH, PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeBlocks.SNOWY_BIRCH_LEAVES); + } } diff --git a/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticleFactories.java b/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticleFactories.java index 885a281b..63b1cd30 100644 --- a/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticleFactories.java +++ b/src/client/java/fr/hugman/promenade/client/particle/PromenadeLeavesParticleFactories.java @@ -1,7 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.particle; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import org.jetbrains.annotations.Nullable; + import net.minecraft.client.particle.LeavesParticle; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; @@ -9,20 +20,22 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.particle.SimpleParticleType; import net.minecraft.util.math.random.Random; -import org.jetbrains.annotations.Nullable; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; public class PromenadeLeavesParticleFactories { - @Environment(EnvType.CLIENT) - public static class MapleLeavesFactory implements ParticleFactory { - private final SpriteProvider spriteProvider; + @Environment(EnvType.CLIENT) + public static class MapleLeavesFactory implements ParticleFactory { + private final SpriteProvider spriteProvider; - public MapleLeavesFactory(SpriteProvider spriteProvider) { - this.spriteProvider = spriteProvider; - } + public MapleLeavesFactory(SpriteProvider spriteProvider) { + this.spriteProvider = spriteProvider; + } - @Override - public @Nullable Particle createParticle(SimpleParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, Random random) { - return new LeavesParticle(world, x, y, z, this.spriteProvider.getSprite(random), 0.07F, 5.0F, true, false, 1.5F, 0.021F); - } - } + @Override + public @Nullable Particle createParticle(SimpleParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, Random random) { + return new LeavesParticle(world, x, y, z, this.spriteProvider.getSprite(random), 0.07F, 5.0F, true, false, 1.5F, 0.021F); + } + } } diff --git a/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticleFactories.java b/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticleFactories.java index b85c895b..0dd3f3a1 100644 --- a/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticleFactories.java +++ b/src/client/java/fr/hugman/promenade/client/particle/PromenadeParticleFactories.java @@ -1,21 +1,34 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.particle; -import fr.hugman.promenade.particle.PromenadeParticleTypes; +import net.minecraft.client.particle.LeavesParticle; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; -import net.minecraft.client.particle.LeavesParticle; + +import fr.hugman.promenade.particle.PromenadeParticleTypes; @Environment(EnvType.CLIENT) public class PromenadeParticleFactories { - public static void register() { - var instance = ParticleFactoryRegistry.getInstance(); + public static void register() { + var instance = ParticleFactoryRegistry.getInstance(); - instance.register(PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM, LeavesParticle.CherryLeavesFactory::new); - instance.register(PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM, LeavesParticle.CherryLeavesFactory::new); + instance.register(PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM, LeavesParticle.CherryLeavesFactory::new); + instance.register(PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM, LeavesParticle.CherryLeavesFactory::new); - instance.register(PromenadeParticleTypes.MIKADO_MAPLE_LEAF, PromenadeLeavesParticleFactories.MapleLeavesFactory::new); - instance.register(PromenadeParticleTypes.FULVOUS_MAPLE_LEAF, PromenadeLeavesParticleFactories.MapleLeavesFactory::new); - instance.register(PromenadeParticleTypes.VERMILION_MAPLE_LEAF, PromenadeLeavesParticleFactories.MapleLeavesFactory::new); - } + instance.register(PromenadeParticleTypes.MIKADO_MAPLE_LEAF, PromenadeLeavesParticleFactories.MapleLeavesFactory::new); + instance.register(PromenadeParticleTypes.FULVOUS_MAPLE_LEAF, PromenadeLeavesParticleFactories.MapleLeavesFactory::new); + instance.register(PromenadeParticleTypes.VERMILION_MAPLE_LEAF, PromenadeLeavesParticleFactories.MapleLeavesFactory::new); + } } diff --git a/src/client/java/fr/hugman/promenade/client/render/block/PromenadeBlockRenderLayers.java b/src/client/java/fr/hugman/promenade/client/render/block/PromenadeBlockRenderLayers.java index 34ea023f..1ae049f4 100644 --- a/src/client/java/fr/hugman/promenade/client/render/block/PromenadeBlockRenderLayers.java +++ b/src/client/java/fr/hugman/promenade/client/render/block/PromenadeBlockRenderLayers.java @@ -1,109 +1,122 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.block; -import fr.hugman.promenade.block.PromenadeBlocks; +import net.minecraft.client.render.BlockRenderLayer; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.rendering.v1.BlockRenderLayerMap; -import net.minecraft.client.render.BlockRenderLayer; + +import fr.hugman.promenade.block.PromenadeBlocks; @Environment(EnvType.CLIENT) public final class PromenadeBlockRenderLayers { - public static void register() { + public static void register() { - BlockRenderLayerMap.putBlocks(BlockRenderLayer.CUTOUT_MIPPED, - PromenadeBlocks.OAK_LEAF_PILE, - PromenadeBlocks.SPRUCE_LEAF_PILE, - PromenadeBlocks.BIRCH_LEAF_PILE, - PromenadeBlocks.JUNGLE_LEAF_PILE, - PromenadeBlocks.ACACIA_LEAF_PILE, - PromenadeBlocks.CHERRY_LEAF_PILE, - PromenadeBlocks.DARK_OAK_LEAF_PILE, - PromenadeBlocks.MANGROVE_LEAF_PILE, - PromenadeBlocks.PALE_OAK_LEAF_PILE, - PromenadeBlocks.AZALEA_LEAF_PILE, - PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, - PromenadeBlocks.DANDELION_PILE, - PromenadeBlocks.POPPY_PILE, - PromenadeBlocks.BLUE_ORCHID_PILE, - PromenadeBlocks.ALLIUM_PILE, - PromenadeBlocks.AZURE_BLUET_PILE, - PromenadeBlocks.RED_TULIP_PILE, - PromenadeBlocks.ORANGE_TULIP_PILE, - PromenadeBlocks.WHITE_TULIP_PILE, - PromenadeBlocks.PINK_TULIP_PILE, - PromenadeBlocks.OXEYE_DAISY_PILE, - PromenadeBlocks.CORNFLOWER_PILE, - PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, - PromenadeBlocks.WITHER_ROSE_PILE, - PromenadeBlocks.SNOWY_OAK_LEAVES, - PromenadeBlocks.SNOWY_SPRUCE_LEAVES, - PromenadeBlocks.SNOWY_BIRCH_LEAVES, - PromenadeBlocks.SNOWY_JUNGLE_LEAVES, - PromenadeBlocks.SNOWY_ACACIA_LEAVES, - PromenadeBlocks.SNOWY_CHERRY_LEAVES, - PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, - PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, - PromenadeBlocks.SNOWY_MANGROVE_LEAVES, - PromenadeBlocks.SNOWY_AZALEA_LEAVES, - PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, - PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, - PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, - PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, - PromenadeBlocks.BLUSH_SAKURA_SAPLING, - PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING, - PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, - PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, - PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, - PromenadeBlocks.COTTON_SAKURA_SAPLING, - PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING, - PromenadeBlocks.SAP_MAPLE_SAPLING, - PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING, - PromenadeBlocks.SAP_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, - PromenadeBlocks.SAP_MAPLE_LEAF_PILE, - PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, - PromenadeBlocks.VERMILION_MAPLE_SAPLING, - PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING, - PromenadeBlocks.VERMILION_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, - PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, - PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, - PromenadeBlocks.FULVOUS_MAPLE_SAPLING, - PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING, - PromenadeBlocks.FULVOUS_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, - PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, - PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, - PromenadeBlocks.MIKADO_MAPLE_SAPLING, - PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING, - PromenadeBlocks.MIKADO_MAPLE_LEAVES, - PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, - PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, - PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, - PromenadeBlocks.PALM_LEAVES, - PromenadeBlocks.SNOWY_PALM_LEAVES, - PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS, - PromenadeBlocks.DARK_AMARANTH_FUNGUS, - PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS - ); + BlockRenderLayerMap.putBlocks(BlockRenderLayer.CUTOUT_MIPPED, + PromenadeBlocks.OAK_LEAF_PILE, + PromenadeBlocks.SPRUCE_LEAF_PILE, + PromenadeBlocks.BIRCH_LEAF_PILE, + PromenadeBlocks.JUNGLE_LEAF_PILE, + PromenadeBlocks.ACACIA_LEAF_PILE, + PromenadeBlocks.CHERRY_LEAF_PILE, + PromenadeBlocks.DARK_OAK_LEAF_PILE, + PromenadeBlocks.MANGROVE_LEAF_PILE, + PromenadeBlocks.PALE_OAK_LEAF_PILE, + PromenadeBlocks.AZALEA_LEAF_PILE, + PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, + PromenadeBlocks.DANDELION_PILE, + PromenadeBlocks.POPPY_PILE, + PromenadeBlocks.BLUE_ORCHID_PILE, + PromenadeBlocks.ALLIUM_PILE, + PromenadeBlocks.AZURE_BLUET_PILE, + PromenadeBlocks.RED_TULIP_PILE, + PromenadeBlocks.ORANGE_TULIP_PILE, + PromenadeBlocks.WHITE_TULIP_PILE, + PromenadeBlocks.PINK_TULIP_PILE, + PromenadeBlocks.OXEYE_DAISY_PILE, + PromenadeBlocks.CORNFLOWER_PILE, + PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, + PromenadeBlocks.WITHER_ROSE_PILE, + PromenadeBlocks.SNOWY_OAK_LEAVES, + PromenadeBlocks.SNOWY_SPRUCE_LEAVES, + PromenadeBlocks.SNOWY_BIRCH_LEAVES, + PromenadeBlocks.SNOWY_JUNGLE_LEAVES, + PromenadeBlocks.SNOWY_ACACIA_LEAVES, + PromenadeBlocks.SNOWY_CHERRY_LEAVES, + PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, + PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, + PromenadeBlocks.SNOWY_MANGROVE_LEAVES, + PromenadeBlocks.SNOWY_AZALEA_LEAVES, + PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, + PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, + PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, + PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, + PromenadeBlocks.BLUSH_SAKURA_SAPLING, + PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING, + PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, + PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, + PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, + PromenadeBlocks.COTTON_SAKURA_SAPLING, + PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING, + PromenadeBlocks.SAP_MAPLE_SAPLING, + PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING, + PromenadeBlocks.SAP_MAPLE_LEAVES, + PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, + PromenadeBlocks.SAP_MAPLE_LEAF_PILE, + PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, + PromenadeBlocks.VERMILION_MAPLE_SAPLING, + PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING, + PromenadeBlocks.VERMILION_MAPLE_LEAVES, + PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, + PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, + PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, + PromenadeBlocks.FULVOUS_MAPLE_SAPLING, + PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING, + PromenadeBlocks.FULVOUS_MAPLE_LEAVES, + PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, + PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, + PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, + PromenadeBlocks.MIKADO_MAPLE_SAPLING, + PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING, + PromenadeBlocks.MIKADO_MAPLE_LEAVES, + PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, + PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, + PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, + PromenadeBlocks.PALM_LEAVES, + PromenadeBlocks.SNOWY_PALM_LEAVES, + PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS, + PromenadeBlocks.DARK_AMARANTH_FUNGUS, + PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS + ); - BlockRenderLayerMap.putBlocks(BlockRenderLayer.CUTOUT, - PromenadeBlocks.SAKURA_DOOR, - PromenadeBlocks.SAKURA_TRAPDOOR, - PromenadeBlocks.MAPLE_DOOR, - PromenadeBlocks.MAPLE_TRAPDOOR, - PromenadeBlocks.PALM_DOOR, - PromenadeBlocks.PALM_TRAPDOOR, - PromenadeBlocks.PALM_SAPLING, - PromenadeBlocks.POTTED_PALM_SAPLING, - PromenadeBlocks.PALM_HANGING_LEAVES, - PromenadeBlocks.PALM_LEAF_PILE, - PromenadeBlocks.DARK_AMARANTH_DOOR, - PromenadeBlocks.DARK_AMARANTH_TRAPDOOR, - PromenadeBlocks.DARK_AMARANTH_ROOTS, - PromenadeBlocks.COILED_VINES, - PromenadeBlocks.COILED_VINES_PLANT, - PromenadeBlocks.BLUEBERRY_BUSH - ); - } + BlockRenderLayerMap.putBlocks(BlockRenderLayer.CUTOUT, + PromenadeBlocks.SAKURA_DOOR, + PromenadeBlocks.SAKURA_TRAPDOOR, + PromenadeBlocks.MAPLE_DOOR, + PromenadeBlocks.MAPLE_TRAPDOOR, + PromenadeBlocks.PALM_DOOR, + PromenadeBlocks.PALM_TRAPDOOR, + PromenadeBlocks.PALM_SAPLING, + PromenadeBlocks.POTTED_PALM_SAPLING, + PromenadeBlocks.PALM_HANGING_LEAVES, + PromenadeBlocks.PALM_LEAF_PILE, + PromenadeBlocks.DARK_AMARANTH_DOOR, + PromenadeBlocks.DARK_AMARANTH_TRAPDOOR, + PromenadeBlocks.DARK_AMARANTH_ROOTS, + PromenadeBlocks.COILED_VINES, + PromenadeBlocks.COILED_VINES_PLANT, + PromenadeBlocks.BLUEBERRY_BUSH + ); + } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/CapybaraEntityRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/CapybaraEntityRenderer.java index ab2c33a9..b78ff6f7 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/CapybaraEntityRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/CapybaraEntityRenderer.java @@ -1,56 +1,69 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity; -import fr.hugman.promenade.client.render.entity.model.CapybaraEntityModel; -import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; -import fr.hugman.promenade.client.render.entity.state.CapybaraEntityRenderState; -import fr.hugman.promenade.entity.CapybaraEntity; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.render.entity.AgeableMobEntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.texture.MissingSprite; import net.minecraft.util.Identifier; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import fr.hugman.promenade.client.render.entity.model.CapybaraEntityModel; +import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; +import fr.hugman.promenade.client.render.entity.state.CapybaraEntityRenderState; +import fr.hugman.promenade.entity.CapybaraEntity; + @Environment(EnvType.CLIENT) public class CapybaraEntityRenderer extends AgeableMobEntityRenderer { - public CapybaraEntityRenderer(EntityRendererFactory.Context context) { - super( - context, - new CapybaraEntityModel(context.getPart(PromenadeEntityModelLayers.CAPYBARA)), - new CapybaraEntityModel(context.getPart(PromenadeEntityModelLayers.CAPYBARA_BABY)), - 0.5f - ); - } - - @Override - public CapybaraEntityRenderState createRenderState() { - return new CapybaraEntityRenderState(); - } - - @Override - public Identifier getTexture(CapybaraEntityRenderState state) { - if (state.variant == null) { - return MissingSprite.getMissingSpriteId(); - } - if (state.closedEyes) { - return state.variant.closedEyesTexture().texturePath(); - } - return state.largeEyes ? state.variant.largeEyesTexture().texturePath() : state.variant.smallEyesTexture().texturePath(); - } - - @Override - public void updateRenderState(E capybara, CapybaraEntityRenderState state, float f) { - super.updateRenderState(capybara, state, f); - state.earWiggleAnimState.copyFrom(capybara.earWiggleAnimState); - state.fallToSleepAnimState.copyFrom(capybara.fallToSleepAnimState); - state.sleepingAnimState.copyFrom(capybara.sleepingAnimState); - state.wakeUpAnimState.copyFrom(capybara.wakeUpAnimState); - state.fartAnimState.copyFrom(capybara.fartAnimState); - - state.variant = capybara.getVariant().value(); - state.closedEyes = capybara.hasClosedEyes(); - state.largeEyes = capybara.hasLargeEyes(); - state.earWiggleSpeed = capybara.getEarWiggleSpeed(); - state.canAngleHead = capybara.canAngleHead(); - } + public CapybaraEntityRenderer(EntityRendererFactory.Context context) { + super( + context, + new CapybaraEntityModel(context.getPart(PromenadeEntityModelLayers.CAPYBARA)), + new CapybaraEntityModel(context.getPart(PromenadeEntityModelLayers.CAPYBARA_BABY)), + 0.5f + ); + } + + @Override + public CapybaraEntityRenderState createRenderState() { + return new CapybaraEntityRenderState(); + } + + @Override + public Identifier getTexture(CapybaraEntityRenderState state) { + if (state.variant == null) { + return MissingSprite.getMissingSpriteId(); + } + if (state.closedEyes) { + return state.variant.closedEyesTexture().texturePath(); + } + return state.largeEyes ? state.variant.largeEyesTexture().texturePath() : state.variant.smallEyesTexture().texturePath(); + } + + @Override + public void updateRenderState(E capybara, CapybaraEntityRenderState state, float f) { + super.updateRenderState(capybara, state, f); + state.earWiggleAnimState.copyFrom(capybara.earWiggleAnimState); + state.fallToSleepAnimState.copyFrom(capybara.fallToSleepAnimState); + state.sleepingAnimState.copyFrom(capybara.sleepingAnimState); + state.wakeUpAnimState.copyFrom(capybara.wakeUpAnimState); + state.fartAnimState.copyFrom(capybara.fartAnimState); + + state.variant = capybara.getVariant().value(); + state.closedEyes = capybara.hasClosedEyes(); + state.largeEyes = capybara.hasLargeEyes(); + state.earWiggleSpeed = capybara.getEarWiggleSpeed(); + state.canAngleHead = capybara.canAngleHead(); + } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/CreeperOverlayRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/CreeperOverlayRenderer.java index 11fd8fb4..f6d24757 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/CreeperOverlayRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/CreeperOverlayRenderer.java @@ -1,7 +1,16 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.render.command.OrderedRenderCommandQueue; import net.minecraft.client.render.entity.feature.FeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRendererContext; @@ -13,20 +22,22 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + @Environment(EnvType.CLIENT) public class CreeperOverlayRenderer> extends FeatureRenderer { - private final CreeperEntityModel model; - private final Identifier texture; + private final CreeperEntityModel model; + private final Identifier texture; - public CreeperOverlayRenderer(FeatureRendererContext context, LoadedEntityModels loader, EntityModelLayer layer, Identifier texture) { - super(context); - this.model = new CreeperEntityModel(loader.getModelPart(layer)); - this.texture = texture; - } + public CreeperOverlayRenderer(FeatureRendererContext context, LoadedEntityModels loader, EntityModelLayer layer, Identifier texture) { + super(context); + this.model = new CreeperEntityModel(loader.getModelPart(layer)); + this.texture = texture; + } - @Override - public void render(MatrixStack matrices, OrderedRenderCommandQueue queue, int light, S state, float limbAngle, float limbDistance) { - render(this.model, this.texture, matrices, queue, light, state, -1, 1); - } + @Override + public void render(MatrixStack matrices, OrderedRenderCommandQueue queue, int light, S state, float limbAngle, float limbDistance) { + render(this.model, this.texture, matrices, queue, light, state, - 1, 1); + } } - diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/DuckEntityRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/DuckEntityRenderer.java index a47057dd..d4e61286 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/DuckEntityRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/DuckEntityRenderer.java @@ -1,48 +1,61 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity; -import fr.hugman.promenade.client.render.entity.model.DuckEntityModel; -import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; -import fr.hugman.promenade.client.render.entity.state.DuckEntityRenderState; -import fr.hugman.promenade.entity.DuckEntity; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.render.entity.AgeableMobEntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.texture.MissingSprite; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import fr.hugman.promenade.client.render.entity.model.DuckEntityModel; +import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; +import fr.hugman.promenade.client.render.entity.state.DuckEntityRenderState; +import fr.hugman.promenade.entity.DuckEntity; + @Environment(EnvType.CLIENT) public class DuckEntityRenderer extends AgeableMobEntityRenderer { - public DuckEntityRenderer(EntityRendererFactory.Context context) { - super( - context, - new DuckEntityModel(context.getPart(PromenadeEntityModelLayers.DUCK)), - new DuckEntityModel(context.getPart(PromenadeEntityModelLayers.DUCK_BABY)), - 0.3F - ); - } + public DuckEntityRenderer(EntityRendererFactory.Context context) { + super( + context, + new DuckEntityModel(context.getPart(PromenadeEntityModelLayers.DUCK)), + new DuckEntityModel(context.getPart(PromenadeEntityModelLayers.DUCK_BABY)), + 0.3F + ); + } - @Override - public DuckEntityRenderState createRenderState() { - return new DuckEntityRenderState(); - } + @Override + public DuckEntityRenderState createRenderState() { + return new DuckEntityRenderState(); + } - @Override - public Identifier getTexture(DuckEntityRenderState state) { - if (state.variant == null) { - return MissingSprite.getMissingSpriteId(); - } - if (state.baby) { - return state.variant.babyTexture().texturePath(); - } - return state.variant.texture().texturePath(); - } + @Override + public Identifier getTexture(DuckEntityRenderState state) { + if (state.variant == null) { + return MissingSprite.getMissingSpriteId(); + } + if (state.baby) { + return state.variant.babyTexture().texturePath(); + } + return state.variant.texture().texturePath(); + } - public void updateRenderState(DuckEntity duck, DuckEntityRenderState state, float f) { - super.updateRenderState(duck, state, f); - state.flapProgress = MathHelper.lerp(f, duck.prevFlapProgress, duck.flapProgress); - state.maxWingDeviation = MathHelper.lerp(f, duck.prevMaxWingDeviation, duck.maxWingDeviation); - state.variant = duck.getVariant().value(); - } + public void updateRenderState(DuckEntity duck, DuckEntityRenderState state, float f) { + super.updateRenderState(duck, state, f); + state.flapProgress = MathHelper.lerp(f, duck.prevFlapProgress, duck.flapProgress); + state.maxWingDeviation = MathHelper.lerp(f, duck.prevMaxWingDeviation, duck.maxWingDeviation); + state.variant = duck.getVariant().value(); + } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/LushCreeperRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/LushCreeperRenderer.java index 888e877e..bd776c27 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/LushCreeperRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/LushCreeperRenderer.java @@ -1,10 +1,16 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; -import fr.hugman.promenade.entity.LushCreeperEntity; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.entity.MobEntityRenderer; import net.minecraft.client.render.entity.model.CreeperEntityModel; @@ -13,47 +19,54 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; +import fr.hugman.promenade.entity.LushCreeperEntity; + @Environment(EnvType.CLIENT) public class LushCreeperRenderer extends MobEntityRenderer { - private static final Identifier TEXTURE = Promenade.id("textures/entity/lush_creeper/base.png"); - private static final Identifier OVERLAY_TEXTURE = Promenade.id("textures/entity/lush_creeper/overlay.png"); - - public LushCreeperRenderer(EntityRendererFactory.Context context) { - super(context, new CreeperEntityModel(context.getPart(PromenadeEntityModelLayers.LUSH_CREEPER)), 0.5F); - this.addFeature(new CreeperOverlayRenderer<>(this, context.getEntityModels(), PromenadeEntityModelLayers.LUSH_CREEPER_OUTER, OVERLAY_TEXTURE)); - } - - @Override - public CreeperEntityRenderState createRenderState() { - return new CreeperEntityRenderState(); - } - - @Override - protected void scale(CreeperEntityRenderState creeperEntityRenderState, MatrixStack matrixStack) { - float f = creeperEntityRenderState.fuseTime; - float g = 1.0F + MathHelper.sin(f * 100.0F) * f * 0.01F; - f = MathHelper.clamp(f, 0.0F, 1.0F); - f *= f; - f *= f; - float h = (1.0F + f * 0.4F) * g; - float i = (1.0F + f * 0.1F) / g; - matrixStack.scale(h, i, h); - } - - @Override - protected float getAnimationCounter(CreeperEntityRenderState state) { - float f = state.fuseTime; - return (int) (f * 10.0F) % 2 == 0 ? 0.0F : MathHelper.clamp(f, 0.5F, 1.0F); - } - - @Override - public Identifier getTexture(CreeperEntityRenderState state) { - return TEXTURE; - } - - public void updateRenderState(LushCreeperEntity lushCreeper, CreeperEntityRenderState creeperEntityRenderState, float f) { - super.updateRenderState(lushCreeper, creeperEntityRenderState, f); - creeperEntityRenderState.fuseTime = lushCreeper.getLerpedFuseTime(f); - creeperEntityRenderState.charged = lushCreeper.isCharged(); - } + private static final Identifier TEXTURE = Promenade.id("textures/entity/lush_creeper/base.png"); + private static final Identifier OVERLAY_TEXTURE = Promenade.id("textures/entity/lush_creeper/overlay.png"); + + public LushCreeperRenderer(EntityRendererFactory.Context context) { + super(context, new CreeperEntityModel(context.getPart(PromenadeEntityModelLayers.LUSH_CREEPER)), 0.5F); + this.addFeature(new CreeperOverlayRenderer<>(this, context.getEntityModels(), PromenadeEntityModelLayers.LUSH_CREEPER_OUTER, OVERLAY_TEXTURE)); + } + + @Override + public CreeperEntityRenderState createRenderState() { + return new CreeperEntityRenderState(); + } + + @Override + protected void scale(CreeperEntityRenderState creeperEntityRenderState, MatrixStack matrixStack) { + float f = creeperEntityRenderState.fuseTime; + float g = 1.0F + MathHelper.sin(f * 100.0F) * f * 0.01F; + f = MathHelper.clamp(f, 0.0F, 1.0F); + f *= f; + f *= f; + float h = (1.0F + f * 0.4F) * g; + float i = (1.0F + f * 0.1F) / g; + matrixStack.scale(h, i, h); + } + + @Override + protected float getAnimationCounter(CreeperEntityRenderState state) { + float f = state.fuseTime; + return (int) (f * 10.0F) % 2 == 0 ? 0.0F : MathHelper.clamp(f, 0.5F, 1.0F); + } + + @Override + public Identifier getTexture(CreeperEntityRenderState state) { + return TEXTURE; + } + + public void updateRenderState(LushCreeperEntity lushCreeper, CreeperEntityRenderState creeperEntityRenderState, float f) { + super.updateRenderState(lushCreeper, creeperEntityRenderState, f); + creeperEntityRenderState.fuseTime = lushCreeper.getLerpedFuseTime(f); + creeperEntityRenderState.charged = lushCreeper.isCharged(); + } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/PromenadeEntityRenderers.java b/src/client/java/fr/hugman/promenade/client/render/entity/PromenadeEntityRenderers.java index 79145efc..b9544107 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/PromenadeEntityRenderers.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/PromenadeEntityRenderers.java @@ -1,32 +1,45 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity; -import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; -import fr.hugman.promenade.entity.PromenadeEntityTypes; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.minecraft.client.render.entity.BoatEntityRenderer; import net.minecraft.client.render.entity.model.EntityModelLayer; import net.minecraft.entity.EntityType; import net.minecraft.entity.vehicle.AbstractBoatEntity; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; + +import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; +import fr.hugman.promenade.entity.PromenadeEntityTypes; + @Environment(EnvType.CLIENT) public class PromenadeEntityRenderers { - public static void register() { - EntityRendererRegistry.register(PromenadeEntityTypes.CAPYBARA, CapybaraEntityRenderer::new); - EntityRendererRegistry.register(PromenadeEntityTypes.DUCK, DuckEntityRenderer::new); - EntityRendererRegistry.register(PromenadeEntityTypes.LUSH_CREEPER, LushCreeperRenderer::new); - EntityRendererRegistry.register(PromenadeEntityTypes.SUNKEN, SunkenEntityRenderer::new); + public static void register() { + EntityRendererRegistry.register(PromenadeEntityTypes.CAPYBARA, CapybaraEntityRenderer::new); + EntityRendererRegistry.register(PromenadeEntityTypes.DUCK, DuckEntityRenderer::new); + EntityRendererRegistry.register(PromenadeEntityTypes.LUSH_CREEPER, LushCreeperRenderer::new); + EntityRendererRegistry.register(PromenadeEntityTypes.SUNKEN, SunkenEntityRenderer::new); - registerBoat(PromenadeEntityTypes.SAKURA_BOAT, PromenadeEntityModelLayers.SAKURA_BOAT); - registerBoat(PromenadeEntityTypes.SAKURA_CHEST_BOAT, PromenadeEntityModelLayers.SAKURA_CHEST_BOAT); - registerBoat(PromenadeEntityTypes.MAPLE_BOAT, PromenadeEntityModelLayers.MAPLE_BOAT); - registerBoat(PromenadeEntityTypes.MAPLE_CHEST_BOAT, PromenadeEntityModelLayers.MAPLE_CHEST_BOAT); - registerBoat(PromenadeEntityTypes.PALM_BOAT, PromenadeEntityModelLayers.PALM_BOAT); - registerBoat(PromenadeEntityTypes.PALM_CHEST_BOAT, PromenadeEntityModelLayers.PALM_CHEST_BOAT); - } + registerBoat(PromenadeEntityTypes.SAKURA_BOAT, PromenadeEntityModelLayers.SAKURA_BOAT); + registerBoat(PromenadeEntityTypes.SAKURA_CHEST_BOAT, PromenadeEntityModelLayers.SAKURA_CHEST_BOAT); + registerBoat(PromenadeEntityTypes.MAPLE_BOAT, PromenadeEntityModelLayers.MAPLE_BOAT); + registerBoat(PromenadeEntityTypes.MAPLE_CHEST_BOAT, PromenadeEntityModelLayers.MAPLE_CHEST_BOAT); + registerBoat(PromenadeEntityTypes.PALM_BOAT, PromenadeEntityModelLayers.PALM_BOAT); + registerBoat(PromenadeEntityTypes.PALM_CHEST_BOAT, PromenadeEntityModelLayers.PALM_CHEST_BOAT); + } - private static void registerBoat(EntityType type, EntityModelLayer modelLayer) { - EntityRendererRegistry.register(type, context -> new BoatEntityRenderer(context, modelLayer)); - } + private static void registerBoat(EntityType type, EntityModelLayer modelLayer) { + EntityRendererRegistry.register(type, context -> new BoatEntityRenderer(context, modelLayer)); + } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/SunkenEntityRenderer.java b/src/client/java/fr/hugman/promenade/client/render/entity/SunkenEntityRenderer.java index 9ced905d..248c5358 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/SunkenEntityRenderer.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/SunkenEntityRenderer.java @@ -1,11 +1,16 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity; -import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; -import fr.hugman.promenade.client.render.entity.model.SunkenEntityModel; -import fr.hugman.promenade.client.render.entity.state.SunkenEntityRenderState; -import fr.hugman.promenade.entity.SunkenEntity; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.render.entity.AbstractSkeletonEntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.texture.MissingSprite; @@ -14,48 +19,56 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RotationAxis; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import fr.hugman.promenade.client.render.entity.model.PromenadeEntityModelLayers; +import fr.hugman.promenade.client.render.entity.model.SunkenEntityModel; +import fr.hugman.promenade.client.render.entity.state.SunkenEntityRenderState; +import fr.hugman.promenade.entity.SunkenEntity; + @Environment(EnvType.CLIENT) public class SunkenEntityRenderer extends AbstractSkeletonEntityRenderer { - public SunkenEntityRenderer(EntityRendererFactory.Context context) { - super( - context, - PromenadeEntityModelLayers.SUNKEN_EQUIPMENT, - new SunkenEntityModel(context.getPart(PromenadeEntityModelLayers.SUNKEN)) - ); - } - - @Override - public SunkenEntityRenderState createRenderState() { - return new SunkenEntityRenderState(); - } - - @Override - protected void setupTransforms(SunkenEntityRenderState state, MatrixStack matrices, float bodyYaw, float baseHeight) { - float h = state.leaningPitch; - float i = state.pitch; - - super.setupTransforms(state, matrices, bodyYaw, baseHeight); - if (h > 0.0F) { - float jx = state.touchingWater ? -90.0F - i : -90.0F; - float k = MathHelper.lerp(h, 0.0F, jx); - matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(k)); - if (state.isSwimming) { - matrices.translate(0.0F, -1.0F, 0.3F); - } - } - } - - @Override - public Identifier getTexture(SunkenEntityRenderState state) { - if (state.variant == null) { - return MissingSprite.getMissingSpriteId(); - } - return state.variant.texture().texturePath(); - } - - @Override - public void updateRenderState(SunkenEntity sunken, SunkenEntityRenderState state, float f) { - super.updateRenderState(sunken, state, f); - state.variant = sunken.getVariant().value(); - } + public SunkenEntityRenderer(EntityRendererFactory.Context context) { + super( + context, + PromenadeEntityModelLayers.SUNKEN_EQUIPMENT, + new SunkenEntityModel(context.getPart(PromenadeEntityModelLayers.SUNKEN)) + ); + } + + @Override + public SunkenEntityRenderState createRenderState() { + return new SunkenEntityRenderState(); + } + + @Override + protected void setupTransforms(SunkenEntityRenderState state, MatrixStack matrices, float bodyYaw, float baseHeight) { + float h = state.leaningPitch; + float i = state.pitch; + + super.setupTransforms(state, matrices, bodyYaw, baseHeight); + if (h > 0.0F) { + float jx = state.touchingWater ? - 90.0F - i : - 90.0F; + float k = MathHelper.lerp(h, 0.0F, jx); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(k)); + if (state.isSwimming) { + matrices.translate(0.0F, - 1.0F, 0.3F); + } + } + } + + @Override + public Identifier getTexture(SunkenEntityRenderState state) { + if (state.variant == null) { + return MissingSprite.getMissingSpriteId(); + } + return state.variant.texture().texturePath(); + } + + @Override + public void updateRenderState(SunkenEntity sunken, SunkenEntityRenderState state, float f) { + super.updateRenderState(sunken, state, f); + state.variant = sunken.getVariant().value(); + } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/animation/CapybaraAnimations.java b/src/client/java/fr/hugman/promenade/client/render/entity/animation/CapybaraAnimations.java index 822ccc74..62dad126 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/animation/CapybaraAnimations.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/animation/CapybaraAnimations.java @@ -1,388 +1,400 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity.animation; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.render.entity.animation.AnimationDefinition; import net.minecraft.client.render.entity.animation.AnimationHelper; import net.minecraft.client.render.entity.animation.Keyframe; import net.minecraft.client.render.entity.animation.Transformation; import net.minecraft.client.render.entity.model.EntityModelPartNames; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + @Environment(EnvType.CLIENT) public class CapybaraAnimations { - public static final AnimationDefinition EAR_WIGGLE = AnimationDefinition.Builder.create(0.2f) - .addBoneAnimation(EntityModelPartNames.RIGHT_EAR, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.1f, AnimationHelper.createRotationalVector(-13.5f, -15f, 13f), Transformation.Interpolations.CUBIC), - new Keyframe(0.2f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_EAR, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.1f, AnimationHelper.createRotationalVector(-13.5f, 15f, -13f), Transformation.Interpolations.CUBIC), - new Keyframe(0.2f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .build(); + public static final AnimationDefinition EAR_WIGGLE = AnimationDefinition.Builder.create(0.2f) + .addBoneAnimation(EntityModelPartNames.RIGHT_EAR, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.1f, AnimationHelper.createRotationalVector(- 13.5f, - 15f, 13f), Transformation.Interpolations.CUBIC), + new Keyframe(0.2f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_EAR, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.1f, AnimationHelper.createRotationalVector(- 13.5f, 15f, - 13f), Transformation.Interpolations.CUBIC), + new Keyframe(0.2f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .build(); - public static final AnimationDefinition WALKING = AnimationDefinition.Builder.create(1.5f).looping() - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 2.5f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(0f, 0f, -2.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(0f, 0f, 2.5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(0f, 0f, 5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.75f, AnimationHelper.createRotationalVector(-27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition WALKING = AnimationDefinition.Builder.create(1.5f).looping() + .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 2.5f), Transformation.Interpolations.CUBIC), + new Keyframe(0.75f, AnimationHelper.createRotationalVector(0f, 0f, - 2.5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5f, AnimationHelper.createRotationalVector(0f, 0f, 2.5f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, - 5f), Transformation.Interpolations.CUBIC), + new Keyframe(0.75f, AnimationHelper.createRotationalVector(0f, 0f, 5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5f, AnimationHelper.createRotationalVector(0f, 0f, - 5f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.75f, AnimationHelper.createRotationalVector(- 27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(- 27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.75f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5f, AnimationHelper.createRotationalVector(- 27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(- 27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.75f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5f, AnimationHelper.createRotationalVector(- 27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.75f, AnimationHelper.createRotationalVector(- 27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))).build(); - public static final AnimationDefinition FALL_TO_SLEEP = AnimationDefinition.Builder.create(1.9167667f) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5834333f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, -10f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5834333f, AnimationHelper.createRotationalVector(0f, 0f, -90f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.375f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.4583433f, AnimationHelper.createScalingVector(0.8f, 1.1f, 1.1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5834333f, AnimationHelper.createScalingVector(1.2f, 0.9f, 0.9f), Transformation.Interpolations.CUBIC), - new Keyframe(1.6766667f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.3433333f, AnimationHelper.createRotationalVector(0f, 0f, -60f), Transformation.Interpolations.CUBIC), - new Keyframe(1.625f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7916767f, AnimationHelper.createRotationalVector(-7.387326251354352f, -1.2987564674722307f, 7.583846147258555f), Transformation.Interpolations.LINEAR), - new Keyframe(1.9167667f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0.8343334f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(0.9583434f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.0834333f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.1676667f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 40f), Transformation.Interpolations.CUBIC), - new Keyframe(1.1676667f, AnimationHelper.createRotationalVector(-0.8329438344855409f, -2.0100084957616673f, -31.292852606551207f), Transformation.Interpolations.CUBIC), - new Keyframe(1.625f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0.8343334f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(0.9583434f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.0834333f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), - new Keyframe(1.1676667f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.3433333f, AnimationHelper.createRotationalVector(0f, 0f, -77.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.625f, AnimationHelper.createRotationalVector(22.480717026093316f, 0.9564494572955482f, 20.19008655601783f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7916767f, AnimationHelper.createRotationalVector(22.018164129528486f, 4.751129561951075f, 10.924817551732758f), Transformation.Interpolations.LINEAR), - new Keyframe(1.9167667f, AnimationHelper.createRotationalVector(22.480717026093316f, 0.9564494572955482f, 20.19008655601783f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 42.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.1676667f, AnimationHelper.createRotationalVector(5.989807308760465f, 9.302389729048627f, -28.590097057579058f), Transformation.Interpolations.CUBIC), - new Keyframe(1.625f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7083433f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(4.990462591650612f, 4.99522900802458f, -20.218651201461853f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(0f, 0f, 27.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7083433f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition FALL_TO_SLEEP = AnimationDefinition.Builder.create(1.9167667f) + .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.8343334f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5834333f, AnimationHelper.createTranslationalVector(- 12f, - 5f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, - 10f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5834333f, AnimationHelper.createRotationalVector(0f, 0f, - 90f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.SCALE, + new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR), + new Keyframe(1.375f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(1.4583433f, AnimationHelper.createScalingVector(0.8f, 1.1f, 1.1f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5834333f, AnimationHelper.createScalingVector(1.2f, 0.9f, 0.9f), Transformation.Interpolations.CUBIC), + new Keyframe(1.6766667f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.3433333f, AnimationHelper.createRotationalVector(0f, 0f, - 60f), Transformation.Interpolations.CUBIC), + new Keyframe(1.625f, AnimationHelper.createRotationalVector(- 7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.7916767f, AnimationHelper.createRotationalVector(- 7.387326251354352f, - 1.2987564674722307f, 7.583846147258555f), Transformation.Interpolations.LINEAR), + new Keyframe(1.9167667f, AnimationHelper.createRotationalVector(- 7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.SCALE, + new Keyframe(0.8343334f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR), + new Keyframe(0.9583434f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), + new Keyframe(1.0834333f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), + new Keyframe(1.1676667f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.8343334f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 40f), Transformation.Interpolations.CUBIC), + new Keyframe(1.1676667f, AnimationHelper.createRotationalVector(- 0.8329438344855409f, - 2.0100084957616673f, - 31.292852606551207f), Transformation.Interpolations.CUBIC), + new Keyframe(1.625f, AnimationHelper.createRotationalVector(- 20f, 0f, 5f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.SCALE, + new Keyframe(0.8343334f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR), + new Keyframe(0.9583434f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), + new Keyframe(1.0834333f, AnimationHelper.createScalingVector(1f, 0.8f, 1f), Transformation.Interpolations.LINEAR), + new Keyframe(1.1676667f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.LINEAR))) + .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.3433333f, AnimationHelper.createRotationalVector(0f, 0f, - 77.5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.625f, AnimationHelper.createRotationalVector(22.480717026093316f, 0.9564494572955482f, 20.19008655601783f), Transformation.Interpolations.CUBIC), + new Keyframe(1.7916767f, AnimationHelper.createRotationalVector(22.018164129528486f, 4.751129561951075f, 10.924817551732758f), Transformation.Interpolations.LINEAR), + new Keyframe(1.9167667f, AnimationHelper.createRotationalVector(22.480717026093316f, 0.9564494572955482f, 20.19008655601783f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.8343334f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(0f, 0f, 42.5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.1676667f, AnimationHelper.createRotationalVector(5.989807308760465f, 9.302389729048627f, - 28.590097057579058f), Transformation.Interpolations.CUBIC), + new Keyframe(1.625f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.7083433f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.8343334f, AnimationHelper.createRotationalVector(4.990462591650612f, 4.99522900802458f, - 20.218651201461853f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createRotationalVector(0f, 0f, 27.5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.7083433f, AnimationHelper.createRotationalVector(0f, 0f, - 5f), Transformation.Interpolations.CUBIC))).build(); - public static final AnimationDefinition SLEEP = AnimationDefinition.Builder.create(4.5f).looping() - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -90f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(22.30257854223737f, -3.0529741491914137f, 29.898054778260757f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createRotationalVector(22.30257854223737f, -3.0529741491914137f, 29.898054778260757f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.5416767f, AnimationHelper.createRotationalVector(-5f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(2.5416765f, AnimationHelper.createRotationalVector(-5f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7083435f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createScalingVector(1.1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(2.25f, AnimationHelper.createScalingVector(1.1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.5f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition SLEEP = AnimationDefinition.Builder.create(4.5f).looping() + .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(- 12f, - 5f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, - 90f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.25f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(- 7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createRotationalVector(- 7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), + new Keyframe(2.25f, AnimationHelper.createRotationalVector(- 7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createRotationalVector(- 7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), + new Keyframe(4.5f, AnimationHelper.createRotationalVector(- 7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(- 20f, 0f, 5f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.25f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createRotationalVector(22.30257854223737f, - 3.0529741491914137f, 29.898054778260757f), Transformation.Interpolations.CUBIC), + new Keyframe(2.25f, AnimationHelper.createRotationalVector(22.30257854223737f, - 3.0529741491914137f, 29.898054778260757f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC), + new Keyframe(4.5f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, - 5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.5416767f, AnimationHelper.createRotationalVector(- 5f, 0f, - 5f), Transformation.Interpolations.CUBIC), + new Keyframe(2.5416765f, AnimationHelper.createRotationalVector(- 5f, 0f, - 5f), Transformation.Interpolations.CUBIC), + new Keyframe(3.7083435f, AnimationHelper.createRotationalVector(0f, 0f, - 5f), Transformation.Interpolations.CUBIC), + new Keyframe(4.5f, AnimationHelper.createRotationalVector(0f, 0f, - 5f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.25f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.SCALE, + new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createScalingVector(1.1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(2.25f, AnimationHelper.createScalingVector(1.1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(4.5f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))).build(); - public static final AnimationDefinition FART = AnimationDefinition.Builder.create(3.8343335f) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.08343333f, AnimationHelper.createTranslationalVector(0f, 5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(0.08343333f, AnimationHelper.createScalingVector(1f, 1.2f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.0416765f, AnimationHelper.createTranslationalVector(0.63f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.375f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(-7.5f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(-7.5f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.1676665f, AnimationHelper.createRotationalVector(0.2727354654598457f, 0.4131058282196136f, -6.089277436131233f), Transformation.Interpolations.CUBIC), - new Keyframe(2.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.375f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.7083435f, AnimationHelper.createTranslationalVector(-0.12f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.0416765f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.375f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.7916765f, AnimationHelper.createRotationalVector(-5.111516362223829f, -0.446597721821945f, 6.992121938251076f), Transformation.Interpolations.CUBIC), - new Keyframe(3.0416765f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.2083435f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.5f, AnimationHelper.createTranslationalVector(0.63f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.8343335f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(0f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(0f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.2083435f, AnimationHelper.createRotationalVector(0f, 0f, -17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.625f, AnimationHelper.createRotationalVector(0.2727354654598457f, 0.4131058282196136f, -6.089277436131233f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(2.8343335f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.LINEAR), - new Keyframe(3.1676665f, AnimationHelper.createTranslationalVector(-0.12f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(0f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(0f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(2.8343335f, AnimationHelper.createRotationalVector(0f, 0f, 17.5f), Transformation.Interpolations.LINEAR), - new Keyframe(3.25f, AnimationHelper.createRotationalVector(-5.111516362223829f, -0.446597721821945f, 6.992121938251076f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(10f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(10f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.1676665f, AnimationHelper.createRotationalVector(2.2307925039942713f, -0.21576122102964312f, -7.927957140726775f), Transformation.Interpolations.CUBIC), - new Keyframe(2.4167665f, AnimationHelper.createRotationalVector(4.294867444937954f, 2.2606154253199566f, -6.0592613319625706f), Transformation.Interpolations.CUBIC), - new Keyframe(2.625f, AnimationHelper.createRotationalVector(1.7645231481382142f, 1.1309400733304573f, 0.14523321293696423f), Transformation.Interpolations.CUBIC), - new Keyframe(2.875f, AnimationHelper.createRotationalVector(6.178001369910271f, -0.19388043339675276f, 5.467675351455965f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(0f, -1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createTranslationalVector(0f, -1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9167665f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(2.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(2.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.0834335f, AnimationHelper.createRotationalVector(49.89121214627585f, -3.3756177280956763f, 3.6906601938271706f), Transformation.Interpolations.CUBIC), - new Keyframe(2.375f, AnimationHelper.createRotationalVector(62.26769532549997f, 10.515127085314361f, 31.44641266227063f), Transformation.Interpolations.CUBIC), - new Keyframe(2.7083435f, AnimationHelper.createRotationalVector(62.54663949450434f, -8.432200276274816f, -49.78158893940414f), Transformation.Interpolations.CUBIC), - new Keyframe(3f, AnimationHelper.createRotationalVector(58.19080366360111f, 20.578159182988493f, 18.790040178069503f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2083435f, AnimationHelper.createRotationalVector(34.363668641116874f, 11.307647518170633f, 12.797722379234328f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5f, AnimationHelper.createRotationalVector(-7.379261962134369f, 2.46597558997084f, 2.922121806087871f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7916765f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition FART = AnimationDefinition.Builder.create(3.8343335f) + .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.08343333f, AnimationHelper.createTranslationalVector(0f, 5f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.SCALE, + new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(0.08343333f, AnimationHelper.createScalingVector(1f, 1.2f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(1.75f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(2.0416765f, AnimationHelper.createTranslationalVector(0.63f, 1f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.375f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(- 7.5f, 0f, - 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(1.75f, AnimationHelper.createRotationalVector(- 7.5f, 0f, - 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(2.1676665f, AnimationHelper.createRotationalVector(0.2727354654598457f, 0.4131058282196136f, - 6.089277436131233f), Transformation.Interpolations.CUBIC), + new Keyframe(2.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(1.75f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(2.375f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(2.7083435f, AnimationHelper.createTranslationalVector(- 0.12f, 1f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.0416765f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(- 7.5f, 0f, 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(1.75f, AnimationHelper.createRotationalVector(- 7.5f, 0f, 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(2.375f, AnimationHelper.createRotationalVector(- 7.5f, 0f, 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(2.7916765f, AnimationHelper.createRotationalVector(- 5.111516362223829f, - 0.446597721821945f, 6.992121938251076f), Transformation.Interpolations.CUBIC), + new Keyframe(3.0416765f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(1.75f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(2.2083435f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(2.5f, AnimationHelper.createTranslationalVector(0.63f, 1f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.8343335f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(0f, 0f, - 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(1.75f, AnimationHelper.createRotationalVector(0f, 0f, - 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(2.2083435f, AnimationHelper.createRotationalVector(0f, 0f, - 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(2.625f, AnimationHelper.createRotationalVector(0.2727354654598457f, 0.4131058282196136f, - 6.089277436131233f), Transformation.Interpolations.CUBIC), + new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(1.75f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(2.8343335f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.LINEAR), + new Keyframe(3.1676665f, AnimationHelper.createTranslationalVector(- 0.12f, 1f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(0f, 0f, 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(1.75f, AnimationHelper.createRotationalVector(0f, 0f, 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(2.8343335f, AnimationHelper.createRotationalVector(0f, 0f, 17.5f), Transformation.Interpolations.LINEAR), + new Keyframe(3.25f, AnimationHelper.createRotationalVector(- 5.111516362223829f, - 0.446597721821945f, 6.992121938251076f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(10f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.75f, AnimationHelper.createRotationalVector(10f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.1676665f, AnimationHelper.createRotationalVector(2.2307925039942713f, - 0.21576122102964312f, - 7.927957140726775f), Transformation.Interpolations.CUBIC), + new Keyframe(2.4167665f, AnimationHelper.createRotationalVector(4.294867444937954f, 2.2606154253199566f, - 6.0592613319625706f), Transformation.Interpolations.CUBIC), + new Keyframe(2.625f, AnimationHelper.createRotationalVector(1.7645231481382142f, 1.1309400733304573f, 0.14523321293696423f), Transformation.Interpolations.CUBIC), + new Keyframe(2.875f, AnimationHelper.createRotationalVector(6.178001369910271f, - 0.19388043339675276f, 5.467675351455965f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createTranslationalVector(0f, - 1f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.75f, AnimationHelper.createTranslationalVector(0f, - 1f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.9167665f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.16766666f, AnimationHelper.createRotationalVector(2.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.75f, AnimationHelper.createRotationalVector(2.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.0834335f, AnimationHelper.createRotationalVector(49.89121214627585f, - 3.3756177280956763f, 3.6906601938271706f), Transformation.Interpolations.CUBIC), + new Keyframe(2.375f, AnimationHelper.createRotationalVector(62.26769532549997f, 10.515127085314361f, 31.44641266227063f), Transformation.Interpolations.CUBIC), + new Keyframe(2.7083435f, AnimationHelper.createRotationalVector(62.54663949450434f, - 8.432200276274816f, - 49.78158893940414f), Transformation.Interpolations.CUBIC), + new Keyframe(3f, AnimationHelper.createRotationalVector(58.19080366360111f, 20.578159182988493f, 18.790040178069503f), Transformation.Interpolations.CUBIC), + new Keyframe(3.2083435f, AnimationHelper.createRotationalVector(34.363668641116874f, 11.307647518170633f, 12.797722379234328f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5f, AnimationHelper.createRotationalVector(- 7.379261962134369f, 2.46597558997084f, 2.922121806087871f), Transformation.Interpolations.CUBIC), + new Keyframe(3.7916765f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))).build(); - public static final AnimationDefinition WAKE_UP = AnimationDefinition.Builder.create(5.791677f) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createTranslationalVector(-12f, -5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7083435f, AnimationHelper.createTranslationalVector(-14f, -5f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.375f, AnimationHelper.createTranslationalVector(-9f, -3f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.75f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -90f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(0f, 0f, -90f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createRotationalVector(0f, 0f, -92.5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7083435f, AnimationHelper.createRotationalVector(0f, 0f, -117.5f), Transformation.Interpolations.CUBIC), - new Keyframe(4.375f, AnimationHelper.createRotationalVector(0f, 0f, -70f), Transformation.Interpolations.CUBIC), - new Keyframe(4.75f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createRotationalVector(0f, 0f, 7.5f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createTranslationalVector(1f, 0.25f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.125f, AnimationHelper.createTranslationalVector(0.75f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createRotationalVector(-7.366127295935403f, -1.4184144280073452f, 6.660634475402492f), Transformation.Interpolations.CUBIC), - new Keyframe(1.9583433f, AnimationHelper.createRotationalVector(-7.408694655995223f, 1.1699920891777946f, 26.424248239231403f), Transformation.Interpolations.CUBIC), - new Keyframe(2.0416765f, AnimationHelper.createRotationalVector(-7.49745918025943f, 0.19576730469809256f, 18.98717307987583f), Transformation.Interpolations.CUBIC), - new Keyframe(2.2083435f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), - new Keyframe(3.7083435f, AnimationHelper.createRotationalVector(-6.041112393472904f, 4.452922991257692f, 53.76491217464347f), Transformation.Interpolations.CUBIC), - new Keyframe(4.375f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createRotationalVector(0.24117231125816033f, -0.09448572501914895f, -16.85553579291023f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(3.125f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5416765f, AnimationHelper.createTranslationalVector(-1f, -0.75f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.125f, AnimationHelper.createTranslationalVector(-0.78f, 0.42000000000000004f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createRotationalVector(-20f, 0f, 5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5416765f, AnimationHelper.createRotationalVector(-12.279770389181849f, 12.007062843212225f, 47.98109178875055f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.SCALE, - new Keyframe(3.5416765f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(3.9583435f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.583433f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.75f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.834333f, AnimationHelper.createTranslationalVector(1f, 0.25f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.958343f, AnimationHelper.createTranslationalVector(0.75f, 1f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.125f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createRotationalVector(22.30257854223737f, -3.0529741491914137f, 29.898054778260757f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(20.091305344004923f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createRotationalVector(-4.866127295935403f, -1.4184144280073452f, 6.660634475402492f), Transformation.Interpolations.CUBIC), - new Keyframe(1.9583433f, AnimationHelper.createRotationalVector(-7.408694655995223f, 1.1699920891777946f, 26.424248239231403f), Transformation.Interpolations.CUBIC), - new Keyframe(2.0416765f, AnimationHelper.createRotationalVector(-7.49745918025943f, 0.19576730469809256f, 18.98717307987583f), Transformation.Interpolations.CUBIC), - new Keyframe(2.2083435f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(-7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5416765f, AnimationHelper.createRotationalVector(-6.041112393472904f, 4.452922991257692f, 53.76491217464347f), Transformation.Interpolations.CUBIC), - new Keyframe(4.208343f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.834333f, AnimationHelper.createRotationalVector(0.24117231125816033f, -0.09448572501914895f, -16.85553579291023f), Transformation.Interpolations.CUBIC), - new Keyframe(5.125f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2083435f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.625f, AnimationHelper.createTranslationalVector(-1f, -0.75f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(4.208343f, AnimationHelper.createTranslationalVector(-0.78f, 0.42000000000000004f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5.375f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.75f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createRotationalVector(7.14232996078681f, 4.599015978825719f, -8.889268973502567f), Transformation.Interpolations.CUBIC), - new Keyframe(1.9583433f, AnimationHelper.createRotationalVector(-2.475429931501239f, 4.3960867006031545f, -3.8970580610586154f), Transformation.Interpolations.CUBIC), - new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(-2.475429931501239f, 4.3960867006031545f, -3.8970580610586154f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2083435f, AnimationHelper.createRotationalVector(-2.475429931501239f, 4.3960867006031545f, -3.8970580610586154f), Transformation.Interpolations.CUBIC), - new Keyframe(3.625f, AnimationHelper.createRotationalVector(-12.279770389181849f, 12.007062843212225f, 47.98109178875055f), Transformation.Interpolations.CUBIC), - new Keyframe(5.375f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.SCALE, - new Keyframe(3.625f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.041677f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.583433f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(4.75f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.125f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.5416765f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.SCALE, - new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.25f, AnimationHelper.createScalingVector(1.1f, 1f, 1f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, - new Keyframe(0f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(0.9583434f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7083433f, AnimationHelper.createTranslationalVector(-1f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createTranslationalVector(1.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2916765f, AnimationHelper.createTranslationalVector(1.25f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(3.625f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC))) - .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, - new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(0.5f, AnimationHelper.createRotationalVector(0f, 0f, 20f), Transformation.Interpolations.CUBIC), - new Keyframe(0.9583434f, AnimationHelper.createRotationalVector(0f, 0f, 20f), Transformation.Interpolations.CUBIC), - new Keyframe(1.7083433f, AnimationHelper.createRotationalVector(0f, 0f, -5f), Transformation.Interpolations.CUBIC), - new Keyframe(1.875f, AnimationHelper.createRotationalVector(0f, 0f, 57.5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.0834335f, AnimationHelper.createRotationalVector(0f, 0f, 57.5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.2916765f, AnimationHelper.createRotationalVector(17.5f, 0f, 57.5f), Transformation.Interpolations.CUBIC), - new Keyframe(3.625f, AnimationHelper.createRotationalVector(16.14973182841186f, 6.279671924441573f, 33.25231220461228f), Transformation.Interpolations.CUBIC), - new Keyframe(4f, AnimationHelper.createRotationalVector(11.23738518791506f, 12.240295486395354f, 3.4386635769687928f), Transformation.Interpolations.CUBIC), - new Keyframe(4.25f, AnimationHelper.createRotationalVector(7.106591348469683f, 14.290604655089956f, -14.422213143878762f), Transformation.Interpolations.CUBIC), - new Keyframe(4.676667f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), - new Keyframe(5f, AnimationHelper.createRotationalVector(0f, 0f, 15f), Transformation.Interpolations.CUBIC), - new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))).build(); + public static final AnimationDefinition WAKE_UP = AnimationDefinition.Builder.create(5.791677f) + .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(- 12f, - 5f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.9583435f, AnimationHelper.createTranslationalVector(- 12f, - 5f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.125f, AnimationHelper.createTranslationalVector(- 12f, - 5f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.7083435f, AnimationHelper.createTranslationalVector(- 14f, - 5f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.375f, AnimationHelper.createTranslationalVector(- 9f, - 3f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.75f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5.291677f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.ROOT, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, - 90f), Transformation.Interpolations.CUBIC), + new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(0f, 0f, - 90f), Transformation.Interpolations.CUBIC), + new Keyframe(3.125f, AnimationHelper.createRotationalVector(0f, 0f, - 92.5f), Transformation.Interpolations.CUBIC), + new Keyframe(3.7083435f, AnimationHelper.createRotationalVector(0f, 0f, - 117.5f), Transformation.Interpolations.CUBIC), + new Keyframe(4.375f, AnimationHelper.createRotationalVector(0f, 0f, - 70f), Transformation.Interpolations.CUBIC), + new Keyframe(4.75f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5f, AnimationHelper.createRotationalVector(0f, 0f, 7.5f), Transformation.Interpolations.CUBIC), + new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.875f, AnimationHelper.createTranslationalVector(0.75f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5f, AnimationHelper.createTranslationalVector(1f, 0.25f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5.125f, AnimationHelper.createTranslationalVector(0.75f, 1f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5.291677f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(- 7.5f, 0f, 17.5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createRotationalVector(- 7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), + new Keyframe(1.75f, AnimationHelper.createRotationalVector(- 7.4086946559950775f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), + new Keyframe(1.875f, AnimationHelper.createRotationalVector(- 7.366127295935403f, - 1.4184144280073452f, 6.660634475402492f), Transformation.Interpolations.CUBIC), + new Keyframe(1.9583433f, AnimationHelper.createRotationalVector(- 7.408694655995223f, 1.1699920891777946f, 26.424248239231403f), Transformation.Interpolations.CUBIC), + new Keyframe(2.0416765f, AnimationHelper.createRotationalVector(- 7.49745918025943f, 0.19576730469809256f, 18.98717307987583f), Transformation.Interpolations.CUBIC), + new Keyframe(2.2083435f, AnimationHelper.createRotationalVector(- 7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), + new Keyframe(3.125f, AnimationHelper.createRotationalVector(- 7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), + new Keyframe(3.7083435f, AnimationHelper.createRotationalVector(- 6.041112393472904f, 4.452922991257692f, 53.76491217464347f), Transformation.Interpolations.CUBIC), + new Keyframe(4.375f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5f, AnimationHelper.createRotationalVector(0.24117231125816033f, - 0.09448572501914895f, - 16.85553579291023f), Transformation.Interpolations.CUBIC), + new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(3.125f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5416765f, AnimationHelper.createTranslationalVector(- 1f, - 0.75f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.125f, AnimationHelper.createTranslationalVector(- 0.78f, 0.42000000000000004f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5.291677f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(- 20f, 0f, 5f), Transformation.Interpolations.CUBIC), + new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(- 20f, 0f, 5f), Transformation.Interpolations.CUBIC), + new Keyframe(3.125f, AnimationHelper.createRotationalVector(- 20f, 0f, 5f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5416765f, AnimationHelper.createRotationalVector(- 12.279770389181849f, 12.007062843212225f, 47.98109178875055f), Transformation.Interpolations.CUBIC), + new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_FRONT_LEG, new Transformation(Transformation.Targets.SCALE, + new Keyframe(3.5416765f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(3.9583435f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(4.583433f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(4.75f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.875f, AnimationHelper.createTranslationalVector(1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.834333f, AnimationHelper.createTranslationalVector(1f, 0.25f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.958343f, AnimationHelper.createTranslationalVector(0.75f, 1f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5.125f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.RIGHT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(22.48071702609377f, 0.9564494572955482f, 20.190086556017377f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createRotationalVector(22.30257854223737f, - 3.0529741491914137f, 29.898054778260757f), Transformation.Interpolations.CUBIC), + new Keyframe(1.75f, AnimationHelper.createRotationalVector(20.091305344004923f, 1.1699920891774127f, 26.424248239231474f), Transformation.Interpolations.CUBIC), + new Keyframe(1.875f, AnimationHelper.createRotationalVector(- 4.866127295935403f, - 1.4184144280073452f, 6.660634475402492f), Transformation.Interpolations.CUBIC), + new Keyframe(1.9583433f, AnimationHelper.createRotationalVector(- 7.408694655995223f, 1.1699920891777946f, 26.424248239231403f), Transformation.Interpolations.CUBIC), + new Keyframe(2.0416765f, AnimationHelper.createRotationalVector(- 7.49745918025943f, 0.19576730469809256f, 18.98717307987583f), Transformation.Interpolations.CUBIC), + new Keyframe(2.2083435f, AnimationHelper.createRotationalVector(- 7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), + new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(- 7.4086946559950775f, 1.1699920891780493f, 26.42424823923169f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5416765f, AnimationHelper.createRotationalVector(- 6.041112393472904f, 4.452922991257692f, 53.76491217464347f), Transformation.Interpolations.CUBIC), + new Keyframe(4.208343f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.834333f, AnimationHelper.createRotationalVector(0.24117231125816033f, - 0.09448572501914895f, - 16.85553579291023f), Transformation.Interpolations.CUBIC), + new Keyframe(5.125f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(2.9583435f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.2083435f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.625f, AnimationHelper.createTranslationalVector(- 1f, - 0.75f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(4.208343f, AnimationHelper.createTranslationalVector(- 0.78f, 0.42000000000000004f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5.375f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.75f, AnimationHelper.createRotationalVector(27.5f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.875f, AnimationHelper.createRotationalVector(7.14232996078681f, 4.599015978825719f, - 8.889268973502567f), Transformation.Interpolations.CUBIC), + new Keyframe(1.9583433f, AnimationHelper.createRotationalVector(- 2.475429931501239f, 4.3960867006031545f, - 3.8970580610586154f), Transformation.Interpolations.CUBIC), + new Keyframe(2.9583435f, AnimationHelper.createRotationalVector(- 2.475429931501239f, 4.3960867006031545f, - 3.8970580610586154f), Transformation.Interpolations.CUBIC), + new Keyframe(3.2083435f, AnimationHelper.createRotationalVector(- 2.475429931501239f, 4.3960867006031545f, - 3.8970580610586154f), Transformation.Interpolations.CUBIC), + new Keyframe(3.625f, AnimationHelper.createRotationalVector(- 12.279770389181849f, 12.007062843212225f, 47.98109178875055f), Transformation.Interpolations.CUBIC), + new Keyframe(5.375f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.LEFT_HIND_LEG, new Transformation(Transformation.Targets.SCALE, + new Keyframe(3.625f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(4.041677f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(4.583433f, AnimationHelper.createScalingVector(1f, 0.6f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(4.75f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.875f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.125f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.5416765f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.BODY, new Transformation(Transformation.Targets.SCALE, + new Keyframe(0f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(1.25f, AnimationHelper.createScalingVector(1.1f, 1f, 1f), Transformation.Interpolations.CUBIC), + new Keyframe(1.875f, AnimationHelper.createScalingVector(1f, 1f, 1f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.MOVE_ORIGIN, + new Keyframe(0f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.5f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(0.9583434f, AnimationHelper.createTranslationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.7083433f, AnimationHelper.createTranslationalVector(- 1f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(1.875f, AnimationHelper.createTranslationalVector(1.25f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.2916765f, AnimationHelper.createTranslationalVector(1.25f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(3.625f, AnimationHelper.createTranslationalVector(0.25f, 0f, 0f), Transformation.Interpolations.CUBIC))) + .addBoneAnimation(EntityModelPartNames.HEAD, new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0f, AnimationHelper.createRotationalVector(0f, 0f, - 5f), Transformation.Interpolations.CUBIC), + new Keyframe(0.5f, AnimationHelper.createRotationalVector(0f, 0f, 20f), Transformation.Interpolations.CUBIC), + new Keyframe(0.9583434f, AnimationHelper.createRotationalVector(0f, 0f, 20f), Transformation.Interpolations.CUBIC), + new Keyframe(1.7083433f, AnimationHelper.createRotationalVector(0f, 0f, - 5f), Transformation.Interpolations.CUBIC), + new Keyframe(1.875f, AnimationHelper.createRotationalVector(0f, 0f, 57.5f), Transformation.Interpolations.CUBIC), + new Keyframe(3.0834335f, AnimationHelper.createRotationalVector(0f, 0f, 57.5f), Transformation.Interpolations.CUBIC), + new Keyframe(3.2916765f, AnimationHelper.createRotationalVector(17.5f, 0f, 57.5f), Transformation.Interpolations.CUBIC), + new Keyframe(3.625f, AnimationHelper.createRotationalVector(16.14973182841186f, 6.279671924441573f, 33.25231220461228f), Transformation.Interpolations.CUBIC), + new Keyframe(4f, AnimationHelper.createRotationalVector(11.23738518791506f, 12.240295486395354f, 3.4386635769687928f), Transformation.Interpolations.CUBIC), + new Keyframe(4.25f, AnimationHelper.createRotationalVector(7.106591348469683f, 14.290604655089956f, - 14.422213143878762f), Transformation.Interpolations.CUBIC), + new Keyframe(4.676667f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC), + new Keyframe(5f, AnimationHelper.createRotationalVector(0f, 0f, 15f), Transformation.Interpolations.CUBIC), + new Keyframe(5.291677f, AnimationHelper.createRotationalVector(0f, 0f, 0f), Transformation.Interpolations.CUBIC))).build(); } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/CapybaraEntityModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/CapybaraEntityModel.java index bf087630..cd6b60e2 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/model/CapybaraEntityModel.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/CapybaraEntityModel.java @@ -1,9 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity.model; -import fr.hugman.promenade.client.render.entity.animation.CapybaraAnimations; -import fr.hugman.promenade.client.render.entity.state.CapybaraEntityRenderState; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import java.util.Set; + import net.minecraft.client.model.*; import net.minecraft.client.render.entity.animation.Animation; import net.minecraft.client.render.entity.model.BabyModelTransformer; @@ -11,78 +20,82 @@ import net.minecraft.client.render.entity.model.EntityModelPartNames; import net.minecraft.client.render.entity.model.ModelTransformer; -import java.util.Set; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import fr.hugman.promenade.client.render.entity.animation.CapybaraAnimations; +import fr.hugman.promenade.client.render.entity.state.CapybaraEntityRenderState; @Environment(EnvType.CLIENT) public class CapybaraEntityModel extends EntityModel { - private static final String LOWER_TEETH = "lower_teeth"; - private static final String UPPER_TEETH = "upper_teeth"; - - private final ModelPart head; - - private final Animation walkingAnimation; - private final Animation earWiggleAnimation; - private final Animation fallToSleepAnimation; - private final Animation sleepingAnimation; - private final Animation wakeUpAnimation; - private final Animation fartAnimation; - - public static final ModelTransformer BABY_TRANSFORMER = new BabyModelTransformer(false, 1.00F, 0.6F, Set.of(EntityModelPartNames.HEAD)); - - public CapybaraEntityModel(ModelPart part) { - super(part.getChild(EntityModelPartNames.ROOT)); - this.head = this.root.getChild(EntityModelPartNames.HEAD); - this.walkingAnimation = CapybaraAnimations.WALKING.createAnimation(this.root); - this.earWiggleAnimation = CapybaraAnimations.EAR_WIGGLE.createAnimation(this.root); - this.fallToSleepAnimation = CapybaraAnimations.FALL_TO_SLEEP.createAnimation(this.root); - this.sleepingAnimation = CapybaraAnimations.SLEEP.createAnimation(this.root); - this.wakeUpAnimation = CapybaraAnimations.WAKE_UP.createAnimation(this.root); - this.fartAnimation = CapybaraAnimations.FART.createAnimation(this.root); - } - - public static TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData modelPartData = modelData.getRoot(); - ModelPartData root = modelPartData.addChild(EntityModelPartNames.ROOT, ModelPartBuilder.create(), ModelTransform.origin(0.5F, 14.5F, 0.5F)); - - root.addChild(EntityModelPartNames.RIGHT_HIND_LEG, ModelPartBuilder.create().uv(31, 0).cuboid(-1.5F, 0.0F, -0.5F, 3.0F, 7.0F, 3.0F), ModelTransform.origin(1.5F, 2.5F, 5.5F)); - root.addChild(EntityModelPartNames.LEFT_HIND_LEG, ModelPartBuilder.create().uv(0, 0).cuboid(-1.5F, 0.0F, -0.5F, 3.0F, 7.0F, 3.0F), ModelTransform.origin(-2.5F, 2.5F, 5.5F)); - root.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, ModelPartBuilder.create().uv(0, 36).cuboid(-1.5F, -1.0F, -2.0F, 3.0F, 6.0F, 3.0F), ModelTransform.origin(1.5F, 4.5F, -4.5F)); - root.addChild(EntityModelPartNames.LEFT_FRONT_LEG, ModelPartBuilder.create().uv(12, 36).cuboid(-1.5F, -1.0F, -2.0F, 3.0F, 6.0F, 3.0F), ModelTransform.origin(-2.5F, 4.5F, -4.5F)); - - root.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create().uv(0, 0).cuboid(-4.0F, -4.0F, -7.5F, 8.0F, 8.0F, 15.0F), ModelTransform.origin(-0.5F, 0.5F, 0.0F)); - ModelPartData head = root.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create() - .uv(20, 23).cuboid(-3.0F, 1.0F, -5.0F, 6.0F, 1.0F, 5.0F) - .uv(0, 23).cuboid(-3.0F, -4.0F, -8.0F, 6.0F, 5.0F, 8.0F), - ModelTransform.of(-0.5F, -2.5F, -6.5F, -0.0436F, 0.0F, 0.0F)); - ModelPartData jaw = head.addChild(EntityModelPartNames.JAW, ModelPartBuilder.create().uv(28, 29).cuboid(-3.0F, 0.0F, -3.0F, 6.0F, 1.0F, 3.0F), ModelTransform.origin(0.0F, 1.0F, -5.0F)); - - head.addChild(EntityModelPartNames.LEFT_EAR, ModelPartBuilder.create().uv(0, 10).cuboid(0.0F, -2.0F, 0.0F, 1.0F, 2.0F, 2.0F), ModelTransform.of(2.0F, -3.0F, -1.0F, -0.2F, 0.2F, 0.0F)); - head.addChild(EntityModelPartNames.RIGHT_EAR, ModelPartBuilder.create().uv(6, 10).cuboid(-1.0F, -2.0F, 0.0F, 1.0F, 2.0F, 2.0F), ModelTransform.of(-2.0F, -3.0F, -1.0F, -0.2F, -0.2F, 0.0F)); - head.addChild(UPPER_TEETH, ModelPartBuilder.create().uv(9, 0).cuboid(-1.0F, -0.25F, 0.0F, 2.0F, 1.0F, 0.0F), ModelTransform.origin(0.0F, 1.0F, -7.0F)); - jaw.addChild(LOWER_TEETH, ModelPartBuilder.create().uv(9, 1).cuboid(-1.0F, -0.75F, 0.0F, 2.0F, 1.0F, 0.0F), ModelTransform.origin(0.0F, 0.0F, -2.0F)); - - return TexturedModelData.of(modelData, 64, 64); - } - - @Override - public void setAngles(CapybaraEntityRenderState state) { - super.setAngles(state); - - // Head - if (state.canAngleHead) { - this.head.pitch = state.pitch * (float) (Math.PI / 180.0); - this.head.yaw = state.relativeHeadYaw * (float) (Math.PI / 180.0); - } - - // Dynamic animations - this.walkingAnimation.applyWalking(state.limbSwingAnimationProgress, state.limbSwingAmplitude, 4.0F, 2.5F); - - // Custom animations - this.earWiggleAnimation.apply(state.earWiggleAnimState, state.age, state.earWiggleSpeed); - this.fallToSleepAnimation.apply(state.fallToSleepAnimState, state.age); - this.sleepingAnimation.apply(state.sleepingAnimState, state.age); - this.wakeUpAnimation.apply(state.wakeUpAnimState, state.age); - this.fartAnimation.apply(state.fartAnimState, state.age); - } + private static final String LOWER_TEETH = "lower_teeth"; + private static final String UPPER_TEETH = "upper_teeth"; + + private final ModelPart head; + + private final Animation walkingAnimation; + private final Animation earWiggleAnimation; + private final Animation fallToSleepAnimation; + private final Animation sleepingAnimation; + private final Animation wakeUpAnimation; + private final Animation fartAnimation; + + public static final ModelTransformer BABY_TRANSFORMER = new BabyModelTransformer(false, 1.00F, 0.6F, Set.of(EntityModelPartNames.HEAD)); + + public CapybaraEntityModel(ModelPart part) { + super(part.getChild(EntityModelPartNames.ROOT)); + this.head = this.root.getChild(EntityModelPartNames.HEAD); + this.walkingAnimation = CapybaraAnimations.WALKING.createAnimation(this.root); + this.earWiggleAnimation = CapybaraAnimations.EAR_WIGGLE.createAnimation(this.root); + this.fallToSleepAnimation = CapybaraAnimations.FALL_TO_SLEEP.createAnimation(this.root); + this.sleepingAnimation = CapybaraAnimations.SLEEP.createAnimation(this.root); + this.wakeUpAnimation = CapybaraAnimations.WAKE_UP.createAnimation(this.root); + this.fartAnimation = CapybaraAnimations.FART.createAnimation(this.root); + } + + public static TexturedModelData getTexturedModelData() { + ModelData modelData = new ModelData(); + ModelPartData modelPartData = modelData.getRoot(); + ModelPartData root = modelPartData.addChild(EntityModelPartNames.ROOT, ModelPartBuilder.create(), ModelTransform.origin(0.5F, 14.5F, 0.5F)); + + root.addChild(EntityModelPartNames.RIGHT_HIND_LEG, ModelPartBuilder.create().uv(31, 0).cuboid(- 1.5F, 0.0F, - 0.5F, 3.0F, 7.0F, 3.0F), ModelTransform.origin(1.5F, 2.5F, 5.5F)); + root.addChild(EntityModelPartNames.LEFT_HIND_LEG, ModelPartBuilder.create().uv(0, 0).cuboid(- 1.5F, 0.0F, - 0.5F, 3.0F, 7.0F, 3.0F), ModelTransform.origin(- 2.5F, 2.5F, 5.5F)); + root.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, ModelPartBuilder.create().uv(0, 36).cuboid(- 1.5F, - 1.0F, - 2.0F, 3.0F, 6.0F, 3.0F), ModelTransform.origin(1.5F, 4.5F, - 4.5F)); + root.addChild(EntityModelPartNames.LEFT_FRONT_LEG, ModelPartBuilder.create().uv(12, 36).cuboid(- 1.5F, - 1.0F, - 2.0F, 3.0F, 6.0F, 3.0F), ModelTransform.origin(- 2.5F, 4.5F, - 4.5F)); + + root.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create().uv(0, 0).cuboid(- 4.0F, - 4.0F, - 7.5F, 8.0F, 8.0F, 15.0F), ModelTransform.origin(- 0.5F, 0.5F, 0.0F)); + ModelPartData head = root.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create() + .uv(20, 23).cuboid(- 3.0F, 1.0F, - 5.0F, 6.0F, 1.0F, 5.0F) + .uv(0, 23).cuboid(- 3.0F, - 4.0F, - 8.0F, 6.0F, 5.0F, 8.0F), + ModelTransform.of(- 0.5F, - 2.5F, - 6.5F, - 0.0436F, 0.0F, 0.0F)); + ModelPartData jaw = head.addChild(EntityModelPartNames.JAW, ModelPartBuilder.create().uv(28, 29).cuboid(- 3.0F, 0.0F, - 3.0F, 6.0F, 1.0F, 3.0F), ModelTransform.origin(0.0F, 1.0F, - 5.0F)); + + head.addChild(EntityModelPartNames.LEFT_EAR, ModelPartBuilder.create().uv(0, 10).cuboid(0.0F, - 2.0F, 0.0F, 1.0F, 2.0F, 2.0F), ModelTransform.of(2.0F, - 3.0F, - 1.0F, - 0.2F, 0.2F, 0.0F)); + head.addChild(EntityModelPartNames.RIGHT_EAR, ModelPartBuilder.create().uv(6, 10).cuboid(- 1.0F, - 2.0F, 0.0F, 1.0F, 2.0F, 2.0F), ModelTransform.of(- 2.0F, - 3.0F, - 1.0F, - 0.2F, - 0.2F, 0.0F)); + head.addChild(UPPER_TEETH, ModelPartBuilder.create().uv(9, 0).cuboid(- 1.0F, - 0.25F, 0.0F, 2.0F, 1.0F, 0.0F), ModelTransform.origin(0.0F, 1.0F, - 7.0F)); + jaw.addChild(LOWER_TEETH, ModelPartBuilder.create().uv(9, 1).cuboid(- 1.0F, - 0.75F, 0.0F, 2.0F, 1.0F, 0.0F), ModelTransform.origin(0.0F, 0.0F, - 2.0F)); + + return TexturedModelData.of(modelData, 64, 64); + } + + @Override + public void setAngles(CapybaraEntityRenderState state) { + super.setAngles(state); + + // Head + if (state.canAngleHead) { + this.head.pitch = state.pitch * (float) (Math.PI / 180.0); + this.head.yaw = state.relativeHeadYaw * (float) (Math.PI / 180.0); + } + + // Dynamic animations + this.walkingAnimation.applyWalking(state.limbSwingAnimationProgress, state.limbSwingAmplitude, 4.0F, 2.5F); + + // Custom animations + this.earWiggleAnimation.apply(state.earWiggleAnimState, state.age, state.earWiggleSpeed); + this.fallToSleepAnimation.apply(state.fallToSleepAnimState, state.age); + this.sleepingAnimation.apply(state.sleepingAnimState, state.age); + this.wakeUpAnimation.apply(state.wakeUpAnimState, state.age); + this.fartAnimation.apply(state.fartAnimState, state.age); + } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/DuckEntityModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/DuckEntityModel.java index 673faffa..4a42cc5b 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/model/DuckEntityModel.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/DuckEntityModel.java @@ -1,8 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity.model; -import fr.hugman.promenade.client.render.entity.state.DuckEntityRenderState; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import java.util.Set; + import net.minecraft.client.model.*; import net.minecraft.client.render.entity.model.BabyModelTransformer; import net.minecraft.client.render.entity.model.EntityModel; @@ -10,57 +20,60 @@ import net.minecraft.client.render.entity.model.ModelTransformer; import net.minecraft.util.math.MathHelper; -import java.util.Set; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import fr.hugman.promenade.client.render.entity.state.DuckEntityRenderState; @Environment(EnvType.CLIENT) public class DuckEntityModel extends EntityModel { - public static final ModelTransformer BABY_TRANSFORMER = new BabyModelTransformer(Set.of(EntityModelPartNames.HEAD, EntityModelPartNames.BEAK)); + public static final ModelTransformer BABY_TRANSFORMER = new BabyModelTransformer(Set.of(EntityModelPartNames.HEAD, EntityModelPartNames.BEAK)); - private final ModelPart head; - private final ModelPart rightLeg; - private final ModelPart leftLeg; - private final ModelPart rightWing; - private final ModelPart leftWing; + private final ModelPart head; + private final ModelPart rightLeg; + private final ModelPart leftLeg; + private final ModelPart rightWing; + private final ModelPart leftWing; - public DuckEntityModel(ModelPart root) { - super(root); - this.head = root.getChild(EntityModelPartNames.HEAD); - this.rightLeg = root.getChild(EntityModelPartNames.RIGHT_LEG); - this.leftLeg = root.getChild(EntityModelPartNames.LEFT_LEG); - this.rightWing = root.getChild(EntityModelPartNames.RIGHT_WING); - this.leftWing = root.getChild(EntityModelPartNames.LEFT_WING); - } + public DuckEntityModel(ModelPart root) { + super(root); + this.head = root.getChild(EntityModelPartNames.HEAD); + this.rightLeg = root.getChild(EntityModelPartNames.RIGHT_LEG); + this.leftLeg = root.getChild(EntityModelPartNames.LEFT_LEG); + this.rightWing = root.getChild(EntityModelPartNames.RIGHT_WING); + this.leftWing = root.getChild(EntityModelPartNames.LEFT_WING); + } - public static TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData root = modelData.getRoot(); + public static TexturedModelData getTexturedModelData() { + ModelData modelData = new ModelData(); + ModelPartData root = modelData.getRoot(); - var head = root.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create().uv(0, 0).cuboid(-2.0F, -10.0F, -2.0F, 4.0F, 10.0F, 3.0F), ModelTransform.origin(0.0F, 15.0F, -4.0F)); - head.addChild(EntityModelPartNames.BEAK, ModelPartBuilder.create().uv(14, 0).cuboid(-2.0F, -8.0F, -5.0F, 4.0F, 2.0F, 3.0F), ModelTransform.NONE); - root.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create().uv(0, 13).cuboid(-3.0F, -4.0F, -3.0F, 6.0F, 8.0F, 6.0F), ModelTransform.origin(0.0F, 16.0F, 0.0F)); - root.addChild(EntityModelPartNames.RIGHT_LEG, ModelPartBuilder.create().uv(28, 0).cuboid(-1.0F, 0.0F, -3.0F, 3.0F, 5.0F, 3.0F), ModelTransform.origin(-2.0F, 19.0F, 1.0F)); - root.addChild(EntityModelPartNames.LEFT_LEG, ModelPartBuilder.create().uv(28, 0).cuboid(-1.0F, 0.0F, -3.0F, 3.0F, 5.0F, 3.0F), ModelTransform.origin(1.0F, 19.0F, 1.0F)); - root.addChild(EntityModelPartNames.RIGHT_WING, ModelPartBuilder.create().uv(24, 17).cuboid(0.0F, 0.0F, -3.0F, 1.0F, 4.0F, 6.0F), ModelTransform.origin(-4.0F, 13.0F, 0.0F)); - root.addChild(EntityModelPartNames.LEFT_WING, ModelPartBuilder.create().uv(24, 17).cuboid(-1.0F, 0.0F, -3.0F, 1.0F, 4.0F, 6.0F), ModelTransform.origin(4.0F, 13.0F, 0.0F)); - return TexturedModelData.of(modelData, 64, 32); - } + var head = root.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create().uv(0, 0).cuboid(- 2.0F, - 10.0F, - 2.0F, 4.0F, 10.0F, 3.0F), ModelTransform.origin(0.0F, 15.0F, - 4.0F)); + head.addChild(EntityModelPartNames.BEAK, ModelPartBuilder.create().uv(14, 0).cuboid(- 2.0F, - 8.0F, - 5.0F, 4.0F, 2.0F, 3.0F), ModelTransform.NONE); + root.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create().uv(0, 13).cuboid(- 3.0F, - 4.0F, - 3.0F, 6.0F, 8.0F, 6.0F), ModelTransform.origin(0.0F, 16.0F, 0.0F)); + root.addChild(EntityModelPartNames.RIGHT_LEG, ModelPartBuilder.create().uv(28, 0).cuboid(- 1.0F, 0.0F, - 3.0F, 3.0F, 5.0F, 3.0F), ModelTransform.origin(- 2.0F, 19.0F, 1.0F)); + root.addChild(EntityModelPartNames.LEFT_LEG, ModelPartBuilder.create().uv(28, 0).cuboid(- 1.0F, 0.0F, - 3.0F, 3.0F, 5.0F, 3.0F), ModelTransform.origin(1.0F, 19.0F, 1.0F)); + root.addChild(EntityModelPartNames.RIGHT_WING, ModelPartBuilder.create().uv(24, 17).cuboid(0.0F, 0.0F, - 3.0F, 1.0F, 4.0F, 6.0F), ModelTransform.origin(- 4.0F, 13.0F, 0.0F)); + root.addChild(EntityModelPartNames.LEFT_WING, ModelPartBuilder.create().uv(24, 17).cuboid(- 1.0F, 0.0F, - 3.0F, 1.0F, 4.0F, 6.0F), ModelTransform.origin(4.0F, 13.0F, 0.0F)); + return TexturedModelData.of(modelData, 64, 32); + } - public void setAngles(DuckEntityRenderState state) { - super.setAngles(state); + public void setAngles(DuckEntityRenderState state) { + super.setAngles(state); - // Head - this.head.pitch = state.pitch * (float) (Math.PI / 180.0); - this.head.yaw = state.relativeHeadYaw * (float) (Math.PI / 180.0); + // Head + this.head.pitch = state.pitch * (float) (Math.PI / 180.0); + this.head.yaw = state.relativeHeadYaw * (float) (Math.PI / 180.0); - // Legs - float g = state.limbSwingAmplitude; - float h = state.limbSwingAnimationProgress; - this.rightLeg.pitch = MathHelper.cos(h * 0.6662F) * 1.4F * g; - this.leftLeg.pitch = MathHelper.cos(h * 0.6662F + (float) Math.PI) * 1.4F * g; + // Legs + float g = state.limbSwingAmplitude; + float h = state.limbSwingAnimationProgress; + this.rightLeg.pitch = MathHelper.cos(h * 0.6662F) * 1.4F * g; + this.leftLeg.pitch = MathHelper.cos(h * 0.6662F + (float) Math.PI) * 1.4F * g; - // Wings - float f = (MathHelper.sin(state.flapProgress) + 1.0F) * state.maxWingDeviation; - this.rightWing.roll = f; - this.leftWing.roll = -f; - } + // Wings + float f = (MathHelper.sin(state.flapProgress) + 1.0F) * state.maxWingDeviation; + this.rightWing.roll = f; + this.leftWing.roll = - f; + } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/PromenadeEntityModelLayers.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/PromenadeEntityModelLayers.java index b704d1fa..e19bdf0a 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/model/PromenadeEntityModelLayers.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/PromenadeEntityModelLayers.java @@ -1,80 +1,93 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity.model; -import fr.hugman.promenade.Promenade; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; import net.minecraft.client.model.Dilation; import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.render.entity.model.*; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; + +import fr.hugman.promenade.Promenade; + @Environment(EnvType.CLIENT) public class PromenadeEntityModelLayers { - public static final EntityModelLayer SAKURA_BOAT = ofMain("boat/sakura"); - public static final EntityModelLayer SAKURA_CHEST_BOAT = ofMain("chest_boat/sakura"); - public static final EntityModelLayer MAPLE_BOAT = ofMain("boat/maple"); - public static final EntityModelLayer MAPLE_CHEST_BOAT = ofMain("chest_boat/maple"); - public static final EntityModelLayer PALM_BOAT = ofMain("boat/palm"); - public static final EntityModelLayer PALM_CHEST_BOAT = ofMain("chest_boat/palm"); + public static final EntityModelLayer SAKURA_BOAT = ofMain("boat/sakura"); + public static final EntityModelLayer SAKURA_CHEST_BOAT = ofMain("chest_boat/sakura"); + public static final EntityModelLayer MAPLE_BOAT = ofMain("boat/maple"); + public static final EntityModelLayer MAPLE_CHEST_BOAT = ofMain("chest_boat/maple"); + public static final EntityModelLayer PALM_BOAT = ofMain("boat/palm"); + public static final EntityModelLayer PALM_CHEST_BOAT = ofMain("chest_boat/palm"); - public static final EntityModelLayer CAPYBARA = ofMain("capybara"); - public static final EntityModelLayer CAPYBARA_BABY = ofMain("capybara_baby"); + public static final EntityModelLayer CAPYBARA = ofMain("capybara"); + public static final EntityModelLayer CAPYBARA_BABY = ofMain("capybara_baby"); - public static final EntityModelLayer DUCK = ofMain("duck"); - public static final EntityModelLayer DUCK_BABY = ofMain("duck_baby"); + public static final EntityModelLayer DUCK = ofMain("duck"); + public static final EntityModelLayer DUCK_BABY = ofMain("duck_baby"); - public static final EntityModelLayer LUSH_CREEPER = ofMain("lush_creeper"); - public static final EntityModelLayer LUSH_CREEPER_OUTER = of("lush_creeper", "outer"); + public static final EntityModelLayer LUSH_CREEPER = ofMain("lush_creeper"); + public static final EntityModelLayer LUSH_CREEPER_OUTER = of("lush_creeper", "outer"); - public static final EntityModelLayer SUNKEN = ofMain("sunken"); - public static final EquipmentModelData SUNKEN_EQUIPMENT = equipment("stray"); + public static final EntityModelLayer SUNKEN = ofMain("sunken"); + public static final EquipmentModelData SUNKEN_EQUIPMENT = equipment("stray"); - private static final Dilation ARMOR_DILATION = new Dilation(1.0F); - private static final Dilation HAT_DILATION = new Dilation(0.5F); - private static final TexturedModelData INNER_ARMOR_MODEL_DATA = TexturedModelData.of(BipedEntityModel.getModelData(HAT_DILATION, 0.0F), 64, 32); - private static final TexturedModelData OUTER_ARMOR_MODEL_DATA = TexturedModelData.of(BipedEntityModel.getModelData(ARMOR_DILATION, 0.0F), 64, 32); + private static final Dilation ARMOR_DILATION = new Dilation(1.0F); + private static final Dilation HAT_DILATION = new Dilation(0.5F); + private static final TexturedModelData INNER_ARMOR_MODEL_DATA = TexturedModelData.of(BipedEntityModel.getModelData(HAT_DILATION, 0.0F), 64, 32); + private static final TexturedModelData OUTER_ARMOR_MODEL_DATA = TexturedModelData.of(BipedEntityModel.getModelData(ARMOR_DILATION, 0.0F), 64, 32); - public static void register() { - EquipmentModelData equipmentModelData = BipedEntityModel.createEquipmentModelData(HAT_DILATION, ARMOR_DILATION).map((data) -> TexturedModelData.of(data, 64, 32)); + public static void register() { + EquipmentModelData equipmentModelData = BipedEntityModel.createEquipmentModelData(HAT_DILATION, ARMOR_DILATION).map((data) -> TexturedModelData.of(data, 64, 32)); - var capybaraModelData = CapybaraEntityModel.getTexturedModelData(); - EntityModelLayerRegistry.registerModelLayer(CAPYBARA, () -> capybaraModelData); - EntityModelLayerRegistry.registerModelLayer(CAPYBARA_BABY, () -> capybaraModelData.transform(CapybaraEntityModel.BABY_TRANSFORMER)); + var capybaraModelData = CapybaraEntityModel.getTexturedModelData(); + EntityModelLayerRegistry.registerModelLayer(CAPYBARA, () -> capybaraModelData); + EntityModelLayerRegistry.registerModelLayer(CAPYBARA_BABY, () -> capybaraModelData.transform(CapybaraEntityModel.BABY_TRANSFORMER)); - var duckModelData = DuckEntityModel.getTexturedModelData(); + var duckModelData = DuckEntityModel.getTexturedModelData(); - EntityModelLayerRegistry.registerModelLayer(DUCK, () -> duckModelData); - EntityModelLayerRegistry.registerModelLayer(DUCK_BABY, () -> duckModelData.transform(DuckEntityModel.BABY_TRANSFORMER)); + EntityModelLayerRegistry.registerModelLayer(DUCK, () -> duckModelData); + EntityModelLayerRegistry.registerModelLayer(DUCK_BABY, () -> duckModelData.transform(DuckEntityModel.BABY_TRANSFORMER)); - EntityModelLayerRegistry.registerModelLayer(LUSH_CREEPER, () -> CreeperEntityModel.getTexturedModelData(Dilation.NONE)); - EntityModelLayerRegistry.registerModelLayer(LUSH_CREEPER_OUTER, () -> CreeperEntityModel.getTexturedModelData(new Dilation(0.25f))); + EntityModelLayerRegistry.registerModelLayer(LUSH_CREEPER, () -> CreeperEntityModel.getTexturedModelData(Dilation.NONE)); + EntityModelLayerRegistry.registerModelLayer(LUSH_CREEPER_OUTER, () -> CreeperEntityModel.getTexturedModelData(new Dilation(0.25f))); - EntityModelLayerRegistry.registerModelLayer(SUNKEN, SunkenEntityModel::getTexturedModelData); - EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.head(), equipmentModelData::head); - EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.chest(), equipmentModelData::chest); - EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.legs(), equipmentModelData::legs); - EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.feet(), equipmentModelData::feet); + EntityModelLayerRegistry.registerModelLayer(SUNKEN, SunkenEntityModel::getTexturedModelData); + EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.head(), equipmentModelData::head); + EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.chest(), equipmentModelData::chest); + EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.legs(), equipmentModelData::legs); + EntityModelLayerRegistry.registerModelLayer(SUNKEN_EQUIPMENT.feet(), equipmentModelData::feet); - TexturedModelData boatModel = BoatEntityModel.getTexturedModelData(); - TexturedModelData chestBoatModel = BoatEntityModel.getChestTexturedModelData(); - EntityModelLayerRegistry.registerModelLayer(SAKURA_BOAT, () -> boatModel); - EntityModelLayerRegistry.registerModelLayer(SAKURA_CHEST_BOAT, () -> chestBoatModel); - EntityModelLayerRegistry.registerModelLayer(MAPLE_BOAT, () -> boatModel); - EntityModelLayerRegistry.registerModelLayer(MAPLE_CHEST_BOAT, () -> chestBoatModel); - EntityModelLayerRegistry.registerModelLayer(PALM_BOAT, () -> boatModel); - EntityModelLayerRegistry.registerModelLayer(PALM_CHEST_BOAT, () -> chestBoatModel); - } + TexturedModelData boatModel = BoatEntityModel.getTexturedModelData(); + TexturedModelData chestBoatModel = BoatEntityModel.getChestTexturedModelData(); + EntityModelLayerRegistry.registerModelLayer(SAKURA_BOAT, () -> boatModel); + EntityModelLayerRegistry.registerModelLayer(SAKURA_CHEST_BOAT, () -> chestBoatModel); + EntityModelLayerRegistry.registerModelLayer(MAPLE_BOAT, () -> boatModel); + EntityModelLayerRegistry.registerModelLayer(MAPLE_CHEST_BOAT, () -> chestBoatModel); + EntityModelLayerRegistry.registerModelLayer(PALM_BOAT, () -> boatModel); + EntityModelLayerRegistry.registerModelLayer(PALM_CHEST_BOAT, () -> chestBoatModel); + } - private static EntityModelLayer of(String name, String layer) { - return new EntityModelLayer(Promenade.id(name), layer); - } + private static EntityModelLayer of(String name, String layer) { + return new EntityModelLayer(Promenade.id(name), layer); + } - private static EntityModelLayer ofMain(String name) { - return of(name, "main"); - } + private static EntityModelLayer ofMain(String name) { + return of(name, "main"); + } - private static EquipmentModelData equipment(String id) { - return new EquipmentModelData(of(id, "helmet"), of(id, "chestplate"), of(id, "leggings"), of(id, "boots")); - } + private static EquipmentModelData equipment(String id) { + return new EquipmentModelData(of(id, "helmet"), of(id, "chestplate"), of(id, "leggings"), of(id, "boots")); + } } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/model/SunkenEntityModel.java b/src/client/java/fr/hugman/promenade/client/render/entity/model/SunkenEntityModel.java index 2d5541e1..3fbcad4c 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/model/SunkenEntityModel.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/model/SunkenEntityModel.java @@ -1,31 +1,44 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity.model; -import fr.hugman.promenade.client.render.entity.state.SunkenEntityRenderState; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.model.*; import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.client.render.entity.model.EntityModelPartNames; import net.minecraft.client.render.entity.model.SkeletonEntityModel; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import fr.hugman.promenade.client.render.entity.state.SunkenEntityRenderState; + @Environment(EnvType.CLIENT) public class SunkenEntityModel extends SkeletonEntityModel { - public SunkenEntityModel(ModelPart root) { - super(root); - } + public SunkenEntityModel(ModelPart root) { + super(root); + } - public static TexturedModelData getTexturedModelData() { - ModelData modelData = BipedEntityModel.getModelData(Dilation.NONE, 0.0F); - ModelPartData root = modelData.getRoot(); - SkeletonEntityModel.addLimbs(root); - modelData.getRoot().getChild(EntityModelPartNames.HEAD) - .addChild(EntityModelPartNames.HAT, ModelPartBuilder.create().uv(32, 0).cuboid(-4.0F, -16.0F, -4.0F, 16.0F, 16.0F, 0.0F), ModelTransform.origin(0.0F, 0.0F, 0.0F)); - return TexturedModelData.of(modelData, 64, 32); - } + public static TexturedModelData getTexturedModelData() { + ModelData modelData = BipedEntityModel.getModelData(Dilation.NONE, 0.0F); + ModelPartData root = modelData.getRoot(); + SkeletonEntityModel.addLimbs(root); + modelData.getRoot().getChild(EntityModelPartNames.HEAD) + .addChild(EntityModelPartNames.HAT, ModelPartBuilder.create().uv(32, 0).cuboid(- 4.0F, - 16.0F, - 4.0F, 16.0F, 16.0F, 0.0F), ModelTransform.origin(0.0F, 0.0F, 0.0F)); + return TexturedModelData.of(modelData, 64, 32); + } - @Override - public void setAngles(SunkenEntityRenderState state) { - super.setAngles(state); - this.hat.visible = state.equippedHeadStack.isEmpty(); - } + @Override + public void setAngles(SunkenEntityRenderState state) { + super.setAngles(state); + this.hat.visible = state.equippedHeadStack.isEmpty(); + } } \ No newline at end of file diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraEntityRenderState.java b/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraEntityRenderState.java index 1fdb9a98..7c2a29f3 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraEntityRenderState.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/state/CapybaraEntityRenderState.java @@ -1,25 +1,39 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity.state; -import fr.hugman.promenade.entity.variant.CapybaraVariant; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import org.jetbrains.annotations.Nullable; + import net.minecraft.client.render.entity.state.LivingEntityRenderState; import net.minecraft.entity.AnimationState; -import org.jetbrains.annotations.Nullable; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import fr.hugman.promenade.entity.variant.CapybaraVariant; @Environment(EnvType.CLIENT) public class CapybaraEntityRenderState extends LivingEntityRenderState { - public final AnimationState earWiggleAnimState = new AnimationState(); - public final AnimationState fallToSleepAnimState = new AnimationState(); - public final AnimationState sleepingAnimState = new AnimationState(); - public final AnimationState wakeUpAnimState = new AnimationState(); - public final AnimationState fartAnimState = new AnimationState(); + public final AnimationState earWiggleAnimState = new AnimationState(); + public final AnimationState fallToSleepAnimState = new AnimationState(); + public final AnimationState sleepingAnimState = new AnimationState(); + public final AnimationState wakeUpAnimState = new AnimationState(); + public final AnimationState fartAnimState = new AnimationState(); - @Nullable - public CapybaraVariant variant; - public boolean closedEyes = false; - public boolean largeEyes = false; - public float earWiggleSpeed = 1.0f; + @Nullable + public CapybaraVariant variant; + public boolean closedEyes = false; + public boolean largeEyes = false; + public float earWiggleSpeed = 1.0f; - public boolean canAngleHead = true; + public boolean canAngleHead = true; } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/state/DuckEntityRenderState.java b/src/client/java/fr/hugman/promenade/client/render/entity/state/DuckEntityRenderState.java index 976d9e32..a1eeb701 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/state/DuckEntityRenderState.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/state/DuckEntityRenderState.java @@ -1,16 +1,30 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity.state; -import fr.hugman.promenade.entity.variant.DuckVariant; +import org.jetbrains.annotations.Nullable; + +import net.minecraft.client.render.entity.state.LivingEntityRenderState; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.state.LivingEntityRenderState; -import org.jetbrains.annotations.Nullable; + +import fr.hugman.promenade.entity.variant.DuckVariant; @Environment(EnvType.CLIENT) public class DuckEntityRenderState extends LivingEntityRenderState { - @Nullable - public DuckVariant variant; + @Nullable + public DuckVariant variant; - public float flapProgress; - public float maxWingDeviation; + public float flapProgress; + public float maxWingDeviation; } diff --git a/src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenEntityRenderState.java b/src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenEntityRenderState.java index c3e1e069..dbb32984 100644 --- a/src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenEntityRenderState.java +++ b/src/client/java/fr/hugman/promenade/client/render/entity/state/SunkenEntityRenderState.java @@ -1,13 +1,27 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.client.render.entity.state; -import fr.hugman.promenade.entity.variant.SunkenVariant; +import org.jetbrains.annotations.Nullable; + +import net.minecraft.client.render.entity.state.SkeletonEntityRenderState; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.state.SkeletonEntityRenderState; -import org.jetbrains.annotations.Nullable; + +import fr.hugman.promenade.entity.variant.SunkenVariant; @Environment(EnvType.CLIENT) public class SunkenEntityRenderState extends SkeletonEntityRenderState { - @Nullable - public SunkenVariant variant; + @Nullable + public SunkenVariant variant; } diff --git a/src/client/resources/assets/promenade/lang/en_us.json b/src/client/resources/assets/promenade/lang/en_us.json index d6dc952a..4730ac50 100644 --- a/src/client/resources/assets/promenade/lang/en_us.json +++ b/src/client/resources/assets/promenade/lang/en_us.json @@ -199,7 +199,6 @@ "block.promenade.banner.bovine.red": "Red Bovine", "block.promenade.banner.bovine.white": "White Bovine", "block.promenade.banner.bovine.yellow": "Yellow Bovine", - "item.promenade.capybara_spawn_egg": "Capybara Spawn Egg", "item.promenade.duck_spawn_egg": "Duck Spawn Egg", "item.promenade.lush_creeper_spawn_egg": "Lush Creeper Spawn Egg", @@ -236,4 +235,4 @@ "death.fell.accident.coiled_vines": "%1$s fell off some coiled vines", "gamerule.doBlocksGetSnowy": "Blocks can get snowy", "gamerule.doBlocksGetSnowy.description": "Some blocks may turn into snowy variants when they are covered by a snow layer" -} \ No newline at end of file +} diff --git a/src/datagen/java/fr/hugman/promenade/data/PromenadeBlockFamilies.java b/src/datagen/java/fr/hugman/promenade/data/PromenadeBlockFamilies.java index fa8e5bc0..e22c7d05 100644 --- a/src/datagen/java/fr/hugman/promenade/data/PromenadeBlockFamilies.java +++ b/src/datagen/java/fr/hugman/promenade/data/PromenadeBlockFamilies.java @@ -1,117 +1,130 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data; +import java.util.Map; +import java.util.stream.Stream; + import com.google.common.collect.Maps; -import fr.hugman.promenade.block.PromenadeBlocks; + import net.minecraft.block.Block; import net.minecraft.data.family.BlockFamily; import net.minecraft.registry.Registries; -import java.util.Map; -import java.util.stream.Stream; +import fr.hugman.promenade.block.PromenadeBlocks; public class PromenadeBlockFamilies { - private static final Map BASE_BLOCKS_TO_FAMILIES = Maps.newHashMap(); - - /** - * The group used for the recipes of wooden block families. - */ - private static final String WOODEN_GROUP = "wooden"; - /** - * The name of the criterion used for the recipe unlock advancements of wooden block families. - */ - private static final String WOODEN_UNLOCK_CRITERION_NAME = "has_planks"; - - public static final BlockFamily ASPHALT = register(PromenadeBlocks.ASPHALT) - .wall(PromenadeBlocks.ASPHALT_WALL) - .stairs(PromenadeBlocks.ASPHALT_STAIRS) - .slab(PromenadeBlocks.ASPHALT_SLAB) - .polished(PromenadeBlocks.POLISHED_ASPHALT) - .build(); - public static final BlockFamily POLISHED_ASPHALT = register(PromenadeBlocks.POLISHED_ASPHALT) - .stairs(PromenadeBlocks.POLISHED_ASPHALT_STAIRS) - .slab(PromenadeBlocks.POLISHED_ASPHALT_SLAB) - .build(); - - public static final BlockFamily BLUNITE = register(PromenadeBlocks.BLUNITE) - .wall(PromenadeBlocks.BLUNITE_WALL) - .stairs(PromenadeBlocks.BLUNITE_STAIRS) - .slab(PromenadeBlocks.BLUNITE_SLAB) - .polished(PromenadeBlocks.POLISHED_BLUNITE) - .build(); - - public static final BlockFamily POLISHED_BLUNITE = register(PromenadeBlocks.POLISHED_BLUNITE) - .stairs(PromenadeBlocks.POLISHED_BLUNITE_STAIRS) - .slab(PromenadeBlocks.POLISHED_BLUNITE_SLAB) - .build(); - - public static final BlockFamily SAKURA = register(PromenadeBlocks.SAKURA_PLANKS) - .button(PromenadeBlocks.SAKURA_BUTTON) - .fence(PromenadeBlocks.SAKURA_FENCE) - .fenceGate(PromenadeBlocks.SAKURA_FENCE_GATE) - .pressurePlate(PromenadeBlocks.SAKURA_PRESSURE_PLATE) - .sign(PromenadeBlocks.SAKURA_SIGN, PromenadeBlocks.SAKURA_WALL_SIGN) - .slab(PromenadeBlocks.SAKURA_SLAB) - .stairs(PromenadeBlocks.SAKURA_STAIRS) - .door(PromenadeBlocks.SAKURA_DOOR) - .trapdoor(PromenadeBlocks.SAKURA_TRAPDOOR) - .group(WOODEN_GROUP) - .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) - .build(); - - public static final BlockFamily MAPLE = register(PromenadeBlocks.MAPLE_PLANKS) - .button(PromenadeBlocks.MAPLE_BUTTON) - .fence(PromenadeBlocks.MAPLE_FENCE) - .fenceGate(PromenadeBlocks.MAPLE_FENCE_GATE) - .pressurePlate(PromenadeBlocks.MAPLE_PRESSURE_PLATE) - .sign(PromenadeBlocks.MAPLE_SIGN, PromenadeBlocks.MAPLE_WALL_SIGN) - .slab(PromenadeBlocks.MAPLE_SLAB) - .stairs(PromenadeBlocks.MAPLE_STAIRS) - .door(PromenadeBlocks.MAPLE_DOOR) - .trapdoor(PromenadeBlocks.MAPLE_TRAPDOOR) - .group(WOODEN_GROUP) - .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) - .build(); - - public static final BlockFamily PALM = register(PromenadeBlocks.PALM_PLANKS) - .button(PromenadeBlocks.PALM_BUTTON) - .fence(PromenadeBlocks.PALM_FENCE) - .fenceGate(PromenadeBlocks.PALM_FENCE_GATE) - .pressurePlate(PromenadeBlocks.PALM_PRESSURE_PLATE) - .sign(PromenadeBlocks.PALM_SIGN, PromenadeBlocks.PALM_WALL_SIGN) - .slab(PromenadeBlocks.PALM_SLAB) - .stairs(PromenadeBlocks.PALM_STAIRS) - .door(PromenadeBlocks.PALM_DOOR) - .trapdoor(PromenadeBlocks.PALM_TRAPDOOR) - .group(WOODEN_GROUP) - .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) - .build(); - - public static final BlockFamily DARK_AMARANTH = register(PromenadeBlocks.DARK_AMARANTH_PLANKS) - .button(PromenadeBlocks.DARK_AMARANTH_BUTTON) - .fence(PromenadeBlocks.DARK_AMARANTH_FENCE) - .fenceGate(PromenadeBlocks.DARK_AMARANTH_FENCE_GATE) - .pressurePlate(PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE) - .sign(PromenadeBlocks.DARK_AMARANTH_SIGN, PromenadeBlocks.DARK_AMARANTH_WALL_SIGN) - .slab(PromenadeBlocks.DARK_AMARANTH_SLAB) - .stairs(PromenadeBlocks.DARK_AMARANTH_STAIRS) - .door(PromenadeBlocks.DARK_AMARANTH_DOOR) - .trapdoor(PromenadeBlocks.DARK_AMARANTH_TRAPDOOR) - .group(WOODEN_GROUP) - .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) - .build(); - - - public static BlockFamily.Builder register(Block baseBlock) { - BlockFamily.Builder builder = new BlockFamily.Builder(baseBlock); - BlockFamily blockFamily = BASE_BLOCKS_TO_FAMILIES.put(baseBlock, builder.build()); - if (blockFamily != null) { - throw new IllegalStateException("Duplicate family definition for " + Registries.BLOCK.getId(baseBlock)); - } else { - return builder; - } - } - - public static Stream getFamilies() { - return BASE_BLOCKS_TO_FAMILIES.values().stream(); - } + private static final Map BASE_BLOCKS_TO_FAMILIES = Maps.newHashMap(); + + /** + * The group used for the recipes of wooden block families. + */ + private static final String WOODEN_GROUP = "wooden"; + /** + * The name of the criterion used for the recipe unlock advancements of wooden block families. + */ + private static final String WOODEN_UNLOCK_CRITERION_NAME = "has_planks"; + + public static final BlockFamily ASPHALT = register(PromenadeBlocks.ASPHALT) + .wall(PromenadeBlocks.ASPHALT_WALL) + .stairs(PromenadeBlocks.ASPHALT_STAIRS) + .slab(PromenadeBlocks.ASPHALT_SLAB) + .polished(PromenadeBlocks.POLISHED_ASPHALT) + .build(); + public static final BlockFamily POLISHED_ASPHALT = register(PromenadeBlocks.POLISHED_ASPHALT) + .stairs(PromenadeBlocks.POLISHED_ASPHALT_STAIRS) + .slab(PromenadeBlocks.POLISHED_ASPHALT_SLAB) + .build(); + + public static final BlockFamily BLUNITE = register(PromenadeBlocks.BLUNITE) + .wall(PromenadeBlocks.BLUNITE_WALL) + .stairs(PromenadeBlocks.BLUNITE_STAIRS) + .slab(PromenadeBlocks.BLUNITE_SLAB) + .polished(PromenadeBlocks.POLISHED_BLUNITE) + .build(); + + public static final BlockFamily POLISHED_BLUNITE = register(PromenadeBlocks.POLISHED_BLUNITE) + .stairs(PromenadeBlocks.POLISHED_BLUNITE_STAIRS) + .slab(PromenadeBlocks.POLISHED_BLUNITE_SLAB) + .build(); + + public static final BlockFamily SAKURA = register(PromenadeBlocks.SAKURA_PLANKS) + .button(PromenadeBlocks.SAKURA_BUTTON) + .fence(PromenadeBlocks.SAKURA_FENCE) + .fenceGate(PromenadeBlocks.SAKURA_FENCE_GATE) + .pressurePlate(PromenadeBlocks.SAKURA_PRESSURE_PLATE) + .sign(PromenadeBlocks.SAKURA_SIGN, PromenadeBlocks.SAKURA_WALL_SIGN) + .slab(PromenadeBlocks.SAKURA_SLAB) + .stairs(PromenadeBlocks.SAKURA_STAIRS) + .door(PromenadeBlocks.SAKURA_DOOR) + .trapdoor(PromenadeBlocks.SAKURA_TRAPDOOR) + .group(WOODEN_GROUP) + .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) + .build(); + + public static final BlockFamily MAPLE = register(PromenadeBlocks.MAPLE_PLANKS) + .button(PromenadeBlocks.MAPLE_BUTTON) + .fence(PromenadeBlocks.MAPLE_FENCE) + .fenceGate(PromenadeBlocks.MAPLE_FENCE_GATE) + .pressurePlate(PromenadeBlocks.MAPLE_PRESSURE_PLATE) + .sign(PromenadeBlocks.MAPLE_SIGN, PromenadeBlocks.MAPLE_WALL_SIGN) + .slab(PromenadeBlocks.MAPLE_SLAB) + .stairs(PromenadeBlocks.MAPLE_STAIRS) + .door(PromenadeBlocks.MAPLE_DOOR) + .trapdoor(PromenadeBlocks.MAPLE_TRAPDOOR) + .group(WOODEN_GROUP) + .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) + .build(); + + public static final BlockFamily PALM = register(PromenadeBlocks.PALM_PLANKS) + .button(PromenadeBlocks.PALM_BUTTON) + .fence(PromenadeBlocks.PALM_FENCE) + .fenceGate(PromenadeBlocks.PALM_FENCE_GATE) + .pressurePlate(PromenadeBlocks.PALM_PRESSURE_PLATE) + .sign(PromenadeBlocks.PALM_SIGN, PromenadeBlocks.PALM_WALL_SIGN) + .slab(PromenadeBlocks.PALM_SLAB) + .stairs(PromenadeBlocks.PALM_STAIRS) + .door(PromenadeBlocks.PALM_DOOR) + .trapdoor(PromenadeBlocks.PALM_TRAPDOOR) + .group(WOODEN_GROUP) + .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) + .build(); + + public static final BlockFamily DARK_AMARANTH = register(PromenadeBlocks.DARK_AMARANTH_PLANKS) + .button(PromenadeBlocks.DARK_AMARANTH_BUTTON) + .fence(PromenadeBlocks.DARK_AMARANTH_FENCE) + .fenceGate(PromenadeBlocks.DARK_AMARANTH_FENCE_GATE) + .pressurePlate(PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE) + .sign(PromenadeBlocks.DARK_AMARANTH_SIGN, PromenadeBlocks.DARK_AMARANTH_WALL_SIGN) + .slab(PromenadeBlocks.DARK_AMARANTH_SLAB) + .stairs(PromenadeBlocks.DARK_AMARANTH_STAIRS) + .door(PromenadeBlocks.DARK_AMARANTH_DOOR) + .trapdoor(PromenadeBlocks.DARK_AMARANTH_TRAPDOOR) + .group(WOODEN_GROUP) + .unlockCriterionName(WOODEN_UNLOCK_CRITERION_NAME) + .build(); + + + public static BlockFamily.Builder register(Block baseBlock) { + BlockFamily.Builder builder = new BlockFamily.Builder(baseBlock); + BlockFamily blockFamily = BASE_BLOCKS_TO_FAMILIES.put(baseBlock, builder.build()); + if (blockFamily != null) { + throw new IllegalStateException("Duplicate family definition for " + Registries.BLOCK.getId(baseBlock)); + } else { + return builder; + } + } + + public static Stream getFamilies() { + return BASE_BLOCKS_TO_FAMILIES.values().stream(); + } } diff --git a/src/datagen/java/fr/hugman/promenade/data/PromenadeDataGenerator.java b/src/datagen/java/fr/hugman/promenade/data/PromenadeDataGenerator.java index e3a502cf..1cea0e50 100644 --- a/src/datagen/java/fr/hugman/promenade/data/PromenadeDataGenerator.java +++ b/src/datagen/java/fr/hugman/promenade/data/PromenadeDataGenerator.java @@ -1,94 +1,108 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data; import com.google.common.reflect.Reflection; +import org.jetbrains.annotations.Nullable; + +import net.minecraft.registry.RegistryBuilder; +import net.minecraft.registry.RegistryKeys; + +import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; +import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; + import fr.hugman.promenade.Promenade; import fr.hugman.promenade.data.provider.*; import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; -import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; -import net.minecraft.registry.RegistryBuilder; -import net.minecraft.registry.RegistryKeys; -import org.jetbrains.annotations.Nullable; public class PromenadeDataGenerator implements DataGeneratorEntrypoint { - @Override - public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { - Reflection.initialize(PromenadeBlockFamilies.class); - - FabricDataGenerator.Pack pack = fabricDataGenerator.createPack(); - - // Resource Pack - pack.addProvider(PromenadeModelProvider::new); - pack.addProvider(PromenadeSoundsProvider::new); - - // Data Pack - - // - Modded stuff - pack.addProvider(PromenadeSnowyBlockTransformationProvider::new); - - // - Variants - pack.addProvider(PromenadeWolfVariantProvider::new); - pack.addProvider(PromenadeCapybaraVariantProvider::new); - pack.addProvider(PromenadeDuckVariantProvider::new); - pack.addProvider(PromenadeSunkenVariantProvider::new); - pack.addProvider(PromenadePaintingVariantProvider::new); - - // - World generation - pack.addProvider(PromenadeTemplatePoolProvider::new); - pack.addProvider(PromenadeStructureProvider::new); - pack.addProvider(PromenadeStructureSetProvider::new); - - pack.addProvider(PromenadeConfiguredFeatureProvider::new); - pack.addProvider(PromenadePlacedFeatureProvider::new); - pack.addProvider(PromenadeBiomeProvider::new); - - // - Loot tables - pack.addProvider(PromenadeBlockLootTableProvider::new); - pack.addProvider(PromenadeEntityLootTableProvider::new); - pack.addProvider(PromenadeChestLootTableProvider::new); - - // - Banner Patterns - pack.addProvider(PromenadeBannerPatternProvider::new); - - // - Tags - var blockTagProvider = pack.addProvider(PromenadeBlockTagProvider::new); - pack.addProvider((output, lookup) -> new PromenadeItemTagProvider(output, lookup, blockTagProvider)); - pack.addProvider(PromenadeBiomeTagProvider::new); - pack.addProvider(PromenadeEntityTypeTagProvider::new); - pack.addProvider(PromenadeBannerPatternTagProvider::new); - pack.addProvider(PromenadePaintingVariantTagProvider::new); - - // - Recipes - pack.addProvider(PromenadeRecipeGenerator::create); - - // - Advancements - pack.addProvider(PromenadeAdvancementProvider::new); - } - - @Override - public void buildRegistry(RegistryBuilder registryBuilder) { - registryBuilder.addRegistry(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, PromenadeSnowyBlockTransformationProvider::register); - - registryBuilder.addRegistry(RegistryKeys.WOLF_VARIANT, PromenadeWolfVariantProvider::register); - registryBuilder.addRegistry(PromenadeRegistryKeys.CAPYBARA_VARIANT, PromenadeCapybaraVariantProvider::register); - registryBuilder.addRegistry(PromenadeRegistryKeys.DUCK_VARIANT, PromenadeDuckVariantProvider::register); - registryBuilder.addRegistry(PromenadeRegistryKeys.SUNKEN_VARIANT, PromenadeSunkenVariantProvider::register); - registryBuilder.addRegistry(RegistryKeys.PAINTING_VARIANT, PromenadePaintingVariantProvider::register); - - registryBuilder.addRegistry(RegistryKeys.TEMPLATE_POOL, PromenadeTemplatePoolProvider::register); - registryBuilder.addRegistry(RegistryKeys.STRUCTURE, PromenadeStructureProvider::register); - registryBuilder.addRegistry(RegistryKeys.STRUCTURE_SET, PromenadeStructureSetProvider::register); - - registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, PromenadeConfiguredFeatureProvider::register); - registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, PromenadePlacedFeatureProvider::register); - registryBuilder.addRegistry(RegistryKeys.BIOME, PromenadeBiomeProvider::register); - - registryBuilder.addRegistry(RegistryKeys.BANNER_PATTERN, PromenadeBannerPatternProvider::register); - } - - @Override - @Nullable - public String getEffectiveModId() { - return Promenade.MOD_ID; - } + @Override + public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { + Reflection.initialize(PromenadeBlockFamilies.class); + + FabricDataGenerator.Pack pack = fabricDataGenerator.createPack(); + + // Resource Pack + pack.addProvider(PromenadeModelProvider::new); + pack.addProvider(PromenadeSoundsProvider::new); + + // Data Pack + + // - Modded stuff + pack.addProvider(PromenadeSnowyBlockTransformationProvider::new); + + // - Variants + pack.addProvider(PromenadeWolfVariantProvider::new); + pack.addProvider(PromenadeCapybaraVariantProvider::new); + pack.addProvider(PromenadeDuckVariantProvider::new); + pack.addProvider(PromenadeSunkenVariantProvider::new); + pack.addProvider(PromenadePaintingVariantProvider::new); + + // - World generation + pack.addProvider(PromenadeTemplatePoolProvider::new); + pack.addProvider(PromenadeStructureProvider::new); + pack.addProvider(PromenadeStructureSetProvider::new); + + pack.addProvider(PromenadeConfiguredFeatureProvider::new); + pack.addProvider(PromenadePlacedFeatureProvider::new); + pack.addProvider(PromenadeBiomeProvider::new); + + // - Loot tables + pack.addProvider(PromenadeBlockLootTableProvider::new); + pack.addProvider(PromenadeEntityLootTableProvider::new); + pack.addProvider(PromenadeChestLootTableProvider::new); + + // - Banner Patterns + pack.addProvider(PromenadeBannerPatternProvider::new); + + // - Tags + var blockTagProvider = pack.addProvider(PromenadeBlockTagProvider::new); + pack.addProvider((output, lookup) -> new PromenadeItemTagProvider(output, lookup, blockTagProvider)); + pack.addProvider(PromenadeBiomeTagProvider::new); + pack.addProvider(PromenadeEntityTypeTagProvider::new); + pack.addProvider(PromenadeBannerPatternTagProvider::new); + pack.addProvider(PromenadePaintingVariantTagProvider::new); + + // - Recipes + pack.addProvider(PromenadeRecipeGenerator::create); + + // - Advancements + pack.addProvider(PromenadeAdvancementProvider::new); + } + + @Override + public void buildRegistry(RegistryBuilder registryBuilder) { + registryBuilder.addRegistry(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, PromenadeSnowyBlockTransformationProvider::register); + + registryBuilder.addRegistry(RegistryKeys.WOLF_VARIANT, PromenadeWolfVariantProvider::register); + registryBuilder.addRegistry(PromenadeRegistryKeys.CAPYBARA_VARIANT, PromenadeCapybaraVariantProvider::register); + registryBuilder.addRegistry(PromenadeRegistryKeys.DUCK_VARIANT, PromenadeDuckVariantProvider::register); + registryBuilder.addRegistry(PromenadeRegistryKeys.SUNKEN_VARIANT, PromenadeSunkenVariantProvider::register); + registryBuilder.addRegistry(RegistryKeys.PAINTING_VARIANT, PromenadePaintingVariantProvider::register); + + registryBuilder.addRegistry(RegistryKeys.TEMPLATE_POOL, PromenadeTemplatePoolProvider::register); + registryBuilder.addRegistry(RegistryKeys.STRUCTURE, PromenadeStructureProvider::register); + registryBuilder.addRegistry(RegistryKeys.STRUCTURE_SET, PromenadeStructureSetProvider::register); + + registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, PromenadeConfiguredFeatureProvider::register); + registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, PromenadePlacedFeatureProvider::register); + registryBuilder.addRegistry(RegistryKeys.BIOME, PromenadeBiomeProvider::register); + + registryBuilder.addRegistry(RegistryKeys.BANNER_PATTERN, PromenadeBannerPatternProvider::register); + } + + @Override + @Nullable + public String getEffectiveModId() { + return Promenade.MOD_ID; + } } diff --git a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeModels.java b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeModels.java index d701533a..e7cb7bbd 100644 --- a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeModels.java +++ b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeModels.java @@ -1,33 +1,45 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.model; -import fr.hugman.promenade.Promenade; +import java.util.Optional; + import net.minecraft.client.data.Model; import net.minecraft.client.data.TextureKey; -import java.util.Optional; +import fr.hugman.promenade.Promenade; public class PromenadeModels { - public static final Model PILE = block("pile", TextureKey.ALL); - public static final Model FALLEN_LEAVES = block("fallen_leaves", TextureKey.ALL); - public static final Model BOTTOM_SNOWY_LEAVES = block("bottom_snowy_leaves", TextureKey.ALL, TextureKey.TOP, TextureKey.SIDE); + public static final Model PILE = block("pile", TextureKey.ALL); + public static final Model FALLEN_LEAVES = block("fallen_leaves", TextureKey.ALL); + public static final Model BOTTOM_SNOWY_LEAVES = block("bottom_snowy_leaves", TextureKey.ALL, TextureKey.TOP, TextureKey.SIDE); - private static Model make(TextureKey... requiredTextureKeys) { - return new Model(Optional.empty(), Optional.empty(), requiredTextureKeys); - } + private static Model make(TextureKey... requiredTextureKeys) { + return new Model(Optional.empty(), Optional.empty(), requiredTextureKeys); + } - private static Model block(String parent, TextureKey... requiredTextureKeys) { - return new Model(Optional.of(Promenade.id("block/" + parent)), Optional.empty(), requiredTextureKeys); - } + private static Model block(String parent, TextureKey... requiredTextureKeys) { + return new Model(Optional.of(Promenade.id("block/" + parent)), Optional.empty(), requiredTextureKeys); + } - private static Model item(String parent, TextureKey... requiredTextureKeys) { - return new Model(Optional.of(Promenade.id("item/" + parent)), Optional.empty(), requiredTextureKeys); - } + private static Model item(String parent, TextureKey... requiredTextureKeys) { + return new Model(Optional.of(Promenade.id("item/" + parent)), Optional.empty(), requiredTextureKeys); + } - private static Model openBundle(String parent, String variant, TextureKey... requiredTextureKeys) { - return new Model(Optional.of(Promenade.id("item/" + parent)), Optional.of(variant), requiredTextureKeys); - } + private static Model openBundle(String parent, String variant, TextureKey... requiredTextureKeys) { + return new Model(Optional.of(Promenade.id("item/" + parent)), Optional.of(variant), requiredTextureKeys); + } - private static Model block(String parent, String variant, TextureKey... requiredTextureKeys) { - return new Model(Optional.of(Promenade.id("block/" + parent)), Optional.of(variant), requiredTextureKeys); - } + private static Model block(String parent, String variant, TextureKey... requiredTextureKeys) { + return new Model(Optional.of(Promenade.id("block/" + parent)), Optional.of(variant), requiredTextureKeys); + } } diff --git a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTextureMaps.java b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTextureMaps.java index ff91932b..0e1694dd 100644 --- a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTextureMaps.java +++ b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTextureMaps.java @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.model; import net.minecraft.block.Block; @@ -6,19 +17,17 @@ import net.minecraft.util.Identifier; public class PromenadeTextureMaps { - public static TextureMap snowyLeaves(Block snowyLeaves, Block baseLeaves) { - return new TextureMap() - .put(TextureKey.ALL, TextureMap.getId(baseLeaves)) - .put(TextureKey.TOP, TextureMap.getId(snowyLeaves)) - .put(TextureKey.SIDE, TextureMap.getSubId(snowyLeaves, "_bottom")); - } + public static TextureMap snowyLeaves(Block snowyLeaves, Block baseLeaves) { + return new TextureMap() + .put(TextureKey.ALL, TextureMap.getId(baseLeaves)) + .put(TextureKey.TOP, TextureMap.getId(snowyLeaves)) + .put(TextureKey.SIDE, TextureMap.getSubId(snowyLeaves, "_bottom")); + } - - public static TextureMap snowyLeaves(Identifier snowyLeavesTexture, Block baseLeaves) { - - return new TextureMap() - .put(TextureKey.ALL, TextureMap.getId(baseLeaves)) - .put(TextureKey.TOP, snowyLeavesTexture) - .put(TextureKey.SIDE, snowyLeavesTexture.withSuffixedPath("_bottom")); - } + public static TextureMap snowyLeaves(Identifier snowyLeavesTexture, Block baseLeaves) { + return new TextureMap() + .put(TextureKey.ALL, TextureMap.getId(baseLeaves)) + .put(TextureKey.TOP, snowyLeavesTexture) + .put(TextureKey.SIDE, snowyLeavesTexture.withSuffixedPath("_bottom")); + } } diff --git a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTexturedModels.java b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTexturedModels.java index cf8e869a..e1841378 100644 --- a/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTexturedModels.java +++ b/src/datagen/java/fr/hugman/promenade/data/model/PromenadeTexturedModels.java @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.model; import net.minecraft.block.Block; @@ -5,14 +16,14 @@ import net.minecraft.client.data.TexturedModel; public class PromenadeTexturedModels { - public static final TexturedModel.Factory PILE = TexturedModel.makeFactory(TextureMap::all, PromenadeModels.PILE); - public static final TexturedModel.Factory FALLEN_LEAVES = TexturedModel.makeFactory(TextureMap::all, PromenadeModels.FALLEN_LEAVES); + public static final TexturedModel.Factory PILE = TexturedModel.makeFactory(TextureMap::all, PromenadeModels.PILE); + public static final TexturedModel.Factory FALLEN_LEAVES = TexturedModel.makeFactory(TextureMap::all, PromenadeModels.FALLEN_LEAVES); - public static TexturedModel.Factory pile(Block block) { - return TexturedModel.makeFactory(b -> TextureMap.all(block), PromenadeModels.PILE); - } + public static TexturedModel.Factory pile(Block block) { + return TexturedModel.makeFactory(b -> TextureMap.all(block), PromenadeModels.PILE); + } - public static TexturedModel.Factory fallenLeaves(Block block) { - return TexturedModel.makeFactory(b -> TextureMap.all(block), PromenadeModels.FALLEN_LEAVES); - } + public static TexturedModel.Factory fallenLeaves(Block block) { + return TexturedModel.makeFactory(b -> TextureMap.all(block), PromenadeModels.FALLEN_LEAVES); + } } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/DataProviderUtil.java b/src/datagen/java/fr/hugman/promenade/data/provider/DataProviderUtil.java index 11f6a1b5..3a68765a 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/DataProviderUtil.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/DataProviderUtil.java @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; import net.minecraft.entity.spawn.BiomeSpawnCondition; @@ -6,7 +17,7 @@ import net.minecraft.world.biome.Biome; public final class DataProviderUtil { - public static SpawnConditionSelectors createSpawnConditions(RegistryEntryList requiredBiomes) { - return SpawnConditionSelectors.createSingle(new BiomeSpawnCondition(requiredBiomes), 1); - } + public static SpawnConditionSelectors createSpawnConditions(RegistryEntryList requiredBiomes) { + return SpawnConditionSelectors.createSingle(new BiomeSpawnCondition(requiredBiomes), 1); + } } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeAdvancementProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeAdvancementProvider.java index 11610a58..bd7c45d6 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeAdvancementProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeAdvancementProvider.java @@ -1,11 +1,21 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.entity.PromenadeEntityTypes; -import fr.hugman.promenade.item.PromenadeItems; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; + import net.minecraft.advancement.*; import net.minecraft.advancement.criterion.Criteria; import net.minecraft.advancement.criterion.ItemCriterion; @@ -35,84 +45,87 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.function.Consumer; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider; + +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.entity.PromenadeEntityTypes; +import fr.hugman.promenade.item.PromenadeItems; public class PromenadeAdvancementProvider extends FabricAdvancementProvider { - public PromenadeAdvancementProvider(FabricDataOutput output, CompletableFuture registryLookup) { - super(output, registryLookup); - } + public PromenadeAdvancementProvider(FabricDataOutput output, CompletableFuture registryLookup) { + super(output, registryLookup); + } - @Override - public void generateAdvancement(RegistryWrapper.WrapperLookup wrapperLookup, Consumer consumer) { - final var entities = wrapperLookup.getOrThrow(RegistryKeys.ENTITY_TYPE); - final var fluids = wrapperLookup.getOrThrow(RegistryKeys.FLUID); - final var blocks = wrapperLookup.getOrThrow(RegistryKeys.BLOCK); - final var items = wrapperLookup.getOrThrow(RegistryKeys.ITEM); + @Override + public void generateAdvancement(RegistryWrapper.WrapperLookup wrapperLookup, Consumer consumer) { + final var entities = wrapperLookup.getOrThrow(RegistryKeys.ENTITY_TYPE); + final var fluids = wrapperLookup.getOrThrow(RegistryKeys.FLUID); + final var blocks = wrapperLookup.getOrThrow(RegistryKeys.BLOCK); + final var items = wrapperLookup.getOrThrow(RegistryKeys.ITEM); - Advancement.Builder.create() - .display( - PromenadeItems.MAPLE_SYRUP_BOTTLE, - Text.translatable("advancements.promenade.husbandry.harvest_maple_syrup.title"), - Text.translatable("advancements.promenade.husbandry.harvest_maple_syrup.description"), - null, - AdvancementFrame.TASK, - true, - true, - false - ) - .parent(Identifier.of("husbandry/safely_harvest_honey")) - .criterion("harvest_maple_syrup", createPickMapleSyrup(blocks, items)) - .build(consumer, Promenade.MOD_ID + ":husbandry/harvest_maple_syrup"); - Advancement.Builder.create() - .display( - Items.FIRE_CORAL, - Text.translatable("advancements.promenade.adventure.kill_sunken_outside_water.title"), - Text.translatable("advancements.promenade.adventure.kill_sunken_outside_water.description"), - null, - AdvancementFrame.CHALLENGE, - true, - true, - false - ) - .parent(Identifier.of("adventure/whos_the_pillager_now")) - .criterion("kill_sunken_outside_water", createCrossbowSunkenOutsideWaterFromWater(fluids, entities)) - .rewards(AdvancementRewards.Builder.experience(65)) - .build(consumer, Promenade.MOD_ID + ":adventure/kill_sunken_outside_water"); + Advancement.Builder.create() + .display( + PromenadeItems.MAPLE_SYRUP_BOTTLE, + Text.translatable("advancements.promenade.husbandry.harvest_maple_syrup.title"), + Text.translatable("advancements.promenade.husbandry.harvest_maple_syrup.description"), + null, + AdvancementFrame.TASK, + true, + true, + false + ) + .parent(Identifier.of("husbandry/safely_harvest_honey")) + .criterion("harvest_maple_syrup", createPickMapleSyrup(blocks, items)) + .build(consumer, Promenade.MOD_ID + ":husbandry/harvest_maple_syrup"); + Advancement.Builder.create() + .display( + Items.FIRE_CORAL, + Text.translatable("advancements.promenade.adventure.kill_sunken_outside_water.title"), + Text.translatable("advancements.promenade.adventure.kill_sunken_outside_water.description"), + null, + AdvancementFrame.CHALLENGE, + true, + true, + false + ) + .parent(Identifier.of("adventure/whos_the_pillager_now")) + .criterion("kill_sunken_outside_water", createCrossbowSunkenOutsideWaterFromWater(fluids, entities)) + .rewards(AdvancementRewards.Builder.experience(65)) + .build(consumer, Promenade.MOD_ID + ":adventure/kill_sunken_outside_water"); - } + } - public static AdvancementCriterion createCrossbowSunkenOutsideWaterFromWater(RegistryEntryLookup fluids, RegistryEntryLookup> entities) { - return Criteria.KILLED_BY_ARROW.create( - new KilledByArrowCriterion.Conditions( - // player is in water - Optional.of(LootContextPredicate.create(LocationCheckLootCondition.builder(LocationPredicate.Builder.create().fluid(FluidPredicate.Builder.create().tag(fluids.getOrThrow(FluidTags.WATER))), new BlockPos(0, 1, 0)).build())), - // entity is a sunken and is outside water - List.of(LootContextPredicate.create( - EntityPropertiesLootCondition.builder(LootContext.EntityReference.THIS, EntityPredicate.Builder.create().type(entities, PromenadeEntityTypes.SUNKEN)).build(), - InvertedLootCondition.builder(EntityPropertiesLootCondition.builder(LootContext.EntityReference.THIS, - EntityPredicate.Builder.create().location(LocationPredicate.Builder.create().fluid(FluidPredicate.Builder.create().tag(fluids.getOrThrow(FluidTags.WATER)))) - )).build() - )), - NumberRange.IntRange.ANY, - Optional.empty() - ) - ); - } + public static AdvancementCriterion createCrossbowSunkenOutsideWaterFromWater(RegistryEntryLookup fluids, RegistryEntryLookup> entities) { + return Criteria.KILLED_BY_ARROW.create( + new KilledByArrowCriterion.Conditions( + // player is in water + Optional.of(LootContextPredicate.create(LocationCheckLootCondition.builder(LocationPredicate.Builder.create().fluid(FluidPredicate.Builder.create().tag(fluids.getOrThrow(FluidTags.WATER))), new BlockPos(0, 1, 0)).build())), + // entity is a sunken and is outside water + List.of(LootContextPredicate.create( + EntityPropertiesLootCondition.builder(LootContext.EntityReference.THIS, EntityPredicate.Builder.create().type(entities, PromenadeEntityTypes.SUNKEN)).build(), + InvertedLootCondition.builder(EntityPropertiesLootCondition.builder(LootContext.EntityReference.THIS, + EntityPredicate.Builder.create().location(LocationPredicate.Builder.create().fluid(FluidPredicate.Builder.create().tag(fluids.getOrThrow(FluidTags.WATER)))) + )).build() + )), + NumberRange.IntRange.ANY, + Optional.empty() + ) + ); + } - public static AdvancementCriterion createPickMapleSyrup(RegistryEntryLookup blocks, RegistryEntryLookup items) { - return Criteria.ITEM_USED_ON_BLOCK.create( - new ItemCriterion.Conditions( - Optional.empty(), - Optional.of(LootContextPredicate.create( - LocationCheckLootCondition.builder(LocationPredicate.Builder.create().block(BlockPredicate.Builder.create().blocks(blocks, PromenadeBlocks.STRIPPED_MAPLE_LOG))).build(), - MatchToolLootCondition.builder(ItemPredicate.Builder.create().items(items, Items.GLASS_BOTTLE)).build() - )) - ) - ); - } + public static AdvancementCriterion createPickMapleSyrup(RegistryEntryLookup blocks, RegistryEntryLookup items) { + return Criteria.ITEM_USED_ON_BLOCK.create( + new ItemCriterion.Conditions( + Optional.empty(), + Optional.of(LootContextPredicate.create( + LocationCheckLootCondition.builder(LocationPredicate.Builder.create().block(BlockPredicate.Builder.create().blocks(blocks, PromenadeBlocks.STRIPPED_MAPLE_LOG))).build(), + MatchToolLootCondition.builder(ItemPredicate.Builder.create().items(items, Items.GLASS_BOTTLE)).build() + )) + ) + ); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternProvider.java index ab51eb4b..ccd9af8b 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternProvider.java @@ -1,37 +1,50 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.banner.PromenadeBannerPatterns; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.block.entity.BannerPattern; import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.banner.PromenadeBannerPatterns; public class PromenadeBannerPatternProvider extends FabricDynamicRegistryProvider { - public PromenadeBannerPatternProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.BANNER_PATTERN)); - } - - @Override - public String getName() { - return "Banner Patterns"; - } - - public static void register(Registerable registerable) { - of(registerable, PromenadeBannerPatterns.BOVINE); - } - - public static void of(Registerable registerable, RegistryKey key) { - registerable.register(key, new BannerPattern(key.getValue(), "block.promenade.banner." + key.getValue().getPath())); - } + public PromenadeBannerPatternProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(RegistryKeys.BANNER_PATTERN)); + } + + @Override + public String getName() { + return "Banner Patterns"; + } + + public static void register(Registerable registerable) { + of(registerable, PromenadeBannerPatterns.BOVINE); + } + + public static void of(Registerable registerable, RegistryKey key) { + registerable.register(key, new BannerPattern(key.getValue(), "block.promenade.banner." + key.getValue().getPath())); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternTagProvider.java index 91fa07fc..4d581eba 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBannerPatternTagProvider.java @@ -1,23 +1,36 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.banner.PromenadeBannerPatternTags; -import fr.hugman.promenade.banner.PromenadeBannerPatterns; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.block.entity.BannerPattern; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; + +import fr.hugman.promenade.banner.PromenadeBannerPatternTags; +import fr.hugman.promenade.banner.PromenadeBannerPatterns; public class PromenadeBannerPatternTagProvider extends FabricTagProvider { - public PromenadeBannerPatternTagProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, RegistryKeys.BANNER_PATTERN, registriesFuture); - } + public PromenadeBannerPatternTagProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, RegistryKeys.BANNER_PATTERN, registriesFuture); + } - @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { - // Promenade - builder(PromenadeBannerPatternTags.BOVINE_PATTERN_ITEM).add(PromenadeBannerPatterns.BOVINE); - } + @Override + protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + // Promenade + builder(PromenadeBannerPatternTags.BOVINE_PATTERN_ITEM).add(PromenadeBannerPatterns.BOVINE); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeProvider.java index d63e8357..0cd20f52 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeProvider.java @@ -1,11 +1,20 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.entity.PromenadeEntityTypes; -import fr.hugman.promenade.sound.PromenadeSoundEvents; -import fr.hugman.promenade.world.biome.PromenadeBiomes; -import fr.hugman.promenade.world.gen.feature.PromenadePlacedFeatures; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.concurrent.CompletableFuture; + +import org.jetbrains.annotations.Nullable; + import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; import net.minecraft.particle.ParticleTypes; @@ -16,287 +25,292 @@ import net.minecraft.world.gen.carver.ConfiguredCarver; import net.minecraft.world.gen.carver.ConfiguredCarvers; import net.minecraft.world.gen.feature.*; -import org.jetbrains.annotations.Nullable; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.entity.PromenadeEntityTypes; +import fr.hugman.promenade.sound.PromenadeSoundEvents; +import fr.hugman.promenade.world.biome.PromenadeBiomes; +import fr.hugman.promenade.world.gen.feature.PromenadePlacedFeatures; public class PromenadeBiomeProvider extends FabricDynamicRegistryProvider { - public PromenadeBiomeProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } + public PromenadeBiomeProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.BIOME)); - } + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(RegistryKeys.BIOME)); + } - @Override - public String getName() { - return "Biomes"; - } + @Override + public String getName() { + return "Biomes"; + } - public static void register(Registerable registerable) { - final var features = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); - final var carvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER); + public static void register(Registerable registerable) { + final var features = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + final var carvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER); - registerable.register(PromenadeBiomes.BLUSH_SAKURA_GROVE, createSakuraGroves(features, carvers, PromenadePlacedFeatures.BLUSH_SAKURA_GROVE_TREES)); - registerable.register(PromenadeBiomes.COTTON_SAKURA_GROVE, createSakuraGroves(features, carvers, PromenadePlacedFeatures.COTTON_SAKURA_GROVE_TREES)); + registerable.register(PromenadeBiomes.BLUSH_SAKURA_GROVE, createSakuraGroves(features, carvers, PromenadePlacedFeatures.BLUSH_SAKURA_GROVE_TREES)); + registerable.register(PromenadeBiomes.COTTON_SAKURA_GROVE, createSakuraGroves(features, carvers, PromenadePlacedFeatures.COTTON_SAKURA_GROVE_TREES)); - registerable.register(PromenadeBiomes.CARNELIAN_TREEWAY, createCarnelianTreeway(features, carvers)); - registerable.register(PromenadeBiomes.GLACARIAN_TAIGA, createGlacarianTaiga(features, carvers)); + registerable.register(PromenadeBiomes.CARNELIAN_TREEWAY, createCarnelianTreeway(features, carvers)); + registerable.register(PromenadeBiomes.GLACARIAN_TAIGA, createGlacarianTaiga(features, carvers)); - registerable.register(PromenadeBiomes.DARK_AMARANTH_FOREST, createDarkAmaranthForest(features, carvers)); - } + registerable.register(PromenadeBiomes.DARK_AMARANTH_FOREST, createDarkAmaranthForest(features, carvers)); + } - public static Biome createSakuraGroves(RegistryEntryLookup features, RegistryEntryLookup> carvers, RegistryKey trees) { - GenerationSettings.LookupBackedBuilder generation = new GenerationSettings.LookupBackedBuilder(features, carvers); + public static Biome createSakuraGroves(RegistryEntryLookup features, RegistryEntryLookup> carvers, RegistryKey trees) { + GenerationSettings.LookupBackedBuilder generation = new GenerationSettings.LookupBackedBuilder(features, carvers); - addBasicFeatures(generation); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.WATER_POOLS_GRAVEL_DECORATED); - generation.feature(GenerationStep.Feature.LOCAL_MODIFICATIONS, PromenadePlacedFeatures.CUTE_LITTLE_ROCKS); + addBasicFeatures(generation); + generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.WATER_POOLS_GRAVEL_DECORATED); + generation.feature(GenerationStep.Feature.LOCAL_MODIFICATIONS, PromenadePlacedFeatures.CUTE_LITTLE_ROCKS); - DefaultBiomeFeatures.addForestFlowers(generation); + DefaultBiomeFeatures.addForestFlowers(generation); - DefaultBiomeFeatures.addDefaultOres(generation); - DefaultBiomeFeatures.addDefaultDisks(generation); + DefaultBiomeFeatures.addDefaultOres(generation); + DefaultBiomeFeatures.addDefaultDisks(generation); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.SAKURA_GROVE_BAMBOO); - - DefaultBiomeFeatures.addDefaultFlowers(generation); - DefaultBiomeFeatures.addForestGrass(generation); - - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, VegetationPlacedFeatures.PATCH_WATERLILY); - - DefaultBiomeFeatures.addDefaultMushrooms(generation); - DefaultBiomeFeatures.addDefaultVegetation(generation, true); - - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, trees); - - SpawnSettings.Builder spawns = new SpawnSettings.Builder(); - - DefaultBiomeFeatures.addFarmAnimals(spawns); - DefaultBiomeFeatures.addBatsAndMonsters(spawns); - spawns.spawn(SpawnGroup.CREATURE, 5, new SpawnSettings.SpawnEntry(EntityType.WOLF, 4, 4)); - spawns.spawn(SpawnGroup.CREATURE, 16, new SpawnSettings.SpawnEntry(EntityType.FOX, 1, 3)); - spawns.spawn(SpawnGroup.CREATURE, 2, new SpawnSettings.SpawnEntry(EntityType.PANDA, 4, 5)); - - return createBiome( - true, - 0.6F, - 0.4F, - 6459391, - 2170954, - 6484135, - null, - spawns, - generation, - MusicType.createIngameMusic(PromenadeSoundEvents.MUSIC_OVERWORLD_SAKURA_GROVES) - ); - } - - public static Biome createCarnelianTreeway(RegistryEntryLookup features, RegistryEntryLookup> carvers) { - GenerationSettings.LookupBackedBuilder generation = new GenerationSettings.LookupBackedBuilder(features, carvers); - - addBasicFeatures(generation); - - DefaultBiomeFeatures.addForestFlowers(generation); - - DefaultBiomeFeatures.addDefaultOres(generation); - DefaultBiomeFeatures.addDefaultDisks(generation); - - DefaultBiomeFeatures.addDefaultFlowers(generation); - DefaultBiomeFeatures.addForestGrass(generation); - - DefaultBiomeFeatures.addDefaultMushrooms(generation); - DefaultBiomeFeatures.addDefaultVegetation(generation, true); - - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.CARNELIAN_TREEWAY_TREES); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES); - - SpawnSettings.Builder spawns = new SpawnSettings.Builder(); - - DefaultBiomeFeatures.addFarmAnimals(spawns); - DefaultBiomeFeatures.addBatsAndMonsters(spawns); - spawns.spawn(SpawnGroup.CREATURE, 5, new SpawnSettings.SpawnEntry(EntityType.WOLF, 4, 4)); - spawns.spawn(SpawnGroup.CREATURE, 7, new SpawnSettings.SpawnEntry(EntityType.FOX, 2, 3)); - - return createBiome( - true, - 1.2F, - 0.9F, - 155336, - 541, - 9090320, - 10931465, - spawns, - generation, - null - ); - } - - public static Biome createGlacarianTaiga(RegistryEntryLookup featureLookup, RegistryEntryLookup> carverLookup) { - GenerationSettings.LookupBackedBuilder generation = new GenerationSettings.LookupBackedBuilder(featureLookup, carverLookup); - - generation.carver(ConfiguredCarvers.CAVE); - generation.carver(ConfiguredCarvers.CAVE_EXTRA_UNDERGROUND); - generation.carver(ConfiguredCarvers.CANYON); - generation.feature(GenerationStep.Feature.LAKES, MiscPlacedFeatures.LAKE_LAVA_UNDERGROUND); - - DefaultBiomeFeatures.addAmethystGeodes(generation); - DefaultBiomeFeatures.addDungeons(generation); - - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIRT); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GRAVEL); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GRANITE_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIORITE_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_ANDESITE_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_TUFF); - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, UndergroundPlacedFeatures.GLOW_LICHEN); - - generation.feature(GenerationStep.Feature.FLUID_SPRINGS, MiscPlacedFeatures.SPRING_WATER); - - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_COAL_UPPER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_COAL_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_IRON_UPPER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_IRON_MIDDLE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_IRON_SMALL); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GOLD); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GOLD_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_REDSTONE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_REDSTONE_LOWER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND_MEDIUM); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND_LARGE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND_BURIED); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_LAPIS); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_LAPIS_BURIED); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_COPPER); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.PACKED_ICE_ORE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.BLUE_ICE_ORE); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, MiscPlacedFeatures.DISK_CLAY); - generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, MiscPlacedFeatures.DISK_GRAVEL); - - DefaultBiomeFeatures.addInfestedStone(generation); - - generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.GLACARIAN_TAIGA_TREES); - generation.feature(GenerationStep.Feature.TOP_LAYER_MODIFICATION, PromenadePlacedFeatures.FREEZE_TOP_LAYER); - - SpawnSettings.Builder spawns = new SpawnSettings.Builder() - .spawn(SpawnGroup.CREATURE, 4, new SpawnSettings.SpawnEntry(PromenadeEntityTypes.DUCK, 4, 4)) - .spawn(SpawnGroup.CREATURE, 8, new SpawnSettings.SpawnEntry(EntityType.WOLF, 4, 4)) - .spawn(SpawnGroup.CREATURE, 8, new SpawnSettings.SpawnEntry(EntityType.FOX, 2, 4)); - DefaultBiomeFeatures.addBatsAndMonsters(spawns); - - return createBiome( - true, - -0.7F, - 0.8f, - 1724346, - 197394, - null, - null, - spawns, - generation, - null - ); - } - - public static Biome createDarkAmaranthForest(RegistryEntryLookup featureLookup, RegistryEntryLookup> carverLookup) { - SpawnSettings spawnSettings = new SpawnSettings.Builder() - .spawn(SpawnGroup.MONSTER, 1, new SpawnSettings.SpawnEntry(EntityType.ENDERMAN, 4, 4)) - .spawn(SpawnGroup.CREATURE, 60, new SpawnSettings.SpawnEntry(EntityType.STRIDER, 1, 2)) - .spawnCost(EntityType.ENDERMAN, 1.0, 0.12) - .build(); - GenerationSettings.LookupBackedBuilder lookupBackedBuilder = new GenerationSettings.LookupBackedBuilder(featureLookup, carverLookup) - .carver(ConfiguredCarvers.NETHER_CAVE) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, MiscPlacedFeatures.SPRING_LAVA); - DefaultBiomeFeatures.addDefaultMushrooms(lookupBackedBuilder); - lookupBackedBuilder.feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.SPRING_OPEN) - .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.PATCH_FIRE) - .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.PATCH_SOUL_FIRE) - .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, OrePlacedFeatures.ORE_MAGMA) - .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.SPRING_CLOSED) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.DARK_AMARANTH_FUNGI) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.DARK_AMARANTH_FOREST_VEGETATION) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, NetherPlacedFeatures.NETHER_SPROUTS) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.COILED_VINES); - DefaultBiomeFeatures.addNetherMineables(lookupBackedBuilder); - return new Biome.Builder() - .precipitation(false) - .temperature(2.0F) - .downfall(0.0F) - .effects( - new BiomeEffects.Builder() - .waterColor(4159204) - .waterFogColor(329011) - .fogColor(524562) - .skyColor(OverworldBiomeCreator.getSkyColor(2.0F)) - .particleConfig(new BiomeParticleConfig(ParticleTypes.WARPED_SPORE, 0.01428F)) //TODO - .loopSound(SoundEvents.AMBIENT_WARPED_FOREST_LOOP) //TODO - .moodSound(new BiomeMoodSound(SoundEvents.AMBIENT_WARPED_FOREST_MOOD, 6000, 8, 2.0)) //TODO - .additionsSound(new BiomeAdditionsSound(SoundEvents.AMBIENT_WARPED_FOREST_ADDITIONS, 0.0111)) //TODO - .music(MusicType.createIngameMusic(SoundEvents.MUSIC_NETHER_WARPED_FOREST)) //TODO - .build() - ) - .spawnSettings(spawnSettings) - .generationSettings(lookupBackedBuilder.build()) - .build(); - } - - private static void addBasicFeatures(GenerationSettings.LookupBackedBuilder generationSettings) { - DefaultBiomeFeatures.addLandCarvers(generationSettings); - DefaultBiomeFeatures.addAmethystGeodes(generationSettings); - DefaultBiomeFeatures.addDungeons(generationSettings); - DefaultBiomeFeatures.addMineables(generationSettings); - DefaultBiomeFeatures.addSprings(generationSettings); - DefaultBiomeFeatures.addFrozenTopLayer(generationSettings); - } - - private static Biome createBiome( - boolean precipitation, - float temperature, - float downfall, - SpawnSettings.Builder spawnSettings, - GenerationSettings.LookupBackedBuilder generationSettings, - @Nullable MusicSound music - ) { - return createBiome(precipitation, temperature, downfall, 4159204, 329011, null, null, spawnSettings, generationSettings, music); - } - - private static Biome createBiome( - boolean precipitation, - float temperature, - float downfall, - int waterColor, - int waterFogColor, - @Nullable Integer grassColor, - @Nullable Integer foliageColor, - SpawnSettings.Builder spawnSettings, - GenerationSettings.LookupBackedBuilder generationSettings, - @Nullable MusicSound music - ) { - BiomeEffects.Builder builder = new BiomeEffects.Builder() - .waterColor(waterColor) - .waterFogColor(waterFogColor) - .fogColor(12638463) - .skyColor(OverworldBiomeCreator.getSkyColor(temperature)) - .moodSound(BiomeMoodSound.CAVE) - .music(music); - if (grassColor != null) { - builder.grassColor(grassColor); - } - - if (foliageColor != null) { - builder.foliageColor(foliageColor); - } - - return new Biome.Builder() - .precipitation(precipitation) - .temperature(temperature) - .downfall(downfall) - .effects(builder.build()) - .spawnSettings(spawnSettings.build()) - .generationSettings(generationSettings.build()) - .build(); - } + generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.SAKURA_GROVE_BAMBOO); + + DefaultBiomeFeatures.addDefaultFlowers(generation); + DefaultBiomeFeatures.addForestGrass(generation); + + generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, VegetationPlacedFeatures.PATCH_WATERLILY); + + DefaultBiomeFeatures.addDefaultMushrooms(generation); + DefaultBiomeFeatures.addDefaultVegetation(generation, true); + + generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, trees); + + SpawnSettings.Builder spawns = new SpawnSettings.Builder(); + + DefaultBiomeFeatures.addFarmAnimals(spawns); + DefaultBiomeFeatures.addBatsAndMonsters(spawns); + spawns.spawn(SpawnGroup.CREATURE, 5, new SpawnSettings.SpawnEntry(EntityType.WOLF, 4, 4)); + spawns.spawn(SpawnGroup.CREATURE, 16, new SpawnSettings.SpawnEntry(EntityType.FOX, 1, 3)); + spawns.spawn(SpawnGroup.CREATURE, 2, new SpawnSettings.SpawnEntry(EntityType.PANDA, 4, 5)); + + return createBiome( + true, + 0.6F, + 0.4F, + 6459391, + 2170954, + 6484135, + null, + spawns, + generation, + MusicType.createIngameMusic(PromenadeSoundEvents.MUSIC_OVERWORLD_SAKURA_GROVES) + ); + } + + public static Biome createCarnelianTreeway(RegistryEntryLookup features, RegistryEntryLookup> carvers) { + GenerationSettings.LookupBackedBuilder generation = new GenerationSettings.LookupBackedBuilder(features, carvers); + + addBasicFeatures(generation); + + DefaultBiomeFeatures.addForestFlowers(generation); + + DefaultBiomeFeatures.addDefaultOres(generation); + DefaultBiomeFeatures.addDefaultDisks(generation); + + DefaultBiomeFeatures.addDefaultFlowers(generation); + DefaultBiomeFeatures.addForestGrass(generation); + + DefaultBiomeFeatures.addDefaultMushrooms(generation); + DefaultBiomeFeatures.addDefaultVegetation(generation, true); + + generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.CARNELIAN_TREEWAY_TREES); + generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES); + + SpawnSettings.Builder spawns = new SpawnSettings.Builder(); + + DefaultBiomeFeatures.addFarmAnimals(spawns); + DefaultBiomeFeatures.addBatsAndMonsters(spawns); + spawns.spawn(SpawnGroup.CREATURE, 5, new SpawnSettings.SpawnEntry(EntityType.WOLF, 4, 4)); + spawns.spawn(SpawnGroup.CREATURE, 7, new SpawnSettings.SpawnEntry(EntityType.FOX, 2, 3)); + + return createBiome( + true, + 1.2F, + 0.9F, + 155336, + 541, + 9090320, + 10931465, + spawns, + generation, + null + ); + } + + public static Biome createGlacarianTaiga(RegistryEntryLookup featureLookup, RegistryEntryLookup> carverLookup) { + GenerationSettings.LookupBackedBuilder generation = new GenerationSettings.LookupBackedBuilder(featureLookup, carverLookup); + + generation.carver(ConfiguredCarvers.CAVE); + generation.carver(ConfiguredCarvers.CAVE_EXTRA_UNDERGROUND); + generation.carver(ConfiguredCarvers.CANYON); + generation.feature(GenerationStep.Feature.LAKES, MiscPlacedFeatures.LAKE_LAVA_UNDERGROUND); + + DefaultBiomeFeatures.addAmethystGeodes(generation); + DefaultBiomeFeatures.addDungeons(generation); + + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIRT); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GRAVEL); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GRANITE_LOWER); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIORITE_LOWER); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_ANDESITE_LOWER); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_TUFF); + generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, UndergroundPlacedFeatures.GLOW_LICHEN); + + generation.feature(GenerationStep.Feature.FLUID_SPRINGS, MiscPlacedFeatures.SPRING_WATER); + + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_COAL_UPPER); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_COAL_LOWER); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_IRON_UPPER); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_IRON_MIDDLE); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_IRON_SMALL); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GOLD); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_GOLD_LOWER); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_REDSTONE); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_REDSTONE_LOWER); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND_MEDIUM); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND_LARGE); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_DIAMOND_BURIED); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_LAPIS); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_LAPIS_BURIED); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, OrePlacedFeatures.ORE_COPPER); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.PACKED_ICE_ORE); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.BLUE_ICE_ORE); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, MiscPlacedFeatures.DISK_CLAY); + generation.feature(GenerationStep.Feature.UNDERGROUND_ORES, MiscPlacedFeatures.DISK_GRAVEL); + + DefaultBiomeFeatures.addInfestedStone(generation); + + generation.feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.GLACARIAN_TAIGA_TREES); + generation.feature(GenerationStep.Feature.TOP_LAYER_MODIFICATION, PromenadePlacedFeatures.FREEZE_TOP_LAYER); + + SpawnSettings.Builder spawns = new SpawnSettings.Builder() + .spawn(SpawnGroup.CREATURE, 4, new SpawnSettings.SpawnEntry(PromenadeEntityTypes.DUCK, 4, 4)) + .spawn(SpawnGroup.CREATURE, 8, new SpawnSettings.SpawnEntry(EntityType.WOLF, 4, 4)) + .spawn(SpawnGroup.CREATURE, 8, new SpawnSettings.SpawnEntry(EntityType.FOX, 2, 4)); + DefaultBiomeFeatures.addBatsAndMonsters(spawns); + + return createBiome( + true, + - 0.7F, + 0.8f, + 1724346, + 197394, + null, + null, + spawns, + generation, + null + ); + } + + public static Biome createDarkAmaranthForest(RegistryEntryLookup featureLookup, RegistryEntryLookup> carverLookup) { + SpawnSettings spawnSettings = new SpawnSettings.Builder() + .spawn(SpawnGroup.MONSTER, 1, new SpawnSettings.SpawnEntry(EntityType.ENDERMAN, 4, 4)) + .spawn(SpawnGroup.CREATURE, 60, new SpawnSettings.SpawnEntry(EntityType.STRIDER, 1, 2)) + .spawnCost(EntityType.ENDERMAN, 1.0, 0.12) + .build(); + GenerationSettings.LookupBackedBuilder lookupBackedBuilder = new GenerationSettings.LookupBackedBuilder(featureLookup, carverLookup) + .carver(ConfiguredCarvers.NETHER_CAVE) + .feature(GenerationStep.Feature.VEGETAL_DECORATION, MiscPlacedFeatures.SPRING_LAVA); + DefaultBiomeFeatures.addDefaultMushrooms(lookupBackedBuilder); + lookupBackedBuilder.feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.SPRING_OPEN) + .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.PATCH_FIRE) + .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.PATCH_SOUL_FIRE) + .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, OrePlacedFeatures.ORE_MAGMA) + .feature(GenerationStep.Feature.UNDERGROUND_DECORATION, NetherPlacedFeatures.SPRING_CLOSED) + .feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.DARK_AMARANTH_FUNGI) + .feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.DARK_AMARANTH_FOREST_VEGETATION) + .feature(GenerationStep.Feature.VEGETAL_DECORATION, NetherPlacedFeatures.NETHER_SPROUTS) + .feature(GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.COILED_VINES); + DefaultBiomeFeatures.addNetherMineables(lookupBackedBuilder); + return new Biome.Builder() + .precipitation(false) + .temperature(2.0F) + .downfall(0.0F) + .effects( + new BiomeEffects.Builder() + .waterColor(4159204) + .waterFogColor(329011) + .fogColor(524562) + .skyColor(OverworldBiomeCreator.getSkyColor(2.0F)) + .particleConfig(new BiomeParticleConfig(ParticleTypes.WARPED_SPORE, 0.01428F)) //TODO + .loopSound(SoundEvents.AMBIENT_WARPED_FOREST_LOOP) //TODO + .moodSound(new BiomeMoodSound(SoundEvents.AMBIENT_WARPED_FOREST_MOOD, 6000, 8, 2.0)) //TODO + .additionsSound(new BiomeAdditionsSound(SoundEvents.AMBIENT_WARPED_FOREST_ADDITIONS, 0.0111)) //TODO + .music(MusicType.createIngameMusic(SoundEvents.MUSIC_NETHER_WARPED_FOREST)) //TODO + .build() + ) + .spawnSettings(spawnSettings) + .generationSettings(lookupBackedBuilder.build()) + .build(); + } + + private static void addBasicFeatures(GenerationSettings.LookupBackedBuilder generationSettings) { + DefaultBiomeFeatures.addLandCarvers(generationSettings); + DefaultBiomeFeatures.addAmethystGeodes(generationSettings); + DefaultBiomeFeatures.addDungeons(generationSettings); + DefaultBiomeFeatures.addMineables(generationSettings); + DefaultBiomeFeatures.addSprings(generationSettings); + DefaultBiomeFeatures.addFrozenTopLayer(generationSettings); + } + + private static Biome createBiome( + boolean precipitation, + float temperature, + float downfall, + SpawnSettings.Builder spawnSettings, + GenerationSettings.LookupBackedBuilder generationSettings, + @Nullable MusicSound music + ) { + return createBiome(precipitation, temperature, downfall, 4159204, 329011, null, null, spawnSettings, generationSettings, music); + } + + private static Biome createBiome( + boolean precipitation, + float temperature, + float downfall, + int waterColor, + int waterFogColor, + @Nullable Integer grassColor, + @Nullable Integer foliageColor, + SpawnSettings.Builder spawnSettings, + GenerationSettings.LookupBackedBuilder generationSettings, + @Nullable MusicSound music + ) { + BiomeEffects.Builder builder = new BiomeEffects.Builder() + .waterColor(waterColor) + .waterFogColor(waterFogColor) + .fogColor(12638463) + .skyColor(OverworldBiomeCreator.getSkyColor(temperature)) + .moodSound(BiomeMoodSound.CAVE) + .music(music); + if (grassColor != null) { + builder.grassColor(grassColor); + } + + if (foliageColor != null) { + builder.foliageColor(foliageColor); + } + + return new Biome.Builder() + .precipitation(precipitation) + .temperature(temperature) + .downfall(downfall) + .effects(builder.build()) + .spawnSettings(spawnSettings.build()) + .generationSettings(generationSettings.build()) + .build(); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeTagProvider.java index 9031bd49..36c80efc 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBiomeTagProvider.java @@ -1,67 +1,79 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; -import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBiomeTags; +import static fr.hugman.promenade.tag.PromenadeBiomeTags.*; +import static fr.hugman.promenade.world.biome.PromenadeBiomes.*; +import static net.minecraft.world.biome.BiomeKeys.*; + +import java.util.concurrent.CompletableFuture; + import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.tag.BiomeTags; import net.minecraft.world.biome.Biome; -import java.util.concurrent.CompletableFuture; - -import static fr.hugman.promenade.tag.PromenadeBiomeTags.*; -import static fr.hugman.promenade.world.biome.PromenadeBiomes.*; -import static net.minecraft.world.biome.BiomeKeys.*; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBiomeTags; public class PromenadeBiomeTagProvider extends FabricTagProvider { - public PromenadeBiomeTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { - super(output, RegistryKeys.BIOME, completableFuture); - } + public PromenadeBiomeTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { + super(output, RegistryKeys.BIOME, completableFuture); + } - @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { - // Promenade - builder(SAKURA_GROVES).add(BLUSH_SAKURA_GROVE, COTTON_SAKURA_GROVE); + @Override + protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + // Promenade + builder(SAKURA_GROVES).add(BLUSH_SAKURA_GROVE, COTTON_SAKURA_GROVE); - builder(HAS_PALMS) - .add(DESERT) - .addOptionalTag(ConventionalBiomeTags.IS_DESERT); - builder(HAS_DARK_FOREST_WITCH_HUT) - .add(DARK_FOREST, PALE_GARDEN) - .addOptionalTag(ConventionalBiomeTags.IS_DARK_FOREST); + builder(HAS_PALMS) + .add(DESERT) + .addOptionalTag(ConventionalBiomeTags.IS_DESERT); + builder(HAS_DARK_FOREST_WITCH_HUT) + .add(DARK_FOREST, PALE_GARDEN) + .addOptionalTag(ConventionalBiomeTags.IS_DARK_FOREST); - builder(CAN_FREEZE_DURING_SNOWFALL).add(GLACARIAN_TAIGA); + builder(CAN_FREEZE_DURING_SNOWFALL).add(GLACARIAN_TAIGA); - builder(SPAWNS_CAPYBARAS) - .forceAddTag(BiomeTags.IS_RIVER) - .add(MANGROVE_SWAMP, SWAMP) - .addOptionalTag(ConventionalBiomeTags.IS_RIVER) - .addOptionalTag(ConventionalBiomeTags.IS_SWAMP); - builder(SPAWNS_SUNKEN).add(WARM_OCEAN, LUKEWARM_OCEAN, DEEP_LUKEWARM_OCEAN); - builder(SPAWNS_MALLARD_DUCKS) - .forceAddTag(BiomeTags.IS_OCEAN) - .forceAddTag(BiomeTags.IS_RIVER) - .addOptionalTag(ConventionalBiomeTags.IS_OCEAN) - .addOptionalTag(ConventionalBiomeTags.IS_RIVER); - builder(SPAWNS_PEKIN_DUCKS) - .add(PLAINS) - .forceAddTag(BiomeTags.IS_FOREST) - .addOptionalTag(ConventionalBiomeTags.IS_OCEAN); + builder(SPAWNS_CAPYBARAS) + .forceAddTag(BiomeTags.IS_RIVER) + .add(MANGROVE_SWAMP, SWAMP) + .addOptionalTag(ConventionalBiomeTags.IS_RIVER) + .addOptionalTag(ConventionalBiomeTags.IS_SWAMP); + builder(SPAWNS_SUNKEN).add(WARM_OCEAN, LUKEWARM_OCEAN, DEEP_LUKEWARM_OCEAN); + builder(SPAWNS_MALLARD_DUCKS) + .forceAddTag(BiomeTags.IS_OCEAN) + .forceAddTag(BiomeTags.IS_RIVER) + .addOptionalTag(ConventionalBiomeTags.IS_OCEAN) + .addOptionalTag(ConventionalBiomeTags.IS_RIVER); + builder(SPAWNS_PEKIN_DUCKS) + .add(PLAINS) + .forceAddTag(BiomeTags.IS_FOREST) + .addOptionalTag(ConventionalBiomeTags.IS_OCEAN); - // Vanilla - builder(BiomeTags.IS_FOREST).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY); - builder(BiomeTags.IS_NETHER).add(DARK_AMARANTH_FOREST); - builder(BiomeTags.IS_OVERWORLD).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY, GLACARIAN_TAIGA); - builder(BiomeTags.IS_TAIGA).add(GLACARIAN_TAIGA); + // Vanilla + builder(BiomeTags.IS_FOREST).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY); + builder(BiomeTags.IS_NETHER).add(DARK_AMARANTH_FOREST); + builder(BiomeTags.IS_OVERWORLD).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY, GLACARIAN_TAIGA); + builder(BiomeTags.IS_TAIGA).add(GLACARIAN_TAIGA); - builder(BiomeTags.STRONGHOLD_BIASED_TO).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY, GLACARIAN_TAIGA); - builder(BiomeTags.TRIAL_CHAMBERS_HAS_STRUCTURE).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY, GLACARIAN_TAIGA); - builder(BiomeTags.BASTION_REMNANT_HAS_STRUCTURE).add(DARK_AMARANTH_FOREST); + builder(BiomeTags.STRONGHOLD_BIASED_TO).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY, GLACARIAN_TAIGA); + builder(BiomeTags.TRIAL_CHAMBERS_HAS_STRUCTURE).addTag(SAKURA_GROVES).add(CARNELIAN_TREEWAY, GLACARIAN_TAIGA); + builder(BiomeTags.BASTION_REMNANT_HAS_STRUCTURE).add(DARK_AMARANTH_FOREST); - builder(BiomeTags.SPAWNS_COLD_VARIANT_FROGS).add(GLACARIAN_TAIGA); - builder(BiomeTags.SPAWNS_SNOW_FOXES).add(GLACARIAN_TAIGA); - builder(BiomeTags.SPAWNS_WHITE_RABBITS).add(GLACARIAN_TAIGA); - builder(BiomeTags.SNOW_GOLEM_MELTS).add(DARK_AMARANTH_FOREST); - } + builder(BiomeTags.SPAWNS_COLD_VARIANT_FROGS).add(GLACARIAN_TAIGA); + builder(BiomeTags.SPAWNS_SNOW_FOXES).add(GLACARIAN_TAIGA); + builder(BiomeTags.SPAWNS_WHITE_RABBITS).add(GLACARIAN_TAIGA); + builder(BiomeTags.SNOW_GOLEM_MELTS).add(DARK_AMARANTH_FOREST); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockLootTableProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockLootTableProvider.java index 0a01a9c9..68dce4a5 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockLootTableProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockLootTableProvider.java @@ -1,10 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.block.BerryBushBlock; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.item.PromenadeItems; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; + import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.enchantment.Enchantment; @@ -23,288 +32,292 @@ import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider; + +import fr.hugman.promenade.block.BerryBushBlock; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.item.PromenadeItems; public class PromenadeBlockLootTableProvider extends FabricBlockLootTableProvider { - private static final float[] JUNGLE_SAPLING_DROP_CHANCE = new float[]{0.025F, 0.027777778F, 0.03125F, 0.041666668F, 0.1F}; - protected static final float[] SAPLING_DROP_CHANCE = new float[]{0.05F, 0.0625F, 0.083333336F, 0.1F}; - private static final float[] LEAVES_STICK_DROP_CHANCE = new float[]{0.02F, 0.022222223F, 0.025F, 0.033333335F, 0.1F}; - - public PromenadeBlockLootTableProvider(FabricDataOutput dataOutput, CompletableFuture registryLookup) { - super(dataOutput, registryLookup); - } - - @Override - public void generate() { - final var enchantments = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT); - - addDrop(PromenadeBlocks.ASPHALT); - addDrop(PromenadeBlocks.ASPHALT_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.ASPHALT_STAIRS); - addDrop(PromenadeBlocks.ASPHALT_WALL); - addDrop(PromenadeBlocks.POLISHED_ASPHALT); - addDrop(PromenadeBlocks.POLISHED_ASPHALT_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.POLISHED_ASPHALT_STAIRS); - - addDrop(PromenadeBlocks.BLUNITE); - addDrop(PromenadeBlocks.BLUNITE_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.BLUNITE_STAIRS); - addDrop(PromenadeBlocks.BLUNITE_WALL); - addDrop(PromenadeBlocks.POLISHED_BLUNITE); - addDrop(PromenadeBlocks.POLISHED_BLUNITE_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.POLISHED_BLUNITE_STAIRS); - - addDrop(PromenadeBlocks.OAK_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.SPRUCE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.BIRCH_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.JUNGLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.ACACIA_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.CHERRY_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.DARK_OAK_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.PALE_OAK_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.MANGROVE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.AZALEA_LEAF_PILE, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.DANDELION_PILE, flowerPile(Items.DANDELION)); - addDrop(PromenadeBlocks.POPPY_PILE, flowerPile(Items.POPPY)); - addDrop(PromenadeBlocks.BLUE_ORCHID_PILE, flowerPile(Items.BLUE_ORCHID)); - addDrop(PromenadeBlocks.ALLIUM_PILE, flowerPile(Items.ALLIUM)); - addDrop(PromenadeBlocks.AZURE_BLUET_PILE, flowerPile(Items.AZURE_BLUET)); - addDrop(PromenadeBlocks.RED_TULIP_PILE, flowerPile(Items.RED_TULIP)); - addDrop(PromenadeBlocks.ORANGE_TULIP_PILE, flowerPile(Items.ORANGE_TULIP)); - addDrop(PromenadeBlocks.WHITE_TULIP_PILE, flowerPile(Items.WHITE_TULIP)); - addDrop(PromenadeBlocks.PINK_TULIP_PILE, flowerPile(Items.PINK_TULIP)); - addDrop(PromenadeBlocks.OXEYE_DAISY_PILE, flowerPile(Items.OXEYE_DAISY)); - addDrop(PromenadeBlocks.CORNFLOWER_PILE, flowerPile(Items.CORNFLOWER)); - addDrop(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, flowerPile(Items.LILY_OF_THE_VALLEY)); - addDrop(PromenadeBlocks.WITHER_ROSE_PILE, flowerPile(Items.WITHER_ROSE)); - - addDrop(PromenadeBlocks.SNOWY_OAK_LEAVES, block -> this.snowyFruitLeavesDrop(block, Blocks.OAK_SAPLING, Items.APPLE, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.SPRUCE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_BIRCH_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.BIRCH_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.JUNGLE_SAPLING, JUNGLE_SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_ACACIA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.ACACIA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_CHERRY_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.CHERRY_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, block -> this.snowyFruitLeavesDrop(block, Blocks.DARK_OAK_SAPLING, Items.APPLE, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.PALE_OAK_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, this::snowyMangroveLeavesDrops); - addDrop(PromenadeBlocks.SNOWY_AZALEA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.AZALEA, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.FLOWERING_AZALEA, SAPLING_DROP_CHANCE)); - - addDrop(PromenadeBlocks.STRIPPED_SAKURA_LOG); - addDrop(PromenadeBlocks.SAKURA_LOG); - addDrop(PromenadeBlocks.STRIPPED_SAKURA_WOOD); - addDrop(PromenadeBlocks.SAKURA_WOOD); - addDrop(PromenadeBlocks.SAKURA_PLANKS); - addDrop(PromenadeBlocks.SAKURA_STAIRS); - addDrop(PromenadeBlocks.SAKURA_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.SAKURA_FENCE); - addDrop(PromenadeBlocks.SAKURA_FENCE_GATE); - addDrop(PromenadeBlocks.SAKURA_DOOR, this::doorDrops); - addDrop(PromenadeBlocks.SAKURA_TRAPDOOR); - addDrop(PromenadeBlocks.SAKURA_BUTTON); - addDrop(PromenadeBlocks.SAKURA_PRESSURE_PLATE); - addDrop(PromenadeBlocks.SAKURA_SIGN); - addDrop(PromenadeBlocks.SAKURA_HANGING_SIGN); - - addDrop(PromenadeBlocks.BLUSH_SAKURA_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING); - addDrop(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, block -> this.leavesDrops(block, PromenadeBlocks.BLUSH_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, block -> this.snowyLeavesDrops(block, PromenadeBlocks.BLUSH_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.COTTON_SAKURA_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING); - addDrop(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, block -> this.leavesDrops(block, PromenadeBlocks.COTTON_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, block -> this.snowyLeavesDrops(block, PromenadeBlocks.COTTON_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.STRIPPED_MAPLE_LOG); - addDrop(PromenadeBlocks.MAPLE_LOG); - addDrop(PromenadeBlocks.STRIPPED_MAPLE_WOOD); - addDrop(PromenadeBlocks.MAPLE_WOOD); - addDrop(PromenadeBlocks.MAPLE_PLANKS); - addDrop(PromenadeBlocks.MAPLE_STAIRS); - addDrop(PromenadeBlocks.MAPLE_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.MAPLE_FENCE); - addDrop(PromenadeBlocks.MAPLE_FENCE_GATE); - addDrop(PromenadeBlocks.MAPLE_DOOR, this::doorDrops); - addDrop(PromenadeBlocks.MAPLE_TRAPDOOR); - addDrop(PromenadeBlocks.MAPLE_BUTTON); - addDrop(PromenadeBlocks.MAPLE_PRESSURE_PLATE); - addDrop(PromenadeBlocks.MAPLE_SIGN); - addDrop(PromenadeBlocks.MAPLE_HANGING_SIGN); - - addDrop(PromenadeBlocks.SAP_MAPLE_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING); - addDrop(PromenadeBlocks.SAP_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.SAP_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.SAP_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.VERMILION_MAPLE_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING); - addDrop(PromenadeBlocks.VERMILION_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.VERMILION_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.VERMILION_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.FULVOUS_MAPLE_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING); - addDrop(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.MIKADO_MAPLE_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING); - addDrop(PromenadeBlocks.MIKADO_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.MIKADO_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.MIKADO_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.STRIPPED_PALM_LOG); - addDrop(PromenadeBlocks.PALM_LOG); - addDrop(PromenadeBlocks.STRIPPED_PALM_WOOD); - addDrop(PromenadeBlocks.PALM_WOOD); - addDrop(PromenadeBlocks.PALM_PLANKS); - addDrop(PromenadeBlocks.PALM_STAIRS); - addDrop(PromenadeBlocks.PALM_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.PALM_FENCE); - addDrop(PromenadeBlocks.PALM_FENCE_GATE); - addDrop(PromenadeBlocks.PALM_DOOR, this::doorDrops); - addDrop(PromenadeBlocks.PALM_TRAPDOOR); - addDrop(PromenadeBlocks.PALM_BUTTON); - addDrop(PromenadeBlocks.PALM_PRESSURE_PLATE); - addDrop(PromenadeBlocks.PALM_SIGN); - addDrop(PromenadeBlocks.PALM_HANGING_SIGN); - - addDrop(PromenadeBlocks.PALM_SAPLING); - addPottedPlantDrops(PromenadeBlocks.POTTED_PALM_SAPLING); - addDrop(PromenadeBlocks.PALM_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.PALM_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.SNOWY_PALM_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.PALM_SAPLING, SAPLING_DROP_CHANCE)); - addDrop(PromenadeBlocks.PALM_HANGING_LEAVES, this::dropsWithSilkTouchOrShears); - addDrop(PromenadeBlocks.PALM_LEAF_PILE, this::dropsWithSilkTouchOrShears); - - addDrop(PromenadeBlocks.DARK_AMARANTH_NYLIUM, block -> this.drops(block, Blocks.NETHERRACK)); - addDrop(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); - addDrop(PromenadeBlocks.DARK_AMARANTH_ROOTS); - addPottedPlantDrops(PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS); - - addDrop(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); - addDrop(PromenadeBlocks.DARK_AMARANTH_STEM); - addDrop(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); - addDrop(PromenadeBlocks.DARK_AMARANTH_HYPHAE); - addDrop(PromenadeBlocks.DARK_AMARANTH_PLANKS); - addDrop(PromenadeBlocks.DARK_AMARANTH_STAIRS); - addDrop(PromenadeBlocks.DARK_AMARANTH_SLAB, this::slabDrops); - addDrop(PromenadeBlocks.DARK_AMARANTH_FENCE); - addDrop(PromenadeBlocks.DARK_AMARANTH_FENCE_GATE); - addDrop(PromenadeBlocks.DARK_AMARANTH_DOOR, this::doorDrops); - addDrop(PromenadeBlocks.DARK_AMARANTH_TRAPDOOR); - addDrop(PromenadeBlocks.DARK_AMARANTH_BUTTON); - addDrop(PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE); - addDrop(PromenadeBlocks.DARK_AMARANTH_SIGN); - addDrop(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN); - - addDrop(PromenadeBlocks.DARK_AMARANTH_FUNGUS); - addPottedPlantDrops(PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS); - - addDrop(PromenadeBlocks.SOUL_SHROOMLIGHT); - - addVinePlantDrop(PromenadeBlocks.COILED_VINES, PromenadeBlocks.COILED_VINES_PLANT); - - addDrop(PromenadeBlocks.MOAI); - - //TODO: generify this fat block of code - this.addDrop( - PromenadeBlocks.BLUEBERRY_BUSH, - block -> this.applyExplosionDecay( - block, - LootTable.builder() - .pool( - LootPool.builder() - .conditionally( - BlockStatePropertyLootCondition.builder(PromenadeBlocks.BLUEBERRY_BUSH).properties(StatePredicate.Builder.create().exactMatch(BerryBushBlock.AGE, 3)) - ) - .with(ItemEntry.builder(PromenadeItems.BLUEBERRIES)) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 3.0F))) - .apply(ApplyBonusLootFunction.uniformBonusCount(enchantments.getOrThrow(Enchantments.FORTUNE))) - ) - .pool( - LootPool.builder() - .conditionally( - BlockStatePropertyLootCondition.builder(PromenadeBlocks.BLUEBERRY_BUSH).properties(StatePredicate.Builder.create().exactMatch(BerryBushBlock.AGE, 2)) - ) - .with(ItemEntry.builder(PromenadeItems.BLUEBERRIES)) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1.0F, 2.0F))) - .apply(ApplyBonusLootFunction.uniformBonusCount(enchantments.getOrThrow(Enchantments.FORTUNE))) - ) - ) - ); - - this.lootTables.forEach((id, lootTable) -> lootTable.randomSequenceId(id.getValue())); - } - - public LootTable.Builder snowyLeavesDrops(Block leaves, Block sapling, float... saplingChance) { - return this.leavesDrops(leaves, sapling, saplingChance) - .pool( - LootPool.builder() - .conditionally(this.createWithoutShearsOrSilkTouchCondition()) - .with( - this.addSurvivesExplosionCondition(leaves, - ItemEntry.builder(Items.SNOWBALL) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 4.0F))) - ) - )); - } - - public LootTable.Builder snowyMangroveLeavesDrops(Block leaves) { - return this.mangroveLeavesDrops(leaves) - .pool( - LootPool.builder() - .conditionally(this.createWithoutShearsOrSilkTouchCondition()) - .with( - this.addSurvivesExplosionCondition(leaves, - ItemEntry.builder(Items.SNOWBALL).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 4.0F))) - ) - )); - } - - public LootTable.Builder fruitLeavesDrops(Block leaves, Block sapling, Item fruit, float... saplingChance) { - RegistryWrapper.Impl impl = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT); - return this.leavesDrops(leaves, sapling, saplingChance) - .pool(LootPool.builder() - .conditionally(this.createWithoutSilkTouchCondition()) - .with( - this.addSurvivesExplosionCondition(leaves, ItemEntry.builder(fruit)) - .conditionally(TableBonusLootCondition.builder(impl.getOrThrow(Enchantments.FORTUNE), 0.005F, 0.0055555557F, 0.00625F, 0.008333334F, 0.025F)) - ) - ); - } - - public LootTable.Builder snowyFruitLeavesDrop(Block leaves, Block sapling, Item fruit, float... saplingChance) { - return this.fruitLeavesDrops(leaves, sapling, fruit, saplingChance) - .pool(LootPool.builder() - .conditionally(this.createWithoutShearsOrSilkTouchCondition()) - .with( - this.addSurvivesExplosionCondition(leaves, - ItemEntry.builder(Items.SNOWBALL).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 4.0F))) - ) - ) - ); - } - - public Function flowerPile(Item flower) { - return block -> this.flowerPile(block, flower); - } - - public LootTable.Builder flowerPile(Block pile, Item flower) { - return this.dropsWithSilkTouchOrShears( - pile, - this.applyExplosionDecay(pile, ItemEntry.builder(flower).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 3.0F)))) - ); - } + private static final float[] JUNGLE_SAPLING_DROP_CHANCE = new float[]{0.025F, 0.027777778F, 0.03125F, 0.041666668F, 0.1F}; + protected static final float[] SAPLING_DROP_CHANCE = new float[]{0.05F, 0.0625F, 0.083333336F, 0.1F}; + private static final float[] LEAVES_STICK_DROP_CHANCE = new float[]{0.02F, 0.022222223F, 0.025F, 0.033333335F, 0.1F}; + + public PromenadeBlockLootTableProvider(FabricDataOutput dataOutput, CompletableFuture registryLookup) { + super(dataOutput, registryLookup); + } + + @Override + public void generate() { + final var enchantments = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT); + + addDrop(PromenadeBlocks.ASPHALT); + addDrop(PromenadeBlocks.ASPHALT_SLAB, this::slabDrops); + addDrop(PromenadeBlocks.ASPHALT_STAIRS); + addDrop(PromenadeBlocks.ASPHALT_WALL); + addDrop(PromenadeBlocks.POLISHED_ASPHALT); + addDrop(PromenadeBlocks.POLISHED_ASPHALT_SLAB, this::slabDrops); + addDrop(PromenadeBlocks.POLISHED_ASPHALT_STAIRS); + + addDrop(PromenadeBlocks.BLUNITE); + addDrop(PromenadeBlocks.BLUNITE_SLAB, this::slabDrops); + addDrop(PromenadeBlocks.BLUNITE_STAIRS); + addDrop(PromenadeBlocks.BLUNITE_WALL); + addDrop(PromenadeBlocks.POLISHED_BLUNITE); + addDrop(PromenadeBlocks.POLISHED_BLUNITE_SLAB, this::slabDrops); + addDrop(PromenadeBlocks.POLISHED_BLUNITE_STAIRS); + + addDrop(PromenadeBlocks.OAK_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.SPRUCE_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.BIRCH_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.JUNGLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.ACACIA_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.CHERRY_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.DARK_OAK_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.PALE_OAK_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.MANGROVE_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.AZALEA_LEAF_PILE, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, this::dropsWithSilkTouchOrShears); + + addDrop(PromenadeBlocks.DANDELION_PILE, flowerPile(Items.DANDELION)); + addDrop(PromenadeBlocks.POPPY_PILE, flowerPile(Items.POPPY)); + addDrop(PromenadeBlocks.BLUE_ORCHID_PILE, flowerPile(Items.BLUE_ORCHID)); + addDrop(PromenadeBlocks.ALLIUM_PILE, flowerPile(Items.ALLIUM)); + addDrop(PromenadeBlocks.AZURE_BLUET_PILE, flowerPile(Items.AZURE_BLUET)); + addDrop(PromenadeBlocks.RED_TULIP_PILE, flowerPile(Items.RED_TULIP)); + addDrop(PromenadeBlocks.ORANGE_TULIP_PILE, flowerPile(Items.ORANGE_TULIP)); + addDrop(PromenadeBlocks.WHITE_TULIP_PILE, flowerPile(Items.WHITE_TULIP)); + addDrop(PromenadeBlocks.PINK_TULIP_PILE, flowerPile(Items.PINK_TULIP)); + addDrop(PromenadeBlocks.OXEYE_DAISY_PILE, flowerPile(Items.OXEYE_DAISY)); + addDrop(PromenadeBlocks.CORNFLOWER_PILE, flowerPile(Items.CORNFLOWER)); + addDrop(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, flowerPile(Items.LILY_OF_THE_VALLEY)); + addDrop(PromenadeBlocks.WITHER_ROSE_PILE, flowerPile(Items.WITHER_ROSE)); + + addDrop(PromenadeBlocks.SNOWY_OAK_LEAVES, block -> this.snowyFruitLeavesDrop(block, Blocks.OAK_SAPLING, Items.APPLE, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.SPRUCE_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_BIRCH_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.BIRCH_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.JUNGLE_SAPLING, JUNGLE_SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_ACACIA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.ACACIA_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_CHERRY_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.CHERRY_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, block -> this.snowyFruitLeavesDrop(block, Blocks.DARK_OAK_SAPLING, Items.APPLE, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.PALE_OAK_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, this::snowyMangroveLeavesDrops); + addDrop(PromenadeBlocks.SNOWY_AZALEA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.AZALEA, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, block -> this.snowyLeavesDrops(block, Blocks.FLOWERING_AZALEA, SAPLING_DROP_CHANCE)); + + addDrop(PromenadeBlocks.STRIPPED_SAKURA_LOG); + addDrop(PromenadeBlocks.SAKURA_LOG); + addDrop(PromenadeBlocks.STRIPPED_SAKURA_WOOD); + addDrop(PromenadeBlocks.SAKURA_WOOD); + addDrop(PromenadeBlocks.SAKURA_PLANKS); + addDrop(PromenadeBlocks.SAKURA_STAIRS); + addDrop(PromenadeBlocks.SAKURA_SLAB, this::slabDrops); + addDrop(PromenadeBlocks.SAKURA_FENCE); + addDrop(PromenadeBlocks.SAKURA_FENCE_GATE); + addDrop(PromenadeBlocks.SAKURA_DOOR, this::doorDrops); + addDrop(PromenadeBlocks.SAKURA_TRAPDOOR); + addDrop(PromenadeBlocks.SAKURA_BUTTON); + addDrop(PromenadeBlocks.SAKURA_PRESSURE_PLATE); + addDrop(PromenadeBlocks.SAKURA_SIGN); + addDrop(PromenadeBlocks.SAKURA_HANGING_SIGN); + + addDrop(PromenadeBlocks.BLUSH_SAKURA_SAPLING); + addPottedPlantDrops(PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING); + addDrop(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, block -> this.leavesDrops(block, PromenadeBlocks.BLUSH_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, block -> this.snowyLeavesDrops(block, PromenadeBlocks.BLUSH_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, this::dropsWithSilkTouchOrShears); + + addDrop(PromenadeBlocks.COTTON_SAKURA_SAPLING); + addPottedPlantDrops(PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING); + addDrop(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, block -> this.leavesDrops(block, PromenadeBlocks.COTTON_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, block -> this.snowyLeavesDrops(block, PromenadeBlocks.COTTON_SAKURA_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, this::dropsWithSilkTouchOrShears); + + addDrop(PromenadeBlocks.STRIPPED_MAPLE_LOG); + addDrop(PromenadeBlocks.MAPLE_LOG); + addDrop(PromenadeBlocks.STRIPPED_MAPLE_WOOD); + addDrop(PromenadeBlocks.MAPLE_WOOD); + addDrop(PromenadeBlocks.MAPLE_PLANKS); + addDrop(PromenadeBlocks.MAPLE_STAIRS); + addDrop(PromenadeBlocks.MAPLE_SLAB, this::slabDrops); + addDrop(PromenadeBlocks.MAPLE_FENCE); + addDrop(PromenadeBlocks.MAPLE_FENCE_GATE); + addDrop(PromenadeBlocks.MAPLE_DOOR, this::doorDrops); + addDrop(PromenadeBlocks.MAPLE_TRAPDOOR); + addDrop(PromenadeBlocks.MAPLE_BUTTON); + addDrop(PromenadeBlocks.MAPLE_PRESSURE_PLATE); + addDrop(PromenadeBlocks.MAPLE_SIGN); + addDrop(PromenadeBlocks.MAPLE_HANGING_SIGN); + + addDrop(PromenadeBlocks.SAP_MAPLE_SAPLING); + addPottedPlantDrops(PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING); + addDrop(PromenadeBlocks.SAP_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.SAP_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.SAP_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); + + addDrop(PromenadeBlocks.VERMILION_MAPLE_SAPLING); + addPottedPlantDrops(PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING); + addDrop(PromenadeBlocks.VERMILION_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.VERMILION_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.VERMILION_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); + + addDrop(PromenadeBlocks.FULVOUS_MAPLE_SAPLING); + addPottedPlantDrops(PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING); + addDrop(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); + + addDrop(PromenadeBlocks.MIKADO_MAPLE_SAPLING); + addPottedPlantDrops(PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING); + addDrop(PromenadeBlocks.MIKADO_MAPLE_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.MIKADO_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.MIKADO_MAPLE_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, this::dropsWithSilkTouchOrShears); + + addDrop(PromenadeBlocks.STRIPPED_PALM_LOG); + addDrop(PromenadeBlocks.PALM_LOG); + addDrop(PromenadeBlocks.STRIPPED_PALM_WOOD); + addDrop(PromenadeBlocks.PALM_WOOD); + addDrop(PromenadeBlocks.PALM_PLANKS); + addDrop(PromenadeBlocks.PALM_STAIRS); + addDrop(PromenadeBlocks.PALM_SLAB, this::slabDrops); + addDrop(PromenadeBlocks.PALM_FENCE); + addDrop(PromenadeBlocks.PALM_FENCE_GATE); + addDrop(PromenadeBlocks.PALM_DOOR, this::doorDrops); + addDrop(PromenadeBlocks.PALM_TRAPDOOR); + addDrop(PromenadeBlocks.PALM_BUTTON); + addDrop(PromenadeBlocks.PALM_PRESSURE_PLATE); + addDrop(PromenadeBlocks.PALM_SIGN); + addDrop(PromenadeBlocks.PALM_HANGING_SIGN); + + addDrop(PromenadeBlocks.PALM_SAPLING); + addPottedPlantDrops(PromenadeBlocks.POTTED_PALM_SAPLING); + addDrop(PromenadeBlocks.PALM_LEAVES, block -> this.leavesDrops(block, PromenadeBlocks.PALM_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.SNOWY_PALM_LEAVES, block -> this.snowyLeavesDrops(block, PromenadeBlocks.PALM_SAPLING, SAPLING_DROP_CHANCE)); + addDrop(PromenadeBlocks.PALM_HANGING_LEAVES, this::dropsWithSilkTouchOrShears); + addDrop(PromenadeBlocks.PALM_LEAF_PILE, this::dropsWithSilkTouchOrShears); + + addDrop(PromenadeBlocks.DARK_AMARANTH_NYLIUM, block -> this.drops(block, Blocks.NETHERRACK)); + addDrop(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); + addDrop(PromenadeBlocks.DARK_AMARANTH_ROOTS); + addPottedPlantDrops(PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS); + + addDrop(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); + addDrop(PromenadeBlocks.DARK_AMARANTH_STEM); + addDrop(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); + addDrop(PromenadeBlocks.DARK_AMARANTH_HYPHAE); + addDrop(PromenadeBlocks.DARK_AMARANTH_PLANKS); + addDrop(PromenadeBlocks.DARK_AMARANTH_STAIRS); + addDrop(PromenadeBlocks.DARK_AMARANTH_SLAB, this::slabDrops); + addDrop(PromenadeBlocks.DARK_AMARANTH_FENCE); + addDrop(PromenadeBlocks.DARK_AMARANTH_FENCE_GATE); + addDrop(PromenadeBlocks.DARK_AMARANTH_DOOR, this::doorDrops); + addDrop(PromenadeBlocks.DARK_AMARANTH_TRAPDOOR); + addDrop(PromenadeBlocks.DARK_AMARANTH_BUTTON); + addDrop(PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE); + addDrop(PromenadeBlocks.DARK_AMARANTH_SIGN); + addDrop(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN); + + addDrop(PromenadeBlocks.DARK_AMARANTH_FUNGUS); + addPottedPlantDrops(PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS); + + addDrop(PromenadeBlocks.SOUL_SHROOMLIGHT); + + addVinePlantDrop(PromenadeBlocks.COILED_VINES, PromenadeBlocks.COILED_VINES_PLANT); + + addDrop(PromenadeBlocks.MOAI); + + //TODO: generify this fat block of code + this.addDrop( + PromenadeBlocks.BLUEBERRY_BUSH, + block -> this.applyExplosionDecay( + block, + LootTable.builder() + .pool( + LootPool.builder() + .conditionally( + BlockStatePropertyLootCondition.builder(PromenadeBlocks.BLUEBERRY_BUSH).properties(StatePredicate.Builder.create().exactMatch(BerryBushBlock.AGE, 3)) + ) + .with(ItemEntry.builder(PromenadeItems.BLUEBERRIES)) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 3.0F))) + .apply(ApplyBonusLootFunction.uniformBonusCount(enchantments.getOrThrow(Enchantments.FORTUNE))) + ) + .pool( + LootPool.builder() + .conditionally( + BlockStatePropertyLootCondition.builder(PromenadeBlocks.BLUEBERRY_BUSH).properties(StatePredicate.Builder.create().exactMatch(BerryBushBlock.AGE, 2)) + ) + .with(ItemEntry.builder(PromenadeItems.BLUEBERRIES)) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1.0F, 2.0F))) + .apply(ApplyBonusLootFunction.uniformBonusCount(enchantments.getOrThrow(Enchantments.FORTUNE))) + ) + ) + ); + + this.lootTables.forEach((id, lootTable) -> lootTable.randomSequenceId(id.getValue())); + } + + public LootTable.Builder snowyLeavesDrops(Block leaves, Block sapling, float... saplingChance) { + return this.leavesDrops(leaves, sapling, saplingChance) + .pool( + LootPool.builder() + .conditionally(this.createWithoutShearsOrSilkTouchCondition()) + .with( + this.addSurvivesExplosionCondition(leaves, + ItemEntry.builder(Items.SNOWBALL) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 4.0F))) + ) + )); + } + + public LootTable.Builder snowyMangroveLeavesDrops(Block leaves) { + return this.mangroveLeavesDrops(leaves) + .pool( + LootPool.builder() + .conditionally(this.createWithoutShearsOrSilkTouchCondition()) + .with( + this.addSurvivesExplosionCondition(leaves, + ItemEntry.builder(Items.SNOWBALL).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 4.0F))) + ) + )); + } + + public LootTable.Builder fruitLeavesDrops(Block leaves, Block sapling, Item fruit, float... saplingChance) { + RegistryWrapper.Impl impl = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT); + return this.leavesDrops(leaves, sapling, saplingChance) + .pool(LootPool.builder() + .conditionally(this.createWithoutSilkTouchCondition()) + .with( + this.addSurvivesExplosionCondition(leaves, ItemEntry.builder(fruit)) + .conditionally(TableBonusLootCondition.builder(impl.getOrThrow(Enchantments.FORTUNE), 0.005F, 0.0055555557F, 0.00625F, 0.008333334F, 0.025F)) + ) + ); + } + + public LootTable.Builder snowyFruitLeavesDrop(Block leaves, Block sapling, Item fruit, float... saplingChance) { + return this.fruitLeavesDrops(leaves, sapling, fruit, saplingChance) + .pool(LootPool.builder() + .conditionally(this.createWithoutShearsOrSilkTouchCondition()) + .with( + this.addSurvivesExplosionCondition(leaves, + ItemEntry.builder(Items.SNOWBALL).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 4.0F))) + ) + ) + ); + } + + public Function flowerPile(Item flower) { + return block -> this.flowerPile(block, flower); + } + + public LootTable.Builder flowerPile(Block pile, Item flower) { + return this.dropsWithSilkTouchOrShears( + pile, + this.applyExplosionDecay(pile, ItemEntry.builder(flower).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0F, 3.0F)))) + ); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockTagProvider.java index e1596e1a..937139cb 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeBlockTagProvider.java @@ -1,222 +1,234 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; -import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags; +import static fr.hugman.promenade.block.PromenadeBlocks.*; +import static fr.hugman.promenade.tag.PromenadeBlockTags.*; + +import java.util.concurrent.CompletableFuture; + import net.minecraft.block.Blocks; import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.tag.BlockTags; -import java.util.concurrent.CompletableFuture; - -import static fr.hugman.promenade.block.PromenadeBlocks.*; -import static fr.hugman.promenade.tag.PromenadeBlockTags.*; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags; public class PromenadeBlockTagProvider extends FabricTagProvider.BlockTagProvider { - public PromenadeBlockTagProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { - // Promenade - valueLookupBuilder(SAKURA_LOGS).add(SAKURA_LOG, STRIPPED_SAKURA_LOG, SAKURA_WOOD, STRIPPED_SAKURA_WOOD); - valueLookupBuilder(MAPLE_LOGS).add(MAPLE_LOG, STRIPPED_MAPLE_LOG, MAPLE_WOOD, STRIPPED_MAPLE_WOOD); - valueLookupBuilder(PALM_LOGS).add(PALM_LOG, STRIPPED_PALM_LOG, PALM_WOOD, STRIPPED_PALM_WOOD); - valueLookupBuilder(DARK_AMARANTH_STEMS).add(DARK_AMARANTH_STEM, STRIPPED_DARK_AMARANTH_STEM, DARK_AMARANTH_HYPHAE, STRIPPED_DARK_AMARANTH_HYPHAE); - - valueLookupBuilder(SNOWY_LEAVES).add( - SNOWY_OAK_LEAVES, - SNOWY_SPRUCE_LEAVES, - SNOWY_BIRCH_LEAVES, - SNOWY_JUNGLE_LEAVES, - SNOWY_ACACIA_LEAVES, - SNOWY_CHERRY_LEAVES, - SNOWY_DARK_OAK_LEAVES, - SNOWY_PALE_OAK_LEAVES, - SNOWY_MANGROVE_LEAVES, - SNOWY_AZALEA_LEAVES, - SNOWY_FLOWERING_AZALEA_LEAVES, - SNOWY_BLUSH_SAKURA_BLOSSOMS, - SNOWY_COTTON_SAKURA_BLOSSOMS, - SNOWY_SAP_MAPLE_LEAVES, - SNOWY_VERMILION_MAPLE_LEAVES, - SNOWY_FULVOUS_MAPLE_LEAVES, - SNOWY_MIKADO_MAPLE_LEAVES, - SNOWY_PALM_LEAVES - ); - - valueLookupBuilder(FALLEN_LEAVES).add( - FALLEN_SAP_MAPLE_LEAVES, - FALLEN_VERMILION_MAPLE_LEAVES, - FALLEN_FULVOUS_MAPLE_LEAVES, - FALLEN_MIKADO_MAPLE_LEAVES - ); - valueLookupBuilder(LEAF_PILES).add( - OAK_LEAF_PILE, - SPRUCE_LEAF_PILE, - BIRCH_LEAF_PILE, - JUNGLE_LEAF_PILE, - ACACIA_LEAF_PILE, - CHERRY_LEAF_PILE, - DARK_OAK_LEAF_PILE, - PALE_OAK_LEAF_PILE, - MANGROVE_LEAF_PILE, - AZALEA_LEAF_PILE, - FLOWERING_AZALEA_LEAF_PILE, - VERMILION_MAPLE_LEAF_PILE, - FULVOUS_MAPLE_LEAF_PILE, - MIKADO_MAPLE_LEAF_PILE, - SAP_MAPLE_LEAF_PILE, - BLUSH_SAKURA_BLOSSOM_PILE, - COTTON_SAKURA_BLOSSOM_PILE, - PALM_LEAF_PILE - ); - - valueLookupBuilder(FLOWER_PILES).add( - DANDELION_PILE, - POPPY_PILE, - BLUE_ORCHID_PILE, - ALLIUM_PILE, - AZURE_BLUET_PILE, - RED_TULIP_PILE, - ORANGE_TULIP_PILE, - WHITE_TULIP_PILE, - PINK_TULIP_PILE, - OXEYE_DAISY_PILE, - CORNFLOWER_PILE, - LILY_OF_THE_VALLEY_PILE, - WITHER_ROSE_PILE - ); - - valueLookupBuilder(DARK_AMARANTH_FUNGUS_GROWABLE_ON).add(DARK_AMARANTH_NYLIUM); - valueLookupBuilder(DARK_AMARANTH_FUNGUS_PLACEABLE_ON) - .addTag(DARK_AMARANTH_FUNGUS_GROWABLE_ON) - .forceAddTag(BlockTags.NYLIUM) - .add(Blocks.MYCELIUM) - .add(Blocks.SOUL_SOIL) - .add(Blocks.DIRT) - .add(Blocks.FARMLAND); - valueLookupBuilder(DARK_AMARANTH_ROOTS_PLACEABLE_ON) - .forceAddTag(BlockTags.NYLIUM) - .add(Blocks.SOUL_SOIL) - .add(Blocks.DIRT) - .add(Blocks.FARMLAND); - - // Vanilla - valueLookupBuilder(BlockTags.BASE_STONE_OVERWORLD).add(ASPHALT, BLUNITE); - valueLookupBuilder(BlockTags.STONE_ORE_REPLACEABLES).add(ASPHALT, BLUNITE); - - - valueLookupBuilder(BlockTags.SLABS).add(ASPHALT_SLAB, BLUNITE_SLAB, POLISHED_ASPHALT_SLAB, POLISHED_BLUNITE_SLAB); - valueLookupBuilder(BlockTags.STAIRS).add(ASPHALT_STAIRS, BLUNITE_STAIRS, POLISHED_ASPHALT_STAIRS, POLISHED_BLUNITE_STAIRS); - valueLookupBuilder(BlockTags.WALLS).add(ASPHALT_WALL, BLUNITE_WALL); - - valueLookupBuilder(BlockTags.LOGS).addTag(DARK_AMARANTH_STEMS); - valueLookupBuilder(BlockTags.LOGS_THAT_BURN).addTag(SAKURA_LOGS).addTag(MAPLE_LOGS).addTag(PALM_LOGS); - valueLookupBuilder(BlockTags.OVERWORLD_NATURAL_LOGS).add(SAKURA_LOG, MAPLE_LOG, PALM_LOG); - valueLookupBuilder(BlockTags.PLANKS).add(SAKURA_PLANKS, MAPLE_PLANKS, PALM_PLANKS, DARK_AMARANTH_PLANKS); - valueLookupBuilder(BlockTags.WOODEN_BUTTONS).add(SAKURA_BUTTON, MAPLE_BUTTON, PALM_BUTTON, DARK_AMARANTH_BUTTON); - valueLookupBuilder(BlockTags.WOODEN_DOORS).add(SAKURA_DOOR, MAPLE_DOOR, PALM_DOOR, DARK_AMARANTH_DOOR); - valueLookupBuilder(BlockTags.WOODEN_FENCES).add(SAKURA_FENCE, MAPLE_FENCE, PALM_FENCE, DARK_AMARANTH_FENCE); - valueLookupBuilder(BlockTags.WOODEN_PRESSURE_PLATES).add(SAKURA_PRESSURE_PLATE, MAPLE_PRESSURE_PLATE, PALM_PRESSURE_PLATE, DARK_AMARANTH_PRESSURE_PLATE); - valueLookupBuilder(BlockTags.WOODEN_SLABS).add(SAKURA_SLAB, MAPLE_SLAB, PALM_SLAB, DARK_AMARANTH_SLAB); - valueLookupBuilder(BlockTags.WOODEN_STAIRS).add(SAKURA_STAIRS, MAPLE_STAIRS, PALM_STAIRS, DARK_AMARANTH_STAIRS); - valueLookupBuilder(BlockTags.WOODEN_TRAPDOORS).add(SAKURA_TRAPDOOR, MAPLE_TRAPDOOR, PALM_TRAPDOOR, DARK_AMARANTH_TRAPDOOR); - valueLookupBuilder(BlockTags.FENCE_GATES).add(SAKURA_FENCE_GATE, MAPLE_FENCE_GATE, PALM_FENCE_GATE, DARK_AMARANTH_FENCE_GATE); - valueLookupBuilder(BlockTags.STANDING_SIGNS).add(SAKURA_SIGN, MAPLE_SIGN, PALM_SIGN, DARK_AMARANTH_SIGN); - valueLookupBuilder(BlockTags.WALL_SIGNS).add(SAKURA_WALL_SIGN, MAPLE_WALL_SIGN, PALM_WALL_SIGN, DARK_AMARANTH_WALL_SIGN); - valueLookupBuilder(BlockTags.CEILING_HANGING_SIGNS).add(SAKURA_HANGING_SIGN, MAPLE_HANGING_SIGN, PALM_HANGING_SIGN, DARK_AMARANTH_HANGING_SIGN); - valueLookupBuilder(BlockTags.WALL_HANGING_SIGNS).add(SAKURA_WALL_HANGING_SIGN, MAPLE_WALL_HANGING_SIGN, PALM_WALL_HANGING_SIGN, DARK_AMARANTH_WALL_HANGING_SIGN); - - valueLookupBuilder(BlockTags.LEAVES).add( - VERMILION_MAPLE_LEAVES, - FULVOUS_MAPLE_LEAVES, - MIKADO_MAPLE_LEAVES, - SAP_MAPLE_LEAVES, - BLUSH_SAKURA_BLOSSOMS, - COTTON_SAKURA_BLOSSOMS, - PALM_LEAVES - ).addTag(SNOWY_LEAVES); - valueLookupBuilder(BlockTags.SAPLINGS).add( - BLUSH_SAKURA_SAPLING, COTTON_SAKURA_SAPLING, - SAP_MAPLE_SAPLING, VERMILION_MAPLE_SAPLING, FULVOUS_MAPLE_SAPLING, MIKADO_MAPLE_SAPLING, - PALM_SAPLING); - - valueLookupBuilder(BlockTags.BEE_ATTRACTIVE).add(AZALEA_LEAF_PILE, FLOWERING_AZALEA_LEAF_PILE); - valueLookupBuilder(BlockTags.FLOWERS).add(AZALEA_LEAF_PILE, FLOWERING_AZALEA_LEAF_PILE); - valueLookupBuilder(BlockTags.FLOWER_POTS).add( - POTTED_BLUSH_SAKURA_SAPLING, POTTED_COTTON_SAKURA_SAPLING, - POTTED_SAP_MAPLE_SAPLING, POTTED_VERMILION_MAPLE_SAPLING, POTTED_FULVOUS_MAPLE_SAPLING, POTTED_MIKADO_MAPLE_SAPLING, - POTTED_PALM_SAPLING, - POTTED_DARK_AMARANTH_FUNGUS, POTTED_DARK_AMARANTH_ROOTS - ); - - valueLookupBuilder(BlockTags.REPLACEABLE_BY_TREES) - .addTag(FALLEN_LEAVES) - .addTag(LEAF_PILES) - .addTag(FLOWER_PILES) - .add(DARK_AMARANTH_ROOTS); - valueLookupBuilder(BlockTags.BEE_GROWABLES).add(BLUEBERRY_BUSH); - valueLookupBuilder(BlockTags.MUSHROOM_GROW_BLOCK).add(DARK_AMARANTH_NYLIUM); - - valueLookupBuilder(BlockTags.NYLIUM).add(DARK_AMARANTH_NYLIUM); - valueLookupBuilder(BlockTags.WART_BLOCKS).add(DARK_AMARANTH_WART_BLOCK); - valueLookupBuilder(BlockTags.SOUL_FIRE_BASE_BLOCKS).add(DARK_AMARANTH_NYLIUM, DARK_AMARANTH_WART_BLOCK, SOUL_SHROOMLIGHT); - - valueLookupBuilder(BlockTags.ENDERMAN_HOLDABLE).add(DARK_AMARANTH_FUNGUS, DARK_AMARANTH_NYLIUM, DARK_AMARANTH_ROOTS); - - valueLookupBuilder(BlockTags.INSIDE_STEP_SOUND_BLOCKS).addTag(FALLEN_LEAVES); - valueLookupBuilder(BlockTags.COMBINATION_STEP_SOUND_BLOCKS).add(DARK_AMARANTH_ROOTS); - - valueLookupBuilder(BlockTags.CLIMBABLE).add(COILED_VINES, COILED_VINES_PLANT); - valueLookupBuilder(BlockTags.REPLACEABLE).addTag(FALLEN_LEAVES); - - valueLookupBuilder(BlockTags.SWORD_EFFICIENT) - .addTag(LEAF_PILES) - .addTag(FLOWER_PILES) - .add(DARK_AMARANTH_ROOTS, COILED_VINES, COILED_VINES_PLANT); - valueLookupBuilder(BlockTags.PICKAXE_MINEABLE).add( - BLUNITE, - BLUNITE_STAIRS, - BLUNITE_SLAB, - ASPHALT, - ASPHALT_STAIRS, - ASPHALT_SLAB, - POLISHED_BLUNITE, - POLISHED_BLUNITE_STAIRS, - POLISHED_BLUNITE_SLAB, - POLISHED_ASPHALT, - POLISHED_ASPHALT_STAIRS, - POLISHED_ASPHALT_SLAB, - MOAI, - DARK_AMARANTH_NYLIUM - ); - valueLookupBuilder(BlockTags.AXE_MINEABLE).add(DARK_AMARANTH_FUNGUS, COILED_VINES, COILED_VINES_PLANT); - valueLookupBuilder(BlockTags.HOE_MINEABLE) - .add( - VERMILION_MAPLE_LEAVES, - FULVOUS_MAPLE_LEAVES, - MIKADO_MAPLE_LEAVES, - SAP_MAPLE_LEAVES, - BLUSH_SAKURA_BLOSSOMS, - COTTON_SAKURA_BLOSSOMS, - PALM_LEAVES - ) - .addTag(SNOWY_LEAVES) - .addTag(FLOWER_PILES) - .addTag(LEAF_PILES) - .add(DARK_AMARANTH_WART_BLOCK, SOUL_SHROOMLIGHT); - - - // Conventional - valueLookupBuilder(ConventionalBlockTags.STONES).add(ASPHALT, BLUNITE); - valueLookupBuilder(ConventionalBlockTags.FENCES).add(SAKURA_FENCE, MAPLE_FENCE, PALM_FENCE, DARK_AMARANTH_FENCE); - valueLookupBuilder(ConventionalBlockTags.WOODEN_FENCES).add(SAKURA_FENCE, MAPLE_FENCE, PALM_FENCE, DARK_AMARANTH_FENCE); - valueLookupBuilder(ConventionalBlockTags.FENCE_GATES).add(SAKURA_FENCE_GATE, MAPLE_FENCE_GATE, PALM_FENCE_GATE, DARK_AMARANTH_FENCE_GATE); - valueLookupBuilder(ConventionalBlockTags.WOODEN_FENCE_GATES).add(SAKURA_FENCE_GATE, MAPLE_FENCE_GATE, PALM_FENCE_GATE, DARK_AMARANTH_FENCE_GATE); - valueLookupBuilder(ConventionalBlockTags.STRIPPED_LOGS).add(STRIPPED_SAKURA_LOG, STRIPPED_MAPLE_LOG, STRIPPED_PALM_LOG, STRIPPED_DARK_AMARANTH_STEM); - valueLookupBuilder(ConventionalBlockTags.STRIPPED_WOODS).add(STRIPPED_SAKURA_WOOD, STRIPPED_MAPLE_WOOD, STRIPPED_PALM_WOOD, STRIPPED_DARK_AMARANTH_HYPHAE); - - } + public PromenadeBlockTagProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + // Promenade + valueLookupBuilder(SAKURA_LOGS).add(SAKURA_LOG, STRIPPED_SAKURA_LOG, SAKURA_WOOD, STRIPPED_SAKURA_WOOD); + valueLookupBuilder(MAPLE_LOGS).add(MAPLE_LOG, STRIPPED_MAPLE_LOG, MAPLE_WOOD, STRIPPED_MAPLE_WOOD); + valueLookupBuilder(PALM_LOGS).add(PALM_LOG, STRIPPED_PALM_LOG, PALM_WOOD, STRIPPED_PALM_WOOD); + valueLookupBuilder(DARK_AMARANTH_STEMS).add(DARK_AMARANTH_STEM, STRIPPED_DARK_AMARANTH_STEM, DARK_AMARANTH_HYPHAE, STRIPPED_DARK_AMARANTH_HYPHAE); + + valueLookupBuilder(SNOWY_LEAVES).add( + SNOWY_OAK_LEAVES, + SNOWY_SPRUCE_LEAVES, + SNOWY_BIRCH_LEAVES, + SNOWY_JUNGLE_LEAVES, + SNOWY_ACACIA_LEAVES, + SNOWY_CHERRY_LEAVES, + SNOWY_DARK_OAK_LEAVES, + SNOWY_PALE_OAK_LEAVES, + SNOWY_MANGROVE_LEAVES, + SNOWY_AZALEA_LEAVES, + SNOWY_FLOWERING_AZALEA_LEAVES, + SNOWY_BLUSH_SAKURA_BLOSSOMS, + SNOWY_COTTON_SAKURA_BLOSSOMS, + SNOWY_SAP_MAPLE_LEAVES, + SNOWY_VERMILION_MAPLE_LEAVES, + SNOWY_FULVOUS_MAPLE_LEAVES, + SNOWY_MIKADO_MAPLE_LEAVES, + SNOWY_PALM_LEAVES + ); + + valueLookupBuilder(FALLEN_LEAVES).add( + FALLEN_SAP_MAPLE_LEAVES, + FALLEN_VERMILION_MAPLE_LEAVES, + FALLEN_FULVOUS_MAPLE_LEAVES, + FALLEN_MIKADO_MAPLE_LEAVES + ); + valueLookupBuilder(LEAF_PILES).add( + OAK_LEAF_PILE, + SPRUCE_LEAF_PILE, + BIRCH_LEAF_PILE, + JUNGLE_LEAF_PILE, + ACACIA_LEAF_PILE, + CHERRY_LEAF_PILE, + DARK_OAK_LEAF_PILE, + PALE_OAK_LEAF_PILE, + MANGROVE_LEAF_PILE, + AZALEA_LEAF_PILE, + FLOWERING_AZALEA_LEAF_PILE, + VERMILION_MAPLE_LEAF_PILE, + FULVOUS_MAPLE_LEAF_PILE, + MIKADO_MAPLE_LEAF_PILE, + SAP_MAPLE_LEAF_PILE, + BLUSH_SAKURA_BLOSSOM_PILE, + COTTON_SAKURA_BLOSSOM_PILE, + PALM_LEAF_PILE + ); + + valueLookupBuilder(FLOWER_PILES).add( + DANDELION_PILE, + POPPY_PILE, + BLUE_ORCHID_PILE, + ALLIUM_PILE, + AZURE_BLUET_PILE, + RED_TULIP_PILE, + ORANGE_TULIP_PILE, + WHITE_TULIP_PILE, + PINK_TULIP_PILE, + OXEYE_DAISY_PILE, + CORNFLOWER_PILE, + LILY_OF_THE_VALLEY_PILE, + WITHER_ROSE_PILE + ); + + valueLookupBuilder(DARK_AMARANTH_FUNGUS_GROWABLE_ON).add(DARK_AMARANTH_NYLIUM); + valueLookupBuilder(DARK_AMARANTH_FUNGUS_PLACEABLE_ON) + .addTag(DARK_AMARANTH_FUNGUS_GROWABLE_ON) + .forceAddTag(BlockTags.NYLIUM) + .add(Blocks.MYCELIUM) + .add(Blocks.SOUL_SOIL) + .add(Blocks.DIRT) + .add(Blocks.FARMLAND); + valueLookupBuilder(DARK_AMARANTH_ROOTS_PLACEABLE_ON) + .forceAddTag(BlockTags.NYLIUM) + .add(Blocks.SOUL_SOIL) + .add(Blocks.DIRT) + .add(Blocks.FARMLAND); + + // Vanilla + valueLookupBuilder(BlockTags.BASE_STONE_OVERWORLD).add(ASPHALT, BLUNITE); + valueLookupBuilder(BlockTags.STONE_ORE_REPLACEABLES).add(ASPHALT, BLUNITE); + + + valueLookupBuilder(BlockTags.SLABS).add(ASPHALT_SLAB, BLUNITE_SLAB, POLISHED_ASPHALT_SLAB, POLISHED_BLUNITE_SLAB); + valueLookupBuilder(BlockTags.STAIRS).add(ASPHALT_STAIRS, BLUNITE_STAIRS, POLISHED_ASPHALT_STAIRS, POLISHED_BLUNITE_STAIRS); + valueLookupBuilder(BlockTags.WALLS).add(ASPHALT_WALL, BLUNITE_WALL); + + valueLookupBuilder(BlockTags.LOGS).addTag(DARK_AMARANTH_STEMS); + valueLookupBuilder(BlockTags.LOGS_THAT_BURN).addTag(SAKURA_LOGS).addTag(MAPLE_LOGS).addTag(PALM_LOGS); + valueLookupBuilder(BlockTags.OVERWORLD_NATURAL_LOGS).add(SAKURA_LOG, MAPLE_LOG, PALM_LOG); + valueLookupBuilder(BlockTags.PLANKS).add(SAKURA_PLANKS, MAPLE_PLANKS, PALM_PLANKS, DARK_AMARANTH_PLANKS); + valueLookupBuilder(BlockTags.WOODEN_BUTTONS).add(SAKURA_BUTTON, MAPLE_BUTTON, PALM_BUTTON, DARK_AMARANTH_BUTTON); + valueLookupBuilder(BlockTags.WOODEN_DOORS).add(SAKURA_DOOR, MAPLE_DOOR, PALM_DOOR, DARK_AMARANTH_DOOR); + valueLookupBuilder(BlockTags.WOODEN_FENCES).add(SAKURA_FENCE, MAPLE_FENCE, PALM_FENCE, DARK_AMARANTH_FENCE); + valueLookupBuilder(BlockTags.WOODEN_PRESSURE_PLATES).add(SAKURA_PRESSURE_PLATE, MAPLE_PRESSURE_PLATE, PALM_PRESSURE_PLATE, DARK_AMARANTH_PRESSURE_PLATE); + valueLookupBuilder(BlockTags.WOODEN_SLABS).add(SAKURA_SLAB, MAPLE_SLAB, PALM_SLAB, DARK_AMARANTH_SLAB); + valueLookupBuilder(BlockTags.WOODEN_STAIRS).add(SAKURA_STAIRS, MAPLE_STAIRS, PALM_STAIRS, DARK_AMARANTH_STAIRS); + valueLookupBuilder(BlockTags.WOODEN_TRAPDOORS).add(SAKURA_TRAPDOOR, MAPLE_TRAPDOOR, PALM_TRAPDOOR, DARK_AMARANTH_TRAPDOOR); + valueLookupBuilder(BlockTags.FENCE_GATES).add(SAKURA_FENCE_GATE, MAPLE_FENCE_GATE, PALM_FENCE_GATE, DARK_AMARANTH_FENCE_GATE); + valueLookupBuilder(BlockTags.STANDING_SIGNS).add(SAKURA_SIGN, MAPLE_SIGN, PALM_SIGN, DARK_AMARANTH_SIGN); + valueLookupBuilder(BlockTags.WALL_SIGNS).add(SAKURA_WALL_SIGN, MAPLE_WALL_SIGN, PALM_WALL_SIGN, DARK_AMARANTH_WALL_SIGN); + valueLookupBuilder(BlockTags.CEILING_HANGING_SIGNS).add(SAKURA_HANGING_SIGN, MAPLE_HANGING_SIGN, PALM_HANGING_SIGN, DARK_AMARANTH_HANGING_SIGN); + valueLookupBuilder(BlockTags.WALL_HANGING_SIGNS).add(SAKURA_WALL_HANGING_SIGN, MAPLE_WALL_HANGING_SIGN, PALM_WALL_HANGING_SIGN, DARK_AMARANTH_WALL_HANGING_SIGN); + + valueLookupBuilder(BlockTags.LEAVES).add( + VERMILION_MAPLE_LEAVES, + FULVOUS_MAPLE_LEAVES, + MIKADO_MAPLE_LEAVES, + SAP_MAPLE_LEAVES, + BLUSH_SAKURA_BLOSSOMS, + COTTON_SAKURA_BLOSSOMS, + PALM_LEAVES + ).addTag(SNOWY_LEAVES); + valueLookupBuilder(BlockTags.SAPLINGS).add( + BLUSH_SAKURA_SAPLING, COTTON_SAKURA_SAPLING, + SAP_MAPLE_SAPLING, VERMILION_MAPLE_SAPLING, FULVOUS_MAPLE_SAPLING, MIKADO_MAPLE_SAPLING, + PALM_SAPLING); + + valueLookupBuilder(BlockTags.BEE_ATTRACTIVE).add(AZALEA_LEAF_PILE, FLOWERING_AZALEA_LEAF_PILE); + valueLookupBuilder(BlockTags.FLOWERS).add(AZALEA_LEAF_PILE, FLOWERING_AZALEA_LEAF_PILE); + valueLookupBuilder(BlockTags.FLOWER_POTS).add( + POTTED_BLUSH_SAKURA_SAPLING, POTTED_COTTON_SAKURA_SAPLING, + POTTED_SAP_MAPLE_SAPLING, POTTED_VERMILION_MAPLE_SAPLING, POTTED_FULVOUS_MAPLE_SAPLING, POTTED_MIKADO_MAPLE_SAPLING, + POTTED_PALM_SAPLING, + POTTED_DARK_AMARANTH_FUNGUS, POTTED_DARK_AMARANTH_ROOTS + ); + + valueLookupBuilder(BlockTags.REPLACEABLE_BY_TREES) + .addTag(FALLEN_LEAVES) + .addTag(LEAF_PILES) + .addTag(FLOWER_PILES) + .add(DARK_AMARANTH_ROOTS); + valueLookupBuilder(BlockTags.BEE_GROWABLES).add(BLUEBERRY_BUSH); + valueLookupBuilder(BlockTags.MUSHROOM_GROW_BLOCK).add(DARK_AMARANTH_NYLIUM); + + valueLookupBuilder(BlockTags.NYLIUM).add(DARK_AMARANTH_NYLIUM); + valueLookupBuilder(BlockTags.WART_BLOCKS).add(DARK_AMARANTH_WART_BLOCK); + valueLookupBuilder(BlockTags.SOUL_FIRE_BASE_BLOCKS).add(DARK_AMARANTH_NYLIUM, DARK_AMARANTH_WART_BLOCK, SOUL_SHROOMLIGHT); + + valueLookupBuilder(BlockTags.ENDERMAN_HOLDABLE).add(DARK_AMARANTH_FUNGUS, DARK_AMARANTH_NYLIUM, DARK_AMARANTH_ROOTS); + + valueLookupBuilder(BlockTags.INSIDE_STEP_SOUND_BLOCKS).addTag(FALLEN_LEAVES); + valueLookupBuilder(BlockTags.COMBINATION_STEP_SOUND_BLOCKS).add(DARK_AMARANTH_ROOTS); + + valueLookupBuilder(BlockTags.CLIMBABLE).add(COILED_VINES, COILED_VINES_PLANT); + valueLookupBuilder(BlockTags.REPLACEABLE).addTag(FALLEN_LEAVES); + + valueLookupBuilder(BlockTags.SWORD_EFFICIENT) + .addTag(LEAF_PILES) + .addTag(FLOWER_PILES) + .add(DARK_AMARANTH_ROOTS, COILED_VINES, COILED_VINES_PLANT); + valueLookupBuilder(BlockTags.PICKAXE_MINEABLE).add( + BLUNITE, + BLUNITE_STAIRS, + BLUNITE_SLAB, + ASPHALT, + ASPHALT_STAIRS, + ASPHALT_SLAB, + POLISHED_BLUNITE, + POLISHED_BLUNITE_STAIRS, + POLISHED_BLUNITE_SLAB, + POLISHED_ASPHALT, + POLISHED_ASPHALT_STAIRS, + POLISHED_ASPHALT_SLAB, + MOAI, + DARK_AMARANTH_NYLIUM + ); + valueLookupBuilder(BlockTags.AXE_MINEABLE).add(DARK_AMARANTH_FUNGUS, COILED_VINES, COILED_VINES_PLANT); + valueLookupBuilder(BlockTags.HOE_MINEABLE) + .add( + VERMILION_MAPLE_LEAVES, + FULVOUS_MAPLE_LEAVES, + MIKADO_MAPLE_LEAVES, + SAP_MAPLE_LEAVES, + BLUSH_SAKURA_BLOSSOMS, + COTTON_SAKURA_BLOSSOMS, + PALM_LEAVES + ) + .addTag(SNOWY_LEAVES) + .addTag(FLOWER_PILES) + .addTag(LEAF_PILES) + .add(DARK_AMARANTH_WART_BLOCK, SOUL_SHROOMLIGHT); + + + // Conventional + valueLookupBuilder(ConventionalBlockTags.STONES).add(ASPHALT, BLUNITE); + valueLookupBuilder(ConventionalBlockTags.FENCES).add(SAKURA_FENCE, MAPLE_FENCE, PALM_FENCE, DARK_AMARANTH_FENCE); + valueLookupBuilder(ConventionalBlockTags.WOODEN_FENCES).add(SAKURA_FENCE, MAPLE_FENCE, PALM_FENCE, DARK_AMARANTH_FENCE); + valueLookupBuilder(ConventionalBlockTags.FENCE_GATES).add(SAKURA_FENCE_GATE, MAPLE_FENCE_GATE, PALM_FENCE_GATE, DARK_AMARANTH_FENCE_GATE); + valueLookupBuilder(ConventionalBlockTags.WOODEN_FENCE_GATES).add(SAKURA_FENCE_GATE, MAPLE_FENCE_GATE, PALM_FENCE_GATE, DARK_AMARANTH_FENCE_GATE); + valueLookupBuilder(ConventionalBlockTags.STRIPPED_LOGS).add(STRIPPED_SAKURA_LOG, STRIPPED_MAPLE_LOG, STRIPPED_PALM_LOG, STRIPPED_DARK_AMARANTH_STEM); + valueLookupBuilder(ConventionalBlockTags.STRIPPED_WOODS).add(STRIPPED_SAKURA_WOOD, STRIPPED_MAPLE_WOOD, STRIPPED_PALM_WOOD, STRIPPED_DARK_AMARANTH_HYPHAE); + + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeCapybaraVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeCapybaraVariantProvider.java index 73e9cedb..899311e7 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeCapybaraVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeCapybaraVariantProvider.java @@ -1,51 +1,64 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.entity.spawn.ChanceSpawnCondition; -import fr.hugman.promenade.entity.variant.CapybaraVariant; -import fr.hugman.promenade.entity.variant.CapybaraVariants; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.entity.spawn.SpawnConditionSelectors; import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryWrapper; import net.minecraft.util.AssetInfo.TextureAssetInfo; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.entity.spawn.ChanceSpawnCondition; +import fr.hugman.promenade.entity.variant.CapybaraVariant; +import fr.hugman.promenade.entity.variant.CapybaraVariants; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; //TODO: a generic class for other devs public class PromenadeCapybaraVariantProvider extends FabricDynamicRegistryProvider { - public PromenadeCapybaraVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.CAPYBARA_VARIANT)); - } - - @Override - public String getName() { - return "Capybara Variants"; - } - - public static void register(Registerable registerable) { - of(registerable, CapybaraVariants.BROWN, SpawnConditionSelectors.createFallback(0)); - of(registerable, CapybaraVariants.ALBINO, 1 / 50f); - } - - private static void of(Registerable registry, RegistryKey key, float rarity) { - of(registry, key, SpawnConditionSelectors.createSingle(new ChanceSpawnCondition(rarity), 0)); - } - - private static void of(Registerable registry, RegistryKey key, SpawnConditionSelectors spawnConditions) { - var baseId = key.getValue().withPrefixedPath("entity/capybara/"); - registry.register(key, new CapybaraVariant( - new TextureAssetInfo(baseId.withSuffixedPath("/small_eyes")), - new TextureAssetInfo(baseId.withSuffixedPath("/large_eyes")), - new TextureAssetInfo(baseId.withSuffixedPath("/closed_eyes")), - spawnConditions - )); - } + public PromenadeCapybaraVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.CAPYBARA_VARIANT)); + } + + @Override + public String getName() { + return "Capybara Variants"; + } + + public static void register(Registerable registerable) { + of(registerable, CapybaraVariants.BROWN, SpawnConditionSelectors.createFallback(0)); + of(registerable, CapybaraVariants.ALBINO, 1 / 50f); + } + + private static void of(Registerable registry, RegistryKey key, float rarity) { + of(registry, key, SpawnConditionSelectors.createSingle(new ChanceSpawnCondition(rarity), 0)); + } + + private static void of(Registerable registry, RegistryKey key, SpawnConditionSelectors spawnConditions) { + var baseId = key.getValue().withPrefixedPath("entity/capybara/"); + registry.register(key, new CapybaraVariant( + new TextureAssetInfo(baseId.withSuffixedPath("/small_eyes")), + new TextureAssetInfo(baseId.withSuffixedPath("/large_eyes")), + new TextureAssetInfo(baseId.withSuffixedPath("/closed_eyes")), + spawnConditions + )); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeChestLootTableProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeChestLootTableProvider.java index b817692a..f42c3475 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeChestLootTableProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeChestLootTableProvider.java @@ -1,8 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.loot.PromenadeLootTables; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableProvider; +import java.util.concurrent.CompletableFuture; +import java.util.function.BiConsumer; + import net.minecraft.item.Items; import net.minecraft.loot.LootPool; import net.minecraft.loot.LootTable; @@ -13,52 +24,54 @@ import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryWrapper; -import java.util.concurrent.CompletableFuture; -import java.util.function.BiConsumer; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableProvider; + +import fr.hugman.promenade.loot.PromenadeLootTables; public class PromenadeChestLootTableProvider extends SimpleFabricLootTableProvider { - public PromenadeChestLootTableProvider(FabricDataOutput output, CompletableFuture registryLookup) { - super(output, registryLookup, LootContextTypes.CHEST); - } + public PromenadeChestLootTableProvider(FabricDataOutput output, CompletableFuture registryLookup) { + super(output, registryLookup, LootContextTypes.CHEST); + } - @Override - public void accept(BiConsumer, LootTable.Builder> output) { - output.accept(PromenadeLootTables.WITCH_HUT_CHEST, - LootTable.builder().pool(LootPool.builder() - .rolls(UniformLootNumberProvider.create(4, 7)) - .with(ItemEntry.builder(Items.GLASS_BOTTLE) - .weight(5) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 3))) - ) - .with(ItemEntry.builder(Items.MAGMA_CREAM).weight(2)) - .with(ItemEntry.builder(Items.MELON_SLICE) - .weight(6) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 3))) - ) - .with(ItemEntry.builder(Items.GLISTERING_MELON_SLICE).weight(2)) - .with(ItemEntry.builder(Items.CARROT) - .weight(10) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 4))) - ) - .with(ItemEntry.builder(Items.GOLDEN_CARROT).weight(2)) - .with(ItemEntry.builder(Items.APPLE) - .weight(10) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 5))) - ) - .with(ItemEntry.builder(Items.GOLDEN_APPLE)) - .with(ItemEntry.builder(Items.RABBIT_FOOT) - .weight(3) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 2))) - ) - .with(ItemEntry.builder(Items.SPIDER_EYE) - .weight(6) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 2))) - ) - .with(ItemEntry.builder(Items.EMERALD) - .weight(4) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 4))) - ) - ) - ); - } + @Override + public void accept(BiConsumer, LootTable.Builder> output) { + output.accept(PromenadeLootTables.WITCH_HUT_CHEST, + LootTable.builder().pool(LootPool.builder() + .rolls(UniformLootNumberProvider.create(4, 7)) + .with(ItemEntry.builder(Items.GLASS_BOTTLE) + .weight(5) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 3))) + ) + .with(ItemEntry.builder(Items.MAGMA_CREAM).weight(2)) + .with(ItemEntry.builder(Items.MELON_SLICE) + .weight(6) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 3))) + ) + .with(ItemEntry.builder(Items.GLISTERING_MELON_SLICE).weight(2)) + .with(ItemEntry.builder(Items.CARROT) + .weight(10) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 4))) + ) + .with(ItemEntry.builder(Items.GOLDEN_CARROT).weight(2)) + .with(ItemEntry.builder(Items.APPLE) + .weight(10) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 5))) + ) + .with(ItemEntry.builder(Items.GOLDEN_APPLE)) + .with(ItemEntry.builder(Items.RABBIT_FOOT) + .weight(3) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 2))) + ) + .with(ItemEntry.builder(Items.SPIDER_EYE) + .weight(6) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 2))) + ) + .with(ItemEntry.builder(Items.EMERALD) + .weight(4) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 4))) + ) + ) + ); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeConfiguredFeatureProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeConfiguredFeatureProvider.java index d37a64f5..6b71b7c1 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeConfiguredFeatureProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeConfiguredFeatureProvider.java @@ -1,12 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.block.BerryBushBlock; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.data.provider.builders.PromenadeFeatureConfigs; -import fr.hugman.promenade.util.NoiseScale; -import fr.hugman.promenade.world.gen.feature.*; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.List; +import java.util.concurrent.CompletableFuture; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -32,213 +39,219 @@ import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider; import net.minecraft.world.gen.treedecorator.BeehiveTreeDecorator; -import java.util.List; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.block.BerryBushBlock; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.data.provider.builders.PromenadeFeatureConfigs; +import fr.hugman.promenade.util.NoiseScale; +import fr.hugman.promenade.world.gen.feature.*; public class PromenadeConfiguredFeatureProvider extends FabricDynamicRegistryProvider { - public PromenadeConfiguredFeatureProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.CONFIGURED_FEATURE)); - } - - @Override - public String getName() { - return "Configured Features"; - } - - public static void register(Registerable> registerable) { - final var configured = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE); - final var placed = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); - - // Ores - var isBaseStoneOverworld = new TagMatchRuleTest(BlockTags.BASE_STONE_OVERWORLD); - - of(registerable, PromenadeConfiguredFeatures.PACKED_ICE_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, Blocks.PACKED_ICE.getDefaultState(), 50)); - of(registerable, PromenadeConfiguredFeatures.BLUE_ICE_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, Blocks.PACKED_ICE.getDefaultState(), 10)); - of(registerable, PromenadeConfiguredFeatures.ASPHALT_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, PromenadeBlocks.ASPHALT.getDefaultState(), 48)); - of(registerable, PromenadeConfiguredFeatures.BLUNITE_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, PromenadeBlocks.BLUNITE.getDefaultState(), 48)); - - // Trees - var beehive005 = new BeehiveTreeDecorator(0.05F); - var beehive002 = new BeehiveTreeDecorator(0.02F); - - of(registerable, PromenadeConfiguredFeatures.BLUSH_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, false).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, true).build()); - of(registerable, PromenadeConfiguredFeatures.BLUSH_SAKURA_BEES, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, false).decorators(List.of(beehive005)).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA_BEES, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, true).decorators(List.of(beehive005)).build()); - - of(registerable, PromenadeConfiguredFeatures.COTTON_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, false).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, true).build()); - of(registerable, PromenadeConfiguredFeatures.COTTON_SAKURA_BEES, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, false).decorators(List.of(beehive005)).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA_BEES, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, true).decorators(List.of(beehive005)).build()); - - of(registerable, PromenadeConfiguredFeatures.SAP_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.SAP_MAPLE_LEAVES, false).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_SAP_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.SAP_MAPLE_LEAVES, true).build()); - of(registerable, PromenadeConfiguredFeatures.SAP_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.SAP_MAPLE_LEAVES, false).decorators(List.of(beehive002)).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_SAP_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.SAP_MAPLE_LEAVES, true).decorators(List.of(beehive002)).build()); - - of(registerable, PromenadeConfiguredFeatures.VERMILION_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.VERMILION_MAPLE_LEAVES, false).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.VERMILION_MAPLE_LEAVES, true).build()); - of(registerable, PromenadeConfiguredFeatures.VERMILION_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.VERMILION_MAPLE_LEAVES, false).decorators(List.of(beehive002)).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.VERMILION_MAPLE_LEAVES, true).decorators(List.of(beehive002)).build()); - - of(registerable, PromenadeConfiguredFeatures.FULVOUS_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, false).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, true).build()); - of(registerable, PromenadeConfiguredFeatures.FULVOUS_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, false).decorators(List.of(beehive002)).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, true).decorators(List.of(beehive002)).build()); - - of(registerable, PromenadeConfiguredFeatures.MIKADO_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.MIKADO_MAPLE_LEAVES, false).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.MIKADO_MAPLE_LEAVES, true).build()); - of(registerable, PromenadeConfiguredFeatures.MIKADO_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.MIKADO_MAPLE_LEAVES, false).decorators(List.of(beehive002)).build()); - of(registerable, PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.MIKADO_MAPLE_LEAVES, true).decorators(List.of(beehive002)).build()); - - of(registerable, PromenadeConfiguredFeatures.PALM, Feature.TREE, PromenadeFeatureConfigs.palm().build()); - - of(registerable, PromenadeConfiguredFeatures.SNOWY_MEGA_SPRUCE, Feature.TREE, PromenadeFeatureConfigs.snowyMegaSpruce(PromenadeBlocks.SNOWY_SPRUCE_LEAVES).build()); - - of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FUNGUS, Feature.HUGE_FUNGUS, PromenadeFeatureConfigs.hugeDarkAmaranthFungus(false)); - of(registerable, PromenadeConfiguredFeatures.PLANTED_DARK_AMARANTH_FUNGUS, Feature.HUGE_FUNGUS, PromenadeFeatureConfigs.hugeDarkAmaranthFungus(true)); - - // Vegetation - of(registerable, PromenadeConfiguredFeatures.WATER_POOL_GRAVEL_DECORATED, Feature.WATERLOGGED_VEGETATION_PATCH, - new VegetationPatchFeatureConfig( - BlockTags.LUSH_GROUND_REPLACEABLE, - BlockStateProvider.of(Blocks.GRAVEL), - PlacedFeatures.createEntry(RegistryEntry.of(new ConfiguredFeature<>(Feature.RANDOM_SELECTOR, new RandomFeatureConfig(List.of(new RandomFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL)), 0.4F)), PlacedFeatures.createEntry(configured.getOrThrow(VegetationConfiguredFeatures.PATCH_WATERLILY)))))), //hello there - VerticalSurfaceType.FLOOR, - ConstantIntProvider.create(3), - 0.8F, - 5, - 0.15F, - UniformIntProvider.create(4, 7), - 0.7F - )); - - of(registerable, PromenadeConfiguredFeatures.CUTE_LITTLE_ROCK, PromenadeFeatures.BOULDER, new BoulderFeatureConfig( - new WeightedBlockStateProvider( - Pool.builder() - .add(Blocks.STONE.getDefaultState(), 80) - .add(Blocks.CALCITE.getDefaultState(), 20) - ), - BlockPredicate.matchingBlocks(Blocks.GRASS_BLOCK), - UniformIntProvider.create(3, 4) - )); - - - of(registerable, PromenadeConfiguredFeatures.BAMBOO_PATCH, Feature.RANDOM_PATCH, - new RandomPatchFeatureConfig(25, 3, 3, - PlacedFeatures.createEntry(configured.getOrThrow(VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL), BlockFilterPlacementModifier.of(BlockPredicate.IS_AIR)) - )); - of(registerable, PromenadeConfiguredFeatures.BLUEBERRY_BUSH_PATCH, Feature.RANDOM_PATCH, - ConfiguredFeatures.createRandomPatchFeatureConfig( - Feature.SIMPLE_BLOCK, - new SimpleBlockFeatureConfig(BlockStateProvider.of(PromenadeBlocks.BLUEBERRY_BUSH.getDefaultState().with(BerryBushBlock.AGE, 3))), - List.of(Blocks.GRASS_BLOCK) - )); - - WeightedBlockStateProvider darkAmaranthVegetation = new WeightedBlockStateProvider( - Pool.builder() - .add(PromenadeBlocks.DARK_AMARANTH_ROOTS.getDefaultState(), 87) - .add(PromenadeBlocks.DARK_AMARANTH_FUNGUS.getDefaultState(), 11) - .add(Blocks.WARPED_FUNGUS.getDefaultState(), 1) - .add(Blocks.WARPED_ROOTS.getDefaultState(), 1) - ); - - of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_VEGETATION, Feature.NETHER_FOREST_VEGETATION, new NetherForestVegetationFeatureConfig(darkAmaranthVegetation, 8, 4)); - of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION, Feature.NETHER_FOREST_VEGETATION, new NetherForestVegetationFeatureConfig(darkAmaranthVegetation, 3, 1)); - - var horizontalDirections = List.of(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST); - of(registerable, PromenadeConfiguredFeatures.COILED_VINES, PromenadeFeatures.COILED_VINES, new CoiledVinesFeatureConfig(8, 4, 8, horizontalDirections)); - - of(registerable, PromenadeConfiguredFeatures.FALLEN_VERMILION_MAPLE_LEAVES, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig( - Feature.SIMPLE_BLOCK, - new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 1, 3))) - )); - of(registerable, PromenadeConfiguredFeatures.FALLEN_FULVOUS_MAPLE_LEAVES, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig( - Feature.SIMPLE_BLOCK, - new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 1, 3))) - )); - of(registerable, PromenadeConfiguredFeatures.FALLEN_MIKADO_MAPLE_LEAVES, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig( - Feature.SIMPLE_BLOCK, - new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 1, 3))) - )); - - // Grouped features - of(registerable, PromenadeConfiguredFeatures.BLUSH_SAKURA_GROVE_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_BLUSH_SAKURA), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.COTTON_SAKURA), 0.2f) - ), placed.getOrThrow(PromenadePlacedFeatures.BLUSH_SAKURA)) - ); - of(registerable, PromenadeConfiguredFeatures.COTTON_SAKURA_GROVE_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_COTTON_SAKURA), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.BLUSH_SAKURA), 0.2f) - ), placed.getOrThrow(PromenadePlacedFeatures.COTTON_SAKURA)) - ); - - of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_SAP_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_SAP_MAPLE_BEES), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_SAP_MAPLE), 0.2f) - ), placed.getOrThrow(PromenadePlacedFeatures.SAP_MAPLE)) - ); - of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_VERMILION_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_VERMILION_MAPLE_BEES), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_VERMILION_MAPLE), 0.2f) - ), placed.getOrThrow(PromenadePlacedFeatures.VERMILION_MAPLE)) - ); - of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FULVOUS_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE_BEES), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE), 0.2f) - ), placed.getOrThrow(PromenadePlacedFeatures.FULVOUS_MAPLE)) - ); - of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_MIKADO_TREE, Feature.RANDOM_SELECTOR, - new RandomFeatureConfig(List.of( - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_MIKADO_MAPLE_BEES), 0.1f), - new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_MIKADO_MAPLE), 0.2f) - ), placed.getOrThrow(PromenadePlacedFeatures.MIKADO_MAPLE)) - ); - of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_TREE, PromenadeFeatures.NOISE_PICKED, - new NoisePickedFeatureConfig(NoiseScale.of(200.0f), List.of( - new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_SAP_TREE)), -1.0f, 1.0f), - new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_VERMILION_TREE)), 0.2f, 0.95f), - new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FULVOUS_TREE)), -0.5f, 0.5f), - new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_MIKADO_TREE)), -0.95f, -0.2f) - )) - ); - of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES, PromenadeFeatures.NOISE_PICKED, - new NoisePickedFeatureConfig(NoiseScale.of(200.0f), List.of( - new NoisePickedFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FALLEN_VERMILION_MAPLE_LEAVES), 0.2f, 0.95f), - new NoisePickedFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FALLEN_FULVOUS_MAPLE_LEAVES), -0.5f, 0.5f), - new NoisePickedFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FALLEN_MIKADO_MAPLE_LEAVES), -0.95f, -0.2f) - )) - ); - } - - public static Pool.Builder fallenLeaves(Block block, int min, int max) { - return segmentedBlock(block, min, max, LeafLitterBlock.SEGMENT_AMOUNT, LeafLitterBlock.HORIZONTAL_FACING); - } - - private static Pool.Builder segmentedBlock(Block block, int min, int max, IntProperty amountProperty, EnumProperty facingProperty) { - Pool.Builder builder = Pool.builder(); - - for (int i = min; i <= max; ++i) { - for (Direction direction : Direction.Type.HORIZONTAL) { - builder.add(block.getDefaultState().with(amountProperty, i).with(facingProperty, direction), 1); - } - } - - return builder; - } - - private static > void of(Registerable> registry, RegistryKey> key, F feature, FC config) { - ConfiguredFeatures.register(registry, key, feature, config); - } + public PromenadeConfiguredFeatureProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(RegistryKeys.CONFIGURED_FEATURE)); + } + + @Override + public String getName() { + return "Configured Features"; + } + + public static void register(Registerable> registerable) { + final var configured = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE); + final var placed = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE); + + // Ores + var isBaseStoneOverworld = new TagMatchRuleTest(BlockTags.BASE_STONE_OVERWORLD); + + of(registerable, PromenadeConfiguredFeatures.PACKED_ICE_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, Blocks.PACKED_ICE.getDefaultState(), 50)); + of(registerable, PromenadeConfiguredFeatures.BLUE_ICE_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, Blocks.PACKED_ICE.getDefaultState(), 10)); + of(registerable, PromenadeConfiguredFeatures.ASPHALT_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, PromenadeBlocks.ASPHALT.getDefaultState(), 48)); + of(registerable, PromenadeConfiguredFeatures.BLUNITE_ORE, Feature.ORE, new OreFeatureConfig(isBaseStoneOverworld, PromenadeBlocks.BLUNITE.getDefaultState(), 48)); + + // Trees + var beehive005 = new BeehiveTreeDecorator(0.05F); + var beehive002 = new BeehiveTreeDecorator(0.02F); + + of(registerable, PromenadeConfiguredFeatures.BLUSH_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, false).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, true).build()); + of(registerable, PromenadeConfiguredFeatures.BLUSH_SAKURA_BEES, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, false).decorators(List.of(beehive005)).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA_BEES, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, true).decorators(List.of(beehive005)).build()); + + of(registerable, PromenadeConfiguredFeatures.COTTON_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, false).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, true).build()); + of(registerable, PromenadeConfiguredFeatures.COTTON_SAKURA_BEES, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, false).decorators(List.of(beehive005)).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA_BEES, Feature.TREE, PromenadeFeatureConfigs.sakura(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, true).decorators(List.of(beehive005)).build()); + + of(registerable, PromenadeConfiguredFeatures.SAP_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.SAP_MAPLE_LEAVES, false).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_SAP_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.SAP_MAPLE_LEAVES, true).build()); + of(registerable, PromenadeConfiguredFeatures.SAP_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.SAP_MAPLE_LEAVES, false).decorators(List.of(beehive002)).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_SAP_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.SAP_MAPLE_LEAVES, true).decorators(List.of(beehive002)).build()); + + of(registerable, PromenadeConfiguredFeatures.VERMILION_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.VERMILION_MAPLE_LEAVES, false).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.VERMILION_MAPLE_LEAVES, true).build()); + of(registerable, PromenadeConfiguredFeatures.VERMILION_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.VERMILION_MAPLE_LEAVES, false).decorators(List.of(beehive002)).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.VERMILION_MAPLE_LEAVES, true).decorators(List.of(beehive002)).build()); + + of(registerable, PromenadeConfiguredFeatures.FULVOUS_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, false).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, true).build()); + of(registerable, PromenadeConfiguredFeatures.FULVOUS_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, false).decorators(List.of(beehive002)).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, true).decorators(List.of(beehive002)).build()); + + of(registerable, PromenadeConfiguredFeatures.MIKADO_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.MIKADO_MAPLE_LEAVES, false).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.MIKADO_MAPLE_LEAVES, true).build()); + of(registerable, PromenadeConfiguredFeatures.MIKADO_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.MIKADO_MAPLE_LEAVES, false).decorators(List.of(beehive002)).build()); + of(registerable, PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE_BEES, Feature.TREE, PromenadeFeatureConfigs.maple(PromenadeBlocks.MIKADO_MAPLE_LEAVES, true).decorators(List.of(beehive002)).build()); + + of(registerable, PromenadeConfiguredFeatures.PALM, Feature.TREE, PromenadeFeatureConfigs.palm().build()); + + of(registerable, PromenadeConfiguredFeatures.SNOWY_MEGA_SPRUCE, Feature.TREE, PromenadeFeatureConfigs.snowyMegaSpruce(PromenadeBlocks.SNOWY_SPRUCE_LEAVES).build()); + + of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FUNGUS, Feature.HUGE_FUNGUS, PromenadeFeatureConfigs.hugeDarkAmaranthFungus(false)); + of(registerable, PromenadeConfiguredFeatures.PLANTED_DARK_AMARANTH_FUNGUS, Feature.HUGE_FUNGUS, PromenadeFeatureConfigs.hugeDarkAmaranthFungus(true)); + + // Vegetation + of(registerable, PromenadeConfiguredFeatures.WATER_POOL_GRAVEL_DECORATED, Feature.WATERLOGGED_VEGETATION_PATCH, + new VegetationPatchFeatureConfig( + BlockTags.LUSH_GROUND_REPLACEABLE, + BlockStateProvider.of(Blocks.GRAVEL), + PlacedFeatures.createEntry(RegistryEntry.of(new ConfiguredFeature<>(Feature.RANDOM_SELECTOR, new RandomFeatureConfig(List.of(new RandomFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL)), 0.4F)), PlacedFeatures.createEntry(configured.getOrThrow(VegetationConfiguredFeatures.PATCH_WATERLILY)))))), //hello there + VerticalSurfaceType.FLOOR, + ConstantIntProvider.create(3), + 0.8F, + 5, + 0.15F, + UniformIntProvider.create(4, 7), + 0.7F + )); + + of(registerable, PromenadeConfiguredFeatures.CUTE_LITTLE_ROCK, PromenadeFeatures.BOULDER, new BoulderFeatureConfig( + new WeightedBlockStateProvider( + Pool.builder() + .add(Blocks.STONE.getDefaultState(), 80) + .add(Blocks.CALCITE.getDefaultState(), 20) + ), + BlockPredicate.matchingBlocks(Blocks.GRASS_BLOCK), + UniformIntProvider.create(3, 4) + )); + + + of(registerable, PromenadeConfiguredFeatures.BAMBOO_PATCH, Feature.RANDOM_PATCH, + new RandomPatchFeatureConfig(25, 3, 3, + PlacedFeatures.createEntry(configured.getOrThrow(VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL), BlockFilterPlacementModifier.of(BlockPredicate.IS_AIR)) + )); + of(registerable, PromenadeConfiguredFeatures.BLUEBERRY_BUSH_PATCH, Feature.RANDOM_PATCH, + ConfiguredFeatures.createRandomPatchFeatureConfig( + Feature.SIMPLE_BLOCK, + new SimpleBlockFeatureConfig(BlockStateProvider.of(PromenadeBlocks.BLUEBERRY_BUSH.getDefaultState().with(BerryBushBlock.AGE, 3))), + List.of(Blocks.GRASS_BLOCK) + )); + + WeightedBlockStateProvider darkAmaranthVegetation = new WeightedBlockStateProvider( + Pool.builder() + .add(PromenadeBlocks.DARK_AMARANTH_ROOTS.getDefaultState(), 87) + .add(PromenadeBlocks.DARK_AMARANTH_FUNGUS.getDefaultState(), 11) + .add(Blocks.WARPED_FUNGUS.getDefaultState(), 1) + .add(Blocks.WARPED_ROOTS.getDefaultState(), 1) + ); + + of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_VEGETATION, Feature.NETHER_FOREST_VEGETATION, new NetherForestVegetationFeatureConfig(darkAmaranthVegetation, 8, 4)); + of(registerable, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION, Feature.NETHER_FOREST_VEGETATION, new NetherForestVegetationFeatureConfig(darkAmaranthVegetation, 3, 1)); + + var horizontalDirections = List.of(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST); + of(registerable, PromenadeConfiguredFeatures.COILED_VINES, PromenadeFeatures.COILED_VINES, new CoiledVinesFeatureConfig(8, 4, 8, horizontalDirections)); + + of(registerable, PromenadeConfiguredFeatures.FALLEN_VERMILION_MAPLE_LEAVES, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig( + Feature.SIMPLE_BLOCK, + new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 1, 3))) + )); + of(registerable, PromenadeConfiguredFeatures.FALLEN_FULVOUS_MAPLE_LEAVES, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig( + Feature.SIMPLE_BLOCK, + new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 1, 3))) + )); + of(registerable, PromenadeConfiguredFeatures.FALLEN_MIKADO_MAPLE_LEAVES, Feature.RANDOM_PATCH, ConfiguredFeatures.createRandomPatchFeatureConfig( + Feature.SIMPLE_BLOCK, + new SimpleBlockFeatureConfig(new WeightedBlockStateProvider(fallenLeaves(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 1, 3))) + )); + + // Grouped features + of(registerable, PromenadeConfiguredFeatures.BLUSH_SAKURA_GROVE_TREE, Feature.RANDOM_SELECTOR, + new RandomFeatureConfig(List.of( + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_BLUSH_SAKURA), 0.1f), + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.COTTON_SAKURA), 0.2f) + ), placed.getOrThrow(PromenadePlacedFeatures.BLUSH_SAKURA)) + ); + of(registerable, PromenadeConfiguredFeatures.COTTON_SAKURA_GROVE_TREE, Feature.RANDOM_SELECTOR, + new RandomFeatureConfig(List.of( + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_COTTON_SAKURA), 0.1f), + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.BLUSH_SAKURA), 0.2f) + ), placed.getOrThrow(PromenadePlacedFeatures.COTTON_SAKURA)) + ); + + of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_SAP_TREE, Feature.RANDOM_SELECTOR, + new RandomFeatureConfig(List.of( + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_SAP_MAPLE_BEES), 0.1f), + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_SAP_MAPLE), 0.2f) + ), placed.getOrThrow(PromenadePlacedFeatures.SAP_MAPLE)) + ); + of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_VERMILION_TREE, Feature.RANDOM_SELECTOR, + new RandomFeatureConfig(List.of( + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_VERMILION_MAPLE_BEES), 0.1f), + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_VERMILION_MAPLE), 0.2f) + ), placed.getOrThrow(PromenadePlacedFeatures.VERMILION_MAPLE)) + ); + of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FULVOUS_TREE, Feature.RANDOM_SELECTOR, + new RandomFeatureConfig(List.of( + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE_BEES), 0.1f), + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE), 0.2f) + ), placed.getOrThrow(PromenadePlacedFeatures.FULVOUS_MAPLE)) + ); + of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_MIKADO_TREE, Feature.RANDOM_SELECTOR, + new RandomFeatureConfig(List.of( + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_MIKADO_MAPLE_BEES), 0.1f), + new RandomFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FANCY_MIKADO_MAPLE), 0.2f) + ), placed.getOrThrow(PromenadePlacedFeatures.MIKADO_MAPLE)) + ); + of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_TREE, PromenadeFeatures.NOISE_PICKED, + new NoisePickedFeatureConfig(NoiseScale.of(200.0f), List.of( + new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_SAP_TREE)), - 1.0f, 1.0f), + new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_VERMILION_TREE)), 0.2f, 0.95f), + new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FULVOUS_TREE)), - 0.5f, 0.5f), + new NoisePickedFeatureEntry(PlacedFeatures.createEntry(configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_MIKADO_TREE)), - 0.95f, - 0.2f) + )) + ); + of(registerable, PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES, PromenadeFeatures.NOISE_PICKED, + new NoisePickedFeatureConfig(NoiseScale.of(200.0f), List.of( + new NoisePickedFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FALLEN_VERMILION_MAPLE_LEAVES), 0.2f, 0.95f), + new NoisePickedFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FALLEN_FULVOUS_MAPLE_LEAVES), - 0.5f, 0.5f), + new NoisePickedFeatureEntry(placed.getOrThrow(PromenadePlacedFeatures.FALLEN_MIKADO_MAPLE_LEAVES), - 0.95f, - 0.2f) + )) + ); + } + + public static Pool.Builder fallenLeaves(Block block, int min, int max) { + return segmentedBlock(block, min, max, LeafLitterBlock.SEGMENT_AMOUNT, LeafLitterBlock.HORIZONTAL_FACING); + } + + private static Pool.Builder segmentedBlock(Block block, int min, int max, IntProperty amountProperty, EnumProperty facingProperty) { + Pool.Builder builder = Pool.builder(); + + for (int i = min; i <= max; ++ i) { + for (Direction direction : Direction.Type.HORIZONTAL) { + builder.add(block.getDefaultState().with(amountProperty, i).with(facingProperty, direction), 1); + } + } + + return builder; + } + + private static > void of(Registerable> registry, RegistryKey> key, F feature, FC config) { + ConfiguredFeatures.register(registry, key, feature, config); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeDuckVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeDuckVariantProvider.java index 0b4378d1..ea371777 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeDuckVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeDuckVariantProvider.java @@ -1,11 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.entity.variant.DuckVariant; -import fr.hugman.promenade.entity.variant.DuckVariants; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import fr.hugman.promenade.tag.PromenadeBiomeTags; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.entity.spawn.SpawnConditionSelectors; import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryKey; @@ -15,34 +22,40 @@ import net.minecraft.util.AssetInfo.TextureAssetInfo; import net.minecraft.world.biome.Biome; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.entity.variant.DuckVariant; +import fr.hugman.promenade.entity.variant.DuckVariants; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import fr.hugman.promenade.tag.PromenadeBiomeTags; //TODO: a generic class for other devs public class PromenadeDuckVariantProvider extends FabricDynamicRegistryProvider { - public PromenadeDuckVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.DUCK_VARIANT)); - } - - @Override - public String getName() { - return "Duck Variants"; - } - - public static void register(Registerable registerable) { - of(registerable, DuckVariants.PEKIN, PromenadeBiomeTags.SPAWNS_PEKIN_DUCKS); - of(registerable, DuckVariants.MALLARD, PromenadeBiomeTags.SPAWNS_MALLARD_DUCKS); - } - - private static void of(Registerable registry, RegistryKey key, TagKey biomeTag) { - of(registry, key, DataProviderUtil.createSpawnConditions(registry.getRegistryLookup(RegistryKeys.BIOME).getOrThrow(biomeTag))); - } - - private static void of(Registerable registry, RegistryKey key, SpawnConditionSelectors spawnConditions) { - registry.register(key, new DuckVariant(new TextureAssetInfo(key.getValue().withPrefixedPath("entity/duck/")), DuckVariant.DEFAULT_DUCKLING_ASSET, spawnConditions)); - } + public PromenadeDuckVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.DUCK_VARIANT)); + } + + @Override + public String getName() { + return "Duck Variants"; + } + + public static void register(Registerable registerable) { + of(registerable, DuckVariants.PEKIN, PromenadeBiomeTags.SPAWNS_PEKIN_DUCKS); + of(registerable, DuckVariants.MALLARD, PromenadeBiomeTags.SPAWNS_MALLARD_DUCKS); + } + + private static void of(Registerable registry, RegistryKey key, TagKey biomeTag) { + of(registry, key, DataProviderUtil.createSpawnConditions(registry.getRegistryLookup(RegistryKeys.BIOME).getOrThrow(biomeTag))); + } + + private static void of(Registerable registry, RegistryKey key, SpawnConditionSelectors spawnConditions) { + registry.register(key, new DuckVariant(new TextureAssetInfo(key.getValue().withPrefixedPath("entity/duck/")), DuckVariant.DEFAULT_DUCKLING_ASSET, spawnConditions)); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityLootTableProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityLootTableProvider.java index 2a100055..0325ffb1 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityLootTableProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityLootTableProvider.java @@ -1,10 +1,20 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.entity.PromenadeEntityTypes; -import fr.hugman.promenade.item.PromenadeItems; -import fr.hugman.promenade.loot.PromenadeLootTables; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableProvider; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.function.BiConsumer; + import net.minecraft.enchantment.Enchantment; import net.minecraft.fluid.Fluid; import net.minecraft.item.Item; @@ -42,125 +52,128 @@ import net.minecraft.registry.tag.FluidTags; import net.minecraft.registry.tag.ItemTags; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.function.BiConsumer; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableProvider; + +import fr.hugman.promenade.entity.PromenadeEntityTypes; +import fr.hugman.promenade.item.PromenadeItems; +import fr.hugman.promenade.loot.PromenadeLootTables; public class PromenadeEntityLootTableProvider extends SimpleFabricLootTableProvider { - private final RegistryWrapper.WrapperLookup registries; + private final RegistryWrapper.WrapperLookup registries; - public PromenadeEntityLootTableProvider(FabricDataOutput output, CompletableFuture registryLookup) { - super(output, registryLookup, LootContextTypes.ENTITY); - this.registries = registryLookup.join(); - } + public PromenadeEntityLootTableProvider(FabricDataOutput output, CompletableFuture registryLookup) { + super(output, registryLookup, LootContextTypes.ENTITY); + this.registries = registryLookup.join(); + } - @Override - public void accept(BiConsumer, LootTable.Builder> output) { - final var entities = this.registries.getOrThrow(RegistryKeys.ENTITY_TYPE); - final var fluids = this.registries.getOrThrow(RegistryKeys.FLUID); + @Override + public void accept(BiConsumer, LootTable.Builder> output) { + final var entities = this.registries.getOrThrow(RegistryKeys.ENTITY_TYPE); + final var fluids = this.registries.getOrThrow(RegistryKeys.FLUID); - output.accept(PromenadeEntityTypes.CAPYBARA.getLootTableKey().orElseThrow(), LootTable.builder()); - output.accept( - PromenadeEntityTypes.DUCK.getLootTableKey().orElseThrow(), - LootTable.builder() - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.FEATHER) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(registries, UniformLootNumberProvider.create(0.0F, 1.0F))) - ) - ) - .pool(LootPool.builder() - .with(ItemEntry.builder(PromenadeItems.DUCK) - .apply(FurnaceSmeltLootFunction.builder().conditionally(this.createSmeltLootCondition())) - .apply(EnchantedCountIncreaseLootFunction.builder(registries, UniformLootNumberProvider.create(0.0F, 1.0F))) - ) - ) - ); + output.accept(PromenadeEntityTypes.CAPYBARA.getLootTableKey().orElseThrow(), LootTable.builder()); + output.accept( + PromenadeEntityTypes.DUCK.getLootTableKey().orElseThrow(), + LootTable.builder() + .pool(LootPool.builder() + .with(ItemEntry.builder(Items.FEATHER) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseLootFunction.builder(registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + ) + ) + .pool(LootPool.builder() + .with(ItemEntry.builder(PromenadeItems.DUCK) + .apply(FurnaceSmeltLootFunction.builder().conditionally(this.createSmeltLootCondition())) + .apply(EnchantedCountIncreaseLootFunction.builder(registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + ) + ) + ); - output.accept( - PromenadeEntityTypes.LUSH_CREEPER.getLootTableKey().orElseThrow(), - LootTable.builder() - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.GUNPOWDER) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) - ) - ) - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.BONE_MEAL).weight(2).quality(2) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) - ) - .with(ItemEntry.builder(Items.MOSS_BLOCK).weight(1).quality(5) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) - ) - ) - .pool(LootPool.builder() - .with(TagEntry.expandBuilder(ItemTags.CREEPER_DROP_MUSIC_DISCS)) - .conditionally( - EntityPropertiesLootCondition.builder( - LootContext.EntityReference.ATTACKER, EntityPredicate.Builder.create().type(entities, EntityTypeTags.SKELETONS) - ) - ) - ) - ); + output.accept( + PromenadeEntityTypes.LUSH_CREEPER.getLootTableKey().orElseThrow(), + LootTable.builder() + .pool(LootPool.builder() + .with(ItemEntry.builder(Items.GUNPOWDER) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + ) + ) + .pool(LootPool.builder() + .with(ItemEntry.builder(Items.BONE_MEAL).weight(2).quality(2) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + ) + .with(ItemEntry.builder(Items.MOSS_BLOCK).weight(1).quality(5) + .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + ) + ) + .pool(LootPool.builder() + .with(TagEntry.expandBuilder(ItemTags.CREEPER_DROP_MUSIC_DISCS)) + .conditionally( + EntityPropertiesLootCondition.builder( + LootContext.EntityReference.ATTACKER, EntityPredicate.Builder.create().type(entities, EntityTypeTags.SKELETONS) + ) + ) + ) + ); - output.accept(PromenadeLootTables.TUBE_SUNKEN, sunken(fluids, Items.TUBE_CORAL, Items.DEAD_TUBE_CORAL)); - output.accept(PromenadeLootTables.BRAIN_SUNKEN, sunken(fluids, Items.BRAIN_CORAL, Items.DEAD_BRAIN_CORAL)); - output.accept(PromenadeLootTables.BUBBLE_SUNKEN, sunken(fluids, Items.BUBBLE_CORAL, Items.DEAD_BUBBLE_CORAL)); - output.accept(PromenadeLootTables.FIRE_SUNKEN, sunken(fluids, Items.FIRE_CORAL, Items.DEAD_FIRE_CORAL)); - output.accept(PromenadeLootTables.HORN_SUNKEN, sunken(fluids, Items.HORN_CORAL, Items.DEAD_HORN_CORAL)); - } + output.accept(PromenadeLootTables.TUBE_SUNKEN, sunken(fluids, Items.TUBE_CORAL, Items.DEAD_TUBE_CORAL)); + output.accept(PromenadeLootTables.BRAIN_SUNKEN, sunken(fluids, Items.BRAIN_CORAL, Items.DEAD_BRAIN_CORAL)); + output.accept(PromenadeLootTables.BUBBLE_SUNKEN, sunken(fluids, Items.BUBBLE_CORAL, Items.DEAD_BUBBLE_CORAL)); + output.accept(PromenadeLootTables.FIRE_SUNKEN, sunken(fluids, Items.FIRE_CORAL, Items.DEAD_FIRE_CORAL)); + output.accept(PromenadeLootTables.HORN_SUNKEN, sunken(fluids, Items.HORN_CORAL, Items.DEAD_HORN_CORAL)); + } - protected final AnyOfLootCondition.Builder createSmeltLootCondition() { - RegistryWrapper.Impl impl = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT); - return AnyOfLootCondition.builder( - EntityPropertiesLootCondition.builder( - LootContext.EntityReference.THIS, EntityPredicate.Builder.create().flags(EntityFlagsPredicate.Builder.create().onFire(true)) - ), - EntityPropertiesLootCondition.builder( - LootContext.EntityReference.DIRECT_ATTACKER, - EntityPredicate.Builder.create() - .equipment( - EntityEquipmentPredicate.Builder.create() - .mainhand( - ItemPredicate.Builder.create() - .components( - ComponentsPredicate.Builder.create() - .partial( - ComponentPredicateTypes.ENCHANTMENTS, - EnchantmentsPredicate.enchantments(List.of(new EnchantmentPredicate(impl.getOrThrow(EnchantmentTags.SMELTS_LOOT), NumberRange.IntRange.ANY))) - ) - .build() - ) - ) - ) - ) - ); - } + protected final AnyOfLootCondition.Builder createSmeltLootCondition() { + RegistryWrapper.Impl impl = this.registries.getOrThrow(RegistryKeys.ENCHANTMENT); + return AnyOfLootCondition.builder( + EntityPropertiesLootCondition.builder( + LootContext.EntityReference.THIS, EntityPredicate.Builder.create().flags(EntityFlagsPredicate.Builder.create().onFire(true)) + ), + EntityPropertiesLootCondition.builder( + LootContext.EntityReference.DIRECT_ATTACKER, + EntityPredicate.Builder.create() + .equipment( + EntityEquipmentPredicate.Builder.create() + .mainhand( + ItemPredicate.Builder.create() + .components( + ComponentsPredicate.Builder.create() + .partial( + ComponentPredicateTypes.ENCHANTMENTS, + EnchantmentsPredicate.enchantments(List.of(new EnchantmentPredicate(impl.getOrThrow(EnchantmentTags.SMELTS_LOOT), NumberRange.IntRange.ANY))) + ) + .build() + ) + ) + ) + ) + ); + } - protected final LootTable.Builder sunken(RegistryEntryLookup fluids, Item coral, Item deadCoral) { - return LootTable.builder() - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.ARROW) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) - ) - ) - .pool(LootPool.builder() - .with(ItemEntry.builder(Items.BONE) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) - ) - ) - .pool(LootPool.builder() - .with( - ItemEntry.builder(coral) - .conditionally(LocationCheckLootCondition.builder(LocationPredicate.Builder.create().fluid(FluidPredicate.Builder.create().tag(fluids.getOrThrow(FluidTags.WATER))))) - .alternatively(ItemEntry.builder(deadCoral)) - ) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1.0F, 3.0F))) - .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) - ); - } + protected final LootTable.Builder sunken(RegistryEntryLookup fluids, Item coral, Item deadCoral) { + return LootTable.builder() + .pool(LootPool.builder() + .with(ItemEntry.builder(Items.ARROW) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + ) + ) + .pool(LootPool.builder() + .with(ItemEntry.builder(Items.BONE) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(0.0F, 2.0F))) + .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + ) + ) + .pool(LootPool.builder() + .with( + ItemEntry.builder(coral) + .conditionally(LocationCheckLootCondition.builder(LocationPredicate.Builder.create().fluid(FluidPredicate.Builder.create().tag(fluids.getOrThrow(FluidTags.WATER))))) + .alternatively(ItemEntry.builder(deadCoral)) + ) + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1.0F, 3.0F))) + .apply(EnchantedCountIncreaseLootFunction.builder(this.registries, UniformLootNumberProvider.create(0.0F, 1.0F))) + ); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityTypeTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityTypeTagProvider.java index 75913f25..d3b1f94d 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityTypeTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeEntityTypeTagProvider.java @@ -1,26 +1,39 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.entity.PromenadeEntityTypes; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.tag.EntityTypeTags; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; + +import fr.hugman.promenade.entity.PromenadeEntityTypes; public class PromenadeEntityTypeTagProvider extends FabricTagProvider.EntityTypeTagProvider { - public PromenadeEntityTypeTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { - super(output, completableFuture); - } + public PromenadeEntityTypeTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { + super(output, completableFuture); + } - @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { - // Vanilla - valueLookupBuilder(EntityTypeTags.SKELETONS).add(PromenadeEntityTypes.SUNKEN); - valueLookupBuilder(EntityTypeTags.AXOLOTL_ALWAYS_HOSTILES).add(PromenadeEntityTypes.SUNKEN); - valueLookupBuilder(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES).add(PromenadeEntityTypes.DUCK); - valueLookupBuilder(EntityTypeTags.FALL_DAMAGE_IMMUNE).add(PromenadeEntityTypes.DUCK); + @Override + protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + // Vanilla + valueLookupBuilder(EntityTypeTags.SKELETONS).add(PromenadeEntityTypes.SUNKEN); + valueLookupBuilder(EntityTypeTags.AXOLOTL_ALWAYS_HOSTILES).add(PromenadeEntityTypes.SUNKEN); + valueLookupBuilder(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES).add(PromenadeEntityTypes.DUCK); + valueLookupBuilder(EntityTypeTags.FALL_DAMAGE_IMMUNE).add(PromenadeEntityTypes.DUCK); - valueLookupBuilder(EntityTypeTags.BOAT).add(PromenadeEntityTypes.SAKURA_BOAT, PromenadeEntityTypes.MAPLE_BOAT, PromenadeEntityTypes.PALM_BOAT); - } + valueLookupBuilder(EntityTypeTags.BOAT).add(PromenadeEntityTypes.SAKURA_BOAT, PromenadeEntityTypes.MAPLE_BOAT, PromenadeEntityTypes.PALM_BOAT); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeItemTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeItemTagProvider.java index 48e2f2c1..c412dba4 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeItemTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeItemTagProvider.java @@ -1,101 +1,115 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.tag.PromenadeBlockTags; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; -import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags; -import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags; +import static fr.hugman.promenade.item.PromenadeItems.*; +import static fr.hugman.promenade.tag.PromenadeItemTags.*; + +import java.util.concurrent.CompletableFuture; + +import org.jetbrains.annotations.Nullable; + import net.minecraft.item.Items; import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.tag.BlockTags; import net.minecraft.registry.tag.ItemTags; -import org.jetbrains.annotations.Nullable; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags; +import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags; -import static fr.hugman.promenade.item.PromenadeItems.*; -import static fr.hugman.promenade.tag.PromenadeItemTags.*; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.tag.PromenadeBlockTags; public class PromenadeItemTagProvider extends FabricTagProvider.ItemTagProvider { - public PromenadeItemTagProvider(FabricDataOutput output, CompletableFuture completableFuture, @Nullable BlockTagProvider blockTagProvider) { - super(output, completableFuture, blockTagProvider); - } + public PromenadeItemTagProvider(FabricDataOutput output, CompletableFuture completableFuture, @Nullable BlockTagProvider blockTagProvider) { + super(output, completableFuture, blockTagProvider); + } - @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { - // Promenade - copy(PromenadeBlockTags.SAKURA_LOGS, SAKURA_LOGS); - copy(PromenadeBlockTags.MAPLE_LOGS, MAPLE_LOGS); - copy(PromenadeBlockTags.PALM_LOGS, PALM_LOGS); - copy(PromenadeBlockTags.DARK_AMARANTH_STEMS, DARK_AMARANTH_STEMS); + @Override + protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + // Promenade + copy(PromenadeBlockTags.SAKURA_LOGS, SAKURA_LOGS); + copy(PromenadeBlockTags.MAPLE_LOGS, MAPLE_LOGS); + copy(PromenadeBlockTags.PALM_LOGS, PALM_LOGS); + copy(PromenadeBlockTags.DARK_AMARANTH_STEMS, DARK_AMARANTH_STEMS); - copy(PromenadeBlockTags.SNOWY_LEAVES, SNOWY_LEAVES); + copy(PromenadeBlockTags.SNOWY_LEAVES, SNOWY_LEAVES); - valueLookupBuilder(CAPYBARA_FOOD).add(Items.CARROT, Items.MELON_SLICE); - valueLookupBuilder(DUCK_FOOD).add(Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS, Items.TORCHFLOWER_SEEDS, Items.PITCHER_POD); + valueLookupBuilder(CAPYBARA_FOOD).add(Items.CARROT, Items.MELON_SLICE); + valueLookupBuilder(DUCK_FOOD).add(Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS, Items.TORCHFLOWER_SEEDS, Items.PITCHER_POD); - // Vanilla - copy(BlockTags.PLANKS, ItemTags.PLANKS); - copy(BlockTags.WOODEN_BUTTONS, ItemTags.WOODEN_BUTTONS); - copy(BlockTags.BUTTONS, ItemTags.BUTTONS); - copy(BlockTags.WOODEN_DOORS, ItemTags.WOODEN_DOORS); - copy(BlockTags.WOODEN_STAIRS, ItemTags.WOODEN_STAIRS); - copy(BlockTags.WOODEN_SLABS, ItemTags.WOODEN_SLABS); - copy(BlockTags.WOODEN_FENCES, ItemTags.WOODEN_FENCES); - copy(BlockTags.FENCE_GATES, ItemTags.FENCE_GATES); - copy(BlockTags.WOODEN_PRESSURE_PLATES, ItemTags.WOODEN_PRESSURE_PLATES); - copy(BlockTags.DOORS, ItemTags.DOORS); - copy(BlockTags.SAPLINGS, ItemTags.SAPLINGS); - copy(BlockTags.WART_BLOCKS, ItemTags.WART_BLOCKS); - copy(BlockTags.LOGS_THAT_BURN, ItemTags.LOGS_THAT_BURN); - copy(BlockTags.LOGS, ItemTags.LOGS); - copy(BlockTags.SLABS, ItemTags.SLABS); - copy(BlockTags.WALLS, ItemTags.WALLS); - copy(BlockTags.STAIRS, ItemTags.STAIRS); - copy(BlockTags.ANVIL, ItemTags.ANVIL); - copy(BlockTags.RAILS, ItemTags.RAILS); - copy(BlockTags.LEAVES, ItemTags.LEAVES); - copy(BlockTags.WOODEN_TRAPDOORS, ItemTags.WOODEN_TRAPDOORS); - copy(BlockTags.FENCES, ItemTags.FENCES); - copy(BlockTags.BEE_ATTRACTIVE, ItemTags.BEE_FOOD); - copy(BlockTags.SOUL_FIRE_BASE_BLOCKS, ItemTags.SOUL_FIRE_BASE_BLOCKS); - copy(BlockTags.STANDING_SIGNS, ItemTags.SIGNS); - copy(BlockTags.CEILING_HANGING_SIGNS, ItemTags.HANGING_SIGNS); + // Vanilla + copy(BlockTags.PLANKS, ItemTags.PLANKS); + copy(BlockTags.WOODEN_BUTTONS, ItemTags.WOODEN_BUTTONS); + copy(BlockTags.BUTTONS, ItemTags.BUTTONS); + copy(BlockTags.WOODEN_DOORS, ItemTags.WOODEN_DOORS); + copy(BlockTags.WOODEN_STAIRS, ItemTags.WOODEN_STAIRS); + copy(BlockTags.WOODEN_SLABS, ItemTags.WOODEN_SLABS); + copy(BlockTags.WOODEN_FENCES, ItemTags.WOODEN_FENCES); + copy(BlockTags.FENCE_GATES, ItemTags.FENCE_GATES); + copy(BlockTags.WOODEN_PRESSURE_PLATES, ItemTags.WOODEN_PRESSURE_PLATES); + copy(BlockTags.DOORS, ItemTags.DOORS); + copy(BlockTags.SAPLINGS, ItemTags.SAPLINGS); + copy(BlockTags.WART_BLOCKS, ItemTags.WART_BLOCKS); + copy(BlockTags.LOGS_THAT_BURN, ItemTags.LOGS_THAT_BURN); + copy(BlockTags.LOGS, ItemTags.LOGS); + copy(BlockTags.SLABS, ItemTags.SLABS); + copy(BlockTags.WALLS, ItemTags.WALLS); + copy(BlockTags.STAIRS, ItemTags.STAIRS); + copy(BlockTags.ANVIL, ItemTags.ANVIL); + copy(BlockTags.RAILS, ItemTags.RAILS); + copy(BlockTags.LEAVES, ItemTags.LEAVES); + copy(BlockTags.WOODEN_TRAPDOORS, ItemTags.WOODEN_TRAPDOORS); + copy(BlockTags.FENCES, ItemTags.FENCES); + copy(BlockTags.BEE_ATTRACTIVE, ItemTags.BEE_FOOD); + copy(BlockTags.SOUL_FIRE_BASE_BLOCKS, ItemTags.SOUL_FIRE_BASE_BLOCKS); + copy(BlockTags.STANDING_SIGNS, ItemTags.SIGNS); + copy(BlockTags.CEILING_HANGING_SIGNS, ItemTags.HANGING_SIGNS); - valueLookupBuilder(ItemTags.BOATS).add(SAKURA_BOAT, MAPLE_BOAT, PALM_BOAT); - valueLookupBuilder(ItemTags.CHEST_BOATS).add(SAKURA_CHEST_BOAT, MAPLE_CHEST_BOAT, PALM_CHEST_BOAT); - valueLookupBuilder(ItemTags.MEAT).add(DUCK, COOKED_DUCK); - valueLookupBuilder(ItemTags.FOX_FOOD).add(BLUEBERRIES); + valueLookupBuilder(ItemTags.BOATS).add(SAKURA_BOAT, MAPLE_BOAT, PALM_BOAT); + valueLookupBuilder(ItemTags.CHEST_BOATS).add(SAKURA_CHEST_BOAT, MAPLE_CHEST_BOAT, PALM_CHEST_BOAT); + valueLookupBuilder(ItemTags.MEAT).add(DUCK, COOKED_DUCK); + valueLookupBuilder(ItemTags.FOX_FOOD).add(BLUEBERRIES); - valueLookupBuilder(ItemTags.NON_FLAMMABLE_WOOD) - .add( - PromenadeBlocks.DARK_AMARANTH_STEM.asItem(), - PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM.asItem(), - PromenadeBlocks.DARK_AMARANTH_HYPHAE.asItem(), - PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE.asItem(), - PromenadeBlocks.DARK_AMARANTH_PLANKS.asItem(), - PromenadeBlocks.DARK_AMARANTH_SLAB.asItem(), - PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE.asItem(), - PromenadeBlocks.DARK_AMARANTH_FENCE.asItem(), - PromenadeBlocks.DARK_AMARANTH_TRAPDOOR.asItem(), - PromenadeBlocks.DARK_AMARANTH_FENCE_GATE.asItem(), - PromenadeBlocks.DARK_AMARANTH_STAIRS.asItem(), - PromenadeBlocks.DARK_AMARANTH_BUTTON.asItem(), - PromenadeBlocks.DARK_AMARANTH_DOOR.asItem(), - DARK_AMARANTH_SIGN, - DARK_AMARANTH_HANGING_SIGN - ); + valueLookupBuilder(ItemTags.NON_FLAMMABLE_WOOD) + .add( + PromenadeBlocks.DARK_AMARANTH_STEM.asItem(), + PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM.asItem(), + PromenadeBlocks.DARK_AMARANTH_HYPHAE.asItem(), + PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE.asItem(), + PromenadeBlocks.DARK_AMARANTH_PLANKS.asItem(), + PromenadeBlocks.DARK_AMARANTH_SLAB.asItem(), + PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE.asItem(), + PromenadeBlocks.DARK_AMARANTH_FENCE.asItem(), + PromenadeBlocks.DARK_AMARANTH_TRAPDOOR.asItem(), + PromenadeBlocks.DARK_AMARANTH_FENCE_GATE.asItem(), + PromenadeBlocks.DARK_AMARANTH_STAIRS.asItem(), + PromenadeBlocks.DARK_AMARANTH_BUTTON.asItem(), + PromenadeBlocks.DARK_AMARANTH_DOOR.asItem(), + DARK_AMARANTH_SIGN, + DARK_AMARANTH_HANGING_SIGN + ); - // Conventional - valueLookupBuilder(ConventionalItemTags.RAW_MEAT_FOODS).add(DUCK); - valueLookupBuilder(ConventionalItemTags.COOKED_MEAT_FOODS).add(COOKED_DUCK); - copy(ConventionalBlockTags.STONES, ConventionalItemTags.STONES); - copy(ConventionalBlockTags.FENCES, ConventionalItemTags.FENCES); - copy(ConventionalBlockTags.WOODEN_FENCES, ConventionalItemTags.WOODEN_FENCES); - copy(ConventionalBlockTags.FENCE_GATES, ConventionalItemTags.FENCE_GATES); - copy(ConventionalBlockTags.WOODEN_FENCE_GATES, ConventionalItemTags.WOODEN_FENCE_GATES); - copy(ConventionalBlockTags.STRIPPED_WOODS, ConventionalItemTags.STRIPPED_WOODS); - copy(ConventionalBlockTags.STRIPPED_LOGS, ConventionalItemTags.STRIPPED_LOGS); - } + // Conventional + valueLookupBuilder(ConventionalItemTags.RAW_MEAT_FOODS).add(DUCK); + valueLookupBuilder(ConventionalItemTags.COOKED_MEAT_FOODS).add(COOKED_DUCK); + copy(ConventionalBlockTags.STONES, ConventionalItemTags.STONES); + copy(ConventionalBlockTags.FENCES, ConventionalItemTags.FENCES); + copy(ConventionalBlockTags.WOODEN_FENCES, ConventionalItemTags.WOODEN_FENCES); + copy(ConventionalBlockTags.FENCE_GATES, ConventionalItemTags.FENCE_GATES); + copy(ConventionalBlockTags.WOODEN_FENCE_GATES, ConventionalItemTags.WOODEN_FENCE_GATES); + copy(ConventionalBlockTags.STRIPPED_WOODS, ConventionalItemTags.STRIPPED_WOODS); + copy(ConventionalBlockTags.STRIPPED_LOGS, ConventionalItemTags.STRIPPED_LOGS); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeModelProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeModelProvider.java index ef81cfc6..496a9f43 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeModelProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeModelProvider.java @@ -1,18 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.block.MoaiBlock; -import fr.hugman.promenade.block.MoaiType; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.block.SnowyLeavesBlock; -import fr.hugman.promenade.block.property.PromenadeBlockProperties; -import fr.hugman.promenade.data.PromenadeBlockFamilies; -import fr.hugman.promenade.data.model.PromenadeModels; -import fr.hugman.promenade.data.model.PromenadeTextureMaps; -import fr.hugman.promenade.data.model.PromenadeTexturedModels; -import fr.hugman.promenade.item.PromenadeItems; -import fr.hugman.promenade.world.biome.PromenadeFoliageColors; -import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import java.util.function.Function; + import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.client.data.*; @@ -28,307 +28,320 @@ import net.minecraft.util.math.Direction; import net.minecraft.world.biome.FoliageColors; -import java.util.function.Function; +import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; + +import fr.hugman.promenade.block.MoaiBlock; +import fr.hugman.promenade.block.MoaiType; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.block.SnowyLeavesBlock; +import fr.hugman.promenade.block.property.PromenadeBlockProperties; +import fr.hugman.promenade.data.PromenadeBlockFamilies; +import fr.hugman.promenade.data.model.PromenadeModels; +import fr.hugman.promenade.data.model.PromenadeTextureMaps; +import fr.hugman.promenade.data.model.PromenadeTexturedModels; +import fr.hugman.promenade.item.PromenadeItems; +import fr.hugman.promenade.world.biome.PromenadeFoliageColors; public class PromenadeModelProvider extends FabricModelProvider { - public static final ModelVariantOperator NO_OP = variant -> variant; - public static final ModelVariantOperator UV_LOCK = ModelVariantOperator.UV_LOCK.withValue(true); - public static final ModelVariantOperator ROTATE_X_90 = ModelVariantOperator.ROTATION_X.withValue(AxisRotation.R90); - public static final ModelVariantOperator ROTATE_X_180 = ModelVariantOperator.ROTATION_X.withValue(AxisRotation.R180); - public static final ModelVariantOperator ROTATE_X_270 = ModelVariantOperator.ROTATION_X.withValue(AxisRotation.R270); - public static final ModelVariantOperator ROTATE_Y_90 = ModelVariantOperator.ROTATION_Y.withValue(AxisRotation.R90); - public static final ModelVariantOperator ROTATE_Y_180 = ModelVariantOperator.ROTATION_Y.withValue(AxisRotation.R180); - public static final ModelVariantOperator ROTATE_Y_270 = ModelVariantOperator.ROTATION_Y.withValue(AxisRotation.R270); - - private static final Function LEAF_LITTER_MODEL_1_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 1); - private static final Function LEAF_LITTER_MODEL_2_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 2, 3); - private static final Function LEAF_LITTER_MODEL_3_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 3); - private static final Function LEAF_LITTER_MODEL_4_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 4); - - private static final BlockStateVariantMap NORTH_DEFAULT_HORIZONTAL_ROTATION_OPERATIONS = BlockStateVariantMap.operations( - Properties.HORIZONTAL_FACING - ) - .register(Direction.EAST, ROTATE_Y_90) - .register(Direction.SOUTH, ROTATE_Y_180) - .register(Direction.WEST, ROTATE_Y_270) - .register(Direction.NORTH, NO_OP); - private static final BlockStateVariantMap UP_DEFAULT_ROTATION_OPERATIONS = BlockStateVariantMap.operations(Properties.FACING) - .register(Direction.DOWN, ROTATE_X_180) - .register(Direction.UP, NO_OP) - .register(Direction.NORTH, ROTATE_X_90) - .register(Direction.SOUTH, ROTATE_X_90.then(ROTATE_Y_180)) - .register(Direction.WEST, ROTATE_X_90.then(ROTATE_Y_270)) - .register(Direction.EAST, ROTATE_X_90.then(ROTATE_Y_90)); - - public PromenadeModelProvider(FabricDataOutput output) { - super(output); - } - - @Override - public void generateBlockStateModels(BlockStateModelGenerator gen) { - PromenadeBlockFamilies.getFamilies().filter(BlockFamily::shouldGenerateModels).forEach(family -> gen.registerCubeAllModelTexturePool(family.getBaseBlock()).family(family)); - - gen.registerTintedBlockAndItem(PromenadeBlocks.OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.OAK_LEAVES), FoliageColors.DEFAULT); - gen.registerTintedBlockAndItem(PromenadeBlocks.SPRUCE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.SPRUCE_LEAVES), FoliageColors.SPRUCE); - gen.registerTintedBlockAndItem(PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.BIRCH_LEAVES), FoliageColors.BIRCH); - gen.registerTintedBlockAndItem(PromenadeBlocks.JUNGLE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.JUNGLE_LEAVES), FoliageColors.DEFAULT); - gen.registerTintedBlockAndItem(PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.ACACIA_LEAVES), FoliageColors.DEFAULT); - gen.registerSingleton(PromenadeBlocks.CHERRY_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.CHERRY_LEAVES)); - gen.registerTintedBlockAndItem(PromenadeBlocks.DARK_OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.DARK_OAK_LEAVES), FoliageColors.DEFAULT); - gen.registerSingleton(PromenadeBlocks.PALE_OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.PALE_OAK_LEAVES)); - gen.registerTintedBlockAndItem(PromenadeBlocks.MANGROVE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.MANGROVE_LEAVES), FoliageColors.MANGROVE); - gen.registerSingleton(PromenadeBlocks.AZALEA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.AZALEA_LEAVES)); - gen.registerSingleton(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.FLOWERING_AZALEA_LEAVES)); - - gen.registerSingleton(PromenadeBlocks.DANDELION_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.POPPY_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.BLUE_ORCHID_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.ALLIUM_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.AZURE_BLUET_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.RED_TULIP_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.ORANGE_TULIP_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.WHITE_TULIP_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.PINK_TULIP_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.OXEYE_DAISY_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.CORNFLOWER_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, PromenadeTexturedModels.PILE); - gen.registerSingleton(PromenadeBlocks.WITHER_ROSE_PILE, PromenadeTexturedModels.PILE); - - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_OAK_LEAVES, Blocks.OAK_LEAVES, FoliageColors.DEFAULT); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_SPRUCE_LEAVES, Blocks.SPRUCE_LEAVES, FoliageColors.SPRUCE); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_BIRCH_LEAVES, Blocks.BIRCH_LEAVES, FoliageColors.BIRCH); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_JUNGLE_LEAVES, Blocks.JUNGLE_LEAVES, FoliageColors.DEFAULT); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_ACACIA_LEAVES, Blocks.ACACIA_LEAVES, FoliageColors.DEFAULT); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_CHERRY_LEAVES, Blocks.CHERRY_LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, Blocks.DARK_OAK_LEAVES, FoliageColors.DEFAULT); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, Blocks.PALE_OAK_LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_MANGROVE_LEAVES, Blocks.MANGROVE_LEAVES, FoliageColors.MANGROVE); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_AZALEA_LEAVES, Blocks.AZALEA_LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, Blocks.FLOWERING_AZALEA_LEAVES); - - gen.createLogTexturePool(PromenadeBlocks.SAKURA_LOG).uvLockedLog(PromenadeBlocks.SAKURA_LOG).wood(PromenadeBlocks.SAKURA_WOOD); - gen.createLogTexturePool(PromenadeBlocks.STRIPPED_SAKURA_LOG).uvLockedLog(PromenadeBlocks.STRIPPED_SAKURA_LOG).wood(PromenadeBlocks.STRIPPED_SAKURA_WOOD); - gen.registerHangingSign(PromenadeBlocks.STRIPPED_SAKURA_LOG, PromenadeBlocks.SAKURA_HANGING_SIGN, PromenadeBlocks.SAKURA_WALL_HANGING_SIGN); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.BLUSH_SAKURA_SAPLING, PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.COTTON_SAKURA_SAPLING, PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerSingleton(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, TexturedModel.LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, "snowy_sakura_blossoms"); - gen.registerSingleton(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, TexturedModel.LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, "snowy_sakura_blossoms"); - gen.registerSingleton(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS)); - gen.registerSingleton(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS)); - - gen.createLogTexturePool(PromenadeBlocks.MAPLE_LOG).log(PromenadeBlocks.MAPLE_LOG).wood(PromenadeBlocks.MAPLE_WOOD); - registerDripLog(gen, PromenadeBlocks.STRIPPED_MAPLE_LOG); - gen.createLogTexturePool(PromenadeBlocks.STRIPPED_MAPLE_LOG).wood(PromenadeBlocks.STRIPPED_MAPLE_WOOD); - gen.registerHangingSign(PromenadeBlocks.STRIPPED_MAPLE_LOG, PromenadeBlocks.MAPLE_HANGING_SIGN, PromenadeBlocks.MAPLE_WALL_HANGING_SIGN); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.SAP_MAPLE_SAPLING, PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.VERMILION_MAPLE_SAPLING, PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.FULVOUS_MAPLE_SAPLING, PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.MIKADO_MAPLE_SAPLING, PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerTintedBlockAndItem(PromenadeBlocks.SAP_MAPLE_LEAVES, TexturedModel.LEAVES, PromenadeFoliageColors.SAP_MAPLE); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES, "snowy_maple_leaves", PromenadeFoliageColors.SAP_MAPLE); - gen.registerSingleton(PromenadeBlocks.VERMILION_MAPLE_LEAVES, TexturedModel.LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, PromenadeBlocks.VERMILION_MAPLE_LEAVES, "snowy_maple_leaves"); - gen.registerSingleton(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, TexturedModel.LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, PromenadeBlocks.FULVOUS_MAPLE_LEAVES, "snowy_maple_leaves"); - gen.registerSingleton(PromenadeBlocks.MIKADO_MAPLE_LEAVES, TexturedModel.LEAVES); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, PromenadeBlocks.MIKADO_MAPLE_LEAVES, "snowy_maple_leaves"); - this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, PromenadeFoliageColors.SAP_MAPLE); - this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES); - this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES); - this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES); - gen.registerTintedBlockAndItem(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.SAP_MAPLE_LEAVES), PromenadeFoliageColors.SAP_MAPLE); - gen.registerSingleton(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.VERMILION_MAPLE_LEAVES)); - gen.registerSingleton(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.FULVOUS_MAPLE_LEAVES)); - gen.registerSingleton(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.MIKADO_MAPLE_LEAVES)); - - gen.createLogTexturePool(PromenadeBlocks.PALM_LOG).log(PromenadeBlocks.PALM_LOG).wood(PromenadeBlocks.PALM_WOOD); - gen.createLogTexturePool(PromenadeBlocks.STRIPPED_PALM_LOG).log(PromenadeBlocks.STRIPPED_PALM_LOG).wood(PromenadeBlocks.STRIPPED_PALM_WOOD); - gen.registerHangingSign(PromenadeBlocks.STRIPPED_PALM_LOG, PromenadeBlocks.PALM_HANGING_SIGN, PromenadeBlocks.PALM_WALL_HANGING_SIGN); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.PALM_SAPLING, PromenadeBlocks.POTTED_PALM_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerTintedBlockAndItem(PromenadeBlocks.PALM_LEAVES, TexturedModel.LEAVES, PromenadeFoliageColors.PALM); - this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_LEAVES, PromenadeFoliageColors.PALM); - gen.registerTintedBlockAndItem(PromenadeBlocks.PALM_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.PALM_LEAVES), PromenadeFoliageColors.PALM); - gen.registerTintableCrossBlockState(PromenadeBlocks.PALM_HANGING_LEAVES, BlockStateModelGenerator.CrossType.TINTED); - this.registerTintedItem(gen, PromenadeBlocks.PALM_HANGING_LEAVES, PromenadeFoliageColors.PALM); - - gen.registerNetherrackBottomCustomTop(PromenadeBlocks.DARK_AMARANTH_NYLIUM); - gen.registerSimpleCubeAll(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); - gen.registerRoots(PromenadeBlocks.DARK_AMARANTH_ROOTS, PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS); - gen.createLogTexturePool(PromenadeBlocks.DARK_AMARANTH_STEM).stem(PromenadeBlocks.DARK_AMARANTH_STEM).wood(PromenadeBlocks.DARK_AMARANTH_HYPHAE); - gen.createLogTexturePool(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM).stem(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM).wood(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); - gen.registerHangingSign(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM, PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN, PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN); - gen.registerFlowerPotPlantAndItem(PromenadeBlocks.DARK_AMARANTH_FUNGUS, PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS, BlockStateModelGenerator.CrossType.NOT_TINTED); - - gen.registerSimpleCubeAll(PromenadeBlocks.SOUL_SHROOMLIGHT); - - this.registerFacingPlantPart(gen, PromenadeBlocks.COILED_VINES, PromenadeBlocks.COILED_VINES_PLANT, BlockStateModelGenerator.CrossType.NOT_TINTED); - gen.registerItemModel(PromenadeBlocks.COILED_VINES, "_plant"); - - this.registerMoai(gen); - - this.registerBlueberryBush(gen); - } - - public final void registerDripLog(BlockStateModelGenerator gen, Block block) { - var textureMap = new TextureMap().put(TextureKey.SIDE, TextureMap.getId(block)).put(TextureKey.END, TextureMap.getSubId(block, "_top")).put(TextureKey.PARTICLE, TextureMap.getId(block)); - var textureMapDrip = new TextureMap().put(TextureKey.SIDE, TextureMap.getSubId(block, "_drip")).put(TextureKey.END, TextureMap.getSubId(block, "_top")).put(TextureKey.PARTICLE, TextureMap.getId(block)); - - var verticalModel = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN.upload(block, textureMap, gen.modelCollector)); - var horizontalModel = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN_HORIZONTAL.upload(block, textureMap, gen.modelCollector)); - - var verticalModelDrip = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN.upload(block, "_drip", textureMapDrip, gen.modelCollector)); - var horizontalModelDrip = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN_HORIZONTAL.upload(block, "_drip", textureMapDrip, gen.modelCollector)); - - gen.blockStateCollector.accept(VariantsBlockModelDefinitionCreator.of(block).with( - BlockStateVariantMap.models(Properties.AXIS, PromenadeBlockProperties.DRIP) - .register(Direction.Axis.Y, false, verticalModel) - .register(Direction.Axis.Z, false, horizontalModel.apply(ROTATE_X_90)) - .register(Direction.Axis.X, false, horizontalModel.apply(ROTATE_X_90).apply(ROTATE_Y_90)) - .register(Direction.Axis.Y, true, verticalModelDrip) - .register(Direction.Axis.Z, true, horizontalModelDrip.apply(ROTATE_X_90)) - .register(Direction.Axis.X, true, horizontalModelDrip.apply(ROTATE_X_90).apply(ROTATE_Y_90)) - )); - } - - public final void registerTintedItem(BlockStateModelGenerator gen, Block block, int constant) { - registerTintedItem(gen, block, ItemModels.constantTintSource(constant)); - } - - public final void registerTintedItem(BlockStateModelGenerator gen, Block block, TintSource tint) { - Identifier identifier = gen.uploadBlockItemModel(block.asItem(), block); - gen.registerTintedItemModel(block, identifier, tint); - } - - public final void registerBlueberryBush(BlockStateModelGenerator gen) { - gen.registerItemModel(PromenadeItems.BLUEBERRIES); - gen.blockStateCollector.accept(VariantsBlockModelDefinitionCreator.of(PromenadeBlocks.BLUEBERRY_BUSH) - .with( - BlockStateVariantMap.models(Properties.AGE_3) - .generate(stage -> BlockStateModelGenerator.createWeightedVariant(gen.createSubModel(PromenadeBlocks.BLUEBERRY_BUSH, "_stage" + stage, Models.CROSS, TextureMap::cross))) - ) - ); - } - - private void registerMoai(BlockStateModelGenerator gen) { - // maybe check if we can't generate the models too? - gen.blockStateCollector - .accept( - VariantsBlockModelDefinitionCreator.of(PromenadeBlocks.MOAI) - .with(BlockStateVariantMap.models(MoaiBlock.TYPE) - .register(MoaiType.SINGLE, BlockStateModelGenerator.createWeightedVariant(ModelIds.getBlockModelId(PromenadeBlocks.MOAI))) - .register(MoaiType.TOP, BlockStateModelGenerator.createWeightedVariant(ModelIds.getBlockSubModelId(PromenadeBlocks.MOAI, "_top"))) - .register(MoaiType.BOTTOM, BlockStateModelGenerator.createWeightedVariant(ModelIds.getBlockSubModelId(PromenadeBlocks.MOAI, "_bottom"))) - ) - .coordinate(NORTH_DEFAULT_HORIZONTAL_ROTATION_OPERATIONS) - ); - } - - private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves) { - registerSnowyLeaves(gen, snowyLeaves, normalLeaves, 0); - } - - private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves, int tint) { - var bottomModel = gen.createSubModel(snowyLeaves, "_bottom", PromenadeModels.BOTTOM_SNOWY_LEAVES, block -> PromenadeTextureMaps.snowyLeaves(snowyLeaves, normalLeaves)); - if (tint != 0) { - gen.registerTintedItemModel(snowyLeaves, bottomModel, ItemModels.constantTintSource(tint)); - } else { - gen.registerItemModel(snowyLeaves.asItem(), bottomModel); - } - gen.blockStateCollector.accept( - VariantsBlockModelDefinitionCreator.of(snowyLeaves) - .with(BlockStateVariantMap.models(SnowyLeavesBlock.BOTTOM) - .register(true, BlockStateModelGenerator.createWeightedVariant(bottomModel)) - .register(false, BlockStateModelGenerator.createWeightedVariant(gen.createSubModel(snowyLeaves, "", Models.CUBE_ALL, TextureMap::all))) - ) - ); - } - - private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves, String textureName) { - registerSnowyLeaves(gen, snowyLeaves, normalLeaves, textureName, 0); - } - - private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves, String textureName, int tint) { - var textureId = Identifier.of(Registries.BLOCK.getId(snowyLeaves).getNamespace(), "block/" + textureName); - var bottomModel = gen.createSubModel(snowyLeaves, "_bottom", PromenadeModels.BOTTOM_SNOWY_LEAVES, block -> PromenadeTextureMaps.snowyLeaves(textureId, normalLeaves)); - if (tint != 0) { - gen.registerTintedItemModel(snowyLeaves, bottomModel, ItemModels.constantTintSource(tint)); - } else { - gen.registerItemModel(snowyLeaves.asItem(), bottomModel); - } - gen.blockStateCollector.accept( - VariantsBlockModelDefinitionCreator.of(snowyLeaves) - .with(BlockStateVariantMap.models(SnowyLeavesBlock.BOTTOM) - .register(true, BlockStateModelGenerator.createWeightedVariant(bottomModel)) - .register(false, BlockStateModelGenerator.createWeightedVariant(gen.createSubModel(snowyLeaves, "", Models.CUBE_ALL, identifier -> TextureMap.all(textureId)))) - ) - ); - - } - - private void registerFallenLeaves(BlockStateModelGenerator gen, Block fallenLeaves) { - registerFallenLeaves(gen, fallenLeaves, 0); - } - - public final void registerFallenLeaves(BlockStateModelGenerator gen, Block fallenLeaves, int tintSource) { - if (tintSource != 0) { - Identifier identifier = gen.uploadBlockItemModel(fallenLeaves.asItem(), fallenLeaves); - gen.registerTintedItemModel(fallenLeaves, identifier, ItemModels.constantTintSource(tintSource)); - } else { - gen.registerItemModel(fallenLeaves); - } - var weightedVariant = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_1.upload(fallenLeaves, gen.modelCollector)); - var weightedVariant2 = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_2.upload(fallenLeaves, gen.modelCollector)); - var weightedVariant3 = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_3.upload(fallenLeaves, gen.modelCollector)); - var weightedVariant4 = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_4.upload(fallenLeaves, gen.modelCollector)); - gen.registerSegmentedBlock(fallenLeaves, - weightedVariant, LEAF_LITTER_MODEL_1_CONDITION_FUNCTION, - weightedVariant2, LEAF_LITTER_MODEL_2_CONDITION_FUNCTION, - weightedVariant3, LEAF_LITTER_MODEL_3_CONDITION_FUNCTION, - weightedVariant4, LEAF_LITTER_MODEL_4_CONDITION_FUNCTION - ); - } - - public final void registerFacingPlantPart(BlockStateModelGenerator gen, Block plant, Block plantStem, BlockStateModelGenerator.CrossType tintType) { - this.registerFacingTintableCrossBlockState(gen, plant, tintType); - this.registerFacingTintableCrossBlockState(gen, plantStem, tintType); - } - - public final void registerFacingTintableCrossBlockState(BlockStateModelGenerator gen, Block block, BlockStateModelGenerator.CrossType tintType) { - TextureMap textureMap = tintType.getTextureMap(block); - this.registerFacingTintableCrossBlockState(gen, block, tintType, textureMap); - } - - public final void registerFacingTintableCrossBlockState(BlockStateModelGenerator gen, Block block, BlockStateModelGenerator.CrossType tintType, TextureMap crossTexture) { - WeightedVariant weightedVariant = BlockStateModelGenerator.createWeightedVariant(tintType.getCrossModel().upload(block, crossTexture, gen.modelCollector)); - gen.blockStateCollector.accept( - BlockStateModelGenerator.createSingletonBlockState(block, weightedVariant) - .coordinate(UP_DEFAULT_ROTATION_OPERATIONS) - ); - } - - @Override - public void generateItemModels(ItemModelGenerator gen) { - gen.register(PromenadeItems.SAKURA_BOAT, Models.GENERATED); - gen.register(PromenadeItems.SAKURA_CHEST_BOAT, Models.GENERATED); - gen.register(PromenadeItems.MAPLE_BOAT, Models.GENERATED); - gen.register(PromenadeItems.MAPLE_CHEST_BOAT, Models.GENERATED); - gen.register(PromenadeItems.MAPLE_SYRUP_BOTTLE, Models.GENERATED); - gen.register(PromenadeItems.PALM_BOAT, Models.GENERATED); - gen.register(PromenadeItems.PALM_CHEST_BOAT, Models.GENERATED); - - gen.register(PromenadeItems.BANANA, Models.GENERATED); - gen.register(PromenadeItems.APRICOT, Models.GENERATED); - gen.register(PromenadeItems.MANGO, Models.GENERATED); - gen.register(PromenadeItems.DUCK, Models.GENERATED); - gen.register(PromenadeItems.COOKED_DUCK, Models.GENERATED); - - gen.register(PromenadeItems.BOVINE_BANNER_PATTERN, Models.GENERATED); - - gen.register(PromenadeItems.CAPYBARA_SPAWN_EGG, Models.GENERATED); - gen.register(PromenadeItems.DUCK_SPAWN_EGG, Models.GENERATED); - gen.register(PromenadeItems.LUSH_CREEPER_SPAWN_EGG, Models.GENERATED); - gen.register(PromenadeItems.SUNKEN_SPAWN_EGG, Models.GENERATED); - } + public static final ModelVariantOperator NO_OP = variant -> variant; + public static final ModelVariantOperator UV_LOCK = ModelVariantOperator.UV_LOCK.withValue(true); + public static final ModelVariantOperator ROTATE_X_90 = ModelVariantOperator.ROTATION_X.withValue(AxisRotation.R90); + public static final ModelVariantOperator ROTATE_X_180 = ModelVariantOperator.ROTATION_X.withValue(AxisRotation.R180); + public static final ModelVariantOperator ROTATE_X_270 = ModelVariantOperator.ROTATION_X.withValue(AxisRotation.R270); + public static final ModelVariantOperator ROTATE_Y_90 = ModelVariantOperator.ROTATION_Y.withValue(AxisRotation.R90); + public static final ModelVariantOperator ROTATE_Y_180 = ModelVariantOperator.ROTATION_Y.withValue(AxisRotation.R180); + public static final ModelVariantOperator ROTATE_Y_270 = ModelVariantOperator.ROTATION_Y.withValue(AxisRotation.R270); + + private static final Function LEAF_LITTER_MODEL_1_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 1); + private static final Function LEAF_LITTER_MODEL_2_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 2, 3); + private static final Function LEAF_LITTER_MODEL_3_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 3); + private static final Function LEAF_LITTER_MODEL_4_CONDITION_FUNCTION = builder -> builder.put(Properties.SEGMENT_AMOUNT, 4); + + private static final BlockStateVariantMap NORTH_DEFAULT_HORIZONTAL_ROTATION_OPERATIONS = BlockStateVariantMap.operations( + Properties.HORIZONTAL_FACING + ) + .register(Direction.EAST, ROTATE_Y_90) + .register(Direction.SOUTH, ROTATE_Y_180) + .register(Direction.WEST, ROTATE_Y_270) + .register(Direction.NORTH, NO_OP); + private static final BlockStateVariantMap UP_DEFAULT_ROTATION_OPERATIONS = BlockStateVariantMap.operations(Properties.FACING) + .register(Direction.DOWN, ROTATE_X_180) + .register(Direction.UP, NO_OP) + .register(Direction.NORTH, ROTATE_X_90) + .register(Direction.SOUTH, ROTATE_X_90.then(ROTATE_Y_180)) + .register(Direction.WEST, ROTATE_X_90.then(ROTATE_Y_270)) + .register(Direction.EAST, ROTATE_X_90.then(ROTATE_Y_90)); + + public PromenadeModelProvider(FabricDataOutput output) { + super(output); + } + + @Override + public void generateBlockStateModels(BlockStateModelGenerator gen) { + PromenadeBlockFamilies.getFamilies().filter(BlockFamily::shouldGenerateModels).forEach(family -> gen.registerCubeAllModelTexturePool(family.getBaseBlock()).family(family)); + + gen.registerTintedBlockAndItem(PromenadeBlocks.OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.OAK_LEAVES), FoliageColors.DEFAULT); + gen.registerTintedBlockAndItem(PromenadeBlocks.SPRUCE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.SPRUCE_LEAVES), FoliageColors.SPRUCE); + gen.registerTintedBlockAndItem(PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.BIRCH_LEAVES), FoliageColors.BIRCH); + gen.registerTintedBlockAndItem(PromenadeBlocks.JUNGLE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.JUNGLE_LEAVES), FoliageColors.DEFAULT); + gen.registerTintedBlockAndItem(PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.ACACIA_LEAVES), FoliageColors.DEFAULT); + gen.registerSingleton(PromenadeBlocks.CHERRY_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.CHERRY_LEAVES)); + gen.registerTintedBlockAndItem(PromenadeBlocks.DARK_OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.DARK_OAK_LEAVES), FoliageColors.DEFAULT); + gen.registerSingleton(PromenadeBlocks.PALE_OAK_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.PALE_OAK_LEAVES)); + gen.registerTintedBlockAndItem(PromenadeBlocks.MANGROVE_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.MANGROVE_LEAVES), FoliageColors.MANGROVE); + gen.registerSingleton(PromenadeBlocks.AZALEA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.AZALEA_LEAVES)); + gen.registerSingleton(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, PromenadeTexturedModels.pile(Blocks.FLOWERING_AZALEA_LEAVES)); + + gen.registerSingleton(PromenadeBlocks.DANDELION_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.POPPY_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.BLUE_ORCHID_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.ALLIUM_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.AZURE_BLUET_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.RED_TULIP_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.ORANGE_TULIP_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.WHITE_TULIP_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.PINK_TULIP_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.OXEYE_DAISY_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.CORNFLOWER_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, PromenadeTexturedModels.PILE); + gen.registerSingleton(PromenadeBlocks.WITHER_ROSE_PILE, PromenadeTexturedModels.PILE); + + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_OAK_LEAVES, Blocks.OAK_LEAVES, FoliageColors.DEFAULT); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_SPRUCE_LEAVES, Blocks.SPRUCE_LEAVES, FoliageColors.SPRUCE); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_BIRCH_LEAVES, Blocks.BIRCH_LEAVES, FoliageColors.BIRCH); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_JUNGLE_LEAVES, Blocks.JUNGLE_LEAVES, FoliageColors.DEFAULT); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_ACACIA_LEAVES, Blocks.ACACIA_LEAVES, FoliageColors.DEFAULT); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_CHERRY_LEAVES, Blocks.CHERRY_LEAVES); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, Blocks.DARK_OAK_LEAVES, FoliageColors.DEFAULT); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, Blocks.PALE_OAK_LEAVES); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_MANGROVE_LEAVES, Blocks.MANGROVE_LEAVES, FoliageColors.MANGROVE); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_AZALEA_LEAVES, Blocks.AZALEA_LEAVES); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, Blocks.FLOWERING_AZALEA_LEAVES); + + gen.createLogTexturePool(PromenadeBlocks.SAKURA_LOG).uvLockedLog(PromenadeBlocks.SAKURA_LOG).wood(PromenadeBlocks.SAKURA_WOOD); + gen.createLogTexturePool(PromenadeBlocks.STRIPPED_SAKURA_LOG).uvLockedLog(PromenadeBlocks.STRIPPED_SAKURA_LOG).wood(PromenadeBlocks.STRIPPED_SAKURA_WOOD); + gen.registerHangingSign(PromenadeBlocks.STRIPPED_SAKURA_LOG, PromenadeBlocks.SAKURA_HANGING_SIGN, PromenadeBlocks.SAKURA_WALL_HANGING_SIGN); + gen.registerFlowerPotPlantAndItem(PromenadeBlocks.BLUSH_SAKURA_SAPLING, PromenadeBlocks.POTTED_BLUSH_SAKURA_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); + gen.registerFlowerPotPlantAndItem(PromenadeBlocks.COTTON_SAKURA_SAPLING, PromenadeBlocks.POTTED_COTTON_SAKURA_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); + gen.registerSingleton(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, TexturedModel.LEAVES); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, "snowy_sakura_blossoms"); + gen.registerSingleton(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, TexturedModel.LEAVES); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, "snowy_sakura_blossoms"); + gen.registerSingleton(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS)); + gen.registerSingleton(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS)); + + gen.createLogTexturePool(PromenadeBlocks.MAPLE_LOG).log(PromenadeBlocks.MAPLE_LOG).wood(PromenadeBlocks.MAPLE_WOOD); + registerDripLog(gen, PromenadeBlocks.STRIPPED_MAPLE_LOG); + gen.createLogTexturePool(PromenadeBlocks.STRIPPED_MAPLE_LOG).wood(PromenadeBlocks.STRIPPED_MAPLE_WOOD); + gen.registerHangingSign(PromenadeBlocks.STRIPPED_MAPLE_LOG, PromenadeBlocks.MAPLE_HANGING_SIGN, PromenadeBlocks.MAPLE_WALL_HANGING_SIGN); + gen.registerFlowerPotPlantAndItem(PromenadeBlocks.SAP_MAPLE_SAPLING, PromenadeBlocks.POTTED_SAP_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); + gen.registerFlowerPotPlantAndItem(PromenadeBlocks.VERMILION_MAPLE_SAPLING, PromenadeBlocks.POTTED_VERMILION_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); + gen.registerFlowerPotPlantAndItem(PromenadeBlocks.FULVOUS_MAPLE_SAPLING, PromenadeBlocks.POTTED_FULVOUS_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); + gen.registerFlowerPotPlantAndItem(PromenadeBlocks.MIKADO_MAPLE_SAPLING, PromenadeBlocks.POTTED_MIKADO_MAPLE_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); + gen.registerTintedBlockAndItem(PromenadeBlocks.SAP_MAPLE_LEAVES, TexturedModel.LEAVES, PromenadeFoliageColors.SAP_MAPLE); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES, "snowy_maple_leaves", PromenadeFoliageColors.SAP_MAPLE); + gen.registerSingleton(PromenadeBlocks.VERMILION_MAPLE_LEAVES, TexturedModel.LEAVES); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, PromenadeBlocks.VERMILION_MAPLE_LEAVES, "snowy_maple_leaves"); + gen.registerSingleton(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, TexturedModel.LEAVES); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, PromenadeBlocks.FULVOUS_MAPLE_LEAVES, "snowy_maple_leaves"); + gen.registerSingleton(PromenadeBlocks.MIKADO_MAPLE_LEAVES, TexturedModel.LEAVES); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, PromenadeBlocks.MIKADO_MAPLE_LEAVES, "snowy_maple_leaves"); + this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, PromenadeFoliageColors.SAP_MAPLE); + this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES); + this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES); + this.registerFallenLeaves(gen, PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES); + gen.registerTintedBlockAndItem(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.SAP_MAPLE_LEAVES), PromenadeFoliageColors.SAP_MAPLE); + gen.registerSingleton(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.VERMILION_MAPLE_LEAVES)); + gen.registerSingleton(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.FULVOUS_MAPLE_LEAVES)); + gen.registerSingleton(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.MIKADO_MAPLE_LEAVES)); + + gen.createLogTexturePool(PromenadeBlocks.PALM_LOG).log(PromenadeBlocks.PALM_LOG).wood(PromenadeBlocks.PALM_WOOD); + gen.createLogTexturePool(PromenadeBlocks.STRIPPED_PALM_LOG).log(PromenadeBlocks.STRIPPED_PALM_LOG).wood(PromenadeBlocks.STRIPPED_PALM_WOOD); + gen.registerHangingSign(PromenadeBlocks.STRIPPED_PALM_LOG, PromenadeBlocks.PALM_HANGING_SIGN, PromenadeBlocks.PALM_WALL_HANGING_SIGN); + gen.registerFlowerPotPlantAndItem(PromenadeBlocks.PALM_SAPLING, PromenadeBlocks.POTTED_PALM_SAPLING, BlockStateModelGenerator.CrossType.NOT_TINTED); + gen.registerTintedBlockAndItem(PromenadeBlocks.PALM_LEAVES, TexturedModel.LEAVES, PromenadeFoliageColors.PALM); + this.registerSnowyLeaves(gen, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_LEAVES, PromenadeFoliageColors.PALM); + gen.registerTintedBlockAndItem(PromenadeBlocks.PALM_LEAF_PILE, PromenadeTexturedModels.pile(PromenadeBlocks.PALM_LEAVES), PromenadeFoliageColors.PALM); + gen.registerTintableCrossBlockState(PromenadeBlocks.PALM_HANGING_LEAVES, BlockStateModelGenerator.CrossType.TINTED); + this.registerTintedItem(gen, PromenadeBlocks.PALM_HANGING_LEAVES, PromenadeFoliageColors.PALM); + + gen.registerNetherrackBottomCustomTop(PromenadeBlocks.DARK_AMARANTH_NYLIUM); + gen.registerSimpleCubeAll(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); + gen.registerRoots(PromenadeBlocks.DARK_AMARANTH_ROOTS, PromenadeBlocks.POTTED_DARK_AMARANTH_ROOTS); + gen.createLogTexturePool(PromenadeBlocks.DARK_AMARANTH_STEM).stem(PromenadeBlocks.DARK_AMARANTH_STEM).wood(PromenadeBlocks.DARK_AMARANTH_HYPHAE); + gen.createLogTexturePool(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM).stem(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM).wood(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); + gen.registerHangingSign(PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM, PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN, PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN); + gen.registerFlowerPotPlantAndItem(PromenadeBlocks.DARK_AMARANTH_FUNGUS, PromenadeBlocks.POTTED_DARK_AMARANTH_FUNGUS, BlockStateModelGenerator.CrossType.NOT_TINTED); + + gen.registerSimpleCubeAll(PromenadeBlocks.SOUL_SHROOMLIGHT); + + this.registerFacingPlantPart(gen, PromenadeBlocks.COILED_VINES, PromenadeBlocks.COILED_VINES_PLANT, BlockStateModelGenerator.CrossType.NOT_TINTED); + gen.registerItemModel(PromenadeBlocks.COILED_VINES, "_plant"); + + this.registerMoai(gen); + + this.registerBlueberryBush(gen); + } + + public final void registerDripLog(BlockStateModelGenerator gen, Block block) { + var textureMap = new TextureMap().put(TextureKey.SIDE, TextureMap.getId(block)).put(TextureKey.END, TextureMap.getSubId(block, "_top")).put(TextureKey.PARTICLE, TextureMap.getId(block)); + var textureMapDrip = new TextureMap().put(TextureKey.SIDE, TextureMap.getSubId(block, "_drip")).put(TextureKey.END, TextureMap.getSubId(block, "_top")).put(TextureKey.PARTICLE, TextureMap.getId(block)); + + var verticalModel = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN.upload(block, textureMap, gen.modelCollector)); + var horizontalModel = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN_HORIZONTAL.upload(block, textureMap, gen.modelCollector)); + + var verticalModelDrip = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN.upload(block, "_drip", textureMapDrip, gen.modelCollector)); + var horizontalModelDrip = BlockStateModelGenerator.createWeightedVariant(Models.CUBE_COLUMN_HORIZONTAL.upload(block, "_drip", textureMapDrip, gen.modelCollector)); + + gen.blockStateCollector.accept(VariantsBlockModelDefinitionCreator.of(block).with( + BlockStateVariantMap.models(Properties.AXIS, PromenadeBlockProperties.DRIP) + .register(Direction.Axis.Y, false, verticalModel) + .register(Direction.Axis.Z, false, horizontalModel.apply(ROTATE_X_90)) + .register(Direction.Axis.X, false, horizontalModel.apply(ROTATE_X_90).apply(ROTATE_Y_90)) + .register(Direction.Axis.Y, true, verticalModelDrip) + .register(Direction.Axis.Z, true, horizontalModelDrip.apply(ROTATE_X_90)) + .register(Direction.Axis.X, true, horizontalModelDrip.apply(ROTATE_X_90).apply(ROTATE_Y_90)) + )); + } + + public final void registerTintedItem(BlockStateModelGenerator gen, Block block, int constant) { + registerTintedItem(gen, block, ItemModels.constantTintSource(constant)); + } + + public final void registerTintedItem(BlockStateModelGenerator gen, Block block, TintSource tint) { + Identifier identifier = gen.uploadBlockItemModel(block.asItem(), block); + gen.registerTintedItemModel(block, identifier, tint); + } + + public final void registerBlueberryBush(BlockStateModelGenerator gen) { + gen.registerItemModel(PromenadeItems.BLUEBERRIES); + gen.blockStateCollector.accept(VariantsBlockModelDefinitionCreator.of(PromenadeBlocks.BLUEBERRY_BUSH) + .with( + BlockStateVariantMap.models(Properties.AGE_3) + .generate(stage -> BlockStateModelGenerator.createWeightedVariant(gen.createSubModel(PromenadeBlocks.BLUEBERRY_BUSH, "_stage" + stage, Models.CROSS, TextureMap::cross))) + ) + ); + } + + private void registerMoai(BlockStateModelGenerator gen) { + // maybe check if we can't generate the models too? + gen.blockStateCollector + .accept( + VariantsBlockModelDefinitionCreator.of(PromenadeBlocks.MOAI) + .with(BlockStateVariantMap.models(MoaiBlock.TYPE) + .register(MoaiType.SINGLE, BlockStateModelGenerator.createWeightedVariant(ModelIds.getBlockModelId(PromenadeBlocks.MOAI))) + .register(MoaiType.TOP, BlockStateModelGenerator.createWeightedVariant(ModelIds.getBlockSubModelId(PromenadeBlocks.MOAI, "_top"))) + .register(MoaiType.BOTTOM, BlockStateModelGenerator.createWeightedVariant(ModelIds.getBlockSubModelId(PromenadeBlocks.MOAI, "_bottom"))) + ) + .coordinate(NORTH_DEFAULT_HORIZONTAL_ROTATION_OPERATIONS) + ); + } + + private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves) { + registerSnowyLeaves(gen, snowyLeaves, normalLeaves, 0); + } + + private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves, int tint) { + var bottomModel = gen.createSubModel(snowyLeaves, "_bottom", PromenadeModels.BOTTOM_SNOWY_LEAVES, block -> PromenadeTextureMaps.snowyLeaves(snowyLeaves, normalLeaves)); + if (tint != 0) { + gen.registerTintedItemModel(snowyLeaves, bottomModel, ItemModels.constantTintSource(tint)); + } else { + gen.registerItemModel(snowyLeaves.asItem(), bottomModel); + } + gen.blockStateCollector.accept( + VariantsBlockModelDefinitionCreator.of(snowyLeaves) + .with(BlockStateVariantMap.models(SnowyLeavesBlock.BOTTOM) + .register(true, BlockStateModelGenerator.createWeightedVariant(bottomModel)) + .register(false, BlockStateModelGenerator.createWeightedVariant(gen.createSubModel(snowyLeaves, "", Models.CUBE_ALL, TextureMap::all))) + ) + ); + } + + private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves, String textureName) { + registerSnowyLeaves(gen, snowyLeaves, normalLeaves, textureName, 0); + } + + private void registerSnowyLeaves(BlockStateModelGenerator gen, Block snowyLeaves, Block normalLeaves, String textureName, int tint) { + var textureId = Identifier.of(Registries.BLOCK.getId(snowyLeaves).getNamespace(), "block/" + textureName); + var bottomModel = gen.createSubModel(snowyLeaves, "_bottom", PromenadeModels.BOTTOM_SNOWY_LEAVES, block -> PromenadeTextureMaps.snowyLeaves(textureId, normalLeaves)); + if (tint != 0) { + gen.registerTintedItemModel(snowyLeaves, bottomModel, ItemModels.constantTintSource(tint)); + } else { + gen.registerItemModel(snowyLeaves.asItem(), bottomModel); + } + gen.blockStateCollector.accept( + VariantsBlockModelDefinitionCreator.of(snowyLeaves) + .with(BlockStateVariantMap.models(SnowyLeavesBlock.BOTTOM) + .register(true, BlockStateModelGenerator.createWeightedVariant(bottomModel)) + .register(false, BlockStateModelGenerator.createWeightedVariant(gen.createSubModel(snowyLeaves, "", Models.CUBE_ALL, identifier -> TextureMap.all(textureId)))) + ) + ); + + } + + private void registerFallenLeaves(BlockStateModelGenerator gen, Block fallenLeaves) { + registerFallenLeaves(gen, fallenLeaves, 0); + } + + public final void registerFallenLeaves(BlockStateModelGenerator gen, Block fallenLeaves, int tintSource) { + if (tintSource != 0) { + Identifier identifier = gen.uploadBlockItemModel(fallenLeaves.asItem(), fallenLeaves); + gen.registerTintedItemModel(fallenLeaves, identifier, ItemModels.constantTintSource(tintSource)); + } else { + gen.registerItemModel(fallenLeaves); + } + var weightedVariant = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_1.upload(fallenLeaves, gen.modelCollector)); + var weightedVariant2 = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_2.upload(fallenLeaves, gen.modelCollector)); + var weightedVariant3 = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_3.upload(fallenLeaves, gen.modelCollector)); + var weightedVariant4 = BlockStateModelGenerator.createWeightedVariant(TexturedModel.TEMPLATE_LEAF_LITTER_4.upload(fallenLeaves, gen.modelCollector)); + gen.registerSegmentedBlock(fallenLeaves, + weightedVariant, LEAF_LITTER_MODEL_1_CONDITION_FUNCTION, + weightedVariant2, LEAF_LITTER_MODEL_2_CONDITION_FUNCTION, + weightedVariant3, LEAF_LITTER_MODEL_3_CONDITION_FUNCTION, + weightedVariant4, LEAF_LITTER_MODEL_4_CONDITION_FUNCTION + ); + } + + public final void registerFacingPlantPart(BlockStateModelGenerator gen, Block plant, Block plantStem, BlockStateModelGenerator.CrossType tintType) { + this.registerFacingTintableCrossBlockState(gen, plant, tintType); + this.registerFacingTintableCrossBlockState(gen, plantStem, tintType); + } + + public final void registerFacingTintableCrossBlockState(BlockStateModelGenerator gen, Block block, BlockStateModelGenerator.CrossType tintType) { + TextureMap textureMap = tintType.getTextureMap(block); + this.registerFacingTintableCrossBlockState(gen, block, tintType, textureMap); + } + + public final void registerFacingTintableCrossBlockState(BlockStateModelGenerator gen, Block block, BlockStateModelGenerator.CrossType tintType, TextureMap crossTexture) { + WeightedVariant weightedVariant = BlockStateModelGenerator.createWeightedVariant(tintType.getCrossModel().upload(block, crossTexture, gen.modelCollector)); + gen.blockStateCollector.accept( + BlockStateModelGenerator.createSingletonBlockState(block, weightedVariant) + .coordinate(UP_DEFAULT_ROTATION_OPERATIONS) + ); + } + + @Override + public void generateItemModels(ItemModelGenerator gen) { + gen.register(PromenadeItems.SAKURA_BOAT, Models.GENERATED); + gen.register(PromenadeItems.SAKURA_CHEST_BOAT, Models.GENERATED); + gen.register(PromenadeItems.MAPLE_BOAT, Models.GENERATED); + gen.register(PromenadeItems.MAPLE_CHEST_BOAT, Models.GENERATED); + gen.register(PromenadeItems.MAPLE_SYRUP_BOTTLE, Models.GENERATED); + gen.register(PromenadeItems.PALM_BOAT, Models.GENERATED); + gen.register(PromenadeItems.PALM_CHEST_BOAT, Models.GENERATED); + + gen.register(PromenadeItems.BANANA, Models.GENERATED); + gen.register(PromenadeItems.APRICOT, Models.GENERATED); + gen.register(PromenadeItems.MANGO, Models.GENERATED); + gen.register(PromenadeItems.DUCK, Models.GENERATED); + gen.register(PromenadeItems.COOKED_DUCK, Models.GENERATED); + + gen.register(PromenadeItems.BOVINE_BANNER_PATTERN, Models.GENERATED); + + gen.register(PromenadeItems.CAPYBARA_SPAWN_EGG, Models.GENERATED); + gen.register(PromenadeItems.DUCK_SPAWN_EGG, Models.GENERATED); + gen.register(PromenadeItems.LUSH_CREEPER_SPAWN_EGG, Models.GENERATED); + gen.register(PromenadeItems.SUNKEN_SPAWN_EGG, Models.GENERATED); + } } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantProvider.java index ccba777b..cf422187 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantProvider.java @@ -1,8 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.entity.variant.PromenadePaintingVariants; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + import net.minecraft.entity.decoration.painting.PaintingVariant; import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryKey; @@ -11,38 +22,40 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.entity.variant.PromenadePaintingVariants; public class PromenadePaintingVariantProvider extends FabricDynamicRegistryProvider { - public PromenadePaintingVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - final var wrapper = registries.getOrThrow(RegistryKeys.PAINTING_VARIANT); - entries.add(wrapper, PromenadePaintingVariants.OPTIMISM); - entries.add(wrapper, PromenadePaintingVariants.NURTURE); - } - - @Override - public String getName() { - return "Painting Variants"; - } - - public static void register(Registerable registerable) { - of(registerable, PromenadePaintingVariants.OPTIMISM, 2, 2, "hugman"); - of(registerable, PromenadePaintingVariants.NURTURE, 2, 2, "hugman"); - } - - private static void of(Registerable registry, RegistryKey key, int width, int height, String authorKey) { - registry.register(key, new PaintingVariant( - width, - height, - key.getValue(), - Optional.of(Text.translatable(key.getValue().toTranslationKey("painting", "title")).formatted(Formatting.YELLOW)), - Optional.of(Text.translatable("name." + authorKey).formatted(Formatting.GRAY))) - ); - } + public PromenadePaintingVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + final var wrapper = registries.getOrThrow(RegistryKeys.PAINTING_VARIANT); + entries.add(wrapper, PromenadePaintingVariants.OPTIMISM); + entries.add(wrapper, PromenadePaintingVariants.NURTURE); + } + + @Override + public String getName() { + return "Painting Variants"; + } + + public static void register(Registerable registerable) { + of(registerable, PromenadePaintingVariants.OPTIMISM, 2, 2, "hugman"); + of(registerable, PromenadePaintingVariants.NURTURE, 2, 2, "hugman"); + } + + private static void of(Registerable registry, RegistryKey key, int width, int height, String authorKey) { + registry.register(key, new PaintingVariant( + width, + height, + key.getValue(), + Optional.of(Text.translatable(key.getValue().toTranslationKey("painting", "title")).formatted(Formatting.YELLOW)), + Optional.of(Text.translatable("name." + authorKey).formatted(Formatting.GRAY))) + ); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantTagProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantTagProvider.java index b0832a68..a5d1659a 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantTagProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePaintingVariantTagProvider.java @@ -1,23 +1,36 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.entity.variant.PromenadePaintingVariants; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.entity.decoration.painting.PaintingVariant; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.tag.PaintingVariantTags; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; + +import fr.hugman.promenade.entity.variant.PromenadePaintingVariants; public class PromenadePaintingVariantTagProvider extends FabricTagProvider { - public PromenadePaintingVariantTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { - super(output, RegistryKeys.PAINTING_VARIANT, completableFuture); - } + public PromenadePaintingVariantTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { + super(output, RegistryKeys.PAINTING_VARIANT, completableFuture); + } - @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { - builder(PaintingVariantTags.PLACEABLE) - .add(PromenadePaintingVariants.OPTIMISM, PromenadePaintingVariants.NURTURE); - } + @Override + protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + builder(PaintingVariantTags.PLACEABLE) + .add(PromenadePaintingVariants.OPTIMISM, PromenadePaintingVariants.NURTURE); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePlacedFeatureProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePlacedFeatureProvider.java index 6415fa20..a48344a6 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePlacedFeatureProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadePlacedFeatureProvider.java @@ -1,13 +1,21 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; +import java.util.List; +import java.util.concurrent.CompletableFuture; + import com.google.common.collect.ImmutableList; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; -import fr.hugman.promenade.world.gen.feature.PromenadeFeatures; -import fr.hugman.promenade.world.gen.feature.PromenadePlacedFeatures; -import fr.hugman.promenade.world.gen.placement_modifier.NoiseIntervalCountPlacementModifier; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.registry.Registerable; @@ -25,191 +33,197 @@ import net.minecraft.world.gen.heightprovider.TrapezoidHeightProvider; import net.minecraft.world.gen.placementmodifier.*; -import java.util.List; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; +import fr.hugman.promenade.world.gen.feature.PromenadeFeatures; +import fr.hugman.promenade.world.gen.feature.PromenadePlacedFeatures; +import fr.hugman.promenade.world.gen.placement_modifier.NoiseIntervalCountPlacementModifier; public class PromenadePlacedFeatureProvider extends FabricDynamicRegistryProvider { - private static final PlacementModifier NOT_IN_SURFACE_WATER_MODIFIER = SurfaceWaterDepthFilterPlacementModifier.of(0); + private static final PlacementModifier NOT_IN_SURFACE_WATER_MODIFIER = SurfaceWaterDepthFilterPlacementModifier.of(0); - public PromenadePlacedFeatureProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } + public PromenadePlacedFeatureProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.PLACED_FEATURE)); - } + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(RegistryKeys.PLACED_FEATURE)); + } - @Override - public String getName() { - return "Placed Features"; - } + @Override + public String getName() { + return "Placed Features"; + } - public static void register(Registerable registerable) { - final var configured = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE); + public static void register(Registerable registerable) { + final var configured = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE); - // Ores - var asphalt = configured.getOrThrow(PromenadeConfiguredFeatures.ASPHALT_ORE); - of(registerable, PromenadePlacedFeatures.ORE_ASPHALT_UPPER, asphalt, modifiersWithRarity(6, HeightRangePlacementModifier.uniform(YOffset.fixed(64), YOffset.fixed(128)))); - of(registerable, PromenadePlacedFeatures.ORE_ASPHALT_LOWER, asphalt, modifiersWithCount(2, HeightRangePlacementModifier.uniform(YOffset.fixed(0), YOffset.fixed(60)))); - var blunite = configured.getOrThrow(PromenadeConfiguredFeatures.BLUNITE_ORE); - of(registerable, PromenadePlacedFeatures.ORE_BLUNITE_UPPER, blunite, modifiersWithRarity(4, HeightRangePlacementModifier.uniform(YOffset.fixed(64), YOffset.fixed(128)))); - of(registerable, PromenadePlacedFeatures.ORE_BLUNITE_LOWER, blunite, modifiersWithCount(2, HeightRangePlacementModifier.uniform(YOffset.fixed(0), YOffset.fixed(60)))); + // Ores + var asphalt = configured.getOrThrow(PromenadeConfiguredFeatures.ASPHALT_ORE); + of(registerable, PromenadePlacedFeatures.ORE_ASPHALT_UPPER, asphalt, modifiersWithRarity(6, HeightRangePlacementModifier.uniform(YOffset.fixed(64), YOffset.fixed(128)))); + of(registerable, PromenadePlacedFeatures.ORE_ASPHALT_LOWER, asphalt, modifiersWithCount(2, HeightRangePlacementModifier.uniform(YOffset.fixed(0), YOffset.fixed(60)))); + var blunite = configured.getOrThrow(PromenadeConfiguredFeatures.BLUNITE_ORE); + of(registerable, PromenadePlacedFeatures.ORE_BLUNITE_UPPER, blunite, modifiersWithRarity(4, HeightRangePlacementModifier.uniform(YOffset.fixed(64), YOffset.fixed(128)))); + of(registerable, PromenadePlacedFeatures.ORE_BLUNITE_LOWER, blunite, modifiersWithCount(2, HeightRangePlacementModifier.uniform(YOffset.fixed(0), YOffset.fixed(60)))); - of(registerable, PromenadePlacedFeatures.PACKED_ICE_ORE, - configured.getOrThrow(PromenadeConfiguredFeatures.PACKED_ICE_ORE), - modifiersWithCount(17, HeightRangePlacementModifier.of(TrapezoidHeightProvider.create(YOffset.fixed(0), YOffset.fixed(100), 60)))); - of(registerable, PromenadePlacedFeatures.BLUE_ICE_ORE, - configured.getOrThrow(PromenadeConfiguredFeatures.BLUE_ICE_ORE), - modifiersWithCount(4, HeightRangePlacementModifier.of(TrapezoidHeightProvider.create(YOffset.fixed(0), YOffset.fixed(100), 20)))); + of(registerable, PromenadePlacedFeatures.PACKED_ICE_ORE, + configured.getOrThrow(PromenadeConfiguredFeatures.PACKED_ICE_ORE), + modifiersWithCount(17, HeightRangePlacementModifier.of(TrapezoidHeightProvider.create(YOffset.fixed(0), YOffset.fixed(100), 60)))); + of(registerable, PromenadePlacedFeatures.BLUE_ICE_ORE, + configured.getOrThrow(PromenadeConfiguredFeatures.BLUE_ICE_ORE), + modifiersWithCount(4, HeightRangePlacementModifier.of(TrapezoidHeightProvider.create(YOffset.fixed(0), YOffset.fixed(100), 20)))); - // Trees - of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_BLUSH_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_BLUSH_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); + // Trees + of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_BLUSH_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_BLUSH_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.BLUSH_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.COTTON_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_COTTON_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.COTTON_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_COTTON_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.COTTON_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_COTTON_SAKURA, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.COTTON_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_COTTON_SAKURA_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.COTTON_SAKURA_SAPLING)); - of(registerable, PromenadePlacedFeatures.SAP_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.SAP_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_SAP_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.SAP_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.SAP_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_SAP_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.SAP_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.SAP_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_SAP_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.SAP_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.SAP_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_SAP_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.SAP_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.VERMILION_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.VERMILION_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_VERMILION_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.VERMILION_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.VERMILION_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_VERMILION_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); - - of(registerable, PromenadePlacedFeatures.FULVOUS_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FULVOUS_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FULVOUS_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FULVOUS_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); - - of(registerable, PromenadePlacedFeatures.MIKADO_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.MIKADO_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_MIKADO_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.MIKADO_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.MIKADO_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); - of(registerable, PromenadePlacedFeatures.FANCY_MIKADO_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); - - - // Vegetation - var blueberryBush = configured.getOrThrow(PromenadeConfiguredFeatures.BLUEBERRY_BUSH_PATCH); - of(registerable, PromenadePlacedFeatures.BLUEBERRY_BUSH_COMMON_PATCH, blueberryBush, rare(32)); - of(registerable, PromenadePlacedFeatures.BLUEBERRY_BUSH_RARE_PATCH, blueberryBush, rare(384)); - - of(registerable, PromenadePlacedFeatures.SAKURA_GROVE_BAMBOO, configured.getOrThrow(PromenadeConfiguredFeatures.BAMBOO_PATCH), modifiers(NoiseBasedCountPlacementModifier.of(2, 50.0d, 0.1d), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP)); - - of(registerable, PromenadePlacedFeatures.CUTE_LITTLE_ROCKS, configured.getOrThrow(PromenadeConfiguredFeatures.CUTE_LITTLE_ROCK), count(2, PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP)); - - of(registerable, PromenadePlacedFeatures.WATER_POOLS_GRAVEL_DECORATED, configured.getOrThrow(PromenadeConfiguredFeatures.WATER_POOL_GRAVEL_DECORATED), rare(10, PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP)); - - of(registerable, PromenadePlacedFeatures.FREEZE_TOP_LAYER, RegistryEntry.of(new ConfiguredFeature<>(PromenadeFeatures.FREEZE_TOP_LAYER, FeatureConfig.DEFAULT)), BiomePlacementModifier.of()); - - of(registerable, PromenadePlacedFeatures.DARK_AMARANTH_FOREST_VEGETATION, configured.getOrThrow(PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_VEGETATION), netherCount(6)); - - of(registerable, PromenadePlacedFeatures.FALLEN_VERMILION_MAPLE_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.FALLEN_VERMILION_MAPLE_LEAVES)); - of(registerable, PromenadePlacedFeatures.FALLEN_FULVOUS_MAPLE_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.FALLEN_FULVOUS_MAPLE_LEAVES)); - of(registerable, PromenadePlacedFeatures.FALLEN_MIKADO_MAPLE_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.FALLEN_MIKADO_MAPLE_LEAVES)); - - of(registerable, PromenadePlacedFeatures.COILED_VINES, configured.getOrThrow(PromenadeConfiguredFeatures.COILED_VINES), CountPlacementModifier.of(10), SquarePlacementModifier.of(), PlacedFeatures.BOTTOM_TO_TOP_RANGE, BiomePlacementModifier.of()); - - // Tree groups - of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA_GROVE_TREES, - configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA_GROVE_TREE), - treeModifiers(PlacedFeatures.createCountExtraModifier(2, 0.1F, 1))); - of(registerable, PromenadePlacedFeatures.COTTON_SAKURA_GROVE_TREES, - configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA_GROVE_TREE), - treeModifiers(PlacedFeatures.createCountExtraModifier(2, 0.1F, 1))); - - of(registerable, PromenadePlacedFeatures.CARNELIAN_TREEWAY_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_TREE), treeModifiers(PlacedFeatures.createCountExtraModifier(10, 0.1F, 1))); - of(registerable, PromenadePlacedFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES), count(25)); - - of(registerable, PromenadePlacedFeatures.GLACARIAN_TAIGA_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.SNOWY_MEGA_SPRUCE), treeModifiersWithWouldSurvive(PlacedFeatures.createCountExtraModifier(14, 0.1F, 4), Blocks.SPRUCE_SAPLING)); - - of(registerable, PromenadePlacedFeatures.PALMS, configured.getOrThrow(PromenadeConfiguredFeatures.PALM), treeModifiersWithWouldSurvive(PlacedFeatures.createCountExtraModifier(0, 0.1F, 1), PromenadeBlocks.PALM_SAPLING)); - - of(registerable, PromenadePlacedFeatures.DARK_AMARANTH_FUNGI, configured.getOrThrow(PromenadeConfiguredFeatures.DARK_AMARANTH_FUNGUS), netherCount(8)); - - } - - public static List rare(int chance) { - return rare(chance, PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP); - } - - public static List rare(int chance, PlacementModifier heightModifier) { - return modifiers(RarityFilterPlacementModifier.of(chance), heightModifier); - } - - public static List count(int count) { - return count(count, PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP); - } - - public static List count(int count, PlacementModifier heightModifier) { - return modifiers(CountPlacementModifier.of(count), heightModifier); - } - - public static List netherCount(int count) { - return List.of(CountMultilayerPlacementModifier.of(count), BiomePlacementModifier.of()); - } - - private static List modifiers(PlacementModifier countModifier, PlacementModifier heightModifier) { - return List.of(countModifier, SquarePlacementModifier.of(), heightModifier, BiomePlacementModifier.of()); - } - - private static List modifiersWithCount(int count, PlacementModifier heightModifier) { - return modifiers(CountPlacementModifier.of(count), heightModifier); - } - - private static List modifiersWithRarity(int chance, PlacementModifier heightModifier) { - return modifiers(RarityFilterPlacementModifier.of(chance), heightModifier); - } - - private static ImmutableList.Builder treeModifiersBuilder(PlacementModifier countModifier) { - return ImmutableList.builder() - .add(countModifier) - .add(SquarePlacementModifier.of()) - .add(NOT_IN_SURFACE_WATER_MODIFIER) - .add(PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP) - .add(BiomePlacementModifier.of()); - } - - public static List treeModifiersWithNoiseInterval(PlacementModifier countModifier, float noiseMin, float noiseMax) { - return ImmutableList.builder() - .add(countModifier) - .add(SquarePlacementModifier.of()) - .add(NoiseIntervalCountPlacementModifier.of(noiseMin, noiseMax, 1, 0)) - .add(NOT_IN_SURFACE_WATER_MODIFIER) - .add(PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP) - .add(BiomePlacementModifier.of()) - .build(); - } - - public static List treeModifiersWithWouldSurvive(PlacementModifier modifier, Block block) { - return treeModifiersBuilder(modifier).add(BlockFilterPlacementModifier.of(BlockPredicate.wouldSurvive(block.getDefaultState(), BlockPos.ORIGIN))).build(); - } - - public static List treeModifiers(PlacementModifier modifier) { - return treeModifiersBuilder(modifier).build(); - } - - public static void of( - Registerable featureRegisterable, - RegistryKey key, - RegistryEntry> feature, - List modifiers - ) { - PlacedFeatures.register(featureRegisterable, key, feature, modifiers); - } - - public static void of( - Registerable featureRegisterable, - RegistryKey key, - RegistryEntry> feature, - PlacementModifier... modifiers - ) { - PlacedFeatures.register(featureRegisterable, key, feature, modifiers); - } + of(registerable, PromenadePlacedFeatures.VERMILION_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.VERMILION_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_VERMILION_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.VERMILION_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.VERMILION_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_VERMILION_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.VERMILION_MAPLE_SAPLING)); + + of(registerable, PromenadePlacedFeatures.FULVOUS_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FULVOUS_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FULVOUS_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FULVOUS_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_FULVOUS_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.FULVOUS_MAPLE_SAPLING)); + + of(registerable, PromenadePlacedFeatures.MIKADO_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.MIKADO_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_MIKADO_MAPLE, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.MIKADO_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.MIKADO_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); + of(registerable, PromenadePlacedFeatures.FANCY_MIKADO_MAPLE_BEES, configured.getOrThrow(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE_BEES), PlacedFeatures.wouldSurvive(PromenadeBlocks.MIKADO_MAPLE_SAPLING)); + + + // Vegetation + var blueberryBush = configured.getOrThrow(PromenadeConfiguredFeatures.BLUEBERRY_BUSH_PATCH); + of(registerable, PromenadePlacedFeatures.BLUEBERRY_BUSH_COMMON_PATCH, blueberryBush, rare(32)); + of(registerable, PromenadePlacedFeatures.BLUEBERRY_BUSH_RARE_PATCH, blueberryBush, rare(384)); + + of(registerable, PromenadePlacedFeatures.SAKURA_GROVE_BAMBOO, configured.getOrThrow(PromenadeConfiguredFeatures.BAMBOO_PATCH), modifiers(NoiseBasedCountPlacementModifier.of(2, 50.0d, 0.1d), PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP)); + + of(registerable, PromenadePlacedFeatures.CUTE_LITTLE_ROCKS, configured.getOrThrow(PromenadeConfiguredFeatures.CUTE_LITTLE_ROCK), count(2, PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP)); + + of(registerable, PromenadePlacedFeatures.WATER_POOLS_GRAVEL_DECORATED, configured.getOrThrow(PromenadeConfiguredFeatures.WATER_POOL_GRAVEL_DECORATED), rare(10, PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP)); + + of(registerable, PromenadePlacedFeatures.FREEZE_TOP_LAYER, RegistryEntry.of(new ConfiguredFeature<>(PromenadeFeatures.FREEZE_TOP_LAYER, FeatureConfig.DEFAULT)), BiomePlacementModifier.of()); + + of(registerable, PromenadePlacedFeatures.DARK_AMARANTH_FOREST_VEGETATION, configured.getOrThrow(PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_VEGETATION), netherCount(6)); + + of(registerable, PromenadePlacedFeatures.FALLEN_VERMILION_MAPLE_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.FALLEN_VERMILION_MAPLE_LEAVES)); + of(registerable, PromenadePlacedFeatures.FALLEN_FULVOUS_MAPLE_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.FALLEN_FULVOUS_MAPLE_LEAVES)); + of(registerable, PromenadePlacedFeatures.FALLEN_MIKADO_MAPLE_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.FALLEN_MIKADO_MAPLE_LEAVES)); + + of(registerable, PromenadePlacedFeatures.COILED_VINES, configured.getOrThrow(PromenadeConfiguredFeatures.COILED_VINES), CountPlacementModifier.of(10), SquarePlacementModifier.of(), PlacedFeatures.BOTTOM_TO_TOP_RANGE, BiomePlacementModifier.of()); + + // Tree groups + of(registerable, PromenadePlacedFeatures.BLUSH_SAKURA_GROVE_TREES, + configured.getOrThrow(PromenadeConfiguredFeatures.BLUSH_SAKURA_GROVE_TREE), + treeModifiers(PlacedFeatures.createCountExtraModifier(2, 0.1F, 1))); + of(registerable, PromenadePlacedFeatures.COTTON_SAKURA_GROVE_TREES, + configured.getOrThrow(PromenadeConfiguredFeatures.COTTON_SAKURA_GROVE_TREE), + treeModifiers(PlacedFeatures.createCountExtraModifier(2, 0.1F, 1))); + + of(registerable, PromenadePlacedFeatures.CARNELIAN_TREEWAY_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_TREE), treeModifiers(PlacedFeatures.createCountExtraModifier(10, 0.1F, 1))); + of(registerable, PromenadePlacedFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES, configured.getOrThrow(PromenadeConfiguredFeatures.CARNELIAN_TREEWAY_FALLEN_LEAVES), count(25)); + + of(registerable, PromenadePlacedFeatures.GLACARIAN_TAIGA_TREES, configured.getOrThrow(PromenadeConfiguredFeatures.SNOWY_MEGA_SPRUCE), treeModifiersWithWouldSurvive(PlacedFeatures.createCountExtraModifier(14, 0.1F, 4), Blocks.SPRUCE_SAPLING)); + + of(registerable, PromenadePlacedFeatures.PALMS, configured.getOrThrow(PromenadeConfiguredFeatures.PALM), treeModifiersWithWouldSurvive(PlacedFeatures.createCountExtraModifier(0, 0.1F, 1), PromenadeBlocks.PALM_SAPLING)); + + of(registerable, PromenadePlacedFeatures.DARK_AMARANTH_FUNGI, configured.getOrThrow(PromenadeConfiguredFeatures.DARK_AMARANTH_FUNGUS), netherCount(8)); + + } + + public static List rare(int chance) { + return rare(chance, PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP); + } + + public static List rare(int chance, PlacementModifier heightModifier) { + return modifiers(RarityFilterPlacementModifier.of(chance), heightModifier); + } + + public static List count(int count) { + return count(count, PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP); + } + + public static List count(int count, PlacementModifier heightModifier) { + return modifiers(CountPlacementModifier.of(count), heightModifier); + } + + public static List netherCount(int count) { + return List.of(CountMultilayerPlacementModifier.of(count), BiomePlacementModifier.of()); + } + + private static List modifiers(PlacementModifier countModifier, PlacementModifier heightModifier) { + return List.of(countModifier, SquarePlacementModifier.of(), heightModifier, BiomePlacementModifier.of()); + } + + private static List modifiersWithCount(int count, PlacementModifier heightModifier) { + return modifiers(CountPlacementModifier.of(count), heightModifier); + } + + private static List modifiersWithRarity(int chance, PlacementModifier heightModifier) { + return modifiers(RarityFilterPlacementModifier.of(chance), heightModifier); + } + + private static ImmutableList.Builder treeModifiersBuilder(PlacementModifier countModifier) { + return ImmutableList.builder() + .add(countModifier) + .add(SquarePlacementModifier.of()) + .add(NOT_IN_SURFACE_WATER_MODIFIER) + .add(PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP) + .add(BiomePlacementModifier.of()); + } + + public static List treeModifiersWithNoiseInterval(PlacementModifier countModifier, float noiseMin, float noiseMax) { + return ImmutableList.builder() + .add(countModifier) + .add(SquarePlacementModifier.of()) + .add(NoiseIntervalCountPlacementModifier.of(noiseMin, noiseMax, 1, 0)) + .add(NOT_IN_SURFACE_WATER_MODIFIER) + .add(PlacedFeatures.OCEAN_FLOOR_HEIGHTMAP) + .add(BiomePlacementModifier.of()) + .build(); + } + + public static List treeModifiersWithWouldSurvive(PlacementModifier modifier, Block block) { + return treeModifiersBuilder(modifier).add(BlockFilterPlacementModifier.of(BlockPredicate.wouldSurvive(block.getDefaultState(), BlockPos.ORIGIN))).build(); + } + + public static List treeModifiers(PlacementModifier modifier) { + return treeModifiersBuilder(modifier).build(); + } + + public static void of( + Registerable featureRegisterable, + RegistryKey key, + RegistryEntry> feature, + List modifiers + ) { + PlacedFeatures.register(featureRegisterable, key, feature, modifiers); + } + + public static void of( + Registerable featureRegisterable, + RegistryKey key, + RegistryEntry> feature, + PlacementModifier... modifiers + ) { + PlacedFeatures.register(featureRegisterable, key, feature, modifiers); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeRecipeGenerator.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeRecipeGenerator.java index b1522e74..549050f1 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeRecipeGenerator.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeRecipeGenerator.java @@ -1,11 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.data.PromenadeBlockFamilies; -import fr.hugman.promenade.item.PromenadeItems; -import fr.hugman.promenade.tag.PromenadeItemTags; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.block.Blocks; import net.minecraft.data.family.BlockFamily; import net.minecraft.data.recipe.RecipeExporter; @@ -18,189 +25,195 @@ import net.minecraft.resource.featuretoggle.FeatureFlags; import net.minecraft.resource.featuretoggle.FeatureSet; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider; + +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.data.PromenadeBlockFamilies; +import fr.hugman.promenade.item.PromenadeItems; +import fr.hugman.promenade.tag.PromenadeItemTags; public class PromenadeRecipeGenerator extends RecipeGenerator { - public PromenadeRecipeGenerator(RegistryWrapper.WrapperLookup registries, RecipeExporter exporter) { - super(registries, exporter); - } - - @Override - public void generate() { - PromenadeBlockFamilies.getFamilies().filter(BlockFamily::shouldGenerateRecipes).forEach(family -> this.generateFamily(family, FeatureSet.of(FeatureFlags.VANILLA))); - - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.ASPHALT_SLAB, PromenadeBlocks.ASPHALT, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.ASPHALT_STAIRS, PromenadeBlocks.ASPHALT); - this.offerStonecuttingRecipe(RecipeCategory.DECORATIONS, PromenadeBlocks.ASPHALT_WALL, PromenadeBlocks.ASPHALT); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT, PromenadeBlocks.ASPHALT); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.ASPHALT, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_STAIRS, PromenadeBlocks.ASPHALT); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.POLISHED_ASPHALT, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_STAIRS, PromenadeBlocks.POLISHED_ASPHALT); - - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.BLUNITE_SLAB, PromenadeBlocks.BLUNITE, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.BLUNITE_STAIRS, PromenadeBlocks.BLUNITE); - this.offerStonecuttingRecipe(RecipeCategory.DECORATIONS, PromenadeBlocks.BLUNITE_WALL, PromenadeBlocks.BLUNITE); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE, PromenadeBlocks.BLUNITE); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.BLUNITE, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, PromenadeBlocks.BLUNITE); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.POLISHED_BLUNITE, 2); - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, PromenadeBlocks.POLISHED_BLUNITE); - - this.offerLeafPileRecipe(PromenadeBlocks.OAK_LEAF_PILE, Blocks.OAK_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.SPRUCE_LEAF_PILE, Blocks.SPRUCE_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.BIRCH_LEAF_PILE, Blocks.BIRCH_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.JUNGLE_LEAF_PILE, Blocks.JUNGLE_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.ACACIA_LEAF_PILE, Blocks.ACACIA_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.CHERRY_LEAF_PILE, Blocks.CHERRY_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.DARK_OAK_LEAF_PILE, Blocks.DARK_OAK_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.PALE_OAK_LEAF_PILE, Blocks.PALE_OAK_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.MANGROVE_LEAF_PILE, Blocks.MANGROVE_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.AZALEA_LEAF_PILE, Blocks.AZALEA_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, Blocks.FLOWERING_AZALEA_LEAVES); - - this.offerFlowerPileRecipe(PromenadeBlocks.DANDELION_PILE, Blocks.DANDELION); - this.offerFlowerPileRecipe(PromenadeBlocks.POPPY_PILE, Blocks.POPPY); - this.offerFlowerPileRecipe(PromenadeBlocks.BLUE_ORCHID_PILE, Blocks.BLUE_ORCHID); - this.offerFlowerPileRecipe(PromenadeBlocks.ALLIUM_PILE, Blocks.ALLIUM); - this.offerFlowerPileRecipe(PromenadeBlocks.AZURE_BLUET_PILE, Blocks.AZURE_BLUET); - this.offerFlowerPileRecipe(PromenadeBlocks.RED_TULIP_PILE, Blocks.RED_TULIP); - this.offerFlowerPileRecipe(PromenadeBlocks.ORANGE_TULIP_PILE, Blocks.ORANGE_TULIP); - this.offerFlowerPileRecipe(PromenadeBlocks.WHITE_TULIP_PILE, Blocks.WHITE_TULIP); - this.offerFlowerPileRecipe(PromenadeBlocks.PINK_TULIP_PILE, Blocks.PINK_TULIP); - this.offerFlowerPileRecipe(PromenadeBlocks.OXEYE_DAISY_PILE, Blocks.OXEYE_DAISY); - this.offerFlowerPileRecipe(PromenadeBlocks.CORNFLOWER_PILE, Blocks.CORNFLOWER); - this.offerFlowerPileRecipe(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, Blocks.LILY_OF_THE_VALLEY); - this.offerFlowerPileRecipe(PromenadeBlocks.WITHER_ROSE_PILE, Blocks.WITHER_ROSE); - - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_OAK_LEAVES, Blocks.OAK_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, Blocks.SPRUCE_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_BIRCH_LEAVES, Blocks.BIRCH_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, Blocks.JUNGLE_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_ACACIA_LEAVES, Blocks.ACACIA_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_CHERRY_LEAVES, Blocks.CHERRY_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, Blocks.DARK_OAK_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, Blocks.PALE_OAK_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, Blocks.MANGROVE_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_AZALEA_LEAVES, Blocks.AZALEA_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, Blocks.FLOWERING_AZALEA_LEAVES); - - this.offerPlanksRecipe(PromenadeBlocks.SAKURA_PLANKS, PromenadeItemTags.SAKURA_LOGS, 4); - this.offerBarkBlockRecipe(PromenadeBlocks.SAKURA_WOOD, PromenadeBlocks.SAKURA_LOG); - this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_SAKURA_WOOD, PromenadeBlocks.STRIPPED_SAKURA_LOG); - this.offerHangingSignRecipe(PromenadeItems.SAKURA_HANGING_SIGN, PromenadeBlocks.STRIPPED_SAKURA_LOG); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.COTTON_SAKURA_BLOSSOMS); - this.offerLeafPileRecipe(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE); - this.offerLeafPileRecipe(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE); - this.offerBoatRecipe(PromenadeItems.SAKURA_BOAT, PromenadeBlocks.SAKURA_PLANKS); - this.offerChestBoatRecipe(PromenadeItems.SAKURA_CHEST_BOAT, PromenadeItems.SAKURA_BOAT); - - this.offerPlanksRecipe(PromenadeBlocks.MAPLE_PLANKS, PromenadeItemTags.MAPLE_LOGS, 4); - this.offerBarkBlockRecipe(PromenadeBlocks.MAPLE_WOOD, PromenadeBlocks.MAPLE_LOG); - this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_MAPLE_WOOD, PromenadeBlocks.STRIPPED_MAPLE_LOG); - this.offerHangingSignRecipe(PromenadeItems.MAPLE_HANGING_SIGN, PromenadeBlocks.STRIPPED_MAPLE_LOG); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, PromenadeBlocks.VERMILION_MAPLE_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, PromenadeBlocks.FULVOUS_MAPLE_LEAVES); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, PromenadeBlocks.MIKADO_MAPLE_LEAVES); - this.offerFallenLeavesRecipe(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES); - this.offerFallenLeavesRecipe(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES); - this.offerFallenLeavesRecipe(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, PromenadeBlocks.FULVOUS_MAPLE_LEAVES); - this.offerFallenLeavesRecipe(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, PromenadeBlocks.MIKADO_MAPLE_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.SAP_MAPLE_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE); - this.offerLeafPileRecipe(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeBlocks.FULVOUS_MAPLE_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, PromenadeBlocks.MIKADO_MAPLE_LEAVES); - this.offerBoatRecipe(PromenadeItems.MAPLE_BOAT, PromenadeBlocks.MAPLE_PLANKS); - this.offerChestBoatRecipe(PromenadeItems.MAPLE_CHEST_BOAT, PromenadeItems.MAPLE_BOAT); - - this.offerPlanksRecipe(PromenadeBlocks.PALM_PLANKS, PromenadeItemTags.PALM_LOGS, 4); - this.offerBarkBlockRecipe(PromenadeBlocks.PALM_WOOD, PromenadeBlocks.PALM_LOG); - this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_PALM_WOOD, PromenadeBlocks.STRIPPED_PALM_LOG); - this.offerHangingSignRecipe(PromenadeItems.PALM_HANGING_SIGN, PromenadeBlocks.STRIPPED_PALM_LOG); - this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_LEAVES); - this.offerLeafPileRecipe(PromenadeBlocks.PALM_LEAF_PILE, PromenadeBlocks.PALM_LEAVES); - this.offerBoatRecipe(PromenadeItems.PALM_BOAT, PromenadeBlocks.PALM_PLANKS); - this.offerChestBoatRecipe(PromenadeItems.PALM_CHEST_BOAT, PromenadeItems.PALM_BOAT); - - this.offerPlanksRecipe(PromenadeBlocks.DARK_AMARANTH_PLANKS, PromenadeItemTags.DARK_AMARANTH_STEMS, 4); - this.offerBarkBlockRecipe(PromenadeBlocks.DARK_AMARANTH_HYPHAE, PromenadeBlocks.DARK_AMARANTH_STEM); - this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); - this.offerHangingSignRecipe(PromenadeItems.DARK_AMARANTH_HANGING_SIGN, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); - - this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.MOAI, Blocks.TUFF); - - this.generateCookingRecipes("smelting", RecipeSerializer.SMELTING, SmeltingRecipe::new, 200); - this.generateCookingRecipes("smoking", RecipeSerializer.SMOKING, SmokingRecipe::new, 100); - this.generateCookingRecipes("campfire_cooking", RecipeSerializer.CAMPFIRE_COOKING, CampfireCookingRecipe::new, 600); - - this.offerShapelessRecipe(Items.MAGENTA_DYE, PromenadeItems.BLUEBERRIES, "magenta_dye", 1); - - this.createShapeless(RecipeCategory.MISC, PromenadeItems.BOVINE_BANNER_PATTERN) - .input(Items.PAPER) - .input(Items.LEATHER) - .criterion("has_leather", this.conditionsFromItem(Items.LEATHER)) - .offerTo(this.exporter); - } - - public void offerSnowyLeavesRecipe(ItemConvertible output, ItemConvertible input) { - this.createShaped(RecipeCategory.DECORATIONS, output, 1) - .input('_', Blocks.SNOW) - .input('#', input) - .pattern("_") - .pattern("#") - .group("snowy_leaves") - .criterion(hasItem(input), this.conditionsFromItem(input)) - .offerTo(this.exporter); - - } - - public void offerFallenLeavesRecipe(ItemConvertible output, ItemConvertible input) { - this.createShaped(RecipeCategory.DECORATIONS, output, 2) - .input('#', input) - .pattern("##") - .group("fallen_leaves") - .criterion(hasItem(input), this.conditionsFromItem(input)) - .offerTo(this.exporter); - } - - - public void offerLeafPileRecipe(ItemConvertible output, ItemConvertible input) { - this.createShaped(RecipeCategory.DECORATIONS, output, 3) - .input('#', input) - .pattern("###") - .group("leaf_pile") - .criterion(hasItem(input), this.conditionsFromItem(input)) - .offerTo(this.exporter); - } - - public void offerFlowerPileRecipe(ItemConvertible output, ItemConvertible input) { - this.createShaped(RecipeCategory.DECORATIONS, output, 2) - .input('#', input) - .pattern("##") - .group("flower_pile") - .criterion(hasItem(input), this.conditionsFromItem(input)) - .offerTo(this.exporter); - } - - public void generateCookingRecipes( - String cooker, RecipeSerializer serializer, AbstractCookingRecipe.RecipeFactory recipeFactory, int cookingTime - ) { - this.offerFoodCookingRecipe(cooker, serializer, recipeFactory, cookingTime, PromenadeItems.DUCK, PromenadeItems.COOKED_DUCK, 0.35F); - } - - public static FabricRecipeProvider create(FabricDataOutput fabricDataOutput, CompletableFuture completableFuture) { - return new FabricRecipeProvider(fabricDataOutput, completableFuture) { - @Override - protected RecipeGenerator getRecipeGenerator(RegistryWrapper.WrapperLookup wrapperLookup, RecipeExporter recipeExporter) { - return new PromenadeRecipeGenerator(wrapperLookup, recipeExporter); - } - - @Override - public String getName() { - return "Recipes"; - } - }; - } + public PromenadeRecipeGenerator(RegistryWrapper.WrapperLookup registries, RecipeExporter exporter) { + super(registries, exporter); + } + + @Override + public void generate() { + PromenadeBlockFamilies.getFamilies().filter(BlockFamily::shouldGenerateRecipes).forEach(family -> this.generateFamily(family, FeatureSet.of(FeatureFlags.VANILLA))); + + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.ASPHALT_SLAB, PromenadeBlocks.ASPHALT, 2); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.ASPHALT_STAIRS, PromenadeBlocks.ASPHALT); + this.offerStonecuttingRecipe(RecipeCategory.DECORATIONS, PromenadeBlocks.ASPHALT_WALL, PromenadeBlocks.ASPHALT); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT, PromenadeBlocks.ASPHALT); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.ASPHALT, 2); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_STAIRS, PromenadeBlocks.ASPHALT); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.POLISHED_ASPHALT, 2); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_ASPHALT_STAIRS, PromenadeBlocks.POLISHED_ASPHALT); + + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.BLUNITE_SLAB, PromenadeBlocks.BLUNITE, 2); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.BLUNITE_STAIRS, PromenadeBlocks.BLUNITE); + this.offerStonecuttingRecipe(RecipeCategory.DECORATIONS, PromenadeBlocks.BLUNITE_WALL, PromenadeBlocks.BLUNITE); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE, PromenadeBlocks.BLUNITE); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.BLUNITE, 2); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, PromenadeBlocks.BLUNITE); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.POLISHED_BLUNITE, 2); + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, PromenadeBlocks.POLISHED_BLUNITE); + + this.offerLeafPileRecipe(PromenadeBlocks.OAK_LEAF_PILE, Blocks.OAK_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.SPRUCE_LEAF_PILE, Blocks.SPRUCE_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.BIRCH_LEAF_PILE, Blocks.BIRCH_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.JUNGLE_LEAF_PILE, Blocks.JUNGLE_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.ACACIA_LEAF_PILE, Blocks.ACACIA_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.CHERRY_LEAF_PILE, Blocks.CHERRY_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.DARK_OAK_LEAF_PILE, Blocks.DARK_OAK_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.PALE_OAK_LEAF_PILE, Blocks.PALE_OAK_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.MANGROVE_LEAF_PILE, Blocks.MANGROVE_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.AZALEA_LEAF_PILE, Blocks.AZALEA_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, Blocks.FLOWERING_AZALEA_LEAVES); + + this.offerFlowerPileRecipe(PromenadeBlocks.DANDELION_PILE, Blocks.DANDELION); + this.offerFlowerPileRecipe(PromenadeBlocks.POPPY_PILE, Blocks.POPPY); + this.offerFlowerPileRecipe(PromenadeBlocks.BLUE_ORCHID_PILE, Blocks.BLUE_ORCHID); + this.offerFlowerPileRecipe(PromenadeBlocks.ALLIUM_PILE, Blocks.ALLIUM); + this.offerFlowerPileRecipe(PromenadeBlocks.AZURE_BLUET_PILE, Blocks.AZURE_BLUET); + this.offerFlowerPileRecipe(PromenadeBlocks.RED_TULIP_PILE, Blocks.RED_TULIP); + this.offerFlowerPileRecipe(PromenadeBlocks.ORANGE_TULIP_PILE, Blocks.ORANGE_TULIP); + this.offerFlowerPileRecipe(PromenadeBlocks.WHITE_TULIP_PILE, Blocks.WHITE_TULIP); + this.offerFlowerPileRecipe(PromenadeBlocks.PINK_TULIP_PILE, Blocks.PINK_TULIP); + this.offerFlowerPileRecipe(PromenadeBlocks.OXEYE_DAISY_PILE, Blocks.OXEYE_DAISY); + this.offerFlowerPileRecipe(PromenadeBlocks.CORNFLOWER_PILE, Blocks.CORNFLOWER); + this.offerFlowerPileRecipe(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, Blocks.LILY_OF_THE_VALLEY); + this.offerFlowerPileRecipe(PromenadeBlocks.WITHER_ROSE_PILE, Blocks.WITHER_ROSE); + + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_OAK_LEAVES, Blocks.OAK_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, Blocks.SPRUCE_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_BIRCH_LEAVES, Blocks.BIRCH_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, Blocks.JUNGLE_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_ACACIA_LEAVES, Blocks.ACACIA_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_CHERRY_LEAVES, Blocks.CHERRY_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, Blocks.DARK_OAK_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, Blocks.PALE_OAK_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, Blocks.MANGROVE_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_AZALEA_LEAVES, Blocks.AZALEA_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, Blocks.FLOWERING_AZALEA_LEAVES); + + this.offerPlanksRecipe(PromenadeBlocks.SAKURA_PLANKS, PromenadeItemTags.SAKURA_LOGS, 4); + this.offerBarkBlockRecipe(PromenadeBlocks.SAKURA_WOOD, PromenadeBlocks.SAKURA_LOG); + this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_SAKURA_WOOD, PromenadeBlocks.STRIPPED_SAKURA_LOG); + this.offerHangingSignRecipe(PromenadeItems.SAKURA_HANGING_SIGN, PromenadeBlocks.STRIPPED_SAKURA_LOG); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.COTTON_SAKURA_BLOSSOMS); + this.offerLeafPileRecipe(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE); + this.offerLeafPileRecipe(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE); + this.offerBoatRecipe(PromenadeItems.SAKURA_BOAT, PromenadeBlocks.SAKURA_PLANKS); + this.offerChestBoatRecipe(PromenadeItems.SAKURA_CHEST_BOAT, PromenadeItems.SAKURA_BOAT); + + this.offerPlanksRecipe(PromenadeBlocks.MAPLE_PLANKS, PromenadeItemTags.MAPLE_LOGS, 4); + this.offerBarkBlockRecipe(PromenadeBlocks.MAPLE_WOOD, PromenadeBlocks.MAPLE_LOG); + this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_MAPLE_WOOD, PromenadeBlocks.STRIPPED_MAPLE_LOG); + this.offerHangingSignRecipe(PromenadeItems.MAPLE_HANGING_SIGN, PromenadeBlocks.STRIPPED_MAPLE_LOG); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, PromenadeBlocks.VERMILION_MAPLE_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, PromenadeBlocks.FULVOUS_MAPLE_LEAVES); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, PromenadeBlocks.MIKADO_MAPLE_LEAVES); + this.offerFallenLeavesRecipe(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES); + this.offerFallenLeavesRecipe(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, PromenadeBlocks.SAP_MAPLE_LEAVES); + this.offerFallenLeavesRecipe(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, PromenadeBlocks.FULVOUS_MAPLE_LEAVES); + this.offerFallenLeavesRecipe(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, PromenadeBlocks.MIKADO_MAPLE_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.SAP_MAPLE_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE); + this.offerLeafPileRecipe(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeBlocks.FULVOUS_MAPLE_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, PromenadeBlocks.MIKADO_MAPLE_LEAVES); + this.offerBoatRecipe(PromenadeItems.MAPLE_BOAT, PromenadeBlocks.MAPLE_PLANKS); + this.offerChestBoatRecipe(PromenadeItems.MAPLE_CHEST_BOAT, PromenadeItems.MAPLE_BOAT); + + this.offerPlanksRecipe(PromenadeBlocks.PALM_PLANKS, PromenadeItemTags.PALM_LOGS, 4); + this.offerBarkBlockRecipe(PromenadeBlocks.PALM_WOOD, PromenadeBlocks.PALM_LOG); + this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_PALM_WOOD, PromenadeBlocks.STRIPPED_PALM_LOG); + this.offerHangingSignRecipe(PromenadeItems.PALM_HANGING_SIGN, PromenadeBlocks.STRIPPED_PALM_LOG); + this.offerSnowyLeavesRecipe(PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_LEAVES); + this.offerLeafPileRecipe(PromenadeBlocks.PALM_LEAF_PILE, PromenadeBlocks.PALM_LEAVES); + this.offerBoatRecipe(PromenadeItems.PALM_BOAT, PromenadeBlocks.PALM_PLANKS); + this.offerChestBoatRecipe(PromenadeItems.PALM_CHEST_BOAT, PromenadeItems.PALM_BOAT); + + this.offerPlanksRecipe(PromenadeBlocks.DARK_AMARANTH_PLANKS, PromenadeItemTags.DARK_AMARANTH_STEMS, 4); + this.offerBarkBlockRecipe(PromenadeBlocks.DARK_AMARANTH_HYPHAE, PromenadeBlocks.DARK_AMARANTH_STEM); + this.offerBarkBlockRecipe(PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); + this.offerHangingSignRecipe(PromenadeItems.DARK_AMARANTH_HANGING_SIGN, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); + + this.offerStonecuttingRecipe(RecipeCategory.BUILDING_BLOCKS, PromenadeBlocks.MOAI, Blocks.TUFF); + + this.generateCookingRecipes("smelting", RecipeSerializer.SMELTING, SmeltingRecipe::new, 200); + this.generateCookingRecipes("smoking", RecipeSerializer.SMOKING, SmokingRecipe::new, 100); + this.generateCookingRecipes("campfire_cooking", RecipeSerializer.CAMPFIRE_COOKING, CampfireCookingRecipe::new, 600); + + this.offerShapelessRecipe(Items.MAGENTA_DYE, PromenadeItems.BLUEBERRIES, "magenta_dye", 1); + + this.createShapeless(RecipeCategory.MISC, PromenadeItems.BOVINE_BANNER_PATTERN) + .input(Items.PAPER) + .input(Items.LEATHER) + .criterion("has_leather", this.conditionsFromItem(Items.LEATHER)) + .offerTo(this.exporter); + } + + public void offerSnowyLeavesRecipe(ItemConvertible output, ItemConvertible input) { + this.createShaped(RecipeCategory.DECORATIONS, output, 1) + .input('_', Blocks.SNOW) + .input('#', input) + .pattern("_") + .pattern("#") + .group("snowy_leaves") + .criterion(hasItem(input), this.conditionsFromItem(input)) + .offerTo(this.exporter); + + } + + public void offerFallenLeavesRecipe(ItemConvertible output, ItemConvertible input) { + this.createShaped(RecipeCategory.DECORATIONS, output, 2) + .input('#', input) + .pattern("##") + .group("fallen_leaves") + .criterion(hasItem(input), this.conditionsFromItem(input)) + .offerTo(this.exporter); + } + + + public void offerLeafPileRecipe(ItemConvertible output, ItemConvertible input) { + this.createShaped(RecipeCategory.DECORATIONS, output, 3) + .input('#', input) + .pattern("###") + .group("leaf_pile") + .criterion(hasItem(input), this.conditionsFromItem(input)) + .offerTo(this.exporter); + } + + public void offerFlowerPileRecipe(ItemConvertible output, ItemConvertible input) { + this.createShaped(RecipeCategory.DECORATIONS, output, 2) + .input('#', input) + .pattern("##") + .group("flower_pile") + .criterion(hasItem(input), this.conditionsFromItem(input)) + .offerTo(this.exporter); + } + + public void generateCookingRecipes( + String cooker, RecipeSerializer serializer, AbstractCookingRecipe.RecipeFactory recipeFactory, int cookingTime + ) { + this.offerFoodCookingRecipe(cooker, serializer, recipeFactory, cookingTime, PromenadeItems.DUCK, PromenadeItems.COOKED_DUCK, 0.35F); + } + + public static FabricRecipeProvider create(FabricDataOutput fabricDataOutput, CompletableFuture completableFuture) { + return new FabricRecipeProvider(fabricDataOutput, completableFuture) { + @Override + protected RecipeGenerator getRecipeGenerator(RegistryWrapper.WrapperLookup wrapperLookup, RecipeExporter recipeExporter) { + return new PromenadeRecipeGenerator(wrapperLookup, recipeExporter); + } + + @Override + public String getName() { + return "Recipes"; + } + }; + } } diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSnowyBlockTransformationProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSnowyBlockTransformationProvider.java index 64506d6c..6bf40b84 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSnowyBlockTransformationProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSnowyBlockTransformationProvider.java @@ -1,11 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.block.snowy.SnowyBlockTransformation; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.registry.Registerable; @@ -13,47 +20,53 @@ import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryWrapper; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.block.snowy.SnowyBlockTransformation; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; //TODO: a generic class for other devs public class PromenadeSnowyBlockTransformationProvider extends FabricDynamicRegistryProvider { - public PromenadeSnowyBlockTransformationProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION)); - } - - @Override - public String getName() { - return "Snowy Block Transformations"; - } - - public static void register(Registerable registerable) { - of(registerable, Blocks.OAK_LEAVES, PromenadeBlocks.SNOWY_OAK_LEAVES); - of(registerable, Blocks.SPRUCE_LEAVES, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); - of(registerable, Blocks.BIRCH_LEAVES, PromenadeBlocks.SNOWY_BIRCH_LEAVES); - of(registerable, Blocks.JUNGLE_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES); - of(registerable, Blocks.ACACIA_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES); - of(registerable, Blocks.CHERRY_LEAVES, PromenadeBlocks.SNOWY_CHERRY_LEAVES); - of(registerable, Blocks.DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES); - of(registerable, Blocks.PALE_OAK_LEAVES, PromenadeBlocks.SNOWY_PALE_OAK_LEAVES); - of(registerable, Blocks.MANGROVE_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES); - of(registerable, Blocks.AZALEA_LEAVES, PromenadeBlocks.SNOWY_AZALEA_LEAVES); - of(registerable, Blocks.FLOWERING_AZALEA_LEAVES, PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES); - of(registerable, PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS); - of(registerable, PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS); - of(registerable, PromenadeBlocks.SAP_MAPLE_LEAVES, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES); - of(registerable, PromenadeBlocks.VERMILION_MAPLE_LEAVES, PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES); - of(registerable, PromenadeBlocks.FULVOUS_MAPLE_LEAVES, PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES); - of(registerable, PromenadeBlocks.MIKADO_MAPLE_LEAVES, PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES); - of(registerable, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES); - } - - private static void of(Registerable registry, Block baseBlock, Block snowyBlock) { - var id = RegistryKey.of(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, Promenade.id(Registries.BLOCK.getId(snowyBlock).getPath())); - registry.register(id, new SnowyBlockTransformation(baseBlock.getRegistryEntry(), snowyBlock.getRegistryEntry())); - } + public PromenadeSnowyBlockTransformationProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION)); + } + + @Override + public String getName() { + return "Snowy Block Transformations"; + } + + public static void register(Registerable registerable) { + of(registerable, Blocks.OAK_LEAVES, PromenadeBlocks.SNOWY_OAK_LEAVES); + of(registerable, Blocks.SPRUCE_LEAVES, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); + of(registerable, Blocks.BIRCH_LEAVES, PromenadeBlocks.SNOWY_BIRCH_LEAVES); + of(registerable, Blocks.JUNGLE_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES); + of(registerable, Blocks.ACACIA_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES); + of(registerable, Blocks.CHERRY_LEAVES, PromenadeBlocks.SNOWY_CHERRY_LEAVES); + of(registerable, Blocks.DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES); + of(registerable, Blocks.PALE_OAK_LEAVES, PromenadeBlocks.SNOWY_PALE_OAK_LEAVES); + of(registerable, Blocks.MANGROVE_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES); + of(registerable, Blocks.AZALEA_LEAVES, PromenadeBlocks.SNOWY_AZALEA_LEAVES); + of(registerable, Blocks.FLOWERING_AZALEA_LEAVES, PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES); + of(registerable, PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS); + of(registerable, PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS); + of(registerable, PromenadeBlocks.SAP_MAPLE_LEAVES, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES); + of(registerable, PromenadeBlocks.VERMILION_MAPLE_LEAVES, PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES); + of(registerable, PromenadeBlocks.FULVOUS_MAPLE_LEAVES, PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES); + of(registerable, PromenadeBlocks.MIKADO_MAPLE_LEAVES, PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES); + of(registerable, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES); + } + + private static void of(Registerable registry, Block baseBlock, Block snowyBlock) { + var id = RegistryKey.of(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, Promenade.id(Registries.BLOCK.getId(snowyBlock).getPath())); + registry.register(id, new SnowyBlockTransformation(baseBlock.getRegistryEntry(), snowyBlock.getRegistryEntry())); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSoundsProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSoundsProvider.java index d27a7228..0c1fe166 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSoundsProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSoundsProvider.java @@ -1,100 +1,113 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.sound.PromenadeSoundEvents; -import net.fabricmc.fabric.api.client.datagen.v1.builder.SoundTypeBuilder; -import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricSoundsProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.data.DataOutput; import net.minecraft.registry.RegistryWrapper; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.client.datagen.v1.builder.SoundTypeBuilder; +import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricSoundsProvider; + +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.sound.PromenadeSoundEvents; public class PromenadeSoundsProvider extends FabricSoundsProvider { - public PromenadeSoundsProvider(DataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - public String getName() { - return "Sounds"; - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup wrapperLookup, SoundExporter soundExporter) { - // Blocks - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_BREAK, variantSoundBuilder(4, Promenade.id("block/snowy_leaves/break")).subtitle("subtitles.block.generic.break")); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_PLACE, variantSoundBuilder(4, Promenade.id("block/snowy_leaves/break")).subtitle("subtitles.block.generic.place")); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_FALL, variantSoundBuilder(6, Promenade.id("block/snowy_leaves/step"))); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_HIT, variantSoundBuilder(6, Promenade.id("block/snowy_leaves/step")).subtitle("subtitles.block.generic.hit")); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_STEP, variantSoundBuilder(6, Promenade.id("block/snowy_leaves/step")).subtitle("subtitles.block.generic.footsteps")); - - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_BREAK, variantSoundBuilder(7, Promenade.id("block/snowy_azalea_leaves/break")).subtitle("subtitles.block.generic.break")); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_PLACE, variantSoundBuilder(7, Promenade.id("block/snowy_azalea_leaves/break")).subtitle("subtitles.block.generic.place")); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_FALL, variantSoundBuilder(5, Promenade.id("block/snowy_azalea_leaves/step"))); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_HIT, variantSoundBuilder(5, Promenade.id("block/snowy_azalea_leaves/step")).subtitle("subtitles.block.generic.hit")); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_STEP, variantSoundBuilder(5, Promenade.id("block/snowy_azalea_leaves/step")).subtitle("subtitles.block.generic.footsteps")); - - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_BREAK, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/break")).subtitle("subtitles.block.generic.break")); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_PLACE, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/break")).subtitle("subtitles.block.generic.place")); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_FALL, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/step"))); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_HIT, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/step")).subtitle("subtitles.block.generic.hit")); - soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_STEP, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/step")).subtitle("subtitles.block.generic.footsteps")); - - // Entities - soundExporter.add(PromenadeSoundEvents.DUCK_AMBIENT, variantSoundBuilder(PromenadeSoundEvents.DUCK_AMBIENT, 4)); - soundExporter.add(PromenadeSoundEvents.DUCK_HURT, variantSoundBuilder(PromenadeSoundEvents.DUCK_HURT, 3)); - soundExporter.add(PromenadeSoundEvents.DUCK_DEATH, variantSoundBuilder(PromenadeSoundEvents.DUCK_DEATH, 1)); - soundExporter.add(PromenadeSoundEvents.DUCK_STEP, SoundTypeBuilder.of().subtitle("subtitles.block.generic.footsteps") - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("mob/chicken/step1"))) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("mob/chicken/step2"))) - ); - - soundExporter.add(PromenadeSoundEvents.CAPYBARA_AMBIENT, variantSoundBuilder(PromenadeSoundEvents.CAPYBARA_AMBIENT, 5)); - soundExporter.add(PromenadeSoundEvents.CAPYBARA_AMBIENT_BABY, variantSoundBuilder(PromenadeSoundEvents.CAPYBARA_AMBIENT_BABY, 6).subtitle("subtitles.promenade.entity.capybara.ambient")); - soundExporter.add(PromenadeSoundEvents.CAPYBARA_FART, variantSoundBuilder(PromenadeSoundEvents.CAPYBARA_FART, 6)); - - soundExporter.add(PromenadeSoundEvents.SUNKEN_AMBIENT, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_AMBIENT, 3)); - soundExporter.add(PromenadeSoundEvents.SUNKEN_HURT, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_HURT, 4)); - soundExporter.add(PromenadeSoundEvents.SUNKEN_DEATH, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_DEATH, 3)); - soundExporter.add(PromenadeSoundEvents.SUNKEN_SHOOT, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_SHOOT, 3)); - soundExporter.add(PromenadeSoundEvents.SUNKEN_STEP, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_STEP, 4).subtitle("subtitles.block.generic.footsteps")); - - // Music - soundExporter.add(PromenadeSoundEvents.MUSIC_OVERWORLD_SAKURA_GROVES, SoundTypeBuilder.of() - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Promenade.id("music/brise_couleur_pastel")).stream(true).volume(0.4f).weight(6)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/minecraft")).stream(true)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/sweden")).stream(true)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/clark")).stream(true)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/left_to_bloom")).stream(true).volume(0.4f)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/featherfall")).stream(true).volume(0.4f).weight(3)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/echo_in_the_wind")).stream(true).volume(0.4f).weight(3)) - .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/bromeliad")).stream(true).volume(0.4f).weight(3)) - ); - } - - private SoundTypeBuilder variantSoundBuilder(SoundEvent soundEvent, int count) { - return variantSoundBuilder(SoundTypeBuilder.of(soundEvent), count, soundEvent.id().withPath(s -> s.replace(".", "/"))); - } - - private SoundTypeBuilder variantSoundBuilder(SoundEvent soundEvent, int count, Identifier baseId) { - return variantSoundBuilder(SoundTypeBuilder.of(soundEvent), count, baseId.withPath(s -> s.replace(".", "/"))); - } - - private SoundTypeBuilder variantSoundBuilder(int count, Identifier baseId) { - return variantSoundBuilder(SoundTypeBuilder.of(), count, baseId.withPath(s -> s.replace(".", "/"))); - } - - private SoundTypeBuilder variantSoundBuilder(SoundTypeBuilder builder, int count, Identifier baseId) { - if (count > 1) { - for (int i = 1; i <= count; i++) { - Identifier soundId = baseId.withSuffixedPath("/" + i); - builder.sound(SoundTypeBuilder.EntryBuilder.ofFile(soundId)); - } - } else { - builder.sound(SoundTypeBuilder.EntryBuilder.ofFile(baseId)); - } - return builder; - } + public PromenadeSoundsProvider(DataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + public String getName() { + return "Sounds"; + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup wrapperLookup, SoundExporter soundExporter) { + // Blocks + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_BREAK, variantSoundBuilder(4, Promenade.id("block/snowy_leaves/break")).subtitle("subtitles.block.generic.break")); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_PLACE, variantSoundBuilder(4, Promenade.id("block/snowy_leaves/break")).subtitle("subtitles.block.generic.place")); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_FALL, variantSoundBuilder(6, Promenade.id("block/snowy_leaves/step"))); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_HIT, variantSoundBuilder(6, Promenade.id("block/snowy_leaves/step")).subtitle("subtitles.block.generic.hit")); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_STEP, variantSoundBuilder(6, Promenade.id("block/snowy_leaves/step")).subtitle("subtitles.block.generic.footsteps")); + + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_BREAK, variantSoundBuilder(7, Promenade.id("block/snowy_azalea_leaves/break")).subtitle("subtitles.block.generic.break")); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_PLACE, variantSoundBuilder(7, Promenade.id("block/snowy_azalea_leaves/break")).subtitle("subtitles.block.generic.place")); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_FALL, variantSoundBuilder(5, Promenade.id("block/snowy_azalea_leaves/step"))); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_HIT, variantSoundBuilder(5, Promenade.id("block/snowy_azalea_leaves/step")).subtitle("subtitles.block.generic.hit")); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_STEP, variantSoundBuilder(5, Promenade.id("block/snowy_azalea_leaves/step")).subtitle("subtitles.block.generic.footsteps")); + + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_BREAK, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/break")).subtitle("subtitles.block.generic.break")); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_PLACE, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/break")).subtitle("subtitles.block.generic.place")); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_FALL, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/step"))); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_HIT, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/step")).subtitle("subtitles.block.generic.hit")); + soundExporter.add(PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_STEP, variantSoundBuilder(5, Promenade.id("block/snowy_cherry_leaves/step")).subtitle("subtitles.block.generic.footsteps")); + + // Entities + soundExporter.add(PromenadeSoundEvents.DUCK_AMBIENT, variantSoundBuilder(PromenadeSoundEvents.DUCK_AMBIENT, 4)); + soundExporter.add(PromenadeSoundEvents.DUCK_HURT, variantSoundBuilder(PromenadeSoundEvents.DUCK_HURT, 3)); + soundExporter.add(PromenadeSoundEvents.DUCK_DEATH, variantSoundBuilder(PromenadeSoundEvents.DUCK_DEATH, 1)); + soundExporter.add(PromenadeSoundEvents.DUCK_STEP, SoundTypeBuilder.of().subtitle("subtitles.block.generic.footsteps") + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("mob/chicken/step1"))) + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("mob/chicken/step2"))) + ); + + soundExporter.add(PromenadeSoundEvents.CAPYBARA_AMBIENT, variantSoundBuilder(PromenadeSoundEvents.CAPYBARA_AMBIENT, 5)); + soundExporter.add(PromenadeSoundEvents.CAPYBARA_AMBIENT_BABY, variantSoundBuilder(PromenadeSoundEvents.CAPYBARA_AMBIENT_BABY, 6).subtitle("subtitles.promenade.entity.capybara.ambient")); + soundExporter.add(PromenadeSoundEvents.CAPYBARA_FART, variantSoundBuilder(PromenadeSoundEvents.CAPYBARA_FART, 6)); + + soundExporter.add(PromenadeSoundEvents.SUNKEN_AMBIENT, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_AMBIENT, 3)); + soundExporter.add(PromenadeSoundEvents.SUNKEN_HURT, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_HURT, 4)); + soundExporter.add(PromenadeSoundEvents.SUNKEN_DEATH, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_DEATH, 3)); + soundExporter.add(PromenadeSoundEvents.SUNKEN_SHOOT, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_SHOOT, 3)); + soundExporter.add(PromenadeSoundEvents.SUNKEN_STEP, variantSoundBuilder(PromenadeSoundEvents.SUNKEN_STEP, 4).subtitle("subtitles.block.generic.footsteps")); + + // Music + soundExporter.add(PromenadeSoundEvents.MUSIC_OVERWORLD_SAKURA_GROVES, SoundTypeBuilder.of() + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Promenade.id("music/brise_couleur_pastel")).stream(true).volume(0.4f).weight(6)) + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/minecraft")).stream(true)) + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/sweden")).stream(true)) + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/clark")).stream(true)) + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/left_to_bloom")).stream(true).volume(0.4f)) + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/featherfall")).stream(true).volume(0.4f).weight(3)) + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/echo_in_the_wind")).stream(true).volume(0.4f).weight(3)) + .sound(SoundTypeBuilder.EntryBuilder.ofFile(Identifier.of("minecraft:music/game/bromeliad")).stream(true).volume(0.4f).weight(3)) + ); + } + + private SoundTypeBuilder variantSoundBuilder(SoundEvent soundEvent, int count) { + return variantSoundBuilder(SoundTypeBuilder.of(soundEvent), count, soundEvent.id().withPath(s -> s.replace(".", "/"))); + } + + private SoundTypeBuilder variantSoundBuilder(SoundEvent soundEvent, int count, Identifier baseId) { + return variantSoundBuilder(SoundTypeBuilder.of(soundEvent), count, baseId.withPath(s -> s.replace(".", "/"))); + } + + private SoundTypeBuilder variantSoundBuilder(int count, Identifier baseId) { + return variantSoundBuilder(SoundTypeBuilder.of(), count, baseId.withPath(s -> s.replace(".", "/"))); + } + + private SoundTypeBuilder variantSoundBuilder(SoundTypeBuilder builder, int count, Identifier baseId) { + if (count > 1) { + for (int i = 1; i <= count; i++) { + Identifier soundId = baseId.withSuffixedPath("/" + i); + builder.sound(SoundTypeBuilder.EntryBuilder.ofFile(soundId)); + } + } else { + builder.sound(SoundTypeBuilder.EntryBuilder.ofFile(baseId)); + } + return builder; + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureProvider.java index b2c203d8..dd793a99 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureProvider.java @@ -1,10 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.tag.PromenadeBiomeTags; -import fr.hugman.promenade.world.gen.structure.PromenadeStructureKeys; -import fr.hugman.promenade.world.gen.structure.PromenadeStructurePoolsKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; @@ -16,40 +24,45 @@ import net.minecraft.world.gen.structure.JigsawStructure; import net.minecraft.world.gen.structure.Structure; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.tag.PromenadeBiomeTags; +import fr.hugman.promenade.world.gen.structure.PromenadeStructureKeys; +import fr.hugman.promenade.world.gen.structure.PromenadeStructurePoolsKeys; public class PromenadeStructureProvider extends FabricDynamicRegistryProvider { - public PromenadeStructureProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.STRUCTURE)); - } - - @Override - public String getName() { - return "Structures"; - } - - public static void register(Registerable registerable) { - var biomes = registerable.getRegistryLookup(RegistryKeys.BIOME); - var templatePools = registerable.getRegistryLookup(RegistryKeys.TEMPLATE_POOL); - - registerable.register( - PromenadeStructureKeys.DARK_FOREST_WITCH_HUT, - new JigsawStructure( - new Structure.Config.Builder(biomes.getOrThrow(PromenadeBiomeTags.HAS_DARK_FOREST_WITCH_HUT)) - .step(GenerationStep.Feature.SURFACE_STRUCTURES) - .terrainAdaptation(StructureTerrainAdaptation.BEARD_THIN) - .build(), - templatePools.getOrThrow(PromenadeStructurePoolsKeys.DARK_FOREST_WITCH_HUTS), - 1, - ConstantHeightProvider.create(YOffset.fixed(0)), - false, - Heightmap.Type.WORLD_SURFACE_WG - ) - ); - } + public PromenadeStructureProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(RegistryKeys.STRUCTURE)); + } + + @Override + public String getName() { + return "Structures"; + } + + public static void register(Registerable registerable) { + var biomes = registerable.getRegistryLookup(RegistryKeys.BIOME); + var templatePools = registerable.getRegistryLookup(RegistryKeys.TEMPLATE_POOL); + + registerable.register( + PromenadeStructureKeys.DARK_FOREST_WITCH_HUT, + new JigsawStructure( + new Structure.Config.Builder(biomes.getOrThrow(PromenadeBiomeTags.HAS_DARK_FOREST_WITCH_HUT)) + .step(GenerationStep.Feature.SURFACE_STRUCTURES) + .terrainAdaptation(StructureTerrainAdaptation.BEARD_THIN) + .build(), + templatePools.getOrThrow(PromenadeStructurePoolsKeys.DARK_FOREST_WITCH_HUTS), + 1, + ConstantHeightProvider.create(YOffset.fixed(0)), + false, + Heightmap.Type.WORLD_SURFACE_WG + ) + ); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureSetProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureSetProvider.java index d352d04f..7e2a581d 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureSetProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeStructureSetProvider.java @@ -1,9 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.world.gen.structure.PromenadeStructureKeys; -import fr.hugman.promenade.world.gen.structure.PromenadeStructureSetKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; @@ -11,32 +20,36 @@ import net.minecraft.world.gen.chunk.placement.RandomSpreadStructurePlacement; import net.minecraft.world.gen.chunk.placement.SpreadType; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.world.gen.structure.PromenadeStructureKeys; +import fr.hugman.promenade.world.gen.structure.PromenadeStructureSetKeys; public class PromenadeStructureSetProvider extends FabricDynamicRegistryProvider { - public PromenadeStructureSetProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.STRUCTURE_SET)); - } - - @Override - public String getName() { - return "Structure Sets"; - } - - public static void register(Registerable registerable) { - var structures = registerable.getRegistryLookup(RegistryKeys.STRUCTURE); - - registerable.register( - PromenadeStructureSetKeys.WITCH_HUTS, - new StructureSet( - structures.getOrThrow(PromenadeStructureKeys.DARK_FOREST_WITCH_HUT), - new RandomSpreadStructurePlacement(32, 8, SpreadType.LINEAR, 14357620) - ) - ); - } + public PromenadeStructureSetProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(RegistryKeys.STRUCTURE_SET)); + } + + @Override + public String getName() { + return "Structure Sets"; + } + + public static void register(Registerable registerable) { + var structures = registerable.getRegistryLookup(RegistryKeys.STRUCTURE); + + registerable.register( + PromenadeStructureSetKeys.WITCH_HUTS, + new StructureSet( + structures.getOrThrow(PromenadeStructureKeys.DARK_FOREST_WITCH_HUT), + new RandomSpreadStructurePlacement(32, 8, SpreadType.LINEAR, 14357620) + ) + ); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSunkenVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSunkenVariantProvider.java index 364daaf0..9b698efd 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSunkenVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeSunkenVariantProvider.java @@ -1,11 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.entity.variant.SunkenVariant; -import fr.hugman.promenade.entity.variant.SunkenVariants; -import fr.hugman.promenade.loot.PromenadeLootTables; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.entity.spawn.SpawnConditionSelectors; import net.minecraft.loot.LootTable; import net.minecraft.registry.Registerable; @@ -13,33 +20,39 @@ import net.minecraft.registry.RegistryWrapper; import net.minecraft.util.AssetInfo.TextureAssetInfo; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.entity.variant.SunkenVariant; +import fr.hugman.promenade.entity.variant.SunkenVariants; +import fr.hugman.promenade.loot.PromenadeLootTables; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; //TODO: a generic class for other devs public class PromenadeSunkenVariantProvider extends FabricDynamicRegistryProvider { - public PromenadeSunkenVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT)); - } - - @Override - public String getName() { - return "Sunken Variants"; - } - - public static void register(Registerable registry) { - of(registry, SunkenVariants.TUBE, PromenadeLootTables.TUBE_SUNKEN); - of(registry, SunkenVariants.BRAIN, PromenadeLootTables.BRAIN_SUNKEN); - of(registry, SunkenVariants.BUBBLE, PromenadeLootTables.BUBBLE_SUNKEN); - of(registry, SunkenVariants.FIRE, PromenadeLootTables.FIRE_SUNKEN); - of(registry, SunkenVariants.HORN, PromenadeLootTables.HORN_SUNKEN); - } - - private static void of(Registerable registry, RegistryKey key, RegistryKey lootTable) { - registry.register(key, new SunkenVariant(new TextureAssetInfo(key.getValue().withPrefixedPath("entity/sunken/")), lootTable, SpawnConditionSelectors.createFallback(0))); - } + public PromenadeSunkenVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT)); + } + + @Override + public String getName() { + return "Sunken Variants"; + } + + public static void register(Registerable registry) { + of(registry, SunkenVariants.TUBE, PromenadeLootTables.TUBE_SUNKEN); + of(registry, SunkenVariants.BRAIN, PromenadeLootTables.BRAIN_SUNKEN); + of(registry, SunkenVariants.BUBBLE, PromenadeLootTables.BUBBLE_SUNKEN); + of(registry, SunkenVariants.FIRE, PromenadeLootTables.FIRE_SUNKEN); + of(registry, SunkenVariants.HORN, PromenadeLootTables.HORN_SUNKEN); + } + + private static void of(Registerable registry, RegistryKey key, RegistryKey lootTable) { + registry.register(key, new SunkenVariant(new TextureAssetInfo(key.getValue().withPrefixedPath("entity/sunken/")), lootTable, SpawnConditionSelectors.createFallback(0))); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeTemplatePoolProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeTemplatePoolProvider.java index 61c11345..aef4fe4b 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeTemplatePoolProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeTemplatePoolProvider.java @@ -1,11 +1,21 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; +import java.util.concurrent.CompletableFuture; + import com.google.common.collect.ImmutableList; import com.mojang.datafixers.util.Pair; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.world.gen.structure.PromenadeStructurePoolsKeys; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; @@ -13,41 +23,45 @@ import net.minecraft.structure.pool.StructurePoolElement; import net.minecraft.structure.pool.StructurePools; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.world.gen.structure.PromenadeStructurePoolsKeys; public class PromenadeTemplatePoolProvider extends FabricDynamicRegistryProvider { - public PromenadeTemplatePoolProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getOrThrow(RegistryKeys.TEMPLATE_POOL)); - } - - @Override - public String getName() { - return "Template Pools"; - } - - public static void register(Registerable registerable) { - var pools = registerable.getRegistryLookup(RegistryKeys.TEMPLATE_POOL); - var empty = pools.getOrThrow(StructurePools.EMPTY); - - registerable.register(PromenadeStructurePoolsKeys.DARK_FOREST_WITCH_HUTS, new StructurePool(empty, - ImmutableList.of( - Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut").toString()), 1) - ), - StructurePool.Projection.RIGID - )); - - registerable.register(PromenadeStructurePoolsKeys.WITCH_HUT_INTERIORS, new StructurePool(empty, - ImmutableList.of( - Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut/interior/normal").toString()), 5), - Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut/interior/hatred").toString()), 1), - Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut/interior/afraid").toString()), 1) - ), - StructurePool.Projection.RIGID - )); - } + public PromenadeTemplatePoolProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + entries.addAll(registries.getOrThrow(RegistryKeys.TEMPLATE_POOL)); + } + + @Override + public String getName() { + return "Template Pools"; + } + + public static void register(Registerable registerable) { + var pools = registerable.getRegistryLookup(RegistryKeys.TEMPLATE_POOL); + var empty = pools.getOrThrow(StructurePools.EMPTY); + + registerable.register(PromenadeStructurePoolsKeys.DARK_FOREST_WITCH_HUTS, new StructurePool(empty, + ImmutableList.of( + Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut").toString()), 1) + ), + StructurePool.Projection.RIGID + )); + + registerable.register(PromenadeStructurePoolsKeys.WITCH_HUT_INTERIORS, new StructurePool(empty, + ImmutableList.of( + Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut/interior/normal").toString()), 5), + Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut/interior/hatred").toString()), 1), + Pair.of(StructurePoolElement.ofSingle(Promenade.id("witch_hut/interior/afraid").toString()), 1) + ), + StructurePool.Projection.RIGID + )); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeWolfVariantProvider.java b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeWolfVariantProvider.java index 8771d615..566c9ded 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeWolfVariantProvider.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/PromenadeWolfVariantProvider.java @@ -1,9 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider; -import fr.hugman.promenade.entity.variant.PromenadeWolfVariants; -import fr.hugman.promenade.tag.PromenadeBiomeTags; -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import java.util.concurrent.CompletableFuture; + import net.minecraft.entity.passive.WolfVariant; import net.minecraft.entity.spawn.SpawnConditionSelectors; import net.minecraft.registry.Registerable; @@ -14,41 +23,45 @@ import net.minecraft.util.AssetInfo.TextureAssetInfo; import net.minecraft.world.biome.Biome; -import java.util.concurrent.CompletableFuture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; + +import fr.hugman.promenade.entity.variant.PromenadeWolfVariants; +import fr.hugman.promenade.tag.PromenadeBiomeTags; public class PromenadeWolfVariantProvider extends FabricDynamicRegistryProvider { - public PromenadeWolfVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { - super(output, registriesFuture); - } - - @Override - protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - var wrapper = registries.getOrThrow(RegistryKeys.WOLF_VARIANT); - entries.add(wrapper, PromenadeWolfVariants.SHIBA_INU); - } - - @Override - public String getName() { - return "Wolf Variants"; - } - - public static void register(Registerable registry) { - of(registry, PromenadeWolfVariants.SHIBA_INU, PromenadeBiomeTags.SAKURA_GROVES); - } - - private static void of(Registerable registry, RegistryKey key, TagKey biomeTag) { - of(registry, key, DataProviderUtil.createSpawnConditions(registry.getRegistryLookup(RegistryKeys.BIOME).getOrThrow(biomeTag))); - } - - private static void of(Registerable registry, RegistryKey key, SpawnConditionSelectors spawnConditions) { - var baseId = key.getValue().withPrefixedPath("entity/wolf/"); - registry.register(key, new WolfVariant( - new WolfVariant.WolfAssetInfo( - new TextureAssetInfo(baseId.withSuffixedPath("/wild")), - new TextureAssetInfo(baseId.withSuffixedPath("/tame")), - new TextureAssetInfo(baseId.withSuffixedPath("/angry")) - ), - spawnConditions - )); - } + public PromenadeWolfVariantProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + var wrapper = registries.getOrThrow(RegistryKeys.WOLF_VARIANT); + entries.add(wrapper, PromenadeWolfVariants.SHIBA_INU); + } + + @Override + public String getName() { + return "Wolf Variants"; + } + + public static void register(Registerable registry) { + of(registry, PromenadeWolfVariants.SHIBA_INU, PromenadeBiomeTags.SAKURA_GROVES); + } + + private static void of(Registerable registry, RegistryKey key, TagKey biomeTag) { + of(registry, key, DataProviderUtil.createSpawnConditions(registry.getRegistryLookup(RegistryKeys.BIOME).getOrThrow(biomeTag))); + } + + private static void of(Registerable registry, RegistryKey key, SpawnConditionSelectors spawnConditions) { + var baseId = key.getValue().withPrefixedPath("entity/wolf/"); + registry.register(key, new WolfVariant( + new WolfVariant.WolfAssetInfo( + new TextureAssetInfo(baseId.withSuffixedPath("/wild")), + new TextureAssetInfo(baseId.withSuffixedPath("/tame")), + new TextureAssetInfo(baseId.withSuffixedPath("/angry")) + ), + spawnConditions + )); + } } \ No newline at end of file diff --git a/src/datagen/java/fr/hugman/promenade/data/provider/builders/PromenadeFeatureConfigs.java b/src/datagen/java/fr/hugman/promenade/data/provider/builders/PromenadeFeatureConfigs.java index 29179b3e..661c5bf7 100644 --- a/src/datagen/java/fr/hugman/promenade/data/provider/builders/PromenadeFeatureConfigs.java +++ b/src/datagen/java/fr/hugman/promenade/data/provider/builders/PromenadeFeatureConfigs.java @@ -1,12 +1,21 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.data.provider.builders; +import java.util.List; +import java.util.OptionalInt; + import com.google.common.collect.ImmutableList; -import fr.hugman.promenade.block.MapleLogBlock; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.world.gen.tree.foliage.MapleFoliagePlacer; -import fr.hugman.promenade.world.gen.tree.foliage.PalmFoliagePlacer; -import fr.hugman.promenade.world.gen.tree.trunk.BranchingStraightTrunkPlacer; -import fr.hugman.promenade.world.gen.tree.trunk.LeapingTrunkPlacer; + import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.util.math.Direction; @@ -24,130 +33,134 @@ import net.minecraft.world.gen.trunk.ForkingTrunkPlacer; import net.minecraft.world.gen.trunk.GiantTrunkPlacer; -import java.util.List; -import java.util.OptionalInt; +import fr.hugman.promenade.block.MapleLogBlock; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.world.gen.tree.foliage.MapleFoliagePlacer; +import fr.hugman.promenade.world.gen.tree.foliage.PalmFoliagePlacer; +import fr.hugman.promenade.world.gen.tree.trunk.BranchingStraightTrunkPlacer; +import fr.hugman.promenade.world.gen.tree.trunk.LeapingTrunkPlacer; public class PromenadeFeatureConfigs { - //TODO: should be a tag - public static final BlockPredicate FUNGUS_REPLACEABLE = BlockPredicate.matchingBlocks( - Blocks.OAK_SAPLING, - Blocks.SPRUCE_SAPLING, - Blocks.BIRCH_SAPLING, - Blocks.JUNGLE_SAPLING, - Blocks.ACACIA_SAPLING, - Blocks.CHERRY_SAPLING, - Blocks.DARK_OAK_SAPLING, - Blocks.PALE_OAK_SAPLING, - Blocks.MANGROVE_PROPAGULE, - Blocks.DANDELION, - Blocks.TORCHFLOWER, - Blocks.POPPY, - Blocks.BLUE_ORCHID, - Blocks.ALLIUM, - Blocks.AZURE_BLUET, - Blocks.RED_TULIP, - Blocks.ORANGE_TULIP, - Blocks.WHITE_TULIP, - Blocks.PINK_TULIP, - Blocks.OXEYE_DAISY, - Blocks.CORNFLOWER, - Blocks.WITHER_ROSE, - Blocks.LILY_OF_THE_VALLEY, - Blocks.BROWN_MUSHROOM, - Blocks.RED_MUSHROOM, - Blocks.WHEAT, - Blocks.SUGAR_CANE, - Blocks.ATTACHED_PUMPKIN_STEM, - Blocks.ATTACHED_MELON_STEM, - Blocks.PUMPKIN_STEM, - Blocks.MELON_STEM, - Blocks.LILY_PAD, - Blocks.NETHER_WART, - Blocks.COCOA, - Blocks.CARROTS, - Blocks.POTATOES, - Blocks.CHORUS_PLANT, - Blocks.CHORUS_FLOWER, - Blocks.TORCHFLOWER_CROP, - Blocks.PITCHER_CROP, - Blocks.BEETROOTS, - Blocks.SWEET_BERRY_BUSH, - Blocks.WARPED_FUNGUS, - Blocks.CRIMSON_FUNGUS, - Blocks.WEEPING_VINES, - Blocks.WEEPING_VINES_PLANT, - Blocks.TWISTING_VINES, - Blocks.TWISTING_VINES_PLANT, - Blocks.CAVE_VINES, - Blocks.CAVE_VINES_PLANT, - Blocks.SPORE_BLOSSOM, - Blocks.AZALEA, - Blocks.FLOWERING_AZALEA, - Blocks.MOSS_CARPET, - Blocks.PINK_PETALS, - Blocks.BIG_DRIPLEAF, - Blocks.BIG_DRIPLEAF_STEM, - Blocks.SMALL_DRIPLEAF - ); + //TODO: should be a tag + public static final BlockPredicate FUNGUS_REPLACEABLE = BlockPredicate.matchingBlocks( + Blocks.OAK_SAPLING, + Blocks.SPRUCE_SAPLING, + Blocks.BIRCH_SAPLING, + Blocks.JUNGLE_SAPLING, + Blocks.ACACIA_SAPLING, + Blocks.CHERRY_SAPLING, + Blocks.DARK_OAK_SAPLING, + Blocks.PALE_OAK_SAPLING, + Blocks.MANGROVE_PROPAGULE, + Blocks.DANDELION, + Blocks.TORCHFLOWER, + Blocks.POPPY, + Blocks.BLUE_ORCHID, + Blocks.ALLIUM, + Blocks.AZURE_BLUET, + Blocks.RED_TULIP, + Blocks.ORANGE_TULIP, + Blocks.WHITE_TULIP, + Blocks.PINK_TULIP, + Blocks.OXEYE_DAISY, + Blocks.CORNFLOWER, + Blocks.WITHER_ROSE, + Blocks.LILY_OF_THE_VALLEY, + Blocks.BROWN_MUSHROOM, + Blocks.RED_MUSHROOM, + Blocks.WHEAT, + Blocks.SUGAR_CANE, + Blocks.ATTACHED_PUMPKIN_STEM, + Blocks.ATTACHED_MELON_STEM, + Blocks.PUMPKIN_STEM, + Blocks.MELON_STEM, + Blocks.LILY_PAD, + Blocks.NETHER_WART, + Blocks.COCOA, + Blocks.CARROTS, + Blocks.POTATOES, + Blocks.CHORUS_PLANT, + Blocks.CHORUS_FLOWER, + Blocks.TORCHFLOWER_CROP, + Blocks.PITCHER_CROP, + Blocks.BEETROOTS, + Blocks.SWEET_BERRY_BUSH, + Blocks.WARPED_FUNGUS, + Blocks.CRIMSON_FUNGUS, + Blocks.WEEPING_VINES, + Blocks.WEEPING_VINES_PLANT, + Blocks.TWISTING_VINES, + Blocks.TWISTING_VINES_PLANT, + Blocks.CAVE_VINES, + Blocks.CAVE_VINES_PLANT, + Blocks.SPORE_BLOSSOM, + Blocks.AZALEA, + Blocks.FLOWERING_AZALEA, + Blocks.MOSS_CARPET, + Blocks.PINK_PETALS, + Blocks.BIG_DRIPLEAF, + Blocks.BIG_DRIPLEAF_STEM, + Blocks.SMALL_DRIPLEAF + ); - public static TreeFeatureConfig.Builder palm() { - return new TreeFeatureConfig.Builder( - BlockStateProvider.of(PromenadeBlocks.PALM_LOG), - new LeapingTrunkPlacer(6, 5, 2, BiasedToBottomIntProvider.create(3, 10), UniformIntProvider.create(-1, 0), 0.45f, 2), - BlockStateProvider.of(PromenadeBlocks.PALM_LEAVES), - new PalmFoliagePlacer(ConstantIntProvider.create(0), ConstantIntProvider.create(0)), - new TwoLayersFeatureSize(1, 0, 1) - ) - .decorators(ImmutableList.of(new AttachedToLeavesTreeDecorator(0.8f, 1, 0, BlockStateProvider.of(PromenadeBlocks.PALM_HANGING_LEAVES), 2, List.of(Direction.DOWN)))) - .dirtProvider(BlockStateProvider.of(Blocks.SAND)) - .forceDirt() - .ignoreVines(); - } + public static TreeFeatureConfig.Builder palm() { + return new TreeFeatureConfig.Builder( + BlockStateProvider.of(PromenadeBlocks.PALM_LOG), + new LeapingTrunkPlacer(6, 5, 2, BiasedToBottomIntProvider.create(3, 10), UniformIntProvider.create(- 1, 0), 0.45f, 2), + BlockStateProvider.of(PromenadeBlocks.PALM_LEAVES), + new PalmFoliagePlacer(ConstantIntProvider.create(0), ConstantIntProvider.create(0)), + new TwoLayersFeatureSize(1, 0, 1) + ) + .decorators(ImmutableList.of(new AttachedToLeavesTreeDecorator(0.8f, 1, 0, BlockStateProvider.of(PromenadeBlocks.PALM_HANGING_LEAVES), 2, List.of(Direction.DOWN)))) + .dirtProvider(BlockStateProvider.of(Blocks.SAND)) + .forceDirt() + .ignoreVines(); + } - public static TreeFeatureConfig.Builder sakura(Block leaves, boolean fancy) { - return new TreeFeatureConfig.Builder( - BlockStateProvider.of(PromenadeBlocks.SAKURA_LOG), - fancy ? new ForkingTrunkPlacer(5, 3, 2) : - new ForkingTrunkPlacer(3, 2, 1), - BlockStateProvider.of(leaves), - new AcaciaFoliagePlacer(UniformIntProvider.create(1, 2), ConstantIntProvider.create(0)), - new TwoLayersFeatureSize(1, 0, 1) - ).ignoreVines(); - } + public static TreeFeatureConfig.Builder sakura(Block leaves, boolean fancy) { + return new TreeFeatureConfig.Builder( + BlockStateProvider.of(PromenadeBlocks.SAKURA_LOG), + fancy ? new ForkingTrunkPlacer(5, 3, 2) : + new ForkingTrunkPlacer(3, 2, 1), + BlockStateProvider.of(leaves), + new AcaciaFoliagePlacer(UniformIntProvider.create(1, 2), ConstantIntProvider.create(0)), + new TwoLayersFeatureSize(1, 0, 1) + ).ignoreVines(); + } - public static TreeFeatureConfig.Builder maple(Block leaves, boolean fancy) { - return new TreeFeatureConfig.Builder( - BlockStateProvider.of(PromenadeBlocks.MAPLE_LOG.getDefaultState().with(MapleLogBlock.NATURAL, true)), - fancy ? new BranchingStraightTrunkPlacer(17, 5, 3) : - new BranchingStraightTrunkPlacer(13, 4, 2), - BlockStateProvider.of(leaves), - new MapleFoliagePlacer(BiasedToBottomIntProvider.create(3, 4), UniformIntProvider.create(5, 6), BiasedToBottomIntProvider.create(17, 20)), - fancy ? new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4)) : - new TwoLayersFeatureSize(1, 0, 1, OptionalInt.empty()) - ) - .ignoreVines(); - } + public static TreeFeatureConfig.Builder maple(Block leaves, boolean fancy) { + return new TreeFeatureConfig.Builder( + BlockStateProvider.of(PromenadeBlocks.MAPLE_LOG.getDefaultState().with(MapleLogBlock.NATURAL, true)), + fancy ? new BranchingStraightTrunkPlacer(17, 5, 3) : + new BranchingStraightTrunkPlacer(13, 4, 2), + BlockStateProvider.of(leaves), + new MapleFoliagePlacer(BiasedToBottomIntProvider.create(3, 4), UniformIntProvider.create(5, 6), BiasedToBottomIntProvider.create(17, 20)), + fancy ? new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4)) : + new TwoLayersFeatureSize(1, 0, 1, OptionalInt.empty()) + ) + .ignoreVines(); + } - public static TreeFeatureConfig.Builder snowyMegaSpruce(Block leaves) { - return new TreeFeatureConfig.Builder( - BlockStateProvider.of(Blocks.SPRUCE_LOG), - new GiantTrunkPlacer(13, 2, 14), - BlockStateProvider.of(leaves), - new MegaPineFoliagePlacer(ConstantIntProvider.create(0), ConstantIntProvider.create(0), UniformIntProvider.create(13, 17)), - new TwoLayersFeatureSize(1, 1, 2) - ); - } + public static TreeFeatureConfig.Builder snowyMegaSpruce(Block leaves) { + return new TreeFeatureConfig.Builder( + BlockStateProvider.of(Blocks.SPRUCE_LOG), + new GiantTrunkPlacer(13, 2, 14), + BlockStateProvider.of(leaves), + new MegaPineFoliagePlacer(ConstantIntProvider.create(0), ConstantIntProvider.create(0), UniformIntProvider.create(13, 17)), + new TwoLayersFeatureSize(1, 1, 2) + ); + } - public static HugeFungusFeatureConfig hugeDarkAmaranthFungus(boolean planted) { - return new HugeFungusFeatureConfig( - PromenadeBlocks.DARK_AMARANTH_NYLIUM.getDefaultState(), - PromenadeBlocks.DARK_AMARANTH_STEM.getDefaultState(), - PromenadeBlocks.DARK_AMARANTH_WART_BLOCK.getDefaultState(), - PromenadeBlocks.SOUL_SHROOMLIGHT.getDefaultState(), - PromenadeFeatureConfigs.FUNGUS_REPLACEABLE, - planted - ); - } + public static HugeFungusFeatureConfig hugeDarkAmaranthFungus(boolean planted) { + return new HugeFungusFeatureConfig( + PromenadeBlocks.DARK_AMARANTH_NYLIUM.getDefaultState(), + PromenadeBlocks.DARK_AMARANTH_STEM.getDefaultState(), + PromenadeBlocks.DARK_AMARANTH_WART_BLOCK.getDefaultState(), + PromenadeBlocks.SOUL_SHROOMLIGHT.getDefaultState(), + PromenadeFeatureConfigs.FUNGUS_REPLACEABLE, + planted + ); + } } diff --git a/src/main/java/fr/hugman/promenade/Promenade.java b/src/main/java/fr/hugman/promenade/Promenade.java index 6c62b087..c05a5bc7 100644 --- a/src/main/java/fr/hugman/promenade/Promenade.java +++ b/src/main/java/fr/hugman/promenade/Promenade.java @@ -1,6 +1,24 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade; import com.google.common.reflect.Reflection; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.minecraft.util.Identifier; + +import net.fabricmc.api.ModInitializer; + import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.block.dispenser.PromenadeDispenserBehaviors; import fr.hugman.promenade.block.entity.PromenadeBlockEntities; @@ -23,58 +41,54 @@ import fr.hugman.promenade.world.gen.placement_modifier.PromenadePlacementModifierTypes; import fr.hugman.promenade.world.gen.tree.foliage.PromenadeFoliagePlacerTypes; import fr.hugman.promenade.world.gen.tree.trunk.PromenadeTrunkPlacerTypes; -import net.fabricmc.api.ModInitializer; -import net.minecraft.util.Identifier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; public class Promenade implements ModInitializer { - public static final String MOD_ID = "promenade"; - public static final Logger LOGGER = LogManager.getLogger(); + public static final String MOD_ID = "promenade"; + public static final Logger LOGGER = LogManager.getLogger(); - @Override - public void onInitialize() { - PromenadeRegistries.register(); + @Override + public void onInitialize() { + PromenadeRegistries.register(); - Reflection.initialize(PromenadeSoundEvents.class); + Reflection.initialize(PromenadeSoundEvents.class); - Reflection.initialize(PromenadeBlocks.class); + Reflection.initialize(PromenadeBlocks.class); - PromenadeStrippables.register(); - PromenadeFlammables.register(); - PromenadeBlockEntities.addBlocksToVanillaBlockEntityTypes(); + PromenadeStrippables.register(); + PromenadeFlammables.register(); + PromenadeBlockEntities.addBlocksToVanillaBlockEntityTypes(); - Reflection.initialize(PromenadeComponentTypes.class); - Reflection.initialize(PromenadeItems.class); + Reflection.initialize(PromenadeComponentTypes.class); + Reflection.initialize(PromenadeItems.class); - Reflection.initialize(PromenadeItemGroups.class); - PromenadeItemGroupAdditions.appendItemGroups(); - PromenadeCompostingChances.register(); - PromenadeTrades.appendVillagerTrades(); - PromenadeDispenserBehaviors.register(); + Reflection.initialize(PromenadeItemGroups.class); + PromenadeItemGroupAdditions.appendItemGroups(); + PromenadeCompostingChances.register(); + PromenadeTrades.appendVillagerTrades(); + PromenadeDispenserBehaviors.register(); - Reflection.initialize(PromenadeSensorTypes.class); - Reflection.initialize(PromenadeMemoryModuleTypes.class); - Reflection.initialize(PromenadeTrackedData.class); - Reflection.initialize(PromenadeEntityTypes.class); + Reflection.initialize(PromenadeSensorTypes.class); + Reflection.initialize(PromenadeMemoryModuleTypes.class); + Reflection.initialize(PromenadeTrackedData.class); + Reflection.initialize(PromenadeEntityTypes.class); - Reflection.initialize(PromenadeTrunkPlacerTypes.class); - Reflection.initialize(PromenadeFoliagePlacerTypes.class); - Reflection.initialize(PromenadeFeatures.class); - Reflection.initialize(PromenadePlacementModifierTypes.class); + Reflection.initialize(PromenadeTrunkPlacerTypes.class); + Reflection.initialize(PromenadeFoliagePlacerTypes.class); + Reflection.initialize(PromenadeFeatures.class); + Reflection.initialize(PromenadePlacementModifierTypes.class); - PromenadeSpawnConditions.register(); + PromenadeSpawnConditions.register(); - PromenadeEntityTypes.appendWorldGen(); - PromenadeBiomes.appendWorldGen(); - PromenadePlacedFeatures.appendWorldGen(); + PromenadeEntityTypes.appendWorldGen(); + PromenadeBiomes.appendWorldGen(); + PromenadePlacedFeatures.appendWorldGen(); - PromenadeRegistryAliases.registerAliases(); + PromenadeRegistryAliases.registerAliases(); - Reflection.initialize(PromenadeGameRules.class); - } + Reflection.initialize(PromenadeGameRules.class); + } - public static Identifier id(String path) { - return Identifier.of(MOD_ID, path); - } + public static Identifier id(String path) { + return Identifier.of(MOD_ID, path); + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatternTags.java b/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatternTags.java index e261500e..cb03acf6 100644 --- a/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatternTags.java +++ b/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatternTags.java @@ -1,14 +1,26 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.banner; -import fr.hugman.promenade.Promenade; import net.minecraft.block.entity.BannerPattern; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; +import fr.hugman.promenade.Promenade; + public class PromenadeBannerPatternTags { - public static final TagKey BOVINE_PATTERN_ITEM = of("pattern_item/bovine"); + public static final TagKey BOVINE_PATTERN_ITEM = of("pattern_item/bovine"); - private static TagKey of(String path) { - return TagKey.of(RegistryKeys.BANNER_PATTERN, Promenade.id(path)); - } + private static TagKey of(String path) { + return TagKey.of(RegistryKeys.BANNER_PATTERN, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatterns.java b/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatterns.java index d48b0073..223acd6e 100644 --- a/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatterns.java +++ b/src/main/java/fr/hugman/promenade/banner/PromenadeBannerPatterns.java @@ -1,14 +1,26 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.banner; -import fr.hugman.promenade.Promenade; import net.minecraft.block.entity.BannerPattern; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; +import fr.hugman.promenade.Promenade; + public class PromenadeBannerPatterns { - public static final RegistryKey BOVINE = of("bovine"); + public static final RegistryKey BOVINE = of("bovine"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.BANNER_PATTERN, Promenade.id(path)); - } + private static RegistryKey of(String path) { + return RegistryKey.of(RegistryKeys.BANNER_PATTERN, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantBlock.java b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantBlock.java index 6990d2e3..8fc9043a 100644 --- a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantBlock.java +++ b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantBlock.java @@ -1,6 +1,20 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; +import java.util.Optional; + import com.mojang.serialization.MapCodec; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Fertilizable; @@ -18,86 +32,84 @@ import net.minecraft.world.WorldView; import net.minecraft.world.tick.ScheduledTickView; -import java.util.Optional; - public abstract class AbstractFacingPlantBlock extends AbstractFacingPlantPartBlock implements Fertilizable { - protected AbstractFacingPlantBlock(Settings settings, VoxelShape[] outlineShapes, boolean bl) { - super(settings, outlineShapes, bl); - } - - @Override - protected abstract MapCodec getCodec(); - - protected BlockState copyState(BlockState from, BlockState to) { - return to.with(FACING, from.get(FACING)); - } - - @Override - protected BlockState getStateForNeighborUpdate( - BlockState state, - WorldView world, - ScheduledTickView tickView, - BlockPos pos, - Direction direction, - BlockPos neighborPos, - BlockState neighborState, - Random random - ) { - var facing = state.get(FACING); - if (direction == facing.getOpposite() && !state.canPlaceAt(world, pos)) { - tickView.scheduleBlockTick(pos, this, 1); - } - - AbstractFacingPlantStemBlock stem = this.getStem(); - if (direction == facing && !((neighborState.isOf(this) || neighborState.isOf(stem)) && neighborState.get(FACING) == facing)) { - return this.copyState(state, stem.getRandomGrowthState(random)); - } else { - if (this.tickWater) { - tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - } - - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); - } - } - - @Override - protected ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state, boolean includeData) { - return new ItemStack(this.getStem()); - } - - @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - var facing = state.get(FACING); - Optional optional = this.getStemHeadPos(world, pos, state.getBlock(), facing); - return optional.isPresent() && this.getStem().canGrowAt(world.getBlockState(optional.get().offset(facing))); - } - - @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { - return true; - } - - @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - Optional optional = this.getStemHeadPos(world, pos, state.getBlock(), state.get(FACING)); - if (optional.isPresent()) { - BlockState blockState = world.getBlockState(optional.get()); - ((AbstractFacingPlantStemBlock) blockState.getBlock()).grow(world, random, optional.get(), blockState); - } - } - - private Optional getStemHeadPos(BlockView world, BlockPos pos, Block block, Direction direction) { - return BlockLocating.findColumnEnd(world, pos, block, direction, this.getStem()); - } - - @Override - protected boolean canReplace(BlockState state, ItemPlacementContext context) { - boolean bl = super.canReplace(state, context); - return (!bl || !context.getStack().isOf(this.getStem().asItem())) && bl; - } - - @Override - protected Block getPlant() { - return this; - } + protected AbstractFacingPlantBlock(Settings settings, VoxelShape[] outlineShapes, boolean bl) { + super(settings, outlineShapes, bl); + } + + @Override + protected abstract MapCodec getCodec(); + + protected BlockState copyState(BlockState from, BlockState to) { + return to.with(FACING, from.get(FACING)); + } + + @Override + protected BlockState getStateForNeighborUpdate( + BlockState state, + WorldView world, + ScheduledTickView tickView, + BlockPos pos, + Direction direction, + BlockPos neighborPos, + BlockState neighborState, + Random random + ) { + var facing = state.get(FACING); + if (direction == facing.getOpposite() && !state.canPlaceAt(world, pos)) { + tickView.scheduleBlockTick(pos, this, 1); + } + + AbstractFacingPlantStemBlock stem = this.getStem(); + if (direction == facing && !((neighborState.isOf(this) || neighborState.isOf(stem)) && neighborState.get(FACING) == facing)) { + return this.copyState(state, stem.getRandomGrowthState(random)); + } else { + if (this.tickWater) { + tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + + return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); + } + } + + @Override + protected ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state, boolean includeData) { + return new ItemStack(this.getStem()); + } + + @Override + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { + var facing = state.get(FACING); + Optional optional = this.getStemHeadPos(world, pos, state.getBlock(), facing); + return optional.isPresent() && this.getStem().canGrowAt(world.getBlockState(optional.get().offset(facing))); + } + + @Override + public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + return true; + } + + @Override + public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + Optional optional = this.getStemHeadPos(world, pos, state.getBlock(), state.get(FACING)); + if (optional.isPresent()) { + BlockState blockState = world.getBlockState(optional.get()); + ((AbstractFacingPlantStemBlock) blockState.getBlock()).grow(world, random, optional.get(), blockState); + } + } + + private Optional getStemHeadPos(BlockView world, BlockPos pos, Block block, Direction direction) { + return BlockLocating.findColumnEnd(world, pos, block, direction, this.getStem()); + } + + @Override + protected boolean canReplace(BlockState state, ItemPlacementContext context) { + boolean bl = super.canReplace(state, context); + return (!bl || !context.getStack().isOf(this.getStem().asItem())) && bl; + } + + @Override + protected Block getPlant() { + return this; + } } diff --git a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantPartBlock.java b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantPartBlock.java index 41e91204..9453795a 100644 --- a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantPartBlock.java +++ b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantPartBlock.java @@ -1,6 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.FacingBlock; @@ -16,89 +29,89 @@ import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; import net.minecraft.world.WorldView; -import org.jetbrains.annotations.Nullable; public abstract class AbstractFacingPlantPartBlock extends FacingBlock { - public static final EnumProperty FACING = Properties.FACING; + public static final EnumProperty FACING = Properties.FACING; - protected final VoxelShape[] outlineShapes; - protected final boolean tickWater; + protected final VoxelShape[] outlineShapes; + protected final boolean tickWater; - public AbstractFacingPlantPartBlock( - Settings settings, - VoxelShape[] outlineShapes, - boolean tickWater - ) { - super(settings); - this.outlineShapes = outlineShapes; - this.tickWater = tickWater; - } + public AbstractFacingPlantPartBlock( + Settings settings, + VoxelShape[] outlineShapes, + boolean tickWater + ) { + super(settings); + this.outlineShapes = outlineShapes; + this.tickWater = tickWater; + } - @Override - protected abstract MapCodec getCodec(); + @Override + protected abstract MapCodec getCodec(); - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(FACING); - } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(FACING); + } - @Nullable - @Override - public BlockState getPlacementState(ItemPlacementContext ctx) { - var placementDirections = ctx.getPlacementDirections(); - //TODO: make it prefer existing stems if not sneaking - for (var direction : placementDirections) { - var opposite = direction.getOpposite(); - var otherState = ctx.getWorld().getBlockState(ctx.getBlockPos().offset(opposite)); - var newState = !otherState.isOf(this.getStem()) && !otherState.isOf(this.getPlant()) - ? this.getRandomGrowthState(ctx.getWorld().random) - : this.getPlant().getDefaultState(); - if (newState.contains(FACING)) { - newState = newState.with(FACING, opposite); - } - if (newState.canPlaceAt(ctx.getWorld(), ctx.getBlockPos())) { - return newState; - } - } - return null; - } + @Nullable + @Override + public BlockState getPlacementState(ItemPlacementContext ctx) { + var placementDirections = ctx.getPlacementDirections(); + //TODO: make it prefer existing stems if not sneaking + for (var direction : placementDirections) { + var opposite = direction.getOpposite(); + var otherState = ctx.getWorld().getBlockState(ctx.getBlockPos().offset(opposite)); + var newState = !otherState.isOf(this.getStem()) && !otherState.isOf(this.getPlant()) + ? this.getRandomGrowthState(ctx.getWorld().random) + : this.getPlant().getDefaultState(); + if (newState.contains(FACING)) { + newState = newState.with(FACING, opposite); + } + if (newState.canPlaceAt(ctx.getWorld(), ctx.getBlockPos())) { + return newState; + } + } + return null; + } - public BlockState getRandomGrowthState(Random random) { - return this.getDefaultState(); - } + public BlockState getRandomGrowthState(Random random) { + return this.getDefaultState(); + } - @Override - protected boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - var facing = state.get(FACING); - var blockPos = pos.offset(facing.getOpposite()); - var blockState = world.getBlockState(blockPos); - if (!this.canAttachTo(blockState)) return false; - if (blockState.isOf(this.getStem()) || blockState.isOf(this.getPlant())) { - if (blockState.contains(FACING) && blockState.get(FACING) == facing) { - return true; - } - } - return blockState.isSideSolidFullSquare(world, blockPos, facing); - } + @Override + protected boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + var facing = state.get(FACING); + var blockPos = pos.offset(facing.getOpposite()); + var blockState = world.getBlockState(blockPos); + if (!this.canAttachTo(blockState)) + return false; + if (blockState.isOf(this.getStem()) || blockState.isOf(this.getPlant())) { + if (blockState.contains(FACING) && blockState.get(FACING) == facing) { + return true; + } + } + return blockState.isSideSolidFullSquare(world, blockPos, facing); + } - @Override - protected void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (!state.canPlaceAt(world, pos)) { - world.breakBlock(pos, true); - } - } + @Override + protected void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + if (!state.canPlaceAt(world, pos)) { + world.breakBlock(pos, true); + } + } - protected boolean canAttachTo(BlockState state) { - return true; - } + protected boolean canAttachTo(BlockState state) { + return true; + } - @Override - protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - return this.outlineShapes[state.get(FACING).getIndex()]; - } + @Override + protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + return this.outlineShapes[state.get(FACING).getIndex()]; + } - protected abstract AbstractFacingPlantStemBlock getStem(); + protected abstract AbstractFacingPlantStemBlock getStem(); - protected abstract Block getPlant(); + protected abstract Block getPlant(); } diff --git a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantStemBlock.java b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantStemBlock.java index 3cc0b263..d8ed2ec5 100644 --- a/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantStemBlock.java +++ b/src/main/java/fr/hugman/promenade/block/AbstractFacingPlantStemBlock.java @@ -1,6 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; + import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -19,123 +31,123 @@ import net.minecraft.world.tick.ScheduledTickView; public abstract class AbstractFacingPlantStemBlock extends AbstractFacingPlantPartBlock implements Fertilizable { - public static final IntProperty AGE = Properties.AGE_25; - public static final int MAX_AGE = 25; - private final double growthChance; - - public AbstractFacingPlantStemBlock( - AbstractBlock.Settings settings, - VoxelShape[] outlineShapes, - boolean tickWater, - double growthChance - ) { - super(settings, outlineShapes, tickWater); - this.growthChance = growthChance; - this.setDefaultState(this.stateManager.getDefaultState().with(AGE, Integer.valueOf(0))); - } - - @Override - protected abstract MapCodec getCodec(); - - @Override - public BlockState getRandomGrowthState(Random random) { - return this.getDefaultState().with(AGE, Integer.valueOf(random.nextInt(MAX_AGE))); - } - - @Override - protected boolean hasRandomTicks(BlockState state) { - return state.get(AGE) < MAX_AGE; - } - - @Override - protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (state.get(AGE) < 25 && random.nextDouble() < this.growthChance) { - BlockPos blockPos = pos.offset(state.get(FACING)); - if (this.canGrowAt(world.getBlockState(blockPos))) { - world.setBlockState(blockPos, this.age(state, world.random)); - } - } - } - - protected BlockState age(BlockState state, Random random) { - return state.cycle(AGE); - } - - public BlockState withMaxAge(BlockState state) { - return state.with(AGE, Integer.valueOf(MAX_AGE)); - } - - public boolean hasMaxAge(BlockState state) { - return state.get(AGE) == MAX_AGE; - } - - protected BlockState copyState(BlockState from, BlockState to) { - return to.with(FACING, from.get(FACING)); - } - - @Override - protected BlockState getStateForNeighborUpdate( - BlockState state, - WorldView world, - ScheduledTickView tickView, - BlockPos pos, - Direction direction, - BlockPos neighborPos, - BlockState neighborState, - Random random - ) { - var facing = state.get(FACING); - if (direction == facing.getOpposite() && !state.canPlaceAt(world, pos)) { - tickView.scheduleBlockTick(pos, this, 1); - } - - if (direction != facing || !((neighborState.isOf(this) || neighborState.isOf(this.getPlant())) && neighborState.get(FACING) == facing)) { - if (this.tickWater) { - tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - } - - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); - } else { - return this.copyState(state, this.getPlant().getDefaultState()); - } - } - - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(AGE); - } - - @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - return this.canGrowAt(world.getBlockState(pos.offset(state.get(FACING)))); - } - - @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { - return true; - } - - @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - var facing = state.get(FACING); - var blockPos = pos.offset(facing); - var i = Math.min(state.get(AGE) + 1, MAX_AGE); - var j = this.getGrowthLength(random); - - for (int k = 0; k < j && this.canGrowAt(world.getBlockState(blockPos)); k++) { - world.setBlockState(blockPos, state.with(AGE, Integer.valueOf(i)).with(FACING, facing)); - blockPos = blockPos.offset(facing); - i = Math.min(i + 1, MAX_AGE); - } - } - - protected abstract int getGrowthLength(Random random); - - protected abstract boolean canGrowAt(BlockState state); - - @Override - protected AbstractFacingPlantStemBlock getStem() { - return this; - } + public static final IntProperty AGE = Properties.AGE_25; + public static final int MAX_AGE = 25; + private final double growthChance; + + public AbstractFacingPlantStemBlock( + AbstractBlock.Settings settings, + VoxelShape[] outlineShapes, + boolean tickWater, + double growthChance + ) { + super(settings, outlineShapes, tickWater); + this.growthChance = growthChance; + this.setDefaultState(this.stateManager.getDefaultState().with(AGE, Integer.valueOf(0))); + } + + @Override + protected abstract MapCodec getCodec(); + + @Override + public BlockState getRandomGrowthState(Random random) { + return this.getDefaultState().with(AGE, Integer.valueOf(random.nextInt(MAX_AGE))); + } + + @Override + protected boolean hasRandomTicks(BlockState state) { + return state.get(AGE) < MAX_AGE; + } + + @Override + protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + if (state.get(AGE) < 25 && random.nextDouble() < this.growthChance) { + BlockPos blockPos = pos.offset(state.get(FACING)); + if (this.canGrowAt(world.getBlockState(blockPos))) { + world.setBlockState(blockPos, this.age(state, world.random)); + } + } + } + + protected BlockState age(BlockState state, Random random) { + return state.cycle(AGE); + } + + public BlockState withMaxAge(BlockState state) { + return state.with(AGE, Integer.valueOf(MAX_AGE)); + } + + public boolean hasMaxAge(BlockState state) { + return state.get(AGE) == MAX_AGE; + } + + protected BlockState copyState(BlockState from, BlockState to) { + return to.with(FACING, from.get(FACING)); + } + + @Override + protected BlockState getStateForNeighborUpdate( + BlockState state, + WorldView world, + ScheduledTickView tickView, + BlockPos pos, + Direction direction, + BlockPos neighborPos, + BlockState neighborState, + Random random + ) { + var facing = state.get(FACING); + if (direction == facing.getOpposite() && !state.canPlaceAt(world, pos)) { + tickView.scheduleBlockTick(pos, this, 1); + } + + if (direction != facing || !((neighborState.isOf(this) || neighborState.isOf(this.getPlant())) && neighborState.get(FACING) == facing)) { + if (this.tickWater) { + tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + + return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); + } else { + return this.copyState(state, this.getPlant().getDefaultState()); + } + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(AGE); + } + + @Override + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { + return this.canGrowAt(world.getBlockState(pos.offset(state.get(FACING)))); + } + + @Override + public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + return true; + } + + @Override + public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + var facing = state.get(FACING); + var blockPos = pos.offset(facing); + var i = Math.min(state.get(AGE) + 1, MAX_AGE); + var j = this.getGrowthLength(random); + + for (int k = 0; k < j && this.canGrowAt(world.getBlockState(blockPos)); k++) { + world.setBlockState(blockPos, state.with(AGE, Integer.valueOf(i)).with(FACING, facing)); + blockPos = blockPos.offset(facing); + i = Math.min(i + 1, MAX_AGE); + } + } + + protected abstract int getGrowthLength(Random random); + + protected abstract boolean canGrowAt(BlockState state); + + @Override + protected AbstractFacingPlantStemBlock getStem() { + return this; + } } diff --git a/src/main/java/fr/hugman/promenade/block/BerryBushBlock.java b/src/main/java/fr/hugman/promenade/block/BerryBushBlock.java index afd6ae87..6a231e1a 100644 --- a/src/main/java/fr/hugman/promenade/block/BerryBushBlock.java +++ b/src/main/java/fr/hugman/promenade/block/BerryBushBlock.java @@ -1,9 +1,21 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.datafixers.DataFixUtils; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.block.*; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCollisionHandler; @@ -34,122 +46,122 @@ import net.minecraft.world.event.GameEvent; public class BerryBushBlock extends PlantBlock implements Fertilizable { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - RegistryKey.createCodec(RegistryKeys.ITEM).fieldOf("berry").forGetter(block -> block.berry), - Codec.BOOL.fieldOf("is_spiny").forGetter(block -> block.isSpiny), - createSettingsCodec()) - .apply(instance, BerryBushBlock::new)); - - private static final float MIN_MOVEMENT_FOR_DAMAGE = 0.003f; - public static final int MAX_AGE = 3; - public static final IntProperty AGE = Properties.AGE_3; - private static final VoxelShape SMALL_SHAPE = Block.createCuboidShape(3.0, 0.0, 3.0, 13.0, 8.0, 13.0); - private static final VoxelShape LARGE_SHAPE = Block.createCuboidShape(1.0, 0.0, 1.0, 15.0, 16.0, 15.0); - - private final RegistryKey berry; - private final boolean isSpiny; - - public BerryBushBlock(RegistryKey berry, boolean isSpiny, AbstractBlock.Settings settings) { - super(settings); - this.berry = berry; - this.isSpiny = isSpiny; - this.setDefaultState(this.stateManager.getDefaultState().with(AGE, 0)); - } - - @Override - public MapCodec getCodec() { - return CODEC; - } - - @Override - protected ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state, boolean includeData) { - return new ItemStack(DataFixUtils.orElse(world.getRegistryManager().getOrThrow(RegistryKeys.ITEM).getOptionalValue(this.berry), this)); - } - - @Override - protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - if (state.get(AGE) == 0) { - return SMALL_SHAPE; - } - if (state.get(AGE) < MAX_AGE) { - return LARGE_SHAPE; - } - return super.getOutlineShape(state, world, pos, context); - } - - @Override - protected boolean hasRandomTicks(BlockState state) { - return state.get(AGE) < MAX_AGE; - } - - @Override - protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - int age = state.get(AGE); - if (age < MAX_AGE && random.nextInt(5) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) { - BlockState blockState = state.with(AGE, age + 1); - world.setBlockState(pos, blockState, Block.NOTIFY_LISTENERS); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(blockState)); - } - } - - @Override - protected void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity, EntityCollisionHandler handler) { - if (!(entity instanceof LivingEntity) || entity.getType() == EntityType.FOX || entity.getType() == EntityType.BEE) { - return; - } - entity.slowMovement(state, new Vec3d(0.8f, 0.75, 0.8f)); - if (this.isSpiny) { - if (world instanceof ServerWorld serverWorld && state.get(AGE) != 0) { - Vec3d vec3d = entity.isControlledByPlayer() ? entity.getMovement() : entity.getLastRenderPos().subtract(entity.getEntityPos()); - if (vec3d.horizontalLengthSquared() > 0.0) { - double d = Math.abs(vec3d.getX()); - double e = Math.abs(vec3d.getZ()); - if (d >= MIN_MOVEMENT_FOR_DAMAGE || e >= MIN_MOVEMENT_FOR_DAMAGE) { - entity.damage(serverWorld, world.getDamageSources().sweetBerryBush(), 1.0F); - } - } - } - } - } - - @Override - protected ActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - return state.get(AGE) != 3 && stack.isOf(Items.BONE_MEAL) ? ActionResult.PASS : super.onUseWithItem(stack, state, world, pos, player, hand, hit); - } - - @Override - protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) { - int age = state.get(AGE); - if (age > 1) { - int j = 1 + world.random.nextInt(2); - dropStack(world, pos, new ItemStack(DataFixUtils.orElse(world.getRegistryManager().getOrThrow(RegistryKeys.ITEM).getOptionalValue(this.berry), this), j + (age == MAX_AGE ? 1 : 0))); - world.playSound(null, pos, SoundEvents.BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0f, 0.8f + world.random.nextFloat() * 0.4f); - BlockState blockState = state.with(AGE, 1); - world.setBlockState(pos, blockState, Block.NOTIFY_LISTENERS); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(player, blockState)); - return ActionResult.SUCCESS; - } - return super.onUse(state, world, pos, player, hit); - } - - @Override - protected void appendProperties(StateManager.Builder builder) { - builder.add(AGE); - } - - @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - return state.get(AGE) < 3; - } - - @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { - return true; - } - - @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - int i = Math.min(MAX_AGE, state.get(AGE) + 1); - world.setBlockState(pos, state.with(AGE, i), Block.NOTIFY_LISTENERS); - } + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + RegistryKey.createCodec(RegistryKeys.ITEM).fieldOf("berry").forGetter(block -> block.berry), + Codec.BOOL.fieldOf("is_spiny").forGetter(block -> block.isSpiny), + createSettingsCodec()) + .apply(instance, BerryBushBlock::new)); + + private static final float MIN_MOVEMENT_FOR_DAMAGE = 0.003f; + public static final int MAX_AGE = 3; + public static final IntProperty AGE = Properties.AGE_3; + private static final VoxelShape SMALL_SHAPE = Block.createCuboidShape(3.0, 0.0, 3.0, 13.0, 8.0, 13.0); + private static final VoxelShape LARGE_SHAPE = Block.createCuboidShape(1.0, 0.0, 1.0, 15.0, 16.0, 15.0); + + private final RegistryKey berry; + private final boolean isSpiny; + + public BerryBushBlock(RegistryKey berry, boolean isSpiny, AbstractBlock.Settings settings) { + super(settings); + this.berry = berry; + this.isSpiny = isSpiny; + this.setDefaultState(this.stateManager.getDefaultState().with(AGE, 0)); + } + + @Override + public MapCodec getCodec() { + return CODEC; + } + + @Override + protected ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state, boolean includeData) { + return new ItemStack(DataFixUtils.orElse(world.getRegistryManager().getOrThrow(RegistryKeys.ITEM).getOptionalValue(this.berry), this)); + } + + @Override + protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + if (state.get(AGE) == 0) { + return SMALL_SHAPE; + } + if (state.get(AGE) < MAX_AGE) { + return LARGE_SHAPE; + } + return super.getOutlineShape(state, world, pos, context); + } + + @Override + protected boolean hasRandomTicks(BlockState state) { + return state.get(AGE) < MAX_AGE; + } + + @Override + protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + int age = state.get(AGE); + if (age < MAX_AGE && random.nextInt(5) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) { + BlockState blockState = state.with(AGE, age + 1); + world.setBlockState(pos, blockState, Block.NOTIFY_LISTENERS); + world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(blockState)); + } + } + + @Override + protected void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity, EntityCollisionHandler handler) { + if (!(entity instanceof LivingEntity) || entity.getType() == EntityType.FOX || entity.getType() == EntityType.BEE) { + return; + } + entity.slowMovement(state, new Vec3d(0.8f, 0.75, 0.8f)); + if (this.isSpiny) { + if (world instanceof ServerWorld serverWorld && state.get(AGE) != 0) { + Vec3d vec3d = entity.isControlledByPlayer() ? entity.getMovement() : entity.getLastRenderPos().subtract(entity.getEntityPos()); + if (vec3d.horizontalLengthSquared() > 0.0) { + double d = Math.abs(vec3d.getX()); + double e = Math.abs(vec3d.getZ()); + if (d >= MIN_MOVEMENT_FOR_DAMAGE || e >= MIN_MOVEMENT_FOR_DAMAGE) { + entity.damage(serverWorld, world.getDamageSources().sweetBerryBush(), 1.0F); + } + } + } + } + } + + @Override + protected ActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + return state.get(AGE) != 3 && stack.isOf(Items.BONE_MEAL) ? ActionResult.PASS : super.onUseWithItem(stack, state, world, pos, player, hand, hit); + } + + @Override + protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) { + int age = state.get(AGE); + if (age > 1) { + int j = 1 + world.random.nextInt(2); + dropStack(world, pos, new ItemStack(DataFixUtils.orElse(world.getRegistryManager().getOrThrow(RegistryKeys.ITEM).getOptionalValue(this.berry), this), j + (age == MAX_AGE ? 1 : 0))); + world.playSound(null, pos, SoundEvents.BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0f, 0.8f + world.random.nextFloat() * 0.4f); + BlockState blockState = state.with(AGE, 1); + world.setBlockState(pos, blockState, Block.NOTIFY_LISTENERS); + world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(player, blockState)); + return ActionResult.SUCCESS; + } + return super.onUse(state, world, pos, player, hit); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(AGE); + } + + @Override + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { + return state.get(AGE) < 3; + } + + @Override + public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + return true; + } + + @Override + public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + int i = Math.min(MAX_AGE, state.get(AGE) + 1); + world.setBlockState(pos, state.with(AGE, i), Block.NOTIFY_LISTENERS); + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/BlockSettings.java b/src/main/java/fr/hugman/promenade/block/BlockSettings.java index bc119e63..21caff78 100644 --- a/src/main/java/fr/hugman/promenade/block/BlockSettings.java +++ b/src/main/java/fr/hugman/promenade/block/BlockSettings.java @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import net.minecraft.block.AbstractBlock; @@ -6,21 +17,22 @@ import net.minecraft.sound.BlockSoundGroup; public final class BlockSettings { - public static AbstractBlock.Settings rock() { - return AbstractBlock.Settings.create().instrument(NoteBlockInstrument.BASEDRUM).requiresTool().strength(1.5F, 6.0f); - } + public static AbstractBlock.Settings rock() { + return AbstractBlock.Settings.create().instrument(NoteBlockInstrument.BASEDRUM).requiresTool().strength(1.5F, 6.0f); + } - public static AbstractBlock.Settings rock(MapColor mapColor, BlockSoundGroup sounds) { - return rock().mapColor(mapColor).sounds(sounds); - } + public static AbstractBlock.Settings rock(MapColor mapColor, BlockSoundGroup sounds) { + return rock().mapColor(mapColor).sounds(sounds); + } - public static AbstractBlock.Settings planks(MapColor color, BlockSoundGroup sounds, boolean flammable) { - AbstractBlock.Settings settings = AbstractBlock.Settings.create() - .mapColor(color) - .instrument(NoteBlockInstrument.BASS) - .strength(2.0f, 3.0f) - .sounds(sounds); - if (flammable) settings.burnable(); - return settings; - } + public static AbstractBlock.Settings planks(MapColor color, BlockSoundGroup sounds, boolean flammable) { + AbstractBlock.Settings settings = AbstractBlock.Settings.create() + .mapColor(color) + .instrument(NoteBlockInstrument.BASS) + .strength(2.0f, 3.0f) + .sounds(sounds); + if (flammable) + settings.burnable(); + return settings; + } } diff --git a/src/main/java/fr/hugman/promenade/block/CoiledVinesBlock.java b/src/main/java/fr/hugman/promenade/block/CoiledVinesBlock.java index 9e3ec12e..d4dad92e 100644 --- a/src/main/java/fr/hugman/promenade/block/CoiledVinesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/CoiledVinesBlock.java @@ -1,6 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.VineLogic; @@ -8,37 +20,37 @@ import net.minecraft.util.shape.VoxelShape; public class CoiledVinesBlock extends AbstractFacingPlantStemBlock { - public static final MapCodec CODEC = createCodec(CoiledVinesBlock::new); - public static final VoxelShape[] SHAPES = new VoxelShape[]{ - Block.createCuboidShape(2.0, 2.0, 2.0, 14.0, 16.0, 14.0), // DOWN - Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 14.0, 14.0), // UP - Block.createCuboidShape(2.0, 2.0, 2.0, 14.0, 14.0, 16.0), // NORTH - Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 14.0), // SOUTH - Block.createCuboidShape(2.0, 2.0, 2.0, 16.0, 14.0, 14.0), // WEST - Block.createCuboidShape(0.0, 2.0, 2.0, 14.0, 14.0, 14.0) // EAST - }; - - public CoiledVinesBlock(Settings settings) { - super(settings, SHAPES, false, 0.1); - } - - @Override - protected MapCodec getCodec() { - return CODEC; - } - - @Override - protected Block getPlant() { - return PromenadeBlocks.COILED_VINES_PLANT; - } - - @Override - protected int getGrowthLength(Random random) { - return VineLogic.getGrowthLength(random); - } - - @Override - protected boolean canGrowAt(BlockState state) { - return VineLogic.isValidForWeepingStem(state); - } + public static final MapCodec CODEC = createCodec(CoiledVinesBlock::new); + public static final VoxelShape[] SHAPES = new VoxelShape[]{ + Block.createCuboidShape(2.0, 2.0, 2.0, 14.0, 16.0, 14.0), // DOWN + Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 14.0, 14.0), // UP + Block.createCuboidShape(2.0, 2.0, 2.0, 14.0, 14.0, 16.0), // NORTH + Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 14.0), // SOUTH + Block.createCuboidShape(2.0, 2.0, 2.0, 16.0, 14.0, 14.0), // WEST + Block.createCuboidShape(0.0, 2.0, 2.0, 14.0, 14.0, 14.0) // EAST + }; + + public CoiledVinesBlock(Settings settings) { + super(settings, SHAPES, false, 0.1); + } + + @Override + protected MapCodec getCodec() { + return CODEC; + } + + @Override + protected Block getPlant() { + return PromenadeBlocks.COILED_VINES_PLANT; + } + + @Override + protected int getGrowthLength(Random random) { + return VineLogic.getGrowthLength(random); + } + + @Override + protected boolean canGrowAt(BlockState state) { + return VineLogic.isValidForWeepingStem(state); + } } diff --git a/src/main/java/fr/hugman/promenade/block/CoiledVinesPlantBlock.java b/src/main/java/fr/hugman/promenade/block/CoiledVinesPlantBlock.java index c8762588..083db66c 100644 --- a/src/main/java/fr/hugman/promenade/block/CoiledVinesPlantBlock.java +++ b/src/main/java/fr/hugman/promenade/block/CoiledVinesPlantBlock.java @@ -1,31 +1,43 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; + import net.minecraft.block.Block; import net.minecraft.util.shape.VoxelShape; public class CoiledVinesPlantBlock extends AbstractFacingPlantBlock { - public static final MapCodec CODEC = createCodec(CoiledVinesPlantBlock::new); - public static final VoxelShape[] SHAPES = new VoxelShape[]{ - Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 16.0, 14.0), // DOWN - Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 16.0, 14.0), // UP - Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 16.0), // NORTH - Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 16.0), // SOUTH - Block.createCuboidShape(0.0, 2.0, 2.0, 16.0, 14.0, 14.0), // WEST - Block.createCuboidShape(0.0, 2.0, 2.0, 16.0, 14.0, 14.0) // EAST - }; + public static final MapCodec CODEC = createCodec(CoiledVinesPlantBlock::new); + public static final VoxelShape[] SHAPES = new VoxelShape[]{ + Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 16.0, 14.0), // DOWN + Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 16.0, 14.0), // UP + Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 16.0), // NORTH + Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 16.0), // SOUTH + Block.createCuboidShape(0.0, 2.0, 2.0, 16.0, 14.0, 14.0), // WEST + Block.createCuboidShape(0.0, 2.0, 2.0, 16.0, 14.0, 14.0) // EAST + }; - public CoiledVinesPlantBlock(Settings settings) { - super(settings, SHAPES, false); - } + public CoiledVinesPlantBlock(Settings settings) { + super(settings, SHAPES, false); + } - @Override - protected MapCodec getCodec() { - return CODEC; - } + @Override + protected MapCodec getCodec() { + return CODEC; + } - @Override - protected AbstractFacingPlantStemBlock getStem() { - return (AbstractFacingPlantStemBlock) PromenadeBlocks.COILED_VINES; - } + @Override + protected AbstractFacingPlantStemBlock getStem() { + return (AbstractFacingPlantStemBlock) PromenadeBlocks.COILED_VINES; + } } diff --git a/src/main/java/fr/hugman/promenade/block/ExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/ExtendedLeavesBlock.java index 0458773f..66cf0457 100644 --- a/src/main/java/fr/hugman/promenade/block/ExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/ExtendedLeavesBlock.java @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import net.minecraft.block.*; @@ -24,137 +35,137 @@ import net.minecraft.world.tick.ScheduledTickView; public abstract class ExtendedLeavesBlock extends Block implements Waterloggable { - public static final int MAX_DISTANCE = 14; - public static final IntProperty DISTANCE = IntProperty.of("distance", 1, MAX_DISTANCE); - public static final BooleanProperty PERSISTENT = Properties.PERSISTENT; - public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; - protected final float leafParticleChance; - - public ExtendedLeavesBlock(float leafParticleChance, AbstractBlock.Settings settings) { - super(settings); - this.leafParticleChance = leafParticleChance; - this.setDefaultState(this.stateManager.getDefaultState() - .with(DISTANCE, MAX_DISTANCE) - .with(PERSISTENT, false) - .with(WATERLOGGED, false)); - } - - @Override - protected VoxelShape getSidesShape(BlockState state, BlockView world, BlockPos pos) { - return VoxelShapes.empty(); - } - - @Override - public boolean hasRandomTicks(BlockState state) { - return state.get(DISTANCE) == MAX_DISTANCE && !state.get(PERSISTENT); - } - - @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (this.shouldDecay(state)) { - ExtendedLeavesBlock.dropStacks(state, world, pos); - world.removeBlock(pos, false); - } - } - - protected boolean shouldDecay(BlockState state) { - return !state.get(PERSISTENT) && state.get(DISTANCE) == MAX_DISTANCE; - } - - @Override - public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - world.setBlockState(pos, ExtendedLeavesBlock.updateDistanceFromLogs(state, world, pos), 3); - } - - @Override - protected int getOpacity(BlockState state) { - return 1; - } - - @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - if (state.get(WATERLOGGED)) { - tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - } - - int distance = ExtendedLeavesBlock.getDistanceFromLog(neighborState) + 1; - if (distance != 1 || state.get(DISTANCE) != distance) { - tickView.scheduleBlockTick(pos, this, 1); - } - - return state; - } - - private static BlockState updateDistanceFromLogs(BlockState state, WorldAccess world, BlockPos pos) { - int distance = MAX_DISTANCE; - BlockPos.Mutable mutable = new BlockPos.Mutable(); - - for (Direction direction : Direction.values()) { - mutable.set(pos, direction); - distance = Math.min(distance, ExtendedLeavesBlock.getDistanceFromLog(world.getBlockState(mutable)) + 1); - if (distance == 1) { - break; - } - } - - return state.with(DISTANCE, distance); - } - - private static int getDistanceFromLog(BlockState state) { - if (state.isIn(BlockTags.LOGS)) { - return 0; - } - - Block block = state.getBlock(); - if (block instanceof ExtendedLeavesBlock) { - return state.get(DISTANCE); - } else if (block instanceof LeavesBlock) { - int distance = state.get(LeavesBlock.DISTANCE); - return distance < LeavesBlock.MAX_DISTANCE ? distance : MAX_DISTANCE; - } - - return MAX_DISTANCE; - } - - @Override - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { - super.randomDisplayTick(state, world, pos, random); - BlockPos blockPos = pos.down(); - BlockState blockState = world.getBlockState(blockPos); - spawnWaterParticle(world, pos, random, blockState, blockPos); - this.spawnLeafParticle(world, pos, random, blockState, blockPos); - } - - private static void spawnWaterParticle(World world, BlockPos pos, Random random, BlockState state, BlockPos posBelow) { - if (world.hasRain(pos.up())) { - if (random.nextInt(15) == 1) { - if (!state.isOpaque() || !state.isSideSolidFullSquare(world, posBelow, Direction.UP)) { - ParticleUtil.spawnParticle(world, pos, random, ParticleTypes.DRIPPING_WATER); - } - } - } - } - - private void spawnLeafParticle(World world, BlockPos pos, Random random, BlockState state, BlockPos posBelow) { - if (!(random.nextFloat() >= this.leafParticleChance)) { - if (!isFaceFullSquare(state.getCollisionShape(world, posBelow), Direction.UP)) { - this.spawnLeafParticle(world, pos, random); - } - } - } - - protected abstract void spawnLeafParticle(World world, BlockPos pos, Random random); - - @Override - protected void appendProperties(StateManager.Builder builder) { - builder.add(DISTANCE, PERSISTENT, WATERLOGGED); - } - - @Override - public BlockState getPlacementState(ItemPlacementContext context) { - FluidState fluidState = context.getWorld().getFluidState(context.getBlockPos()); - BlockState blockState = this.getDefaultState().with(PERSISTENT, true).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); - - return ExtendedLeavesBlock.updateDistanceFromLogs(blockState, context.getWorld(), context.getBlockPos()); - } + public static final int MAX_DISTANCE = 14; + public static final IntProperty DISTANCE = IntProperty.of("distance", 1, MAX_DISTANCE); + public static final BooleanProperty PERSISTENT = Properties.PERSISTENT; + public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; + protected final float leafParticleChance; + + public ExtendedLeavesBlock(float leafParticleChance, AbstractBlock.Settings settings) { + super(settings); + this.leafParticleChance = leafParticleChance; + this.setDefaultState(this.stateManager.getDefaultState() + .with(DISTANCE, MAX_DISTANCE) + .with(PERSISTENT, false) + .with(WATERLOGGED, false)); + } + + @Override + protected VoxelShape getSidesShape(BlockState state, BlockView world, BlockPos pos) { + return VoxelShapes.empty(); + } + + @Override + public boolean hasRandomTicks(BlockState state) { + return state.get(DISTANCE) == MAX_DISTANCE && !state.get(PERSISTENT); + } + + @Override + public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + if (this.shouldDecay(state)) { + ExtendedLeavesBlock.dropStacks(state, world, pos); + world.removeBlock(pos, false); + } + } + + protected boolean shouldDecay(BlockState state) { + return !state.get(PERSISTENT) && state.get(DISTANCE) == MAX_DISTANCE; + } + + @Override + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + world.setBlockState(pos, ExtendedLeavesBlock.updateDistanceFromLogs(state, world, pos), 3); + } + + @Override + protected int getOpacity(BlockState state) { + return 1; + } + + @Override + protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { + if (state.get(WATERLOGGED)) { + tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + + int distance = ExtendedLeavesBlock.getDistanceFromLog(neighborState) + 1; + if (distance != 1 || state.get(DISTANCE) != distance) { + tickView.scheduleBlockTick(pos, this, 1); + } + + return state; + } + + private static BlockState updateDistanceFromLogs(BlockState state, WorldAccess world, BlockPos pos) { + int distance = MAX_DISTANCE; + BlockPos.Mutable mutable = new BlockPos.Mutable(); + + for (Direction direction : Direction.values()) { + mutable.set(pos, direction); + distance = Math.min(distance, ExtendedLeavesBlock.getDistanceFromLog(world.getBlockState(mutable)) + 1); + if (distance == 1) { + break; + } + } + + return state.with(DISTANCE, distance); + } + + private static int getDistanceFromLog(BlockState state) { + if (state.isIn(BlockTags.LOGS)) { + return 0; + } + + Block block = state.getBlock(); + if (block instanceof ExtendedLeavesBlock) { + return state.get(DISTANCE); + } else if (block instanceof LeavesBlock) { + int distance = state.get(LeavesBlock.DISTANCE); + return distance < LeavesBlock.MAX_DISTANCE ? distance : MAX_DISTANCE; + } + + return MAX_DISTANCE; + } + + @Override + public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + super.randomDisplayTick(state, world, pos, random); + BlockPos blockPos = pos.down(); + BlockState blockState = world.getBlockState(blockPos); + spawnWaterParticle(world, pos, random, blockState, blockPos); + this.spawnLeafParticle(world, pos, random, blockState, blockPos); + } + + private static void spawnWaterParticle(World world, BlockPos pos, Random random, BlockState state, BlockPos posBelow) { + if (world.hasRain(pos.up())) { + if (random.nextInt(15) == 1) { + if (!state.isOpaque() || !state.isSideSolidFullSquare(world, posBelow, Direction.UP)) { + ParticleUtil.spawnParticle(world, pos, random, ParticleTypes.DRIPPING_WATER); + } + } + } + } + + private void spawnLeafParticle(World world, BlockPos pos, Random random, BlockState state, BlockPos posBelow) { + if (!(random.nextFloat() >= this.leafParticleChance)) { + if (!isFaceFullSquare(state.getCollisionShape(world, posBelow), Direction.UP)) { + this.spawnLeafParticle(world, pos, random); + } + } + } + + protected abstract void spawnLeafParticle(World world, BlockPos pos, Random random); + + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(DISTANCE, PERSISTENT, WATERLOGGED); + } + + @Override + public BlockState getPlacementState(ItemPlacementContext context) { + FluidState fluidState = context.getWorld().getFluidState(context.getBlockPos()); + BlockState blockState = this.getDefaultState().with(PERSISTENT, true).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); + + return ExtendedLeavesBlock.updateDistanceFromLogs(blockState, context.getWorld(), context.getBlockPos()); + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/FungusBlock.java b/src/main/java/fr/hugman/promenade/block/FungusBlock.java index c3b70b41..55dcb7d6 100644 --- a/src/main/java/fr/hugman/promenade/block/FungusBlock.java +++ b/src/main/java/fr/hugman/promenade/block/FungusBlock.java @@ -1,5 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; +import java.util.function.Predicate; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.registry.RegistryKey; @@ -9,29 +22,27 @@ import net.minecraft.world.WorldView; import net.minecraft.world.gen.feature.ConfiguredFeature; -import java.util.function.Predicate; - public class FungusBlock extends net.minecraft.block.FungusBlock { - private final Predicate canPlantOn; - private final Predicate canGrowOn; + private final Predicate canPlantOn; + private final Predicate canGrowOn; - public FungusBlock(RegistryKey> featureKey, TagKey canPlantOn, TagKey canGrowOn, Settings settings) { - this(featureKey, s -> s.isIn(canPlantOn), s -> s.isIn(canGrowOn), settings); - } + public FungusBlock(RegistryKey> featureKey, TagKey canPlantOn, TagKey canGrowOn, Settings settings) { + this(featureKey, s -> s.isIn(canPlantOn), s -> s.isIn(canGrowOn), settings); + } - public FungusBlock(RegistryKey> featureKey, Predicate canPlantOn, Predicate canGrowOn, Settings settings) { - super(featureKey, null, settings); - this.canPlantOn = canPlantOn; - this.canGrowOn = canGrowOn; - } + public FungusBlock(RegistryKey> featureKey, Predicate canPlantOn, Predicate canGrowOn, Settings settings) { + super(featureKey, null, settings); + this.canPlantOn = canPlantOn; + this.canGrowOn = canGrowOn; + } - @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - return this.canGrowOn.test(world.getBlockState(pos.down())); - } + @Override + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { + return this.canGrowOn.test(world.getBlockState(pos.down())); + } - @Override - protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { - return this.canPlantOn.test(floor); - } + @Override + protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + return this.canPlantOn.test(floor); + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/HangingLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/HangingLeavesBlock.java index c2551b78..53578e8e 100644 --- a/src/main/java/fr/hugman/promenade/block/HangingLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/HangingLeavesBlock.java @@ -1,6 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.*; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; @@ -16,65 +29,64 @@ import net.minecraft.world.BlockView; import net.minecraft.world.WorldView; import net.minecraft.world.tick.ScheduledTickView; -import org.jetbrains.annotations.Nullable; public class HangingLeavesBlock extends Block implements Waterloggable { - private static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; - protected static final VoxelShape SHAPE = Block.createCuboidShape(2.0, 10.0, 2.0, 14.0, 16.0, 14.0); - public static final MapCodec CODEC = createCodec(HangingLeavesBlock::new); + private static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; + protected static final VoxelShape SHAPE = Block.createCuboidShape(2.0, 10.0, 2.0, 14.0, 16.0, 14.0); + public static final MapCodec CODEC = createCodec(HangingLeavesBlock::new); - public HangingLeavesBlock(AbstractBlock.Settings settings) { - super(settings); - this.setDefaultState(this.stateManager.getDefaultState().with(WATERLOGGED, false)); - } + public HangingLeavesBlock(AbstractBlock.Settings settings) { + super(settings); + this.setDefaultState(this.stateManager.getDefaultState().with(WATERLOGGED, false)); + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } - @Override - protected void appendProperties(StateManager.Builder builder) { - builder.add(WATERLOGGED); - } + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(WATERLOGGED); + } - @Override - public FluidState getFluidState(BlockState state) { - return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); - } + @Override + public FluidState getFluidState(BlockState state) { + return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + } - @Nullable - @Override - public BlockState getPlacementState(ItemPlacementContext ctx) { - BlockState blockState = super.getPlacementState(ctx); - if (blockState != null) { - FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); - return blockState.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); - } else { - return null; - } - } + @Nullable + @Override + public BlockState getPlacementState(ItemPlacementContext ctx) { + BlockState blockState = super.getPlacementState(ctx); + if (blockState != null) { + FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); + return blockState.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); + } else { + return null; + } + } - @Override - public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockPos blockPos = pos.up(); - BlockState blockState = world.getBlockState(blockPos); - return (blockState.isIn(BlockTags.LEAVES) && blockState.isSolid()) || blockState.isSideSolidFullSquare(world, blockPos, Direction.DOWN); - } + @Override + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + BlockPos blockPos = pos.up(); + BlockState blockState = world.getBlockState(blockPos); + return (blockState.isIn(BlockTags.LEAVES) && blockState.isSolid()) || blockState.isSideSolidFullSquare(world, blockPos, Direction.DOWN); + } - @Override - public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - return SHAPE; - } + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + return SHAPE; + } - @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - if (direction == Direction.UP && !this.canPlaceAt(state, world, pos)) { - return Blocks.AIR.getDefaultState(); - } - if (state.get(WATERLOGGED)) { - tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - } - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); - } + @Override + protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { + if (direction == Direction.UP && !this.canPlaceAt(state, world, pos)) { + return Blocks.AIR.getDefaultState(); + } + if (state.get(WATERLOGGED)) { + tickView.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); + } } diff --git a/src/main/java/fr/hugman/promenade/block/MapleLogBlock.java b/src/main/java/fr/hugman/promenade/block/MapleLogBlock.java index 51e2e841..d49add32 100644 --- a/src/main/java/fr/hugman/promenade/block/MapleLogBlock.java +++ b/src/main/java/fr/hugman/promenade/block/MapleLogBlock.java @@ -1,30 +1,43 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import fr.hugman.promenade.block.property.PromenadeBlockProperties; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.PillarBlock; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; +import fr.hugman.promenade.block.property.PromenadeBlockProperties; + public class MapleLogBlock extends PillarBlock { - public static final BooleanProperty NATURAL = PromenadeBlockProperties.NATURAL; - public static final MapCodec CODEC = createCodec(MapleLogBlock::new); + public static final BooleanProperty NATURAL = PromenadeBlockProperties.NATURAL; + public static final MapCodec CODEC = createCodec(MapleLogBlock::new); - public MapleLogBlock(Settings settings) { - super(settings); - this.setDefaultState(this.getDefaultState().with(NATURAL, false)); - } + public MapleLogBlock(Settings settings) { + super(settings); + this.setDefaultState(this.getDefaultState().with(NATURAL, false)); + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(NATURAL); - } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(NATURAL); + } } diff --git a/src/main/java/fr/hugman/promenade/block/MoaiBlock.java b/src/main/java/fr/hugman/promenade/block/MoaiBlock.java index 4ec7350c..90b306d1 100644 --- a/src/main/java/fr/hugman/promenade/block/MoaiBlock.java +++ b/src/main/java/fr/hugman/promenade/block/MoaiBlock.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import fr.hugman.promenade.block.property.PromenadeBlockProperties; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.HorizontalFacingBlock; @@ -16,90 +28,91 @@ import net.minecraft.world.World; import net.minecraft.world.WorldView; import net.minecraft.world.tick.ScheduledTickView; -import org.jetbrains.annotations.Nullable; + +import fr.hugman.promenade.block.property.PromenadeBlockProperties; public class MoaiBlock extends HorizontalFacingBlock { - public static final MapCodec CODEC = createCodec(MoaiBlock::new); - public static final EnumProperty TYPE = PromenadeBlockProperties.MOAI_TYPE; - - public MoaiBlock(Settings settings) { - super(settings); - this.setDefaultState(this.stateManager.getDefaultState().with(TYPE, MoaiType.SINGLE).with(FACING, Direction.NORTH)); - } - - @Override - protected MapCodec getCodec() { - return CODEC; - } - - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(TYPE, FACING); - } - - @Override - public BlockState getPlacementState(ItemPlacementContext context) { - var world = context.getWorld(); - boolean sneaking = context.shouldCancelInteraction(); // stupid yarn name - var direction = context.getHorizontalPlayerFacing().getOpposite(); - var hitSide = context.getSide(); - - var posBelow = context.getBlockPos().down(); - var posAbove = context.getBlockPos().up(); - - boolean mergeWithBelow = isSingleMoai(direction, world.getBlockState(posBelow)); - boolean mergeWithAbove = isSingleMoai(direction, world.getBlockState(posAbove)); - - if (sneaking) { - mergeWithBelow = false; - mergeWithAbove = false; - } - - if (mergeWithBelow && mergeWithAbove) { - if (hitSide == Direction.DOWN) { - mergeWithBelow = false; - } else if (hitSide == Direction.UP) { - mergeWithAbove = false; - } - } - - if (mergeWithBelow) { - return this.getDefaultState().with(TYPE, MoaiType.TOP).with(FACING, direction); - } else if (mergeWithAbove) { - return this.getDefaultState().with(TYPE, MoaiType.BOTTOM).with(FACING, direction); - } else { - return this.getDefaultState().with(TYPE, MoaiType.SINGLE).with(FACING, direction); - } - } - - @Override - public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { - super.onPlaced(world, pos, state, placer, itemStack); - var type = state.get(TYPE); - var direction = state.get(FACING); - var posBelow = pos.down(); - var posAbove = pos.up(); - - if (isSingleMoai(direction, world.getBlockState(posBelow)) && type == MoaiType.TOP) { - world.setBlockState(posBelow, world.getBlockState(posBelow).with(TYPE, MoaiType.BOTTOM), Block.NOTIFY_ALL); - } else if (isSingleMoai(direction, world.getBlockState(posAbove)) && type == MoaiType.BOTTOM) { - world.setBlockState(posAbove, world.getBlockState(posAbove).with(TYPE, MoaiType.TOP), Block.NOTIFY_ALL); - } - } - - @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - var type = state.get(TYPE); - if ((type == MoaiType.TOP && direction == Direction.DOWN) || (type == MoaiType.BOTTOM && direction == Direction.UP)) { - if (!(neighborState.isOf(this) && neighborState.get(TYPE) == (type == MoaiType.TOP ? MoaiType.BOTTOM : MoaiType.TOP))) { - return state.with(TYPE, MoaiType.SINGLE); - } - } - return state; - } - - public boolean isSingleMoai(Direction direction, BlockState state) { - return state.isOf(this) && state.get(TYPE) == MoaiType.SINGLE && state.get(FACING) == direction; - } + public static final MapCodec CODEC = createCodec(MoaiBlock::new); + public static final EnumProperty TYPE = PromenadeBlockProperties.MOAI_TYPE; + + public MoaiBlock(Settings settings) { + super(settings); + this.setDefaultState(this.stateManager.getDefaultState().with(TYPE, MoaiType.SINGLE).with(FACING, Direction.NORTH)); + } + + @Override + protected MapCodec getCodec() { + return CODEC; + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(TYPE, FACING); + } + + @Override + public BlockState getPlacementState(ItemPlacementContext context) { + var world = context.getWorld(); + boolean sneaking = context.shouldCancelInteraction(); // stupid yarn name + var direction = context.getHorizontalPlayerFacing().getOpposite(); + var hitSide = context.getSide(); + + var posBelow = context.getBlockPos().down(); + var posAbove = context.getBlockPos().up(); + + boolean mergeWithBelow = isSingleMoai(direction, world.getBlockState(posBelow)); + boolean mergeWithAbove = isSingleMoai(direction, world.getBlockState(posAbove)); + + if (sneaking) { + mergeWithBelow = false; + mergeWithAbove = false; + } + + if (mergeWithBelow && mergeWithAbove) { + if (hitSide == Direction.DOWN) { + mergeWithBelow = false; + } else if (hitSide == Direction.UP) { + mergeWithAbove = false; + } + } + + if (mergeWithBelow) { + return this.getDefaultState().with(TYPE, MoaiType.TOP).with(FACING, direction); + } else if (mergeWithAbove) { + return this.getDefaultState().with(TYPE, MoaiType.BOTTOM).with(FACING, direction); + } else { + return this.getDefaultState().with(TYPE, MoaiType.SINGLE).with(FACING, direction); + } + } + + @Override + public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { + super.onPlaced(world, pos, state, placer, itemStack); + var type = state.get(TYPE); + var direction = state.get(FACING); + var posBelow = pos.down(); + var posAbove = pos.up(); + + if (isSingleMoai(direction, world.getBlockState(posBelow)) && type == MoaiType.TOP) { + world.setBlockState(posBelow, world.getBlockState(posBelow).with(TYPE, MoaiType.BOTTOM), Block.NOTIFY_ALL); + } else if (isSingleMoai(direction, world.getBlockState(posAbove)) && type == MoaiType.BOTTOM) { + world.setBlockState(posAbove, world.getBlockState(posAbove).with(TYPE, MoaiType.TOP), Block.NOTIFY_ALL); + } + } + + @Override + protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { + var type = state.get(TYPE); + if ((type == MoaiType.TOP && direction == Direction.DOWN) || (type == MoaiType.BOTTOM && direction == Direction.UP)) { + if (!(neighborState.isOf(this) && neighborState.get(TYPE) == (type == MoaiType.TOP ? MoaiType.BOTTOM : MoaiType.TOP))) { + return state.with(TYPE, MoaiType.SINGLE); + } + } + return state; + } + + public boolean isSingleMoai(Direction direction, BlockState state) { + return state.isOf(this) && state.get(TYPE) == MoaiType.SINGLE && state.get(FACING) == direction; + } } diff --git a/src/main/java/fr/hugman/promenade/block/MoaiType.java b/src/main/java/fr/hugman/promenade/block/MoaiType.java index c87cfd79..55d40988 100644 --- a/src/main/java/fr/hugman/promenade/block/MoaiType.java +++ b/src/main/java/fr/hugman/promenade/block/MoaiType.java @@ -1,20 +1,31 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import net.minecraft.util.StringIdentifiable; public enum MoaiType implements StringIdentifiable { - SINGLE("single"), - TOP("top"), - BOTTOM("bottom"); + SINGLE("single"), + TOP("top"), + BOTTOM("bottom"); - private final String name; + private final String name; - MoaiType(String name) { - this.name = name; - } + MoaiType(String name) { + this.name = name; + } - @Override - public String asString() { - return this.name; - } + @Override + public String asString() { + return this.name; + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/NyliumBlock.java b/src/main/java/fr/hugman/promenade/block/NyliumBlock.java index 1ba4d29c..d4ef9a30 100644 --- a/src/main/java/fr/hugman/promenade/block/NyliumBlock.java +++ b/src/main/java/fr/hugman/promenade/block/NyliumBlock.java @@ -1,7 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -19,65 +30,67 @@ import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.ConfiguredFeature; +import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; + public class NyliumBlock extends Block implements Fertilizable { - public static final MapCodec CODEC = createCodec(NyliumBlock::new); + public static final MapCodec CODEC = createCodec(NyliumBlock::new); - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } - public NyliumBlock(Settings settings) { - super(settings); - } + public NyliumBlock(Settings settings) { + super(settings); + } - private static boolean stayAlive(BlockState state, WorldView world, BlockPos pos) { - BlockPos blockPos = pos.up(); - BlockState blockState = world.getBlockState(blockPos); - int i = ChunkLightProvider.getRealisticOpacity(state, blockState, Direction.UP, blockState.getOpacity()); - return i < 15; - } + private static boolean stayAlive(BlockState state, WorldView world, BlockPos pos) { + BlockPos blockPos = pos.up(); + BlockState blockState = world.getBlockState(blockPos); + int i = ChunkLightProvider.getRealisticOpacity(state, blockState, Direction.UP, blockState.getOpacity()); + return i < 15; + } - @Override - protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (!stayAlive(state, world, pos)) { - //TODO: make this configurable - world.setBlockState(pos, Blocks.NETHERRACK.getDefaultState()); - } - } + @Override + protected void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + if (!stayAlive(state, world, pos)) { + //TODO: make this configurable + world.setBlockState(pos, Blocks.NETHERRACK.getDefaultState()); + } + } - @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { - return world.getBlockState(pos.up()).isAir(); - } + @Override + public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) { + return world.getBlockState(pos.up()).isAir(); + } - @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { - return true; - } + @Override + public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + return true; + } - @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { - BlockPos blockPos = pos.up(); - ChunkGenerator chunkGenerator = world.getChunkManager().getChunkGenerator(); - Registry> registry = world.getRegistryManager().getOrThrow(RegistryKeys.CONFIGURED_FEATURE); - //TODO: make this configurable - this.generate(registry, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION, world, chunkGenerator, random, blockPos); - } + @Override + public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + BlockPos blockPos = pos.up(); + ChunkGenerator chunkGenerator = world.getChunkManager().getChunkGenerator(); + Registry> registry = world.getRegistryManager().getOrThrow(RegistryKeys.CONFIGURED_FEATURE); + //TODO: make this configurable + this.generate(registry, PromenadeConfiguredFeatures.DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION, world, chunkGenerator, random, blockPos); + } - private void generate( - Registry> registry, - RegistryKey> key, - ServerWorld world, - ChunkGenerator chunkGenerator, - Random random, - BlockPos pos - ) { - registry.getOptional(key).ifPresent(entry -> entry.value().generate(world, chunkGenerator, random, pos)); - } + private void generate( + Registry> registry, + RegistryKey> key, + ServerWorld world, + ChunkGenerator chunkGenerator, + Random random, + BlockPos pos + ) { + registry.getOptional(key).ifPresent(entry -> entry.value().generate(world, chunkGenerator, random, pos)); + } - @Override - public FertilizableType getFertilizableType() { - return FertilizableType.NEIGHBOR_SPREADER; - } + @Override + public FertilizableType getFertilizableType() { + return FertilizableType.NEIGHBOR_SPREADER; + } } diff --git a/src/main/java/fr/hugman/promenade/block/PileBlock.java b/src/main/java/fr/hugman/promenade/block/PileBlock.java index b9c51e36..e60aaddd 100644 --- a/src/main/java/fr/hugman/promenade/block/PileBlock.java +++ b/src/main/java/fr/hugman/promenade/block/PileBlock.java @@ -1,6 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; + import net.minecraft.block.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -11,37 +23,37 @@ import net.minecraft.world.tick.ScheduledTickView; public class PileBlock extends PlantBlock { - public static final MapCodec CODEC = createCodec(PileBlock::new); - protected static final VoxelShape SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D); - - public PileBlock(Settings settings) { - super(settings); - } - - @Override - protected MapCodec getCodec() { - return CODEC; - } - - @Override - public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) { - return SHAPE; - } - - @Override - protected int getOpacity(BlockState state) { - return 1; - } - - @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); - } - - @Override - public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - BlockPos blockpos = pos.offset(Direction.DOWN); - BlockState blockState = world.getBlockState(blockpos); - return Block.isFaceFullSquare(blockState.getCollisionShape(world, blockpos), Direction.UP); - } + public static final MapCodec CODEC = createCodec(PileBlock::new); + protected static final VoxelShape SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D); + + public PileBlock(Settings settings) { + super(settings); + } + + @Override + protected MapCodec getCodec() { + return CODEC; + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) { + return SHAPE; + } + + @Override + protected int getOpacity(BlockState state) { + return 1; + } + + @Override + protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { + return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random); + } + + @Override + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + BlockPos blockpos = pos.offset(Direction.DOWN); + BlockState blockState = world.getBlockState(blockpos); + return Block.isFaceFullSquare(blockState.getCollisionShape(world, blockpos), Direction.UP); + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/PromenadeBlockTypes.java b/src/main/java/fr/hugman/promenade/block/PromenadeBlockTypes.java index b427e11d..bd585127 100644 --- a/src/main/java/fr/hugman/promenade/block/PromenadeBlockTypes.java +++ b/src/main/java/fr/hugman/promenade/block/PromenadeBlockTypes.java @@ -1,28 +1,41 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import fr.hugman.promenade.Promenade; + import net.minecraft.block.Block; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import fr.hugman.promenade.Promenade; + public class PromenadeBlockTypes { - public static final MapCodec BERRY_BUSH = of("berry_bush", BerryBushBlock.CODEC); - public static final MapCodec MOAI = of("moai", MoaiBlock.CODEC); - public static final MapCodec HANGING_LEAVES = of("hanging_leaves", HangingLeavesBlock.CODEC); - public static final MapCodec MAPLE_LOG = of("maple_log", MapleLogBlock.CODEC); - public static final MapCodec PILE = of("pile", PileBlock.CODEC); - public static final MapCodec UNTINTED_PARTICLE_SNOWY_LEAVES = of("untinted_particle_snowy_leaves", UntintedParticleSnowyLeavesBlock.CODEC); - public static final MapCodec TINTED_PARTICLE_SNOWY_LEAVES = of("tinted_particle_snowy_leaves", TintedParticleSnowyLeavesBlock.CODEC); - public static final MapCodec UNTINTED_PARTICLE_EXTENDED_LEAVES = of("untinted_particle_extended_leaves", UntintedParticleExtendedLeavesBlock.CODEC); - public static final MapCodec TINTED_PARTICLE_EXTENDED_LEAVES = of("tinted_particle_extended_leaves", TintedParticleExtendedLeavesBlock.CODEC); - public static final MapCodec UNTINTED_PARTICLE_SNOWY_EXTENDED_LEAVES = of("untinted_particle_snowy_extended_leaves", UntintedParticleSnowyExtendedLeavesBlock.CODEC); - public static final MapCodec TINTED_PARTICLE_SNOWY_EXTENDED_LEAVES = of("tinted_particle_snowy_extended_leaves", TintedParticleSnowyExtendedLeavesBlock.CODEC); - public static final MapCodec STRIPPED_MAPLE_LOG = of("stripped_maple_log", StrippedMapleLogBlock.CODEC); - public static final MapCodec WITHER_ROSE_PILE = of("wither_rose_pile", WitherRosePileBlock.CODEC); - public static final MapCodec NYLIUM = of("nylium", NyliumBlock.CODEC); + public static final MapCodec BERRY_BUSH = of("berry_bush", BerryBushBlock.CODEC); + public static final MapCodec MOAI = of("moai", MoaiBlock.CODEC); + public static final MapCodec HANGING_LEAVES = of("hanging_leaves", HangingLeavesBlock.CODEC); + public static final MapCodec MAPLE_LOG = of("maple_log", MapleLogBlock.CODEC); + public static final MapCodec PILE = of("pile", PileBlock.CODEC); + public static final MapCodec UNTINTED_PARTICLE_SNOWY_LEAVES = of("untinted_particle_snowy_leaves", UntintedParticleSnowyLeavesBlock.CODEC); + public static final MapCodec TINTED_PARTICLE_SNOWY_LEAVES = of("tinted_particle_snowy_leaves", TintedParticleSnowyLeavesBlock.CODEC); + public static final MapCodec UNTINTED_PARTICLE_EXTENDED_LEAVES = of("untinted_particle_extended_leaves", UntintedParticleExtendedLeavesBlock.CODEC); + public static final MapCodec TINTED_PARTICLE_EXTENDED_LEAVES = of("tinted_particle_extended_leaves", TintedParticleExtendedLeavesBlock.CODEC); + public static final MapCodec UNTINTED_PARTICLE_SNOWY_EXTENDED_LEAVES = of("untinted_particle_snowy_extended_leaves", UntintedParticleSnowyExtendedLeavesBlock.CODEC); + public static final MapCodec TINTED_PARTICLE_SNOWY_EXTENDED_LEAVES = of("tinted_particle_snowy_extended_leaves", TintedParticleSnowyExtendedLeavesBlock.CODEC); + public static final MapCodec STRIPPED_MAPLE_LOG = of("stripped_maple_log", StrippedMapleLogBlock.CODEC); + public static final MapCodec WITHER_ROSE_PILE = of("wither_rose_pile", WitherRosePileBlock.CODEC); + public static final MapCodec NYLIUM = of("nylium", NyliumBlock.CODEC); - private static MapCodec of(String path, MapCodec blockType) { - return Registry.register(Registries.BLOCK_TYPE, Promenade.id(path), blockType); - } + private static MapCodec of(String path, MapCodec blockType) { + return Registry.register(Registries.BLOCK_TYPE, Promenade.id(path), blockType); + } } diff --git a/src/main/java/fr/hugman/promenade/block/PromenadeBlocks.java b/src/main/java/fr/hugman/promenade/block/PromenadeBlocks.java index dfcc16aa..911b9be7 100644 --- a/src/main/java/fr/hugman/promenade/block/PromenadeBlocks.java +++ b/src/main/java/fr/hugman/promenade/block/PromenadeBlocks.java @@ -1,17 +1,16 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.block.helper.BlockBuilder; -import fr.hugman.promenade.block.helper.BlockFactory; -import fr.hugman.promenade.block.map_color.PromenadeMapColors; -import fr.hugman.promenade.block.type.PromenadeBlockSetTypes; -import fr.hugman.promenade.block.type.PromenadeWoodTypes; -import fr.hugman.promenade.item.PromenadeItemKeys; -import fr.hugman.promenade.particle.PromenadeParticleTypes; -import fr.hugman.promenade.sound.PromenadeBlockSounds; -import fr.hugman.promenade.tag.PromenadeBlockTags; -import fr.hugman.promenade.world.PromenadeSaplingGenerators; -import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.Blocks; @@ -25,278 +24,291 @@ import net.minecraft.registry.tag.BlockTags; import net.minecraft.sound.BlockSoundGroup; +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.block.helper.BlockBuilder; +import fr.hugman.promenade.block.helper.BlockFactory; +import fr.hugman.promenade.block.map_color.PromenadeMapColors; +import fr.hugman.promenade.block.type.PromenadeBlockSetTypes; +import fr.hugman.promenade.block.type.PromenadeWoodTypes; +import fr.hugman.promenade.item.PromenadeItemKeys; +import fr.hugman.promenade.particle.PromenadeParticleTypes; +import fr.hugman.promenade.sound.PromenadeBlockSounds; +import fr.hugman.promenade.tag.PromenadeBlockTags; +import fr.hugman.promenade.world.PromenadeSaplingGenerators; +import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; + public class PromenadeBlocks { - /* ========= */ - /* ROCKS */ - /* ========= */ - public static final Block ASPHALT = register("asphalt", BlockFactory.of(BlockSettings.rock(MapColor.DEEPSLATE_GRAY, BlockSoundGroup.BASALT))); - public static final Block ASPHALT_SLAB = register("asphalt_slab", BlockFactory.slab(ASPHALT)); - public static final Block ASPHALT_STAIRS = register("asphalt_stairs", BlockFactory.stairs(ASPHALT)); - public static final Block ASPHALT_WALL = register("asphalt_wall", BlockFactory.wall(ASPHALT)); - - public static final Block POLISHED_ASPHALT = register("polished_asphalt", BlockFactory.copy(ASPHALT)); - public static final Block POLISHED_ASPHALT_SLAB = register("polished_asphalt_slab", BlockFactory.slab(POLISHED_ASPHALT)); - public static final Block POLISHED_ASPHALT_STAIRS = register("polished_asphalt_stairs", BlockFactory.stairs(POLISHED_ASPHALT)); - - public static final Block BLUNITE = register("blunite", BlockFactory.of(BlockSettings.rock(MapColor.TERRACOTTA_CYAN, BlockSoundGroup.TUFF))); - public static final Block BLUNITE_SLAB = register("blunite_slab", BlockFactory.slab(BLUNITE)); - public static final Block BLUNITE_STAIRS = register("blunite_stairs", BlockFactory.stairs(BLUNITE)); - public static final Block BLUNITE_WALL = register("blunite_wall", BlockFactory.wall(BLUNITE)); - - public static final Block POLISHED_BLUNITE = register("polished_blunite", BlockFactory.copy(BLUNITE)); - public static final Block POLISHED_BLUNITE_SLAB = register("polished_blunite_slab", BlockFactory.slab(POLISHED_BLUNITE)); - public static final Block POLISHED_BLUNITE_STAIRS = register("polished_blunite_stairs", BlockFactory.stairs(POLISHED_BLUNITE)); - - - /* ================= */ - /* VANILLA PILES */ - /* ================= */ - public static final Block OAK_LEAF_PILE = register("oak_leaf_pile", BlockFactory.pile()); - public static final Block SPRUCE_LEAF_PILE = register("spruce_leaf_pile", BlockFactory.pile()); - public static final Block BIRCH_LEAF_PILE = register("birch_leaf_pile", BlockFactory.pile()); - public static final Block JUNGLE_LEAF_PILE = register("jungle_leaf_pile", BlockFactory.pile()); - public static final Block ACACIA_LEAF_PILE = register("acacia_leaf_pile", BlockFactory.pile()); - public static final Block CHERRY_LEAF_PILE = register("cherry_leaf_pile", BlockFactory.pile(MapColor.PINK).settings(s -> s.sounds(BlockSoundGroup.CHERRY_LEAVES))); - public static final Block DARK_OAK_LEAF_PILE = register("dark_oak_leaf_pile", BlockFactory.pile()); - public static final Block PALE_OAK_LEAF_PILE = register("pale_oak_leaf_pile", BlockFactory.pile()); - public static final Block MANGROVE_LEAF_PILE = register("mangrove_leaf_pile", BlockFactory.pile()); - public static final Block AZALEA_LEAF_PILE = register("azalea_leaf_pile", BlockFactory.pile().settings(s -> s.sounds(BlockSoundGroup.AZALEA_LEAVES))); - public static final Block FLOWERING_AZALEA_LEAF_PILE = register("flowering_azalea_leaf_pile", BlockFactory.pile().settings(s -> s.sounds(BlockSoundGroup.AZALEA_LEAVES))); - - public static final Block DANDELION_PILE = register("dandelion_pile", BlockFactory.pile(MapColor.GOLD)); - public static final Block POPPY_PILE = register("poppy_pile", BlockFactory.pile(MapColor.DULL_RED)); - public static final Block BLUE_ORCHID_PILE = register("blue_orchid_pile", BlockFactory.pile(MapColor.LIGHT_BLUE)); - public static final Block ALLIUM_PILE = register("allium_pile", BlockFactory.pile(MapColor.MAGENTA)); - public static final Block AZURE_BLUET_PILE = register("azure_bluet_pile", BlockFactory.pile(MapColor.PALE_YELLOW)); - public static final Block RED_TULIP_PILE = register("red_tulip_pile", BlockFactory.pile(MapColor.DULL_RED)); - public static final Block ORANGE_TULIP_PILE = register("orange_tulip_pile", BlockFactory.pile(MapColor.ORANGE)); - public static final Block WHITE_TULIP_PILE = register("white_tulip_pile", BlockFactory.pile(MapColor.WHITE)); - public static final Block PINK_TULIP_PILE = register("pink_tulip_pile", BlockFactory.pile(MapColor.PINK)); - public static final Block OXEYE_DAISY_PILE = register("oxeye_daisy_pile", BlockFactory.pile(MapColor.GOLD)); - public static final Block CORNFLOWER_PILE = register("cornflower_pile", BlockFactory.pile(MapColor.LAPIS_BLUE)); - public static final Block LILY_OF_THE_VALLEY_PILE = register("lily_of_the_valley_pile", BlockFactory.pile(MapColor.WHITE)); - public static final Block WITHER_ROSE_PILE = register("wither_rose_pile", BlockFactory.pile(MapColor.BLACK).factory(WitherRosePileBlock::new)); - - - /* ======================== */ - /* VANILLA SNOWY LEAVES */ - /* ======================== */ - public static final Block SNOWY_OAK_LEAVES = register("snowy_oak_leaves", BlockFactory.snowyLeaves()); - public static final Block SNOWY_SPRUCE_LEAVES = register("snowy_spruce_leaves", BlockFactory.snowyLeaves()); - public static final Block SNOWY_BIRCH_LEAVES = register("snowy_birch_leaves", BlockFactory.snowyLeaves()); - public static final Block SNOWY_JUNGLE_LEAVES = register("snowy_jungle_leaves", BlockFactory.snowyLeaves()); - public static final Block SNOWY_ACACIA_LEAVES = register("snowy_acacia_leaves", BlockFactory.snowyLeaves()); - public static final Block SNOWY_CHERRY_LEAVES = register("snowy_cherry_leaves", BlockFactory.snowyLeaves(0.1f, ParticleTypes.CHERRY_LEAVES, PromenadeBlockSounds.SNOWY_CHERRY_LEAVES)); - public static final Block SNOWY_DARK_OAK_LEAVES = register("snowy_dark_oak_leaves", BlockFactory.snowyLeaves()); - public static final Block SNOWY_PALE_OAK_LEAVES = register("snowy_pale_oak_leaves", BlockFactory.snowyLeaves(0.02F, ParticleTypes.PALE_OAK_LEAVES)); - public static final Block SNOWY_MANGROVE_LEAVES = register("snowy_mangrove_leaves", BlockFactory.snowyLeaves()); - public static final Block SNOWY_AZALEA_LEAVES = register("snowy_azalea_leaves", BlockFactory.snowyLeaves(PromenadeBlockSounds.SNOWY_AZALEA_LEAVES)); - public static final Block SNOWY_FLOWERING_AZALEA_LEAVES = register("snowy_flowering_azalea_leaves", BlockFactory.snowyLeaves(PromenadeBlockSounds.SNOWY_AZALEA_LEAVES)); - - - /* ========== */ - /* SAKURA */ - /* ========== */ - public static final Block SAKURA_LOG = register("sakura_log", BlockFactory.log(PromenadeMapColors.SAKURA_WOOD, PromenadeMapColors.SAKURA_BARK, PromenadeBlockSounds.SAKURA_WOOD, true)); - public static final Block STRIPPED_SAKURA_LOG = register("stripped_sakura_log", BlockFactory.log(PromenadeMapColors.SAKURA_WOOD, PromenadeBlockSounds.SAKURA_WOOD, true)); - public static final Block SAKURA_WOOD = register("sakura_wood", BlockFactory.log(PromenadeMapColors.SAKURA_BARK, PromenadeBlockSounds.SAKURA_WOOD, true)); - public static final Block STRIPPED_SAKURA_WOOD = register("stripped_sakura_wood", BlockFactory.log(PromenadeMapColors.SAKURA_WOOD, PromenadeBlockSounds.SAKURA_WOOD, true)); - - public static final Block SAKURA_PLANKS = register("sakura_planks", BlockFactory.of(BlockSettings.planks(PromenadeMapColors.SAKURA_WOOD, PromenadeBlockSounds.SAKURA_WOOD, true))); - public static final Block SAKURA_STAIRS = register("sakura_stairs", BlockFactory.stairs(SAKURA_PLANKS)); - public static final Block SAKURA_SLAB = register("sakura_slab", BlockFactory.slab(SAKURA_PLANKS)); - public static final Block SAKURA_FENCE = register("sakura_fence", BlockFactory.fence(SAKURA_PLANKS)); - public static final Block SAKURA_FENCE_GATE = register("sakura_fence_gate", BlockFactory.fenceGate(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA)); - public static final Block SAKURA_DOOR = register("sakura_door", BlockFactory.door(SAKURA_PLANKS, PromenadeBlockSetTypes.SAKURA)); - public static final Block SAKURA_TRAPDOOR = register("sakura_trapdoor", BlockFactory.trapdoor(SAKURA_PLANKS, PromenadeBlockSetTypes.SAKURA)); - public static final Block SAKURA_BUTTON = register("sakura_button", BlockFactory.woodenButton(SAKURA_PLANKS, PromenadeBlockSetTypes.SAKURA)); - public static final Block SAKURA_PRESSURE_PLATE = register("sakura_pressure_plate", BlockFactory.pressurePlate(SAKURA_PLANKS, PromenadeBlockSetTypes.SAKURA)); - public static final Block SAKURA_SIGN = register("sakura_sign", BlockFactory.sign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA)); - public static final Block SAKURA_WALL_SIGN = register("sakura_wall_sign", BlockFactory.wallSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA)); - public static final Block SAKURA_HANGING_SIGN = register("sakura_hanging_sign", BlockFactory.hangingSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); - public static final Block SAKURA_WALL_HANGING_SIGN = register("sakura_wall_hanging_sign", BlockFactory.wallHangingSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); - - public static final Block BLUSH_SAKURA_SAPLING = register("blush_sakura_sapling", BlockFactory.sapling(PromenadeMapColors.BLUSH_BLOSSOMS, PromenadeSaplingGenerators.BLUSH_SAKURA)); - public static final Block POTTED_BLUSH_SAKURA_SAPLING = register("potted_blush_sakura_sapling", BlockFactory.pot(BLUSH_SAKURA_SAPLING)); - public static final Block BLUSH_SAKURA_BLOSSOMS = register("blush_sakura_blossoms", BlockFactory.leaves(PromenadeMapColors.BLUSH_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES, 0.1f, PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM)); - public static final Block SNOWY_BLUSH_SAKURA_BLOSSOMS = register("snowy_blush_sakura_blossoms", BlockFactory.snowyLeaves(0.1f, PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM, PromenadeBlockSounds.SNOWY_CHERRY_LEAVES)); - public static final Block BLUSH_SAKURA_BLOSSOM_PILE = register("blush_sakura_blossom_pile", BlockFactory.pile(PromenadeMapColors.BLUSH_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES)); - - public static final Block COTTON_SAKURA_SAPLING = register("cotton_sakura_sapling", BlockFactory.sapling(PromenadeMapColors.COTTON_BLOSSOMS, PromenadeSaplingGenerators.COTTON_SAKURA)); - public static final Block POTTED_COTTON_SAKURA_SAPLING = register("potted_cotton_sakura_sapling", BlockFactory.pot(COTTON_SAKURA_SAPLING)); - public static final Block COTTON_SAKURA_BLOSSOMS = register("cotton_sakura_blossoms", BlockFactory.leaves(PromenadeMapColors.COTTON_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES, 0.1f, PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM)); - public static final Block SNOWY_COTTON_SAKURA_BLOSSOMS = register("snowy_cotton_sakura_blossoms", BlockFactory.snowyLeaves(0.1f, PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM, PromenadeBlockSounds.SNOWY_CHERRY_LEAVES)); - public static final Block COTTON_SAKURA_BLOSSOM_PILE = register("cotton_sakura_blossom_pile", BlockFactory.pile(PromenadeMapColors.COTTON_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES)); - - - /* ========= */ - /* MAPLE */ - /* ========= */ - public static final Block MAPLE_LOG = register("maple_log", BlockFactory.log(PromenadeMapColors.MAPLE_WOOD, PromenadeMapColors.MAPLE_BARK, PromenadeBlockSounds.MAPLE_WOOD, true).factory(MapleLogBlock::new)); - public static final Block STRIPPED_MAPLE_LOG = register("stripped_maple_log", BlockFactory.log(PromenadeMapColors.MAPLE_WOOD, PromenadeBlockSounds.MAPLE_WOOD, true).factory(StrippedMapleLogBlock::new)); - public static final Block MAPLE_WOOD = register("maple_wood", BlockFactory.log(PromenadeMapColors.MAPLE_BARK, PromenadeBlockSounds.MAPLE_WOOD, true)); - public static final Block STRIPPED_MAPLE_WOOD = register("stripped_maple_wood", BlockFactory.log(PromenadeMapColors.MAPLE_WOOD, PromenadeBlockSounds.MAPLE_WOOD, true)); - - public static final Block MAPLE_PLANKS = register("maple_planks", BlockFactory.of(BlockSettings.planks(PromenadeMapColors.MAPLE_WOOD, PromenadeBlockSounds.MAPLE_WOOD, true))); - public static final Block MAPLE_STAIRS = register("maple_stairs", BlockFactory.stairs(MAPLE_PLANKS)); - public static final Block MAPLE_SLAB = register("maple_slab", BlockFactory.slab(MAPLE_PLANKS)); - public static final Block MAPLE_FENCE = register("maple_fence", BlockFactory.fence(MAPLE_PLANKS)); - public static final Block MAPLE_FENCE_GATE = register("maple_fence_gate", BlockFactory.fenceGate(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE)); - public static final Block MAPLE_DOOR = register("maple_door", BlockFactory.door(MAPLE_PLANKS, PromenadeBlockSetTypes.MAPLE)); - public static final Block MAPLE_TRAPDOOR = register("maple_trapdoor", BlockFactory.trapdoor(MAPLE_PLANKS, PromenadeBlockSetTypes.MAPLE)); - public static final Block MAPLE_BUTTON = register("maple_button", BlockFactory.woodenButton(MAPLE_PLANKS, PromenadeBlockSetTypes.MAPLE)); - public static final Block MAPLE_PRESSURE_PLATE = register("maple_pressure_plate", BlockFactory.pressurePlate(MAPLE_PLANKS, PromenadeBlockSetTypes.MAPLE)); - public static final Block MAPLE_SIGN = register("maple_sign", BlockFactory.sign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE)); - public static final Block MAPLE_WALL_SIGN = register("maple_wall_sign", BlockFactory.wallSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE)); - public static final Block MAPLE_HANGING_SIGN = register("maple_hanging_sign", BlockFactory.hangingSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); - public static final Block MAPLE_WALL_HANGING_SIGN = register("maple_wall_hanging_sign", BlockFactory.wallHangingSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); - - public static final Block SAP_MAPLE_SAPLING = register("sap_maple_sapling", BlockFactory.sapling(PromenadeMapColors.SAP_MAPLE_LEAVES, PromenadeSaplingGenerators.SAP_MAPLE)); - public static final Block POTTED_SAP_MAPLE_SAPLING = register("potted_sap_maple_sapling", BlockFactory.pot(SAP_MAPLE_SAPLING)); - public static final Block SAP_MAPLE_LEAVES = register("sap_maple_leaves", BlockFactory.leaves(PromenadeMapColors.SAP_MAPLE_LEAVES)); - public static final Block SNOWY_SAP_MAPLE_LEAVES = register("snowy_sap_maple_leaves", BlockFactory.snowyLeaves()); - public static final Block FALLEN_SAP_MAPLE_LEAVES = register("fallen_sap_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.SAP_MAPLE_LEAVES)); - public static final Block SAP_MAPLE_LEAF_PILE = register("sap_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.SAP_MAPLE_LEAVES, BlockSoundGroup.GRASS)); - - public static final Block VERMILION_MAPLE_SAPLING = register("vermilion_maple_sapling", BlockFactory.sapling(PromenadeMapColors.VERMILION_MAPLE_LEAVES, PromenadeSaplingGenerators.VERMILION_MAPLE)); - public static final Block POTTED_VERMILION_MAPLE_SAPLING = register("potted_vermilion_maple_sapling", BlockFactory.pot(VERMILION_MAPLE_SAPLING)); - public static final Block VERMILION_MAPLE_LEAVES = register("vermilion_maple_leaves", BlockFactory.leaves(PromenadeMapColors.VERMILION_MAPLE_LEAVES, BlockSoundGroup.GRASS, 0.01F, PromenadeParticleTypes.VERMILION_MAPLE_LEAF)); - public static final Block SNOWY_VERMILION_MAPLE_LEAVES = register("snowy_vermilion_maple_leaves", BlockFactory.snowyLeaves(0.01F, PromenadeParticleTypes.VERMILION_MAPLE_LEAF)); - public static final Block FALLEN_VERMILION_MAPLE_LEAVES = register("fallen_vermilion_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.VERMILION_MAPLE_LEAVES)); - public static final Block VERMILION_MAPLE_LEAF_PILE = register("vermilion_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.VERMILION_MAPLE_LEAVES, BlockSoundGroup.GRASS)); - - public static final Block FULVOUS_MAPLE_SAPLING = register("fulvous_maple_sapling", BlockFactory.sapling(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, PromenadeSaplingGenerators.FULVOUS_MAPLE)); - public static final Block POTTED_FULVOUS_MAPLE_SAPLING = register("potted_fulvous_maple_sapling", BlockFactory.pot(FULVOUS_MAPLE_SAPLING)); - public static final Block FULVOUS_MAPLE_LEAVES = register("fulvous_maple_leaves", BlockFactory.leaves(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, BlockSoundGroup.GRASS, 0.01F, PromenadeParticleTypes.FULVOUS_MAPLE_LEAF)); - public static final Block SNOWY_FULVOUS_MAPLE_LEAVES = register("snowy_fulvous_maple_leaves", BlockFactory.snowyLeaves(0.01F, PromenadeParticleTypes.FULVOUS_MAPLE_LEAF)); - public static final Block FALLEN_FULVOUS_MAPLE_LEAVES = register("fallen_fulvous_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.FULVOUS_MAPLE_LEAVES)); - public static final Block FULVOUS_MAPLE_LEAF_PILE = register("fulvous_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, BlockSoundGroup.GRASS)); - - public static final Block MIKADO_MAPLE_SAPLING = register("mikado_maple_sapling", BlockFactory.sapling(PromenadeMapColors.MIKADO_MAPLE_LEAVES, PromenadeSaplingGenerators.MIKADO_MAPLE)); - public static final Block POTTED_MIKADO_MAPLE_SAPLING = register("potted_mikado_maple_sapling", BlockFactory.pot(MIKADO_MAPLE_SAPLING)); - public static final Block MIKADO_MAPLE_LEAVES = register("mikado_maple_leaves", BlockFactory.leaves(PromenadeMapColors.MIKADO_MAPLE_LEAVES, BlockSoundGroup.GRASS, 0.01F, PromenadeParticleTypes.MIKADO_MAPLE_LEAF)); - public static final Block SNOWY_MIKADO_MAPLE_LEAVES = register("snowy_mikado_maple_leaves", BlockFactory.snowyLeaves(0.01F, PromenadeParticleTypes.MIKADO_MAPLE_LEAF)); - public static final Block FALLEN_MIKADO_MAPLE_LEAVES = register("fallen_mikado_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.MIKADO_MAPLE_LEAVES)); - public static final Block MIKADO_MAPLE_LEAF_PILE = register("mikado_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.MIKADO_MAPLE_LEAVES, BlockSoundGroup.GRASS)); - - - /* ======== */ - /* PALM */ - /* ======== */ - public static final Block PALM_LOG = register("palm_log", BlockFactory.log(PromenadeMapColors.PALM_WOOD, PromenadeMapColors.PALM_BARK, PromenadeBlockSounds.PALM_WOOD, true)); - public static final Block STRIPPED_PALM_LOG = register("stripped_palm_log", BlockFactory.log(PromenadeMapColors.PALM_WOOD, PromenadeBlockSounds.PALM_WOOD, true)); - public static final Block PALM_WOOD = register("palm_wood", BlockFactory.log(PromenadeMapColors.PALM_BARK, PromenadeBlockSounds.PALM_WOOD, true)); - public static final Block STRIPPED_PALM_WOOD = register("stripped_palm_wood", BlockFactory.log(PromenadeMapColors.PALM_WOOD, PromenadeBlockSounds.PALM_WOOD, true)); - - public static final Block PALM_PLANKS = register("palm_planks", BlockFactory.of(BlockSettings.planks(PromenadeMapColors.PALM_WOOD, PromenadeBlockSounds.PALM_WOOD, true))); - public static final Block PALM_STAIRS = register("palm_stairs", BlockFactory.stairs(PALM_PLANKS)); - public static final Block PALM_SLAB = register("palm_slab", BlockFactory.slab(PALM_PLANKS)); - public static final Block PALM_FENCE = register("palm_fence", BlockFactory.fence(PALM_PLANKS)); - public static final Block PALM_FENCE_GATE = register("palm_fence_gate", BlockFactory.fenceGate(PALM_PLANKS, PromenadeWoodTypes.PALM)); - public static final Block PALM_DOOR = register("palm_door", BlockFactory.door(PALM_PLANKS, PromenadeBlockSetTypes.PALM)); - public static final Block PALM_TRAPDOOR = register("palm_trapdoor", BlockFactory.trapdoor(PALM_PLANKS, PromenadeBlockSetTypes.PALM)); - public static final Block PALM_BUTTON = register("palm_button", BlockFactory.woodenButton(PALM_PLANKS, PromenadeBlockSetTypes.PALM)); - public static final Block PALM_PRESSURE_PLATE = register("palm_pressure_plate", BlockFactory.pressurePlate(PALM_PLANKS, PromenadeBlockSetTypes.PALM)); - public static final Block PALM_SIGN = register("palm_sign", BlockFactory.sign(PALM_PLANKS, PromenadeWoodTypes.PALM)); - public static final Block PALM_WALL_SIGN = register("palm_wall_sign", BlockFactory.wallSign(PALM_PLANKS, PromenadeWoodTypes.PALM)); - public static final Block PALM_HANGING_SIGN = register("palm_hanging_sign", BlockFactory.hangingSign(PALM_PLANKS, PromenadeWoodTypes.PALM, BlockSoundGroup.HANGING_SIGN)); - public static final Block PALM_WALL_HANGING_SIGN = register("palm_wall_hanging_sign", BlockFactory.wallHangingSign(PALM_PLANKS, PromenadeWoodTypes.PALM, BlockSoundGroup.HANGING_SIGN)); - - public static final Block PALM_SAPLING = register("palm_sapling", BlockFactory.sapling(PromenadeMapColors.PALM_LEAVES, PromenadeSaplingGenerators.PALM, state -> state.isIn(BlockTags.SAND))); - public static final Block POTTED_PALM_SAPLING = register("potted_palm_sapling", BlockFactory.pot(PALM_SAPLING)); - public static final Block PALM_LEAVES = register("palm_leaves", BlockFactory.leaves(PromenadeMapColors.PALM_LEAVES).factory(s -> new TintedParticleExtendedLeavesBlock(0.01F, s))); - public static final Block SNOWY_PALM_LEAVES = register("snowy_palm_leaves", BlockFactory.snowyLeaves().factory(s -> new TintedParticleSnowyExtendedLeavesBlock(0.01F, s))); - public static final Block PALM_HANGING_LEAVES = register("palm_hanging_leaves", BlockFactory.hangingLeaves(PromenadeMapColors.PALM_LEAVES)); - public static final Block PALM_LEAF_PILE = register("palm_leaf_pile", BlockFactory.pile(PromenadeMapColors.PALM_LEAVES, BlockSoundGroup.GRASS)); - - - /* ============ */ - /* AMARANTH */ - /* ============ */ - public static final Block DARK_AMARANTH_NYLIUM = register("dark_amaranth_nylium", BlockFactory.of(NyliumBlock::new, - AbstractBlock.Settings.create() - .mapColor(MapColor.BLACK) - .instrument(NoteBlockInstrument.BASEDRUM) - .requiresTool() - .strength(0.4F) - .sounds(BlockSoundGroup.NYLIUM) - .ticksRandomly())); - public static final Block DARK_AMARANTH_WART_BLOCK = register("dark_amaranth_wart_block", - BlockFactory.of(AbstractBlock.Settings.create() - .mapColor(MapColor.PURPLE) - .strength(1.0F) - .sounds(BlockSoundGroup.WART_BLOCK))); - public static final Block DARK_AMARANTH_ROOTS = register("dark_amaranth_roots", BlockFactory.of(s -> new RootsBlock(state -> state.isIn(PromenadeBlockTags.DARK_AMARANTH_ROOTS_PLACEABLE_ON), s), - AbstractBlock.Settings.create() - .mapColor(MapColor.PURPLE) - .replaceable() - .breakInstantly() - .noCollision() - .sounds(BlockSoundGroup.ROOTS))); - public static final Block POTTED_DARK_AMARANTH_ROOTS = register("potted_dark_amaranth_roots", BlockFactory.pot(DARK_AMARANTH_ROOTS)); - - public static final Block DARK_AMARANTH_STEM = register("dark_amaranth_stem", BlockFactory.log(PromenadeMapColors.AMARANTH_BARK, PromenadeBlockSounds.AMARANTH_WOOD, false)); - public static final Block STRIPPED_DARK_AMARANTH_STEM = register("stripped_dark_amaranth_stem", BlockFactory.log(PromenadeMapColors.AMARANTH_WOOD, PromenadeBlockSounds.AMARANTH_WOOD, false)); - public static final Block DARK_AMARANTH_HYPHAE = register("dark_amaranth_hyphae", BlockFactory.log(PromenadeMapColors.AMARANTH_BARK, PromenadeBlockSounds.AMARANTH_WOOD, false)); - public static final Block STRIPPED_DARK_AMARANTH_HYPHAE = register("stripped_dark_amaranth_hyphae", BlockFactory.log(PromenadeMapColors.AMARANTH_WOOD, PromenadeBlockSounds.AMARANTH_WOOD, false)); - - public static final Block DARK_AMARANTH_PLANKS = register("dark_amaranth_planks", BlockFactory.of(BlockSettings.planks(PromenadeMapColors.AMARANTH_WOOD, PromenadeBlockSounds.AMARANTH_WOOD, false))); - public static final Block DARK_AMARANTH_STAIRS = register("dark_amaranth_stairs", BlockFactory.stairs(DARK_AMARANTH_PLANKS)); - public static final Block DARK_AMARANTH_SLAB = register("dark_amaranth_slab", BlockFactory.slab(DARK_AMARANTH_PLANKS)); - public static final Block DARK_AMARANTH_FENCE = register("dark_amaranth_fence", BlockFactory.fence(DARK_AMARANTH_PLANKS)); - public static final Block DARK_AMARANTH_FENCE_GATE = register("dark_amaranth_fence_gate", BlockFactory.fenceGate(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH)); - public static final Block DARK_AMARANTH_DOOR = register("dark_amaranth_door", BlockFactory.door(DARK_AMARANTH_PLANKS, PromenadeBlockSetTypes.DARK_AMARANTH)); - public static final Block DARK_AMARANTH_TRAPDOOR = register("dark_amaranth_trapdoor", BlockFactory.trapdoor(DARK_AMARANTH_PLANKS, PromenadeBlockSetTypes.DARK_AMARANTH)); - public static final Block DARK_AMARANTH_BUTTON = register("dark_amaranth_button", BlockFactory.woodenButton(DARK_AMARANTH_PLANKS, PromenadeBlockSetTypes.DARK_AMARANTH)); - public static final Block DARK_AMARANTH_PRESSURE_PLATE = register("dark_amaranth_pressure_plate", BlockFactory.pressurePlate(DARK_AMARANTH_PLANKS, PromenadeBlockSetTypes.DARK_AMARANTH)); - public static final Block DARK_AMARANTH_SIGN = register("dark_amaranth_sign", BlockFactory.sign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH)); - public static final Block DARK_AMARANTH_WALL_SIGN = register("dark_amaranth_wall_sign", BlockFactory.wallSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH)); - public static final Block DARK_AMARANTH_HANGING_SIGN = register("dark_amaranth_hanging_sign", BlockFactory.hangingSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH, BlockSoundGroup.NETHER_WOOD_HANGING_SIGN)); - public static final Block DARK_AMARANTH_WALL_HANGING_SIGN = register("dark_amaranth_wall_hanging_sign", BlockFactory.wallHangingSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH, BlockSoundGroup.NETHER_WOOD_HANGING_SIGN)); - - public static final Block DARK_AMARANTH_FUNGUS = register("dark_amaranth_fungus", BlockFactory.fungus(MapColor.PURPLE, PromenadeConfiguredFeatures.PLANTED_DARK_AMARANTH_FUNGUS, PromenadeBlockTags.DARK_AMARANTH_FUNGUS_PLACEABLE_ON, PromenadeBlockTags.DARK_AMARANTH_FUNGUS_GROWABLE_ON)); - public static final Block POTTED_DARK_AMARANTH_FUNGUS = register("potted_dark_amaranth_fungus", BlockFactory.pot(DARK_AMARANTH_FUNGUS)); - - public static final Block SOUL_SHROOMLIGHT = register("soul_shroomlight", BlockFactory.of(AbstractBlock.Settings.create().mapColor(MapColor.LIGHT_BLUE).strength(1.0F).sounds(BlockSoundGroup.SHROOMLIGHT).luminance(state -> 10))); - - public static final Block COILED_VINES = register("coiled_vines", BlockFactory.of( - CoiledVinesBlock::new, - AbstractBlock.Settings.create() - .mapColor(MapColor.PURPLE) - .ticksRandomly() - .noCollision() - .breakInstantly() - .sounds(BlockSoundGroup.WEEPING_VINES) - .pistonBehavior(PistonBehavior.DESTROY) - )); - public static final Block COILED_VINES_PLANT = register("coiled_vines_plant", BlockFactory.of( - CoiledVinesPlantBlock::new, - AbstractBlock.Settings.create() - .mapColor(MapColor.PURPLE) - .noCollision() - .breakInstantly() - .sounds(BlockSoundGroup.WEEPING_VINES) - .pistonBehavior(PistonBehavior.DESTROY) - ).noItem()); - - public static final Block MOAI = register("moai", BlockFactory.of(MoaiBlock::new, AbstractBlock.Settings.copy(Blocks.TUFF).mapColor(MapColor.TERRACOTTA_LIGHT_GRAY)).itemSettings(s -> s.equipmentSlot((entity, stack) -> EquipmentSlot.HEAD))); - - public static final Block BLUEBERRY_BUSH = register("blueberry_bush", BlockFactory.of(s -> new BerryBushBlock(PromenadeItemKeys.BLUEBERRIES, false, s), AbstractBlock.Settings.create() - .mapColor(MapColor.DARK_GREEN) - .ticksRandomly() - .noCollision() - .sounds(BlockSoundGroup.SWEET_BERRY_BUSH) - .pistonBehavior(PistonBehavior.DESTROY)).noItem()); - - private static RegistryKey keyOf(String id) { - return RegistryKey.of(RegistryKeys.BLOCK, Promenade.id(id)); - } - - private static Block register(RegistryKey key, BlockBuilder builder) { - return builder.register(key); - } - - private static Block register(String id, BlockBuilder builder) { - return register(keyOf(id), builder); - } + /* ========= */ + /* ROCKS */ + /* ========= */ + public static final Block ASPHALT = register("asphalt", BlockFactory.of(BlockSettings.rock(MapColor.DEEPSLATE_GRAY, BlockSoundGroup.BASALT))); + public static final Block ASPHALT_SLAB = register("asphalt_slab", BlockFactory.slab(ASPHALT)); + public static final Block ASPHALT_STAIRS = register("asphalt_stairs", BlockFactory.stairs(ASPHALT)); + public static final Block ASPHALT_WALL = register("asphalt_wall", BlockFactory.wall(ASPHALT)); + + public static final Block POLISHED_ASPHALT = register("polished_asphalt", BlockFactory.copy(ASPHALT)); + public static final Block POLISHED_ASPHALT_SLAB = register("polished_asphalt_slab", BlockFactory.slab(POLISHED_ASPHALT)); + public static final Block POLISHED_ASPHALT_STAIRS = register("polished_asphalt_stairs", BlockFactory.stairs(POLISHED_ASPHALT)); + + public static final Block BLUNITE = register("blunite", BlockFactory.of(BlockSettings.rock(MapColor.TERRACOTTA_CYAN, BlockSoundGroup.TUFF))); + public static final Block BLUNITE_SLAB = register("blunite_slab", BlockFactory.slab(BLUNITE)); + public static final Block BLUNITE_STAIRS = register("blunite_stairs", BlockFactory.stairs(BLUNITE)); + public static final Block BLUNITE_WALL = register("blunite_wall", BlockFactory.wall(BLUNITE)); + + public static final Block POLISHED_BLUNITE = register("polished_blunite", BlockFactory.copy(BLUNITE)); + public static final Block POLISHED_BLUNITE_SLAB = register("polished_blunite_slab", BlockFactory.slab(POLISHED_BLUNITE)); + public static final Block POLISHED_BLUNITE_STAIRS = register("polished_blunite_stairs", BlockFactory.stairs(POLISHED_BLUNITE)); + + + /* ================= */ + /* VANILLA PILES */ + /* ================= */ + public static final Block OAK_LEAF_PILE = register("oak_leaf_pile", BlockFactory.pile()); + public static final Block SPRUCE_LEAF_PILE = register("spruce_leaf_pile", BlockFactory.pile()); + public static final Block BIRCH_LEAF_PILE = register("birch_leaf_pile", BlockFactory.pile()); + public static final Block JUNGLE_LEAF_PILE = register("jungle_leaf_pile", BlockFactory.pile()); + public static final Block ACACIA_LEAF_PILE = register("acacia_leaf_pile", BlockFactory.pile()); + public static final Block CHERRY_LEAF_PILE = register("cherry_leaf_pile", BlockFactory.pile(MapColor.PINK).settings(s -> s.sounds(BlockSoundGroup.CHERRY_LEAVES))); + public static final Block DARK_OAK_LEAF_PILE = register("dark_oak_leaf_pile", BlockFactory.pile()); + public static final Block PALE_OAK_LEAF_PILE = register("pale_oak_leaf_pile", BlockFactory.pile()); + public static final Block MANGROVE_LEAF_PILE = register("mangrove_leaf_pile", BlockFactory.pile()); + public static final Block AZALEA_LEAF_PILE = register("azalea_leaf_pile", BlockFactory.pile().settings(s -> s.sounds(BlockSoundGroup.AZALEA_LEAVES))); + public static final Block FLOWERING_AZALEA_LEAF_PILE = register("flowering_azalea_leaf_pile", BlockFactory.pile().settings(s -> s.sounds(BlockSoundGroup.AZALEA_LEAVES))); + + public static final Block DANDELION_PILE = register("dandelion_pile", BlockFactory.pile(MapColor.GOLD)); + public static final Block POPPY_PILE = register("poppy_pile", BlockFactory.pile(MapColor.DULL_RED)); + public static final Block BLUE_ORCHID_PILE = register("blue_orchid_pile", BlockFactory.pile(MapColor.LIGHT_BLUE)); + public static final Block ALLIUM_PILE = register("allium_pile", BlockFactory.pile(MapColor.MAGENTA)); + public static final Block AZURE_BLUET_PILE = register("azure_bluet_pile", BlockFactory.pile(MapColor.PALE_YELLOW)); + public static final Block RED_TULIP_PILE = register("red_tulip_pile", BlockFactory.pile(MapColor.DULL_RED)); + public static final Block ORANGE_TULIP_PILE = register("orange_tulip_pile", BlockFactory.pile(MapColor.ORANGE)); + public static final Block WHITE_TULIP_PILE = register("white_tulip_pile", BlockFactory.pile(MapColor.WHITE)); + public static final Block PINK_TULIP_PILE = register("pink_tulip_pile", BlockFactory.pile(MapColor.PINK)); + public static final Block OXEYE_DAISY_PILE = register("oxeye_daisy_pile", BlockFactory.pile(MapColor.GOLD)); + public static final Block CORNFLOWER_PILE = register("cornflower_pile", BlockFactory.pile(MapColor.LAPIS_BLUE)); + public static final Block LILY_OF_THE_VALLEY_PILE = register("lily_of_the_valley_pile", BlockFactory.pile(MapColor.WHITE)); + public static final Block WITHER_ROSE_PILE = register("wither_rose_pile", BlockFactory.pile(MapColor.BLACK).factory(WitherRosePileBlock::new)); + + + /* ======================== */ + /* VANILLA SNOWY LEAVES */ + /* ======================== */ + public static final Block SNOWY_OAK_LEAVES = register("snowy_oak_leaves", BlockFactory.snowyLeaves()); + public static final Block SNOWY_SPRUCE_LEAVES = register("snowy_spruce_leaves", BlockFactory.snowyLeaves()); + public static final Block SNOWY_BIRCH_LEAVES = register("snowy_birch_leaves", BlockFactory.snowyLeaves()); + public static final Block SNOWY_JUNGLE_LEAVES = register("snowy_jungle_leaves", BlockFactory.snowyLeaves()); + public static final Block SNOWY_ACACIA_LEAVES = register("snowy_acacia_leaves", BlockFactory.snowyLeaves()); + public static final Block SNOWY_CHERRY_LEAVES = register("snowy_cherry_leaves", BlockFactory.snowyLeaves(0.1f, ParticleTypes.CHERRY_LEAVES, PromenadeBlockSounds.SNOWY_CHERRY_LEAVES)); + public static final Block SNOWY_DARK_OAK_LEAVES = register("snowy_dark_oak_leaves", BlockFactory.snowyLeaves()); + public static final Block SNOWY_PALE_OAK_LEAVES = register("snowy_pale_oak_leaves", BlockFactory.snowyLeaves(0.02F, ParticleTypes.PALE_OAK_LEAVES)); + public static final Block SNOWY_MANGROVE_LEAVES = register("snowy_mangrove_leaves", BlockFactory.snowyLeaves()); + public static final Block SNOWY_AZALEA_LEAVES = register("snowy_azalea_leaves", BlockFactory.snowyLeaves(PromenadeBlockSounds.SNOWY_AZALEA_LEAVES)); + public static final Block SNOWY_FLOWERING_AZALEA_LEAVES = register("snowy_flowering_azalea_leaves", BlockFactory.snowyLeaves(PromenadeBlockSounds.SNOWY_AZALEA_LEAVES)); + + + /* ========== */ + /* SAKURA */ + /* ========== */ + public static final Block SAKURA_LOG = register("sakura_log", BlockFactory.log(PromenadeMapColors.SAKURA_WOOD, PromenadeMapColors.SAKURA_BARK, PromenadeBlockSounds.SAKURA_WOOD, true)); + public static final Block STRIPPED_SAKURA_LOG = register("stripped_sakura_log", BlockFactory.log(PromenadeMapColors.SAKURA_WOOD, PromenadeBlockSounds.SAKURA_WOOD, true)); + public static final Block SAKURA_WOOD = register("sakura_wood", BlockFactory.log(PromenadeMapColors.SAKURA_BARK, PromenadeBlockSounds.SAKURA_WOOD, true)); + public static final Block STRIPPED_SAKURA_WOOD = register("stripped_sakura_wood", BlockFactory.log(PromenadeMapColors.SAKURA_WOOD, PromenadeBlockSounds.SAKURA_WOOD, true)); + + public static final Block SAKURA_PLANKS = register("sakura_planks", BlockFactory.of(BlockSettings.planks(PromenadeMapColors.SAKURA_WOOD, PromenadeBlockSounds.SAKURA_WOOD, true))); + public static final Block SAKURA_STAIRS = register("sakura_stairs", BlockFactory.stairs(SAKURA_PLANKS)); + public static final Block SAKURA_SLAB = register("sakura_slab", BlockFactory.slab(SAKURA_PLANKS)); + public static final Block SAKURA_FENCE = register("sakura_fence", BlockFactory.fence(SAKURA_PLANKS)); + public static final Block SAKURA_FENCE_GATE = register("sakura_fence_gate", BlockFactory.fenceGate(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA)); + public static final Block SAKURA_DOOR = register("sakura_door", BlockFactory.door(SAKURA_PLANKS, PromenadeBlockSetTypes.SAKURA)); + public static final Block SAKURA_TRAPDOOR = register("sakura_trapdoor", BlockFactory.trapdoor(SAKURA_PLANKS, PromenadeBlockSetTypes.SAKURA)); + public static final Block SAKURA_BUTTON = register("sakura_button", BlockFactory.woodenButton(SAKURA_PLANKS, PromenadeBlockSetTypes.SAKURA)); + public static final Block SAKURA_PRESSURE_PLATE = register("sakura_pressure_plate", BlockFactory.pressurePlate(SAKURA_PLANKS, PromenadeBlockSetTypes.SAKURA)); + public static final Block SAKURA_SIGN = register("sakura_sign", BlockFactory.sign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA)); + public static final Block SAKURA_WALL_SIGN = register("sakura_wall_sign", BlockFactory.wallSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA)); + public static final Block SAKURA_HANGING_SIGN = register("sakura_hanging_sign", BlockFactory.hangingSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); + public static final Block SAKURA_WALL_HANGING_SIGN = register("sakura_wall_hanging_sign", BlockFactory.wallHangingSign(SAKURA_PLANKS, PromenadeWoodTypes.SAKURA, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); + + public static final Block BLUSH_SAKURA_SAPLING = register("blush_sakura_sapling", BlockFactory.sapling(PromenadeMapColors.BLUSH_BLOSSOMS, PromenadeSaplingGenerators.BLUSH_SAKURA)); + public static final Block POTTED_BLUSH_SAKURA_SAPLING = register("potted_blush_sakura_sapling", BlockFactory.pot(BLUSH_SAKURA_SAPLING)); + public static final Block BLUSH_SAKURA_BLOSSOMS = register("blush_sakura_blossoms", BlockFactory.leaves(PromenadeMapColors.BLUSH_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES, 0.1f, PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM)); + public static final Block SNOWY_BLUSH_SAKURA_BLOSSOMS = register("snowy_blush_sakura_blossoms", BlockFactory.snowyLeaves(0.1f, PromenadeParticleTypes.BLUSH_SAKURA_BLOSSOM, PromenadeBlockSounds.SNOWY_CHERRY_LEAVES)); + public static final Block BLUSH_SAKURA_BLOSSOM_PILE = register("blush_sakura_blossom_pile", BlockFactory.pile(PromenadeMapColors.BLUSH_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES)); + + public static final Block COTTON_SAKURA_SAPLING = register("cotton_sakura_sapling", BlockFactory.sapling(PromenadeMapColors.COTTON_BLOSSOMS, PromenadeSaplingGenerators.COTTON_SAKURA)); + public static final Block POTTED_COTTON_SAKURA_SAPLING = register("potted_cotton_sakura_sapling", BlockFactory.pot(COTTON_SAKURA_SAPLING)); + public static final Block COTTON_SAKURA_BLOSSOMS = register("cotton_sakura_blossoms", BlockFactory.leaves(PromenadeMapColors.COTTON_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES, 0.1f, PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM)); + public static final Block SNOWY_COTTON_SAKURA_BLOSSOMS = register("snowy_cotton_sakura_blossoms", BlockFactory.snowyLeaves(0.1f, PromenadeParticleTypes.COTTON_SAKURA_BLOSSOM, PromenadeBlockSounds.SNOWY_CHERRY_LEAVES)); + public static final Block COTTON_SAKURA_BLOSSOM_PILE = register("cotton_sakura_blossom_pile", BlockFactory.pile(PromenadeMapColors.COTTON_BLOSSOMS, BlockSoundGroup.CHERRY_LEAVES)); + + + /* ========= */ + /* MAPLE */ + /* ========= */ + public static final Block MAPLE_LOG = register("maple_log", BlockFactory.log(PromenadeMapColors.MAPLE_WOOD, PromenadeMapColors.MAPLE_BARK, PromenadeBlockSounds.MAPLE_WOOD, true).factory(MapleLogBlock::new)); + public static final Block STRIPPED_MAPLE_LOG = register("stripped_maple_log", BlockFactory.log(PromenadeMapColors.MAPLE_WOOD, PromenadeBlockSounds.MAPLE_WOOD, true).factory(StrippedMapleLogBlock::new)); + public static final Block MAPLE_WOOD = register("maple_wood", BlockFactory.log(PromenadeMapColors.MAPLE_BARK, PromenadeBlockSounds.MAPLE_WOOD, true)); + public static final Block STRIPPED_MAPLE_WOOD = register("stripped_maple_wood", BlockFactory.log(PromenadeMapColors.MAPLE_WOOD, PromenadeBlockSounds.MAPLE_WOOD, true)); + + public static final Block MAPLE_PLANKS = register("maple_planks", BlockFactory.of(BlockSettings.planks(PromenadeMapColors.MAPLE_WOOD, PromenadeBlockSounds.MAPLE_WOOD, true))); + public static final Block MAPLE_STAIRS = register("maple_stairs", BlockFactory.stairs(MAPLE_PLANKS)); + public static final Block MAPLE_SLAB = register("maple_slab", BlockFactory.slab(MAPLE_PLANKS)); + public static final Block MAPLE_FENCE = register("maple_fence", BlockFactory.fence(MAPLE_PLANKS)); + public static final Block MAPLE_FENCE_GATE = register("maple_fence_gate", BlockFactory.fenceGate(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE)); + public static final Block MAPLE_DOOR = register("maple_door", BlockFactory.door(MAPLE_PLANKS, PromenadeBlockSetTypes.MAPLE)); + public static final Block MAPLE_TRAPDOOR = register("maple_trapdoor", BlockFactory.trapdoor(MAPLE_PLANKS, PromenadeBlockSetTypes.MAPLE)); + public static final Block MAPLE_BUTTON = register("maple_button", BlockFactory.woodenButton(MAPLE_PLANKS, PromenadeBlockSetTypes.MAPLE)); + public static final Block MAPLE_PRESSURE_PLATE = register("maple_pressure_plate", BlockFactory.pressurePlate(MAPLE_PLANKS, PromenadeBlockSetTypes.MAPLE)); + public static final Block MAPLE_SIGN = register("maple_sign", BlockFactory.sign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE)); + public static final Block MAPLE_WALL_SIGN = register("maple_wall_sign", BlockFactory.wallSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE)); + public static final Block MAPLE_HANGING_SIGN = register("maple_hanging_sign", BlockFactory.hangingSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); + public static final Block MAPLE_WALL_HANGING_SIGN = register("maple_wall_hanging_sign", BlockFactory.wallHangingSign(MAPLE_PLANKS, PromenadeWoodTypes.MAPLE, BlockSoundGroup.CHERRY_WOOD_HANGING_SIGN)); + + public static final Block SAP_MAPLE_SAPLING = register("sap_maple_sapling", BlockFactory.sapling(PromenadeMapColors.SAP_MAPLE_LEAVES, PromenadeSaplingGenerators.SAP_MAPLE)); + public static final Block POTTED_SAP_MAPLE_SAPLING = register("potted_sap_maple_sapling", BlockFactory.pot(SAP_MAPLE_SAPLING)); + public static final Block SAP_MAPLE_LEAVES = register("sap_maple_leaves", BlockFactory.leaves(PromenadeMapColors.SAP_MAPLE_LEAVES)); + public static final Block SNOWY_SAP_MAPLE_LEAVES = register("snowy_sap_maple_leaves", BlockFactory.snowyLeaves()); + public static final Block FALLEN_SAP_MAPLE_LEAVES = register("fallen_sap_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.SAP_MAPLE_LEAVES)); + public static final Block SAP_MAPLE_LEAF_PILE = register("sap_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.SAP_MAPLE_LEAVES, BlockSoundGroup.GRASS)); + + public static final Block VERMILION_MAPLE_SAPLING = register("vermilion_maple_sapling", BlockFactory.sapling(PromenadeMapColors.VERMILION_MAPLE_LEAVES, PromenadeSaplingGenerators.VERMILION_MAPLE)); + public static final Block POTTED_VERMILION_MAPLE_SAPLING = register("potted_vermilion_maple_sapling", BlockFactory.pot(VERMILION_MAPLE_SAPLING)); + public static final Block VERMILION_MAPLE_LEAVES = register("vermilion_maple_leaves", BlockFactory.leaves(PromenadeMapColors.VERMILION_MAPLE_LEAVES, BlockSoundGroup.GRASS, 0.01F, PromenadeParticleTypes.VERMILION_MAPLE_LEAF)); + public static final Block SNOWY_VERMILION_MAPLE_LEAVES = register("snowy_vermilion_maple_leaves", BlockFactory.snowyLeaves(0.01F, PromenadeParticleTypes.VERMILION_MAPLE_LEAF)); + public static final Block FALLEN_VERMILION_MAPLE_LEAVES = register("fallen_vermilion_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.VERMILION_MAPLE_LEAVES)); + public static final Block VERMILION_MAPLE_LEAF_PILE = register("vermilion_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.VERMILION_MAPLE_LEAVES, BlockSoundGroup.GRASS)); + + public static final Block FULVOUS_MAPLE_SAPLING = register("fulvous_maple_sapling", BlockFactory.sapling(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, PromenadeSaplingGenerators.FULVOUS_MAPLE)); + public static final Block POTTED_FULVOUS_MAPLE_SAPLING = register("potted_fulvous_maple_sapling", BlockFactory.pot(FULVOUS_MAPLE_SAPLING)); + public static final Block FULVOUS_MAPLE_LEAVES = register("fulvous_maple_leaves", BlockFactory.leaves(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, BlockSoundGroup.GRASS, 0.01F, PromenadeParticleTypes.FULVOUS_MAPLE_LEAF)); + public static final Block SNOWY_FULVOUS_MAPLE_LEAVES = register("snowy_fulvous_maple_leaves", BlockFactory.snowyLeaves(0.01F, PromenadeParticleTypes.FULVOUS_MAPLE_LEAF)); + public static final Block FALLEN_FULVOUS_MAPLE_LEAVES = register("fallen_fulvous_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.FULVOUS_MAPLE_LEAVES)); + public static final Block FULVOUS_MAPLE_LEAF_PILE = register("fulvous_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.FULVOUS_MAPLE_LEAVES, BlockSoundGroup.GRASS)); + + public static final Block MIKADO_MAPLE_SAPLING = register("mikado_maple_sapling", BlockFactory.sapling(PromenadeMapColors.MIKADO_MAPLE_LEAVES, PromenadeSaplingGenerators.MIKADO_MAPLE)); + public static final Block POTTED_MIKADO_MAPLE_SAPLING = register("potted_mikado_maple_sapling", BlockFactory.pot(MIKADO_MAPLE_SAPLING)); + public static final Block MIKADO_MAPLE_LEAVES = register("mikado_maple_leaves", BlockFactory.leaves(PromenadeMapColors.MIKADO_MAPLE_LEAVES, BlockSoundGroup.GRASS, 0.01F, PromenadeParticleTypes.MIKADO_MAPLE_LEAF)); + public static final Block SNOWY_MIKADO_MAPLE_LEAVES = register("snowy_mikado_maple_leaves", BlockFactory.snowyLeaves(0.01F, PromenadeParticleTypes.MIKADO_MAPLE_LEAF)); + public static final Block FALLEN_MIKADO_MAPLE_LEAVES = register("fallen_mikado_maple_leaves", BlockFactory.fallenLeaves(PromenadeMapColors.MIKADO_MAPLE_LEAVES)); + public static final Block MIKADO_MAPLE_LEAF_PILE = register("mikado_maple_leaf_pile", BlockFactory.pile(PromenadeMapColors.MIKADO_MAPLE_LEAVES, BlockSoundGroup.GRASS)); + + + /* ======== */ + /* PALM */ + /* ======== */ + public static final Block PALM_LOG = register("palm_log", BlockFactory.log(PromenadeMapColors.PALM_WOOD, PromenadeMapColors.PALM_BARK, PromenadeBlockSounds.PALM_WOOD, true)); + public static final Block STRIPPED_PALM_LOG = register("stripped_palm_log", BlockFactory.log(PromenadeMapColors.PALM_WOOD, PromenadeBlockSounds.PALM_WOOD, true)); + public static final Block PALM_WOOD = register("palm_wood", BlockFactory.log(PromenadeMapColors.PALM_BARK, PromenadeBlockSounds.PALM_WOOD, true)); + public static final Block STRIPPED_PALM_WOOD = register("stripped_palm_wood", BlockFactory.log(PromenadeMapColors.PALM_WOOD, PromenadeBlockSounds.PALM_WOOD, true)); + + public static final Block PALM_PLANKS = register("palm_planks", BlockFactory.of(BlockSettings.planks(PromenadeMapColors.PALM_WOOD, PromenadeBlockSounds.PALM_WOOD, true))); + public static final Block PALM_STAIRS = register("palm_stairs", BlockFactory.stairs(PALM_PLANKS)); + public static final Block PALM_SLAB = register("palm_slab", BlockFactory.slab(PALM_PLANKS)); + public static final Block PALM_FENCE = register("palm_fence", BlockFactory.fence(PALM_PLANKS)); + public static final Block PALM_FENCE_GATE = register("palm_fence_gate", BlockFactory.fenceGate(PALM_PLANKS, PromenadeWoodTypes.PALM)); + public static final Block PALM_DOOR = register("palm_door", BlockFactory.door(PALM_PLANKS, PromenadeBlockSetTypes.PALM)); + public static final Block PALM_TRAPDOOR = register("palm_trapdoor", BlockFactory.trapdoor(PALM_PLANKS, PromenadeBlockSetTypes.PALM)); + public static final Block PALM_BUTTON = register("palm_button", BlockFactory.woodenButton(PALM_PLANKS, PromenadeBlockSetTypes.PALM)); + public static final Block PALM_PRESSURE_PLATE = register("palm_pressure_plate", BlockFactory.pressurePlate(PALM_PLANKS, PromenadeBlockSetTypes.PALM)); + public static final Block PALM_SIGN = register("palm_sign", BlockFactory.sign(PALM_PLANKS, PromenadeWoodTypes.PALM)); + public static final Block PALM_WALL_SIGN = register("palm_wall_sign", BlockFactory.wallSign(PALM_PLANKS, PromenadeWoodTypes.PALM)); + public static final Block PALM_HANGING_SIGN = register("palm_hanging_sign", BlockFactory.hangingSign(PALM_PLANKS, PromenadeWoodTypes.PALM, BlockSoundGroup.HANGING_SIGN)); + public static final Block PALM_WALL_HANGING_SIGN = register("palm_wall_hanging_sign", BlockFactory.wallHangingSign(PALM_PLANKS, PromenadeWoodTypes.PALM, BlockSoundGroup.HANGING_SIGN)); + + public static final Block PALM_SAPLING = register("palm_sapling", BlockFactory.sapling(PromenadeMapColors.PALM_LEAVES, PromenadeSaplingGenerators.PALM, state -> state.isIn(BlockTags.SAND))); + public static final Block POTTED_PALM_SAPLING = register("potted_palm_sapling", BlockFactory.pot(PALM_SAPLING)); + public static final Block PALM_LEAVES = register("palm_leaves", BlockFactory.leaves(PromenadeMapColors.PALM_LEAVES).factory(s -> new TintedParticleExtendedLeavesBlock(0.01F, s))); + public static final Block SNOWY_PALM_LEAVES = register("snowy_palm_leaves", BlockFactory.snowyLeaves().factory(s -> new TintedParticleSnowyExtendedLeavesBlock(0.01F, s))); + public static final Block PALM_HANGING_LEAVES = register("palm_hanging_leaves", BlockFactory.hangingLeaves(PromenadeMapColors.PALM_LEAVES)); + public static final Block PALM_LEAF_PILE = register("palm_leaf_pile", BlockFactory.pile(PromenadeMapColors.PALM_LEAVES, BlockSoundGroup.GRASS)); + + + /* ============ */ + /* AMARANTH */ + /* ============ */ + public static final Block DARK_AMARANTH_NYLIUM = register("dark_amaranth_nylium", BlockFactory.of(NyliumBlock::new, + AbstractBlock.Settings.create() + .mapColor(MapColor.BLACK) + .instrument(NoteBlockInstrument.BASEDRUM) + .requiresTool() + .strength(0.4F) + .sounds(BlockSoundGroup.NYLIUM) + .ticksRandomly())); + public static final Block DARK_AMARANTH_WART_BLOCK = register("dark_amaranth_wart_block", + BlockFactory.of(AbstractBlock.Settings.create() + .mapColor(MapColor.PURPLE) + .strength(1.0F) + .sounds(BlockSoundGroup.WART_BLOCK))); + public static final Block DARK_AMARANTH_ROOTS = register("dark_amaranth_roots", BlockFactory.of(s -> new RootsBlock(state -> state.isIn(PromenadeBlockTags.DARK_AMARANTH_ROOTS_PLACEABLE_ON), s), + AbstractBlock.Settings.create() + .mapColor(MapColor.PURPLE) + .replaceable() + .breakInstantly() + .noCollision() + .sounds(BlockSoundGroup.ROOTS))); + public static final Block POTTED_DARK_AMARANTH_ROOTS = register("potted_dark_amaranth_roots", BlockFactory.pot(DARK_AMARANTH_ROOTS)); + + public static final Block DARK_AMARANTH_STEM = register("dark_amaranth_stem", BlockFactory.log(PromenadeMapColors.AMARANTH_BARK, PromenadeBlockSounds.AMARANTH_WOOD, false)); + public static final Block STRIPPED_DARK_AMARANTH_STEM = register("stripped_dark_amaranth_stem", BlockFactory.log(PromenadeMapColors.AMARANTH_WOOD, PromenadeBlockSounds.AMARANTH_WOOD, false)); + public static final Block DARK_AMARANTH_HYPHAE = register("dark_amaranth_hyphae", BlockFactory.log(PromenadeMapColors.AMARANTH_BARK, PromenadeBlockSounds.AMARANTH_WOOD, false)); + public static final Block STRIPPED_DARK_AMARANTH_HYPHAE = register("stripped_dark_amaranth_hyphae", BlockFactory.log(PromenadeMapColors.AMARANTH_WOOD, PromenadeBlockSounds.AMARANTH_WOOD, false)); + + public static final Block DARK_AMARANTH_PLANKS = register("dark_amaranth_planks", BlockFactory.of(BlockSettings.planks(PromenadeMapColors.AMARANTH_WOOD, PromenadeBlockSounds.AMARANTH_WOOD, false))); + public static final Block DARK_AMARANTH_STAIRS = register("dark_amaranth_stairs", BlockFactory.stairs(DARK_AMARANTH_PLANKS)); + public static final Block DARK_AMARANTH_SLAB = register("dark_amaranth_slab", BlockFactory.slab(DARK_AMARANTH_PLANKS)); + public static final Block DARK_AMARANTH_FENCE = register("dark_amaranth_fence", BlockFactory.fence(DARK_AMARANTH_PLANKS)); + public static final Block DARK_AMARANTH_FENCE_GATE = register("dark_amaranth_fence_gate", BlockFactory.fenceGate(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH)); + public static final Block DARK_AMARANTH_DOOR = register("dark_amaranth_door", BlockFactory.door(DARK_AMARANTH_PLANKS, PromenadeBlockSetTypes.DARK_AMARANTH)); + public static final Block DARK_AMARANTH_TRAPDOOR = register("dark_amaranth_trapdoor", BlockFactory.trapdoor(DARK_AMARANTH_PLANKS, PromenadeBlockSetTypes.DARK_AMARANTH)); + public static final Block DARK_AMARANTH_BUTTON = register("dark_amaranth_button", BlockFactory.woodenButton(DARK_AMARANTH_PLANKS, PromenadeBlockSetTypes.DARK_AMARANTH)); + public static final Block DARK_AMARANTH_PRESSURE_PLATE = register("dark_amaranth_pressure_plate", BlockFactory.pressurePlate(DARK_AMARANTH_PLANKS, PromenadeBlockSetTypes.DARK_AMARANTH)); + public static final Block DARK_AMARANTH_SIGN = register("dark_amaranth_sign", BlockFactory.sign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH)); + public static final Block DARK_AMARANTH_WALL_SIGN = register("dark_amaranth_wall_sign", BlockFactory.wallSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH)); + public static final Block DARK_AMARANTH_HANGING_SIGN = register("dark_amaranth_hanging_sign", BlockFactory.hangingSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH, BlockSoundGroup.NETHER_WOOD_HANGING_SIGN)); + public static final Block DARK_AMARANTH_WALL_HANGING_SIGN = register("dark_amaranth_wall_hanging_sign", BlockFactory.wallHangingSign(DARK_AMARANTH_PLANKS, PromenadeWoodTypes.DARK_AMARANTH, BlockSoundGroup.NETHER_WOOD_HANGING_SIGN)); + + public static final Block DARK_AMARANTH_FUNGUS = register("dark_amaranth_fungus", BlockFactory.fungus(MapColor.PURPLE, PromenadeConfiguredFeatures.PLANTED_DARK_AMARANTH_FUNGUS, PromenadeBlockTags.DARK_AMARANTH_FUNGUS_PLACEABLE_ON, PromenadeBlockTags.DARK_AMARANTH_FUNGUS_GROWABLE_ON)); + public static final Block POTTED_DARK_AMARANTH_FUNGUS = register("potted_dark_amaranth_fungus", BlockFactory.pot(DARK_AMARANTH_FUNGUS)); + + public static final Block SOUL_SHROOMLIGHT = register("soul_shroomlight", BlockFactory.of(AbstractBlock.Settings.create().mapColor(MapColor.LIGHT_BLUE).strength(1.0F).sounds(BlockSoundGroup.SHROOMLIGHT).luminance(state -> 10))); + + public static final Block COILED_VINES = register("coiled_vines", BlockFactory.of( + CoiledVinesBlock::new, + AbstractBlock.Settings.create() + .mapColor(MapColor.PURPLE) + .ticksRandomly() + .noCollision() + .breakInstantly() + .sounds(BlockSoundGroup.WEEPING_VINES) + .pistonBehavior(PistonBehavior.DESTROY) + )); + public static final Block COILED_VINES_PLANT = register("coiled_vines_plant", BlockFactory.of( + CoiledVinesPlantBlock::new, + AbstractBlock.Settings.create() + .mapColor(MapColor.PURPLE) + .noCollision() + .breakInstantly() + .sounds(BlockSoundGroup.WEEPING_VINES) + .pistonBehavior(PistonBehavior.DESTROY) + ).noItem()); + + public static final Block MOAI = register("moai", BlockFactory.of(MoaiBlock::new, AbstractBlock.Settings.copy(Blocks.TUFF).mapColor(MapColor.TERRACOTTA_LIGHT_GRAY)).itemSettings(s -> s.equipmentSlot((entity, stack) -> EquipmentSlot.HEAD))); + + public static final Block BLUEBERRY_BUSH = register("blueberry_bush", BlockFactory.of(s -> new BerryBushBlock(PromenadeItemKeys.BLUEBERRIES, false, s), AbstractBlock.Settings.create() + .mapColor(MapColor.DARK_GREEN) + .ticksRandomly() + .noCollision() + .sounds(BlockSoundGroup.SWEET_BERRY_BUSH) + .pistonBehavior(PistonBehavior.DESTROY)).noItem()); + + private static RegistryKey keyOf(String id) { + return RegistryKey.of(RegistryKeys.BLOCK, Promenade.id(id)); + } + + private static Block register(RegistryKey key, BlockBuilder builder) { + return builder.register(key); + } + + private static Block register(String id, BlockBuilder builder) { + return register(keyOf(id), builder); + } } diff --git a/src/main/java/fr/hugman/promenade/block/RootsBlock.java b/src/main/java/fr/hugman/promenade/block/RootsBlock.java index dcf06334..e78b5aac 100644 --- a/src/main/java/fr/hugman/promenade/block/RootsBlock.java +++ b/src/main/java/fr/hugman/promenade/block/RootsBlock.java @@ -1,21 +1,32 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; +import java.util.function.Predicate; + import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; -import java.util.function.Predicate; - //TODO: codec public class RootsBlock extends net.minecraft.block.RootsBlock { - private final Predicate canPlantOn; + private final Predicate canPlantOn; - public RootsBlock(Predicate canPlantOn, Settings settings) { - super(settings); - this.canPlantOn = canPlantOn; - } + public RootsBlock(Predicate canPlantOn, Settings settings) { + super(settings); + this.canPlantOn = canPlantOn; + } - protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { - return this.canPlantOn.test(floor); - } + protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + return this.canPlantOn.test(floor); + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/SaplingBlock.java b/src/main/java/fr/hugman/promenade/block/SaplingBlock.java index dec55b23..ba013ceb 100644 --- a/src/main/java/fr/hugman/promenade/block/SaplingBlock.java +++ b/src/main/java/fr/hugman/promenade/block/SaplingBlock.java @@ -1,24 +1,36 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; +import java.util.function.Predicate; + import net.minecraft.block.BlockState; import net.minecraft.block.SaplingGenerator; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; -import java.util.function.Predicate; - //TODO: codec public class SaplingBlock extends net.minecraft.block.SaplingBlock { - private final Predicate predicate; + private final Predicate predicate; - public SaplingBlock(SaplingGenerator saplingGenerator, Predicate predicate, Settings settings) { - super(saplingGenerator, settings); - this.predicate = predicate; - } + public SaplingBlock(SaplingGenerator saplingGenerator, Predicate predicate, Settings settings) { + super(saplingGenerator, settings); + this.predicate = predicate; + } - @Override - protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { - if (predicate != null) return predicate.test(floor); - return super.canPlantOnTop(floor, world, pos); - } + @Override + protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + if (predicate != null) + return predicate.test(floor); + return super.canPlantOnTop(floor, world, pos); + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/block/SnowyLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/SnowyLeavesBlock.java index 576e63c7..1d8446be 100644 --- a/src/main/java/fr/hugman/promenade/block/SnowyLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/SnowyLeavesBlock.java @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import net.minecraft.block.Block; @@ -14,34 +25,35 @@ import net.minecraft.world.tick.ScheduledTickView; public abstract class SnowyLeavesBlock extends LeavesBlock { - public static final BooleanProperty BOTTOM = Properties.BOTTOM; + public static final BooleanProperty BOTTOM = Properties.BOTTOM; - public SnowyLeavesBlock(float leafParticleChance, Settings settings) { - super(leafParticleChance, settings); - this.setDefaultState(this.getDefaultState().with(BOTTOM, false)); - } + public SnowyLeavesBlock(float leafParticleChance, Settings settings) { + super(leafParticleChance, settings); + this.setDefaultState(this.getDefaultState().with(BOTTOM, false)); + } - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(BOTTOM); - } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(BOTTOM); + } - @Override - public BlockState getPlacementState(ItemPlacementContext context) { - BlockState state = super.getPlacementState(context); - if (state == null) return null; - BlockState stateBelow = context.getWorld().getBlockState(context.getBlockPos().down()); - return state.with(BOTTOM, !isSnow(stateBelow)); - } + @Override + public BlockState getPlacementState(ItemPlacementContext context) { + BlockState state = super.getPlacementState(context); + if (state == null) + return null; + BlockState stateBelow = context.getWorld().getBlockState(context.getBlockPos().down()); + return state.with(BOTTOM, !isSnow(stateBelow)); + } - @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - BlockState stateBelow = world.getBlockState(pos.down()); - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random).with(BOTTOM, !isSnow(stateBelow)); - } + @Override + protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { + BlockState stateBelow = world.getBlockState(pos.down()); + return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random).with(BOTTOM, !isSnow(stateBelow)); + } - public static boolean isSnow(BlockState state) { - return state.getBlock() instanceof SnowyLeavesBlock; - } + public static boolean isSnow(BlockState state) { + return state.getBlock() instanceof SnowyLeavesBlock; + } } diff --git a/src/main/java/fr/hugman/promenade/block/StrippedMapleLogBlock.java b/src/main/java/fr/hugman/promenade/block/StrippedMapleLogBlock.java index 3aef8336..56fe21bb 100644 --- a/src/main/java/fr/hugman/promenade/block/StrippedMapleLogBlock.java +++ b/src/main/java/fr/hugman/promenade/block/StrippedMapleLogBlock.java @@ -1,8 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import fr.hugman.promenade.block.property.PromenadeBlockProperties; -import fr.hugman.promenade.item.PromenadeItems; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.PillarBlock; @@ -21,47 +31,50 @@ import net.minecraft.world.World; import net.minecraft.world.event.GameEvent; +import fr.hugman.promenade.block.property.PromenadeBlockProperties; +import fr.hugman.promenade.item.PromenadeItems; + //TODO make generic public class StrippedMapleLogBlock extends PillarBlock { - public static final MapCodec CODEC = createCodec(StrippedMapleLogBlock::new); - public static final BooleanProperty DRIP = PromenadeBlockProperties.DRIP; + public static final MapCodec CODEC = createCodec(StrippedMapleLogBlock::new); + public static final BooleanProperty DRIP = PromenadeBlockProperties.DRIP; - //TODO : add dispenser behavior + //TODO : add dispenser behavior - public StrippedMapleLogBlock(Settings settings) { - super(settings); - this.setDefaultState(this.getDefaultState().with(DRIP, false)); - } + public StrippedMapleLogBlock(Settings settings) { + super(settings); + this.setDefaultState(this.getDefaultState().with(DRIP, false)); + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(DRIP); - } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(DRIP); + } - @Override - protected ActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - // if the player is holding a bottle, they can collect the syrup - if (state.get(DRIP)) { - if (stack.getItem() == Items.GLASS_BOTTLE) { - stack.decrement(1); - world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F); - if (stack.isEmpty()) { - player.setStackInHand(hand, new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE)); - } else if (!player.getInventory().insertStack(new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE))) { - player.dropItem(new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE), false); - } - world.emitGameEvent(player, GameEvent.FLUID_PICKUP, pos); - player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem())); - world.setBlockState(pos, state.with(DRIP, false)); - return ActionResult.SUCCESS; - } - } - return super.onUseWithItem(stack, state, world, pos, player, hand, hit); - } + @Override + protected ActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + // if the player is holding a bottle, they can collect the syrup + if (state.get(DRIP)) { + if (stack.getItem() == Items.GLASS_BOTTLE) { + stack.decrement(1); + world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F); + if (stack.isEmpty()) { + player.setStackInHand(hand, new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE)); + } else if (!player.getInventory().insertStack(new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE))) { + player.dropItem(new ItemStack(PromenadeItems.MAPLE_SYRUP_BOTTLE), false); + } + world.emitGameEvent(player, GameEvent.FLUID_PICKUP, pos); + player.incrementStat(Stats.USED.getOrCreateStat(stack.getItem())); + world.setBlockState(pos, state.with(DRIP, false)); + return ActionResult.SUCCESS; + } + } + return super.onUseWithItem(stack, state, world, pos, player, hand, hit); + } } diff --git a/src/main/java/fr/hugman/promenade/block/TintedParticleExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/TintedParticleExtendedLeavesBlock.java index 594b4f22..df943d96 100644 --- a/src/main/java/fr/hugman/promenade/block/TintedParticleExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/TintedParticleExtendedLeavesBlock.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleUtil; import net.minecraft.particle.TintedParticleEffect; @@ -11,22 +23,22 @@ import net.minecraft.world.World; public class TintedParticleExtendedLeavesBlock extends ExtendedLeavesBlock { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(tintedParticleLeavesBlock -> tintedParticleLeavesBlock.leafParticleChance), - createSettingsCodec() - ).apply(instance, TintedParticleExtendedLeavesBlock::new)); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(tintedParticleLeavesBlock -> tintedParticleLeavesBlock.leafParticleChance), + createSettingsCodec() + ).apply(instance, TintedParticleExtendedLeavesBlock::new)); - public TintedParticleExtendedLeavesBlock(float f, Settings settings) { - super(f, settings); - } + public TintedParticleExtendedLeavesBlock(float f, Settings settings) { + super(f, settings); + } - @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, TintedParticleEffect.create(ParticleTypes.TINTED_LEAVES, world.getBlockColor(pos))); - } + @Override + protected void spawnLeafParticle(World world, BlockPos pos, Random random) { + ParticleUtil.spawnParticle(world, pos, random, TintedParticleEffect.create(ParticleTypes.TINTED_LEAVES, world.getBlockColor(pos))); + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } } diff --git a/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyExtendedLeavesBlock.java index 91fd6bbd..5c432c33 100644 --- a/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyExtendedLeavesBlock.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.ItemPlacementContext; @@ -20,48 +32,49 @@ import net.minecraft.world.tick.ScheduledTickView; public class TintedParticleSnowyExtendedLeavesBlock extends ExtendedLeavesBlock { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), - createSettingsCodec() - ).apply(instance, TintedParticleSnowyExtendedLeavesBlock::new)); - public static final BooleanProperty BOTTOM = Properties.BOTTOM; + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), + createSettingsCodec() + ).apply(instance, TintedParticleSnowyExtendedLeavesBlock::new)); + public static final BooleanProperty BOTTOM = Properties.BOTTOM; - public TintedParticleSnowyExtendedLeavesBlock(float leafParticleChance, Settings settings) { - super(leafParticleChance, settings); - this.setDefaultState(this.getDefaultState().with(BOTTOM, false)); - } + public TintedParticleSnowyExtendedLeavesBlock(float leafParticleChance, Settings settings) { + super(leafParticleChance, settings); + this.setDefaultState(this.getDefaultState().with(BOTTOM, false)); + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(BOTTOM); - } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(BOTTOM); + } - @Override - public BlockState getPlacementState(ItemPlacementContext context) { - BlockState state = super.getPlacementState(context); - if (state == null) return null; - BlockState stateBelow = context.getWorld().getBlockState(context.getBlockPos().down()); - return state.with(BOTTOM, !isSnow(stateBelow)); - } + @Override + public BlockState getPlacementState(ItemPlacementContext context) { + BlockState state = super.getPlacementState(context); + if (state == null) + return null; + BlockState stateBelow = context.getWorld().getBlockState(context.getBlockPos().down()); + return state.with(BOTTOM, !isSnow(stateBelow)); + } - @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - BlockState stateBelow = world.getBlockState(pos.down()); - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random).with(BOTTOM, !isSnow(stateBelow)); - } + @Override + protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { + BlockState stateBelow = world.getBlockState(pos.down()); + return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random).with(BOTTOM, !isSnow(stateBelow)); + } - public static boolean isSnow(BlockState state) { - return state.getBlock() instanceof TintedParticleSnowyExtendedLeavesBlock; - } + public static boolean isSnow(BlockState state) { + return state.getBlock() instanceof TintedParticleSnowyExtendedLeavesBlock; + } - @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, TintedParticleEffect.create(ParticleTypes.TINTED_LEAVES, world.getBlockColor(pos))); - } + @Override + protected void spawnLeafParticle(World world, BlockPos pos, Random random) { + ParticleUtil.spawnParticle(world, pos, random, TintedParticleEffect.create(ParticleTypes.TINTED_LEAVES, world.getBlockColor(pos))); + } } diff --git a/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyLeavesBlock.java index cdd8114e..1abf4f8c 100644 --- a/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/TintedParticleSnowyLeavesBlock.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleUtil; import net.minecraft.particle.TintedParticleEffect; @@ -11,22 +23,22 @@ import net.minecraft.world.World; public class TintedParticleSnowyLeavesBlock extends SnowyLeavesBlock { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(tintedParticleLeavesBlock -> tintedParticleLeavesBlock.leafParticleChance), - createSettingsCodec() - ).apply(instance, TintedParticleSnowyLeavesBlock::new)); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(tintedParticleLeavesBlock -> tintedParticleLeavesBlock.leafParticleChance), + createSettingsCodec() + ).apply(instance, TintedParticleSnowyLeavesBlock::new)); - public TintedParticleSnowyLeavesBlock(float f, Settings settings) { - super(f, settings); - } + public TintedParticleSnowyLeavesBlock(float f, Settings settings) { + super(f, settings); + } - @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, TintedParticleEffect.create(ParticleTypes.TINTED_LEAVES, world.getBlockColor(pos))); - } + @Override + protected void spawnLeafParticle(World world, BlockPos pos, Random random) { + ParticleUtil.spawnParticle(world, pos, random, TintedParticleEffect.create(ParticleTypes.TINTED_LEAVES, world.getBlockColor(pos))); + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } } diff --git a/src/main/java/fr/hugman/promenade/block/UntintedParticleExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/UntintedParticleExtendedLeavesBlock.java index 85da809e..a3bf4346 100644 --- a/src/main/java/fr/hugman/promenade/block/UntintedParticleExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/UntintedParticleExtendedLeavesBlock.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleUtil; @@ -11,30 +23,30 @@ import net.minecraft.world.World; public class UntintedParticleExtendedLeavesBlock extends ExtendedLeavesBlock { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( - instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F) - .fieldOf("leaf_particle_chance") - .forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), - ParticleTypes.TYPE_CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), - createSettingsCodec() - ) - .apply(instance, UntintedParticleExtendedLeavesBlock::new) - ); - protected final ParticleEffect leafParticleEffect; + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( + instance -> instance.group( + Codecs.rangedInclusiveFloat(0.0F, 1.0F) + .fieldOf("leaf_particle_chance") + .forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), + ParticleTypes.TYPE_CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), + createSettingsCodec() + ) + .apply(instance, UntintedParticleExtendedLeavesBlock::new) + ); + protected final ParticleEffect leafParticleEffect; - public UntintedParticleExtendedLeavesBlock(float leafParticleChance, ParticleEffect leafParticleEffect, Settings settings) { - super(leafParticleChance, settings); - this.leafParticleEffect = leafParticleEffect; - } + public UntintedParticleExtendedLeavesBlock(float leafParticleChance, ParticleEffect leafParticleEffect, Settings settings) { + super(leafParticleChance, settings); + this.leafParticleEffect = leafParticleEffect; + } - @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, this.leafParticleEffect); - } + @Override + protected void spawnLeafParticle(World world, BlockPos pos, Random random) { + ParticleUtil.spawnParticle(world, pos, random, this.leafParticleEffect); + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } } diff --git a/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyExtendedLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyExtendedLeavesBlock.java index 975ee686..af7676ca 100644 --- a/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyExtendedLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyExtendedLeavesBlock.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.ItemPlacementContext; @@ -20,52 +32,53 @@ import net.minecraft.world.tick.ScheduledTickView; public class UntintedParticleSnowyExtendedLeavesBlock extends ExtendedLeavesBlock { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), - ParticleTypes.TYPE_CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), - createSettingsCodec() - ).apply(instance, UntintedParticleSnowyExtendedLeavesBlock::new)); - public static final BooleanProperty BOTTOM = Properties.BOTTOM; + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), + ParticleTypes.TYPE_CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), + createSettingsCodec() + ).apply(instance, UntintedParticleSnowyExtendedLeavesBlock::new)); + public static final BooleanProperty BOTTOM = Properties.BOTTOM; - protected final ParticleEffect leafParticleEffect; + protected final ParticleEffect leafParticleEffect; - public UntintedParticleSnowyExtendedLeavesBlock(float leafParticleChance, ParticleEffect leafParticleEffect, Settings settings) { - super(leafParticleChance, settings); - this.setDefaultState(this.getDefaultState().with(BOTTOM, false)); - this.leafParticleEffect = leafParticleEffect; - } + public UntintedParticleSnowyExtendedLeavesBlock(float leafParticleChance, ParticleEffect leafParticleEffect, Settings settings) { + super(leafParticleChance, settings); + this.setDefaultState(this.getDefaultState().with(BOTTOM, false)); + this.leafParticleEffect = leafParticleEffect; + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(BOTTOM); - } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(BOTTOM); + } - @Override - public BlockState getPlacementState(ItemPlacementContext context) { - BlockState state = super.getPlacementState(context); - if (state == null) return null; - BlockState stateBelow = context.getWorld().getBlockState(context.getBlockPos().down()); - return state.with(BOTTOM, !isSnow(stateBelow)); - } + @Override + public BlockState getPlacementState(ItemPlacementContext context) { + BlockState state = super.getPlacementState(context); + if (state == null) + return null; + BlockState stateBelow = context.getWorld().getBlockState(context.getBlockPos().down()); + return state.with(BOTTOM, !isSnow(stateBelow)); + } - @Override - protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { - BlockState stateBelow = world.getBlockState(pos.down()); - return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random).with(BOTTOM, !isSnow(stateBelow)); - } + @Override + protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) { + BlockState stateBelow = world.getBlockState(pos.down()); + return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random).with(BOTTOM, !isSnow(stateBelow)); + } - public static boolean isSnow(BlockState state) { - return state.getBlock() instanceof UntintedParticleSnowyExtendedLeavesBlock; - } + public static boolean isSnow(BlockState state) { + return state.getBlock() instanceof UntintedParticleSnowyExtendedLeavesBlock; + } - @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, this.leafParticleEffect); - } + @Override + protected void spawnLeafParticle(World world, BlockPos pos, Random random) { + ParticleUtil.spawnParticle(world, pos, random, this.leafParticleEffect); + } } diff --git a/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyLeavesBlock.java b/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyLeavesBlock.java index b8ddabc2..92f27012 100644 --- a/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyLeavesBlock.java +++ b/src/main/java/fr/hugman/promenade/block/UntintedParticleSnowyLeavesBlock.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleUtil; @@ -11,25 +23,25 @@ import net.minecraft.world.World; public class UntintedParticleSnowyLeavesBlock extends SnowyLeavesBlock { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), - ParticleTypes.TYPE_CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), - createSettingsCodec() - ).apply(instance, UntintedParticleSnowyLeavesBlock::new)); - protected final ParticleEffect leafParticleEffect; + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("leaf_particle_chance").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleChance), + ParticleTypes.TYPE_CODEC.fieldOf("leaf_particle").forGetter(untintedParticleLeavesBlock -> untintedParticleLeavesBlock.leafParticleEffect), + createSettingsCodec() + ).apply(instance, UntintedParticleSnowyLeavesBlock::new)); + protected final ParticleEffect leafParticleEffect; - public UntintedParticleSnowyLeavesBlock(float leafParticleChance, ParticleEffect leafParticleEffect, Settings settings) { - super(leafParticleChance, settings); - this.leafParticleEffect = leafParticleEffect; - } + public UntintedParticleSnowyLeavesBlock(float leafParticleChance, ParticleEffect leafParticleEffect, Settings settings) { + super(leafParticleChance, settings); + this.leafParticleEffect = leafParticleEffect; + } - @Override - protected void spawnLeafParticle(World world, BlockPos pos, Random random) { - ParticleUtil.spawnParticle(world, pos, random, this.leafParticleEffect); - } + @Override + protected void spawnLeafParticle(World world, BlockPos pos, Random random) { + ParticleUtil.spawnParticle(world, pos, random, this.leafParticleEffect); + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } } diff --git a/src/main/java/fr/hugman/promenade/block/WitherRosePileBlock.java b/src/main/java/fr/hugman/promenade/block/WitherRosePileBlock.java index 7dc4dc82..1000685e 100644 --- a/src/main/java/fr/hugman/promenade/block/WitherRosePileBlock.java +++ b/src/main/java/fr/hugman/promenade/block/WitherRosePileBlock.java @@ -1,8 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block; import com.mojang.serialization.MapCodec; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; @@ -18,45 +28,48 @@ import net.minecraft.world.Difficulty; import net.minecraft.world.World; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + public class WitherRosePileBlock extends PileBlock { - public static final MapCodec CODEC = createCodec(WitherRosePileBlock::new); - - public WitherRosePileBlock(Settings builder) { - super(builder); - } - - @Override - protected MapCodec getCodec() { - return CODEC; - } - - @Override - public boolean canPlantOnTop(BlockState state, BlockView world, BlockPos pos) { - return super.canPlantOnTop(state, world, pos) || state.getBlock() == Blocks.SOUL_SAND; - } - - @Override - @Environment(EnvType.CLIENT) - public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) { - for (int i = 0; i < 5; ++i) { - if (rand.nextBoolean()) { - world.addParticleClient(ParticleTypes.SMOKE, (double) pos.getX() + (double) (rand.nextInt(17) / 16), (double) pos.getY() + (0.5D - (double) rand.nextFloat()), (double) pos.getZ() + (double) (rand.nextInt(17) / 16), 0.0D, 0.0D, 0.0D); - } - } - } - - @Override - protected void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity, EntityCollisionHandler handler) { - if (world instanceof ServerWorld serverWorld - && world.getDifficulty() != Difficulty.PEACEFUL - && entity instanceof LivingEntity livingEntity - && !livingEntity.isInvulnerableTo(serverWorld, world.getDamageSources().wither())) { - livingEntity.addStatusEffect(this.getContactEffect()); - } - super.onEntityCollision(state, world, pos, entity, handler); - } - - public StatusEffectInstance getContactEffect() { - return new StatusEffectInstance(StatusEffects.WITHER, 40); - } + public static final MapCodec CODEC = createCodec(WitherRosePileBlock::new); + + public WitherRosePileBlock(Settings builder) { + super(builder); + } + + @Override + protected MapCodec getCodec() { + return CODEC; + } + + @Override + public boolean canPlantOnTop(BlockState state, BlockView world, BlockPos pos) { + return super.canPlantOnTop(state, world, pos) || state.getBlock() == Blocks.SOUL_SAND; + } + + @Override + @Environment(EnvType.CLIENT) + public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) { + for (int i = 0; i < 5; ++i) { + if (rand.nextBoolean()) { + world.addParticleClient(ParticleTypes.SMOKE, (double) pos.getX() + (double) (rand.nextInt(17) / 16), (double) pos.getY() + (0.5D - (double) rand.nextFloat()), (double) pos.getZ() + (double) (rand.nextInt(17) / 16), 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + protected void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity, EntityCollisionHandler handler) { + if (world instanceof ServerWorld serverWorld + && world.getDifficulty() != Difficulty.PEACEFUL + && entity instanceof LivingEntity livingEntity + && !livingEntity.isInvulnerableTo(serverWorld, world.getDamageSources().wither())) { + livingEntity.addStatusEffect(this.getContactEffect()); + } + super.onEntityCollision(state, world, pos, entity, handler); + } + + public StatusEffectInstance getContactEffect() { + return new StatusEffectInstance(StatusEffects.WITHER, 40); + } } diff --git a/src/main/java/fr/hugman/promenade/block/dispenser/PromenadeDispenserBehaviors.java b/src/main/java/fr/hugman/promenade/block/dispenser/PromenadeDispenserBehaviors.java index 5dfb5d02..3df69253 100644 --- a/src/main/java/fr/hugman/promenade/block/dispenser/PromenadeDispenserBehaviors.java +++ b/src/main/java/fr/hugman/promenade/block/dispenser/PromenadeDispenserBehaviors.java @@ -1,7 +1,16 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block.dispenser; -import fr.hugman.promenade.entity.PromenadeEntityTypes; -import fr.hugman.promenade.item.PromenadeItems; import net.minecraft.block.DispenserBlock; import net.minecraft.block.dispenser.BoatDispenserBehavior; import net.minecraft.block.dispenser.ItemDispenserBehavior; @@ -13,38 +22,41 @@ import net.minecraft.util.math.Direction; import net.minecraft.world.event.GameEvent; +import fr.hugman.promenade.entity.PromenadeEntityTypes; +import fr.hugman.promenade.item.PromenadeItems; + public class PromenadeDispenserBehaviors { - public static void register() { - ItemDispenserBehavior spawnEggBehavior = new ItemDispenserBehavior() { - @Override - public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { - Direction direction = pointer.state().get(DispenserBlock.FACING); - EntityType entityType = ((SpawnEggItem) stack.getItem()).getEntityType(stack); - - try { - entityType.spawnFromItemStack(pointer.world(), stack, null, pointer.pos().offset(direction), SpawnReason.DISPENSER, direction != Direction.UP, false); - } catch (Exception var6) { - LOGGER.error("Error while dispensing spawn egg from dispenser at {}", pointer.pos(), var6); - return ItemStack.EMPTY; - } - - stack.decrement(1); - pointer.world().emitGameEvent(null, GameEvent.ENTITY_PLACE, pointer.pos()); - return stack; - } - }; - - DispenserBlock.registerBehavior(PromenadeItems.SAKURA_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.SAKURA_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.SAKURA_CHEST_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.SAKURA_CHEST_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.MAPLE_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.MAPLE_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.MAPLE_CHEST_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.MAPLE_CHEST_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.PALM_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.PALM_BOAT)); - DispenserBlock.registerBehavior(PromenadeItems.PALM_CHEST_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.PALM_CHEST_BOAT)); - - - DispenserBlock.registerBehavior(PromenadeItems.CAPYBARA_SPAWN_EGG, spawnEggBehavior); - DispenserBlock.registerBehavior(PromenadeItems.DUCK_SPAWN_EGG, spawnEggBehavior); - DispenserBlock.registerBehavior(PromenadeItems.LUSH_CREEPER_SPAWN_EGG, spawnEggBehavior); - DispenserBlock.registerBehavior(PromenadeItems.SUNKEN_SPAWN_EGG, spawnEggBehavior); - } + public static void register() { + ItemDispenserBehavior spawnEggBehavior = new ItemDispenserBehavior() { + @Override + public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { + Direction direction = pointer.state().get(DispenserBlock.FACING); + EntityType entityType = ((SpawnEggItem) stack.getItem()).getEntityType(stack); + + try { + entityType.spawnFromItemStack(pointer.world(), stack, null, pointer.pos().offset(direction), SpawnReason.DISPENSER, direction != Direction.UP, false); + } catch (Exception var6) { + LOGGER.error("Error while dispensing spawn egg from dispenser at {}", pointer.pos(), var6); + return ItemStack.EMPTY; + } + + stack.decrement(1); + pointer.world().emitGameEvent(null, GameEvent.ENTITY_PLACE, pointer.pos()); + return stack; + } + }; + + DispenserBlock.registerBehavior(PromenadeItems.SAKURA_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.SAKURA_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.SAKURA_CHEST_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.SAKURA_CHEST_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.MAPLE_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.MAPLE_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.MAPLE_CHEST_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.MAPLE_CHEST_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.PALM_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.PALM_BOAT)); + DispenserBlock.registerBehavior(PromenadeItems.PALM_CHEST_BOAT, new BoatDispenserBehavior(PromenadeEntityTypes.PALM_CHEST_BOAT)); + + + DispenserBlock.registerBehavior(PromenadeItems.CAPYBARA_SPAWN_EGG, spawnEggBehavior); + DispenserBlock.registerBehavior(PromenadeItems.DUCK_SPAWN_EGG, spawnEggBehavior); + DispenserBlock.registerBehavior(PromenadeItems.LUSH_CREEPER_SPAWN_EGG, spawnEggBehavior); + DispenserBlock.registerBehavior(PromenadeItems.SUNKEN_SPAWN_EGG, spawnEggBehavior); + } } diff --git a/src/main/java/fr/hugman/promenade/block/entity/PromenadeBlockEntities.java b/src/main/java/fr/hugman/promenade/block/entity/PromenadeBlockEntities.java index c4a72a3a..b307c419 100644 --- a/src/main/java/fr/hugman/promenade/block/entity/PromenadeBlockEntities.java +++ b/src/main/java/fr/hugman/promenade/block/entity/PromenadeBlockEntities.java @@ -1,25 +1,37 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block.entity; -import fr.hugman.promenade.block.PromenadeBlocks; import net.minecraft.block.entity.BlockEntityType; +import fr.hugman.promenade.block.PromenadeBlocks; + public class PromenadeBlockEntities { - public static void addBlocksToVanillaBlockEntityTypes() { - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_WALL_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_HANGING_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_WALL_HANGING_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_WALL_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_HANGING_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_WALL_HANGING_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.PALM_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.PALM_WALL_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.PALM_HANGING_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.PALM_WALL_HANGING_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_SIGN); - BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_WALL_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN); - BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN); - } + public static void addBlocksToVanillaBlockEntityTypes() { + BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_SIGN); + BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_WALL_SIGN); + BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_HANGING_SIGN); + BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.SAKURA_WALL_HANGING_SIGN); + BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_SIGN); + BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_WALL_SIGN); + BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_HANGING_SIGN); + BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.MAPLE_WALL_HANGING_SIGN); + BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.PALM_SIGN); + BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.PALM_WALL_SIGN); + BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.PALM_HANGING_SIGN); + BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.PALM_WALL_HANGING_SIGN); + BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_SIGN); + BlockEntityType.SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_WALL_SIGN); + BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN); + BlockEntityType.HANGING_SIGN.addSupportedBlock(PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN); + } } diff --git a/src/main/java/fr/hugman/promenade/block/helper/BlockBuilder.java b/src/main/java/fr/hugman/promenade/block/helper/BlockBuilder.java index 48f17e3c..3356ab3e 100644 --- a/src/main/java/fr/hugman/promenade/block/helper/BlockBuilder.java +++ b/src/main/java/fr/hugman/promenade/block/helper/BlockBuilder.java @@ -1,5 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block.helper; +import java.util.function.Function; +import java.util.function.Supplier; + import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; @@ -9,72 +23,69 @@ import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; -import java.util.function.Function; -import java.util.function.Supplier; - public class BlockBuilder { - private static final Function DEFAULT_FACTORY = Block::new; - private static final Supplier DEFAULT_ITEM_SETTINGS = () -> new Item.Settings().useBlockPrefixedTranslationKey(); + private static final Function DEFAULT_FACTORY = Block::new; + private static final Supplier DEFAULT_ITEM_SETTINGS = () -> new Item.Settings().useBlockPrefixedTranslationKey(); - private Function factory = DEFAULT_FACTORY; - private AbstractBlock.Settings settings; + private Function factory = DEFAULT_FACTORY; + private AbstractBlock.Settings settings; - private Item.Settings itemSettings = DEFAULT_ITEM_SETTINGS.get(); + private Item.Settings itemSettings = DEFAULT_ITEM_SETTINGS.get(); - public BlockBuilder(Function factory, AbstractBlock.Settings settings) { - this.factory = factory; - this.settings = settings; - } + public BlockBuilder(Function factory, AbstractBlock.Settings settings) { + this.factory = factory; + this.settings = settings; + } - public BlockBuilder(AbstractBlock.Settings settings) { - this.settings = settings; - } + public BlockBuilder(AbstractBlock.Settings settings) { + this.settings = settings; + } - public BlockBuilder(Block block) { - // retrieves the block's values - this.settings = AbstractBlock.Settings.copyShallow(block); - } + public BlockBuilder(Block block) { + // retrieves the block's values + this.settings = AbstractBlock.Settings.copyShallow(block); + } - public BlockBuilder factory(Function factory) { - this.factory = factory; - return this; - } + public BlockBuilder factory(Function factory) { + this.factory = factory; + return this; + } - public BlockBuilder settings(AbstractBlock.Settings settings) { - this.settings = settings; - return this; - } + public BlockBuilder settings(AbstractBlock.Settings settings) { + this.settings = settings; + return this; + } - public BlockBuilder settings(Function settingsConsumer) { - this.settings = settingsConsumer.apply(this.settings); - return this; - } + public BlockBuilder settings(Function settingsConsumer) { + this.settings = settingsConsumer.apply(this.settings); + return this; + } - public BlockBuilder itemSettings(Item.Settings settings) { - this.itemSettings = settings; - return this; - } + public BlockBuilder itemSettings(Item.Settings settings) { + this.itemSettings = settings; + return this; + } - public BlockBuilder itemSettings(Function settings) { - this.itemSettings = settings.apply(this.itemSettings); - return this; - } + public BlockBuilder itemSettings(Function settings) { + this.itemSettings = settings.apply(this.itemSettings); + return this; + } - public BlockBuilder noItem() { - this.itemSettings = null; - return this; - } + public BlockBuilder noItem() { + this.itemSettings = null; + return this; + } - public Block register(RegistryKey key) { - if (this.factory == null) { - throw new IllegalStateException("Cannot register block: factory is not set!"); - } - var block = this.factory.apply(this.settings.registryKey(key)); - Registry.register(Registries.BLOCK, key, block); - if (this.itemSettings instanceof Item.Settings) { - var itemRegistryKey = RegistryKey.of(RegistryKeys.ITEM, key.getValue()); - Registry.register(Registries.ITEM, itemRegistryKey, new BlockItem(block, this.itemSettings.registryKey(itemRegistryKey))); - } - return block; - } + public Block register(RegistryKey key) { + if (this.factory == null) { + throw new IllegalStateException("Cannot register block: factory is not set!"); + } + var block = this.factory.apply(this.settings.registryKey(key)); + Registry.register(Registries.BLOCK, key, block); + if (this.itemSettings instanceof Item.Settings) { + var itemRegistryKey = RegistryKey.of(RegistryKeys.ITEM, key.getValue()); + Registry.register(Registries.ITEM, itemRegistryKey, new BlockItem(block, this.itemSettings.registryKey(itemRegistryKey))); + } + return block; + } } diff --git a/src/main/java/fr/hugman/promenade/block/helper/BlockFactory.java b/src/main/java/fr/hugman/promenade/block/helper/BlockFactory.java index a3d5fd83..0ddcaded 100644 --- a/src/main/java/fr/hugman/promenade/block/helper/BlockFactory.java +++ b/src/main/java/fr/hugman/promenade/block/helper/BlockFactory.java @@ -1,10 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block.helper; -import fr.hugman.promenade.block.HangingLeavesBlock; -import fr.hugman.promenade.block.PileBlock; -import fr.hugman.promenade.block.TintedParticleSnowyLeavesBlock; -import fr.hugman.promenade.block.UntintedParticleSnowyLeavesBlock; -import fr.hugman.promenade.sound.PromenadeBlockSounds; +import java.util.function.Function; +import java.util.function.Predicate; + import net.minecraft.block.*; import net.minecraft.block.enums.NoteBlockInstrument; import net.minecraft.block.piston.PistonBehavior; @@ -15,250 +24,254 @@ import net.minecraft.util.math.Direction; import net.minecraft.world.gen.feature.ConfiguredFeature; -import java.util.function.Function; -import java.util.function.Predicate; +import fr.hugman.promenade.block.HangingLeavesBlock; +import fr.hugman.promenade.block.PileBlock; +import fr.hugman.promenade.block.TintedParticleSnowyLeavesBlock; +import fr.hugman.promenade.block.UntintedParticleSnowyLeavesBlock; +import fr.hugman.promenade.sound.PromenadeBlockSounds; public final class BlockFactory { - public static BlockBuilder of(Function factory, AbstractBlock.Settings settings) { - return new BlockBuilder(factory, settings); - } - - public static BlockBuilder of(AbstractBlock.Settings settings) { - return new BlockBuilder(settings); - } - - public static BlockBuilder copy(Block block) { - return new BlockBuilder(block); - } - - public static BlockBuilder slab(Block baseBlock) { - return copy(baseBlock).factory(SlabBlock::new); - } - - public static BlockBuilder stairs(Block baseBlock) { - return copy(baseBlock).factory(s -> new StairsBlock(baseBlock.getDefaultState(), s)); - } - - public static BlockBuilder wall(Block baseBlock) { - return copy(baseBlock).factory(WallBlock::new).settings(AbstractBlock.Settings.copyShallow(baseBlock).solid()); - } - - public static BlockBuilder fence(Block baseBlock) { - return copy(baseBlock).factory(FenceBlock::new).settings(AbstractBlock.Settings.copyShallow(baseBlock)); - } - - public static BlockBuilder fenceGate(Block baseBlock, WoodType woodType) { - return copy(baseBlock).factory(s -> new FenceGateBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock).solid()); - } - - public static BlockBuilder trapdoor(Block baseBlock, BlockSetType setType) { - return copy(baseBlock).factory(s -> new TrapdoorBlock(setType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) - .strength(3.0f) - .nonOpaque() - .allowsSpawning(Blocks::never)); - } - - public static BlockBuilder door(Block baseBlock, BlockSetType setType) { - return copy(baseBlock).factory(s -> new DoorBlock(setType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) - .strength(3.0f) - .nonOpaque() - .pistonBehavior(PistonBehavior.DESTROY)); - } - - public static BlockBuilder woodenButton(Block baseBlock, BlockSetType setType) { - return copy(baseBlock).factory(s -> new ButtonBlock(setType, 30, s)).settings(AbstractBlock.Settings.create() - .strength(0.5f) - .noCollision() - .pistonBehavior(PistonBehavior.DESTROY) - .sounds(baseBlock.getDefaultState().getSoundGroup())); - } - - public static BlockBuilder pressurePlate(Block baseBlock, BlockSetType setType) { - return copy(baseBlock).factory(s -> new PressurePlateBlock(setType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) - .solid() - .strength(0.5f) - .pistonBehavior(PistonBehavior.DESTROY) - .requiresTool() - .noCollision()); - } - - public static BlockBuilder sign(Block baseBlock, WoodType woodType) { - return copy(baseBlock).factory(s -> new SignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) - .mapColor(baseBlock.getDefaultMapColor()) - .solid() - .noCollision() - .strength(1.0F)).noItem(); - } - - public static BlockBuilder wallSign(Block standingSign, WoodType woodType) { - return copy(standingSign).factory(s -> new WallSignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(standingSign) - .lootTable(standingSign.getLootTableKey()) - .mapColor(standingSign.getDefaultMapColor()) - .solid() - .noCollision() - .strength(1.0F)).noItem(); - } - - public static BlockBuilder hangingSign(Block baseBlock, WoodType woodType, BlockSoundGroup soundGroup) { - return copy(baseBlock).factory(s -> new HangingSignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) - .mapColor(baseBlock.getDefaultMapColor()) - .solid() - .noCollision() - .strength(1.0F) - .sounds(soundGroup)).noItem(); - } - - public static BlockBuilder wallHangingSign(Block standingSign, WoodType woodType, BlockSoundGroup soundGroup) { - return copy(standingSign).factory(s -> new WallHangingSignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(standingSign) - .lootTable(standingSign.getLootTableKey()) - .mapColor(standingSign.getDefaultMapColor()) - .solid() - .noCollision() - .strength(1.0F) - .sounds(soundGroup)).noItem(); - } - - public static BlockBuilder log(MapColor woodColor, MapColor barkColor, BlockSoundGroup sounds, boolean flammable) { - return log(woodColor, sounds, flammable) - .settings(settings -> settings.mapColor((state) -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? woodColor : barkColor)); - } - - public static BlockBuilder log(MapColor color, BlockSoundGroup sounds, boolean flammable) { - AbstractBlock.Settings settings = AbstractBlock.Settings.create() - .mapColor(color) - .instrument(NoteBlockInstrument.BASS) - .strength(2.0F) - .sounds(sounds); - if (flammable) settings.burnable(); - var builder = new BlockBuilder(PillarBlock::new, settings); - return builder; - } - - public static BlockBuilder sapling(MapColor mapColor, SaplingGenerator generator) { - return new BlockBuilder(s -> new SaplingBlock(generator, s), AbstractBlock.Settings.create() - .mapColor(mapColor) - .sounds(BlockSoundGroup.GRASS) - .breakInstantly() - .noCollision() - .ticksRandomly() - .pistonBehavior(PistonBehavior.DESTROY)); - } - - public static BlockBuilder sapling(MapColor mapColor, SaplingGenerator generator, Predicate saplingSoilPredicate) { - return sapling(mapColor, generator).factory(settings -> new fr.hugman.promenade.block.SaplingBlock(generator, saplingSoilPredicate, settings)); - } - - public static BlockBuilder leaves(MapColor mapColor) { - return new BlockBuilder(s -> new TintedParticleLeavesBlock(0.01f, s), AbstractBlock.Settings.create() - .mapColor(mapColor) - .strength(0.2f) - .ticksRandomly() - .sounds(BlockSoundGroup.GRASS) - .nonOpaque() - .allowsSpawning(Blocks::never) - .suffocates(Blocks::never) - .blockVision(Blocks::never) - .pistonBehavior(PistonBehavior.DESTROY) - .solidBlock(Blocks::never)); - } - - public static BlockBuilder leaves(MapColor mapColor, BlockSoundGroup soundGroup, float particleChance, ParticleEffect fallingParticle) { - return new BlockBuilder(s -> new UntintedParticleLeavesBlock(particleChance, fallingParticle, s), AbstractBlock.Settings.create() - .mapColor(mapColor) - .strength(0.2f) - .ticksRandomly() - .sounds(soundGroup) - .nonOpaque() - .burnable() - .allowsSpawning(Blocks::never) - .suffocates(Blocks::never) - .blockVision(Blocks::never) - .pistonBehavior(PistonBehavior.DESTROY) - .solidBlock(Blocks::never)); - } - - public static BlockBuilder hangingLeaves(MapColor mapColor) { - return new BlockBuilder(HangingLeavesBlock::new, AbstractBlock.Settings.create() - .mapColor(mapColor) - .sounds(BlockSoundGroup.GRASS) - .replaceable().noCollision().breakInstantly() - .burnable() - .pistonBehavior(PistonBehavior.DESTROY)); - } - - public static BlockBuilder snowyLeaves() { - return new BlockBuilder(s -> new TintedParticleSnowyLeavesBlock(0.01f, s), AbstractBlock.Settings.create() - .mapColor(MapColor.WHITE) - .strength(0.2f) - .ticksRandomly() - .sounds(PromenadeBlockSounds.SNOWY_LEAVES) - .nonOpaque() - .burnable() - .allowsSpawning(Blocks::canSpawnOnLeaves) - .suffocates(Blocks::never) - .blockVision(Blocks::never) - .pistonBehavior(PistonBehavior.DESTROY) - .solidBlock(Blocks::never)); - } - - public static BlockBuilder snowyLeaves(BlockSoundGroup soundGroup) { - return snowyLeaves().settings(settings -> settings.sounds(soundGroup)); - } - - public static BlockBuilder snowyLeaves(float particleChance, ParticleEffect particle) { - return snowyLeaves().factory(s -> new UntintedParticleSnowyLeavesBlock(particleChance, particle, s)); - } - - public static BlockBuilder snowyLeaves(float particleChance, ParticleEffect particle, BlockSoundGroup soundGroup) { - return snowyLeaves(particleChance, particle).settings(settings -> settings.sounds(soundGroup)); - } - - public static BlockBuilder pot(Block block) { - return new BlockBuilder(s -> new FlowerPotBlock(block, s), AbstractBlock.Settings.create() - .breakInstantly() - .nonOpaque() - .luminance(state -> block.getDefaultState().getLuminance()) - .pistonBehavior(PistonBehavior.DESTROY)); - } - - public static BlockBuilder pile() { - return pile(MapColor.DARK_GREEN); - } - - public static BlockBuilder pile(MapColor color) { - return pile(color, BlockSoundGroup.GRASS); - } - - public static BlockBuilder pile(MapColor color, BlockSoundGroup sounds) { - return new BlockBuilder(PileBlock::new, AbstractBlock.Settings.create() - .mapColor(color) - .burnable() - .strength(0.1f) - .sounds(sounds) - .noCollision() - .nonOpaque()); - } - - public static BlockBuilder fallenLeaves(MapColor color) { - return fallenLeaves(color, BlockSoundGroup.LEAF_LITTER); - } - - public static BlockBuilder fallenLeaves(MapColor color, BlockSoundGroup sounds) { - return new BlockBuilder(LeafLitterBlock::new, AbstractBlock.Settings.create() - .mapColor(color) - .replaceable() - .noCollision() - .sounds(sounds) - .pistonBehavior(PistonBehavior.DESTROY) - ); - } - - public static BlockBuilder fungus(MapColor mapColor, RegistryKey> featureKey, TagKey canPlantOn, TagKey canGrowOn) { - return of(s -> new fr.hugman.promenade.block.FungusBlock(featureKey, canPlantOn, canGrowOn, s), AbstractBlock.Settings.create() - .mapColor(mapColor) - .sounds(BlockSoundGroup.FUNGUS) - .pistonBehavior(PistonBehavior.DESTROY) - .breakInstantly() - .noCollision()); - } + public static BlockBuilder of(Function factory, AbstractBlock.Settings settings) { + return new BlockBuilder(factory, settings); + } + + public static BlockBuilder of(AbstractBlock.Settings settings) { + return new BlockBuilder(settings); + } + + public static BlockBuilder copy(Block block) { + return new BlockBuilder(block); + } + + public static BlockBuilder slab(Block baseBlock) { + return copy(baseBlock).factory(SlabBlock::new); + } + + public static BlockBuilder stairs(Block baseBlock) { + return copy(baseBlock).factory(s -> new StairsBlock(baseBlock.getDefaultState(), s)); + } + + public static BlockBuilder wall(Block baseBlock) { + return copy(baseBlock).factory(WallBlock::new).settings(AbstractBlock.Settings.copyShallow(baseBlock).solid()); + } + + public static BlockBuilder fence(Block baseBlock) { + return copy(baseBlock).factory(FenceBlock::new).settings(AbstractBlock.Settings.copyShallow(baseBlock)); + } + + public static BlockBuilder fenceGate(Block baseBlock, WoodType woodType) { + return copy(baseBlock).factory(s -> new FenceGateBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock).solid()); + } + + public static BlockBuilder trapdoor(Block baseBlock, BlockSetType setType) { + return copy(baseBlock).factory(s -> new TrapdoorBlock(setType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) + .strength(3.0f) + .nonOpaque() + .allowsSpawning(Blocks::never)); + } + + public static BlockBuilder door(Block baseBlock, BlockSetType setType) { + return copy(baseBlock).factory(s -> new DoorBlock(setType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) + .strength(3.0f) + .nonOpaque() + .pistonBehavior(PistonBehavior.DESTROY)); + } + + public static BlockBuilder woodenButton(Block baseBlock, BlockSetType setType) { + return copy(baseBlock).factory(s -> new ButtonBlock(setType, 30, s)).settings(AbstractBlock.Settings.create() + .strength(0.5f) + .noCollision() + .pistonBehavior(PistonBehavior.DESTROY) + .sounds(baseBlock.getDefaultState().getSoundGroup())); + } + + public static BlockBuilder pressurePlate(Block baseBlock, BlockSetType setType) { + return copy(baseBlock).factory(s -> new PressurePlateBlock(setType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) + .solid() + .strength(0.5f) + .pistonBehavior(PistonBehavior.DESTROY) + .requiresTool() + .noCollision()); + } + + public static BlockBuilder sign(Block baseBlock, WoodType woodType) { + return copy(baseBlock).factory(s -> new SignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) + .mapColor(baseBlock.getDefaultMapColor()) + .solid() + .noCollision() + .strength(1.0F)).noItem(); + } + + public static BlockBuilder wallSign(Block standingSign, WoodType woodType) { + return copy(standingSign).factory(s -> new WallSignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(standingSign) + .lootTable(standingSign.getLootTableKey()) + .mapColor(standingSign.getDefaultMapColor()) + .solid() + .noCollision() + .strength(1.0F)).noItem(); + } + + public static BlockBuilder hangingSign(Block baseBlock, WoodType woodType, BlockSoundGroup soundGroup) { + return copy(baseBlock).factory(s -> new HangingSignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(baseBlock) + .mapColor(baseBlock.getDefaultMapColor()) + .solid() + .noCollision() + .strength(1.0F) + .sounds(soundGroup)).noItem(); + } + + public static BlockBuilder wallHangingSign(Block standingSign, WoodType woodType, BlockSoundGroup soundGroup) { + return copy(standingSign).factory(s -> new WallHangingSignBlock(woodType, s)).settings(AbstractBlock.Settings.copyShallow(standingSign) + .lootTable(standingSign.getLootTableKey()) + .mapColor(standingSign.getDefaultMapColor()) + .solid() + .noCollision() + .strength(1.0F) + .sounds(soundGroup)).noItem(); + } + + public static BlockBuilder log(MapColor woodColor, MapColor barkColor, BlockSoundGroup sounds, boolean flammable) { + return log(woodColor, sounds, flammable) + .settings(settings -> settings.mapColor((state) -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? woodColor : barkColor)); + } + + public static BlockBuilder log(MapColor color, BlockSoundGroup sounds, boolean flammable) { + AbstractBlock.Settings settings = AbstractBlock.Settings.create() + .mapColor(color) + .instrument(NoteBlockInstrument.BASS) + .strength(2.0F) + .sounds(sounds); + if (flammable) + settings.burnable(); + var builder = new BlockBuilder(PillarBlock::new, settings); + return builder; + } + + public static BlockBuilder sapling(MapColor mapColor, SaplingGenerator generator) { + return new BlockBuilder(s -> new SaplingBlock(generator, s), AbstractBlock.Settings.create() + .mapColor(mapColor) + .sounds(BlockSoundGroup.GRASS) + .breakInstantly() + .noCollision() + .ticksRandomly() + .pistonBehavior(PistonBehavior.DESTROY)); + } + + public static BlockBuilder sapling(MapColor mapColor, SaplingGenerator generator, Predicate saplingSoilPredicate) { + return sapling(mapColor, generator).factory(settings -> new fr.hugman.promenade.block.SaplingBlock(generator, saplingSoilPredicate, settings)); + } + + public static BlockBuilder leaves(MapColor mapColor) { + return new BlockBuilder(s -> new TintedParticleLeavesBlock(0.01f, s), AbstractBlock.Settings.create() + .mapColor(mapColor) + .strength(0.2f) + .ticksRandomly() + .sounds(BlockSoundGroup.GRASS) + .nonOpaque() + .allowsSpawning(Blocks::never) + .suffocates(Blocks::never) + .blockVision(Blocks::never) + .pistonBehavior(PistonBehavior.DESTROY) + .solidBlock(Blocks::never)); + } + + public static BlockBuilder leaves(MapColor mapColor, BlockSoundGroup soundGroup, float particleChance, ParticleEffect fallingParticle) { + return new BlockBuilder(s -> new UntintedParticleLeavesBlock(particleChance, fallingParticle, s), AbstractBlock.Settings.create() + .mapColor(mapColor) + .strength(0.2f) + .ticksRandomly() + .sounds(soundGroup) + .nonOpaque() + .burnable() + .allowsSpawning(Blocks::never) + .suffocates(Blocks::never) + .blockVision(Blocks::never) + .pistonBehavior(PistonBehavior.DESTROY) + .solidBlock(Blocks::never)); + } + + public static BlockBuilder hangingLeaves(MapColor mapColor) { + return new BlockBuilder(HangingLeavesBlock::new, AbstractBlock.Settings.create() + .mapColor(mapColor) + .sounds(BlockSoundGroup.GRASS) + .replaceable().noCollision().breakInstantly() + .burnable() + .pistonBehavior(PistonBehavior.DESTROY)); + } + + public static BlockBuilder snowyLeaves() { + return new BlockBuilder(s -> new TintedParticleSnowyLeavesBlock(0.01f, s), AbstractBlock.Settings.create() + .mapColor(MapColor.WHITE) + .strength(0.2f) + .ticksRandomly() + .sounds(PromenadeBlockSounds.SNOWY_LEAVES) + .nonOpaque() + .burnable() + .allowsSpawning(Blocks::canSpawnOnLeaves) + .suffocates(Blocks::never) + .blockVision(Blocks::never) + .pistonBehavior(PistonBehavior.DESTROY) + .solidBlock(Blocks::never)); + } + + public static BlockBuilder snowyLeaves(BlockSoundGroup soundGroup) { + return snowyLeaves().settings(settings -> settings.sounds(soundGroup)); + } + + public static BlockBuilder snowyLeaves(float particleChance, ParticleEffect particle) { + return snowyLeaves().factory(s -> new UntintedParticleSnowyLeavesBlock(particleChance, particle, s)); + } + + public static BlockBuilder snowyLeaves(float particleChance, ParticleEffect particle, BlockSoundGroup soundGroup) { + return snowyLeaves(particleChance, particle).settings(settings -> settings.sounds(soundGroup)); + } + + public static BlockBuilder pot(Block block) { + return new BlockBuilder(s -> new FlowerPotBlock(block, s), AbstractBlock.Settings.create() + .breakInstantly() + .nonOpaque() + .luminance(state -> block.getDefaultState().getLuminance()) + .pistonBehavior(PistonBehavior.DESTROY)); + } + + public static BlockBuilder pile() { + return pile(MapColor.DARK_GREEN); + } + + public static BlockBuilder pile(MapColor color) { + return pile(color, BlockSoundGroup.GRASS); + } + + public static BlockBuilder pile(MapColor color, BlockSoundGroup sounds) { + return new BlockBuilder(PileBlock::new, AbstractBlock.Settings.create() + .mapColor(color) + .burnable() + .strength(0.1f) + .sounds(sounds) + .noCollision() + .nonOpaque()); + } + + public static BlockBuilder fallenLeaves(MapColor color) { + return fallenLeaves(color, BlockSoundGroup.LEAF_LITTER); + } + + public static BlockBuilder fallenLeaves(MapColor color, BlockSoundGroup sounds) { + return new BlockBuilder(LeafLitterBlock::new, AbstractBlock.Settings.create() + .mapColor(color) + .replaceable() + .noCollision() + .sounds(sounds) + .pistonBehavior(PistonBehavior.DESTROY) + ); + } + + public static BlockBuilder fungus(MapColor mapColor, RegistryKey> featureKey, TagKey canPlantOn, TagKey canGrowOn) { + return of(s -> new fr.hugman.promenade.block.FungusBlock(featureKey, canPlantOn, canGrowOn, s), AbstractBlock.Settings.create() + .mapColor(mapColor) + .sounds(BlockSoundGroup.FUNGUS) + .pistonBehavior(PistonBehavior.DESTROY) + .breakInstantly() + .noCollision()); + } } diff --git a/src/main/java/fr/hugman/promenade/block/map_color/PromenadeMapColors.java b/src/main/java/fr/hugman/promenade/block/map_color/PromenadeMapColors.java index 7e3240c6..c565639c 100644 --- a/src/main/java/fr/hugman/promenade/block/map_color/PromenadeMapColors.java +++ b/src/main/java/fr/hugman/promenade/block/map_color/PromenadeMapColors.java @@ -1,26 +1,37 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block.map_color; import net.minecraft.block.MapColor; public class PromenadeMapColors { - public static final MapColor SAKURA_BARK = MapColor.TERRACOTTA_BROWN; - public static final MapColor SAKURA_WOOD = MapColor.TERRACOTTA_BROWN; + public static final MapColor SAKURA_BARK = MapColor.TERRACOTTA_BROWN; + public static final MapColor SAKURA_WOOD = MapColor.TERRACOTTA_BROWN; - public static final MapColor BLUSH_BLOSSOMS = MapColor.PINK; - public static final MapColor COTTON_BLOSSOMS = MapColor.OFF_WHITE; + public static final MapColor BLUSH_BLOSSOMS = MapColor.PINK; + public static final MapColor COTTON_BLOSSOMS = MapColor.OFF_WHITE; - public static final MapColor MAPLE_BARK = MapColor.DEEPSLATE_GRAY; - public static final MapColor MAPLE_WOOD = MapColor.TERRACOTTA_WHITE; + public static final MapColor MAPLE_BARK = MapColor.DEEPSLATE_GRAY; + public static final MapColor MAPLE_WOOD = MapColor.TERRACOTTA_WHITE; - public static final MapColor SAP_MAPLE_LEAVES = MapColor.DARK_GREEN; - public static final MapColor VERMILION_MAPLE_LEAVES = MapColor.DULL_RED; - public static final MapColor FULVOUS_MAPLE_LEAVES = MapColor.ORANGE; - public static final MapColor MIKADO_MAPLE_LEAVES = MapColor.GOLD; + public static final MapColor SAP_MAPLE_LEAVES = MapColor.DARK_GREEN; + public static final MapColor VERMILION_MAPLE_LEAVES = MapColor.DULL_RED; + public static final MapColor FULVOUS_MAPLE_LEAVES = MapColor.ORANGE; + public static final MapColor MIKADO_MAPLE_LEAVES = MapColor.GOLD; - public static final MapColor PALM_BARK = MapColor.SPRUCE_BROWN; - public static final MapColor PALM_WOOD = MapColor.ORANGE; - public static final MapColor PALM_LEAVES = MapColor.DARK_GREEN; + public static final MapColor PALM_BARK = MapColor.SPRUCE_BROWN; + public static final MapColor PALM_WOOD = MapColor.ORANGE; + public static final MapColor PALM_LEAVES = MapColor.DARK_GREEN; - public static final MapColor AMARANTH_BARK = MapColor.DARK_DULL_PINK; - public static final MapColor AMARANTH_WOOD = MapColor.GRAY; + public static final MapColor AMARANTH_BARK = MapColor.DARK_DULL_PINK; + public static final MapColor AMARANTH_WOOD = MapColor.GRAY; } diff --git a/src/main/java/fr/hugman/promenade/block/property/PromenadeBlockProperties.java b/src/main/java/fr/hugman/promenade/block/property/PromenadeBlockProperties.java index bc039b25..183997dc 100644 --- a/src/main/java/fr/hugman/promenade/block/property/PromenadeBlockProperties.java +++ b/src/main/java/fr/hugman/promenade/block/property/PromenadeBlockProperties.java @@ -1,13 +1,25 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block.property; -import fr.hugman.promenade.block.MoaiType; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.IntProperty; +import fr.hugman.promenade.block.MoaiType; + public class PromenadeBlockProperties { - public static final BooleanProperty NATURAL = BooleanProperty.of("natural"); - public static final BooleanProperty DRIP = BooleanProperty.of("drip"); - public static final EnumProperty MOAI_TYPE = EnumProperty.of("type", MoaiType.class); - public static final IntProperty DISTANCE_1_14 = IntProperty.of("distance", 1, 14); + public static final BooleanProperty NATURAL = BooleanProperty.of("natural"); + public static final BooleanProperty DRIP = BooleanProperty.of("drip"); + public static final EnumProperty MOAI_TYPE = EnumProperty.of("type", MoaiType.class); + public static final IntProperty DISTANCE_1_14 = IntProperty.of("distance", 1, 14); } diff --git a/src/main/java/fr/hugman/promenade/block/snowy/SnowyBlockTransformation.java b/src/main/java/fr/hugman/promenade/block/snowy/SnowyBlockTransformation.java index c7a0a238..a4e5db1f 100644 --- a/src/main/java/fr/hugman/promenade/block/snowy/SnowyBlockTransformation.java +++ b/src/main/java/fr/hugman/promenade/block/snowy/SnowyBlockTransformation.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block.snowy; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.block.Block; import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryCodecs; @@ -10,12 +22,12 @@ import net.minecraft.registry.entry.RegistryEntryList; public record SnowyBlockTransformation(RegistryEntryList baseBlocks, RegistryEntry snowyBlock) { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - RegistryCodecs.entryList(RegistryKeys.BLOCK).fieldOf("base_blocks").forGetter(SnowyBlockTransformation::baseBlocks), - Registries.BLOCK.getEntryCodec().fieldOf("snowy_block").forGetter(SnowyBlockTransformation::snowyBlock) - ).apply(instance, SnowyBlockTransformation::new)); + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + RegistryCodecs.entryList(RegistryKeys.BLOCK).fieldOf("base_blocks").forGetter(SnowyBlockTransformation::baseBlocks), + Registries.BLOCK.getEntryCodec().fieldOf("snowy_block").forGetter(SnowyBlockTransformation::snowyBlock) + ).apply(instance, SnowyBlockTransformation::new)); - public SnowyBlockTransformation(RegistryEntry baseBlock, RegistryEntry snowyBlock) { - this(RegistryEntryList.of(baseBlock), snowyBlock); - } + public SnowyBlockTransformation(RegistryEntry baseBlock, RegistryEntry snowyBlock) { + this(RegistryEntryList.of(baseBlock), snowyBlock); + } } diff --git a/src/main/java/fr/hugman/promenade/block/type/PromenadeBlockSetTypes.java b/src/main/java/fr/hugman/promenade/block/type/PromenadeBlockSetTypes.java index 5cafadad..d92a2eb0 100644 --- a/src/main/java/fr/hugman/promenade/block/type/PromenadeBlockSetTypes.java +++ b/src/main/java/fr/hugman/promenade/block/type/PromenadeBlockSetTypes.java @@ -1,12 +1,25 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block.type; -import fr.hugman.promenade.Promenade; -import net.fabricmc.fabric.api.object.builder.v1.block.type.BlockSetTypeBuilder; import net.minecraft.block.BlockSetType; +import net.fabricmc.fabric.api.object.builder.v1.block.type.BlockSetTypeBuilder; + +import fr.hugman.promenade.Promenade; + public class PromenadeBlockSetTypes { - public static final BlockSetType SAKURA = BlockSetTypeBuilder.copyOf(BlockSetType.CHERRY).register(Promenade.id("sakura")); - public static final BlockSetType MAPLE = BlockSetTypeBuilder.copyOf(BlockSetType.OAK).register(Promenade.id("maple")); - public static final BlockSetType PALM = BlockSetTypeBuilder.copyOf(BlockSetType.OAK).register(Promenade.id("palm")); - public static final BlockSetType DARK_AMARANTH = BlockSetTypeBuilder.copyOf(BlockSetType.CRIMSON).register(Promenade.id("dark_amaranth")); + public static final BlockSetType SAKURA = BlockSetTypeBuilder.copyOf(BlockSetType.CHERRY).register(Promenade.id("sakura")); + public static final BlockSetType MAPLE = BlockSetTypeBuilder.copyOf(BlockSetType.OAK).register(Promenade.id("maple")); + public static final BlockSetType PALM = BlockSetTypeBuilder.copyOf(BlockSetType.OAK).register(Promenade.id("palm")); + public static final BlockSetType DARK_AMARANTH = BlockSetTypeBuilder.copyOf(BlockSetType.CRIMSON).register(Promenade.id("dark_amaranth")); } diff --git a/src/main/java/fr/hugman/promenade/block/type/PromenadeWoodTypes.java b/src/main/java/fr/hugman/promenade/block/type/PromenadeWoodTypes.java index 1c5af3b4..bee18713 100644 --- a/src/main/java/fr/hugman/promenade/block/type/PromenadeWoodTypes.java +++ b/src/main/java/fr/hugman/promenade/block/type/PromenadeWoodTypes.java @@ -1,12 +1,25 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.block.type; -import fr.hugman.promenade.Promenade; -import net.fabricmc.fabric.api.object.builder.v1.block.type.WoodTypeBuilder; import net.minecraft.block.WoodType; +import net.fabricmc.fabric.api.object.builder.v1.block.type.WoodTypeBuilder; + +import fr.hugman.promenade.Promenade; + public class PromenadeWoodTypes { - public static final WoodType SAKURA = WoodTypeBuilder.copyOf(WoodType.CHERRY).register(Promenade.id("sakura"), PromenadeBlockSetTypes.SAKURA); - public static final WoodType MAPLE = WoodTypeBuilder.copyOf(WoodType.OAK).register(Promenade.id("maple"), PromenadeBlockSetTypes.MAPLE); - public static final WoodType PALM = WoodTypeBuilder.copyOf(WoodType.OAK).register(Promenade.id("palm"), PromenadeBlockSetTypes.PALM); - public static final WoodType DARK_AMARANTH = WoodTypeBuilder.copyOf(WoodType.CRIMSON).register(Promenade.id("dark_amaranth"), PromenadeBlockSetTypes.DARK_AMARANTH); + public static final WoodType SAKURA = WoodTypeBuilder.copyOf(WoodType.CHERRY).register(Promenade.id("sakura"), PromenadeBlockSetTypes.SAKURA); + public static final WoodType MAPLE = WoodTypeBuilder.copyOf(WoodType.OAK).register(Promenade.id("maple"), PromenadeBlockSetTypes.MAPLE); + public static final WoodType PALM = WoodTypeBuilder.copyOf(WoodType.OAK).register(Promenade.id("palm"), PromenadeBlockSetTypes.PALM); + public static final WoodType DARK_AMARANTH = WoodTypeBuilder.copyOf(WoodType.CRIMSON).register(Promenade.id("dark_amaranth"), PromenadeBlockSetTypes.DARK_AMARANTH); } diff --git a/src/main/java/fr/hugman/promenade/codec/PromenadeCodecs.java b/src/main/java/fr/hugman/promenade/codec/PromenadeCodecs.java index ca1aae1f..2eb394dd 100644 --- a/src/main/java/fr/hugman/promenade/codec/PromenadeCodecs.java +++ b/src/main/java/fr/hugman/promenade/codec/PromenadeCodecs.java @@ -1,23 +1,33 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.codec; +import java.util.function.Function; + import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; -import java.util.function.Function; - public class PromenadeCodecs { - public static final Codec SAMPLED_NOISE_VALUE = rangedInclusiveFloat(-1.0F, 1.0F); + public static final Codec SAMPLED_NOISE_VALUE = rangedInclusiveFloat(-1.0F, 1.0F); - private static Codec rangedInclusiveFloat(float minInclusive, float maxInclusive, Function messageFactory) { - return Codec.FLOAT.validate( - value -> value.compareTo(minInclusive) >= 0 && value.compareTo(maxInclusive) <= 0 - ? DataResult.success(value) - : DataResult.error(() -> messageFactory.apply(value)) - ); - } + private static Codec rangedInclusiveFloat(float minInclusive, float maxInclusive, Function messageFactory) { + return Codec.FLOAT.validate( + value -> value.compareTo(minInclusive) >= 0 && value.compareTo(maxInclusive) <= 0 + ? DataResult.success(value) + : DataResult.error(() -> messageFactory.apply(value)) + ); + } - public static Codec rangedInclusiveFloat(float minInclusive, float maxInclusive) { - return rangedInclusiveFloat(minInclusive, maxInclusive, value -> "Value must be within range [" + minInclusive + ";" + maxInclusive + "]: " + value); - } + public static Codec rangedInclusiveFloat(float minInclusive, float maxInclusive) { + return rangedInclusiveFloat(minInclusive, maxInclusive, value -> "Value must be within range [" + minInclusive + ";" + maxInclusive + "]: " + value); + } } - diff --git a/src/main/java/fr/hugman/promenade/component/PromenadeComponentTypes.java b/src/main/java/fr/hugman/promenade/component/PromenadeComponentTypes.java index 471027b8..cc11a0a4 100644 --- a/src/main/java/fr/hugman/promenade/component/PromenadeComponentTypes.java +++ b/src/main/java/fr/hugman/promenade/component/PromenadeComponentTypes.java @@ -1,10 +1,20 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.component; +import java.util.function.UnaryOperator; + import com.mojang.serialization.Codec; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.entity.variant.CapybaraVariant; -import fr.hugman.promenade.entity.variant.DuckVariant; -import fr.hugman.promenade.entity.variant.SunkenVariant; + import net.minecraft.component.ComponentType; import net.minecraft.network.RegistryByteBuf; import net.minecraft.network.codec.PacketCodec; @@ -12,18 +22,21 @@ import net.minecraft.registry.Registry; import net.minecraft.registry.entry.RegistryEntry; -import java.util.function.UnaryOperator; +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.entity.variant.CapybaraVariant; +import fr.hugman.promenade.entity.variant.DuckVariant; +import fr.hugman.promenade.entity.variant.SunkenVariant; public class PromenadeComponentTypes { - public static final ComponentType> DUCK_VARIANT = of("duck/variant", DuckVariant.ENTRY_CODEC, DuckVariant.ENTRY_PACKET_CODEC); - public static final ComponentType> CAPYBARA_VARIANT = of("capybara/variant", CapybaraVariant.ENTRY_CODEC, CapybaraVariant.ENTRY_PACKET_CODEC); - public static final ComponentType> SUNKEN_VARIANT = of("sunken/variant", SunkenVariant.ENTRY_CODEC, SunkenVariant.ENTRY_PACKET_CODEC); + public static final ComponentType> DUCK_VARIANT = of("duck/variant", DuckVariant.ENTRY_CODEC, DuckVariant.ENTRY_PACKET_CODEC); + public static final ComponentType> CAPYBARA_VARIANT = of("capybara/variant", CapybaraVariant.ENTRY_CODEC, CapybaraVariant.ENTRY_PACKET_CODEC); + public static final ComponentType> SUNKEN_VARIANT = of("sunken/variant", SunkenVariant.ENTRY_CODEC, SunkenVariant.ENTRY_PACKET_CODEC); - private static ComponentType of(String id, Codec codec, PacketCodec packetCodec) { - return of(id, builder -> builder.codec(codec).packetCodec(packetCodec)); - } + private static ComponentType of(String id, Codec codec, PacketCodec packetCodec) { + return of(id, builder -> builder.codec(codec).packetCodec(packetCodec)); + } - private static ComponentType of(String id, UnaryOperator> builderOperator) { - return Registry.register(Registries.DATA_COMPONENT_TYPE, Promenade.id(id), ((ComponentType.Builder)builderOperator.apply(ComponentType.builder())).build()); - } + private static ComponentType of(String id, UnaryOperator> builderOperator) { + return Registry.register(Registries.DATA_COMPONENT_TYPE, Promenade.id(id), ((ComponentType.Builder) builderOperator.apply(ComponentType.builder())).build()); + } } diff --git a/src/main/java/fr/hugman/promenade/component/PromenadeConsumableComponents.java b/src/main/java/fr/hugman/promenade/component/PromenadeConsumableComponents.java index d48672d2..9ea44537 100644 --- a/src/main/java/fr/hugman/promenade/component/PromenadeConsumableComponents.java +++ b/src/main/java/fr/hugman/promenade/component/PromenadeConsumableComponents.java @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.component; import net.minecraft.component.type.ConsumableComponent; @@ -9,15 +20,15 @@ import net.minecraft.sound.SoundEvents; public class PromenadeConsumableComponents { - public static final ConsumableComponent MAPLE_SYRUP_BOTTLE = ConsumableComponents.drink() - .consumeSeconds(2.0F) - .sound(SoundEvents.ITEM_HONEY_BOTTLE_DRINK) - .consumeEffect(new RemoveEffectsConsumeEffect(StatusEffects.POISON)) - .build(); + public static final ConsumableComponent MAPLE_SYRUP_BOTTLE = ConsumableComponents.drink() + .consumeSeconds(2.0F) + .sound(SoundEvents.ITEM_HONEY_BOTTLE_DRINK) + .consumeEffect(new RemoveEffectsConsumeEffect(StatusEffects.POISON)) + .build(); - public static final ConsumableComponent RAW_DUCK = foodWithEffect(new StatusEffectInstance(StatusEffects.HUNGER, 600, 0), 0.3F); + public static final ConsumableComponent RAW_DUCK = foodWithEffect(new StatusEffectInstance(StatusEffects.HUNGER, 600, 0), 0.3F); - public static ConsumableComponent foodWithEffect(StatusEffectInstance effect, float probability) { - return ConsumableComponents.food().consumeEffect(new ApplyEffectsConsumeEffect(effect, probability)).build(); - } + public static ConsumableComponent foodWithEffect(StatusEffectInstance effect, float probability) { + return ConsumableComponents.food().consumeEffect(new ApplyEffectsConsumeEffect(effect, probability)).build(); + } } diff --git a/src/main/java/fr/hugman/promenade/component/PromenadeFoodComponents.java b/src/main/java/fr/hugman/promenade/component/PromenadeFoodComponents.java index 425897d6..35f6102d 100644 --- a/src/main/java/fr/hugman/promenade/component/PromenadeFoodComponents.java +++ b/src/main/java/fr/hugman/promenade/component/PromenadeFoodComponents.java @@ -1,24 +1,35 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.component; import net.minecraft.component.type.FoodComponent; public class PromenadeFoodComponents { - public static final FoodComponent MAPLE_SYRUP_BOTTLE = alwaysEdible(6, 0.1F); + public static final FoodComponent MAPLE_SYRUP_BOTTLE = alwaysEdible(6, 0.1F); - public static final FoodComponent BLUEBERRIES = simple(2, 0.1F); + public static final FoodComponent BLUEBERRIES = simple(2, 0.1F); - public static final FoodComponent BANANA = simple(4, 0.3F); - public static final FoodComponent APRICOT = simple(4, 0.3F); - public static final FoodComponent MANGO = simple(4, 0.3F); + public static final FoodComponent BANANA = simple(4, 0.3F); + public static final FoodComponent APRICOT = simple(4, 0.3F); + public static final FoodComponent MANGO = simple(4, 0.3F); - public static final FoodComponent RAW_DUCK = simple(2, 0.3F); - public static final FoodComponent COOKED_DUCK = simple(6, 0.6F); + public static final FoodComponent RAW_DUCK = simple(2, 0.3F); + public static final FoodComponent COOKED_DUCK = simple(6, 0.6F); - public static FoodComponent simple(int nutrition, float saturation) { - return new FoodComponent.Builder().nutrition(nutrition).saturationModifier(saturation).build(); - } + public static FoodComponent simple(int nutrition, float saturation) { + return new FoodComponent.Builder().nutrition(nutrition).saturationModifier(saturation).build(); + } - public static FoodComponent alwaysEdible(int nutrition, float saturation) { - return new FoodComponent.Builder().nutrition(nutrition).saturationModifier(saturation).build(); - } + public static FoodComponent alwaysEdible(int nutrition, float saturation) { + return new FoodComponent.Builder().nutrition(nutrition).saturationModifier(saturation).build(); + } } diff --git a/src/main/java/fr/hugman/promenade/config/PromenadeConfig.java b/src/main/java/fr/hugman/promenade/config/PromenadeConfig.java index 8bf08bf4..2e480d61 100644 --- a/src/main/java/fr/hugman/promenade/config/PromenadeConfig.java +++ b/src/main/java/fr/hugman/promenade/config/PromenadeConfig.java @@ -1,5 +1,24 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.config; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonParser; @@ -7,143 +26,137 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.JsonOps; import com.mojang.serialization.codecs.RecordCodecBuilder; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.world.biome.PromenadeBiomes; -import net.minecraft.world.biome.source.util.MultiNoiseUtil; import org.apache.commons.io.IOUtils; import org.jetbrains.annotations.NotNull; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; +import net.minecraft.world.biome.source.util.MultiNoiseUtil; + +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.world.biome.PromenadeBiomes; public record PromenadeConfig( - BiomesConfig biomes, - WorldFeaturesConfig worldFeatures, - AnimalsConfig animals, - MonstersConfig monsters + BiomesConfig biomes, + WorldFeaturesConfig worldFeatures, + AnimalsConfig animals, + MonstersConfig monsters ) { - private static final Path PATH = Paths.get("config/promenade.json"); - - private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); - - private static final Codec CODEC = RecordCodecBuilder.create(instance -> - instance.group( - BiomesConfig.CODEC.fieldOf("biomes").forGetter(PromenadeConfig::biomes), - WorldFeaturesConfig.CODEC.fieldOf("world_features").forGetter(PromenadeConfig::worldFeatures), - AnimalsConfig.CODEC.fieldOf("animals").forGetter(PromenadeConfig::animals), - MonstersConfig.CODEC.fieldOf("monsters").forGetter(PromenadeConfig::monsters) - ).apply(instance, PromenadeConfig::new) - ); - - private static PromenadeConfig instance; - - private PromenadeConfig() { - this( - new BiomesConfig(20, 20, 10, Optional.of(PromenadeBiomes.DEFAULT_DARK_AMARANTH_FOREST_HYPERCUBE)), - new WorldFeaturesConfig(true, true, true), - new AnimalsConfig(10, 10), - new MonstersConfig(15, 10) - ); - } - - public record BiomesConfig( - int carnelianTreewayWeight, - int sakuraGrovesWeight, - int glacarianTaigaWeight, - Optional darkAmaranthForestsNoise - ) { - - private static final Codec CODEC = RecordCodecBuilder.create(instance -> - instance.group( - Codec.INT.optionalFieldOf("carnelian_treeway_weight", 20).forGetter(BiomesConfig::carnelianTreewayWeight), - Codec.INT.optionalFieldOf("sakura_groves_weight", 20).forGetter(BiomesConfig::sakuraGrovesWeight), - Codec.INT.optionalFieldOf("glacarian_taiga_weight", 10).forGetter(BiomesConfig::glacarianTaigaWeight), - MultiNoiseUtil.NoiseHypercube.CODEC.optionalFieldOf("dark_amaranth_forests_noise").forGetter(BiomesConfig::darkAmaranthForestsNoise) - ).apply(instance, BiomesConfig::new) - ); - } - - public record WorldFeaturesConfig( - boolean igneousRockPatches, - boolean blueberryBushes, - boolean palms - ) { - private static final Codec CODEC = RecordCodecBuilder.create(instance -> - instance.group( - Codec.BOOL.optionalFieldOf("igneous_rock_patches", true).forGetter(WorldFeaturesConfig::igneousRockPatches), - Codec.BOOL.optionalFieldOf("blueberry_bushes", true).forGetter(WorldFeaturesConfig::blueberryBushes), - Codec.BOOL.optionalFieldOf("palms", true).forGetter(WorldFeaturesConfig::palms) - ).apply(instance, WorldFeaturesConfig::new) - ); - } - - public record AnimalsConfig( - int capybarasWeight, - int ducksWeight - ) { - private static final Codec CODEC = RecordCodecBuilder.create(instance -> - instance.group( - Codec.INT.optionalFieldOf("capybaras_weight", 10).forGetter(AnimalsConfig::capybarasWeight), - Codec.INT.optionalFieldOf("ducks_weight", 10).forGetter(AnimalsConfig::ducksWeight) - ).apply(instance, AnimalsConfig::new) - ); - } - - public record MonstersConfig( - int lushCreepersWeight, - int sunkensWeight - ) { - private static final Codec CODEC = RecordCodecBuilder.create(instance -> - instance.group( - Codec.INT.optionalFieldOf("lush_creepers_weight", 15).forGetter(MonstersConfig::lushCreepersWeight), - Codec.INT.optionalFieldOf("sunkens_weight", 10).forGetter(MonstersConfig::sunkensWeight) - ).apply(instance, MonstersConfig::new) - ); - } - - @NotNull - public static PromenadeConfig get() { - if (instance == null) { - instance = initializeConfig(); - } - return instance; - } - - private static PromenadeConfig initializeConfig() { - if (Files.exists(PATH)) { - return loadConfig(); - } else { - return createDefaultConfig(); - } - } - - private static PromenadeConfig loadConfig() { - try (var input = Files.newInputStream(PATH)) { - var json = JsonParser.parseReader(new InputStreamReader(input)); - var result = CODEC.decode(JsonOps.INSTANCE, json).map(Pair::getFirst); - return result.result().orElseGet(PromenadeConfig::new); - } catch (IOException e) { - Promenade.LOGGER.warn("Failed to load Promenade config", e); - return new PromenadeConfig(); - } - } - - private static PromenadeConfig createDefaultConfig() { - var config = new PromenadeConfig(); - try (var output = Files.newOutputStream(PATH)) { - var result = CODEC.encodeStart(JsonOps.INSTANCE, config).result(); - if (result.isPresent()) { - var json = result.get(); - IOUtils.write(GSON.toJson(json), output, StandardCharsets.UTF_8); - } - } catch (IOException e) { - Promenade.LOGGER.warn("Failed to create default Promenade config", e); - } - return config; - } + private static final Path PATH = Paths.get("config/promenade.json"); + + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + + private static final Codec CODEC = RecordCodecBuilder.create(instance -> + instance.group( + BiomesConfig.CODEC.fieldOf("biomes").forGetter(PromenadeConfig::biomes), + WorldFeaturesConfig.CODEC.fieldOf("world_features").forGetter(PromenadeConfig::worldFeatures), + AnimalsConfig.CODEC.fieldOf("animals").forGetter(PromenadeConfig::animals), + MonstersConfig.CODEC.fieldOf("monsters").forGetter(PromenadeConfig::monsters) + ).apply(instance, PromenadeConfig::new) + ); + + private static PromenadeConfig instance; + + private PromenadeConfig() { + this( + new BiomesConfig(20, 20, 10, Optional.of(PromenadeBiomes.DEFAULT_DARK_AMARANTH_FOREST_HYPERCUBE)), + new WorldFeaturesConfig(true, true, true), + new AnimalsConfig(10, 10), + new MonstersConfig(15, 10) + ); + } + + public record BiomesConfig( + int carnelianTreewayWeight, + int sakuraGrovesWeight, + int glacarianTaigaWeight, + Optional darkAmaranthForestsNoise + ) { + + private static final Codec CODEC = RecordCodecBuilder.create(instance -> + instance.group( + Codec.INT.optionalFieldOf("carnelian_treeway_weight", 20).forGetter(BiomesConfig::carnelianTreewayWeight), + Codec.INT.optionalFieldOf("sakura_groves_weight", 20).forGetter(BiomesConfig::sakuraGrovesWeight), + Codec.INT.optionalFieldOf("glacarian_taiga_weight", 10).forGetter(BiomesConfig::glacarianTaigaWeight), + MultiNoiseUtil.NoiseHypercube.CODEC.optionalFieldOf("dark_amaranth_forests_noise").forGetter(BiomesConfig::darkAmaranthForestsNoise) + ).apply(instance, BiomesConfig::new) + ); + } + + public record WorldFeaturesConfig( + boolean igneousRockPatches, + boolean blueberryBushes, + boolean palms + ) { + private static final Codec CODEC = RecordCodecBuilder.create(instance -> + instance.group( + Codec.BOOL.optionalFieldOf("igneous_rock_patches", true).forGetter(WorldFeaturesConfig::igneousRockPatches), + Codec.BOOL.optionalFieldOf("blueberry_bushes", true).forGetter(WorldFeaturesConfig::blueberryBushes), + Codec.BOOL.optionalFieldOf("palms", true).forGetter(WorldFeaturesConfig::palms) + ).apply(instance, WorldFeaturesConfig::new) + ); + } + + public record AnimalsConfig( + int capybarasWeight, + int ducksWeight + ) { + private static final Codec CODEC = RecordCodecBuilder.create(instance -> + instance.group( + Codec.INT.optionalFieldOf("capybaras_weight", 10).forGetter(AnimalsConfig::capybarasWeight), + Codec.INT.optionalFieldOf("ducks_weight", 10).forGetter(AnimalsConfig::ducksWeight) + ).apply(instance, AnimalsConfig::new) + ); + } + + public record MonstersConfig( + int lushCreepersWeight, + int sunkensWeight + ) { + private static final Codec CODEC = RecordCodecBuilder.create(instance -> + instance.group( + Codec.INT.optionalFieldOf("lush_creepers_weight", 15).forGetter(MonstersConfig::lushCreepersWeight), + Codec.INT.optionalFieldOf("sunkens_weight", 10).forGetter(MonstersConfig::sunkensWeight) + ).apply(instance, MonstersConfig::new) + ); + } + + @NotNull + public static PromenadeConfig get() { + if (instance == null) { + instance = initializeConfig(); + } + return instance; + } + + private static PromenadeConfig initializeConfig() { + if (Files.exists(PATH)) { + return loadConfig(); + } else { + return createDefaultConfig(); + } + } + + private static PromenadeConfig loadConfig() { + try (var input = Files.newInputStream(PATH)) { + var json = JsonParser.parseReader(new InputStreamReader(input)); + var result = CODEC.decode(JsonOps.INSTANCE, json).map(Pair::getFirst); + return result.result().orElseGet(PromenadeConfig::new); + } catch (IOException e) { + Promenade.LOGGER.warn("Failed to load Promenade config", e); + return new PromenadeConfig(); + } + } + + private static PromenadeConfig createDefaultConfig() { + var config = new PromenadeConfig(); + try (var output = Files.newOutputStream(PATH)) { + var result = CODEC.encodeStart(JsonOps.INSTANCE, config).result(); + if (result.isPresent()) { + var json = result.get(); + IOUtils.write(GSON.toJson(json), output, StandardCharsets.UTF_8); + } + } catch (IOException e) { + Promenade.LOGGER.warn("Failed to create default Promenade config", e); + } + return config; + } } diff --git a/src/main/java/fr/hugman/promenade/entity/CapybaraBrain.java b/src/main/java/fr/hugman/promenade/entity/CapybaraBrain.java index e7bd7fca..6853a333 100644 --- a/src/main/java/fr/hugman/promenade/entity/CapybaraBrain.java +++ b/src/main/java/fr/hugman/promenade/entity/CapybaraBrain.java @@ -1,12 +1,24 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity; +import java.util.Map; +import java.util.function.Predicate; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.mojang.datafixers.util.Pair; -import fr.hugman.promenade.entity.ai.brain.PromenadeMemoryModuleTypes; -import fr.hugman.promenade.entity.ai.brain.sensor.PromenadeSensorTypes; -import fr.hugman.promenade.tag.PromenadeItemTags; + import net.minecraft.entity.EntityType; import net.minecraft.entity.ai.brain.Activity; import net.minecraft.entity.ai.brain.Brain; @@ -19,147 +31,148 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.intprovider.UniformIntProvider; -import java.util.Map; -import java.util.function.Predicate; +import fr.hugman.promenade.entity.ai.brain.PromenadeMemoryModuleTypes; +import fr.hugman.promenade.entity.ai.brain.sensor.PromenadeSensorTypes; +import fr.hugman.promenade.tag.PromenadeItemTags; public class CapybaraBrain { - private static final UniformIntProvider WALK_TOWARD_ADULT_RANGE = UniformIntProvider.create(5, 16); - - private static final ImmutableList>> SENSORS = ImmutableList.of( - SensorType.NEAREST_LIVING_ENTITIES, - SensorType.HURT_BY, - PromenadeSensorTypes.CAPYBARA_TEMPTATIONS, - SensorType.NEAREST_ADULT, - SensorType.IS_IN_WATER - ); - - private static final ImmutableList> MEMORY_MODULES = ImmutableList.of( - MemoryModuleType.IS_PANICKING, - MemoryModuleType.HURT_BY, - MemoryModuleType.HURT_BY_ENTITY, - MemoryModuleType.WALK_TARGET, - MemoryModuleType.LOOK_TARGET, - MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, - MemoryModuleType.PATH, - MemoryModuleType.VISIBLE_MOBS, - MemoryModuleType.TEMPTING_PLAYER, - MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, - MemoryModuleType.GAZE_COOLDOWN_TICKS, - MemoryModuleType.IS_TEMPTED, - MemoryModuleType.BREED_TARGET, - MemoryModuleType.NEAREST_VISIBLE_ADULT, - PromenadeMemoryModuleTypes.FART_COOLDOWN - ); - - public static Brain.Profile createProfile() { - return Brain.createProfile(MEMORY_MODULES, SENSORS); - } - - protected static Brain create(Brain brain) { - CapybaraBrain.addCoreActivities(brain); - CapybaraBrain.addIdleActivities(brain); - brain.setCoreActivities(ImmutableSet.of(Activity.CORE)); - brain.setDefaultActivity(Activity.IDLE); - brain.resetPossibleActivities(); - return brain; - } - - private static void addCoreActivities(Brain brain) { - brain.setTaskList(Activity.CORE, 0, ImmutableList.of( - new StayAboveWaterTask<>(0.8f), - new net.minecraft.entity.ai.brain.task.FleeTask<>(1.0F) { - protected void run(ServerWorld serverWorld, CapybaraEntity capybaraEntity, long l) { - capybaraEntity.forceDefaultState(); - super.run(serverWorld, capybaraEntity, l); - } - }, - new UpdateLookControlTask(45, 90), - new MoveToTargetTask(), - new TickCooldownTask(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS), - new TickCooldownTask(MemoryModuleType.GAZE_COOLDOWN_TICKS))); - } - - private static void addIdleActivities(Brain brain) { - brain.setTaskList(Activity.IDLE, ImmutableList.of( - Pair.of(0, LookAtMobWithIntervalTask.follow(EntityType.PLAYER, 6.0f, UniformIntProvider.create(30, 60))), - Pair.of(1, new BreedTask(PromenadeEntityTypes.CAPYBARA)), - Pair.of(2, new TemptTask(entity -> 1.5f)), - Pair.of(3, TaskTriggerer.runIf(Predicate.not(CapybaraEntity::isStationary), WalkTowardsEntityTask.createNearestVisibleAdult(WALK_TOWARD_ADULT_RANGE, 1.5f))), - Pair.of(4, new LookAroundTask(UniformIntProvider.create(150, 250), 30.0f, 0.0f, 10.0f)), - Pair.of(5, new RandomTask<>(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryModuleState.VALUE_ABSENT), ImmutableList.of( - Pair.of(TaskTriggerer.runIf(Predicate.not(CapybaraEntity::isStationary), StrollTask.create(1.0f)), 1), - Pair.of(TaskTriggerer.runIf(Predicate.not(CapybaraEntity::isStationary), GoToLookTargetTask.create(1.0f, 3)), 1), - Pair.of(new SleepOrWakeUpTask(20), 1), - Pair.of(new FartTask(10), 1), - Pair.of(new WaitTask(30, 60), 1) - ))))); - } - - public static void updateActivities(CapybaraEntity capybara) { - capybara.getBrain().resetPossibleActivities(ImmutableList.of(Activity.IDLE)); - } - - public static Predicate getTemptItemPredicate() { - return (stack) -> stack.isIn(PromenadeItemTags.CAPYBARA_FOOD); - } - - public static class SleepOrWakeUpTask extends MultiTickTask { - private final int lastPoseTickDelta; - - public SleepOrWakeUpTask(int lastPoseSecondsDelta) { - super(ImmutableMap.of( - MemoryModuleType.IS_PANICKING, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.IS_TEMPTED, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.IS_IN_WATER, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.BREED_TARGET, MemoryModuleState.VALUE_ABSENT)); - this.lastPoseTickDelta = lastPoseSecondsDelta * 20; - } - - @Override - protected boolean shouldRun(ServerWorld world, CapybaraEntity capybara) { - return capybara.getLastStateTickDelta() >= this.lastPoseTickDelta && - !capybara.isLeashed() && - capybara.isOnGround() && - !capybara.hasControllingPassenger(); - } - - @Override - protected void run(ServerWorld world, CapybaraEntity capybara, long l) { - if (capybara.canFallToSleep()) { - capybara.startFallingToSleep(); - } else if (capybara.canWakeUp()) { - capybara.startWakingUp(); - } - } - } - - static class FartTask extends MultiTickTask { - private final int lastPoseTickDelta; - - FartTask(int lastPoseSecondsDelta) { - super(Map.of( - MemoryModuleType.IS_PANICKING, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.IS_TEMPTED, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.IS_IN_WATER, MemoryModuleState.VALUE_ABSENT, - PromenadeMemoryModuleTypes.FART_COOLDOWN, MemoryModuleState.VALUE_ABSENT, - MemoryModuleType.BREED_TARGET, MemoryModuleState.VALUE_ABSENT - )); - this.lastPoseTickDelta = lastPoseSecondsDelta * 20; - } - - protected boolean shouldRun(ServerWorld serverWorld, CapybaraEntity capybara) { - return capybara.getLastStateTickDelta() >= this.lastPoseTickDelta && - !capybara.mightBeLeashed() && - capybara.isOnGround() && - !capybara.hasControllingPassenger(); - } - - protected boolean shouldKeepRunning(ServerWorld serverWorld, CapybaraEntity capybara, long l) { - return true; - } - - protected void run(ServerWorld serverWorld, CapybaraEntity capybara, long l) { - capybara.fart(); - } - } + private static final UniformIntProvider WALK_TOWARD_ADULT_RANGE = UniformIntProvider.create(5, 16); + + private static final ImmutableList>> SENSORS = ImmutableList.of( + SensorType.NEAREST_LIVING_ENTITIES, + SensorType.HURT_BY, + PromenadeSensorTypes.CAPYBARA_TEMPTATIONS, + SensorType.NEAREST_ADULT, + SensorType.IS_IN_WATER + ); + + private static final ImmutableList> MEMORY_MODULES = ImmutableList.of( + MemoryModuleType.IS_PANICKING, + MemoryModuleType.HURT_BY, + MemoryModuleType.HURT_BY_ENTITY, + MemoryModuleType.WALK_TARGET, + MemoryModuleType.LOOK_TARGET, + MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, + MemoryModuleType.PATH, + MemoryModuleType.VISIBLE_MOBS, + MemoryModuleType.TEMPTING_PLAYER, + MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, + MemoryModuleType.GAZE_COOLDOWN_TICKS, + MemoryModuleType.IS_TEMPTED, + MemoryModuleType.BREED_TARGET, + MemoryModuleType.NEAREST_VISIBLE_ADULT, + PromenadeMemoryModuleTypes.FART_COOLDOWN + ); + + public static Brain.Profile createProfile() { + return Brain.createProfile(MEMORY_MODULES, SENSORS); + } + + protected static Brain create(Brain brain) { + CapybaraBrain.addCoreActivities(brain); + CapybaraBrain.addIdleActivities(brain); + brain.setCoreActivities(ImmutableSet.of(Activity.CORE)); + brain.setDefaultActivity(Activity.IDLE); + brain.resetPossibleActivities(); + return brain; + } + + private static void addCoreActivities(Brain brain) { + brain.setTaskList(Activity.CORE, 0, ImmutableList.of( + new StayAboveWaterTask<>(0.8f), + new net.minecraft.entity.ai.brain.task.FleeTask<>(1.0F) { + protected void run(ServerWorld serverWorld, CapybaraEntity capybaraEntity, long l) { + capybaraEntity.forceDefaultState(); + super.run(serverWorld, capybaraEntity, l); + } + }, + new UpdateLookControlTask(45, 90), + new MoveToTargetTask(), + new TickCooldownTask(MemoryModuleType.TEMPTATION_COOLDOWN_TICKS), + new TickCooldownTask(MemoryModuleType.GAZE_COOLDOWN_TICKS))); + } + + private static void addIdleActivities(Brain brain) { + brain.setTaskList(Activity.IDLE, ImmutableList.of( + Pair.of(0, LookAtMobWithIntervalTask.follow(EntityType.PLAYER, 6.0f, UniformIntProvider.create(30, 60))), + Pair.of(1, new BreedTask(PromenadeEntityTypes.CAPYBARA)), + Pair.of(2, new TemptTask(entity -> 1.5f)), + Pair.of(3, TaskTriggerer.runIf(Predicate.not(CapybaraEntity::isStationary), WalkTowardsEntityTask.createNearestVisibleAdult(WALK_TOWARD_ADULT_RANGE, 1.5f))), + Pair.of(4, new LookAroundTask(UniformIntProvider.create(150, 250), 30.0f, 0.0f, 10.0f)), + Pair.of(5, new RandomTask<>(ImmutableMap.of(MemoryModuleType.WALK_TARGET, MemoryModuleState.VALUE_ABSENT), ImmutableList.of( + Pair.of(TaskTriggerer.runIf(Predicate.not(CapybaraEntity::isStationary), StrollTask.create(1.0f)), 1), + Pair.of(TaskTriggerer.runIf(Predicate.not(CapybaraEntity::isStationary), GoToLookTargetTask.create(1.0f, 3)), 1), + Pair.of(new SleepOrWakeUpTask(20), 1), + Pair.of(new FartTask(10), 1), + Pair.of(new WaitTask(30, 60), 1) + ))))); + } + + public static void updateActivities(CapybaraEntity capybara) { + capybara.getBrain().resetPossibleActivities(ImmutableList.of(Activity.IDLE)); + } + + public static Predicate getTemptItemPredicate() { + return (stack) -> stack.isIn(PromenadeItemTags.CAPYBARA_FOOD); + } + + public static class SleepOrWakeUpTask extends MultiTickTask { + private final int lastPoseTickDelta; + + public SleepOrWakeUpTask(int lastPoseSecondsDelta) { + super(ImmutableMap.of( + MemoryModuleType.IS_PANICKING, MemoryModuleState.VALUE_ABSENT, + MemoryModuleType.IS_TEMPTED, MemoryModuleState.VALUE_ABSENT, + MemoryModuleType.IS_IN_WATER, MemoryModuleState.VALUE_ABSENT, + MemoryModuleType.BREED_TARGET, MemoryModuleState.VALUE_ABSENT)); + this.lastPoseTickDelta = lastPoseSecondsDelta * 20; + } + + @Override + protected boolean shouldRun(ServerWorld world, CapybaraEntity capybara) { + return capybara.getLastStateTickDelta() >= this.lastPoseTickDelta && + !capybara.isLeashed() && + capybara.isOnGround() && + !capybara.hasControllingPassenger(); + } + + @Override + protected void run(ServerWorld world, CapybaraEntity capybara, long l) { + if (capybara.canFallToSleep()) { + capybara.startFallingToSleep(); + } else if (capybara.canWakeUp()) { + capybara.startWakingUp(); + } + } + } + + static class FartTask extends MultiTickTask { + private final int lastPoseTickDelta; + + FartTask(int lastPoseSecondsDelta) { + super(Map.of( + MemoryModuleType.IS_PANICKING, MemoryModuleState.VALUE_ABSENT, + MemoryModuleType.IS_TEMPTED, MemoryModuleState.VALUE_ABSENT, + MemoryModuleType.IS_IN_WATER, MemoryModuleState.VALUE_ABSENT, + PromenadeMemoryModuleTypes.FART_COOLDOWN, MemoryModuleState.VALUE_ABSENT, + MemoryModuleType.BREED_TARGET, MemoryModuleState.VALUE_ABSENT + )); + this.lastPoseTickDelta = lastPoseSecondsDelta * 20; + } + + protected boolean shouldRun(ServerWorld serverWorld, CapybaraEntity capybara) { + return capybara.getLastStateTickDelta() >= this.lastPoseTickDelta && + !capybara.mightBeLeashed() && + capybara.isOnGround() && + !capybara.hasControllingPassenger(); + } + + protected boolean shouldKeepRunning(ServerWorld serverWorld, CapybaraEntity capybara, long l) { + return true; + } + + protected void run(ServerWorld serverWorld, CapybaraEntity capybara, long l) { + capybara.fart(); + } + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/CapybaraEntity.java b/src/main/java/fr/hugman/promenade/entity/CapybaraEntity.java index 9e879130..ae2a1592 100644 --- a/src/main/java/fr/hugman/promenade/entity/CapybaraEntity.java +++ b/src/main/java/fr/hugman/promenade/entity/CapybaraEntity.java @@ -1,17 +1,22 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity; +import java.util.function.IntFunction; + import com.mojang.serialization.Dynamic; -import fr.hugman.promenade.component.PromenadeComponentTypes; -import fr.hugman.promenade.entity.ai.brain.PromenadeMemoryModuleTypes; -import fr.hugman.promenade.entity.data.PromenadeTrackedData; -import fr.hugman.promenade.entity.variant.CapybaraVariant; -import fr.hugman.promenade.entity.variant.CapybaraVariants; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import fr.hugman.promenade.sound.PromenadeSoundEvents; -import fr.hugman.promenade.tag.PromenadeItemTags; import io.netty.buffer.ByteBuf; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import org.jetbrains.annotations.Nullable; + import net.minecraft.SharedConstants; import net.minecraft.component.ComponentType; import net.minecraft.component.ComponentsAccess; @@ -51,477 +56,488 @@ import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; import net.minecraft.world.event.GameEvent; -import org.jetbrains.annotations.Nullable; -import java.util.function.IntFunction; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import fr.hugman.promenade.component.PromenadeComponentTypes; +import fr.hugman.promenade.entity.ai.brain.PromenadeMemoryModuleTypes; +import fr.hugman.promenade.entity.data.PromenadeTrackedData; +import fr.hugman.promenade.entity.variant.CapybaraVariant; +import fr.hugman.promenade.entity.variant.CapybaraVariants; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import fr.hugman.promenade.sound.PromenadeSoundEvents; +import fr.hugman.promenade.tag.PromenadeItemTags; public class CapybaraEntity extends AnimalEntity { - private static final FloatProvider FART_CHANCE_PROVIDER = TrapezoidFloatProvider.create(0.1F, 0.55F, 0.2F); - private static final EntityDimensions BABY_BASE_DIMENSIONS = EntityDimensions.changing(0.7f, 0.875f).scaled(0.5F).withEyeHeight(0.5F); - - protected static final TrackedData STATE = DataTracker.registerData(CapybaraEntity.class, PromenadeTrackedData.CAPYBARA_STATE); - public static final TrackedData LAST_STATE_TICK = DataTracker.registerData(CapybaraEntity.class, TrackedDataHandlerRegistry.LONG); - - public static final String FART_CHANCE_KEY = "fart_chance"; - public static final String LAST_STATE_TICK_KEY = "last_state_tick"; - public static final String STATE_KEY = "state_key"; - - private static final TrackedData> VARIANT = DataTracker.registerData(CapybaraEntity.class, PromenadeTrackedData.CAPYBARA_VARIANT); - private static final TrackedData FART_CHANCE = DataTracker.registerData(CapybaraEntity.class, TrackedDataHandlerRegistry.FLOAT); - - private static final int EAR_WIGGLE_LENGHT = (int) (0.2f * SharedConstants.TICKS_PER_SECOND); - private static final IntProvider EAR_WIGGLE_COOLDOWN_PROVIDER = BiasedToBottomIntProvider.create(EAR_WIGGLE_LENGHT, 64); // Minimum MUST be the length of the anim - public final AnimationState earWiggleAnimState = new AnimationState(); - public final AnimationState fallToSleepAnimState = new AnimationState(); - public final AnimationState sleepingAnimState = new AnimationState(); - public final AnimationState wakeUpAnimState = new AnimationState(); - public final AnimationState fartAnimState = new AnimationState(); - - public int earWiggleCooldown = 0; - - public CapybaraEntity(EntityType entityType, World world) { - super(entityType, world); - this.getNavigation().setCanSwim(true); - } - - @Override - public void tick() { - super.tick(); - if (this.getEntityWorld().isClient()) { - this.updateAnimations(); - } - this.tickState(); - } - - @Override - protected void mobTick(ServerWorld world) { - Profiler profiler = Profilers.get(); - profiler.push("capybaraBrain"); - Brain brain = (Brain) this.getBrain(); - brain.tick((ServerWorld) this.getEntityWorld(), this); - profiler.pop(); - profiler.push("capybaraActivityUpdate"); - CapybaraBrain.updateActivities(this); - profiler.pop(); - super.mobTick(world); - } - - @Override - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData) { - CapybaraVariants.select(this.random, this.getRegistryManager(), SpawnContext.of(world, this.getBlockPos())).ifPresent(this::setVariant); - this.dataTracker.set(LAST_STATE_TICK, world.toServerWorld().getTime() - WAKE_UP_LENGTH); - this.dataTracker.set(FART_CHANCE, FART_CHANCE_PROVIDER.get(this.random)); - return super.initialize(world, difficulty, spawnReason, entityData); - } - - /*========*/ - /* AI */ - /*========*/ - - public static DefaultAttributeContainer.Builder createCapybaraAttributes() { - return createAnimalAttributes() - .add(EntityAttributes.MAX_HEALTH, 10.0) - .add(EntityAttributes.MOVEMENT_SPEED, 0.2); - } - - protected Brain.Profile createBrainProfile() { - return CapybaraBrain.createProfile(); - } - - @Override - protected Brain deserializeBrain(Dynamic dynamic) { - return CapybaraBrain.create(this.createBrainProfile().deserialize(dynamic)); - } - - @Override - public boolean isBreedingItem(ItemStack stack) { - return stack.isIn(PromenadeItemTags.CAPYBARA_FOOD); - } - - @Override - public void travel(Vec3d movementInput) { - if (!this.isAlive()) { - return; - } - if (this.isStationary() && this.isOnGround()) { - this.setVelocity(this.getVelocity().multiply(0.0, 1.0, 0.0)); - movementInput = movementInput.multiply(0.0, 1.0, 0.0); - } - super.travel(movementInput); - } - - public boolean isStationary() { - return this.isFarting() || this.isAsleep() || this.isWakingUp() || this.isFallingToSleep(); - } - - public boolean isPanicking() { - return this.getBrain().isMemoryInState(MemoryModuleType.IS_PANICKING, MemoryModuleState.VALUE_PRESENT); - } - - @Override - protected EntityDimensions getBaseDimensions(EntityPose pose) { - return this.isBaby() ? BABY_BASE_DIMENSIONS : super.getBaseDimensions(pose); - } - - @Override - protected BodyControl createBodyControl() { - return new CapybaraBodyControl(this); - } - - class CapybaraBodyControl extends BodyControl { - - public CapybaraBodyControl(CapybaraEntity capybara) { - super(capybara); - } - - @Override - public void tick() { - if (!CapybaraEntity.this.isStationary()) { - super.tick(); - } - } - } - - - - /*============*/ - /* STATES */ - /*============*/ - - // These values depend on the animations - public static final long FALL_TO_SLEEP_LENGTH = (long) (SharedConstants.TICKS_PER_SECOND * 1.9167667f); - public static final long WAKE_UP_LENGTH = (long) (SharedConstants.TICKS_PER_SECOND * 5.791677f); - public static final long FART_LENGTH = (long) (SharedConstants.TICKS_PER_SECOND * 3.8343335f); - - public void forceDefaultState() { - this.updateState(State.IDLING); - } - - public void updateState(State state) { - this.setState(state); - this.setLastStateTick(this.getEntityWorld().getTime()); - } - - private void tickState() { - if (this.isFarting() && this.getLastStateTickDelta() > this.getFartLength()) { - finishFarting(); - } - if (this.isFallingToSleep() && this.getLastStateTickDelta() > this.getFallToSleepLength()) { - finishFallingToSleep(); - } - if (this.isWakingUp() && this.getLastStateTickDelta() > this.getWakeUpLength()) { - finishWakingUp(); - } - } - - // FALL TO SLEEP - - public boolean isFallingToSleep() { - return this.getState() == State.FALL_TO_SLEEP; - } - - public boolean canFallToSleep() { - return this.isStanding() && !this.isPanicking() && !this.isFarting(); - } - - public long getFallToSleepLength() { - return FALL_TO_SLEEP_LENGTH; - } - - public void startFallingToSleep() { - this.updateState(State.FALL_TO_SLEEP); - } - - public void finishFallingToSleep() { - this.updateState(State.SLEEPING); - } - - // SLEEP - - public boolean isAsleep() { - return this.getState() == State.SLEEPING; - } - - // WAKE UP - - private boolean isWakingUp() { - return this.getState() == State.WAKE_UP; - } + private static final FloatProvider FART_CHANCE_PROVIDER = TrapezoidFloatProvider.create(0.1F, 0.55F, 0.2F); + private static final EntityDimensions BABY_BASE_DIMENSIONS = EntityDimensions.changing(0.7f, 0.875f).scaled(0.5F).withEyeHeight(0.5F); + + protected static final TrackedData STATE = DataTracker.registerData(CapybaraEntity.class, PromenadeTrackedData.CAPYBARA_STATE); + public static final TrackedData LAST_STATE_TICK = DataTracker.registerData(CapybaraEntity.class, TrackedDataHandlerRegistry.LONG); + + public static final String FART_CHANCE_KEY = "fart_chance"; + public static final String LAST_STATE_TICK_KEY = "last_state_tick"; + public static final String STATE_KEY = "state_key"; + + private static final TrackedData> VARIANT = DataTracker.registerData(CapybaraEntity.class, PromenadeTrackedData.CAPYBARA_VARIANT); + private static final TrackedData FART_CHANCE = DataTracker.registerData(CapybaraEntity.class, TrackedDataHandlerRegistry.FLOAT); + + private static final int EAR_WIGGLE_LENGHT = (int) (0.2f * SharedConstants.TICKS_PER_SECOND); + private static final IntProvider EAR_WIGGLE_COOLDOWN_PROVIDER = BiasedToBottomIntProvider.create(EAR_WIGGLE_LENGHT, 64); // Minimum MUST be the length of the anim + public final AnimationState earWiggleAnimState = new AnimationState(); + public final AnimationState fallToSleepAnimState = new AnimationState(); + public final AnimationState sleepingAnimState = new AnimationState(); + public final AnimationState wakeUpAnimState = new AnimationState(); + public final AnimationState fartAnimState = new AnimationState(); + + public int earWiggleCooldown = 0; + + public CapybaraEntity(EntityType entityType, World world) { + super(entityType, world); + this.getNavigation().setCanSwim(true); + } + + @Override + public void tick() { + super.tick(); + if (this.getEntityWorld().isClient()) { + this.updateAnimations(); + } + this.tickState(); + } + + @Override + protected void mobTick(ServerWorld world) { + Profiler profiler = Profilers.get(); + profiler.push("capybaraBrain"); + Brain brain = (Brain) this.getBrain(); + brain.tick((ServerWorld) this.getEntityWorld(), this); + profiler.pop(); + profiler.push("capybaraActivityUpdate"); + CapybaraBrain.updateActivities(this); + profiler.pop(); + super.mobTick(world); + } + + @Override + public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData) { + CapybaraVariants.select(this.random, this.getRegistryManager(), SpawnContext.of(world, this.getBlockPos())).ifPresent(this::setVariant); + this.dataTracker.set(LAST_STATE_TICK, world.toServerWorld().getTime() - WAKE_UP_LENGTH); + this.dataTracker.set(FART_CHANCE, FART_CHANCE_PROVIDER.get(this.random)); + return super.initialize(world, difficulty, spawnReason, entityData); + } + + /*========*/ + /* AI */ + /*========*/ + + public static DefaultAttributeContainer.Builder createCapybaraAttributes() { + return createAnimalAttributes() + .add(EntityAttributes.MAX_HEALTH, 10.0) + .add(EntityAttributes.MOVEMENT_SPEED, 0.2); + } + + protected Brain.Profile createBrainProfile() { + return CapybaraBrain.createProfile(); + } + + @Override + protected Brain deserializeBrain(Dynamic dynamic) { + return CapybaraBrain.create(this.createBrainProfile().deserialize(dynamic)); + } + + @Override + public boolean isBreedingItem(ItemStack stack) { + return stack.isIn(PromenadeItemTags.CAPYBARA_FOOD); + } + + @Override + public void travel(Vec3d movementInput) { + if (!this.isAlive()) { + return; + } + if (this.isStationary() && this.isOnGround()) { + this.setVelocity(this.getVelocity().multiply(0.0, 1.0, 0.0)); + movementInput = movementInput.multiply(0.0, 1.0, 0.0); + } + super.travel(movementInput); + } + + public boolean isStationary() { + return this.isFarting() || this.isAsleep() || this.isWakingUp() || this.isFallingToSleep(); + } + + public boolean isPanicking() { + return this.getBrain().isMemoryInState(MemoryModuleType.IS_PANICKING, MemoryModuleState.VALUE_PRESENT); + } + + @Override + protected EntityDimensions getBaseDimensions(EntityPose pose) { + return this.isBaby() ? BABY_BASE_DIMENSIONS : super.getBaseDimensions(pose); + } + + @Override + protected BodyControl createBodyControl() { + return new CapybaraBodyControl(this); + } + + class CapybaraBodyControl extends BodyControl { + + public CapybaraBodyControl(CapybaraEntity capybara) { + super(capybara); + } + + @Override + public void tick() { + if (!CapybaraEntity.this.isStationary()) { + super.tick(); + } + } + } + + + + /*============*/ + /* STATES */ + /*============*/ + + // These values depend on the animations + public static final long FALL_TO_SLEEP_LENGTH = (long) (SharedConstants.TICKS_PER_SECOND * 1.9167667f); + public static final long WAKE_UP_LENGTH = (long) (SharedConstants.TICKS_PER_SECOND * 5.791677f); + public static final long FART_LENGTH = (long) (SharedConstants.TICKS_PER_SECOND * 3.8343335f); + + public void forceDefaultState() { + this.updateState(State.IDLING); + } + + public void updateState(State state) { + this.setState(state); + this.setLastStateTick(this.getEntityWorld().getTime()); + } + + private void tickState() { + if (this.isFarting() && this.getLastStateTickDelta() > this.getFartLength()) { + finishFarting(); + } + if (this.isFallingToSleep() && this.getLastStateTickDelta() > this.getFallToSleepLength()) { + finishFallingToSleep(); + } + if (this.isWakingUp() && this.getLastStateTickDelta() > this.getWakeUpLength()) { + finishWakingUp(); + } + } + + // FALL TO SLEEP + + public boolean isFallingToSleep() { + return this.getState() == State.FALL_TO_SLEEP; + } + + public boolean canFallToSleep() { + return this.isStanding() && !this.isPanicking() && !this.isFarting(); + } + + public long getFallToSleepLength() { + return FALL_TO_SLEEP_LENGTH; + } + + public void startFallingToSleep() { + this.updateState(State.FALL_TO_SLEEP); + } + + public void finishFallingToSleep() { + this.updateState(State.SLEEPING); + } + + // SLEEP + + public boolean isAsleep() { + return this.getState() == State.SLEEPING; + } + + // WAKE UP + + private boolean isWakingUp() { + return this.getState() == State.WAKE_UP; + } - public boolean canWakeUp() { - return this.isAsleep() && this.getEntityWorld().isDay(); - } - - public long getWakeUpLength() { - return WAKE_UP_LENGTH; - } - - public void startWakingUp() { - this.updateState(State.WAKE_UP); - } - - public void finishWakingUp() { - this.updateState(State.IDLING); - } - - // STAND - - public boolean isStanding() { - return this.getState() == State.IDLING; - } - - // FART - - public void fart() { - this.updateState(State.FARTING); - this.getBrain().remember(PromenadeMemoryModuleTypes.FART_COOLDOWN, Unit.INSTANCE, createFartCooldown()); - - this.playSound(PromenadeSoundEvents.CAPYBARA_FART, getSoundVolume(), getSoundPitch()); - this.emitGameEvent(GameEvent.ENTITY_ACTION); - } - - public boolean isFarting() { - return this.getState() == State.FARTING; - } - - public long getFartLength() { - return FART_LENGTH; - } - - public long createFartCooldown() { - return 120 * 20L; - } - - public void finishFarting() { - this.updateState(State.IDLING); - } - - public void setLastStateTick(long t) { - this.dataTracker.set(LAST_STATE_TICK, t); - } - - public long getLastStateTickDelta() { - return this.getEntityWorld().getTime() - this.dataTracker.get(LAST_STATE_TICK); - } - - public State getState() { - return this.dataTracker.get(STATE); - } - - public void setState(State state) { - this.dataTracker.set(STATE, state); - } - - public enum State implements StringIdentifiable { - IDLING("idling", 0), - FARTING("farting", 1), - SLEEPING("sleeping", 2), - FALL_TO_SLEEP("fall_to_sleep", 3), - WAKE_UP("wake_up", 4); - - private final String name; - private final int index; - - private static final EnumCodec CODEC = StringIdentifiable.createCodec(State::values); - private static final IntFunction INDEX_TO_VALUE = ValueLists.createIndexToValueFunction(State::getIndex, values(), ValueLists.OutOfBoundsHandling.ZERO); - public static final PacketCodec PACKET_CODEC = PacketCodecs.indexed(INDEX_TO_VALUE, State::getIndex); - - State(String name, int index) { - this.name = name; - this.index = index; - } - - public static State fromName(String name) { - return CODEC.byId(name, IDLING); - } - - public String asString() { - return this.name; - } - - private int getIndex() { - return this.index; - } - } - - /*================*/ - /* ANIMATIONS */ - /*================*/ - - @Environment(EnvType.CLIENT) - private void updateAnimations() { - if (this.earWiggleCooldown <= 0) { - this.earWiggleCooldown = MathHelper.clamp(EAR_WIGGLE_COOLDOWN_PROVIDER.get(this.random), (int) (EAR_WIGGLE_LENGHT / this.getEarWiggleSpeed()), Integer.MAX_VALUE); - this.earWiggleAnimState.start(this.age); - } else { - this.earWiggleCooldown--; - } - } - - private void stopAnimations() { - this.fallToSleepAnimState.stop(); - this.sleepingAnimState.stop(); - this.wakeUpAnimState.stop(); - this.fartAnimState.stop(); - } - - @Override - public void onTrackedDataSet(TrackedData data) { - if (STATE.equals(data)) { - var state = this.getState(); - this.stopAnimations(); - AnimationState animstate = (switch (state) { - case FALL_TO_SLEEP -> this.fallToSleepAnimState; - case SLEEPING -> this.sleepingAnimState; - case WAKE_UP -> this.wakeUpAnimState; - case FARTING -> this.fartAnimState; - case null, default -> null; - }); - if (animstate != null) animstate.startIfNotRunning(this.age); - } - - super.onTrackedDataSet(data); - } - - @Environment(EnvType.CLIENT) - public boolean hasLargeEyes() { - boolean surprisedByFart = this.isFarting() && this.getLastStateTickDelta() < 40L; - return isBaby() || surprisedByFart; - } - - @Environment(EnvType.CLIENT) - public boolean hasClosedEyes() { - boolean aboutToStartToSleep = this.isFallingToSleep() && this.getLastStateTickDelta() > 31L; - boolean shakingHead = this.isFarting() && (40L < this.getLastStateTickDelta() && this.getLastStateTickDelta() < 65L); - boolean wakingUp = this.isWakingUp() && (this.getLastStateTickDelta() < 5L || (18L < this.getLastStateTickDelta() && this.getLastStateTickDelta() < 34L)); - - return aboutToStartToSleep || this.isAsleep() || shakingHead || wakingUp; - } - - @Environment(EnvType.CLIENT) - public boolean canAngleHead() { - return !this.isFarting() && !this.isAsleep() && !this.isFallingToSleep() && !this.isWakingUp(); - } - - @Environment(EnvType.CLIENT) - public float getEarWiggleSpeed() { - return this.isAsleep() ? 0.3f : 1.0f; - } - - - /*============*/ - /* SOUNDS */ - /*============*/ - - @Nullable - @Override - protected SoundEvent getAmbientSound() { - if (this.isFallingToSleep() || this.isAsleep() || this.isWakingUp() || this.isFarting()) - return null; //TODO: Sleeping sound - if (this.isBaby()) return PromenadeSoundEvents.CAPYBARA_AMBIENT_BABY; - return PromenadeSoundEvents.CAPYBARA_AMBIENT; - } - - @Override - public int getMinAmbientSoundDelay() { - return this.isBaby() ? 20 : super.getMinAmbientSoundDelay(); - } - - @Override - public void playAmbientSound() { - SoundEvent soundEvent = this.getAmbientSound(); - if (soundEvent != null) { - // Do not pitch up if the sound for babies as it is already pitched up - this.playSound(soundEvent, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - } - } - - - - /*==============*/ - /* VARIANTS */ - /*==============*/ - - @Nullable - @Override - public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { - var capyBaby = PromenadeEntityTypes.CAPYBARA.create(this.getEntityWorld(), SpawnReason.BREEDING); - if (capyBaby != null && entity instanceof CapybaraEntity capyMama) { - capyBaby.setVariant(this.random.nextBoolean() ? this.getVariant() : capyMama.getVariant()); - } - return capyBaby; - } - - public RegistryEntry getVariant() { - return this.dataTracker.get(VARIANT); - } - - public void setVariant(RegistryEntry variant) { - this.dataTracker.set(VARIANT, variant); - } - - public float getFartChance() { - return this.dataTracker.get(FART_CHANCE); - } - - public void setFartChance(float frequency) { - this.dataTracker.set(FART_CHANCE, frequency); - } - - - - /*==========*/ - /* DATA */ - /*==========*/ - - @Override - protected void initDataTracker(DataTracker.Builder builder) { - super.initDataTracker(builder); - builder.add(VARIANT, Variants.getOrDefaultOrThrow(this.getRegistryManager(), CapybaraVariants.DEFAULT)); - builder.add(FART_CHANCE, 0.0f); - builder.add(STATE, State.IDLING); - builder.add(LAST_STATE_TICK, -WAKE_UP_LENGTH); - } - - @Override - protected void writeCustomData(WriteView view) { - super.writeCustomData(view); - Variants.writeVariantToNbt(view, this.getVariant()); - - view.putFloat(FART_CHANCE_KEY, this.getFartChance()); - view.putString(STATE_KEY, this.getState().asString()); - view.putLong(LAST_STATE_TICK_KEY, this.dataTracker.get(LAST_STATE_TICK)); - } - - @Override - protected void readCustomData(ReadView view) { - super.readCustomData(view); - Variants.readVariantFromNbt(view, PromenadeRegistryKeys.CAPYBARA_VARIANT).ifPresent(this::setVariant); - - view.getOptionalString(STATE_KEY).ifPresent(s -> this.setState(State.fromName(s))); - view.getOptionalLong(LAST_STATE_TICK_KEY).ifPresent(this::setLastStateTick); - this.setFartChance(view.getFloat(FART_CHANCE_KEY, FART_CHANCE_PROVIDER.getMin())); - } - - @Nullable - @Override - public T get(ComponentType type) { - return type == PromenadeComponentTypes.CAPYBARA_VARIANT ? castComponentValue((ComponentType)type, this.getVariant()) : super.get(type); - } - - @Override - protected void copyComponentsFrom(ComponentsAccess from) { - this.copyComponentFrom(from, PromenadeComponentTypes.CAPYBARA_VARIANT); - super.copyComponentsFrom(from); - } - - @Override - protected boolean setApplicableComponent(ComponentType type, T value) { - if (type == PromenadeComponentTypes.CAPYBARA_VARIANT) { - this.setVariant(castComponentValue(PromenadeComponentTypes.CAPYBARA_VARIANT, value)); - return true; - } else { - return super.setApplicableComponent(type, value); - } - } + public boolean canWakeUp() { + return this.isAsleep() && this.getEntityWorld().isDay(); + } + + public long getWakeUpLength() { + return WAKE_UP_LENGTH; + } + + public void startWakingUp() { + this.updateState(State.WAKE_UP); + } + + public void finishWakingUp() { + this.updateState(State.IDLING); + } + + // STAND + + public boolean isStanding() { + return this.getState() == State.IDLING; + } + + // FART + + public void fart() { + this.updateState(State.FARTING); + this.getBrain().remember(PromenadeMemoryModuleTypes.FART_COOLDOWN, Unit.INSTANCE, createFartCooldown()); + + this.playSound(PromenadeSoundEvents.CAPYBARA_FART, getSoundVolume(), getSoundPitch()); + this.emitGameEvent(GameEvent.ENTITY_ACTION); + } + + public boolean isFarting() { + return this.getState() == State.FARTING; + } + + public long getFartLength() { + return FART_LENGTH; + } + + public long createFartCooldown() { + return 120 * 20L; + } + + public void finishFarting() { + this.updateState(State.IDLING); + } + + public void setLastStateTick(long t) { + this.dataTracker.set(LAST_STATE_TICK, t); + } + + public long getLastStateTickDelta() { + return this.getEntityWorld().getTime() - this.dataTracker.get(LAST_STATE_TICK); + } + + public State getState() { + return this.dataTracker.get(STATE); + } + + public void setState(State state) { + this.dataTracker.set(STATE, state); + } + + public enum State implements StringIdentifiable { + IDLING("idling", 0), + FARTING("farting", 1), + SLEEPING("sleeping", 2), + FALL_TO_SLEEP("fall_to_sleep", 3), + WAKE_UP("wake_up", 4); + + private final String name; + private final int index; + + private static final EnumCodec CODEC = StringIdentifiable.createCodec(State::values); + private static final IntFunction INDEX_TO_VALUE = ValueLists.createIndexToValueFunction(State::getIndex, values(), ValueLists.OutOfBoundsHandling.ZERO); + public static final PacketCodec PACKET_CODEC = PacketCodecs.indexed(INDEX_TO_VALUE, State::getIndex); + + State(String name, int index) { + this.name = name; + this.index = index; + } + + public static State fromName(String name) { + return CODEC.byId(name, IDLING); + } + + public String asString() { + return this.name; + } + + private int getIndex() { + return this.index; + } + } + + /*================*/ + /* ANIMATIONS */ + /*================*/ + + @Environment(EnvType.CLIENT) + private void updateAnimations() { + if (this.earWiggleCooldown <= 0) { + this.earWiggleCooldown = MathHelper.clamp(EAR_WIGGLE_COOLDOWN_PROVIDER.get(this.random), (int) (EAR_WIGGLE_LENGHT / this.getEarWiggleSpeed()), Integer.MAX_VALUE); + this.earWiggleAnimState.start(this.age); + } else { + this.earWiggleCooldown--; + } + } + + private void stopAnimations() { + this.fallToSleepAnimState.stop(); + this.sleepingAnimState.stop(); + this.wakeUpAnimState.stop(); + this.fartAnimState.stop(); + } + + @Override + public void onTrackedDataSet(TrackedData data) { + if (STATE.equals(data)) { + var state = this.getState(); + this.stopAnimations(); + AnimationState animstate = (switch (state) { + case FALL_TO_SLEEP -> this.fallToSleepAnimState; + case SLEEPING -> this.sleepingAnimState; + case WAKE_UP -> this.wakeUpAnimState; + case FARTING -> this.fartAnimState; + case null, default -> null; + }); + if (animstate != null) + animstate.startIfNotRunning(this.age); + } + + super.onTrackedDataSet(data); + } + + @Environment(EnvType.CLIENT) + public boolean hasLargeEyes() { + boolean surprisedByFart = this.isFarting() && this.getLastStateTickDelta() < 40L; + return isBaby() || surprisedByFart; + } + + @Environment(EnvType.CLIENT) + public boolean hasClosedEyes() { + boolean aboutToStartToSleep = this.isFallingToSleep() && this.getLastStateTickDelta() > 31L; + boolean shakingHead = this.isFarting() && (40L < this.getLastStateTickDelta() && this.getLastStateTickDelta() < 65L); + boolean wakingUp = this.isWakingUp() && (this.getLastStateTickDelta() < 5L || (18L < this.getLastStateTickDelta() && this.getLastStateTickDelta() < 34L)); + + return aboutToStartToSleep || this.isAsleep() || shakingHead || wakingUp; + } + + @Environment(EnvType.CLIENT) + public boolean canAngleHead() { + return !this.isFarting() && !this.isAsleep() && !this.isFallingToSleep() && !this.isWakingUp(); + } + + @Environment(EnvType.CLIENT) + public float getEarWiggleSpeed() { + return this.isAsleep() ? 0.3f : 1.0f; + } + + + /*============*/ + /* SOUNDS */ + /*============*/ + + @Nullable + @Override + protected SoundEvent getAmbientSound() { + if (this.isFallingToSleep() || this.isAsleep() || this.isWakingUp() || this.isFarting()) + return null; //TODO: Sleeping sound + if (this.isBaby()) + return PromenadeSoundEvents.CAPYBARA_AMBIENT_BABY; + return PromenadeSoundEvents.CAPYBARA_AMBIENT; + } + + @Override + public int getMinAmbientSoundDelay() { + return this.isBaby() ? 20 : super.getMinAmbientSoundDelay(); + } + + @Override + public void playAmbientSound() { + SoundEvent soundEvent = this.getAmbientSound(); + if (soundEvent != null) { + // Do not pitch up if the sound for babies as it is already pitched up + this.playSound(soundEvent, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + } + } + + + + /*==============*/ + /* VARIANTS */ + /*==============*/ + + @Nullable + @Override + public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { + var capyBaby = PromenadeEntityTypes.CAPYBARA.create(this.getEntityWorld(), SpawnReason.BREEDING); + if (capyBaby != null && entity instanceof CapybaraEntity capyMama) { + capyBaby.setVariant(this.random.nextBoolean() ? this.getVariant() : capyMama.getVariant()); + } + return capyBaby; + } + + public RegistryEntry getVariant() { + return this.dataTracker.get(VARIANT); + } + + public void setVariant(RegistryEntry variant) { + this.dataTracker.set(VARIANT, variant); + } + + public float getFartChance() { + return this.dataTracker.get(FART_CHANCE); + } + + public void setFartChance(float frequency) { + this.dataTracker.set(FART_CHANCE, frequency); + } + + + + /*==========*/ + /* DATA */ + /*==========*/ + + @Override + protected void initDataTracker(DataTracker.Builder builder) { + super.initDataTracker(builder); + builder.add(VARIANT, Variants.getOrDefaultOrThrow(this.getRegistryManager(), CapybaraVariants.DEFAULT)); + builder.add(FART_CHANCE, 0.0f); + builder.add(STATE, State.IDLING); + builder.add(LAST_STATE_TICK, -WAKE_UP_LENGTH); + } + + @Override + protected void writeCustomData(WriteView view) { + super.writeCustomData(view); + Variants.writeVariantToNbt(view, this.getVariant()); + + view.putFloat(FART_CHANCE_KEY, this.getFartChance()); + view.putString(STATE_KEY, this.getState().asString()); + view.putLong(LAST_STATE_TICK_KEY, this.dataTracker.get(LAST_STATE_TICK)); + } + + @Override + protected void readCustomData(ReadView view) { + super.readCustomData(view); + Variants.readVariantFromNbt(view, PromenadeRegistryKeys.CAPYBARA_VARIANT).ifPresent(this::setVariant); + + view.getOptionalString(STATE_KEY).ifPresent(s -> this.setState(State.fromName(s))); + view.getOptionalLong(LAST_STATE_TICK_KEY).ifPresent(this::setLastStateTick); + this.setFartChance(view.getFloat(FART_CHANCE_KEY, FART_CHANCE_PROVIDER.getMin())); + } + + @Nullable + @Override + public T get(ComponentType type) { + return type == PromenadeComponentTypes.CAPYBARA_VARIANT ? castComponentValue((ComponentType) type, this.getVariant()) : super.get(type); + } + + @Override + protected void copyComponentsFrom(ComponentsAccess from) { + this.copyComponentFrom(from, PromenadeComponentTypes.CAPYBARA_VARIANT); + super.copyComponentsFrom(from); + } + + @Override + protected boolean setApplicableComponent(ComponentType type, T value) { + if (type == PromenadeComponentTypes.CAPYBARA_VARIANT) { + this.setVariant(castComponentValue(PromenadeComponentTypes.CAPYBARA_VARIANT, value)); + return true; + } else { + return super.setApplicableComponent(type, value); + } + } } diff --git a/src/main/java/fr/hugman/promenade/entity/DuckEntity.java b/src/main/java/fr/hugman/promenade/entity/DuckEntity.java index b7209319..b5e7eec6 100644 --- a/src/main/java/fr/hugman/promenade/entity/DuckEntity.java +++ b/src/main/java/fr/hugman/promenade/entity/DuckEntity.java @@ -1,12 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity; -import fr.hugman.promenade.component.PromenadeComponentTypes; -import fr.hugman.promenade.entity.data.PromenadeTrackedData; -import fr.hugman.promenade.entity.variant.DuckVariant; -import fr.hugman.promenade.entity.variant.DuckVariants; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import fr.hugman.promenade.sound.PromenadeSoundEvents; -import fr.hugman.promenade.tag.PromenadeItemTags; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.BlockState; import net.minecraft.component.ComponentType; import net.minecraft.component.ComponentsAccess; @@ -34,183 +40,190 @@ import net.minecraft.world.LocalDifficulty; import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; + +import fr.hugman.promenade.component.PromenadeComponentTypes; +import fr.hugman.promenade.entity.data.PromenadeTrackedData; +import fr.hugman.promenade.entity.variant.DuckVariant; +import fr.hugman.promenade.entity.variant.DuckVariants; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import fr.hugman.promenade.sound.PromenadeSoundEvents; +import fr.hugman.promenade.tag.PromenadeItemTags; public class DuckEntity extends AnimalEntity { - private static final EntityDimensions BABY_BASE_DIMENSIONS = EntityDimensions.changing(0.4F, 0.8F).scaled(0.5F).withEyeHeight(0.78125F); - - private static final TrackedData> VARIANT = DataTracker.registerData(DuckEntity.class, PromenadeTrackedData.DUCK_VARIANT); - - public float flapProgress; - public float maxWingDeviation; - public float prevMaxWingDeviation; - public float prevFlapProgress; - public float wingRotDelta = 1.0F; - - public DuckEntity(EntityType type, World worldIn) { - super(type, worldIn); - this.setPathfindingPenalty(PathNodeType.WATER, 0.0F); - } - - @Override - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @org.jetbrains.annotations.Nullable EntityData entityData) { - DuckVariants.select(this.random, this.getRegistryManager(), SpawnContext.of(world, this.getBlockPos())).ifPresent(this::setVariant); - return super.initialize(world, difficulty, spawnReason, entityData); - } - - @Override - protected EntityDimensions getBaseDimensions(EntityPose pose) { - return this.isBaby() ? BABY_BASE_DIMENSIONS : super.getBaseDimensions(pose); - } - - @Override - protected void updatePassengerPosition(Entity passenger, Entity.PositionUpdater positionUpdater) { - super.updatePassengerPosition(passenger, positionUpdater); - if (passenger instanceof LivingEntity) { - ((LivingEntity) passenger).bodyYaw = this.bodyYaw; - } - } - - /*========*/ - /* AI */ - /*========*/ - - public static Builder createDuckAttributes() { - return createAnimalAttributes() - .add(EntityAttributes.MAX_HEALTH, 4.0D) - .add(EntityAttributes.MOVEMENT_SPEED, 0.25D); - } - - @Override - protected void initGoals() { - this.goalSelector.add(0, new SwimGoal(this)); - this.goalSelector.add(1, new EscapeDangerGoal(this, 1.4D)); - this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D)); - this.goalSelector.add(3, new TemptGoal(this, 1.0, (stack) -> stack.isIn(PromenadeItemTags.DUCK_FOOD), false)); - this.goalSelector.add(4, new FollowParentGoal(this, 1.1D)); - this.goalSelector.add(5, new SwimAroundGoal(this, 1.0, 10)); - this.goalSelector.add(6, new WanderAroundFarGoal(this, 1.0D)); - this.goalSelector.add(7, new LookAtEntityGoal(this, PlayerEntity.class, 6.0F)); - this.goalSelector.add(8, new LookAroundGoal(this)); - } - - @Override - public void tickMovement() { - super.tickMovement(); - boolean isAirBorne = !this.isOnGround() && !this.isTouchingWater(); - this.prevFlapProgress = this.flapProgress; - this.prevMaxWingDeviation = this.maxWingDeviation; - this.maxWingDeviation = (float) ((double) this.maxWingDeviation + (double) (!isAirBorne ? -1 : 4) * 0.3D); - this.maxWingDeviation = MathHelper.clamp(this.maxWingDeviation, 0.0F, 1.0F); - if (isAirBorne && this.wingRotDelta < 0.55F) { - this.wingRotDelta = 0.55F; - } - this.wingRotDelta = (float) ((double) this.wingRotDelta * 0.9D); - Vec3d vec3d = this.getVelocity(); - if (isAirBorne && vec3d.y < 0.0D) { - this.setVelocity(vec3d.multiply(1.0D, 0.75D, 1.0D)); - } - this.flapProgress += this.wingRotDelta * 2.0F; - } - - @Override - public boolean isBreedingItem(ItemStack stack) { - return stack.isIn(PromenadeItemTags.DUCK_FOOD); - } - - @Override - protected float getBaseWaterMovementSpeedMultiplier() { - return 0.9f; - } - - /*============*/ - /* SOUNDS */ - /*============*/ - - @Override - protected SoundEvent getAmbientSound() { - return PromenadeSoundEvents.DUCK_AMBIENT; - } - - @Override - protected SoundEvent getHurtSound(DamageSource source) { - return PromenadeSoundEvents.DUCK_HURT; - } - - @Override - protected SoundEvent getDeathSound() { - return PromenadeSoundEvents.DUCK_DEATH; - } - - @Override - protected void playStepSound(BlockPos pos, BlockState state) { - this.playSound(PromenadeSoundEvents.DUCK_STEP, 0.15F, 1.0F); - } - - /*==============*/ - /* VARIANTS */ - /*==============*/ - - @Nullable - @Override - public DuckEntity createChild(ServerWorld serverWorld, PassiveEntity entity) { - DuckEntity child = PromenadeEntityTypes.DUCK.create(this.getEntityWorld(), SpawnReason.BREEDING); - if (child != null && entity instanceof DuckEntity mama) { - child.setVariant(this.random.nextFloat() < 0.5f ? mama.getVariant() : this.getVariant()); - } - return child; - } - - public RegistryEntry getVariant() { - return this.dataTracker.get(VARIANT); - } - - public void setVariant(RegistryEntry registryEntry) { - this.dataTracker.set(VARIANT, registryEntry); - } - - /*==========*/ - /* DATA */ - /*==========*/ - - @Override - protected void initDataTracker(DataTracker.Builder builder) { - super.initDataTracker(builder); - builder.add(VARIANT, Variants.getOrDefaultOrThrow(this.getRegistryManager(), DuckVariants.DEFAULT)); - } - - @Override - protected void writeCustomData(WriteView view) { - super.writeCustomData(view); - Variants.writeVariantToNbt(view, this.getVariant()); - } - - @Override - protected void readCustomData(ReadView view) { - super.readCustomData(view); - Variants.readVariantFromNbt(view, PromenadeRegistryKeys.DUCK_VARIANT).ifPresent(this::setVariant); - } - - @Nullable - @Override - public T get(ComponentType type) { - return type == PromenadeComponentTypes.DUCK_VARIANT ? castComponentValue((ComponentType) type, this.getVariant()) : super.get(type); - } - - @Override - protected void copyComponentsFrom(ComponentsAccess from) { - this.copyComponentFrom(from, PromenadeComponentTypes.DUCK_VARIANT); - super.copyComponentsFrom(from); - } - - @Override - protected boolean setApplicableComponent(ComponentType type, T value) { - if (type == PromenadeComponentTypes.DUCK_VARIANT) { - this.setVariant(castComponentValue(PromenadeComponentTypes.DUCK_VARIANT, value)); - return true; - } else { - return super.setApplicableComponent(type, value); - } - } + private static final EntityDimensions BABY_BASE_DIMENSIONS = EntityDimensions.changing(0.4F, 0.8F).scaled(0.5F).withEyeHeight(0.78125F); + + private static final TrackedData> VARIANT = DataTracker.registerData(DuckEntity.class, PromenadeTrackedData.DUCK_VARIANT); + + public float flapProgress; + public float maxWingDeviation; + public float prevMaxWingDeviation; + public float prevFlapProgress; + public float wingRotDelta = 1.0F; + + public DuckEntity(EntityType type, World worldIn) { + super(type, worldIn); + this.setPathfindingPenalty(PathNodeType.WATER, 0.0F); + } + + @Override + public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @org.jetbrains.annotations.Nullable EntityData entityData) { + DuckVariants.select(this.random, this.getRegistryManager(), SpawnContext.of(world, this.getBlockPos())).ifPresent(this::setVariant); + return super.initialize(world, difficulty, spawnReason, entityData); + } + + @Override + protected EntityDimensions getBaseDimensions(EntityPose pose) { + return this.isBaby() ? BABY_BASE_DIMENSIONS : super.getBaseDimensions(pose); + } + + @Override + protected void updatePassengerPosition(Entity passenger, Entity.PositionUpdater positionUpdater) { + super.updatePassengerPosition(passenger, positionUpdater); + if (passenger instanceof LivingEntity) { + ((LivingEntity) passenger).bodyYaw = this.bodyYaw; + } + } + + /*========*/ + /* AI */ + /*========*/ + + public static Builder createDuckAttributes() { + return createAnimalAttributes() + .add(EntityAttributes.MAX_HEALTH, 4.0D) + .add(EntityAttributes.MOVEMENT_SPEED, 0.25D); + } + + @Override + protected void initGoals() { + this.goalSelector.add(0, new SwimGoal(this)); + this.goalSelector.add(1, new EscapeDangerGoal(this, 1.4D)); + this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D)); + this.goalSelector.add(3, new TemptGoal(this, 1.0, (stack) -> stack.isIn(PromenadeItemTags.DUCK_FOOD), false)); + this.goalSelector.add(4, new FollowParentGoal(this, 1.1D)); + this.goalSelector.add(5, new SwimAroundGoal(this, 1.0, 10)); + this.goalSelector.add(6, new WanderAroundFarGoal(this, 1.0D)); + this.goalSelector.add(7, new LookAtEntityGoal(this, PlayerEntity.class, 6.0F)); + this.goalSelector.add(8, new LookAroundGoal(this)); + } + + @Override + public void tickMovement() { + super.tickMovement(); + boolean isAirBorne = !this.isOnGround() && !this.isTouchingWater(); + this.prevFlapProgress = this.flapProgress; + this.prevMaxWingDeviation = this.maxWingDeviation; + this.maxWingDeviation = (float) ((double) this.maxWingDeviation + (double) (!isAirBorne ? -1 : 4) * 0.3D); + this.maxWingDeviation = MathHelper.clamp(this.maxWingDeviation, 0.0F, 1.0F); + if (isAirBorne && this.wingRotDelta < 0.55F) { + this.wingRotDelta = 0.55F; + } + this.wingRotDelta = (float) ((double) this.wingRotDelta * 0.9D); + Vec3d vec3d = this.getVelocity(); + if (isAirBorne && vec3d.y < 0.0D) { + this.setVelocity(vec3d.multiply(1.0D, 0.75D, 1.0D)); + } + this.flapProgress += this.wingRotDelta * 2.0F; + } + + @Override + public boolean isBreedingItem(ItemStack stack) { + return stack.isIn(PromenadeItemTags.DUCK_FOOD); + } + + @Override + protected float getBaseWaterMovementSpeedMultiplier() { + return 0.9f; + } + + /*============*/ + /* SOUNDS */ + /*============*/ + + @Override + protected SoundEvent getAmbientSound() { + return PromenadeSoundEvents.DUCK_AMBIENT; + } + + @Override + protected SoundEvent getHurtSound(DamageSource source) { + return PromenadeSoundEvents.DUCK_HURT; + } + + @Override + protected SoundEvent getDeathSound() { + return PromenadeSoundEvents.DUCK_DEATH; + } + + @Override + protected void playStepSound(BlockPos pos, BlockState state) { + this.playSound(PromenadeSoundEvents.DUCK_STEP, 0.15F, 1.0F); + } + + /*==============*/ + /* VARIANTS */ + /*==============*/ + + @Nullable + @Override + public DuckEntity createChild(ServerWorld serverWorld, PassiveEntity entity) { + DuckEntity child = PromenadeEntityTypes.DUCK.create(this.getEntityWorld(), SpawnReason.BREEDING); + if (child != null && entity instanceof DuckEntity mama) { + child.setVariant(this.random.nextFloat() < 0.5f ? mama.getVariant() : this.getVariant()); + } + return child; + } + + public RegistryEntry getVariant() { + return this.dataTracker.get(VARIANT); + } + + public void setVariant(RegistryEntry registryEntry) { + this.dataTracker.set(VARIANT, registryEntry); + } + + /*==========*/ + /* DATA */ + /*==========*/ + + @Override + protected void initDataTracker(DataTracker.Builder builder) { + super.initDataTracker(builder); + builder.add(VARIANT, Variants.getOrDefaultOrThrow(this.getRegistryManager(), DuckVariants.DEFAULT)); + } + + @Override + protected void writeCustomData(WriteView view) { + super.writeCustomData(view); + Variants.writeVariantToNbt(view, this.getVariant()); + } + + @Override + protected void readCustomData(ReadView view) { + super.readCustomData(view); + Variants.readVariantFromNbt(view, PromenadeRegistryKeys.DUCK_VARIANT).ifPresent(this::setVariant); + } + + @Nullable + @Override + public T get(ComponentType type) { + return type == PromenadeComponentTypes.DUCK_VARIANT ? castComponentValue((ComponentType) type, this.getVariant()) : super.get(type); + } + + @Override + protected void copyComponentsFrom(ComponentsAccess from) { + this.copyComponentFrom(from, PromenadeComponentTypes.DUCK_VARIANT); + super.copyComponentsFrom(from); + } + + @Override + protected boolean setApplicableComponent(ComponentType type, T value) { + if (type == PromenadeComponentTypes.DUCK_VARIANT) { + this.setVariant(castComponentValue(PromenadeComponentTypes.DUCK_VARIANT, value)); + return true; + } else { + return super.setApplicableComponent(type, value); + } + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/LushCreeperEntity.java b/src/main/java/fr/hugman/promenade/entity/LushCreeperEntity.java index 5dd0bb32..fc133017 100644 --- a/src/main/java/fr/hugman/promenade/entity/LushCreeperEntity.java +++ b/src/main/java/fr/hugman/promenade/entity/LushCreeperEntity.java @@ -1,5 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity; +import java.util.Collection; + import net.minecraft.entity.AreaEffectCloudEntity; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnReason; @@ -17,70 +30,68 @@ import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.UndergroundConfiguredFeatures; -import java.util.Collection; - public class LushCreeperEntity extends CreeperEntity { - private static final int EXPLOSION_Y_LENGTH = 10; + private static final int EXPLOSION_Y_LENGTH = 10; - public LushCreeperEntity(EntityType entityType, World world) { - super(entityType, world); - } + public LushCreeperEntity(EntityType entityType, World world) { + super(entityType, world); + } - public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { - return pos.getY() < 0 && HostileEntity.canSpawnInDark(type, world, spawnReason, pos, random); - } + public static boolean canSpawn(EntityType type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { + return pos.getY() < 0 && HostileEntity.canSpawnInDark(type, world, spawnReason, pos, random); + } - @Override - protected void explode() { - if (this.getEntityWorld() instanceof ServerWorld serverWorld) { - boolean hasGeneratedMoss = false; - if (serverWorld.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) { - Registry> registry = serverWorld.getRegistryManager().getOrThrow(RegistryKeys.CONFIGURED_FEATURE); - for (int i = 0; i < EXPLOSION_Y_LENGTH; i++) { - BlockPos pos = getBlockPos().down(i); - if (this.getEntityWorld().getBlockState(pos).isSolidBlock(this.getEntityWorld(), pos)) { - if (registry.get(this.getEntityWorld().getRandom().nextBoolean() ? UndergroundConfiguredFeatures.MOSS_PATCH : UndergroundConfiguredFeatures.CLAY_POOL_WITH_DRIPLEAVES).generate(serverWorld, serverWorld.getChunkManager().getChunkGenerator(), random, pos.up())) { - hasGeneratedMoss = true; - } - break; - } - } - for (int i = 0; i < EXPLOSION_Y_LENGTH; i++) { - BlockPos pos = getBlockPos().up(i); - if (this.getEntityWorld().getBlockState(pos).isSolidBlock(this.getEntityWorld(), pos)) { - if (registry.get(UndergroundConfiguredFeatures.MOSS_PATCH_CEILING).generate(serverWorld, serverWorld.getChunkManager().getChunkGenerator(), random, pos.down())) { - hasGeneratedMoss = true; - } - break; - } - } - } - if (hasGeneratedMoss) { - this.dead = true; - float f = this.isCharged() ? 2.0F : 1.0F; - this.getEntityWorld().createExplosion(this, this.getX(), this.getY(), this.getZ(), f, World.ExplosionSourceType.MOB); - this.discard(); - this.spawnEffectsCloud(); - } else { - super.explode(); - } - } - } + @Override + protected void explode() { + if (this.getEntityWorld() instanceof ServerWorld serverWorld) { + boolean hasGeneratedMoss = false; + if (serverWorld.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) { + Registry> registry = serverWorld.getRegistryManager().getOrThrow(RegistryKeys.CONFIGURED_FEATURE); + for (int i = 0; i < EXPLOSION_Y_LENGTH; i++) { + BlockPos pos = getBlockPos().down(i); + if (this.getEntityWorld().getBlockState(pos).isSolidBlock(this.getEntityWorld(), pos)) { + if (registry.get(this.getEntityWorld().getRandom().nextBoolean() ? UndergroundConfiguredFeatures.MOSS_PATCH : UndergroundConfiguredFeatures.CLAY_POOL_WITH_DRIPLEAVES).generate(serverWorld, serverWorld.getChunkManager().getChunkGenerator(), random, pos.up())) { + hasGeneratedMoss = true; + } + break; + } + } + for (int i = 0; i < EXPLOSION_Y_LENGTH; i++) { + BlockPos pos = getBlockPos().up(i); + if (this.getEntityWorld().getBlockState(pos).isSolidBlock(this.getEntityWorld(), pos)) { + if (registry.get(UndergroundConfiguredFeatures.MOSS_PATCH_CEILING).generate(serverWorld, serverWorld.getChunkManager().getChunkGenerator(), random, pos.down())) { + hasGeneratedMoss = true; + } + break; + } + } + } + if (hasGeneratedMoss) { + this.dead = true; + float f = this.isCharged() ? 2.0F : 1.0F; + this.getEntityWorld().createExplosion(this, this.getX(), this.getY(), this.getZ(), f, World.ExplosionSourceType.MOB); + this.discard(); + this.spawnEffectsCloud(); + } else { + super.explode(); + } + } + } - private void spawnEffectsCloud() { - Collection statusEffects = this.getStatusEffects(); - if (!statusEffects.isEmpty()) { - AreaEffectCloudEntity aec = new AreaEffectCloudEntity(this.getEntityWorld(), this.getX(), this.getY(), this.getZ()); - aec.setRadius(2.5F); - aec.setRadiusOnUse(-0.5F); - aec.setWaitTime(10); - aec.setDuration(aec.getDuration() / 2); - aec.setRadiusGrowth(-aec.getRadius() / (float) aec.getDuration()); + private void spawnEffectsCloud() { + Collection statusEffects = this.getStatusEffects(); + if (!statusEffects.isEmpty()) { + AreaEffectCloudEntity aec = new AreaEffectCloudEntity(this.getEntityWorld(), this.getX(), this.getY(), this.getZ()); + aec.setRadius(2.5F); + aec.setRadiusOnUse(-0.5F); + aec.setWaitTime(10); + aec.setDuration(aec.getDuration() / 2); + aec.setRadiusGrowth(-aec.getRadius() / (float) aec.getDuration()); - for (StatusEffectInstance statusEffectInstance : statusEffects) { - aec.addEffect(new StatusEffectInstance(statusEffectInstance)); - } - this.getEntityWorld().spawnEntity(aec); - } - } + for (StatusEffectInstance statusEffectInstance : statusEffects) { + aec.addEffect(new StatusEffectInstance(statusEffectInstance)); + } + this.getEntityWorld().spawnEntity(aec); + } + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/PromenadeEntityTypes.java b/src/main/java/fr/hugman/promenade/entity/PromenadeEntityTypes.java index 5f204910..6360aad5 100644 --- a/src/main/java/fr/hugman/promenade/entity/PromenadeEntityTypes.java +++ b/src/main/java/fr/hugman/promenade/entity/PromenadeEntityTypes.java @@ -1,14 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.config.PromenadeConfig; -import fr.hugman.promenade.entity.helper.EntityTypeFactory; -import fr.hugman.promenade.item.PromenadeItems; -import fr.hugman.promenade.tag.PromenadeBiomeTags; -import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; -import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; -import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType; +import java.util.function.Predicate; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; @@ -23,75 +27,84 @@ import net.minecraft.world.Heightmap; import net.minecraft.world.biome.BiomeKeys; -import java.util.function.Predicate; +import net.fabricmc.fabric.api.biome.v1.BiomeModifications; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; +import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType; + +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.config.PromenadeConfig; +import fr.hugman.promenade.entity.helper.EntityTypeFactory; +import fr.hugman.promenade.item.PromenadeItems; +import fr.hugman.promenade.tag.PromenadeBiomeTags; public class PromenadeEntityTypes { - public static final EntityType SAKURA_BOAT = register("sakura_boat", EntityTypeFactory.boat(() -> PromenadeItems.SAKURA_BOAT)); - public static final EntityType SAKURA_CHEST_BOAT = register("sakura_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.SAKURA_CHEST_BOAT)); + public static final EntityType SAKURA_BOAT = register("sakura_boat", EntityTypeFactory.boat(() -> PromenadeItems.SAKURA_BOAT)); + public static final EntityType SAKURA_CHEST_BOAT = register("sakura_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.SAKURA_CHEST_BOAT)); - public static final EntityType MAPLE_BOAT = register("maple_boat", EntityTypeFactory.boat(() -> PromenadeItems.MAPLE_BOAT)); - public static final EntityType MAPLE_CHEST_BOAT = register("maple_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.MAPLE_CHEST_BOAT)); + public static final EntityType MAPLE_BOAT = register("maple_boat", EntityTypeFactory.boat(() -> PromenadeItems.MAPLE_BOAT)); + public static final EntityType MAPLE_CHEST_BOAT = register("maple_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.MAPLE_CHEST_BOAT)); - public static final EntityType PALM_BOAT = register("palm_boat", EntityTypeFactory.boat(() -> PromenadeItems.PALM_BOAT)); - public static final EntityType PALM_CHEST_BOAT = register("palm_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.PALM_CHEST_BOAT)); + public static final EntityType PALM_BOAT = register("palm_boat", EntityTypeFactory.boat(() -> PromenadeItems.PALM_BOAT)); + public static final EntityType PALM_CHEST_BOAT = register("palm_chest_boat", EntityTypeFactory.chestBoat(() -> PromenadeItems.PALM_CHEST_BOAT)); - public static final EntityType CAPYBARA = register("capybara", FabricEntityType.Builder.createMob(CapybaraEntity::new, SpawnGroup.CREATURE, mob -> mob - .defaultAttributes(CapybaraEntity::createCapybaraAttributes) - .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn) - ) - .dimensions(0.7f, 0.875f) - .eyeHeight(0.875f)); - public static final EntityType DUCK = register("duck", FabricEntityType.Builder.createMob(DuckEntity::new, SpawnGroup.CREATURE, mob -> mob - .defaultAttributes(DuckEntity::createDuckAttributes) - .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn) - ) - .dimensions(0.4F, 0.8F) - .eyeHeight(1.09375f) - .maxTrackingRange(10) - .trackingTickInterval(3)); - public static final EntityType LUSH_CREEPER = register("lush_creeper", FabricEntityType.Builder.createMob(LushCreeperEntity::new, SpawnGroup.MONSTER, mob -> mob - .defaultAttributes(LushCreeperEntity::createCreeperAttributes) - .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, LushCreeperEntity::canSpawn) - ) - .dimensions(0.6f, 1.7f) - .maxTrackingRange(8)); - public static final EntityType SUNKEN = register("sunken", FabricEntityType.Builder.createMob(SunkenEntity::new, SpawnGroup.MONSTER, mob -> mob - .defaultAttributes(SunkenEntity::createSunkenAttributes) - .spawnRestriction(SpawnLocationTypes.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SunkenEntity::canSpawn) - ) - .dimensions(0.6F, 1.99F) - .eyeHeight(1.74F) - .maxTrackingRange(8)); + public static final EntityType CAPYBARA = register("capybara", FabricEntityType.Builder.createMob(CapybaraEntity::new, SpawnGroup.CREATURE, mob -> mob + .defaultAttributes(CapybaraEntity::createCapybaraAttributes) + .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn) + ) + .dimensions(0.7f, 0.875f) + .eyeHeight(0.875f)); + public static final EntityType DUCK = register("duck", FabricEntityType.Builder.createMob(DuckEntity::new, SpawnGroup.CREATURE, mob -> mob + .defaultAttributes(DuckEntity::createDuckAttributes) + .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn) + ) + .dimensions(0.4F, 0.8F) + .eyeHeight(1.09375f) + .maxTrackingRange(10) + .trackingTickInterval(3)); + public static final EntityType LUSH_CREEPER = register("lush_creeper", FabricEntityType.Builder.createMob(LushCreeperEntity::new, SpawnGroup.MONSTER, mob -> mob + .defaultAttributes(LushCreeperEntity::createCreeperAttributes) + .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, LushCreeperEntity::canSpawn) + ) + .dimensions(0.6f, 1.7f) + .maxTrackingRange(8)); + public static final EntityType SUNKEN = register("sunken", FabricEntityType.Builder.createMob(SunkenEntity::new, SpawnGroup.MONSTER, mob -> mob + .defaultAttributes(SunkenEntity::createSunkenAttributes) + .spawnRestriction(SpawnLocationTypes.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SunkenEntity::canSpawn) + ) + .dimensions(0.6F, 1.99F) + .eyeHeight(1.74F) + .maxTrackingRange(8)); - private static EntityType register(String path, EntityType.Builder type) { - var key = RegistryKey.of(RegistryKeys.ENTITY_TYPE, Promenade.id(path)); - return Registry.register(Registries.ENTITY_TYPE, key, type.build(key)); - } + private static EntityType register(String path, EntityType.Builder type) { + var key = RegistryKey.of(RegistryKeys.ENTITY_TYPE, Promenade.id(path)); + return Registry.register(Registries.ENTITY_TYPE, key, type.build(key)); + } - public static void appendWorldGen() { - var duckWeight = PromenadeConfig.get().animals().ducksWeight(); - if (duckWeight != 0) { - Predicate hasFarmAnimals = BiomeSelectors.spawnsOneOf(EntityType.COW) - .and(BiomeSelectors.spawnsOneOf(EntityType.SHEEP)) - .and(BiomeSelectors.spawnsOneOf(EntityType.CHICKEN)) - .and(BiomeSelectors.spawnsOneOf(EntityType.PIG)); - BiomeModifications.addSpawn(hasFarmAnimals, SpawnGroup.CREATURE, PromenadeEntityTypes.DUCK, duckWeight, 4, 4); - } + public static void appendWorldGen() { + var duckWeight = PromenadeConfig.get().animals().ducksWeight(); + if (duckWeight != 0) { + Predicate hasFarmAnimals = BiomeSelectors.spawnsOneOf(EntityType.COW) + .and(BiomeSelectors.spawnsOneOf(EntityType.SHEEP)) + .and(BiomeSelectors.spawnsOneOf(EntityType.CHICKEN)) + .and(BiomeSelectors.spawnsOneOf(EntityType.PIG)); + BiomeModifications.addSpawn(hasFarmAnimals, SpawnGroup.CREATURE, PromenadeEntityTypes.DUCK, duckWeight, 4, 4); + } - var capybaraWeight = PromenadeConfig.get().animals().capybarasWeight(); - if (capybaraWeight != 0) { - BiomeModifications.addSpawn(BiomeSelectors.tag(PromenadeBiomeTags.SPAWNS_CAPYBARAS), SpawnGroup.CREATURE, PromenadeEntityTypes.CAPYBARA, capybaraWeight, 3, 5); - } + var capybaraWeight = PromenadeConfig.get().animals().capybarasWeight(); + if (capybaraWeight != 0) { + BiomeModifications.addSpawn(BiomeSelectors.tag(PromenadeBiomeTags.SPAWNS_CAPYBARAS), SpawnGroup.CREATURE, PromenadeEntityTypes.CAPYBARA, capybaraWeight, 3, 5); + } - var lushCreeperWeight = PromenadeConfig.get().monsters().lushCreepersWeight(); - if (lushCreeperWeight != 0) { - BiomeModifications.addSpawn(BiomeSelectors.spawnsOneOf(EntityType.CREEPER).and(BiomeSelectors.excludeByKey(BiomeKeys.LUSH_CAVES)), SpawnGroup.MONSTER, LUSH_CREEPER, lushCreeperWeight, 2, 3); - BiomeModifications.addSpawn(BiomeSelectors.includeByKey(BiomeKeys.LUSH_CAVES), SpawnGroup.MONSTER, LUSH_CREEPER, lushCreeperWeight * 4, 2, 4); - } + var lushCreeperWeight = PromenadeConfig.get().monsters().lushCreepersWeight(); + if (lushCreeperWeight != 0) { + BiomeModifications.addSpawn(BiomeSelectors.spawnsOneOf(EntityType.CREEPER).and(BiomeSelectors.excludeByKey(BiomeKeys.LUSH_CAVES)), SpawnGroup.MONSTER, LUSH_CREEPER, lushCreeperWeight, 2, 3); + BiomeModifications.addSpawn(BiomeSelectors.includeByKey(BiomeKeys.LUSH_CAVES), SpawnGroup.MONSTER, LUSH_CREEPER, lushCreeperWeight * 4, 2, 4); + } - var sunkensWeight = PromenadeConfig.get().monsters().sunkensWeight(); - if (sunkensWeight != 0) { - BiomeModifications.addSpawn(biomeSelectionContext -> biomeSelectionContext.hasTag(PromenadeBiomeTags.SPAWNS_SUNKEN), SpawnGroup.MONSTER, SUNKEN, sunkensWeight, 1, 3); - } - } + var sunkensWeight = PromenadeConfig.get().monsters().sunkensWeight(); + if (sunkensWeight != 0) { + BiomeModifications.addSpawn(biomeSelectionContext -> biomeSelectionContext.hasTag(PromenadeBiomeTags.SPAWNS_SUNKEN), SpawnGroup.MONSTER, SUNKEN, sunkensWeight, 1, 3); + } + } } diff --git a/src/main/java/fr/hugman/promenade/entity/SunkenEntity.java b/src/main/java/fr/hugman/promenade/entity/SunkenEntity.java index 26f5ee92..7fe007ee 100644 --- a/src/main/java/fr/hugman/promenade/entity/SunkenEntity.java +++ b/src/main/java/fr/hugman/promenade/entity/SunkenEntity.java @@ -1,11 +1,20 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity; -import fr.hugman.promenade.component.PromenadeComponentTypes; -import fr.hugman.promenade.entity.data.PromenadeTrackedData; -import fr.hugman.promenade.entity.variant.SunkenVariant; -import fr.hugman.promenade.entity.variant.SunkenVariants; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import fr.hugman.promenade.sound.PromenadeSoundEvents; +import java.util.Optional; + +import javax.annotation.Nullable; + import net.minecraft.component.ComponentType; import net.minecraft.component.ComponentsAccess; import net.minecraft.entity.*; @@ -45,471 +54,480 @@ import net.minecraft.util.math.random.Random; import net.minecraft.world.*; -import javax.annotation.Nullable; -import java.util.Optional; +import fr.hugman.promenade.component.PromenadeComponentTypes; +import fr.hugman.promenade.entity.data.PromenadeTrackedData; +import fr.hugman.promenade.entity.variant.SunkenVariant; +import fr.hugman.promenade.entity.variant.SunkenVariants; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import fr.hugman.promenade.sound.PromenadeSoundEvents; public class SunkenEntity extends AbstractSkeletonEntity implements CrossbowUser { - private static final TrackedData> VARIANT = DataTracker.registerData(SunkenEntity.class, PromenadeTrackedData.SUNKEN_VARIANT); - private static final TrackedData CHARGING = DataTracker.registerData(SunkenEntity.class, TrackedDataHandlerRegistry.BOOLEAN); - private static final TrackedData SWIMMING = DataTracker.registerData(SunkenEntity.class, TrackedDataHandlerRegistry.BOOLEAN); - - private final static EntityDimensions SWIMMING_DIMENSIONS = EntityDimensions.fixed(0.6F, 0.6F); - - protected final SwimNavigation waterNavigation; - protected final MobNavigation landNavigation; - private final CrossbowAttackGoal crossbowAttackGoal = new CrossbowAttackGoal<>(this, 1.0D, 20.0F); - private final BowAttackGoal bowAttackGoal = new BowAttackGoal<>(this, 1.0D, 20, 15.0F); - private final MeleeAttackGoal meleeAttackGoal = new MeleeAttackGoal(this, 1.2D, false) { - public void stop() { - super.stop(); - SunkenEntity.this.setAttacking(false); - } - - public void start() { - super.start(); - SunkenEntity.this.setAttacking(true); - } - }; - boolean targetingUnderwater; - - public SunkenEntity(EntityType entityType, World world) { - super(entityType, world); - this.updateAttackType(); - this.moveControl = new SunkenMoveControl(this); - this.setPathfindingPenalty(PathNodeType.WATER, 0.0F); - this.waterNavigation = new SwimNavigation(this, world); - this.landNavigation = new MobNavigation(this, world); - } - - @Nullable - @Override - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData) { - SunkenVariants.select(this.random, this.getRegistryManager(), SpawnContext.of(world, this.getBlockPos())).ifPresent(this::setVariant); - this.lootTable = Optional.ofNullable(this.getVariant().value().lootTable()); - return super.initialize(world, difficulty, spawnReason, entityData); - } - - public static boolean canSpawn(EntityType ignoredType, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { - boolean bl = world.getDifficulty() != Difficulty.PEACEFUL - && isSpawnDark(world, pos, random) - && (spawnReason == SpawnReason.SPAWNER || world.getFluidState(pos).isIn(FluidTags.WATER)); - return pos.getY() < world.getSeaLevel() - 10 && bl; - } - - @Override - public boolean canSpawn(WorldView world) { - return world.doesNotIntersectEntities(this); - } - - @Override - public EntityDimensions getBaseDimensions(EntityPose pose) { - if (this.isBreaststrokeSwimming()) return SWIMMING_DIMENSIONS; - else return super.getBaseDimensions(pose); - } - - /*========*/ - /* AI */ - /*========*/ - - public static DefaultAttributeContainer.Builder createSunkenAttributes() { - return createAbstractSkeletonAttributes(); - } - - @Override - protected void initGoals() { - this.goalSelector.add(1, new MoveIntoWaterGoal(this)); - this.goalSelector.add(1, new AvoidSunlightGoal(this)); - this.goalSelector.add(2, new CrossbowAttackGoal(this, 1.0D, 4.5F)); - this.goalSelector.add(3, new FleeEntityGoal(this, PufferfishEntity.class, 8.0F, 1.0D, 1.2D)); - this.goalSelector.add(3, new EscapeSunlightGoal(this, 1.0D)); - this.goalSelector.add(6, new SwimAroundGoal(this, 1.0D, 40)); - this.goalSelector.add(7, new WanderAroundFarGoal(this, 1.0D)); - this.goalSelector.add(7, new SunkenEntity.TargetAboveWaterGoal(this, 1.0D, this.getEntityWorld().getSeaLevel())); - this.goalSelector.add(7, new SunkenEntity.LeaveWaterGoal(this, 1.0D)); - this.goalSelector.add(8, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F)); - this.goalSelector.add(8, new LookAroundGoal(this)); - - this.targetSelector.add(1, new RevengeGoal(this)); - this.targetSelector.add(2, new ActiveTargetGoal(this, PlayerEntity.class, true)); - this.targetSelector.add(2, new ActiveTargetGoal(this, DolphinEntity.class, true)); - } - - @Override - public void shootAt(LivingEntity target, float pullProgress) { - if (this.isHolding(stack -> stack.getItem() instanceof CrossbowItem)) { - this.shoot(this, 1.6F); - } else { - ItemStack itemStack = this.getStackInHand(ProjectileUtil.getHandPossiblyHolding(this, Items.BOW)); - PersistentProjectileEntity persistentProjectileEntity = this.createArrowProjectile(this.getProjectileType(itemStack), pullProgress, itemStack); - double d = target.getX() - this.getX(); - double e = target.getBodyY(0.3333333333333333D) - persistentProjectileEntity.getY(); - double f = target.getZ() - this.getZ(); - double g = Math.sqrt(d * d + f * f); - persistentProjectileEntity.setVelocity(d, e + g * 0.20000000298023224D, f, 1.6F, (float) (14 - this.getEntityWorld().getDifficulty().getId() * 4)); - this.playSound(this.getShootSound(), 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); - this.getEntityWorld().spawnEntity(persistentProjectileEntity); - } - } - - @Override - public void shoot(LivingEntity entity, float speed) { - CrossbowUser.super.shoot(entity, speed); - } - - @Override - protected PersistentProjectileEntity createArrowProjectile(ItemStack arrow, float damageModifier, @Nullable ItemStack shotFrom) { - PersistentProjectileEntity persistentProjectileEntity = super.createArrowProjectile(arrow, damageModifier, shotFrom); - if (persistentProjectileEntity instanceof ArrowEntity) { - ((ArrowEntity) persistentProjectileEntity).addEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 600)); - } - - return persistentProjectileEntity; - } - - @Override - protected void initEquipment(Random random, LocalDifficulty difficulty) { - super.initEquipment(random, difficulty); - this.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.CROSSBOW)); - } - - @Override - public boolean canUseRangedWeapon(RangedWeaponItem weapon) { - return weapon instanceof BowItem || weapon instanceof CrossbowItem; - } - - @Override - public void travel(Vec3d movementInput) { - if (this.canMoveVoluntarily() && this.isTouchingWater()) { - float speed = 0.075F; - this.updateVelocity(speed, movementInput); - this.move(MovementType.SELF, this.getVelocity()); - this.setVelocity(this.getVelocity().multiply(0.9D)); - } else { - super.travel(movementInput); - } - } - - @Override - public boolean isPushedByFluids() { - return !this.isSwimming(); - } - - @Override - public void updateSwimming() { - if (!this.getEntityWorld().isClient()) { - boolean b = this.getEntityWorld().isAir(this.getBlockPos().up(2)); - if (!b && this.canMoveVoluntarily() && this.isSubmergedInWater()) { - this.navigation = this.waterNavigation; - this.setSwimming(true); - this.setBreaststrokeSwimming(true); - } else { - this.navigation = this.landNavigation; - this.setSwimming(false); - this.setBreaststrokeSwimming(false); - } - } - } - - @Override - public void updateAttackType() { - if (this.getEntityWorld() != null && !this.getEntityWorld().isClient()) { - if (this.bowAttackGoal != null && this.crossbowAttackGoal != null && this.meleeAttackGoal != null) { - this.goalSelector.remove(this.bowAttackGoal); - this.goalSelector.remove(this.crossbowAttackGoal); - this.goalSelector.remove(this.meleeAttackGoal); - ItemStack itemStack = this.getStackInHand(ProjectileUtil.getHandPossiblyHolding(this, Items.CROSSBOW)); - if (itemStack.isOf(Items.CROSSBOW)) { - this.goalSelector.add(4, this.crossbowAttackGoal); - } else if (itemStack.isOf(Items.BOW)) { - this.bowAttackGoal.setAttackInterval(this.getEntityWorld().getDifficulty() != Difficulty.HARD ? 40 : 20); - this.goalSelector.add(4, this.bowAttackGoal); - } else { - this.goalSelector.add(4, this.meleeAttackGoal); - } - } - } - } - - public boolean isCharging() { - return this.dataTracker.get(CHARGING); - } - - @Override - public void setCharging(boolean charging) { - this.dataTracker.set(CHARGING, charging); - } - - public boolean isBreaststrokeSwimming() { - if (this.getVelocity().length() < 0.1F) return false; - else return this.dataTracker.get(SWIMMING); - } - - public void setBreaststrokeSwimming(boolean breaststrokeSwimming) { - this.dataTracker.set(SWIMMING, breaststrokeSwimming); - } - - @Override - public boolean isInSwimmingPose() { - return isBreaststrokeSwimming(); - } - - @Override - public void postShoot() { - this.despawnCounter = 0; - } - - protected boolean hasFinishedCurrentPath() { - Path path = this.getNavigation().getCurrentPath(); - if (path != null) { - BlockPos blockPos = path.getTarget(); - if (blockPos != null) { - double d = this.squaredDistanceTo(blockPos.getX(), blockPos.getY(), blockPos.getZ()); - return d < 4.0D; - } - } - - return false; - } - - boolean isTargetingUnderwater() { - if (this.targetingUnderwater) { - return true; - } else { - LivingEntity livingEntity = this.getTarget(); - return livingEntity != null && livingEntity.isTouchingWater(); - } - } - - public void setTargetingUnderwater(boolean targetingUnderwater) { - this.targetingUnderwater = targetingUnderwater; - } - - /*============*/ - /* SOUNDS */ - /*============*/ - - @Override - protected SoundEvent getAmbientSound() { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_AMBIENT : SoundEvents.ENTITY_SKELETON_AMBIENT; - } - - @Override - protected SoundEvent getHurtSound(DamageSource source) { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_HURT : SoundEvents.ENTITY_SKELETON_HURT; - } - - @Override - protected SoundEvent getDeathSound() { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_DEATH : SoundEvents.ENTITY_SKELETON_DEATH; - } - - @Override - protected SoundEvent getStepSound() { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_STEP : SoundEvents.ENTITY_SKELETON_STEP; - } - - protected SoundEvent getShootSound() { - return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_SHOOT : (this.isHolding(stack -> stack.getItem() instanceof CrossbowItem) ? SoundEvents.ITEM_CROSSBOW_SHOOT : SoundEvents.ENTITY_SKELETON_SHOOT); - } - - /*==============*/ - /* VARIANTS */ - /*==============*/ - - public RegistryEntry getVariant() { - return this.dataTracker.get(VARIANT); - } - - public void setVariant(RegistryEntry variant) { - this.dataTracker.set(VARIANT, variant); - } - - /*============*/ - /* STATES */ - /*============*/ - - public State getState() { - if (this.isHolding(Items.CROSSBOW) && this.isCharging()) { - return State.CROSSBOW_CHARGE; - } else if (this.isHolding(CrossbowItem::isCharged)) { - return State.CROSSBOW_HOLD; - } else if (this.isBreaststrokeSwimming()) { - return State.SWIMMING; - } else if (this.isHolding(Items.BOW)) { - return State.BOW_HOLD; - } - return State.NEUTRAL; - } - - public enum State { - CROSSBOW_HOLD, - CROSSBOW_CHARGE, - BOW_HOLD, - SWIMMING, - NEUTRAL - } - - /*==========*/ - /* DATA */ - /*==========*/ - - @Override - protected void initDataTracker(DataTracker.Builder builder) { - super.initDataTracker(builder); - builder.add(VARIANT, this.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT).getOrThrow(SunkenVariants.DEFAULT)); - builder.add(CHARGING, false); - builder.add(SWIMMING, false); - } - - @Override - protected void writeCustomData(WriteView view) { - super.writeCustomData(view); - Variants.writeVariantToNbt(view, this.getVariant()); - - } - - @Override - protected void readCustomData(ReadView view) { - super.readCustomData(view); - Variants.readVariantFromNbt(view, PromenadeRegistryKeys.SUNKEN_VARIANT).ifPresent(this::setVariant); - } - - @org.jetbrains.annotations.Nullable - @Override - public T get(ComponentType type) { - return type == PromenadeComponentTypes.SUNKEN_VARIANT ? castComponentValue((ComponentType) type, this.getVariant()) : super.get(type); - } - - @Override - protected void copyComponentsFrom(ComponentsAccess from) { - this.copyComponentFrom(from, PromenadeComponentTypes.SUNKEN_VARIANT); - super.copyComponentsFrom(from); - } - - @Override - protected boolean setApplicableComponent(ComponentType type, T value) { - if (type == PromenadeComponentTypes.SUNKEN_VARIANT) { - this.setVariant(castComponentValue(PromenadeComponentTypes.SUNKEN_VARIANT, value)); - return true; - } else { - return super.setApplicableComponent(type, value); - } - } - - static class SunkenMoveControl extends MoveControl { - private final SunkenEntity sunken; - - public SunkenMoveControl(SunkenEntity sunken) { - super(sunken); - this.sunken = sunken; - } - - public void tick() { - LivingEntity target = this.sunken.getTarget(); - if (this.sunken.isTargetingUnderwater() || this.sunken.isSubmergedInWater()) { - if (target != null) { - if (target.getY() > this.sunken.getY()) - this.sunken.setVelocity(this.sunken.getVelocity().add(0.0D, 0.002D, 0.0D)); - else this.sunken.setVelocity(this.sunken.getVelocity().add(0.0D, -0.002D, 0.0D)); - } - - if (this.state == State.WAIT || this.sunken.getNavigation().isIdle()) { - this.sunken.setMovementSpeed(0.0F); - } - - double d = this.targetX - this.sunken.getX(); - double e = this.targetY - this.sunken.getY(); - double f = this.targetZ - this.sunken.getZ(); - double g = Math.sqrt(d * d + e * e + f * f); - e /= g; - float h = (float) (MathHelper.atan2(f, d) * 57.2957763671875D) - 90.0F; - this.sunken.setYaw(this.wrapDegrees(this.sunken.getYaw(), h, 90.0F)); - this.sunken.bodyYaw = this.sunken.getYaw(); - float i = (float) (this.speed * this.sunken.getAttributeValue(EntityAttributes.MOVEMENT_SPEED)); - float j = MathHelper.lerp(0.125F, this.sunken.getMovementSpeed(), i); - this.sunken.setMovementSpeed(j); - this.sunken.setVelocity(this.sunken.getVelocity().add((double) j * d * 0.005D, (double) j * e * 0.1D, (double) j * f * 0.005D)); - } else { - if (!this.sunken.isOnGround()) { - this.sunken.setVelocity(this.sunken.getVelocity().add(0.0D, -0.008D, 0.0D)); - } - super.tick(); - } - } - } - - static class LeaveWaterGoal extends MoveToTargetPosGoal { - private final SunkenEntity sunken; - - public LeaveWaterGoal(SunkenEntity sunken, double speed) { - super(sunken, speed, 8, 2); - this.sunken = sunken; - } - - public boolean canStart() { - return super.canStart() && !this.sunken.getEntityWorld().isDay() && this.sunken.isTouchingWater() && this.sunken.getY() >= (double) (this.sunken.getEntityWorld().getSeaLevel() - 3); - } - - public boolean shouldContinue() { - return super.shouldContinue(); - } - - protected boolean isTargetPos(WorldView world, BlockPos pos) { - BlockPos blockPos = pos.up(); - return world.isAir(blockPos) && world.isAir(blockPos.up()) && world.getBlockState(pos).hasSolidTopSurface(world, pos, this.sunken); - } - - public void start() { - this.sunken.setTargetingUnderwater(false); - this.sunken.navigation = this.sunken.landNavigation; - super.start(); - } - - public void stop() { - super.stop(); - } - } - - private static class TargetAboveWaterGoal extends Goal { - private final SunkenEntity sunken; - private final double speed; - private final int minY; - private boolean foundTarget; - - public TargetAboveWaterGoal(SunkenEntity sunken, double speed, int minY) { - this.sunken = sunken; - this.speed = speed; - this.minY = minY; - } - - public boolean canStart() { - return !this.sunken.getEntityWorld().isDay() && this.sunken.isTouchingWater() && !this.sunken.isTargetingUnderwater() && this.sunken.getY() < (double) (this.minY - 2); - } - - public boolean shouldContinue() { - return this.canStart() && !this.foundTarget; - } - - public void tick() { - if (this.sunken.getY() < (double) (this.minY - 1) && (this.sunken.getNavigation().isIdle() || this.sunken.hasFinishedCurrentPath())) { - Vec3d vec3d = NoPenaltyTargeting.findTo(this.sunken, 4, 8, new Vec3d(this.sunken.getX(), this.minY - 1, this.sunken.getZ()), 1.6D); - if (vec3d == null) { - this.foundTarget = true; - return; - } - - this.sunken.getNavigation().startMovingTo(vec3d.x, vec3d.y, vec3d.z, this.speed); - } - - } - - public void start() { - this.sunken.setTargetingUnderwater(true); - this.foundTarget = false; - } - - public void stop() { - this.sunken.setTargetingUnderwater(false); - } - } + private static final TrackedData> VARIANT = DataTracker.registerData(SunkenEntity.class, PromenadeTrackedData.SUNKEN_VARIANT); + private static final TrackedData CHARGING = DataTracker.registerData(SunkenEntity.class, TrackedDataHandlerRegistry.BOOLEAN); + private static final TrackedData SWIMMING = DataTracker.registerData(SunkenEntity.class, TrackedDataHandlerRegistry.BOOLEAN); + + private final static EntityDimensions SWIMMING_DIMENSIONS = EntityDimensions.fixed(0.6F, 0.6F); + + protected final SwimNavigation waterNavigation; + protected final MobNavigation landNavigation; + private final CrossbowAttackGoal crossbowAttackGoal = new CrossbowAttackGoal<>(this, 1.0D, 20.0F); + private final BowAttackGoal bowAttackGoal = new BowAttackGoal<>(this, 1.0D, 20, 15.0F); + private final MeleeAttackGoal meleeAttackGoal = new MeleeAttackGoal(this, 1.2D, false) { + public void stop() { + super.stop(); + SunkenEntity.this.setAttacking(false); + } + + public void start() { + super.start(); + SunkenEntity.this.setAttacking(true); + } + }; + boolean targetingUnderwater; + + public SunkenEntity(EntityType entityType, World world) { + super(entityType, world); + this.updateAttackType(); + this.moveControl = new SunkenMoveControl(this); + this.setPathfindingPenalty(PathNodeType.WATER, 0.0F); + this.waterNavigation = new SwimNavigation(this, world); + this.landNavigation = new MobNavigation(this, world); + } + + @Nullable + @Override + public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData) { + SunkenVariants.select(this.random, this.getRegistryManager(), SpawnContext.of(world, this.getBlockPos())).ifPresent(this::setVariant); + this.lootTable = Optional.ofNullable(this.getVariant().value().lootTable()); + return super.initialize(world, difficulty, spawnReason, entityData); + } + + public static boolean canSpawn(EntityType ignoredType, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { + boolean bl = world.getDifficulty() != Difficulty.PEACEFUL + && isSpawnDark(world, pos, random) + && (spawnReason == SpawnReason.SPAWNER || world.getFluidState(pos).isIn(FluidTags.WATER)); + return pos.getY() < world.getSeaLevel() - 10 && bl; + } + + @Override + public boolean canSpawn(WorldView world) { + return world.doesNotIntersectEntities(this); + } + + @Override + public EntityDimensions getBaseDimensions(EntityPose pose) { + if (this.isBreaststrokeSwimming()) + return SWIMMING_DIMENSIONS; + else + return super.getBaseDimensions(pose); + } + + /*========*/ + /* AI */ + /*========*/ + + public static DefaultAttributeContainer.Builder createSunkenAttributes() { + return createAbstractSkeletonAttributes(); + } + + @Override + protected void initGoals() { + this.goalSelector.add(1, new MoveIntoWaterGoal(this)); + this.goalSelector.add(1, new AvoidSunlightGoal(this)); + this.goalSelector.add(2, new CrossbowAttackGoal(this, 1.0D, 4.5F)); + this.goalSelector.add(3, new FleeEntityGoal(this, PufferfishEntity.class, 8.0F, 1.0D, 1.2D)); + this.goalSelector.add(3, new EscapeSunlightGoal(this, 1.0D)); + this.goalSelector.add(6, new SwimAroundGoal(this, 1.0D, 40)); + this.goalSelector.add(7, new WanderAroundFarGoal(this, 1.0D)); + this.goalSelector.add(7, new SunkenEntity.TargetAboveWaterGoal(this, 1.0D, this.getEntityWorld().getSeaLevel())); + this.goalSelector.add(7, new SunkenEntity.LeaveWaterGoal(this, 1.0D)); + this.goalSelector.add(8, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F)); + this.goalSelector.add(8, new LookAroundGoal(this)); + + this.targetSelector.add(1, new RevengeGoal(this)); + this.targetSelector.add(2, new ActiveTargetGoal(this, PlayerEntity.class, true)); + this.targetSelector.add(2, new ActiveTargetGoal(this, DolphinEntity.class, true)); + } + + @Override + public void shootAt(LivingEntity target, float pullProgress) { + if (this.isHolding(stack -> stack.getItem() instanceof CrossbowItem)) { + this.shoot(this, 1.6F); + } else { + ItemStack itemStack = this.getStackInHand(ProjectileUtil.getHandPossiblyHolding(this, Items.BOW)); + PersistentProjectileEntity persistentProjectileEntity = this.createArrowProjectile(this.getProjectileType(itemStack), pullProgress, itemStack); + double d = target.getX() - this.getX(); + double e = target.getBodyY(0.3333333333333333D) - persistentProjectileEntity.getY(); + double f = target.getZ() - this.getZ(); + double g = Math.sqrt(d * d + f * f); + persistentProjectileEntity.setVelocity(d, e + g * 0.20000000298023224D, f, 1.6F, (float) (14 - this.getEntityWorld().getDifficulty().getId() * 4)); + this.playSound(this.getShootSound(), 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); + this.getEntityWorld().spawnEntity(persistentProjectileEntity); + } + } + + @Override + public void shoot(LivingEntity entity, float speed) { + CrossbowUser.super.shoot(entity, speed); + } + + @Override + protected PersistentProjectileEntity createArrowProjectile(ItemStack arrow, float damageModifier, @Nullable ItemStack shotFrom) { + PersistentProjectileEntity persistentProjectileEntity = super.createArrowProjectile(arrow, damageModifier, shotFrom); + if (persistentProjectileEntity instanceof ArrowEntity) { + ((ArrowEntity) persistentProjectileEntity).addEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 600)); + } + + return persistentProjectileEntity; + } + + @Override + protected void initEquipment(Random random, LocalDifficulty difficulty) { + super.initEquipment(random, difficulty); + this.equipStack(EquipmentSlot.MAINHAND, new ItemStack(Items.CROSSBOW)); + } + + @Override + public boolean canUseRangedWeapon(RangedWeaponItem weapon) { + return weapon instanceof BowItem || weapon instanceof CrossbowItem; + } + + @Override + public void travel(Vec3d movementInput) { + if (this.canMoveVoluntarily() && this.isTouchingWater()) { + float speed = 0.075F; + this.updateVelocity(speed, movementInput); + this.move(MovementType.SELF, this.getVelocity()); + this.setVelocity(this.getVelocity().multiply(0.9D)); + } else { + super.travel(movementInput); + } + } + + @Override + public boolean isPushedByFluids() { + return !this.isSwimming(); + } + + @Override + public void updateSwimming() { + if (!this.getEntityWorld().isClient()) { + boolean b = this.getEntityWorld().isAir(this.getBlockPos().up(2)); + if (!b && this.canMoveVoluntarily() && this.isSubmergedInWater()) { + this.navigation = this.waterNavigation; + this.setSwimming(true); + this.setBreaststrokeSwimming(true); + } else { + this.navigation = this.landNavigation; + this.setSwimming(false); + this.setBreaststrokeSwimming(false); + } + } + } + + @Override + public void updateAttackType() { + if (this.getEntityWorld() != null && !this.getEntityWorld().isClient()) { + if (this.bowAttackGoal != null && this.crossbowAttackGoal != null && this.meleeAttackGoal != null) { + this.goalSelector.remove(this.bowAttackGoal); + this.goalSelector.remove(this.crossbowAttackGoal); + this.goalSelector.remove(this.meleeAttackGoal); + ItemStack itemStack = this.getStackInHand(ProjectileUtil.getHandPossiblyHolding(this, Items.CROSSBOW)); + if (itemStack.isOf(Items.CROSSBOW)) { + this.goalSelector.add(4, this.crossbowAttackGoal); + } else if (itemStack.isOf(Items.BOW)) { + this.bowAttackGoal.setAttackInterval(this.getEntityWorld().getDifficulty() != Difficulty.HARD ? 40 : 20); + this.goalSelector.add(4, this.bowAttackGoal); + } else { + this.goalSelector.add(4, this.meleeAttackGoal); + } + } + } + } + + public boolean isCharging() { + return this.dataTracker.get(CHARGING); + } + + @Override + public void setCharging(boolean charging) { + this.dataTracker.set(CHARGING, charging); + } + + public boolean isBreaststrokeSwimming() { + if (this.getVelocity().length() < 0.1F) + return false; + else + return this.dataTracker.get(SWIMMING); + } + + public void setBreaststrokeSwimming(boolean breaststrokeSwimming) { + this.dataTracker.set(SWIMMING, breaststrokeSwimming); + } + + @Override + public boolean isInSwimmingPose() { + return isBreaststrokeSwimming(); + } + + @Override + public void postShoot() { + this.despawnCounter = 0; + } + + protected boolean hasFinishedCurrentPath() { + Path path = this.getNavigation().getCurrentPath(); + if (path != null) { + BlockPos blockPos = path.getTarget(); + if (blockPos != null) { + double d = this.squaredDistanceTo(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + return d < 4.0D; + } + } + + return false; + } + + boolean isTargetingUnderwater() { + if (this.targetingUnderwater) { + return true; + } else { + LivingEntity livingEntity = this.getTarget(); + return livingEntity != null && livingEntity.isTouchingWater(); + } + } + + public void setTargetingUnderwater(boolean targetingUnderwater) { + this.targetingUnderwater = targetingUnderwater; + } + + /*============*/ + /* SOUNDS */ + /*============*/ + + @Override + protected SoundEvent getAmbientSound() { + return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_AMBIENT : SoundEvents.ENTITY_SKELETON_AMBIENT; + } + + @Override + protected SoundEvent getHurtSound(DamageSource source) { + return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_HURT : SoundEvents.ENTITY_SKELETON_HURT; + } + + @Override + protected SoundEvent getDeathSound() { + return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_DEATH : SoundEvents.ENTITY_SKELETON_DEATH; + } + + @Override + protected SoundEvent getStepSound() { + return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_STEP : SoundEvents.ENTITY_SKELETON_STEP; + } + + protected SoundEvent getShootSound() { + return this.isSubmergedIn(FluidTags.WATER) ? PromenadeSoundEvents.SUNKEN_SHOOT : (this.isHolding(stack -> stack.getItem() instanceof CrossbowItem) ? SoundEvents.ITEM_CROSSBOW_SHOOT : SoundEvents.ENTITY_SKELETON_SHOOT); + } + + /*==============*/ + /* VARIANTS */ + /*==============*/ + + public RegistryEntry getVariant() { + return this.dataTracker.get(VARIANT); + } + + public void setVariant(RegistryEntry variant) { + this.dataTracker.set(VARIANT, variant); + } + + /*============*/ + /* STATES */ + /*============*/ + + public State getState() { + if (this.isHolding(Items.CROSSBOW) && this.isCharging()) { + return State.CROSSBOW_CHARGE; + } else if (this.isHolding(CrossbowItem::isCharged)) { + return State.CROSSBOW_HOLD; + } else if (this.isBreaststrokeSwimming()) { + return State.SWIMMING; + } else if (this.isHolding(Items.BOW)) { + return State.BOW_HOLD; + } + return State.NEUTRAL; + } + + public enum State { + CROSSBOW_HOLD, + CROSSBOW_CHARGE, + BOW_HOLD, + SWIMMING, + NEUTRAL + } + + /*==========*/ + /* DATA */ + /*==========*/ + + @Override + protected void initDataTracker(DataTracker.Builder builder) { + super.initDataTracker(builder); + builder.add(VARIANT, this.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT).getOrThrow(SunkenVariants.DEFAULT)); + builder.add(CHARGING, false); + builder.add(SWIMMING, false); + } + + @Override + protected void writeCustomData(WriteView view) { + super.writeCustomData(view); + Variants.writeVariantToNbt(view, this.getVariant()); + + } + + @Override + protected void readCustomData(ReadView view) { + super.readCustomData(view); + Variants.readVariantFromNbt(view, PromenadeRegistryKeys.SUNKEN_VARIANT).ifPresent(this::setVariant); + } + + @org.jetbrains.annotations.Nullable + @Override + public T get(ComponentType type) { + return type == PromenadeComponentTypes.SUNKEN_VARIANT ? castComponentValue((ComponentType) type, this.getVariant()) : super.get(type); + } + + @Override + protected void copyComponentsFrom(ComponentsAccess from) { + this.copyComponentFrom(from, PromenadeComponentTypes.SUNKEN_VARIANT); + super.copyComponentsFrom(from); + } + + @Override + protected boolean setApplicableComponent(ComponentType type, T value) { + if (type == PromenadeComponentTypes.SUNKEN_VARIANT) { + this.setVariant(castComponentValue(PromenadeComponentTypes.SUNKEN_VARIANT, value)); + return true; + } else { + return super.setApplicableComponent(type, value); + } + } + + static class SunkenMoveControl extends MoveControl { + private final SunkenEntity sunken; + + public SunkenMoveControl(SunkenEntity sunken) { + super(sunken); + this.sunken = sunken; + } + + public void tick() { + LivingEntity target = this.sunken.getTarget(); + if (this.sunken.isTargetingUnderwater() || this.sunken.isSubmergedInWater()) { + if (target != null) { + if (target.getY() > this.sunken.getY()) + this.sunken.setVelocity(this.sunken.getVelocity().add(0.0D, 0.002D, 0.0D)); + else + this.sunken.setVelocity(this.sunken.getVelocity().add(0.0D, -0.002D, 0.0D)); + } + + if (this.state == State.WAIT || this.sunken.getNavigation().isIdle()) { + this.sunken.setMovementSpeed(0.0F); + } + + double d = this.targetX - this.sunken.getX(); + double e = this.targetY - this.sunken.getY(); + double f = this.targetZ - this.sunken.getZ(); + double g = Math.sqrt(d * d + e * e + f * f); + e /= g; + float h = (float) (MathHelper.atan2(f, d) * 57.2957763671875D) - 90.0F; + this.sunken.setYaw(this.wrapDegrees(this.sunken.getYaw(), h, 90.0F)); + this.sunken.bodyYaw = this.sunken.getYaw(); + float i = (float) (this.speed * this.sunken.getAttributeValue(EntityAttributes.MOVEMENT_SPEED)); + float j = MathHelper.lerp(0.125F, this.sunken.getMovementSpeed(), i); + this.sunken.setMovementSpeed(j); + this.sunken.setVelocity(this.sunken.getVelocity().add((double) j * d * 0.005D, (double) j * e * 0.1D, (double) j * f * 0.005D)); + } else { + if (!this.sunken.isOnGround()) { + this.sunken.setVelocity(this.sunken.getVelocity().add(0.0D, -0.008D, 0.0D)); + } + super.tick(); + } + } + } + + static class LeaveWaterGoal extends MoveToTargetPosGoal { + private final SunkenEntity sunken; + + public LeaveWaterGoal(SunkenEntity sunken, double speed) { + super(sunken, speed, 8, 2); + this.sunken = sunken; + } + + public boolean canStart() { + return super.canStart() && !this.sunken.getEntityWorld().isDay() && this.sunken.isTouchingWater() && this.sunken.getY() >= (double) (this.sunken.getEntityWorld().getSeaLevel() - 3); + } + + public boolean shouldContinue() { + return super.shouldContinue(); + } + + protected boolean isTargetPos(WorldView world, BlockPos pos) { + BlockPos blockPos = pos.up(); + return world.isAir(blockPos) && world.isAir(blockPos.up()) && world.getBlockState(pos).hasSolidTopSurface(world, pos, this.sunken); + } + + public void start() { + this.sunken.setTargetingUnderwater(false); + this.sunken.navigation = this.sunken.landNavigation; + super.start(); + } + + public void stop() { + super.stop(); + } + } + + private static class TargetAboveWaterGoal extends Goal { + private final SunkenEntity sunken; + private final double speed; + private final int minY; + private boolean foundTarget; + + public TargetAboveWaterGoal(SunkenEntity sunken, double speed, int minY) { + this.sunken = sunken; + this.speed = speed; + this.minY = minY; + } + + public boolean canStart() { + return !this.sunken.getEntityWorld().isDay() && this.sunken.isTouchingWater() && !this.sunken.isTargetingUnderwater() && this.sunken.getY() < (double) (this.minY - 2); + } + + public boolean shouldContinue() { + return this.canStart() && !this.foundTarget; + } + + public void tick() { + if (this.sunken.getY() < (double) (this.minY - 1) && (this.sunken.getNavigation().isIdle() || this.sunken.hasFinishedCurrentPath())) { + Vec3d vec3d = NoPenaltyTargeting.findTo(this.sunken, 4, 8, new Vec3d(this.sunken.getX(), this.minY - 1, this.sunken.getZ()), 1.6D); + if (vec3d == null) { + this.foundTarget = true; + return; + } + + this.sunken.getNavigation().startMovingTo(vec3d.x, vec3d.y, vec3d.z, this.speed); + } + + } + + public void start() { + this.sunken.setTargetingUnderwater(true); + this.foundTarget = false; + } + + public void stop() { + this.sunken.setTargetingUnderwater(false); + } + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeActivities.java b/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeActivities.java index 18825519..b03a9224 100644 --- a/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeActivities.java +++ b/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeActivities.java @@ -1,15 +1,27 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.ai.brain; -import fr.hugman.promenade.Promenade; import net.minecraft.entity.ai.brain.Activity; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import fr.hugman.promenade.Promenade; + public class PromenadeActivities { - public static final Activity FART = register("fart"); + public static final Activity FART = register("fart"); - private static Activity register(String id) { - var key = Promenade.id(id); - return Registry.register(Registries.ACTIVITY, key, new Activity(key.toString())); - } + private static Activity register(String id) { + var key = Promenade.id(id); + return Registry.register(Registries.ACTIVITY, key, new Activity(key.toString())); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeMemoryModuleTypes.java b/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeMemoryModuleTypes.java index 502778fc..a13bd288 100644 --- a/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeMemoryModuleTypes.java +++ b/src/main/java/fr/hugman/promenade/entity/ai/brain/PromenadeMemoryModuleTypes.java @@ -1,24 +1,37 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.ai.brain; +import java.util.Optional; + import com.mojang.serialization.Codec; -import fr.hugman.promenade.Promenade; + import net.minecraft.entity.ai.brain.MemoryModuleType; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Unit; -import java.util.Optional; +import fr.hugman.promenade.Promenade; public class PromenadeMemoryModuleTypes { - public static final MemoryModuleType FART_COOLDOWN = register("fart_cooldown", Unit.CODEC); + public static final MemoryModuleType FART_COOLDOWN = register("fart_cooldown", Unit.CODEC); - private static MemoryModuleType register(String id, Codec codec) { - return Registry.register(Registries.MEMORY_MODULE_TYPE, Promenade.id(id), new MemoryModuleType<>(Optional.of(codec))); - } + private static MemoryModuleType register(String id, Codec codec) { + return Registry.register(Registries.MEMORY_MODULE_TYPE, Promenade.id(id), new MemoryModuleType<>(Optional.of(codec))); + } - private static MemoryModuleType register(String id) { - return Registry.register(Registries.MEMORY_MODULE_TYPE, Promenade.id(id), new MemoryModuleType<>(Optional.empty())); - } + private static MemoryModuleType register(String id) { + return Registry.register(Registries.MEMORY_MODULE_TYPE, Promenade.id(id), new MemoryModuleType<>(Optional.empty())); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/ai/brain/sensor/PromenadeSensorTypes.java b/src/main/java/fr/hugman/promenade/entity/ai/brain/sensor/PromenadeSensorTypes.java index fbdb91e8..40d93983 100644 --- a/src/main/java/fr/hugman/promenade/entity/ai/brain/sensor/PromenadeSensorTypes.java +++ b/src/main/java/fr/hugman/promenade/entity/ai/brain/sensor/PromenadeSensorTypes.java @@ -1,20 +1,32 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.ai.brain.sensor; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.entity.CapybaraBrain; +import java.util.function.Supplier; + import net.minecraft.entity.ai.brain.sensor.Sensor; import net.minecraft.entity.ai.brain.sensor.SensorType; import net.minecraft.entity.ai.brain.sensor.TemptationsSensor; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; -import java.util.function.Supplier; +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.entity.CapybaraBrain; public class PromenadeSensorTypes { - public static final SensorType CAPYBARA_TEMPTATIONS = register("capybara_temptations", () -> new TemptationsSensor(CapybaraBrain.getTemptItemPredicate())); + public static final SensorType CAPYBARA_TEMPTATIONS = register("capybara_temptations", () -> new TemptationsSensor(CapybaraBrain.getTemptItemPredicate())); - private static > SensorType register(String path, Supplier factory) { - return Registry.register(Registries.SENSOR_TYPE, Promenade.id(path), new SensorType<>(factory)); - } + private static > SensorType register(String path, Supplier factory) { + return Registry.register(Registries.SENSOR_TYPE, Promenade.id(path), new SensorType<>(factory)); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/damage/PromenadeFallLocations.java b/src/main/java/fr/hugman/promenade/entity/damage/PromenadeFallLocations.java index 0f636f88..fea2e07a 100644 --- a/src/main/java/fr/hugman/promenade/entity/damage/PromenadeFallLocations.java +++ b/src/main/java/fr/hugman/promenade/entity/damage/PromenadeFallLocations.java @@ -1,7 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.damage; import net.minecraft.entity.damage.FallLocation; public class PromenadeFallLocations { - public static final FallLocation COILED_VINES = new FallLocation("coiled_vines"); + public static final FallLocation COILED_VINES = new FallLocation("coiled_vines"); } diff --git a/src/main/java/fr/hugman/promenade/entity/data/PromenadeTrackedData.java b/src/main/java/fr/hugman/promenade/entity/data/PromenadeTrackedData.java index 87a7d0b5..f1d50c4d 100644 --- a/src/main/java/fr/hugman/promenade/entity/data/PromenadeTrackedData.java +++ b/src/main/java/fr/hugman/promenade/entity/data/PromenadeTrackedData.java @@ -1,26 +1,39 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.data; +import net.minecraft.entity.data.TrackedDataHandler; +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.network.codec.PacketCodec; +import net.minecraft.registry.entry.RegistryEntry; + +import net.fabricmc.fabric.api.object.builder.v1.entity.FabricTrackedDataRegistry; + import fr.hugman.promenade.Promenade; import fr.hugman.promenade.entity.CapybaraEntity; import fr.hugman.promenade.entity.variant.CapybaraVariant; import fr.hugman.promenade.entity.variant.DuckVariant; import fr.hugman.promenade.entity.variant.SunkenVariant; -import net.fabricmc.fabric.api.object.builder.v1.entity.FabricTrackedDataRegistry; -import net.minecraft.entity.data.TrackedDataHandler; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.registry.entry.RegistryEntry; public class PromenadeTrackedData { - public static final TrackedDataHandler> DUCK_VARIANT = of("duck_variant", DuckVariant.ENTRY_PACKET_CODEC); - public static final TrackedDataHandler> CAPYBARA_VARIANT = of("capybara_variant", CapybaraVariant.ENTRY_PACKET_CODEC); - public static final TrackedDataHandler> SUNKEN_VARIANT = of("sunken_variant", SunkenVariant.ENTRY_PACKET_CODEC); + public static final TrackedDataHandler> DUCK_VARIANT = of("duck_variant", DuckVariant.ENTRY_PACKET_CODEC); + public static final TrackedDataHandler> CAPYBARA_VARIANT = of("capybara_variant", CapybaraVariant.ENTRY_PACKET_CODEC); + public static final TrackedDataHandler> SUNKEN_VARIANT = of("sunken_variant", SunkenVariant.ENTRY_PACKET_CODEC); - public static final TrackedDataHandler CAPYBARA_STATE = of("capybara_state", CapybaraEntity.State.PACKET_CODEC); + public static final TrackedDataHandler CAPYBARA_STATE = of("capybara_state", CapybaraEntity.State.PACKET_CODEC); - public static TrackedDataHandler of(String name, PacketCodec codec) { - var handler = TrackedDataHandler.create(codec); - FabricTrackedDataRegistry.register(Promenade.id(name), handler); - return handler; - } + public static TrackedDataHandler of(String name, PacketCodec codec) { + var handler = TrackedDataHandler.create(codec); + FabricTrackedDataRegistry.register(Promenade.id(name), handler); + return handler; + } } diff --git a/src/main/java/fr/hugman/promenade/entity/helper/EntityTypeFactory.java b/src/main/java/fr/hugman/promenade/entity/helper/EntityTypeFactory.java index 1ae29080..a0eb09ed 100644 --- a/src/main/java/fr/hugman/promenade/entity/helper/EntityTypeFactory.java +++ b/src/main/java/fr/hugman/promenade/entity/helper/EntityTypeFactory.java @@ -1,29 +1,40 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.helper; +import java.util.function.Supplier; + import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.entity.vehicle.ChestBoatEntity; import net.minecraft.item.Item; -import java.util.function.Supplier; - public class EntityTypeFactory { - public static EntityType.Builder boat(Supplier item) { - EntityType.EntityFactory factory = (type, world) -> new BoatEntity(type, world, item); - return EntityType.Builder.create(factory, SpawnGroup.MISC) - .dropsNothing() - .dimensions(1.375F, 0.5625F) - .eyeHeight(0.5625F) - .maxTrackingRange(10); - } + public static EntityType.Builder boat(Supplier item) { + EntityType.EntityFactory factory = (type, world) -> new BoatEntity(type, world, item); + return EntityType.Builder.create(factory, SpawnGroup.MISC) + .dropsNothing() + .dimensions(1.375F, 0.5625F) + .eyeHeight(0.5625F) + .maxTrackingRange(10); + } - public static EntityType.Builder chestBoat(Supplier item) { - EntityType.EntityFactory factory = (type, world) -> new ChestBoatEntity(type, world, item); - return EntityType.Builder.create(factory, SpawnGroup.MISC) - .dropsNothing() - .dimensions(1.375F, 0.5625F) - .eyeHeight(0.5625F) - .maxTrackingRange(10); - } + public static EntityType.Builder chestBoat(Supplier item) { + EntityType.EntityFactory factory = (type, world) -> new ChestBoatEntity(type, world, item); + return EntityType.Builder.create(factory, SpawnGroup.MISC) + .dropsNothing() + .dimensions(1.375F, 0.5625F) + .eyeHeight(0.5625F) + .maxTrackingRange(10); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/spawn/ChanceSpawnCondition.java b/src/main/java/fr/hugman/promenade/entity/spawn/ChanceSpawnCondition.java index f4ab121f..98beba84 100644 --- a/src/main/java/fr/hugman/promenade/entity/spawn/ChanceSpawnCondition.java +++ b/src/main/java/fr/hugman/promenade/entity/spawn/ChanceSpawnCondition.java @@ -1,22 +1,34 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.spawn; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.entity.spawn.SpawnCondition; import net.minecraft.entity.spawn.SpawnContext; import net.minecraft.util.dynamic.Codecs; public record ChanceSpawnCondition(float chance) implements SpawnCondition { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("chance").forGetter(ChanceSpawnCondition::chance) - ).apply(instance, ChanceSpawnCondition::new)); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( + Codecs.rangedInclusiveFloat(0.0F, 1.0F).fieldOf("chance").forGetter(ChanceSpawnCondition::chance) + ).apply(instance, ChanceSpawnCondition::new)); - public boolean test(SpawnContext spawnContext) { - return spawnContext.world().getRandom().nextFloat() < this.chance; - } + public boolean test(SpawnContext spawnContext) { + return spawnContext.world().getRandom().nextFloat() < this.chance; + } - @Override - public MapCodec getCodec() { - return CODEC; - } + @Override + public MapCodec getCodec() { + return CODEC; + } } diff --git a/src/main/java/fr/hugman/promenade/entity/spawn/PromenadeSpawnConditions.java b/src/main/java/fr/hugman/promenade/entity/spawn/PromenadeSpawnConditions.java index c7ef0ef6..d04948a1 100644 --- a/src/main/java/fr/hugman/promenade/entity/spawn/PromenadeSpawnConditions.java +++ b/src/main/java/fr/hugman/promenade/entity/spawn/PromenadeSpawnConditions.java @@ -1,17 +1,30 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.spawn; import com.mojang.serialization.MapCodec; -import fr.hugman.promenade.Promenade; + import net.minecraft.entity.spawn.SpawnCondition; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import fr.hugman.promenade.Promenade; + public class PromenadeSpawnConditions { - public static void register() { - of("chance", ChanceSpawnCondition.CODEC); - } + public static void register() { + of("chance", ChanceSpawnCondition.CODEC); + } - public static MapCodec of(String name, MapCodec codec) { - return Registry.register(Registries.SPAWN_CONDITION_TYPE, Promenade.id(name), codec); - } + public static MapCodec of(String name, MapCodec codec) { + return Registry.register(Registries.SPAWN_CONDITION_TYPE, Promenade.id(name), codec); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariant.java b/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariant.java index c5344dad..84ea37f0 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariant.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariant.java @@ -1,8 +1,21 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.variant; +import java.util.List; + import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; + import net.minecraft.entity.VariantSelectorProvider; import net.minecraft.entity.spawn.SpawnCondition; import net.minecraft.entity.spawn.SpawnConditionSelectors; @@ -14,36 +27,36 @@ import net.minecraft.registry.entry.RegistryFixedCodec; import net.minecraft.util.AssetInfo.TextureAssetInfo; -import java.util.List; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; public record CapybaraVariant( - TextureAssetInfo smallEyesTexture, - TextureAssetInfo largeEyesTexture, - TextureAssetInfo closedEyesTexture, - SpawnConditionSelectors spawnConditions + TextureAssetInfo smallEyesTexture, + TextureAssetInfo largeEyesTexture, + TextureAssetInfo closedEyesTexture, + SpawnConditionSelectors spawnConditions ) implements VariantSelectorProvider { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.CODEC.fieldOf("small_eyes_texture").forGetter(CapybaraVariant::smallEyesTexture), - TextureAssetInfo.CODEC.fieldOf("large_eyes_texture").forGetter(CapybaraVariant::largeEyesTexture), - TextureAssetInfo.CODEC.fieldOf("closed_eyes_texture").forGetter(CapybaraVariant::closedEyesTexture), - SpawnConditionSelectors.CODEC.fieldOf("spawn_conditions").forGetter(CapybaraVariant::spawnConditions) - ).apply(instance, CapybaraVariant::new)); - - public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.CODEC.fieldOf("small_eyes_texture").forGetter(CapybaraVariant::smallEyesTexture), - TextureAssetInfo.CODEC.fieldOf("large_eyes_texture").forGetter(CapybaraVariant::largeEyesTexture), - TextureAssetInfo.CODEC.fieldOf("closed_eyes_texture").forGetter(CapybaraVariant::closedEyesTexture) - ).apply(instance, CapybaraVariant::new)); - - public static final Codec> ENTRY_CODEC = RegistryFixedCodec.of(PromenadeRegistryKeys.CAPYBARA_VARIANT); - public static final PacketCodec> ENTRY_PACKET_CODEC = PacketCodecs.registryEntry(PromenadeRegistryKeys.CAPYBARA_VARIANT); - - private CapybaraVariant(TextureAssetInfo smallEyesTexture, TextureAssetInfo largeEyesTexture, TextureAssetInfo closedEyesTexture) { - this(smallEyesTexture, largeEyesTexture, closedEyesTexture, SpawnConditionSelectors.EMPTY); - } - - @Override - public List> getSelectors() { - return this.spawnConditions.selectors(); - } + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + TextureAssetInfo.CODEC.fieldOf("small_eyes_texture").forGetter(CapybaraVariant::smallEyesTexture), + TextureAssetInfo.CODEC.fieldOf("large_eyes_texture").forGetter(CapybaraVariant::largeEyesTexture), + TextureAssetInfo.CODEC.fieldOf("closed_eyes_texture").forGetter(CapybaraVariant::closedEyesTexture), + SpawnConditionSelectors.CODEC.fieldOf("spawn_conditions").forGetter(CapybaraVariant::spawnConditions) + ).apply(instance, CapybaraVariant::new)); + + public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( + TextureAssetInfo.CODEC.fieldOf("small_eyes_texture").forGetter(CapybaraVariant::smallEyesTexture), + TextureAssetInfo.CODEC.fieldOf("large_eyes_texture").forGetter(CapybaraVariant::largeEyesTexture), + TextureAssetInfo.CODEC.fieldOf("closed_eyes_texture").forGetter(CapybaraVariant::closedEyesTexture) + ).apply(instance, CapybaraVariant::new)); + + public static final Codec> ENTRY_CODEC = RegistryFixedCodec.of(PromenadeRegistryKeys.CAPYBARA_VARIANT); + public static final PacketCodec> ENTRY_PACKET_CODEC = PacketCodecs.registryEntry(PromenadeRegistryKeys.CAPYBARA_VARIANT); + + private CapybaraVariant(TextureAssetInfo smallEyesTexture, TextureAssetInfo largeEyesTexture, TextureAssetInfo closedEyesTexture) { + this(smallEyesTexture, largeEyesTexture, closedEyesTexture, SpawnConditionSelectors.EMPTY); + } + + @Override + public List> getSelectors() { + return this.spawnConditions.selectors(); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariants.java index 704ecd8d..143b3a4a 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/CapybaraVariants.java @@ -1,7 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.variant; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import java.util.Optional; + import net.minecraft.entity.VariantSelectorProvider; import net.minecraft.entity.spawn.SpawnContext; import net.minecraft.registry.DynamicRegistryManager; @@ -9,19 +20,20 @@ import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.math.random.Random; -import java.util.Optional; +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; public class CapybaraVariants { - public static final RegistryKey BROWN = of("brown"); - public static final RegistryKey ALBINO = of("albino"); + public static final RegistryKey BROWN = of("brown"); + public static final RegistryKey ALBINO = of("albino"); - public static final RegistryKey DEFAULT = BROWN; + public static final RegistryKey DEFAULT = BROWN; - public static RegistryKey of(String path) { - return RegistryKey.of(PromenadeRegistryKeys.CAPYBARA_VARIANT, Promenade.id(path)); - } + public static RegistryKey of(String path) { + return RegistryKey.of(PromenadeRegistryKeys.CAPYBARA_VARIANT, Promenade.id(path)); + } - public static Optional> select(Random random, DynamicRegistryManager registries, SpawnContext context) { - return VariantSelectorProvider.select(registries.getOrThrow(PromenadeRegistryKeys.CAPYBARA_VARIANT).streamEntries(), RegistryEntry::value, random, context); - } + public static Optional> select(Random random, DynamicRegistryManager registries, SpawnContext context) { + return VariantSelectorProvider.select(registries.getOrThrow(PromenadeRegistryKeys.CAPYBARA_VARIANT).streamEntries(), RegistryEntry::value, random, context); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/DuckVariant.java b/src/main/java/fr/hugman/promenade/entity/variant/DuckVariant.java index 676f798e..4620c2de 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/DuckVariant.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/DuckVariant.java @@ -1,9 +1,21 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.variant; +import java.util.List; + import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; + import net.minecraft.entity.VariantSelectorProvider; import net.minecraft.entity.spawn.SpawnCondition; import net.minecraft.entity.spawn.SpawnConditionSelectors; @@ -15,35 +27,36 @@ import net.minecraft.registry.entry.RegistryFixedCodec; import net.minecraft.util.AssetInfo.TextureAssetInfo; -import java.util.List; +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; public record DuckVariant( - TextureAssetInfo texture, - TextureAssetInfo babyTexture, - SpawnConditionSelectors spawnConditions + TextureAssetInfo texture, + TextureAssetInfo babyTexture, + SpawnConditionSelectors spawnConditions ) implements VariantSelectorProvider { - public static final TextureAssetInfo DEFAULT_DUCKLING_ASSET = new TextureAssetInfo(Promenade.id("entity/duck/duckling")); - - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.MAP_CODEC.forGetter(DuckVariant::texture), - TextureAssetInfo.CODEC.optionalFieldOf("baby_texture", DEFAULT_DUCKLING_ASSET).forGetter(DuckVariant::babyTexture), - SpawnConditionSelectors.CODEC.fieldOf("spawn_conditions").forGetter(DuckVariant::spawnConditions) - ).apply(instance, DuckVariant::new)); - - public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.MAP_CODEC.forGetter(DuckVariant::texture), - TextureAssetInfo.CODEC.optionalFieldOf("baby_texture", DEFAULT_DUCKLING_ASSET).forGetter(DuckVariant::babyTexture) - ).apply(instance, DuckVariant::new)); - - public static final Codec> ENTRY_CODEC = RegistryFixedCodec.of(PromenadeRegistryKeys.DUCK_VARIANT); - public static final PacketCodec> ENTRY_PACKET_CODEC = PacketCodecs.registryEntry(PromenadeRegistryKeys.DUCK_VARIANT); - - public DuckVariant(TextureAssetInfo texture, TextureAssetInfo babyTexture) { - this(texture, babyTexture, SpawnConditionSelectors.EMPTY); - } - - @Override - public List> getSelectors() { - return this.spawnConditions.selectors(); - } + public static final TextureAssetInfo DEFAULT_DUCKLING_ASSET = new TextureAssetInfo(Promenade.id("entity/duck/duckling")); + + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + TextureAssetInfo.MAP_CODEC.forGetter(DuckVariant::texture), + TextureAssetInfo.CODEC.optionalFieldOf("baby_texture", DEFAULT_DUCKLING_ASSET).forGetter(DuckVariant::babyTexture), + SpawnConditionSelectors.CODEC.fieldOf("spawn_conditions").forGetter(DuckVariant::spawnConditions) + ).apply(instance, DuckVariant::new)); + + public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( + TextureAssetInfo.MAP_CODEC.forGetter(DuckVariant::texture), + TextureAssetInfo.CODEC.optionalFieldOf("baby_texture", DEFAULT_DUCKLING_ASSET).forGetter(DuckVariant::babyTexture) + ).apply(instance, DuckVariant::new)); + + public static final Codec> ENTRY_CODEC = RegistryFixedCodec.of(PromenadeRegistryKeys.DUCK_VARIANT); + public static final PacketCodec> ENTRY_PACKET_CODEC = PacketCodecs.registryEntry(PromenadeRegistryKeys.DUCK_VARIANT); + + public DuckVariant(TextureAssetInfo texture, TextureAssetInfo babyTexture) { + this(texture, babyTexture, SpawnConditionSelectors.EMPTY); + } + + @Override + public List> getSelectors() { + return this.spawnConditions.selectors(); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/DuckVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/DuckVariants.java index dffe0481..c30cb53e 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/DuckVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/DuckVariants.java @@ -1,7 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.variant; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import java.util.Optional; + import net.minecraft.entity.VariantSelectorProvider; import net.minecraft.entity.spawn.SpawnContext; import net.minecraft.registry.DynamicRegistryManager; @@ -10,23 +21,24 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.random.Random; -import java.util.Optional; +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; public class DuckVariants { - public static final RegistryKey PEKIN = of("pekin"); - public static final RegistryKey MALLARD = of("mallard"); + public static final RegistryKey PEKIN = of("pekin"); + public static final RegistryKey MALLARD = of("mallard"); - public static final RegistryKey DEFAULT = PEKIN; + public static final RegistryKey DEFAULT = PEKIN; - private static RegistryKey of(String path) { - return of(Promenade.id(path)); - } + private static RegistryKey of(String path) { + return of(Promenade.id(path)); + } - public static RegistryKey of(Identifier id) { - return RegistryKey.of(PromenadeRegistryKeys.DUCK_VARIANT, id); - } + public static RegistryKey of(Identifier id) { + return RegistryKey.of(PromenadeRegistryKeys.DUCK_VARIANT, id); + } - public static Optional> select(Random random, DynamicRegistryManager registries, SpawnContext context) { - return VariantSelectorProvider.select(registries.getOrThrow(PromenadeRegistryKeys.DUCK_VARIANT).streamEntries(), RegistryEntry::value, random, context); - } + public static Optional> select(Random random, DynamicRegistryManager registries, SpawnContext context) { + return VariantSelectorProvider.select(registries.getOrThrow(PromenadeRegistryKeys.DUCK_VARIANT).streamEntries(), RegistryEntry::value, random, context); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/PromenadePaintingVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/PromenadePaintingVariants.java index b7f22962..ee805dea 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/PromenadePaintingVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/PromenadePaintingVariants.java @@ -1,15 +1,27 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.variant; -import fr.hugman.promenade.Promenade; import net.minecraft.entity.decoration.painting.PaintingVariant; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; +import fr.hugman.promenade.Promenade; + public class PromenadePaintingVariants { - public static final RegistryKey OPTIMISM = of("optimism"); - public static final RegistryKey NURTURE = of("nurture"); + public static final RegistryKey OPTIMISM = of("optimism"); + public static final RegistryKey NURTURE = of("nurture"); - public static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.PAINTING_VARIANT, Promenade.id(path)); - } + public static RegistryKey of(String path) { + return RegistryKey.of(RegistryKeys.PAINTING_VARIANT, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/PromenadeWolfVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/PromenadeWolfVariants.java index 4a031d1c..aa3c9c47 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/PromenadeWolfVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/PromenadeWolfVariants.java @@ -1,14 +1,26 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.variant; -import fr.hugman.promenade.Promenade; import net.minecraft.entity.passive.WolfVariant; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; +import fr.hugman.promenade.Promenade; + public class PromenadeWolfVariants { - public static final RegistryKey SHIBA_INU = of("shiba_inu"); + public static final RegistryKey SHIBA_INU = of("shiba_inu"); - public static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.WOLF_VARIANT, Promenade.id(path)); - } + public static RegistryKey of(String path) { + return RegistryKey.of(RegistryKeys.WOLF_VARIANT, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariant.java b/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariant.java index a8f9f633..9cb3c261 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariant.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariant.java @@ -1,8 +1,21 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.variant; +import java.util.List; + import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; + import net.minecraft.entity.VariantSelectorProvider; import net.minecraft.entity.spawn.SpawnCondition; import net.minecraft.entity.spawn.SpawnConditionSelectors; @@ -17,33 +30,33 @@ import net.minecraft.registry.entry.RegistryFixedCodec; import net.minecraft.util.AssetInfo.TextureAssetInfo; -import java.util.List; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; public record SunkenVariant( - TextureAssetInfo texture, - RegistryKey lootTable, - SpawnConditionSelectors spawnConditions + TextureAssetInfo texture, + RegistryKey lootTable, + SpawnConditionSelectors spawnConditions ) implements VariantSelectorProvider { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.MAP_CODEC.forGetter(SunkenVariant::texture), - RegistryKey.createCodec(RegistryKeys.LOOT_TABLE).fieldOf("loot_table").forGetter(SunkenVariant::lootTable), - SpawnConditionSelectors.CODEC.fieldOf("spawn_conditions").forGetter(SunkenVariant::spawnConditions) - ).apply(instance, SunkenVariant::new)); - - public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( - TextureAssetInfo.MAP_CODEC.forGetter(SunkenVariant::texture), - RegistryKey.createCodec(RegistryKeys.LOOT_TABLE).fieldOf("loot_table").forGetter(SunkenVariant::lootTable) - ).apply(instance, SunkenVariant::new)); - - public static final Codec> ENTRY_CODEC = RegistryFixedCodec.of(PromenadeRegistryKeys.SUNKEN_VARIANT); - public static final PacketCodec> ENTRY_PACKET_CODEC = PacketCodecs.registryEntry(PromenadeRegistryKeys.SUNKEN_VARIANT); - - public SunkenVariant(TextureAssetInfo texture, RegistryKey lootTable) { - this(texture, lootTable, SpawnConditionSelectors.EMPTY); - } - - @Override - public List> getSelectors() { - return this.spawnConditions.selectors(); - } + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + TextureAssetInfo.MAP_CODEC.forGetter(SunkenVariant::texture), + RegistryKey.createCodec(RegistryKeys.LOOT_TABLE).fieldOf("loot_table").forGetter(SunkenVariant::lootTable), + SpawnConditionSelectors.CODEC.fieldOf("spawn_conditions").forGetter(SunkenVariant::spawnConditions) + ).apply(instance, SunkenVariant::new)); + + public static final Codec NETWORK_CODEC = RecordCodecBuilder.create(instance -> instance.group( + TextureAssetInfo.MAP_CODEC.forGetter(SunkenVariant::texture), + RegistryKey.createCodec(RegistryKeys.LOOT_TABLE).fieldOf("loot_table").forGetter(SunkenVariant::lootTable) + ).apply(instance, SunkenVariant::new)); + + public static final Codec> ENTRY_CODEC = RegistryFixedCodec.of(PromenadeRegistryKeys.SUNKEN_VARIANT); + public static final PacketCodec> ENTRY_PACKET_CODEC = PacketCodecs.registryEntry(PromenadeRegistryKeys.SUNKEN_VARIANT); + + public SunkenVariant(TextureAssetInfo texture, RegistryKey lootTable) { + this(texture, lootTable, SpawnConditionSelectors.EMPTY); + } + + @Override + public List> getSelectors() { + return this.spawnConditions.selectors(); + } } diff --git a/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariants.java b/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariants.java index bad75309..bf35ca84 100644 --- a/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariants.java +++ b/src/main/java/fr/hugman/promenade/entity/variant/SunkenVariants.java @@ -1,7 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.entity.variant; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import java.util.Optional; + import net.minecraft.entity.VariantSelectorProvider; import net.minecraft.entity.spawn.SpawnContext; import net.minecraft.registry.DynamicRegistryManager; @@ -10,26 +21,27 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.random.Random; -import java.util.Optional; +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; public class SunkenVariants { - public static final RegistryKey TUBE = of("tube"); - public static final RegistryKey BRAIN = of("brain"); - public static final RegistryKey BUBBLE = of("bubble"); - public static final RegistryKey FIRE = of("fire"); - public static final RegistryKey HORN = of("horn"); + public static final RegistryKey TUBE = of("tube"); + public static final RegistryKey BRAIN = of("brain"); + public static final RegistryKey BUBBLE = of("bubble"); + public static final RegistryKey FIRE = of("fire"); + public static final RegistryKey HORN = of("horn"); - public static final RegistryKey DEFAULT = TUBE; + public static final RegistryKey DEFAULT = TUBE; - private static RegistryKey of(String path) { - return of(Promenade.id(path)); - } + private static RegistryKey of(String path) { + return of(Promenade.id(path)); + } - public static RegistryKey of(Identifier id) { - return RegistryKey.of(PromenadeRegistryKeys.SUNKEN_VARIANT, id); - } + public static RegistryKey of(Identifier id) { + return RegistryKey.of(PromenadeRegistryKeys.SUNKEN_VARIANT, id); + } - public static Optional> select(Random random, DynamicRegistryManager registries, SpawnContext context) { - return VariantSelectorProvider.select(registries.getOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT).streamEntries(), RegistryEntry::value, random, context); - } + public static Optional> select(Random random, DynamicRegistryManager registries, SpawnContext context) { + return VariantSelectorProvider.select(registries.getOrThrow(PromenadeRegistryKeys.SUNKEN_VARIANT).streamEntries(), RegistryEntry::value, random, context); + } } diff --git a/src/main/java/fr/hugman/promenade/item/ItemSettings.java b/src/main/java/fr/hugman/promenade/item/ItemSettings.java index 78fe503e..a77e35d2 100644 --- a/src/main/java/fr/hugman/promenade/item/ItemSettings.java +++ b/src/main/java/fr/hugman/promenade/item/ItemSettings.java @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.item; import net.minecraft.component.type.ConsumableComponent; @@ -6,19 +17,19 @@ import net.minecraft.item.Items; public final class ItemSettings { - public static Item.Settings max1() { - return new Item.Settings().maxCount(1); - } + public static Item.Settings max1() { + return new Item.Settings().maxCount(1); + } - public static Item.Settings max16() { - return new Item.Settings().maxCount(16); - } + public static Item.Settings max16() { + return new Item.Settings().maxCount(16); + } - public static Item.Settings stackableDrink(FoodComponent foodComponent, ConsumableComponent consumableComponent) { - return new Item.Settings() - .recipeRemainder(Items.GLASS_BOTTLE) - .food(foodComponent, consumableComponent) - .useRemainder(Items.GLASS_BOTTLE) - .maxCount(16); - } + public static Item.Settings stackableDrink(FoodComponent foodComponent, ConsumableComponent consumableComponent) { + return new Item.Settings() + .recipeRemainder(Items.GLASS_BOTTLE) + .food(foodComponent, consumableComponent) + .useRemainder(Items.GLASS_BOTTLE) + .maxCount(16); + } } diff --git a/src/main/java/fr/hugman/promenade/item/PromenadeItemKeys.java b/src/main/java/fr/hugman/promenade/item/PromenadeItemKeys.java index fb27ff3b..ab38fbaf 100644 --- a/src/main/java/fr/hugman/promenade/item/PromenadeItemKeys.java +++ b/src/main/java/fr/hugman/promenade/item/PromenadeItemKeys.java @@ -1,14 +1,26 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.item; -import fr.hugman.promenade.Promenade; import net.minecraft.item.Item; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; +import fr.hugman.promenade.Promenade; + public class PromenadeItemKeys { - public static final RegistryKey BLUEBERRIES = of("blueberries"); + public static final RegistryKey BLUEBERRIES = of("blueberries"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.ITEM, Promenade.id(path)); - } + private static RegistryKey of(String path) { + return RegistryKey.of(RegistryKeys.ITEM, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/item/PromenadeItems.java b/src/main/java/fr/hugman/promenade/item/PromenadeItems.java index 036d6de6..06823fc3 100644 --- a/src/main/java/fr/hugman/promenade/item/PromenadeItems.java +++ b/src/main/java/fr/hugman/promenade/item/PromenadeItems.java @@ -1,12 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.item; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.banner.PromenadeBannerPatternTags; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.component.PromenadeConsumableComponents; -import fr.hugman.promenade.component.PromenadeFoodComponents; -import fr.hugman.promenade.entity.PromenadeEntityTypes; -import fr.hugman.promenade.item.helper.ItemFactory; +import java.util.function.BiFunction; +import java.util.function.Function; + import net.minecraft.block.Block; import net.minecraft.component.DataComponentTypes; import net.minecraft.item.Item; @@ -15,71 +22,76 @@ import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; -import java.util.function.BiFunction; -import java.util.function.Function; +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.banner.PromenadeBannerPatternTags; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.component.PromenadeConsumableComponents; +import fr.hugman.promenade.component.PromenadeFoodComponents; +import fr.hugman.promenade.entity.PromenadeEntityTypes; +import fr.hugman.promenade.item.helper.ItemFactory; public class PromenadeItems { - public static final Item SAKURA_SIGN = register(PromenadeBlocks.SAKURA_SIGN, ItemFactory.sign(PromenadeBlocks.SAKURA_WALL_SIGN), ItemSettings.max16()); - public static final Item SAKURA_HANGING_SIGN = register(PromenadeBlocks.SAKURA_HANGING_SIGN, ItemFactory.hangingSign(PromenadeBlocks.SAKURA_WALL_HANGING_SIGN), ItemSettings.max16()); - public static final Item SAKURA_BOAT = register("sakura_boat", ItemFactory.boat(PromenadeEntityTypes.SAKURA_BOAT), ItemSettings.max1()); - public static final Item SAKURA_CHEST_BOAT = register("sakura_chest_boat", ItemFactory.boat(PromenadeEntityTypes.SAKURA_CHEST_BOAT), ItemSettings.max1()); + public static final Item SAKURA_SIGN = register(PromenadeBlocks.SAKURA_SIGN, ItemFactory.sign(PromenadeBlocks.SAKURA_WALL_SIGN), ItemSettings.max16()); + public static final Item SAKURA_HANGING_SIGN = register(PromenadeBlocks.SAKURA_HANGING_SIGN, ItemFactory.hangingSign(PromenadeBlocks.SAKURA_WALL_HANGING_SIGN), ItemSettings.max16()); + public static final Item SAKURA_BOAT = register("sakura_boat", ItemFactory.boat(PromenadeEntityTypes.SAKURA_BOAT), ItemSettings.max1()); + public static final Item SAKURA_CHEST_BOAT = register("sakura_chest_boat", ItemFactory.boat(PromenadeEntityTypes.SAKURA_CHEST_BOAT), ItemSettings.max1()); - public static final Item MAPLE_SIGN = register(PromenadeBlocks.MAPLE_SIGN, ItemFactory.sign(PromenadeBlocks.MAPLE_WALL_SIGN), ItemSettings.max16()); - public static final Item MAPLE_HANGING_SIGN = register(PromenadeBlocks.MAPLE_HANGING_SIGN, ItemFactory.hangingSign(PromenadeBlocks.MAPLE_WALL_HANGING_SIGN), ItemSettings.max16()); - public static final Item MAPLE_BOAT = register("maple_boat", ItemFactory.boat(PromenadeEntityTypes.MAPLE_BOAT), ItemSettings.max1()); - public static final Item MAPLE_CHEST_BOAT = register("maple_chest_boat", ItemFactory.boat(PromenadeEntityTypes.MAPLE_CHEST_BOAT), ItemSettings.max1()); - public static final Item MAPLE_SYRUP_BOTTLE = register("maple_syrup_bottle", ItemSettings.stackableDrink(PromenadeFoodComponents.MAPLE_SYRUP_BOTTLE, PromenadeConsumableComponents.MAPLE_SYRUP_BOTTLE)); + public static final Item MAPLE_SIGN = register(PromenadeBlocks.MAPLE_SIGN, ItemFactory.sign(PromenadeBlocks.MAPLE_WALL_SIGN), ItemSettings.max16()); + public static final Item MAPLE_HANGING_SIGN = register(PromenadeBlocks.MAPLE_HANGING_SIGN, ItemFactory.hangingSign(PromenadeBlocks.MAPLE_WALL_HANGING_SIGN), ItemSettings.max16()); + public static final Item MAPLE_BOAT = register("maple_boat", ItemFactory.boat(PromenadeEntityTypes.MAPLE_BOAT), ItemSettings.max1()); + public static final Item MAPLE_CHEST_BOAT = register("maple_chest_boat", ItemFactory.boat(PromenadeEntityTypes.MAPLE_CHEST_BOAT), ItemSettings.max1()); + public static final Item MAPLE_SYRUP_BOTTLE = register("maple_syrup_bottle", ItemSettings.stackableDrink(PromenadeFoodComponents.MAPLE_SYRUP_BOTTLE, PromenadeConsumableComponents.MAPLE_SYRUP_BOTTLE)); - public static final Item PALM_SIGN = register(PromenadeBlocks.PALM_SIGN, ItemFactory.sign(PromenadeBlocks.PALM_WALL_SIGN), ItemSettings.max16()); - public static final Item PALM_HANGING_SIGN = register(PromenadeBlocks.PALM_HANGING_SIGN, ItemFactory.hangingSign(PromenadeBlocks.PALM_WALL_HANGING_SIGN), ItemSettings.max16()); - public static final Item PALM_BOAT = register("palm_boat", ItemFactory.boat(PromenadeEntityTypes.PALM_BOAT), ItemSettings.max1()); - public static final Item PALM_CHEST_BOAT = register("palm_chest_boat", ItemFactory.boat(PromenadeEntityTypes.PALM_CHEST_BOAT), ItemSettings.max1()); + public static final Item PALM_SIGN = register(PromenadeBlocks.PALM_SIGN, ItemFactory.sign(PromenadeBlocks.PALM_WALL_SIGN), ItemSettings.max16()); + public static final Item PALM_HANGING_SIGN = register(PromenadeBlocks.PALM_HANGING_SIGN, ItemFactory.hangingSign(PromenadeBlocks.PALM_WALL_HANGING_SIGN), ItemSettings.max16()); + public static final Item PALM_BOAT = register("palm_boat", ItemFactory.boat(PromenadeEntityTypes.PALM_BOAT), ItemSettings.max1()); + public static final Item PALM_CHEST_BOAT = register("palm_chest_boat", ItemFactory.boat(PromenadeEntityTypes.PALM_CHEST_BOAT), ItemSettings.max1()); - public static final Item DARK_AMARANTH_SIGN = register(PromenadeBlocks.DARK_AMARANTH_SIGN, ItemFactory.sign(PromenadeBlocks.DARK_AMARANTH_WALL_SIGN), ItemSettings.max16()); - public static final Item DARK_AMARANTH_HANGING_SIGN = register(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN, ItemFactory.hangingSign(PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN), ItemSettings.max16()); + public static final Item DARK_AMARANTH_SIGN = register(PromenadeBlocks.DARK_AMARANTH_SIGN, ItemFactory.sign(PromenadeBlocks.DARK_AMARANTH_WALL_SIGN), ItemSettings.max16()); + public static final Item DARK_AMARANTH_HANGING_SIGN = register(PromenadeBlocks.DARK_AMARANTH_HANGING_SIGN, ItemFactory.hangingSign(PromenadeBlocks.DARK_AMARANTH_WALL_HANGING_SIGN), ItemSettings.max16()); - public static final Item BLUEBERRIES = register(PromenadeItemKeys.BLUEBERRIES, ItemFactory.uniqueNameBlock(PromenadeBlocks.BLUEBERRY_BUSH), new Item.Settings().food(PromenadeFoodComponents.BLUEBERRIES)); + public static final Item BLUEBERRIES = register(PromenadeItemKeys.BLUEBERRIES, ItemFactory.uniqueNameBlock(PromenadeBlocks.BLUEBERRY_BUSH), new Item.Settings().food(PromenadeFoodComponents.BLUEBERRIES)); - public static final Item BANANA = register("banana", new Item.Settings().food(PromenadeFoodComponents.BANANA)); - public static final Item APRICOT = register("apricot", new Item.Settings().food(PromenadeFoodComponents.APRICOT)); - public static final Item MANGO = register("mango", new Item.Settings().food(PromenadeFoodComponents.MANGO)); + public static final Item BANANA = register("banana", new Item.Settings().food(PromenadeFoodComponents.BANANA)); + public static final Item APRICOT = register("apricot", new Item.Settings().food(PromenadeFoodComponents.APRICOT)); + public static final Item MANGO = register("mango", new Item.Settings().food(PromenadeFoodComponents.MANGO)); - public static final Item DUCK = register("duck", new Item.Settings().food(PromenadeFoodComponents.RAW_DUCK, PromenadeConsumableComponents.RAW_DUCK)); - public static final Item COOKED_DUCK = register("cooked_duck", new Item.Settings().food(PromenadeFoodComponents.COOKED_DUCK)); + public static final Item DUCK = register("duck", new Item.Settings().food(PromenadeFoodComponents.RAW_DUCK, PromenadeConsumableComponents.RAW_DUCK)); + public static final Item COOKED_DUCK = register("cooked_duck", new Item.Settings().food(PromenadeFoodComponents.COOKED_DUCK)); - public static final Item BOVINE_BANNER_PATTERN = register("bovine_banner_pattern", ItemSettings.max1().component(DataComponentTypes.PROVIDES_BANNER_PATTERNS, PromenadeBannerPatternTags.BOVINE_PATTERN_ITEM)); + public static final Item BOVINE_BANNER_PATTERN = register("bovine_banner_pattern", ItemSettings.max1().component(DataComponentTypes.PROVIDES_BANNER_PATTERNS, PromenadeBannerPatternTags.BOVINE_PATTERN_ITEM)); - public static final Item CAPYBARA_SPAWN_EGG = register("capybara_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.CAPYBARA)); - public static final Item DUCK_SPAWN_EGG = register("duck_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.DUCK)); - public static final Item LUSH_CREEPER_SPAWN_EGG = register("lush_creeper_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.LUSH_CREEPER)); - public static final Item SUNKEN_SPAWN_EGG = register("sunken_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.SUNKEN)); + public static final Item CAPYBARA_SPAWN_EGG = register("capybara_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.CAPYBARA)); + public static final Item DUCK_SPAWN_EGG = register("duck_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.DUCK)); + public static final Item LUSH_CREEPER_SPAWN_EGG = register("lush_creeper_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.LUSH_CREEPER)); + public static final Item SUNKEN_SPAWN_EGG = register("sunken_spawn_egg", ItemFactory.spawnEgg(PromenadeEntityTypes.SUNKEN)); - private static RegistryKey keyOf(String path) { - return RegistryKey.of(RegistryKeys.ITEM, Promenade.id(path)); - } + private static RegistryKey keyOf(String path) { + return RegistryKey.of(RegistryKeys.ITEM, Promenade.id(path)); + } - private static RegistryKey keyOf(RegistryKey blockKey) { - return RegistryKey.of(RegistryKeys.ITEM, blockKey.getValue()); - } + private static RegistryKey keyOf(RegistryKey blockKey) { + return RegistryKey.of(RegistryKeys.ITEM, blockKey.getValue()); + } - public static O register(Block block, BiFunction factory, Item.Settings settings) { - return register(keyOf(block.getRegistryEntry().registryKey()), itemSettings -> factory.apply(block, itemSettings), settings.useBlockPrefixedTranslationKey()); - } + public static O register(Block block, BiFunction factory, Item.Settings settings) { + return register(keyOf(block.getRegistryEntry().registryKey()), itemSettings -> factory.apply(block, itemSettings), settings.useBlockPrefixedTranslationKey()); + } - public static O register(RegistryKey key, Function factory, Item.Settings settings) { - O item = factory.apply(settings.registryKey(key)); - return Registry.register(Registries.ITEM, key, item); - } + public static O register(RegistryKey key, Function factory, Item.Settings settings) { + O item = factory.apply(settings.registryKey(key)); + return Registry.register(Registries.ITEM, key, item); + } - public static O register(String id, Function factory, Item.Settings settings) { - return register(keyOf(id), factory, settings); - } + public static O register(String id, Function factory, Item.Settings settings) { + return register(keyOf(id), factory, settings); + } - public static O register(String id, Function factory) { - return register(keyOf(id), factory, new Item.Settings()); - } + public static O register(String id, Function factory) { + return register(keyOf(id), factory, new Item.Settings()); + } - public static Item register(String id, Item.Settings settings) { - return register(keyOf(id), Item::new, settings); - } + public static Item register(String id, Item.Settings settings) { + return register(keyOf(id), Item::new, settings); + } } diff --git a/src/main/java/fr/hugman/promenade/item/helper/ItemFactory.java b/src/main/java/fr/hugman/promenade/item/helper/ItemFactory.java index 6f0aa80c..07498177 100644 --- a/src/main/java/fr/hugman/promenade/item/helper/ItemFactory.java +++ b/src/main/java/fr/hugman/promenade/item/helper/ItemFactory.java @@ -1,32 +1,43 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.item.helper; +import java.util.function.BiFunction; +import java.util.function.Function; + import net.minecraft.block.Block; import net.minecraft.entity.EntityType; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.vehicle.AbstractBoatEntity; import net.minecraft.item.*; -import java.util.function.BiFunction; -import java.util.function.Function; - public final class ItemFactory { - public static Function uniqueNameBlock(Block block) { - return settings -> new BlockItem(block, settings.useItemPrefixedTranslationKey()); - } + public static Function uniqueNameBlock(Block block) { + return settings -> new BlockItem(block, settings.useItemPrefixedTranslationKey()); + } - public static BiFunction sign(Block wallSignBlock) { - return (block, settings) -> new SignItem(block, wallSignBlock, settings); - } + public static BiFunction sign(Block wallSignBlock) { + return (block, settings) -> new SignItem(block, wallSignBlock, settings); + } - public static BiFunction hangingSign(Block wallSignBlock) { - return (block, settings) -> new HangingSignItem(block, wallSignBlock, settings); - } + public static BiFunction hangingSign(Block wallSignBlock) { + return (block, settings) -> new HangingSignItem(block, wallSignBlock, settings); + } - public static Function spawnEgg(EntityType entityType) { - return s -> new SpawnEggItem(s.spawnEgg(entityType)); - } + public static Function spawnEgg(EntityType entityType) { + return s -> new SpawnEggItem(s.spawnEgg(entityType)); + } - public static Function boat(EntityType boatEntity) { - return s -> new BoatItem(boatEntity, s); - } + public static Function boat(EntityType boatEntity) { + return s -> new BoatItem(boatEntity, s); + } } diff --git a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroup.java b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroup.java index a55ee727..f5d7448a 100644 --- a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroup.java +++ b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroup.java @@ -1,6 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.itemgroup; -import fr.hugman.promenade.Promenade; +import java.util.Comparator; +import java.util.Set; + import net.minecraft.component.DataComponentTypes; import net.minecraft.entity.decoration.painting.PaintingVariant; import net.minecraft.item.ItemGroup; @@ -12,56 +25,55 @@ import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; -import java.util.Comparator; -import java.util.Set; +import fr.hugman.promenade.Promenade; public final class PromenadeItemGroup { - public static void fill(ItemGroup.DisplayContext displayContext, ItemGroup.Entries entries) { - Set set = ItemStackSet.create(); + public static void fill(ItemGroup.DisplayContext displayContext, ItemGroup.Entries entries) { + Set set = ItemStackSet.create(); - for (ItemGroup itemGroup : Registries.ITEM_GROUP) { - if (itemGroup.getType() != ItemGroup.Type.SEARCH) { - for (var stack : itemGroup.getSearchTabStacks()) { - if (isPromenade(Registries.ITEM.getEntry(stack.getItem()))) { - set.add(stack); - } - } - } - } + for (ItemGroup itemGroup : Registries.ITEM_GROUP) { + if (itemGroup.getType() != ItemGroup.Type.SEARCH) { + for (var stack : itemGroup.getSearchTabStacks()) { + if (isPromenade(Registries.ITEM.getEntry(stack.getItem()))) { + set.add(stack); + } + } + } + } - entries.addAll(set); + entries.addAll(set); - // Vanilla Entity Variants - //TODO: add spawn eggs + // Vanilla Entity Variants + //TODO: add spawn eggs - // Paintings - displayContext.lookup() - .getOptional(RegistryKeys.PAINTING_VARIANT) - .ifPresent(registryWrapper -> registryWrapper.streamEntries() - .filter(PromenadeItemGroup::isPromenade) - .sorted(PAINTING_VARIANT_COMPARATOR) - .forEach( - paintingVariantEntry -> { - ItemStack itemStack = new ItemStack(Items.PAINTING); - itemStack.set(DataComponentTypes.PAINTING_VARIANT, paintingVariantEntry); - entries.add(itemStack, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); - } - ) - ); - } + // Paintings + displayContext.lookup() + .getOptional(RegistryKeys.PAINTING_VARIANT) + .ifPresent(registryWrapper -> registryWrapper.streamEntries() + .filter(PromenadeItemGroup::isPromenade) + .sorted(PAINTING_VARIANT_COMPARATOR) + .forEach( + paintingVariantEntry -> { + ItemStack itemStack = new ItemStack(Items.PAINTING); + itemStack.set(DataComponentTypes.PAINTING_VARIANT, paintingVariantEntry); + entries.add(itemStack, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + } + ) + ); + } - private static boolean isPromenade(RegistryEntry entry) { - return isPromenade(entry.getKey().orElseThrow()); - } + private static boolean isPromenade(RegistryEntry entry) { + return isPromenade(entry.getKey().orElseThrow()); + } - private static boolean isPromenade(RegistryKey key) { - return key.getValue().getNamespace().equals(Promenade.MOD_ID); - } + private static boolean isPromenade(RegistryKey key) { + return key.getValue().getNamespace().equals(Promenade.MOD_ID); + } - // FROM Vanilla ItemGroups + // FROM Vanilla ItemGroups - private static final Comparator> PAINTING_VARIANT_COMPARATOR = Comparator.comparing( - RegistryEntry::value, Comparator.comparingInt(PaintingVariant::getArea).thenComparing(PaintingVariant::width) - ); + private static final Comparator> PAINTING_VARIANT_COMPARATOR = Comparator.comparing( + RegistryEntry::value, Comparator.comparingInt(PaintingVariant::getArea).thenComparing(PaintingVariant::width) + ); } diff --git a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupAdditions.java b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupAdditions.java index a4a45bbf..ce42de9c 100644 --- a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupAdditions.java +++ b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupAdditions.java @@ -1,237 +1,250 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.itemgroup; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.item.PromenadeItems; -import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import java.util.Collections; +import java.util.function.Predicate; + import net.minecraft.block.Blocks; import net.minecraft.item.*; import net.minecraft.registry.Registries; -import java.util.Collections; -import java.util.function.Predicate; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; + +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.item.PromenadeItems; public class PromenadeItemGroupAdditions { - public static void appendItemGroups() { - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> e.addAfter(Blocks.ANDESITE, PromenadeBlocks.BLUNITE, PromenadeBlocks.ASPHALT)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.POLISHED_ANDESITE_SLAB, - PromenadeBlocks.BLUNITE, PromenadeBlocks.BLUNITE_SLAB, PromenadeBlocks.BLUNITE_STAIRS, PromenadeBlocks.BLUNITE_WALL, - PromenadeBlocks.POLISHED_BLUNITE, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, - PromenadeBlocks.ASPHALT, PromenadeBlocks.ASPHALT_SLAB, PromenadeBlocks.ASPHALT_STAIRS, PromenadeBlocks.ASPHALT_WALL, - PromenadeBlocks.POLISHED_ASPHALT, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.POLISHED_ASPHALT_STAIRS - )); - - - // VANILLA PILES - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, - PromenadeBlocks.OAK_LEAF_PILE, - PromenadeBlocks.SPRUCE_LEAF_PILE, - PromenadeBlocks.BIRCH_LEAF_PILE, - PromenadeBlocks.JUNGLE_LEAF_PILE, - PromenadeBlocks.ACACIA_LEAF_PILE, - PromenadeBlocks.CHERRY_LEAF_PILE, - PromenadeBlocks.DARK_OAK_LEAF_PILE, - PromenadeBlocks.PALE_OAK_LEAF_PILE, - PromenadeBlocks.MANGROVE_LEAF_PILE, - PromenadeBlocks.AZALEA_LEAF_PILE, - PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE - ); - - e.addAfter(Blocks.LILY_OF_THE_VALLEY, - PromenadeBlocks.DANDELION_PILE, - PromenadeBlocks.POPPY_PILE, - PromenadeBlocks.BLUE_ORCHID_PILE, - PromenadeBlocks.ALLIUM_PILE, - PromenadeBlocks.AZURE_BLUET_PILE, - PromenadeBlocks.RED_TULIP_PILE, - PromenadeBlocks.ORANGE_TULIP_PILE, - PromenadeBlocks.WHITE_TULIP_PILE, - PromenadeBlocks.PINK_TULIP_PILE, - PromenadeBlocks.OXEYE_DAISY_PILE, - PromenadeBlocks.CORNFLOWER_PILE, - PromenadeBlocks.LILY_OF_THE_VALLEY_PILE); - e.addAfter(Blocks.WITHER_ROSE, PromenadeBlocks.WITHER_ROSE_PILE); - }); - - // VANILLA SNOWY LEAVES - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(Blocks.OAK_LEAVES, PromenadeBlocks.SNOWY_OAK_LEAVES); - e.addAfter(Blocks.SPRUCE_LEAVES, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); - e.addAfter(Blocks.BIRCH_LEAVES, PromenadeBlocks.SNOWY_BIRCH_LEAVES); - e.addAfter(Blocks.JUNGLE_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES); - e.addAfter(Blocks.ACACIA_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES); - e.addAfter(Blocks.CHERRY_LEAVES, PromenadeBlocks.SNOWY_CHERRY_LEAVES); - e.addAfter(Blocks.DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES); - e.addAfter(Blocks.PALE_OAK_LEAVES, PromenadeBlocks.SNOWY_PALE_OAK_LEAVES); - e.addAfter(Blocks.MANGROVE_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES); - e.addAfter(Blocks.AZALEA_LEAVES, PromenadeBlocks.SNOWY_AZALEA_LEAVES); - e.addAfter(Blocks.FLOWERING_AZALEA_LEAVES, PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES); - }); - - // SAKURA - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.BIRCH_BUTTON, - PromenadeBlocks.SAKURA_LOG, - PromenadeBlocks.SAKURA_WOOD, - PromenadeBlocks.STRIPPED_SAKURA_LOG, - PromenadeBlocks.STRIPPED_SAKURA_WOOD, - PromenadeBlocks.SAKURA_PLANKS, - PromenadeBlocks.SAKURA_STAIRS, - PromenadeBlocks.SAKURA_SLAB, - PromenadeBlocks.SAKURA_FENCE, - PromenadeBlocks.SAKURA_FENCE_GATE, - PromenadeBlocks.SAKURA_DOOR, - PromenadeBlocks.SAKURA_TRAPDOOR, - PromenadeBlocks.SAKURA_PRESSURE_PLATE, - PromenadeBlocks.SAKURA_BUTTON - )); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(Blocks.BIRCH_LOG, PromenadeBlocks.SAKURA_LOG); - e.addAfter(PromenadeBlocks.SNOWY_BIRCH_LEAVES, - PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, - PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS - ); - e.addAfter(Blocks.BIRCH_SAPLING, PromenadeBlocks.BLUSH_SAKURA_SAPLING, PromenadeBlocks.COTTON_SAKURA_SAPLING); - e.addAfter(PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE); - }); - - // MAPLE - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> - e.addAfter(PromenadeBlocks.SAKURA_BUTTON, - PromenadeBlocks.MAPLE_LOG, - PromenadeBlocks.MAPLE_WOOD, - PromenadeBlocks.STRIPPED_MAPLE_LOG, - PromenadeBlocks.STRIPPED_MAPLE_WOOD, - PromenadeBlocks.MAPLE_PLANKS, - PromenadeBlocks.MAPLE_STAIRS, - PromenadeBlocks.MAPLE_SLAB, - PromenadeBlocks.MAPLE_FENCE, - PromenadeBlocks.MAPLE_FENCE_GATE, - PromenadeBlocks.MAPLE_DOOR, - PromenadeBlocks.MAPLE_TRAPDOOR, - PromenadeBlocks.MAPLE_PRESSURE_PLATE, - PromenadeBlocks.MAPLE_BUTTON)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(PromenadeBlocks.SAKURA_LOG, PromenadeBlocks.MAPLE_LOG); - e.addAfter(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, - PromenadeBlocks.SAP_MAPLE_LEAVES, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, - PromenadeBlocks.VERMILION_MAPLE_LEAVES, PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, - PromenadeBlocks.FULVOUS_MAPLE_LEAVES, PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, - PromenadeBlocks.MIKADO_MAPLE_LEAVES, PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES - ); - e.addAfter(PromenadeBlocks.COTTON_SAKURA_SAPLING, PromenadeBlocks.SAP_MAPLE_SAPLING, PromenadeBlocks.VERMILION_MAPLE_SAPLING, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, PromenadeBlocks.MIKADO_MAPLE_SAPLING); - e.addAfter(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE); - e.addAfter(Blocks.FLOWERING_AZALEA_LEAVES, - PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, - PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, - PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, - PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES - ); - }); - - // PALM - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> { - e.addAfter(Blocks.ACACIA_BUTTON, - PromenadeBlocks.PALM_LOG, - PromenadeBlocks.PALM_WOOD, - PromenadeBlocks.STRIPPED_PALM_LOG, - PromenadeBlocks.STRIPPED_PALM_WOOD, - PromenadeBlocks.PALM_PLANKS, - PromenadeBlocks.PALM_STAIRS, - PromenadeBlocks.PALM_SLAB, - PromenadeBlocks.PALM_FENCE, - PromenadeBlocks.PALM_FENCE_GATE, - PromenadeBlocks.PALM_DOOR, - PromenadeBlocks.PALM_TRAPDOOR, - PromenadeBlocks.PALM_PRESSURE_PLATE, - PromenadeBlocks.PALM_BUTTON); - }); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(Blocks.ACACIA_LOG, PromenadeBlocks.PALM_LOG); - e.addAfter(PromenadeBlocks.SNOWY_ACACIA_LEAVES, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_HANGING_LEAVES); - e.addAfter(Blocks.ACACIA_SAPLING, PromenadeBlocks.PALM_SAPLING); - e.addAfter(PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeBlocks.PALM_LEAF_PILE); - }); - - // AMARANTH - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.WARPED_BUTTON, - PromenadeBlocks.DARK_AMARANTH_STEM, - PromenadeBlocks.DARK_AMARANTH_HYPHAE, - PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM, - PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE, - PromenadeBlocks.DARK_AMARANTH_PLANKS, - PromenadeBlocks.DARK_AMARANTH_STAIRS, - PromenadeBlocks.DARK_AMARANTH_SLAB, - PromenadeBlocks.DARK_AMARANTH_FENCE, - PromenadeBlocks.DARK_AMARANTH_FENCE_GATE, - PromenadeBlocks.DARK_AMARANTH_DOOR, - PromenadeBlocks.DARK_AMARANTH_TRAPDOOR, - PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE, - PromenadeBlocks.DARK_AMARANTH_BUTTON)); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { - e.addAfter(Blocks.WARPED_NYLIUM, PromenadeBlocks.DARK_AMARANTH_NYLIUM); - e.addAfter(Blocks.WARPED_STEM, PromenadeBlocks.DARK_AMARANTH_STEM); - e.addAfter(Blocks.WARPED_WART_BLOCK, PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); - e.addAfter(Blocks.WARPED_FUNGUS, PromenadeBlocks.DARK_AMARANTH_FUNGUS); - e.addAfter(Blocks.WARPED_ROOTS, PromenadeBlocks.DARK_AMARANTH_ROOTS); - e.addAfter(Blocks.TWISTING_VINES, PromenadeBlocks.COILED_VINES); - e.addAfter(Blocks.SHROOMLIGHT, PromenadeBlocks.SOUL_SHROOMLIGHT); - }); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> { - e.addAfter(Blocks.SHROOMLIGHT, PromenadeBlocks.SOUL_SHROOMLIGHT); - }); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.CUT_RED_SANDSTONE_SLAB, PromenadeBlocks.MOAI)); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.BIRCH_HANGING_SIGN, PromenadeItems.SAKURA_SIGN, PromenadeItems.SAKURA_HANGING_SIGN)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(e -> e.addAfter(Items.BIRCH_CHEST_BOAT, PromenadeItems.SAKURA_BOAT, PromenadeItems.SAKURA_CHEST_BOAT)); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(PromenadeItems.SAKURA_HANGING_SIGN, PromenadeItems.MAPLE_SIGN, PromenadeItems.MAPLE_HANGING_SIGN)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(e -> e.addAfter(PromenadeItems.SAKURA_CHEST_BOAT, PromenadeItems.MAPLE_BOAT, PromenadeItems.MAPLE_CHEST_BOAT)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(e -> e.addAfter(Items.HONEY_BOTTLE, PromenadeItems.MAPLE_SYRUP_BOTTLE)); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.ACACIA_HANGING_SIGN, PromenadeItems.PALM_SIGN, PromenadeItems.PALM_HANGING_SIGN)); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(e -> e.addAfter(Items.ACACIA_CHEST_BOAT, PromenadeItems.PALM_BOAT, PromenadeItems.PALM_CHEST_BOAT)); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.WARPED_HANGING_SIGN, PromenadeItems.DARK_AMARANTH_SIGN, PromenadeItems.DARK_AMARANTH_HANGING_SIGN)); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(e -> { - e.addAfter(Items.SWEET_BERRIES, PromenadeItems.BLUEBERRIES); - e.addAfter(Items.ENCHANTED_GOLDEN_APPLE, PromenadeItems.BANANA); - //TODO apricot and mango - }); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(e -> e.addAfter(Items.COOKED_CHICKEN, PromenadeItems.DUCK, PromenadeItems.COOKED_DUCK)); - - ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(e -> e.addAfter(Items.FLOWER_BANNER_PATTERN, PromenadeItems.BOVINE_BANNER_PATTERN)); - - appendSpawnEgg(PromenadeItems.CAPYBARA_SPAWN_EGG); - appendSpawnEgg(PromenadeItems.DUCK_SPAWN_EGG); - appendSpawnEgg(PromenadeItems.LUSH_CREEPER_SPAWN_EGG); - appendSpawnEgg(PromenadeItems.SUNKEN_SPAWN_EGG); - } - - public static void appendSpawnEgg(Item spawnEgg) { - var itemGroup = Registries.ITEM_GROUP.get(ItemGroups.SPAWN_EGGS); - String path = Registries.ITEM.getId(spawnEgg).getPath(); - - if (itemGroup == null) { - return; - } - - Predicate predicate = stack1 -> { - String path1 = Registries.ITEM.getId(stack1.getItem()).getPath(); - for (ItemStack stack2 : itemGroup.getDisplayStacks()) { - String path2 = Registries.ITEM.getId(stack2.getItem()).getPath(); - if (path1.matches(".*_spawn_egg") && path2.matches(".*_spawn_egg")) { - // check if path is lexicographically between path1 and path2 - if (path.compareTo(path1) > 0 && path.compareTo(path2) < 0) { - return true; - } - } - } - return false; - }; - ItemGroupEvents.modifyEntriesEvent(ItemGroups.SPAWN_EGGS).register(e -> e.addAfter(predicate, Collections.singleton(new ItemStack(spawnEgg)), ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS)); - } + public static void appendItemGroups() { + ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> e.addAfter(Blocks.ANDESITE, PromenadeBlocks.BLUNITE, PromenadeBlocks.ASPHALT)); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.POLISHED_ANDESITE_SLAB, + PromenadeBlocks.BLUNITE, PromenadeBlocks.BLUNITE_SLAB, PromenadeBlocks.BLUNITE_STAIRS, PromenadeBlocks.BLUNITE_WALL, + PromenadeBlocks.POLISHED_BLUNITE, PromenadeBlocks.POLISHED_BLUNITE_SLAB, PromenadeBlocks.POLISHED_BLUNITE_STAIRS, + PromenadeBlocks.ASPHALT, PromenadeBlocks.ASPHALT_SLAB, PromenadeBlocks.ASPHALT_STAIRS, PromenadeBlocks.ASPHALT_WALL, + PromenadeBlocks.POLISHED_ASPHALT, PromenadeBlocks.POLISHED_ASPHALT_SLAB, PromenadeBlocks.POLISHED_ASPHALT_STAIRS + )); + + + // VANILLA PILES + ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { + e.addAfter(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, + PromenadeBlocks.OAK_LEAF_PILE, + PromenadeBlocks.SPRUCE_LEAF_PILE, + PromenadeBlocks.BIRCH_LEAF_PILE, + PromenadeBlocks.JUNGLE_LEAF_PILE, + PromenadeBlocks.ACACIA_LEAF_PILE, + PromenadeBlocks.CHERRY_LEAF_PILE, + PromenadeBlocks.DARK_OAK_LEAF_PILE, + PromenadeBlocks.PALE_OAK_LEAF_PILE, + PromenadeBlocks.MANGROVE_LEAF_PILE, + PromenadeBlocks.AZALEA_LEAF_PILE, + PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE + ); + + e.addAfter(Blocks.LILY_OF_THE_VALLEY, + PromenadeBlocks.DANDELION_PILE, + PromenadeBlocks.POPPY_PILE, + PromenadeBlocks.BLUE_ORCHID_PILE, + PromenadeBlocks.ALLIUM_PILE, + PromenadeBlocks.AZURE_BLUET_PILE, + PromenadeBlocks.RED_TULIP_PILE, + PromenadeBlocks.ORANGE_TULIP_PILE, + PromenadeBlocks.WHITE_TULIP_PILE, + PromenadeBlocks.PINK_TULIP_PILE, + PromenadeBlocks.OXEYE_DAISY_PILE, + PromenadeBlocks.CORNFLOWER_PILE, + PromenadeBlocks.LILY_OF_THE_VALLEY_PILE); + e.addAfter(Blocks.WITHER_ROSE, PromenadeBlocks.WITHER_ROSE_PILE); + }); + + // VANILLA SNOWY LEAVES + ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { + e.addAfter(Blocks.OAK_LEAVES, PromenadeBlocks.SNOWY_OAK_LEAVES); + e.addAfter(Blocks.SPRUCE_LEAVES, PromenadeBlocks.SNOWY_SPRUCE_LEAVES); + e.addAfter(Blocks.BIRCH_LEAVES, PromenadeBlocks.SNOWY_BIRCH_LEAVES); + e.addAfter(Blocks.JUNGLE_LEAVES, PromenadeBlocks.SNOWY_JUNGLE_LEAVES); + e.addAfter(Blocks.ACACIA_LEAVES, PromenadeBlocks.SNOWY_ACACIA_LEAVES); + e.addAfter(Blocks.CHERRY_LEAVES, PromenadeBlocks.SNOWY_CHERRY_LEAVES); + e.addAfter(Blocks.DARK_OAK_LEAVES, PromenadeBlocks.SNOWY_DARK_OAK_LEAVES); + e.addAfter(Blocks.PALE_OAK_LEAVES, PromenadeBlocks.SNOWY_PALE_OAK_LEAVES); + e.addAfter(Blocks.MANGROVE_LEAVES, PromenadeBlocks.SNOWY_MANGROVE_LEAVES); + e.addAfter(Blocks.AZALEA_LEAVES, PromenadeBlocks.SNOWY_AZALEA_LEAVES); + e.addAfter(Blocks.FLOWERING_AZALEA_LEAVES, PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES); + }); + + // SAKURA + ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.BIRCH_BUTTON, + PromenadeBlocks.SAKURA_LOG, + PromenadeBlocks.SAKURA_WOOD, + PromenadeBlocks.STRIPPED_SAKURA_LOG, + PromenadeBlocks.STRIPPED_SAKURA_WOOD, + PromenadeBlocks.SAKURA_PLANKS, + PromenadeBlocks.SAKURA_STAIRS, + PromenadeBlocks.SAKURA_SLAB, + PromenadeBlocks.SAKURA_FENCE, + PromenadeBlocks.SAKURA_FENCE_GATE, + PromenadeBlocks.SAKURA_DOOR, + PromenadeBlocks.SAKURA_TRAPDOOR, + PromenadeBlocks.SAKURA_PRESSURE_PLATE, + PromenadeBlocks.SAKURA_BUTTON + )); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { + e.addAfter(Blocks.BIRCH_LOG, PromenadeBlocks.SAKURA_LOG); + e.addAfter(PromenadeBlocks.SNOWY_BIRCH_LEAVES, + PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, + PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS + ); + e.addAfter(Blocks.BIRCH_SAPLING, PromenadeBlocks.BLUSH_SAKURA_SAPLING, PromenadeBlocks.COTTON_SAKURA_SAPLING); + e.addAfter(PromenadeBlocks.BIRCH_LEAF_PILE, PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE); + }); + + // MAPLE + ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> + e.addAfter(PromenadeBlocks.SAKURA_BUTTON, + PromenadeBlocks.MAPLE_LOG, + PromenadeBlocks.MAPLE_WOOD, + PromenadeBlocks.STRIPPED_MAPLE_LOG, + PromenadeBlocks.STRIPPED_MAPLE_WOOD, + PromenadeBlocks.MAPLE_PLANKS, + PromenadeBlocks.MAPLE_STAIRS, + PromenadeBlocks.MAPLE_SLAB, + PromenadeBlocks.MAPLE_FENCE, + PromenadeBlocks.MAPLE_FENCE_GATE, + PromenadeBlocks.MAPLE_DOOR, + PromenadeBlocks.MAPLE_TRAPDOOR, + PromenadeBlocks.MAPLE_PRESSURE_PLATE, + PromenadeBlocks.MAPLE_BUTTON)); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { + e.addAfter(PromenadeBlocks.SAKURA_LOG, PromenadeBlocks.MAPLE_LOG); + e.addAfter(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, + PromenadeBlocks.SAP_MAPLE_LEAVES, PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, + PromenadeBlocks.VERMILION_MAPLE_LEAVES, PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, + PromenadeBlocks.FULVOUS_MAPLE_LEAVES, PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, + PromenadeBlocks.MIKADO_MAPLE_LEAVES, PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES + ); + e.addAfter(PromenadeBlocks.COTTON_SAKURA_SAPLING, PromenadeBlocks.SAP_MAPLE_SAPLING, PromenadeBlocks.VERMILION_MAPLE_SAPLING, PromenadeBlocks.FULVOUS_MAPLE_SAPLING, PromenadeBlocks.MIKADO_MAPLE_SAPLING); + e.addAfter(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, PromenadeBlocks.SAP_MAPLE_LEAF_PILE, PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE); + e.addAfter(Blocks.FLOWERING_AZALEA_LEAVES, + PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, + PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, + PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, + PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES + ); + }); + + // PALM + ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> { + e.addAfter(Blocks.ACACIA_BUTTON, + PromenadeBlocks.PALM_LOG, + PromenadeBlocks.PALM_WOOD, + PromenadeBlocks.STRIPPED_PALM_LOG, + PromenadeBlocks.STRIPPED_PALM_WOOD, + PromenadeBlocks.PALM_PLANKS, + PromenadeBlocks.PALM_STAIRS, + PromenadeBlocks.PALM_SLAB, + PromenadeBlocks.PALM_FENCE, + PromenadeBlocks.PALM_FENCE_GATE, + PromenadeBlocks.PALM_DOOR, + PromenadeBlocks.PALM_TRAPDOOR, + PromenadeBlocks.PALM_PRESSURE_PLATE, + PromenadeBlocks.PALM_BUTTON); + }); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { + e.addAfter(Blocks.ACACIA_LOG, PromenadeBlocks.PALM_LOG); + e.addAfter(PromenadeBlocks.SNOWY_ACACIA_LEAVES, PromenadeBlocks.PALM_LEAVES, PromenadeBlocks.SNOWY_PALM_LEAVES, PromenadeBlocks.PALM_HANGING_LEAVES); + e.addAfter(Blocks.ACACIA_SAPLING, PromenadeBlocks.PALM_SAPLING); + e.addAfter(PromenadeBlocks.ACACIA_LEAF_PILE, PromenadeBlocks.PALM_LEAF_PILE); + }); + + // AMARANTH + ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.WARPED_BUTTON, + PromenadeBlocks.DARK_AMARANTH_STEM, + PromenadeBlocks.DARK_AMARANTH_HYPHAE, + PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM, + PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE, + PromenadeBlocks.DARK_AMARANTH_PLANKS, + PromenadeBlocks.DARK_AMARANTH_STAIRS, + PromenadeBlocks.DARK_AMARANTH_SLAB, + PromenadeBlocks.DARK_AMARANTH_FENCE, + PromenadeBlocks.DARK_AMARANTH_FENCE_GATE, + PromenadeBlocks.DARK_AMARANTH_DOOR, + PromenadeBlocks.DARK_AMARANTH_TRAPDOOR, + PromenadeBlocks.DARK_AMARANTH_PRESSURE_PLATE, + PromenadeBlocks.DARK_AMARANTH_BUTTON)); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register(e -> { + e.addAfter(Blocks.WARPED_NYLIUM, PromenadeBlocks.DARK_AMARANTH_NYLIUM); + e.addAfter(Blocks.WARPED_STEM, PromenadeBlocks.DARK_AMARANTH_STEM); + e.addAfter(Blocks.WARPED_WART_BLOCK, PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); + e.addAfter(Blocks.WARPED_FUNGUS, PromenadeBlocks.DARK_AMARANTH_FUNGUS); + e.addAfter(Blocks.WARPED_ROOTS, PromenadeBlocks.DARK_AMARANTH_ROOTS); + e.addAfter(Blocks.TWISTING_VINES, PromenadeBlocks.COILED_VINES); + e.addAfter(Blocks.SHROOMLIGHT, PromenadeBlocks.SOUL_SHROOMLIGHT); + }); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> { + e.addAfter(Blocks.SHROOMLIGHT, PromenadeBlocks.SOUL_SHROOMLIGHT); + }); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(e -> e.addAfter(Blocks.CUT_RED_SANDSTONE_SLAB, PromenadeBlocks.MOAI)); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.BIRCH_HANGING_SIGN, PromenadeItems.SAKURA_SIGN, PromenadeItems.SAKURA_HANGING_SIGN)); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(e -> e.addAfter(Items.BIRCH_CHEST_BOAT, PromenadeItems.SAKURA_BOAT, PromenadeItems.SAKURA_CHEST_BOAT)); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(PromenadeItems.SAKURA_HANGING_SIGN, PromenadeItems.MAPLE_SIGN, PromenadeItems.MAPLE_HANGING_SIGN)); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(e -> e.addAfter(PromenadeItems.SAKURA_CHEST_BOAT, PromenadeItems.MAPLE_BOAT, PromenadeItems.MAPLE_CHEST_BOAT)); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(e -> e.addAfter(Items.HONEY_BOTTLE, PromenadeItems.MAPLE_SYRUP_BOTTLE)); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.ACACIA_HANGING_SIGN, PromenadeItems.PALM_SIGN, PromenadeItems.PALM_HANGING_SIGN)); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(e -> e.addAfter(Items.ACACIA_CHEST_BOAT, PromenadeItems.PALM_BOAT, PromenadeItems.PALM_CHEST_BOAT)); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(e -> e.addAfter(Blocks.WARPED_HANGING_SIGN, PromenadeItems.DARK_AMARANTH_SIGN, PromenadeItems.DARK_AMARANTH_HANGING_SIGN)); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(e -> { + e.addAfter(Items.SWEET_BERRIES, PromenadeItems.BLUEBERRIES); + e.addAfter(Items.ENCHANTED_GOLDEN_APPLE, PromenadeItems.BANANA); + //TODO apricot and mango + }); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(e -> e.addAfter(Items.COOKED_CHICKEN, PromenadeItems.DUCK, PromenadeItems.COOKED_DUCK)); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(e -> e.addAfter(Items.FLOWER_BANNER_PATTERN, PromenadeItems.BOVINE_BANNER_PATTERN)); + + appendSpawnEgg(PromenadeItems.CAPYBARA_SPAWN_EGG); + appendSpawnEgg(PromenadeItems.DUCK_SPAWN_EGG); + appendSpawnEgg(PromenadeItems.LUSH_CREEPER_SPAWN_EGG); + appendSpawnEgg(PromenadeItems.SUNKEN_SPAWN_EGG); + } + + public static void appendSpawnEgg(Item spawnEgg) { + var itemGroup = Registries.ITEM_GROUP.get(ItemGroups.SPAWN_EGGS); + String path = Registries.ITEM.getId(spawnEgg).getPath(); + + if (itemGroup == null) { + return; + } + + Predicate predicate = stack1 -> { + String path1 = Registries.ITEM.getId(stack1.getItem()).getPath(); + for (ItemStack stack2 : itemGroup.getDisplayStacks()) { + String path2 = Registries.ITEM.getId(stack2.getItem()).getPath(); + if (path1.matches(".*_spawn_egg") && path2.matches(".*_spawn_egg")) { + // check if path is lexicographically between path1 and path2 + if (path.compareTo(path1) > 0 && path.compareTo(path2) < 0) { + return true; + } + } + } + return false; + }; + ItemGroupEvents.modifyEntriesEvent(ItemGroups.SPAWN_EGGS).register(e -> e.addAfter(predicate, Collections.singleton(new ItemStack(spawnEgg)), ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS)); + } } diff --git a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupKeys.java b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupKeys.java index a484695a..9ea51c79 100644 --- a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupKeys.java +++ b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroupKeys.java @@ -1,14 +1,26 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.itemgroup; -import fr.hugman.promenade.Promenade; import net.minecraft.item.ItemGroup; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; +import fr.hugman.promenade.Promenade; + public class PromenadeItemGroupKeys { - public static final RegistryKey PROMENADE = of("promenade"); + public static final RegistryKey PROMENADE = of("promenade"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.ITEM_GROUP, Promenade.id(path)); - } + private static RegistryKey of(String path) { + return RegistryKey.of(RegistryKeys.ITEM_GROUP, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroups.java b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroups.java index 10ce0bf3..02cb32ad 100644 --- a/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroups.java +++ b/src/main/java/fr/hugman/promenade/itemgroup/PromenadeItemGroups.java @@ -1,7 +1,16 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.itemgroup; -import fr.hugman.promenade.block.PromenadeBlocks; -import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.registry.Registries; @@ -9,14 +18,18 @@ import net.minecraft.registry.RegistryKey; import net.minecraft.text.Text; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; + +import fr.hugman.promenade.block.PromenadeBlocks; + public class PromenadeItemGroups { - public static final ItemGroup PROMENADE = of(PromenadeItemGroupKeys.PROMENADE, FabricItemGroup.builder() - .displayName(Text.translatable("item_group.promenade.promenade")) - .icon(() -> new ItemStack(PromenadeBlocks.BLUSH_SAKURA_SAPLING)) - .entries(PromenadeItemGroup::fill) - .build()); + public static final ItemGroup PROMENADE = of(PromenadeItemGroupKeys.PROMENADE, FabricItemGroup.builder() + .displayName(Text.translatable("item_group.promenade.promenade")) + .icon(() -> new ItemStack(PromenadeBlocks.BLUSH_SAKURA_SAPLING)) + .entries(PromenadeItemGroup::fill) + .build()); - private static ItemGroup of(RegistryKey key, ItemGroup itemGroup) { - return Registry.register(Registries.ITEM_GROUP, key, itemGroup); - } + private static ItemGroup of(RegistryKey key, ItemGroup itemGroup) { + return Registry.register(Registries.ITEM_GROUP, key, itemGroup); + } } diff --git a/src/main/java/fr/hugman/promenade/loot/PromenadeLootTables.java b/src/main/java/fr/hugman/promenade/loot/PromenadeLootTables.java index 1033c719..44eed3ce 100644 --- a/src/main/java/fr/hugman/promenade/loot/PromenadeLootTables.java +++ b/src/main/java/fr/hugman/promenade/loot/PromenadeLootTables.java @@ -1,21 +1,33 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.loot; -import fr.hugman.promenade.Promenade; import net.minecraft.loot.LootTable; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; +import fr.hugman.promenade.Promenade; + public class PromenadeLootTables { - public static final RegistryKey TUBE_SUNKEN = of("entities/sunken/tube"); - public static final RegistryKey BRAIN_SUNKEN = of("entities/sunken/brain"); - public static final RegistryKey BUBBLE_SUNKEN = of("entities/sunken/bubble"); - public static final RegistryKey FIRE_SUNKEN = of("entities/sunken/fire"); - public static final RegistryKey HORN_SUNKEN = of("entities/sunken/horn"); + public static final RegistryKey TUBE_SUNKEN = of("entities/sunken/tube"); + public static final RegistryKey BRAIN_SUNKEN = of("entities/sunken/brain"); + public static final RegistryKey BUBBLE_SUNKEN = of("entities/sunken/bubble"); + public static final RegistryKey FIRE_SUNKEN = of("entities/sunken/fire"); + public static final RegistryKey HORN_SUNKEN = of("entities/sunken/horn"); - public static final RegistryKey WITCH_HUT_CHEST = of("chests/witch_hut"); + public static final RegistryKey WITCH_HUT_CHEST = of("chests/witch_hut"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.LOOT_TABLE, Promenade.id(path)); - } + private static RegistryKey of(String path) { + return RegistryKey.of(RegistryKeys.LOOT_TABLE, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/mixin/AxeItemMixin.java b/src/main/java/fr/hugman/promenade/mixin/AxeItemMixin.java index dee67209..e6bdcf94 100644 --- a/src/main/java/fr/hugman/promenade/mixin/AxeItemMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/AxeItemMixin.java @@ -1,27 +1,40 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.mixin; -import fr.hugman.promenade.block.MapleLogBlock; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.block.StrippedMapleLogBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.PillarBlock; -import net.minecraft.item.AxeItem; +import java.util.Optional; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Optional; +import net.minecraft.block.BlockState; +import net.minecraft.block.PillarBlock; +import net.minecraft.item.AxeItem; + +import fr.hugman.promenade.block.MapleLogBlock; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.block.StrippedMapleLogBlock; @Mixin(AxeItem.class) public class AxeItemMixin { - @Inject(method = "getStrippedState", at = @At("RETURN"), cancellable = true) - private void promenade$appendCustomStrip(BlockState state, CallbackInfoReturnable> cir) { - if (state.getBlock() == PromenadeBlocks.MAPLE_LOG) { - // if the log is natural, it has a 10% chance to be stripped into a stripped log with the state "has_syrup" set to true - cir.setReturnValue(Optional.of(PromenadeBlocks.STRIPPED_MAPLE_LOG.getDefaultState() - .with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)) - .with(StrippedMapleLogBlock.DRIP, state.get(MapleLogBlock.NATURAL) && Math.random() < 0.1f))); - } - } + @Inject(method = "getStrippedState", at = @At("RETURN"), cancellable = true) + private void promenade$appendCustomStrip(BlockState state, CallbackInfoReturnable> cir) { + if (state.getBlock() == PromenadeBlocks.MAPLE_LOG) { + // if the log is natural, it has a 10% chance to be stripped into a stripped log with the state "has_syrup" set to true + cir.setReturnValue(Optional.of(PromenadeBlocks.STRIPPED_MAPLE_LOG.getDefaultState() + .with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)) + .with(StrippedMapleLogBlock.DRIP, state.get(MapleLogBlock.NATURAL) && Math.random() < 0.1f))); + } + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/mixin/FallLocationMixin.java b/src/main/java/fr/hugman/promenade/mixin/FallLocationMixin.java index 2322fe61..89a0dac8 100644 --- a/src/main/java/fr/hugman/promenade/mixin/FallLocationMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/FallLocationMixin.java @@ -1,20 +1,33 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.mixin; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.entity.damage.PromenadeFallLocations; -import net.minecraft.block.BlockState; -import net.minecraft.entity.damage.FallLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.block.BlockState; +import net.minecraft.entity.damage.FallLocation; + +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.entity.damage.PromenadeFallLocations; + @Mixin(FallLocation.class) public class FallLocationMixin { - @Inject(method = "fromBlockState", at = @At("HEAD"), cancellable = true) - private static void promenade$fromBlockState(BlockState state, CallbackInfoReturnable cir) { - if (state.isOf(PromenadeBlocks.COILED_VINES) || state.isOf(PromenadeBlocks.COILED_VINES_PLANT)) { - cir.setReturnValue(PromenadeFallLocations.COILED_VINES); - } - } + @Inject(method = "fromBlockState", at = @At("HEAD"), cancellable = true) + private static void promenade$fromBlockState(BlockState state, CallbackInfoReturnable cir) { + if (state.isOf(PromenadeBlocks.COILED_VINES) || state.isOf(PromenadeBlocks.COILED_VINES_PLANT)) { + cir.setReturnValue(PromenadeFallLocations.COILED_VINES); + } + } } diff --git a/src/main/java/fr/hugman/promenade/mixin/LivingEntityMixin.java b/src/main/java/fr/hugman/promenade/mixin/LivingEntityMixin.java index 744abf30..b0472ed2 100644 --- a/src/main/java/fr/hugman/promenade/mixin/LivingEntityMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/LivingEntityMixin.java @@ -1,26 +1,39 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.mixin; -import fr.hugman.promenade.world.biome.PromenadeBiomes; -import net.minecraft.entity.LivingEntity; -import net.minecraft.registry.tag.EntityTypeTags; -import net.minecraft.server.world.ServerWorld; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import net.minecraft.entity.LivingEntity; +import net.minecraft.registry.tag.EntityTypeTags; +import net.minecraft.server.world.ServerWorld; + +import fr.hugman.promenade.world.biome.PromenadeBiomes; + @Mixin(LivingEntity.class) public class LivingEntityMixin { - @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;setFrozenTicks(I)V", ordinal = 0), cancellable = true) - private void promenade$tickMovement(CallbackInfo ci) { - LivingEntity entity = (LivingEntity) (Object) this; - int frozenTicks = entity.getFrozenTicks(); - if (entity.getEntityWorld() instanceof ServerWorld serverWorld && PromenadeBiomes.canFreezeFromBiomeAndWeather(entity)) { - entity.setFrozenTicks(Math.min(entity.getMinFreezeDamageTicks(), frozenTicks + 1)); - if (entity.age % 40 == 0 && entity.isFrozen()) { - entity.damage(serverWorld, entity.getDamageSources().freeze(), entity.getType().isIn(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES) ? 5 : 1); - } - ci.cancel(); - } - } + @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;setFrozenTicks(I)V", ordinal = 0), cancellable = true) + private void promenade$tickMovement(CallbackInfo ci) { + LivingEntity entity = (LivingEntity) (Object) this; + int frozenTicks = entity.getFrozenTicks(); + if (entity.getEntityWorld() instanceof ServerWorld serverWorld && PromenadeBiomes.canFreezeFromBiomeAndWeather(entity)) { + entity.setFrozenTicks(Math.min(entity.getMinFreezeDamageTicks(), frozenTicks + 1)); + if (entity.age % 40 == 0 && entity.isFrozen()) { + entity.damage(serverWorld, entity.getDamageSources().freeze(), entity.getType().isIn(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES) ? 5 : 1); + } + ci.cancel(); + } + } } diff --git a/src/main/java/fr/hugman/promenade/mixin/NetherrackBlockMixin.java b/src/main/java/fr/hugman/promenade/mixin/NetherrackBlockMixin.java index 144cd72d..ee9cb1c0 100644 --- a/src/main/java/fr/hugman/promenade/mixin/NetherrackBlockMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/NetherrackBlockMixin.java @@ -1,6 +1,25 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.mixin; -import fr.hugman.promenade.block.PromenadeBlocks; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -8,53 +27,47 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; +import fr.hugman.promenade.block.PromenadeBlocks; @Mixin(NetherrackBlock.class) public abstract class NetherrackBlockMixin { - @Inject(method = "grow", at = @At("HEAD"), cancellable = true) - public void promenade$grow(ServerWorld world, Random random, BlockPos pos, BlockState state, CallbackInfo ci) { - boolean crimson = false; - boolean warped = false; - boolean darkAmaranth = false; - - for (BlockPos blockPos : BlockPos.iterate(pos.add(-1, -1, -1), pos.add(1, 1, 1))) { - BlockState blockState = world.getBlockState(blockPos); - if (blockState.isOf(Blocks.WARPED_NYLIUM)) { - warped = true; - } - - if (blockState.isOf(Blocks.CRIMSON_NYLIUM)) { - crimson = true; - } - - if (blockState.isOf(PromenadeBlocks.DARK_AMARANTH_NYLIUM)) { - darkAmaranth = true; - } - - if (warped && crimson && darkAmaranth) { - break; - } - } - - if (warped || crimson || darkAmaranth) { - BlockState[] options = { - warped ? Blocks.WARPED_NYLIUM.getDefaultState() : null, - crimson ? Blocks.CRIMSON_NYLIUM.getDefaultState() : null, - darkAmaranth ? PromenadeBlocks.DARK_AMARANTH_NYLIUM.getDefaultState() : null - }; - - List available = Arrays.stream(options).filter(Objects::nonNull).toList(); - world.setBlockState(pos, available.get(random.nextInt(available.size())), Block.NOTIFY_ALL); - } - - ci.cancel(); - } + @Inject(method = "grow", at = @At("HEAD"), cancellable = true) + public void promenade$grow(ServerWorld world, Random random, BlockPos pos, BlockState state, CallbackInfo ci) { + boolean crimson = false; + boolean warped = false; + boolean darkAmaranth = false; + + for (BlockPos blockPos : BlockPos.iterate(pos.add(-1, -1, -1), pos.add(1, 1, 1))) { + BlockState blockState = world.getBlockState(blockPos); + if (blockState.isOf(Blocks.WARPED_NYLIUM)) { + warped = true; + } + + if (blockState.isOf(Blocks.CRIMSON_NYLIUM)) { + crimson = true; + } + + if (blockState.isOf(PromenadeBlocks.DARK_AMARANTH_NYLIUM)) { + darkAmaranth = true; + } + + if (warped && crimson && darkAmaranth) { + break; + } + } + + if (warped || crimson || darkAmaranth) { + BlockState[] options = { + warped ? Blocks.WARPED_NYLIUM.getDefaultState() : null, + crimson ? Blocks.CRIMSON_NYLIUM.getDefaultState() : null, + darkAmaranth ? PromenadeBlocks.DARK_AMARANTH_NYLIUM.getDefaultState() : null + }; + + List available = Arrays.stream(options).filter(Objects::nonNull).toList(); + world.setBlockState(pos, available.get(random.nextInt(available.size())), Block.NOTIFY_ALL); + } + + ci.cancel(); + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/mixin/ShearsItemMixin.java b/src/main/java/fr/hugman/promenade/mixin/ShearsItemMixin.java index 1753e6d8..cc6abcad 100644 --- a/src/main/java/fr/hugman/promenade/mixin/ShearsItemMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/ShearsItemMixin.java @@ -1,6 +1,21 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.mixin; -import fr.hugman.promenade.block.AbstractFacingPlantStemBlock; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + import net.minecraft.advancement.criterion.Criteria; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; @@ -14,34 +29,32 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.event.GameEvent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import fr.hugman.promenade.block.AbstractFacingPlantStemBlock; @Mixin(ShearsItem.class) public class ShearsItemMixin { - @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true) - public void promenade$useOnBlock(ItemUsageContext context, CallbackInfoReturnable cir) { - World world = context.getWorld(); - BlockPos blockPos = context.getBlockPos(); - BlockState blockState = world.getBlockState(blockPos); - if (blockState.getBlock() instanceof AbstractFacingPlantStemBlock stem && !stem.hasMaxAge(blockState)) { - PlayerEntity playerEntity = context.getPlayer(); - ItemStack itemStack = context.getStack(); - if (playerEntity instanceof ServerPlayerEntity) { - Criteria.ITEM_USED_ON_BLOCK.trigger((ServerPlayerEntity) playerEntity, blockPos, itemStack); - } + @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true) + public void promenade$useOnBlock(ItemUsageContext context, CallbackInfoReturnable cir) { + World world = context.getWorld(); + BlockPos blockPos = context.getBlockPos(); + BlockState blockState = world.getBlockState(blockPos); + if (blockState.getBlock() instanceof AbstractFacingPlantStemBlock stem && !stem.hasMaxAge(blockState)) { + PlayerEntity playerEntity = context.getPlayer(); + ItemStack itemStack = context.getStack(); + if (playerEntity instanceof ServerPlayerEntity) { + Criteria.ITEM_USED_ON_BLOCK.trigger((ServerPlayerEntity) playerEntity, blockPos, itemStack); + } - world.playSound(playerEntity, blockPos, SoundEvents.BLOCK_GROWING_PLANT_CROP, SoundCategory.BLOCKS, 1.0F, 1.0F); - BlockState blockState2 = stem.withMaxAge(blockState); - world.setBlockState(blockPos, blockState2); - world.emitGameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Emitter.of(context.getPlayer(), blockState2)); - if (playerEntity != null) { - itemStack.damage(1, playerEntity, context.getHand()); - } + world.playSound(playerEntity, blockPos, SoundEvents.BLOCK_GROWING_PLANT_CROP, SoundCategory.BLOCKS, 1.0F, 1.0F); + BlockState blockState2 = stem.withMaxAge(blockState); + world.setBlockState(blockPos, blockState2); + world.emitGameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Emitter.of(context.getPlayer(), blockState2)); + if (playerEntity != null) { + itemStack.damage(1, playerEntity, context.getHand()); + } - cir.setReturnValue(ActionResult.SUCCESS); - } - } + cir.setReturnValue(ActionResult.SUCCESS); + } + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/mixin/SnowBlockMixin.java b/src/main/java/fr/hugman/promenade/mixin/SnowBlockMixin.java index a3d2480c..4f720815 100644 --- a/src/main/java/fr/hugman/promenade/mixin/SnowBlockMixin.java +++ b/src/main/java/fr/hugman/promenade/mixin/SnowBlockMixin.java @@ -1,8 +1,26 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.mixin; -import fr.hugman.promenade.block.SnowyLeavesBlock; -import fr.hugman.promenade.registry.PromenadeRegistryKeys; -import fr.hugman.promenade.world.PromenadeGameRules; +import java.util.Optional; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.SnowBlock; @@ -12,81 +30,80 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.random.Random; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Optional; +import fr.hugman.promenade.block.SnowyLeavesBlock; +import fr.hugman.promenade.registry.PromenadeRegistryKeys; +import fr.hugman.promenade.world.PromenadeGameRules; @Mixin(SnowBlock.class) public class SnowBlockMixin { - @Shadow @Final public static IntProperty LAYERS; + @Shadow + @Final + public static IntProperty LAYERS; - @Inject(method = "randomTick", at = @At("HEAD"), cancellable = true) - private void promenade$randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { - if (!world.getGameRules().getBoolean(PromenadeGameRules.DO_BLOCKS_GET_SNOWY)) { - return; - } - if(state.get(LAYERS) == 8 && world.getBlockState(pos.up()).isOf((SnowBlock)(Object)this)) { - return; - } - var downPos = findNextBottomSnowyBlock(world, pos); - if(downPos.isEmpty()) { - return; - } - var downState = world.getBlockState(downPos.get()); - var snowyLeaves = world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().filter( - entry -> entry.baseBlocks().contains(downState.getBlock().getRegistryEntry()) - ).findFirst().map(sbt -> sbt.snowyBlock().value()).orElse(null); + @Inject(method = "randomTick", at = @At("HEAD"), cancellable = true) + private void promenade$randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo ci) { + if (!world.getGameRules().getBoolean(PromenadeGameRules.DO_BLOCKS_GET_SNOWY)) { + return; + } + if (state.get(LAYERS) == 8 && world.getBlockState(pos.up()).isOf((SnowBlock) (Object) this)) { + return; + } + var downPos = findNextBottomSnowyBlock(world, pos); + if (downPos.isEmpty()) { + return; + } + var downState = world.getBlockState(downPos.get()); + var snowyLeaves = world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().filter( + entry -> entry.baseBlocks().contains(downState.getBlock().getRegistryEntry()) + ).findFirst().map(sbt -> sbt.snowyBlock().value()).orElse(null); - if(snowyLeaves != null) { - var layers = state.get(LAYERS) - 1; - var newLeavesState = snowyLeaves.getDefaultState(); - // copy properties of snowy block - for (Property property : downState.getProperties()) { - newLeavesState = newLeavesState.contains(property) ? newLeavesState.with(property, downState.get(property)) : newLeavesState; - } - newLeavesState = newLeavesState.contains(SnowyLeavesBlock.BOTTOM) ? newLeavesState.with(SnowyLeavesBlock.BOTTOM, true) : newLeavesState; - if(layers < 1) { - world.setBlockState(pos, Blocks.AIR.getDefaultState()); - } - else { - world.setBlockState(pos, state.with(LAYERS, layers)); - } - world.setBlockState(downPos.get(), newLeavesState); - ci.cancel(); - } - } + if (snowyLeaves != null) { + var layers = state.get(LAYERS) - 1; + var newLeavesState = snowyLeaves.getDefaultState(); + // copy properties of snowy block + for (Property property : downState.getProperties()) { + newLeavesState = newLeavesState.contains(property) ? newLeavesState.with(property, downState.get(property)) : newLeavesState; + } + newLeavesState = newLeavesState.contains(SnowyLeavesBlock.BOTTOM) ? newLeavesState.with(SnowyLeavesBlock.BOTTOM, true) : newLeavesState; + if (layers < 1) { + world.setBlockState(pos, Blocks.AIR.getDefaultState()); + } else { + world.setBlockState(pos, state.with(LAYERS, layers)); + } + world.setBlockState(downPos.get(), newLeavesState); + ci.cancel(); + } + } - @Unique - private Optional findNextBottomSnowyBlock(ServerWorld world, BlockPos pos) { - BlockPos.Mutable mutable = pos.mutableCopy(); + @Unique + private Optional findNextBottomSnowyBlock(ServerWorld world, BlockPos pos) { + BlockPos.Mutable mutable = pos.mutableCopy(); - BlockState blockState; - do { - mutable.move(Direction.DOWN); - blockState = world.getBlockState(mutable); - } while (isFullSnowyBlock(world, blockState)); + BlockState blockState; + do { + mutable.move(Direction.DOWN); + blockState = world.getBlockState(mutable); + } while (isFullSnowyBlock(world, blockState)); - var block = blockState.getBlock(); - return world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().anyMatch( - entry -> entry.baseBlocks().contains(block.getRegistryEntry()) - ) ? Optional.of(mutable) : Optional.empty(); - } + var block = blockState.getBlock(); + return world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().anyMatch( + entry -> entry.baseBlocks().contains(block.getRegistryEntry()) + ) ? Optional.of(mutable) : Optional.empty(); + } - @Unique - private boolean isFullSnowyBlock(ServerWorld world, BlockState state) { - var block = state.getBlock(); - if (world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().anyMatch( - entry -> entry.snowyBlock().matches(block.getRegistryEntry()) - )) return true; - if(state.isOf(Blocks.SNOW_BLOCK) || state.isOf(Blocks.POWDER_SNOW)) return true; - if(state.isOf(Blocks.SNOW) && state.contains(LAYERS) && state.get(LAYERS) == 8) return true; - return false; - } + @Unique + private boolean isFullSnowyBlock(ServerWorld world, BlockState state) { + var block = state.getBlock(); + if (world.getRegistryManager().getOrThrow(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION).stream().anyMatch( + entry -> entry.snowyBlock().matches(block.getRegistryEntry()) + )) + return true; + if (state.isOf(Blocks.SNOW_BLOCK) || state.isOf(Blocks.POWDER_SNOW)) + return true; + if (state.isOf(Blocks.SNOW) && state.contains(LAYERS) && state.get(LAYERS) == 8) + return true; + return false; + } } diff --git a/src/main/java/fr/hugman/promenade/particle/PromenadeParticleTypes.java b/src/main/java/fr/hugman/promenade/particle/PromenadeParticleTypes.java index 2e4e4c58..3fafab14 100644 --- a/src/main/java/fr/hugman/promenade/particle/PromenadeParticleTypes.java +++ b/src/main/java/fr/hugman/promenade/particle/PromenadeParticleTypes.java @@ -1,21 +1,34 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.particle; -import fr.hugman.promenade.Promenade; -import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; import net.minecraft.particle.ParticleType; import net.minecraft.particle.SimpleParticleType; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; + +import fr.hugman.promenade.Promenade; + public class PromenadeParticleTypes { - public static final SimpleParticleType BLUSH_SAKURA_BLOSSOM = register("blush_sakura_blossom", FabricParticleTypes.simple()); - public static final SimpleParticleType COTTON_SAKURA_BLOSSOM = register("cotton_sakura_blossom", FabricParticleTypes.simple()); + public static final SimpleParticleType BLUSH_SAKURA_BLOSSOM = register("blush_sakura_blossom", FabricParticleTypes.simple()); + public static final SimpleParticleType COTTON_SAKURA_BLOSSOM = register("cotton_sakura_blossom", FabricParticleTypes.simple()); - public static final SimpleParticleType VERMILION_MAPLE_LEAF = register("vermilion_maple_leaf", FabricParticleTypes.simple()); - public static final SimpleParticleType FULVOUS_MAPLE_LEAF = register("fulvous_maple_leaf", FabricParticleTypes.simple()); - public static final SimpleParticleType MIKADO_MAPLE_LEAF = register("mikado_maple_leaf", FabricParticleTypes.simple()); + public static final SimpleParticleType VERMILION_MAPLE_LEAF = register("vermilion_maple_leaf", FabricParticleTypes.simple()); + public static final SimpleParticleType FULVOUS_MAPLE_LEAF = register("fulvous_maple_leaf", FabricParticleTypes.simple()); + public static final SimpleParticleType MIKADO_MAPLE_LEAF = register("mikado_maple_leaf", FabricParticleTypes.simple()); - public static > B register(String path, B particleType) { - return Registry.register(Registries.PARTICLE_TYPE, Promenade.id(path), particleType); - } + public static > B register(String path, B particleType) { + return Registry.register(Registries.PARTICLE_TYPE, Promenade.id(path), particleType); + } } diff --git a/src/main/java/fr/hugman/promenade/registry/PromenadeCompostingChances.java b/src/main/java/fr/hugman/promenade/registry/PromenadeCompostingChances.java index 59931413..a2068ff9 100644 --- a/src/main/java/fr/hugman/promenade/registry/PromenadeCompostingChances.java +++ b/src/main/java/fr/hugman/promenade/registry/PromenadeCompostingChances.java @@ -1,97 +1,109 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.registry; +import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; + import fr.hugman.promenade.block.PromenadeBlocks; import fr.hugman.promenade.item.PromenadeItems; -import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; public class PromenadeCompostingChances { - public static void register() { - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.OAK_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SPRUCE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BIRCH_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.JUNGLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.ACACIA_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.CHERRY_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_OAK_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALE_OAK_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MANGROVE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.AZALEA_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, 0.5F); + public static void register() { + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.OAK_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SPRUCE_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BIRCH_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.JUNGLE_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.ACACIA_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.CHERRY_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_OAK_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALE_OAK_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MANGROVE_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.AZALEA_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, 0.5F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DANDELION_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.POPPY_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUE_ORCHID_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.ALLIUM_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.AZURE_BLUET_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.RED_TULIP_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.ORANGE_TULIP_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.WHITE_TULIP_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PINK_TULIP_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.OXEYE_DAISY_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.CORNFLOWER_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.WITHER_ROSE_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DANDELION_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.POPPY_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUE_ORCHID_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.ALLIUM_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.AZURE_BLUET_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.RED_TULIP_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.ORANGE_TULIP_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.WHITE_TULIP_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PINK_TULIP_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.OXEYE_DAISY_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.CORNFLOWER_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.WITHER_ROSE_PILE, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_OAK_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_BIRCH_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_ACACIA_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_CHERRY_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_AZALEA_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_OAK_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_BIRCH_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_ACACIA_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_CHERRY_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_AZALEA_LEAVES, 0.3f); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, 0.3f); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_SAPLING, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_SAPLING, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_SAPLING, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_SAPLING, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_SAPLING, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_SAPLING, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_SAPLING, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_PALM_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_HANGING_LEAVES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_LEAF_PILE, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_SAPLING, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SNOWY_PALM_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_HANGING_LEAVES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.PALM_LEAF_PILE, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_ROOTS, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK, 0.85F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_FUNGUS, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_ROOTS, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK, 0.85F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.DARK_AMARANTH_FUNGUS, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SOUL_SHROOMLIGHT, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.SOUL_SHROOMLIGHT, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COILED_VINES, 0.5F); + CompostingChanceRegistry.INSTANCE.add(PromenadeBlocks.COILED_VINES, 0.5F); - CompostingChanceRegistry.INSTANCE.add(PromenadeItems.BLUEBERRIES, 0.3F); + CompostingChanceRegistry.INSTANCE.add(PromenadeItems.BLUEBERRIES, 0.3F); - CompostingChanceRegistry.INSTANCE.add(PromenadeItems.BANANA, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeItems.APRICOT, 0.65F); - CompostingChanceRegistry.INSTANCE.add(PromenadeItems.MANGO, 0.65F); - } + CompostingChanceRegistry.INSTANCE.add(PromenadeItems.BANANA, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeItems.APRICOT, 0.65F); + CompostingChanceRegistry.INSTANCE.add(PromenadeItems.MANGO, 0.65F); + } } diff --git a/src/main/java/fr/hugman/promenade/registry/PromenadeFlammables.java b/src/main/java/fr/hugman/promenade/registry/PromenadeFlammables.java index 5f81828c..71fb8c64 100644 --- a/src/main/java/fr/hugman/promenade/registry/PromenadeFlammables.java +++ b/src/main/java/fr/hugman/promenade/registry/PromenadeFlammables.java @@ -1,106 +1,118 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.registry; -import fr.hugman.promenade.block.PromenadeBlocks; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; +import fr.hugman.promenade.block.PromenadeBlocks; + public class PromenadeFlammables { - public static void register() { - var fire = FlammableBlockRegistry.getDefaultInstance(); + public static void register() { + var fire = FlammableBlockRegistry.getDefaultInstance(); - fire.add(PromenadeBlocks.OAK_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.SPRUCE_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.BIRCH_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.JUNGLE_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.ACACIA_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.CHERRY_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.DARK_OAK_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.PALE_OAK_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.MANGROVE_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.AZALEA_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.OAK_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.SPRUCE_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.BIRCH_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.JUNGLE_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.ACACIA_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.CHERRY_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.DARK_OAK_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.PALE_OAK_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.MANGROVE_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.AZALEA_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.FLOWERING_AZALEA_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.DANDELION_PILE, 60, 100); - fire.add(PromenadeBlocks.POPPY_PILE, 60, 100); - fire.add(PromenadeBlocks.BLUE_ORCHID_PILE, 60, 100); - fire.add(PromenadeBlocks.ALLIUM_PILE, 60, 100); - fire.add(PromenadeBlocks.AZURE_BLUET_PILE, 60, 100); - fire.add(PromenadeBlocks.RED_TULIP_PILE, 60, 100); - fire.add(PromenadeBlocks.ORANGE_TULIP_PILE, 60, 100); - fire.add(PromenadeBlocks.WHITE_TULIP_PILE, 60, 100); - fire.add(PromenadeBlocks.PINK_TULIP_PILE, 60, 100); - fire.add(PromenadeBlocks.OXEYE_DAISY_PILE, 60, 100); - fire.add(PromenadeBlocks.CORNFLOWER_PILE, 60, 100); - fire.add(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, 60, 100); - fire.add(PromenadeBlocks.WITHER_ROSE_PILE, 60, 100); + fire.add(PromenadeBlocks.DANDELION_PILE, 60, 100); + fire.add(PromenadeBlocks.POPPY_PILE, 60, 100); + fire.add(PromenadeBlocks.BLUE_ORCHID_PILE, 60, 100); + fire.add(PromenadeBlocks.ALLIUM_PILE, 60, 100); + fire.add(PromenadeBlocks.AZURE_BLUET_PILE, 60, 100); + fire.add(PromenadeBlocks.RED_TULIP_PILE, 60, 100); + fire.add(PromenadeBlocks.ORANGE_TULIP_PILE, 60, 100); + fire.add(PromenadeBlocks.WHITE_TULIP_PILE, 60, 100); + fire.add(PromenadeBlocks.PINK_TULIP_PILE, 60, 100); + fire.add(PromenadeBlocks.OXEYE_DAISY_PILE, 60, 100); + fire.add(PromenadeBlocks.CORNFLOWER_PILE, 60, 100); + fire.add(PromenadeBlocks.LILY_OF_THE_VALLEY_PILE, 60, 100); + fire.add(PromenadeBlocks.WITHER_ROSE_PILE, 60, 100); - fire.add(PromenadeBlocks.SNOWY_OAK_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_BIRCH_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_ACACIA_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_CHERRY_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_AZALEA_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_OAK_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_SPRUCE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_BIRCH_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_JUNGLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_ACACIA_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_CHERRY_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_DARK_OAK_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_PALE_OAK_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_MANGROVE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_AZALEA_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_FLOWERING_AZALEA_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SAKURA_LOG, 5, 5); - fire.add(PromenadeBlocks.STRIPPED_SAKURA_LOG, 5, 5); - fire.add(PromenadeBlocks.SAKURA_WOOD, 5, 5); - fire.add(PromenadeBlocks.STRIPPED_SAKURA_WOOD, 5, 5); - fire.add(PromenadeBlocks.SAKURA_PLANKS, 5, 20); - fire.add(PromenadeBlocks.SAKURA_STAIRS, 5, 20); - fire.add(PromenadeBlocks.SAKURA_SLAB, 5, 20); - fire.add(PromenadeBlocks.SAKURA_FENCE, 5, 20); - fire.add(PromenadeBlocks.SAKURA_FENCE_GATE, 5, 20); - fire.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, 30, 60); - fire.add(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, 30, 60); - fire.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, 30, 60); - fire.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, 30, 60); - fire.add(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, 30, 60); - fire.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, 30, 60); + fire.add(PromenadeBlocks.SAKURA_LOG, 5, 5); + fire.add(PromenadeBlocks.STRIPPED_SAKURA_LOG, 5, 5); + fire.add(PromenadeBlocks.SAKURA_WOOD, 5, 5); + fire.add(PromenadeBlocks.STRIPPED_SAKURA_WOOD, 5, 5); + fire.add(PromenadeBlocks.SAKURA_PLANKS, 5, 20); + fire.add(PromenadeBlocks.SAKURA_STAIRS, 5, 20); + fire.add(PromenadeBlocks.SAKURA_SLAB, 5, 20); + fire.add(PromenadeBlocks.SAKURA_FENCE, 5, 20); + fire.add(PromenadeBlocks.SAKURA_FENCE_GATE, 5, 20); + fire.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOMS, 30, 60); + fire.add(PromenadeBlocks.SNOWY_BLUSH_SAKURA_BLOSSOMS, 30, 60); + fire.add(PromenadeBlocks.BLUSH_SAKURA_BLOSSOM_PILE, 30, 60); + fire.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOMS, 30, 60); + fire.add(PromenadeBlocks.SNOWY_COTTON_SAKURA_BLOSSOMS, 30, 60); + fire.add(PromenadeBlocks.COTTON_SAKURA_BLOSSOM_PILE, 30, 60); - fire.add(PromenadeBlocks.MAPLE_LOG, 5, 5); - fire.add(PromenadeBlocks.STRIPPED_MAPLE_LOG, 5, 5); - fire.add(PromenadeBlocks.MAPLE_WOOD, 5, 5); - fire.add(PromenadeBlocks.STRIPPED_MAPLE_WOOD, 5, 5); - fire.add(PromenadeBlocks.MAPLE_PLANKS, 5, 20); - fire.add(PromenadeBlocks.MAPLE_STAIRS, 5, 20); - fire.add(PromenadeBlocks.MAPLE_SLAB, 5, 20); - fire.add(PromenadeBlocks.MAPLE_FENCE, 5, 20); - fire.add(PromenadeBlocks.MAPLE_FENCE_GATE, 5, 20); - fire.add(PromenadeBlocks.SAP_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.VERMILION_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.MIKADO_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 30, 60); - fire.add(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.MAPLE_LOG, 5, 5); + fire.add(PromenadeBlocks.STRIPPED_MAPLE_LOG, 5, 5); + fire.add(PromenadeBlocks.MAPLE_WOOD, 5, 5); + fire.add(PromenadeBlocks.STRIPPED_MAPLE_WOOD, 5, 5); + fire.add(PromenadeBlocks.MAPLE_PLANKS, 5, 20); + fire.add(PromenadeBlocks.MAPLE_STAIRS, 5, 20); + fire.add(PromenadeBlocks.MAPLE_SLAB, 5, 20); + fire.add(PromenadeBlocks.MAPLE_FENCE, 5, 20); + fire.add(PromenadeBlocks.MAPLE_FENCE_GATE, 5, 20); + fire.add(PromenadeBlocks.SAP_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_SAP_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.FALLEN_SAP_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SAP_MAPLE_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.VERMILION_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_VERMILION_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.FALLEN_VERMILION_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.VERMILION_MAPLE_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.FULVOUS_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_FULVOUS_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.FALLEN_FULVOUS_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.FULVOUS_MAPLE_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.MIKADO_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_MIKADO_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.FALLEN_MIKADO_MAPLE_LEAVES, 30, 60); + fire.add(PromenadeBlocks.MIKADO_MAPLE_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.PALM_LOG, 5, 5); - fire.add(PromenadeBlocks.STRIPPED_PALM_LOG, 5, 5); - fire.add(PromenadeBlocks.PALM_WOOD, 5, 5); - fire.add(PromenadeBlocks.STRIPPED_PALM_WOOD, 5, 5); - fire.add(PromenadeBlocks.PALM_PLANKS, 5, 20); - fire.add(PromenadeBlocks.PALM_STAIRS, 5, 20); - fire.add(PromenadeBlocks.PALM_SLAB, 5, 20); - fire.add(PromenadeBlocks.PALM_FENCE, 5, 20); - fire.add(PromenadeBlocks.PALM_FENCE_GATE, 5, 20); - fire.add(PromenadeBlocks.PALM_LEAVES, 30, 60); - fire.add(PromenadeBlocks.SNOWY_PALM_LEAVES, 30, 60); - fire.add(PromenadeBlocks.PALM_HANGING_LEAVES, 30, 60); - fire.add(PromenadeBlocks.PALM_LEAF_PILE, 30, 60); + fire.add(PromenadeBlocks.PALM_LOG, 5, 5); + fire.add(PromenadeBlocks.STRIPPED_PALM_LOG, 5, 5); + fire.add(PromenadeBlocks.PALM_WOOD, 5, 5); + fire.add(PromenadeBlocks.STRIPPED_PALM_WOOD, 5, 5); + fire.add(PromenadeBlocks.PALM_PLANKS, 5, 20); + fire.add(PromenadeBlocks.PALM_STAIRS, 5, 20); + fire.add(PromenadeBlocks.PALM_SLAB, 5, 20); + fire.add(PromenadeBlocks.PALM_FENCE, 5, 20); + fire.add(PromenadeBlocks.PALM_FENCE_GATE, 5, 20); + fire.add(PromenadeBlocks.PALM_LEAVES, 30, 60); + fire.add(PromenadeBlocks.SNOWY_PALM_LEAVES, 30, 60); + fire.add(PromenadeBlocks.PALM_HANGING_LEAVES, 30, 60); + fire.add(PromenadeBlocks.PALM_LEAF_PILE, 30, 60); - fire.add(PromenadeBlocks.BLUEBERRY_BUSH, 60, 100); - } + fire.add(PromenadeBlocks.BLUEBERRY_BUSH, 60, 100); + } } diff --git a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistries.java b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistries.java index f5866b86..472ff952 100644 --- a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistries.java +++ b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistries.java @@ -1,17 +1,29 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.registry; +import net.fabricmc.fabric.api.event.registry.DynamicRegistries; + import fr.hugman.promenade.block.snowy.SnowyBlockTransformation; import fr.hugman.promenade.entity.variant.CapybaraVariant; import fr.hugman.promenade.entity.variant.DuckVariant; import fr.hugman.promenade.entity.variant.SunkenVariant; -import net.fabricmc.fabric.api.event.registry.DynamicRegistries; public class PromenadeRegistries { - public static void register() { - DynamicRegistries.registerSynced(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, SnowyBlockTransformation.CODEC); + public static void register() { + DynamicRegistries.registerSynced(PromenadeRegistryKeys.SNOWY_BLOCK_TRANSFORMATION, SnowyBlockTransformation.CODEC); - DynamicRegistries.registerSynced(PromenadeRegistryKeys.DUCK_VARIANT, DuckVariant.CODEC, DuckVariant.NETWORK_CODEC); - DynamicRegistries.registerSynced(PromenadeRegistryKeys.CAPYBARA_VARIANT, CapybaraVariant.CODEC, CapybaraVariant.NETWORK_CODEC); - DynamicRegistries.registerSynced(PromenadeRegistryKeys.SUNKEN_VARIANT, SunkenVariant.CODEC, SunkenVariant.NETWORK_CODEC); - } + DynamicRegistries.registerSynced(PromenadeRegistryKeys.DUCK_VARIANT, DuckVariant.CODEC, DuckVariant.NETWORK_CODEC); + DynamicRegistries.registerSynced(PromenadeRegistryKeys.CAPYBARA_VARIANT, CapybaraVariant.CODEC, CapybaraVariant.NETWORK_CODEC); + DynamicRegistries.registerSynced(PromenadeRegistryKeys.SUNKEN_VARIANT, SunkenVariant.CODEC, SunkenVariant.NETWORK_CODEC); + } } diff --git a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryAliases.java b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryAliases.java index 97fd9977..da071786 100644 --- a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryAliases.java +++ b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryAliases.java @@ -1,86 +1,98 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.registry; -import fr.hugman.promenade.Promenade; +import java.util.HashMap; + import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import java.util.HashMap; +import fr.hugman.promenade.Promenade; /** * Registry aliases for Promenade. Prevents players from losing stuff when content is removed along new versions. */ public class PromenadeRegistryAliases { - public static void registerAliases() { - HashMap blockAliases = new HashMap<>(); - - // I forgot what version that was in - Registries.ENTITY_TYPE.addAlias(Promenade.id("sunken_skeleton"), Promenade.id("sunken")); - - // v3.0.0 - - blockAliases.put(Promenade.id("autumn_oak_leaves"), Promenade.id("fulvous_maple_leaves")); - blockAliases.put(Promenade.id("autumn_oak_sapling"), Promenade.id("fulvous_maple_sapling")); - blockAliases.put(Promenade.id("autumn_oak_leaf_pile"), Promenade.id("fulvous_maple_leaf_pile")); - blockAliases.put(Promenade.id("potted_autumn_oak_sapling"), Promenade.id("potted_fulvous_maple_sapling")); - - blockAliases.put(Promenade.id("autumn_birch_leaves"), Promenade.id("mikado_maple_leaves")); - blockAliases.put(Promenade.id("autumn_birch_sapling"), Promenade.id("mikado_maple_sapling")); - blockAliases.put(Promenade.id("autumn_birch_leaf_pile"), Promenade.id("mikado_maple_leaf_pile")); - blockAliases.put(Promenade.id("potted_autumn_birch_sapling"), Promenade.id("potted_mikado_maple_sapling")); - - //TODO: add alias for pumpkin pastures - - // v3.1.0 - blockAliases.put(Promenade.id("cherry_oak_log"), Promenade.id("sakura_log")); - blockAliases.put(Promenade.id("cherry_oak_wood"), Promenade.id("sakura_wood")); - blockAliases.put(Promenade.id("stripped_cherry_oak_log"), Promenade.id("stripped_sakura_log")); - blockAliases.put(Promenade.id("stripped_cherry_oak_wood"), Promenade.id("stripped_sakura_wood")); - - blockAliases.put(Promenade.id("cherry_oak_planks"), Promenade.id("sakura_planks")); - blockAliases.put(Promenade.id("cherry_oak_slab"), Promenade.id("sakura_slab")); - blockAliases.put(Promenade.id("cherry_oak_stairs"), Promenade.id("sakura_stairs")); - blockAliases.put(Promenade.id("cherry_oak_fence"), Promenade.id("sakura_fence")); - blockAliases.put(Promenade.id("cherry_oak_fence_gate"), Promenade.id("sakura_fence_gate")); - blockAliases.put(Promenade.id("cherry_oak_door"), Promenade.id("sakura_door")); - blockAliases.put(Promenade.id("cherry_oak_trapdoor"), Promenade.id("sakura_trapdoor")); - blockAliases.put(Promenade.id("cherry_oak_pressure_plate"), Promenade.id("sakura_pressure_plate")); - blockAliases.put(Promenade.id("cherry_oak_button"), Promenade.id("sakura_button")); - blockAliases.put(Promenade.id("cherry_oak_sign"), Promenade.id("sakura_sign")); - Registries.BLOCK.addAlias(Promenade.id("cherry_oak_wall_sign"), Promenade.id("sakura_wall_sign")); - - blockAliases.put(Promenade.id("pink_cherry_oak_sapling"), Promenade.id("blush_sakura_sapling")); - blockAliases.put(Promenade.id("potted_pink_cherry_oak_sapling"), Promenade.id("potted_blush_sakura_sapling")); - blockAliases.put(Promenade.id("pink_cherry_oak_leaves"), Promenade.id("blush_sakura_blossoms")); - blockAliases.put(Promenade.id("pink_cherry_oak_leaf_pile"), Promenade.id("blush_sakura_blossom_pile")); - - blockAliases.put(Promenade.id("white_cherry_oak_sapling"), Promenade.id("cotton_sakura_sapling")); - blockAliases.put(Promenade.id("potted_white_cherry_oak_sapling"), Promenade.id("potted_cotton_sakura_sapling")); - blockAliases.put(Promenade.id("white_cherry_oak_leaves"), Promenade.id("cotton_sakura_blossoms")); - blockAliases.put(Promenade.id("white_cherry_oak_leaf_pile"), Promenade.id("cotton_sakura_blossom_pile")); - - Registries.ITEM.addAlias(Promenade.id("cherry_oak_boat"), Promenade.id("sakura_boat")); - - // v4.0.0 - blockAliases.put(Promenade.id("carbonite"), Promenade.id("asphalt")); - blockAliases.put(Promenade.id("carbonite_slab"), Promenade.id("asphalt_slab")); - blockAliases.put(Promenade.id("carbonite_stairs"), Promenade.id("asphalt_stairs")); - blockAliases.put(Promenade.id("carbonite_wall"), Promenade.id("asphalt_wall")); - - blockAliases.put(Promenade.id("polished_carbonite"), Promenade.id("polished_asphalt")); - blockAliases.put(Promenade.id("polished_carbonite_slab"), Promenade.id("polished_asphalt_slab")); - blockAliases.put(Promenade.id("polished_carbonite_stairs"), Promenade.id("polished_asphalt_stairs")); - - // v5.0.0 - var grassId = Identifier.ofVanilla("grass_block"); - blockAliases.put(Promenade.id("vermilion_carpeted_grass_block"), grassId); - blockAliases.put(Promenade.id("fulvous_carpeted_grass_block"), grassId); - blockAliases.put(Promenade.id("mikado_carpeted_grass_block"), grassId); - - blockAliases.put(Promenade.id("black_dylium"), Promenade.id("dark_amaranth_nylium")); - - for (var entry : blockAliases.entrySet()) { - Registries.BLOCK.addAlias(entry.getKey(), entry.getValue()); - Registries.ITEM.addAlias(entry.getKey(), entry.getValue()); - } - } + public static void registerAliases() { + HashMap blockAliases = new HashMap<>(); + + // I forgot what version that was in + Registries.ENTITY_TYPE.addAlias(Promenade.id("sunken_skeleton"), Promenade.id("sunken")); + + // v3.0.0 + + blockAliases.put(Promenade.id("autumn_oak_leaves"), Promenade.id("fulvous_maple_leaves")); + blockAliases.put(Promenade.id("autumn_oak_sapling"), Promenade.id("fulvous_maple_sapling")); + blockAliases.put(Promenade.id("autumn_oak_leaf_pile"), Promenade.id("fulvous_maple_leaf_pile")); + blockAliases.put(Promenade.id("potted_autumn_oak_sapling"), Promenade.id("potted_fulvous_maple_sapling")); + + blockAliases.put(Promenade.id("autumn_birch_leaves"), Promenade.id("mikado_maple_leaves")); + blockAliases.put(Promenade.id("autumn_birch_sapling"), Promenade.id("mikado_maple_sapling")); + blockAliases.put(Promenade.id("autumn_birch_leaf_pile"), Promenade.id("mikado_maple_leaf_pile")); + blockAliases.put(Promenade.id("potted_autumn_birch_sapling"), Promenade.id("potted_mikado_maple_sapling")); + + //TODO: add alias for pumpkin pastures + + // v3.1.0 + blockAliases.put(Promenade.id("cherry_oak_log"), Promenade.id("sakura_log")); + blockAliases.put(Promenade.id("cherry_oak_wood"), Promenade.id("sakura_wood")); + blockAliases.put(Promenade.id("stripped_cherry_oak_log"), Promenade.id("stripped_sakura_log")); + blockAliases.put(Promenade.id("stripped_cherry_oak_wood"), Promenade.id("stripped_sakura_wood")); + + blockAliases.put(Promenade.id("cherry_oak_planks"), Promenade.id("sakura_planks")); + blockAliases.put(Promenade.id("cherry_oak_slab"), Promenade.id("sakura_slab")); + blockAliases.put(Promenade.id("cherry_oak_stairs"), Promenade.id("sakura_stairs")); + blockAliases.put(Promenade.id("cherry_oak_fence"), Promenade.id("sakura_fence")); + blockAliases.put(Promenade.id("cherry_oak_fence_gate"), Promenade.id("sakura_fence_gate")); + blockAliases.put(Promenade.id("cherry_oak_door"), Promenade.id("sakura_door")); + blockAliases.put(Promenade.id("cherry_oak_trapdoor"), Promenade.id("sakura_trapdoor")); + blockAliases.put(Promenade.id("cherry_oak_pressure_plate"), Promenade.id("sakura_pressure_plate")); + blockAliases.put(Promenade.id("cherry_oak_button"), Promenade.id("sakura_button")); + blockAliases.put(Promenade.id("cherry_oak_sign"), Promenade.id("sakura_sign")); + Registries.BLOCK.addAlias(Promenade.id("cherry_oak_wall_sign"), Promenade.id("sakura_wall_sign")); + + blockAliases.put(Promenade.id("pink_cherry_oak_sapling"), Promenade.id("blush_sakura_sapling")); + blockAliases.put(Promenade.id("potted_pink_cherry_oak_sapling"), Promenade.id("potted_blush_sakura_sapling")); + blockAliases.put(Promenade.id("pink_cherry_oak_leaves"), Promenade.id("blush_sakura_blossoms")); + blockAliases.put(Promenade.id("pink_cherry_oak_leaf_pile"), Promenade.id("blush_sakura_blossom_pile")); + + blockAliases.put(Promenade.id("white_cherry_oak_sapling"), Promenade.id("cotton_sakura_sapling")); + blockAliases.put(Promenade.id("potted_white_cherry_oak_sapling"), Promenade.id("potted_cotton_sakura_sapling")); + blockAliases.put(Promenade.id("white_cherry_oak_leaves"), Promenade.id("cotton_sakura_blossoms")); + blockAliases.put(Promenade.id("white_cherry_oak_leaf_pile"), Promenade.id("cotton_sakura_blossom_pile")); + + Registries.ITEM.addAlias(Promenade.id("cherry_oak_boat"), Promenade.id("sakura_boat")); + + // v4.0.0 + blockAliases.put(Promenade.id("carbonite"), Promenade.id("asphalt")); + blockAliases.put(Promenade.id("carbonite_slab"), Promenade.id("asphalt_slab")); + blockAliases.put(Promenade.id("carbonite_stairs"), Promenade.id("asphalt_stairs")); + blockAliases.put(Promenade.id("carbonite_wall"), Promenade.id("asphalt_wall")); + + blockAliases.put(Promenade.id("polished_carbonite"), Promenade.id("polished_asphalt")); + blockAliases.put(Promenade.id("polished_carbonite_slab"), Promenade.id("polished_asphalt_slab")); + blockAliases.put(Promenade.id("polished_carbonite_stairs"), Promenade.id("polished_asphalt_stairs")); + + // v5.0.0 + var grassId = Identifier.ofVanilla("grass_block"); + blockAliases.put(Promenade.id("vermilion_carpeted_grass_block"), grassId); + blockAliases.put(Promenade.id("fulvous_carpeted_grass_block"), grassId); + blockAliases.put(Promenade.id("mikado_carpeted_grass_block"), grassId); + + blockAliases.put(Promenade.id("black_dylium"), Promenade.id("dark_amaranth_nylium")); + + for (var entry : blockAliases.entrySet()) { + Registries.BLOCK.addAlias(entry.getKey(), entry.getValue()); + Registries.ITEM.addAlias(entry.getKey(), entry.getValue()); + } + } } diff --git a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryKeys.java b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryKeys.java index aeb8d32a..6476d21b 100644 --- a/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryKeys.java +++ b/src/main/java/fr/hugman/promenade/registry/PromenadeRegistryKeys.java @@ -1,17 +1,29 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.registry; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; + import fr.hugman.promenade.Promenade; import fr.hugman.promenade.block.snowy.SnowyBlockTransformation; import fr.hugman.promenade.entity.variant.CapybaraVariant; import fr.hugman.promenade.entity.variant.DuckVariant; import fr.hugman.promenade.entity.variant.SunkenVariant; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; public class PromenadeRegistryKeys { - public static final RegistryKey> SNOWY_BLOCK_TRANSFORMATION = RegistryKey.ofRegistry(Promenade.id("snowy_block_transformation")); + public static final RegistryKey> SNOWY_BLOCK_TRANSFORMATION = RegistryKey.ofRegistry(Promenade.id("snowy_block_transformation")); - public static final RegistryKey> DUCK_VARIANT = RegistryKey.ofRegistry(Promenade.id("duck_variant")); - public static final RegistryKey> CAPYBARA_VARIANT = RegistryKey.ofRegistry(Promenade.id("capybara_variant")); - public static final RegistryKey> SUNKEN_VARIANT = RegistryKey.ofRegistry(Promenade.id("sunken_variant")); + public static final RegistryKey> DUCK_VARIANT = RegistryKey.ofRegistry(Promenade.id("duck_variant")); + public static final RegistryKey> CAPYBARA_VARIANT = RegistryKey.ofRegistry(Promenade.id("capybara_variant")); + public static final RegistryKey> SUNKEN_VARIANT = RegistryKey.ofRegistry(Promenade.id("sunken_variant")); } diff --git a/src/main/java/fr/hugman/promenade/registry/PromenadeStrippables.java b/src/main/java/fr/hugman/promenade/registry/PromenadeStrippables.java index d916379e..f040aa3e 100644 --- a/src/main/java/fr/hugman/promenade/registry/PromenadeStrippables.java +++ b/src/main/java/fr/hugman/promenade/registry/PromenadeStrippables.java @@ -1,17 +1,29 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.registry; -import fr.hugman.promenade.block.PromenadeBlocks; import net.fabricmc.fabric.api.registry.StrippableBlockRegistry; +import fr.hugman.promenade.block.PromenadeBlocks; + public class PromenadeStrippables { - public static void register() { - StrippableBlockRegistry.register(PromenadeBlocks.SAKURA_LOG, PromenadeBlocks.STRIPPED_SAKURA_LOG); - StrippableBlockRegistry.register(PromenadeBlocks.SAKURA_WOOD, PromenadeBlocks.STRIPPED_SAKURA_WOOD); - StrippableBlockRegistry.register(PromenadeBlocks.MAPLE_LOG, PromenadeBlocks.STRIPPED_MAPLE_LOG); - StrippableBlockRegistry.register(PromenadeBlocks.MAPLE_WOOD, PromenadeBlocks.STRIPPED_MAPLE_WOOD); - StrippableBlockRegistry.register(PromenadeBlocks.PALM_LOG, PromenadeBlocks.STRIPPED_PALM_LOG); - StrippableBlockRegistry.register(PromenadeBlocks.PALM_WOOD, PromenadeBlocks.STRIPPED_PALM_WOOD); - StrippableBlockRegistry.register(PromenadeBlocks.DARK_AMARANTH_STEM, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); - StrippableBlockRegistry.register(PromenadeBlocks.DARK_AMARANTH_HYPHAE, PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); - } + public static void register() { + StrippableBlockRegistry.register(PromenadeBlocks.SAKURA_LOG, PromenadeBlocks.STRIPPED_SAKURA_LOG); + StrippableBlockRegistry.register(PromenadeBlocks.SAKURA_WOOD, PromenadeBlocks.STRIPPED_SAKURA_WOOD); + StrippableBlockRegistry.register(PromenadeBlocks.MAPLE_LOG, PromenadeBlocks.STRIPPED_MAPLE_LOG); + StrippableBlockRegistry.register(PromenadeBlocks.MAPLE_WOOD, PromenadeBlocks.STRIPPED_MAPLE_WOOD); + StrippableBlockRegistry.register(PromenadeBlocks.PALM_LOG, PromenadeBlocks.STRIPPED_PALM_LOG); + StrippableBlockRegistry.register(PromenadeBlocks.PALM_WOOD, PromenadeBlocks.STRIPPED_PALM_WOOD); + StrippableBlockRegistry.register(PromenadeBlocks.DARK_AMARANTH_STEM, PromenadeBlocks.STRIPPED_DARK_AMARANTH_STEM); + StrippableBlockRegistry.register(PromenadeBlocks.DARK_AMARANTH_HYPHAE, PromenadeBlocks.STRIPPED_DARK_AMARANTH_HYPHAE); + } } diff --git a/src/main/java/fr/hugman/promenade/sound/PromenadeBlockSounds.java b/src/main/java/fr/hugman/promenade/sound/PromenadeBlockSounds.java index 81243b48..1ac8f464 100644 --- a/src/main/java/fr/hugman/promenade/sound/PromenadeBlockSounds.java +++ b/src/main/java/fr/hugman/promenade/sound/PromenadeBlockSounds.java @@ -1,35 +1,46 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.sound; import net.minecraft.sound.BlockSoundGroup; public final class PromenadeBlockSounds { - public static final BlockSoundGroup MAPLE_WOOD = BlockSoundGroup.WOOD; - public static final BlockSoundGroup SAKURA_WOOD = BlockSoundGroup.CHERRY_WOOD; - public static final BlockSoundGroup PALM_WOOD = BlockSoundGroup.WOOD; - public static final BlockSoundGroup AMARANTH_WOOD = BlockSoundGroup.NETHER_WOOD; + public static final BlockSoundGroup MAPLE_WOOD = BlockSoundGroup.WOOD; + public static final BlockSoundGroup SAKURA_WOOD = BlockSoundGroup.CHERRY_WOOD; + public static final BlockSoundGroup PALM_WOOD = BlockSoundGroup.WOOD; + public static final BlockSoundGroup AMARANTH_WOOD = BlockSoundGroup.NETHER_WOOD; - public static final BlockSoundGroup SNOWY_LEAVES = new BlockSoundGroup(1.0f, 1.0f, - PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_BREAK, - PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_STEP, - PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_PLACE, - PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_HIT, - PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_FALL - ); + public static final BlockSoundGroup SNOWY_LEAVES = new BlockSoundGroup(1.0f, 1.0f, + PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_BREAK, + PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_STEP, + PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_PLACE, + PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_HIT, + PromenadeSoundEvents.BLOCK_SNOWY_LEAVES_FALL + ); - public static final BlockSoundGroup SNOWY_AZALEA_LEAVES = new BlockSoundGroup(1.0f, 1.0f, - PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_BREAK, - PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_STEP, - PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_PLACE, - PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_HIT, - PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_FALL - ); + public static final BlockSoundGroup SNOWY_AZALEA_LEAVES = new BlockSoundGroup(1.0f, 1.0f, + PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_BREAK, + PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_STEP, + PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_PLACE, + PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_HIT, + PromenadeSoundEvents.BLOCK_SNOWY_AZALEA_LEAVES_FALL + ); - public static final BlockSoundGroup SNOWY_CHERRY_LEAVES = new BlockSoundGroup(1.0f, 1.0f, - PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_BREAK, - PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_STEP, - PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_PLACE, - PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_HIT, - PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_FALL - ); + public static final BlockSoundGroup SNOWY_CHERRY_LEAVES = new BlockSoundGroup(1.0f, 1.0f, + PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_BREAK, + PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_STEP, + PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_PLACE, + PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_HIT, + PromenadeSoundEvents.BLOCK_SNOWY_CHERRY_LEAVES_FALL + ); } diff --git a/src/main/java/fr/hugman/promenade/sound/PromenadeSoundEvents.java b/src/main/java/fr/hugman/promenade/sound/PromenadeSoundEvents.java index dc5f4206..79e324a2 100644 --- a/src/main/java/fr/hugman/promenade/sound/PromenadeSoundEvents.java +++ b/src/main/java/fr/hugman/promenade/sound/PromenadeSoundEvents.java @@ -1,56 +1,68 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.sound; -import fr.hugman.promenade.Promenade; +import java.util.Optional; + import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.sound.SoundEvent; -import java.util.Optional; +import fr.hugman.promenade.Promenade; public class PromenadeSoundEvents { - public static final RegistryEntry.Reference MUSIC_OVERWORLD_SAKURA_GROVES = ofRef("music.overworld.sakura_groves"); - - public static final SoundEvent BLOCK_SNOWY_LEAVES_BREAK = of("block.snowy_leaves.break"); - public static final SoundEvent BLOCK_SNOWY_LEAVES_STEP = of("block.snowy_leaves.step"); - public static final SoundEvent BLOCK_SNOWY_LEAVES_PLACE = of("block.snowy_leaves.place"); - public static final SoundEvent BLOCK_SNOWY_LEAVES_HIT = of("block.snowy_leaves.hit"); - public static final SoundEvent BLOCK_SNOWY_LEAVES_FALL = of("block.snowy_leaves.fall"); - - public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_BREAK = of("block.snowy_azalea_leaves.break"); - public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_STEP = of("block.snowy_azalea_leaves.step"); - public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_PLACE = of("block.snowy_azalea_leaves.place"); - public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_HIT = of("block.snowy_azalea_leaves.hit"); - public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_FALL = of("block.snowy_azalea_leaves.fall"); - - public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_BREAK = of("block.snowy_cherry_leaves.break"); - public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_STEP = of("block.snowy_cherry_leaves.step"); - public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_PLACE = of("block.snowy_cherry_leaves.place"); - public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_HIT = of("block.snowy_cherry_leaves.hit"); - public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_FALL = of("block.snowy_cherry_leaves.fall"); - - public static final SoundEvent CAPYBARA_AMBIENT = of("entity.capybara.ambient"); - public static final SoundEvent CAPYBARA_AMBIENT_BABY = of("entity.capybara.ambient.baby"); - public static final SoundEvent CAPYBARA_FART = of("entity.capybara.fart"); - - public static final SoundEvent DUCK_AMBIENT = of("entity.duck.ambient"); - public static final SoundEvent DUCK_HURT = of("entity.duck.hurt"); - public static final SoundEvent DUCK_DEATH = of("entity.duck.death"); - public static final SoundEvent DUCK_STEP = of("entity.duck.step"); - - public static final SoundEvent SUNKEN_AMBIENT = of("entity.sunken.ambient"); - public static final SoundEvent SUNKEN_HURT = of("entity.sunken.hurt"); - public static final SoundEvent SUNKEN_DEATH = of("entity.sunken.death"); - public static final SoundEvent SUNKEN_STEP = of("entity.sunken.step"); - public static final SoundEvent SUNKEN_SHOOT = of("entity.sunken.shoot"); - - private static RegistryEntry.Reference ofRef(String path) { - var id = Promenade.id(path); - return Registry.registerReference(Registries.SOUND_EVENT, id, new SoundEvent(id, Optional.empty())); - } - - private static SoundEvent of(String path) { - var id = Promenade.id(path); - return Registry.register(Registries.SOUND_EVENT, id, new SoundEvent(id, Optional.empty())); - } + public static final RegistryEntry.Reference MUSIC_OVERWORLD_SAKURA_GROVES = ofRef("music.overworld.sakura_groves"); + + public static final SoundEvent BLOCK_SNOWY_LEAVES_BREAK = of("block.snowy_leaves.break"); + public static final SoundEvent BLOCK_SNOWY_LEAVES_STEP = of("block.snowy_leaves.step"); + public static final SoundEvent BLOCK_SNOWY_LEAVES_PLACE = of("block.snowy_leaves.place"); + public static final SoundEvent BLOCK_SNOWY_LEAVES_HIT = of("block.snowy_leaves.hit"); + public static final SoundEvent BLOCK_SNOWY_LEAVES_FALL = of("block.snowy_leaves.fall"); + + public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_BREAK = of("block.snowy_azalea_leaves.break"); + public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_STEP = of("block.snowy_azalea_leaves.step"); + public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_PLACE = of("block.snowy_azalea_leaves.place"); + public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_HIT = of("block.snowy_azalea_leaves.hit"); + public static final SoundEvent BLOCK_SNOWY_AZALEA_LEAVES_FALL = of("block.snowy_azalea_leaves.fall"); + + public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_BREAK = of("block.snowy_cherry_leaves.break"); + public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_STEP = of("block.snowy_cherry_leaves.step"); + public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_PLACE = of("block.snowy_cherry_leaves.place"); + public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_HIT = of("block.snowy_cherry_leaves.hit"); + public static final SoundEvent BLOCK_SNOWY_CHERRY_LEAVES_FALL = of("block.snowy_cherry_leaves.fall"); + + public static final SoundEvent CAPYBARA_AMBIENT = of("entity.capybara.ambient"); + public static final SoundEvent CAPYBARA_AMBIENT_BABY = of("entity.capybara.ambient.baby"); + public static final SoundEvent CAPYBARA_FART = of("entity.capybara.fart"); + + public static final SoundEvent DUCK_AMBIENT = of("entity.duck.ambient"); + public static final SoundEvent DUCK_HURT = of("entity.duck.hurt"); + public static final SoundEvent DUCK_DEATH = of("entity.duck.death"); + public static final SoundEvent DUCK_STEP = of("entity.duck.step"); + + public static final SoundEvent SUNKEN_AMBIENT = of("entity.sunken.ambient"); + public static final SoundEvent SUNKEN_HURT = of("entity.sunken.hurt"); + public static final SoundEvent SUNKEN_DEATH = of("entity.sunken.death"); + public static final SoundEvent SUNKEN_STEP = of("entity.sunken.step"); + public static final SoundEvent SUNKEN_SHOOT = of("entity.sunken.shoot"); + + private static RegistryEntry.Reference ofRef(String path) { + var id = Promenade.id(path); + return Registry.registerReference(Registries.SOUND_EVENT, id, new SoundEvent(id, Optional.empty())); + } + + private static SoundEvent of(String path) { + var id = Promenade.id(path); + return Registry.register(Registries.SOUND_EVENT, id, new SoundEvent(id, Optional.empty())); + } } diff --git a/src/main/java/fr/hugman/promenade/tag/PromenadeBiomeTags.java b/src/main/java/fr/hugman/promenade/tag/PromenadeBiomeTags.java index e897c777..01f75d89 100644 --- a/src/main/java/fr/hugman/promenade/tag/PromenadeBiomeTags.java +++ b/src/main/java/fr/hugman/promenade/tag/PromenadeBiomeTags.java @@ -1,24 +1,36 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.tag; -import fr.hugman.promenade.Promenade; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; import net.minecraft.world.biome.Biome; +import fr.hugman.promenade.Promenade; + public class PromenadeBiomeTags { - public static final TagKey SAKURA_GROVES = of("sakura_groves"); + public static final TagKey SAKURA_GROVES = of("sakura_groves"); - public static final TagKey HAS_PALMS = of("has_palms"); - public static final TagKey HAS_DARK_FOREST_WITCH_HUT = of("has_structure/dark_forest_witch_hut"); + public static final TagKey HAS_PALMS = of("has_palms"); + public static final TagKey HAS_DARK_FOREST_WITCH_HUT = of("has_structure/dark_forest_witch_hut"); - public static final TagKey CAN_FREEZE_DURING_SNOWFALL = of("can_freeze_during_snowfall"); + public static final TagKey CAN_FREEZE_DURING_SNOWFALL = of("can_freeze_during_snowfall"); - public static final TagKey SPAWNS_CAPYBARAS = of("spawns_capybaras"); - public static final TagKey SPAWNS_SUNKEN = of("spawns_sunken"); - public static final TagKey SPAWNS_MALLARD_DUCKS = of("spawns_mallard_ducks"); - public static final TagKey SPAWNS_PEKIN_DUCKS = of("spawns_pekin_ducks"); + public static final TagKey SPAWNS_CAPYBARAS = of("spawns_capybaras"); + public static final TagKey SPAWNS_SUNKEN = of("spawns_sunken"); + public static final TagKey SPAWNS_MALLARD_DUCKS = of("spawns_mallard_ducks"); + public static final TagKey SPAWNS_PEKIN_DUCKS = of("spawns_pekin_ducks"); - private static TagKey of(String path) { - return TagKey.of(RegistryKeys.BIOME, Promenade.id(path)); - } + private static TagKey of(String path) { + return TagKey.of(RegistryKeys.BIOME, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/tag/PromenadeBlockTags.java b/src/main/java/fr/hugman/promenade/tag/PromenadeBlockTags.java index 24dc3d3b..856d9b9a 100644 --- a/src/main/java/fr/hugman/promenade/tag/PromenadeBlockTags.java +++ b/src/main/java/fr/hugman/promenade/tag/PromenadeBlockTags.java @@ -1,27 +1,39 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.tag; -import fr.hugman.promenade.Promenade; import net.minecraft.block.Block; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; +import fr.hugman.promenade.Promenade; + public class PromenadeBlockTags { - public static final TagKey SAKURA_LOGS = of("sakura_logs"); - public static final TagKey MAPLE_LOGS = of("maple_logs"); - public static final TagKey PALM_LOGS = of("palm_logs"); - public static final TagKey DARK_AMARANTH_STEMS = of("dark_amaranth_stems"); + public static final TagKey SAKURA_LOGS = of("sakura_logs"); + public static final TagKey MAPLE_LOGS = of("maple_logs"); + public static final TagKey PALM_LOGS = of("palm_logs"); + public static final TagKey DARK_AMARANTH_STEMS = of("dark_amaranth_stems"); - public static final TagKey SNOWY_LEAVES = of("snowy_leaves"); + public static final TagKey SNOWY_LEAVES = of("snowy_leaves"); - public static final TagKey FALLEN_LEAVES = of("fallen_leaves"); - public static final TagKey LEAF_PILES = of("leaf_piles"); - public static final TagKey FLOWER_PILES = of("flower_piles"); + public static final TagKey FALLEN_LEAVES = of("fallen_leaves"); + public static final TagKey LEAF_PILES = of("leaf_piles"); + public static final TagKey FLOWER_PILES = of("flower_piles"); - public static final TagKey DARK_AMARANTH_FUNGUS_PLACEABLE_ON = of("dark_amaranth_fungus_placeable_on"); - public static final TagKey DARK_AMARANTH_FUNGUS_GROWABLE_ON = of("dark_amaranth_fungus_growable_on"); - public static final TagKey DARK_AMARANTH_ROOTS_PLACEABLE_ON = of("dark_amaranth_roots_placeable_on"); + public static final TagKey DARK_AMARANTH_FUNGUS_PLACEABLE_ON = of("dark_amaranth_fungus_placeable_on"); + public static final TagKey DARK_AMARANTH_FUNGUS_GROWABLE_ON = of("dark_amaranth_fungus_growable_on"); + public static final TagKey DARK_AMARANTH_ROOTS_PLACEABLE_ON = of("dark_amaranth_roots_placeable_on"); - public static TagKey of(String path) { - return TagKey.of(RegistryKeys.BLOCK, Promenade.id(path)); - } + public static TagKey of(String path) { + return TagKey.of(RegistryKeys.BLOCK, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/tag/PromenadeItemTags.java b/src/main/java/fr/hugman/promenade/tag/PromenadeItemTags.java index 6885a636..ca1d2509 100644 --- a/src/main/java/fr/hugman/promenade/tag/PromenadeItemTags.java +++ b/src/main/java/fr/hugman/promenade/tag/PromenadeItemTags.java @@ -1,22 +1,34 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.tag; -import fr.hugman.promenade.Promenade; import net.minecraft.item.Item; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; +import fr.hugman.promenade.Promenade; + public class PromenadeItemTags { - public static final TagKey SAKURA_LOGS = of("sakura_logs"); - public static final TagKey MAPLE_LOGS = of("maple_logs"); - public static final TagKey PALM_LOGS = of("palm_logs"); - public static final TagKey DARK_AMARANTH_STEMS = of("dark_amaranth_stems"); + public static final TagKey SAKURA_LOGS = of("sakura_logs"); + public static final TagKey MAPLE_LOGS = of("maple_logs"); + public static final TagKey PALM_LOGS = of("palm_logs"); + public static final TagKey DARK_AMARANTH_STEMS = of("dark_amaranth_stems"); - public static final TagKey SNOWY_LEAVES = of("snowy_leaves"); + public static final TagKey SNOWY_LEAVES = of("snowy_leaves"); - public static final TagKey CAPYBARA_FOOD = of("capybara_food"); - public static final TagKey DUCK_FOOD = of("duck_food"); + public static final TagKey CAPYBARA_FOOD = of("capybara_food"); + public static final TagKey DUCK_FOOD = of("duck_food"); - private static TagKey of(String path) { - return TagKey.of(RegistryKeys.ITEM, Promenade.id(path)); - } + private static TagKey of(String path) { + return TagKey.of(RegistryKeys.ITEM, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/trade/PromenadeTrades.java b/src/main/java/fr/hugman/promenade/trade/PromenadeTrades.java index 6b1cf68a..eea822b9 100644 --- a/src/main/java/fr/hugman/promenade/trade/PromenadeTrades.java +++ b/src/main/java/fr/hugman/promenade/trade/PromenadeTrades.java @@ -1,20 +1,32 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.trade; -import fr.hugman.promenade.block.PromenadeBlocks; import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper; +import fr.hugman.promenade.block.PromenadeBlocks; + public class PromenadeTrades { - public static void appendVillagerTrades() { - TradeOfferHelper.registerWanderingTraderOffers(builder -> builder.addOffersToPool(TradeOfferHelper.WanderingTraderOffersBuilder.SELL_COMMON_ITEMS_POOL, - TradeFactory.sapling(PromenadeBlocks.VERMILION_MAPLE_SAPLING), - TradeFactory.sapling(PromenadeBlocks.FULVOUS_MAPLE_SAPLING), - TradeFactory.sapling(PromenadeBlocks.MIKADO_MAPLE_SAPLING), - TradeFactory.sapling(PromenadeBlocks.SAP_MAPLE_SAPLING), + public static void appendVillagerTrades() { + TradeOfferHelper.registerWanderingTraderOffers(builder -> builder.addOffersToPool(TradeOfferHelper.WanderingTraderOffersBuilder.SELL_COMMON_ITEMS_POOL, + TradeFactory.sapling(PromenadeBlocks.VERMILION_MAPLE_SAPLING), + TradeFactory.sapling(PromenadeBlocks.FULVOUS_MAPLE_SAPLING), + TradeFactory.sapling(PromenadeBlocks.MIKADO_MAPLE_SAPLING), + TradeFactory.sapling(PromenadeBlocks.SAP_MAPLE_SAPLING), - TradeFactory.sapling(PromenadeBlocks.BLUSH_SAKURA_SAPLING), - TradeFactory.sapling(PromenadeBlocks.COTTON_SAKURA_SAPLING), + TradeFactory.sapling(PromenadeBlocks.BLUSH_SAKURA_SAPLING), + TradeFactory.sapling(PromenadeBlocks.COTTON_SAKURA_SAPLING), - TradeFactory.sapling(PromenadeBlocks.PALM_SAPLING) - )); - } + TradeFactory.sapling(PromenadeBlocks.PALM_SAPLING) + )); + } } diff --git a/src/main/java/fr/hugman/promenade/trade/TradeFactory.java b/src/main/java/fr/hugman/promenade/trade/TradeFactory.java index 2300e63b..34436ecb 100644 --- a/src/main/java/fr/hugman/promenade/trade/TradeFactory.java +++ b/src/main/java/fr/hugman/promenade/trade/TradeFactory.java @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.trade; import net.minecraft.item.ItemConvertible; @@ -8,7 +19,7 @@ import net.minecraft.village.TradedItem; public class TradeFactory { - public static TradeOffers.Factory sapling(ItemConvertible sapling) { - return (entity, random) -> new TradeOffer(new TradedItem(Items.EMERALD, 5), new ItemStack(sapling), 8, 1, 0.05f); - } + public static TradeOffers.Factory sapling(ItemConvertible sapling) { + return (entity, random) -> new TradeOffer(new TradedItem(Items.EMERALD, 5), new ItemStack(sapling), 8, 1, 0.05f); + } } diff --git a/src/main/java/fr/hugman/promenade/util/NoiseScale.java b/src/main/java/fr/hugman/promenade/util/NoiseScale.java index 85860d61..b0f63bdf 100644 --- a/src/main/java/fr/hugman/promenade/util/NoiseScale.java +++ b/src/main/java/fr/hugman/promenade/util/NoiseScale.java @@ -1,22 +1,34 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.util; import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.util.dynamic.Codecs; public record NoiseScale(float x, float z) { - private static final Codec DIRECT_CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codecs.POSITIVE_FLOAT.fieldOf("x").forGetter(NoiseScale::x), - Codecs.POSITIVE_FLOAT.fieldOf("z").forGetter(NoiseScale::z) - ).apply(instance, NoiseScale::new)); + private static final Codec DIRECT_CODEC = RecordCodecBuilder.create(instance -> instance.group( + Codecs.POSITIVE_FLOAT.fieldOf("x").forGetter(NoiseScale::x), + Codecs.POSITIVE_FLOAT.fieldOf("z").forGetter(NoiseScale::z) + ).apply(instance, NoiseScale::new)); - public static final Codec CODEC = Codec.either(Codecs.POSITIVE_FLOAT, DIRECT_CODEC).xmap( - either -> either.map(value -> new NoiseScale(value, value), scale -> scale), - scale -> scale.x == scale.z ? Either.left(scale.x) : Either.right(scale) - ); + public static final Codec CODEC = Codec.either(Codecs.POSITIVE_FLOAT, DIRECT_CODEC).xmap( + either -> either.map(value -> new NoiseScale(value, value), scale -> scale), + scale -> scale.x == scale.z ? Either.left(scale.x) : Either.right(scale) + ); - public static NoiseScale of(float value) { - return new NoiseScale(value, value); - } + public static NoiseScale of(float value) { + return new NoiseScale(value, value); + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/world/PromenadeGameRules.java b/src/main/java/fr/hugman/promenade/world/PromenadeGameRules.java index 6a204f81..2e98c85f 100644 --- a/src/main/java/fr/hugman/promenade/world/PromenadeGameRules.java +++ b/src/main/java/fr/hugman/promenade/world/PromenadeGameRules.java @@ -1,13 +1,25 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world; +import net.minecraft.world.GameRules; + import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory; import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry; -import net.minecraft.world.GameRules; public class PromenadeGameRules { - public static final GameRules.Key DO_BLOCKS_GET_SNOWY = of("doBlocksGetSnowy", GameRules.Category.UPDATES, GameRuleFactory.createBooleanRule(true)); + public static final GameRules.Key DO_BLOCKS_GET_SNOWY = of("doBlocksGetSnowy", GameRules.Category.UPDATES, GameRuleFactory.createBooleanRule(true)); - public static > GameRules.Key of(String name, GameRules.Category category, GameRules.Type type) { - return GameRuleRegistry.register(name, category, type); - } + public static > GameRules.Key of(String name, GameRules.Category category, GameRules.Type type) { + return GameRuleRegistry.register(name, category, type); + } } diff --git a/src/main/java/fr/hugman/promenade/world/PromenadeSaplingGenerators.java b/src/main/java/fr/hugman/promenade/world/PromenadeSaplingGenerators.java index c0edf215..26916e23 100644 --- a/src/main/java/fr/hugman/promenade/world/PromenadeSaplingGenerators.java +++ b/src/main/java/fr/hugman/promenade/world/PromenadeSaplingGenerators.java @@ -1,36 +1,48 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world; -import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; +import java.util.Optional; + import net.minecraft.block.SaplingGenerator; -import java.util.Optional; +import fr.hugman.promenade.world.gen.feature.PromenadeConfiguredFeatures; public class PromenadeSaplingGenerators { - public static final SaplingGenerator BLUSH_SAKURA = new SaplingGenerator("sakura/blush", 0.1F, Optional.empty(), Optional.empty(), - Optional.of(PromenadeConfiguredFeatures.BLUSH_SAKURA), Optional.of(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA), - Optional.of(PromenadeConfiguredFeatures.BLUSH_SAKURA_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA_BEES) - ); - public static final SaplingGenerator COTTON_SAKURA = new SaplingGenerator("sakura/cotton", 0.1F, Optional.empty(), Optional.empty(), - Optional.of(PromenadeConfiguredFeatures.COTTON_SAKURA), Optional.of(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA), - Optional.of(PromenadeConfiguredFeatures.COTTON_SAKURA_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA_BEES) - ); + public static final SaplingGenerator BLUSH_SAKURA = new SaplingGenerator("sakura/blush", 0.1F, Optional.empty(), Optional.empty(), + Optional.of(PromenadeConfiguredFeatures.BLUSH_SAKURA), Optional.of(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA), + Optional.of(PromenadeConfiguredFeatures.BLUSH_SAKURA_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_BLUSH_SAKURA_BEES) + ); + public static final SaplingGenerator COTTON_SAKURA = new SaplingGenerator("sakura/cotton", 0.1F, Optional.empty(), Optional.empty(), + Optional.of(PromenadeConfiguredFeatures.COTTON_SAKURA), Optional.of(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA), + Optional.of(PromenadeConfiguredFeatures.COTTON_SAKURA_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_COTTON_SAKURA_BEES) + ); - public static final SaplingGenerator SAP_MAPLE = new SaplingGenerator("maple/sap", 0.1F, Optional.empty(), Optional.empty(), - Optional.of(PromenadeConfiguredFeatures.SAP_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE), - Optional.of(PromenadeConfiguredFeatures.SAP_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE_BEES) - ); - public static final SaplingGenerator VERMILION_MAPLE = new SaplingGenerator("maple/vermilion", 0.1F, Optional.empty(), Optional.empty(), - Optional.of(PromenadeConfiguredFeatures.VERMILION_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE), - Optional.of(PromenadeConfiguredFeatures.VERMILION_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE_BEES) - ); - public static final SaplingGenerator FULVOUS_MAPLE = new SaplingGenerator("maple/fulvous", 0.1F, Optional.empty(), Optional.empty(), - Optional.of(PromenadeConfiguredFeatures.FULVOUS_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE), - Optional.of(PromenadeConfiguredFeatures.FULVOUS_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE_BEES) - ); - public static final SaplingGenerator MIKADO_MAPLE = new SaplingGenerator("maple/vermilion", 0.1F, Optional.empty(), Optional.empty(), - Optional.of(PromenadeConfiguredFeatures.MIKADO_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE), - Optional.of(PromenadeConfiguredFeatures.MIKADO_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE_BEES) - ); + public static final SaplingGenerator SAP_MAPLE = new SaplingGenerator("maple/sap", 0.1F, Optional.empty(), Optional.empty(), + Optional.of(PromenadeConfiguredFeatures.SAP_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE), + Optional.of(PromenadeConfiguredFeatures.SAP_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_SAP_MAPLE_BEES) + ); + public static final SaplingGenerator VERMILION_MAPLE = new SaplingGenerator("maple/vermilion", 0.1F, Optional.empty(), Optional.empty(), + Optional.of(PromenadeConfiguredFeatures.VERMILION_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE), + Optional.of(PromenadeConfiguredFeatures.VERMILION_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_VERMILION_MAPLE_BEES) + ); + public static final SaplingGenerator FULVOUS_MAPLE = new SaplingGenerator("maple/fulvous", 0.1F, Optional.empty(), Optional.empty(), + Optional.of(PromenadeConfiguredFeatures.FULVOUS_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE), + Optional.of(PromenadeConfiguredFeatures.FULVOUS_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_FULVOUS_MAPLE_BEES) + ); + public static final SaplingGenerator MIKADO_MAPLE = new SaplingGenerator("maple/vermilion", 0.1F, Optional.empty(), Optional.empty(), + Optional.of(PromenadeConfiguredFeatures.MIKADO_MAPLE), Optional.of(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE), + Optional.of(PromenadeConfiguredFeatures.MIKADO_MAPLE_BEES), Optional.of(PromenadeConfiguredFeatures.FANCY_MIKADO_MAPLE_BEES) + ); - public static final SaplingGenerator PALM = new SaplingGenerator("palm", Optional.empty(), Optional.of(PromenadeConfiguredFeatures.PALM), Optional.empty()); + public static final SaplingGenerator PALM = new SaplingGenerator("palm", Optional.empty(), Optional.of(PromenadeConfiguredFeatures.PALM), Optional.empty()); } diff --git a/src/main/java/fr/hugman/promenade/world/biome/PromenadeBiomes.java b/src/main/java/fr/hugman/promenade/world/biome/PromenadeBiomes.java index ba6c6e98..2e787fad 100644 --- a/src/main/java/fr/hugman/promenade/world/biome/PromenadeBiomes.java +++ b/src/main/java/fr/hugman/promenade/world/biome/PromenadeBiomes.java @@ -1,11 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.biome; import com.terraformersmc.biolith.api.biome.BiomePlacement; import com.terraformersmc.biolith.api.surface.SurfaceGeneration; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.block.PromenadeBlocks; -import fr.hugman.promenade.config.PromenadeConfig; -import fr.hugman.promenade.tag.PromenadeBiomeTags; + import net.minecraft.block.Blocks; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; @@ -23,96 +31,101 @@ import net.minecraft.world.gen.surfacebuilder.MaterialRules; import net.minecraft.world.gen.surfacebuilder.VanillaSurfaceRules; +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.block.PromenadeBlocks; +import fr.hugman.promenade.config.PromenadeConfig; +import fr.hugman.promenade.tag.PromenadeBiomeTags; + public class PromenadeBiomes { - public static final RegistryKey BLUSH_SAKURA_GROVE = of("blush_sakura_grove"); - public static final RegistryKey COTTON_SAKURA_GROVE = of("cotton_sakura_grove"); - public static final RegistryKey CARNELIAN_TREEWAY = of("carnelian_treeway"); - public static final RegistryKey GLACARIAN_TAIGA = of("glacarian_taiga"); + public static final RegistryKey BLUSH_SAKURA_GROVE = of("blush_sakura_grove"); + public static final RegistryKey COTTON_SAKURA_GROVE = of("cotton_sakura_grove"); + public static final RegistryKey CARNELIAN_TREEWAY = of("carnelian_treeway"); + public static final RegistryKey GLACARIAN_TAIGA = of("glacarian_taiga"); - public static final RegistryKey DARK_AMARANTH_FOREST = of("dark_amaranth_forest"); + public static final RegistryKey DARK_AMARANTH_FOREST = of("dark_amaranth_forest"); - public static final MultiNoiseUtil.NoiseHypercube DEFAULT_DARK_AMARANTH_FOREST_HYPERCUBE = MultiNoiseUtil.createNoiseHypercube(0.15f, -0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); + public static final MultiNoiseUtil.NoiseHypercube DEFAULT_DARK_AMARANTH_FOREST_HYPERCUBE = MultiNoiseUtil.createNoiseHypercube(0.15f, -0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.BIOME, Promenade.id(path)); - } + private static RegistryKey of(String path) { + return RegistryKey.of(RegistryKeys.BIOME, Promenade.id(path)); + } - public static void appendWorldGen() { - var biomeConfig = PromenadeConfig.get().biomes(); + public static void appendWorldGen() { + var biomeConfig = PromenadeConfig.get().biomes(); - // Sakura Groves - if (biomeConfig.sakuraGrovesWeight() > 0) { - double sakuraWeight = biomeConfig.sakuraGrovesWeight() / 100.0D; - BiomePlacement.replaceOverworld(BiomeKeys.FOREST, PromenadeBiomes.BLUSH_SAKURA_GROVE, sakuraWeight); - BiomePlacement.replaceOverworld(BiomeKeys.BIRCH_FOREST, PromenadeBiomes.COTTON_SAKURA_GROVE, sakuraWeight); - } + // Sakura Groves + if (biomeConfig.sakuraGrovesWeight() > 0) { + double sakuraWeight = biomeConfig.sakuraGrovesWeight() / 100.0D; + BiomePlacement.replaceOverworld(BiomeKeys.FOREST, PromenadeBiomes.BLUSH_SAKURA_GROVE, sakuraWeight); + BiomePlacement.replaceOverworld(BiomeKeys.BIRCH_FOREST, PromenadeBiomes.COTTON_SAKURA_GROVE, sakuraWeight); + } - // Carnelian Treeway - if (biomeConfig.carnelianTreewayWeight() > 0) { - BiomePlacement.replaceOverworld(BiomeKeys.PLAINS, PromenadeBiomes.CARNELIAN_TREEWAY, biomeConfig.carnelianTreewayWeight() / 100.0D); - } + // Carnelian Treeway + if (biomeConfig.carnelianTreewayWeight() > 0) { + BiomePlacement.replaceOverworld(BiomeKeys.PLAINS, PromenadeBiomes.CARNELIAN_TREEWAY, biomeConfig.carnelianTreewayWeight() / 100.0D); + } - // Glacarian Taiga - if (biomeConfig.glacarianTaigaWeight() > 0) { - double glacarianTaigaWeight = biomeConfig.glacarianTaigaWeight() / 100.0D; - BiomePlacement.replaceOverworld(BiomeKeys.TAIGA, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); - BiomePlacement.replaceOverworld(BiomeKeys.SNOWY_TAIGA, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); - BiomePlacement.replaceOverworld(BiomeKeys.SNOWY_SLOPES, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); - BiomePlacement.replaceOverworld(BiomeKeys.JAGGED_PEAKS, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); - BiomePlacement.replaceOverworld(BiomeKeys.GROVE, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); - } + // Glacarian Taiga + if (biomeConfig.glacarianTaigaWeight() > 0) { + double glacarianTaigaWeight = biomeConfig.glacarianTaigaWeight() / 100.0D; + BiomePlacement.replaceOverworld(BiomeKeys.TAIGA, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + BiomePlacement.replaceOverworld(BiomeKeys.SNOWY_TAIGA, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + BiomePlacement.replaceOverworld(BiomeKeys.SNOWY_SLOPES, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + BiomePlacement.replaceOverworld(BiomeKeys.JAGGED_PEAKS, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + BiomePlacement.replaceOverworld(BiomeKeys.GROVE, PromenadeBiomes.GLACARIAN_TAIGA, glacarianTaigaWeight); + } - if (biomeConfig.darkAmaranthForestsNoise().isPresent()) { - BiomePlacement.addNether(PromenadeBiomes.DARK_AMARANTH_FOREST, biomeConfig.darkAmaranthForestsNoise().get()); + if (biomeConfig.darkAmaranthForestsNoise().isPresent()) { + BiomePlacement.addNether(PromenadeBiomes.DARK_AMARANTH_FOREST, biomeConfig.darkAmaranthForestsNoise().get()); - SurfaceGeneration.addNetherSurfaceRules(Promenade.id("dark_amaranth_forest"), - MaterialRules.condition(MaterialRules.STONE_DEPTH_FLOOR, - MaterialRules.sequence( - MaterialRules.condition(MaterialRules.not(MaterialRules.aboveY(YOffset.fixed(32), 0)), MaterialRules.condition(MaterialRules.hole(), VanillaSurfaceRules.block(Blocks.LAVA))), - MaterialRules.condition(MaterialRules.biome(PromenadeBiomes.DARK_AMARANTH_FOREST), - MaterialRules.condition( - MaterialRules.not(MaterialRules.noiseThreshold(NoiseParametersKeys.NETHERRACK, 0.54)), - MaterialRules.condition(MaterialRules.aboveY(YOffset.fixed(31), 0), MaterialRules.sequence(MaterialRules.condition(MaterialRules.noiseThreshold(NoiseParametersKeys.NETHER_WART, 1.17), VanillaSurfaceRules.block(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK)), VanillaSurfaceRules.block(PromenadeBlocks.DARK_AMARANTH_NYLIUM))) - ) - ) - ) - )); - } - } + SurfaceGeneration.addNetherSurfaceRules(Promenade.id("dark_amaranth_forest"), + MaterialRules.condition(MaterialRules.STONE_DEPTH_FLOOR, + MaterialRules.sequence( + MaterialRules.condition(MaterialRules.not(MaterialRules.aboveY(YOffset.fixed(32), 0)), MaterialRules.condition(MaterialRules.hole(), VanillaSurfaceRules.block(Blocks.LAVA))), + MaterialRules.condition(MaterialRules.biome(PromenadeBiomes.DARK_AMARANTH_FOREST), + MaterialRules.condition( + MaterialRules.not(MaterialRules.noiseThreshold(NoiseParametersKeys.NETHERRACK, 0.54)), + MaterialRules.condition(MaterialRules.aboveY(YOffset.fixed(31), 0), MaterialRules.sequence(MaterialRules.condition(MaterialRules.noiseThreshold(NoiseParametersKeys.NETHER_WART, 1.17), VanillaSurfaceRules.block(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK)), VanillaSurfaceRules.block(PromenadeBlocks.DARK_AMARANTH_NYLIUM))) + ) + ) + ) + )); + } + } - /** - * Check if the entity can freeze from the biome and weather. - * - * @param entity The entity to check. - * @return true if the entity can freeze, false otherwise. - */ - public static boolean canFreezeFromBiomeAndWeather(LivingEntity entity) { - RegistryEntry biome = entity.getEntityWorld().getBiome(entity.getBlockPos()); - if (entity.getType().isIn(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES)) { - // is immune - return false; - } - if (!biome.isIn(PromenadeBiomeTags.CAN_FREEZE_DURING_SNOWFALL) || entity.isSpectator()) { - // is not the correct biome - // is spectator - return false; - } - if (!entity.getEntityWorld().isRaining()) { - // is not snowing - return false; - } - boolean exposedToSky = entity.getEntityWorld().getLightLevel(LightType.SKY, entity.getBlockPos()) >= 5; - boolean lightSourceNear = entity.getEntityWorld().getLightLevel(LightType.BLOCK, entity.getBlockPos()) >= 5; - if (lightSourceNear || !exposedToSky) { - // is near a light source - // is not exposed much to sky - return false; - } - // wear any leather piece - return !entity.getEquippedStack(EquipmentSlot.HEAD).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES) && - !entity.getEquippedStack(EquipmentSlot.CHEST).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES) && - !entity.getEquippedStack(EquipmentSlot.LEGS).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES) && - !entity.getEquippedStack(EquipmentSlot.FEET).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES); - } + /** + * Check if the entity can freeze from the biome and weather. + * + * @param entity The entity to check. + * @return true if the entity can freeze, false otherwise. + */ + public static boolean canFreezeFromBiomeAndWeather(LivingEntity entity) { + RegistryEntry biome = entity.getEntityWorld().getBiome(entity.getBlockPos()); + if (entity.getType().isIn(EntityTypeTags.FREEZE_IMMUNE_ENTITY_TYPES)) { + // is immune + return false; + } + if (!biome.isIn(PromenadeBiomeTags.CAN_FREEZE_DURING_SNOWFALL) || entity.isSpectator()) { + // is not the correct biome + // is spectator + return false; + } + if (!entity.getEntityWorld().isRaining()) { + // is not snowing + return false; + } + boolean exposedToSky = entity.getEntityWorld().getLightLevel(LightType.SKY, entity.getBlockPos()) >= 5; + boolean lightSourceNear = entity.getEntityWorld().getLightLevel(LightType.BLOCK, entity.getBlockPos()) >= 5; + if (lightSourceNear || !exposedToSky) { + // is near a light source + // is not exposed much to sky + return false; + } + // wear any leather piece + return !entity.getEquippedStack(EquipmentSlot.HEAD).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES) && + !entity.getEquippedStack(EquipmentSlot.CHEST).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES) && + !entity.getEquippedStack(EquipmentSlot.LEGS).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES) && + !entity.getEquippedStack(EquipmentSlot.FEET).isIn(ItemTags.FREEZE_IMMUNE_WEARABLES); + } } diff --git a/src/main/java/fr/hugman/promenade/world/biome/PromenadeFoliageColors.java b/src/main/java/fr/hugman/promenade/world/biome/PromenadeFoliageColors.java index 1323b5cb..18d968fa 100644 --- a/src/main/java/fr/hugman/promenade/world/biome/PromenadeFoliageColors.java +++ b/src/main/java/fr/hugman/promenade/world/biome/PromenadeFoliageColors.java @@ -1,6 +1,17 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.biome; public class PromenadeFoliageColors { - public static final int SAP_MAPLE = 10931465; // Carnelian Treeway's generated foliage color - public static final int PALM = 8237614; + public static final int SAP_MAPLE = 10931465; // Carnelian Treeway's generated foliage color + public static final int PALM = 8237614; } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeature.java index 0d3f22ac..c55d79d2 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeature.java @@ -1,6 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; + import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; import net.minecraft.world.StructureWorldAccess; @@ -8,40 +20,40 @@ import net.minecraft.world.gen.feature.util.FeatureContext; public class BoulderFeature extends Feature { - public BoulderFeature(Codec codec) { - super(codec); - } + public BoulderFeature(Codec codec) { + super(codec); + } - @Override - public boolean generate(FeatureContext context) { - Random random = context.getRandom(); - BoulderFeatureConfig config = context.getConfig(); - StructureWorldAccess world = context.getWorld(); - int radius = config.radius().get(random); - BlockPos pos = context.getOrigin(); - for (; pos.getY() > world.getBottomY() + radius; pos = pos.down()) { - if (!world.isAir(pos)) { - if (config.replaceableBlocks().test(world, pos)) { - break; - } - } - } - if (pos.getY() <= world.getBottomY() + radius) { - return false; - } else { - for (int i = 0; i < 3; ++i) { - int j = random.nextInt(radius); - int k = random.nextInt(radius); - int l = random.nextInt(radius); - float f = (float) (j + k + l) * 0.333F + 0.5F; - for (BlockPos pos2 : BlockPos.iterate(pos.add(-j, -k, -l), pos.add(j, k, l))) { - if (pos2.getSquaredDistance(pos) <= (double) (f * f)) { - this.setBlockState(world, pos2, config.stateProvider().get(random, pos)); - } - } - pos = pos.add(-1 + random.nextInt(2), -random.nextInt(2), -1 + random.nextInt(2)); - } - return true; - } - } + @Override + public boolean generate(FeatureContext context) { + Random random = context.getRandom(); + BoulderFeatureConfig config = context.getConfig(); + StructureWorldAccess world = context.getWorld(); + int radius = config.radius().get(random); + BlockPos pos = context.getOrigin(); + for (; pos.getY() > world.getBottomY() + radius; pos = pos.down()) { + if (!world.isAir(pos)) { + if (config.replaceableBlocks().test(world, pos)) { + break; + } + } + } + if (pos.getY() <= world.getBottomY() + radius) { + return false; + } else { + for (int i = 0; i < 3; ++i) { + int j = random.nextInt(radius); + int k = random.nextInt(radius); + int l = random.nextInt(radius); + float f = (float) (j + k + l) * 0.333F + 0.5F; + for (BlockPos pos2 : BlockPos.iterate(pos.add(-j, -k, -l), pos.add(j, k, l))) { + if (pos2.getSquaredDistance(pos) <= (double) (f * f)) { + this.setBlockState(world, pos2, config.stateProvider().get(random, pos)); + } + } + pos = pos.add(-1 + random.nextInt(2), -random.nextInt(2), -1 + random.nextInt(2)); + } + return true; + } + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeatureConfig.java b/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeatureConfig.java index 63ec431b..d78b53d0 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeatureConfig.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/BoulderFeatureConfig.java @@ -1,20 +1,32 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.util.math.intprovider.IntProvider; import net.minecraft.world.gen.blockpredicate.BlockPredicate; import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.stateprovider.BlockStateProvider; public record BoulderFeatureConfig( - BlockStateProvider stateProvider, - BlockPredicate replaceableBlocks, - IntProvider radius + BlockStateProvider stateProvider, + BlockPredicate replaceableBlocks, + IntProvider radius ) implements FeatureConfig { - public static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group( - BlockStateProvider.TYPE_CODEC.fieldOf("state").forGetter((config) -> config.stateProvider), - BlockPredicate.BASE_CODEC.fieldOf("replaceable").forGetter((config) -> config.replaceableBlocks), - IntProvider.createValidatingCodec(1, 64).fieldOf("count").forGetter((config) -> config.radius) - ).apply(instance, BoulderFeatureConfig::new)); + public static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group( + BlockStateProvider.TYPE_CODEC.fieldOf("state").forGetter((config) -> config.stateProvider), + BlockPredicate.BASE_CODEC.fieldOf("replaceable").forGetter((config) -> config.replaceableBlocks), + IntProvider.createValidatingCodec(1, 64).fieldOf("count").forGetter((config) -> config.radius) + ).apply(instance, BoulderFeatureConfig::new)); } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeature.java index b047dc87..aa7ab9de 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeature.java @@ -1,7 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; -import fr.hugman.promenade.block.PromenadeBlocks; + import net.minecraft.block.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -12,101 +23,103 @@ import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.util.FeatureContext; +import fr.hugman.promenade.block.PromenadeBlocks; + public class CoiledVinesFeature extends Feature { - public CoiledVinesFeature(Codec configCodec) { - super(configCodec); - } + public CoiledVinesFeature(Codec configCodec) { + super(configCodec); + } - @Override - public boolean generate(FeatureContext context) { - StructureWorldAccess structureWorldAccess = context.getWorld(); - BlockPos blockPos = context.getOrigin(); - if (isNotSuitable(structureWorldAccess, blockPos, Direction.UP)) { - return false; - } else { - Random random = context.getRandom(); - CoiledVinesFeatureConfig config = context.getConfig(); - int spreadWidth = config.spreadWidth(); - int spreadHeight = config.spreadHeight(); - int maxLength = config.maxLength(); - BlockPos.Mutable mutable = new BlockPos.Mutable(); + @Override + public boolean generate(FeatureContext context) { + StructureWorldAccess structureWorldAccess = context.getWorld(); + BlockPos blockPos = context.getOrigin(); + if (isNotSuitable(structureWorldAccess, blockPos, Direction.UP)) { + return false; + } else { + Random random = context.getRandom(); + CoiledVinesFeatureConfig config = context.getConfig(); + int spreadWidth = config.spreadWidth(); + int spreadHeight = config.spreadHeight(); + int maxLength = config.maxLength(); + BlockPos.Mutable mutable = new BlockPos.Mutable(); - for (int l = 0; l < spreadWidth * spreadWidth; l++) { - // Pick a random direction - var direction = config.directions().get(random.nextInt(config.directions().size())); - // Pick a random position - mutable.set(blockPos).move( - MathHelper.nextInt(random, -spreadWidth, spreadWidth), - MathHelper.nextInt(random, -spreadHeight, spreadHeight), - MathHelper.nextInt(random, -spreadWidth, spreadWidth) - ); + for (int l = 0; l < spreadWidth * spreadWidth; l++) { + // Pick a random direction + var direction = config.directions().get(random.nextInt(config.directions().size())); + // Pick a random position + mutable.set(blockPos).move( + MathHelper.nextInt(random, -spreadWidth, spreadWidth), + MathHelper.nextInt(random, -spreadHeight, spreadHeight), + MathHelper.nextInt(random, -spreadWidth, spreadWidth) + ); - if (findNonAirBlock(structureWorldAccess, mutable, direction) && !isNotSuitable(structureWorldAccess, mutable, direction)) { - int lenght = MathHelper.nextInt(random, 1, maxLength); - if (random.nextInt(6) == 0) { - lenght *= 2; - } - if (random.nextInt(5) == 0) { - lenght = 1; - } - generateVineColumn(structureWorldAccess, random, mutable, lenght, 17, 25, direction); - } - } + if (findNonAirBlock(structureWorldAccess, mutable, direction) && !isNotSuitable(structureWorldAccess, mutable, direction)) { + int lenght = MathHelper.nextInt(random, 1, maxLength); + if (random.nextInt(6) == 0) { + lenght *= 2; + } + if (random.nextInt(5) == 0) { + lenght = 1; + } + generateVineColumn(structureWorldAccess, random, mutable, lenght, 17, 25, direction); + } + } - return true; - } - } + return true; + } + } - private static boolean findNonAirBlock(WorldAccess world, BlockPos.Mutable pos, Direction direction) { - int max = 16; - do { - pos.move(direction.getOpposite()); - if (world.isOutOfHeightLimit(pos) || max-- <= 0) { - return false; - } - } while (world.getBlockState(pos).isAir()); + private static boolean findNonAirBlock(WorldAccess world, BlockPos.Mutable pos, Direction direction) { + int max = 16; + do { + pos.move(direction.getOpposite()); + if (world.isOutOfHeightLimit(pos) || max-- <= 0) { + return false; + } + } while (world.getBlockState(pos).isAir()); - pos.move(direction); - return true; - } + pos.move(direction); + return true; + } - public static void generateVineColumn( - WorldAccess world, - Random random, - BlockPos.Mutable pos, - int maxLength, - int minAge, - int maxAge, - Direction direction - ) { - for (int i = 1; i <= maxLength; i++) { - if (world.isAir(pos)) { - if (i == maxLength || !world.isAir(pos.offset(direction))) { - world.setBlockState( - pos, - PromenadeBlocks.COILED_VINES.getDefaultState() - .with(FacingBlock.FACING, direction) - .with(AbstractPlantStemBlock.AGE, MathHelper.nextInt(random, minAge, maxAge)), - Block.NOTIFY_LISTENERS - ); - break; - } + public static void generateVineColumn( + WorldAccess world, + Random random, + BlockPos.Mutable pos, + int maxLength, + int minAge, + int maxAge, + Direction direction + ) { + for (int i = 1; i <= maxLength; i++) { + if (world.isAir(pos)) { + if (i == maxLength || !world.isAir(pos.offset(direction))) { + world.setBlockState( + pos, + PromenadeBlocks.COILED_VINES.getDefaultState() + .with(FacingBlock.FACING, direction) + .with(AbstractPlantStemBlock.AGE, MathHelper.nextInt(random, minAge, maxAge)), + Block.NOTIFY_LISTENERS + ); + break; + } - world.setBlockState(pos, PromenadeBlocks.COILED_VINES_PLANT.getDefaultState().with(FacingBlock.FACING, direction), Block.NOTIFY_LISTENERS); - } + world.setBlockState(pos, PromenadeBlocks.COILED_VINES_PLANT.getDefaultState().with(FacingBlock.FACING, direction), Block.NOTIFY_LISTENERS); + } - pos.move(direction); - } - } + pos.move(direction); + } + } - private static boolean isNotSuitable(WorldAccess world, BlockPos pos, Direction direction) { - if (!world.isAir(pos)) { - return true; - } else { - BlockState blockState = world.getBlockState(pos.offset(direction.getOpposite())); - return !blockState.isOf(Blocks.NETHERRACK) && - !blockState.isOf(PromenadeBlocks.DARK_AMARANTH_NYLIUM) && - !blockState.isOf(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); - } - } + private static boolean isNotSuitable(WorldAccess world, BlockPos pos, Direction direction) { + if (!world.isAir(pos)) { + return true; + } else { + BlockState blockState = world.getBlockState(pos.offset(direction.getOpposite())); + return !blockState.isOf(Blocks.NETHERRACK) && + !blockState.isOf(PromenadeBlocks.DARK_AMARANTH_NYLIUM) && + !blockState.isOf(PromenadeBlocks.DARK_AMARANTH_WART_BLOCK); + } + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeatureConfig.java b/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeatureConfig.java index ed4fe903..118d9e0a 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeatureConfig.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/CoiledVinesFeatureConfig.java @@ -1,25 +1,37 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; +import java.util.List; + import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.util.dynamic.Codecs; import net.minecraft.util.math.Direction; import net.minecraft.world.gen.feature.FeatureConfig; -import java.util.List; - public record CoiledVinesFeatureConfig( - int spreadWidth, - int spreadHeight, - int maxLength, - List directions + int spreadWidth, + int spreadHeight, + int maxLength, + List directions ) implements FeatureConfig { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codecs.POSITIVE_INT.fieldOf("spread_width").forGetter(CoiledVinesFeatureConfig::spreadWidth), - Codecs.POSITIVE_INT.fieldOf("spread_height").forGetter(CoiledVinesFeatureConfig::spreadHeight), - Codecs.POSITIVE_INT.fieldOf("max_length").forGetter(CoiledVinesFeatureConfig::maxLength), - Codecs.nonEmptyList(Direction.CODEC.listOf()).optionalFieldOf("directions", List.of(Direction.values())).forGetter(CoiledVinesFeatureConfig::directions) - ).apply(instance, CoiledVinesFeatureConfig::new) - ); + Codecs.POSITIVE_INT.fieldOf("spread_width").forGetter(CoiledVinesFeatureConfig::spreadWidth), + Codecs.POSITIVE_INT.fieldOf("spread_height").forGetter(CoiledVinesFeatureConfig::spreadHeight), + Codecs.POSITIVE_INT.fieldOf("max_length").forGetter(CoiledVinesFeatureConfig::maxLength), + Codecs.nonEmptyList(Direction.CODEC.listOf()).optionalFieldOf("directions", List.of(Direction.values())).forGetter(CoiledVinesFeatureConfig::directions) + ).apply(instance, CoiledVinesFeatureConfig::new) + ); } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/FreezeTopLayerFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/FreezeTopLayerFeature.java index 4bb329bf..b6a23faf 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/FreezeTopLayerFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/FreezeTopLayerFeature.java @@ -1,6 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; + import net.minecraft.block.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -13,89 +25,89 @@ import net.minecraft.world.gen.feature.util.FeatureContext; public class FreezeTopLayerFeature extends Feature { - public FreezeTopLayerFeature(Codec codec) { - super(codec); - } + public FreezeTopLayerFeature(Codec codec) { + super(codec); + } - @Override - public boolean generate(FeatureContext context) { - var world = context.getWorld(); - var random = context.getRandom(); - var blockPos = context.getOrigin(); - var topMutable = new BlockPos.Mutable(); - var groundMutable = new BlockPos.Mutable(); - var undergroundMutable = new BlockPos.Mutable(); + @Override + public boolean generate(FeatureContext context) { + var world = context.getWorld(); + var random = context.getRandom(); + var blockPos = context.getOrigin(); + var topMutable = new BlockPos.Mutable(); + var groundMutable = new BlockPos.Mutable(); + var undergroundMutable = new BlockPos.Mutable(); - var snowDepth = ConstantIntProvider.create(3); - var topSnowLayers = UniformIntProvider.create(2, 3); - var packedIceDepth = UniformIntProvider.create(2, 3); - var normalIceDepth = UniformIntProvider.create(2, 3); + var snowDepth = ConstantIntProvider.create(3); + var topSnowLayers = UniformIntProvider.create(2, 3); + var packedIceDepth = UniformIntProvider.create(2, 3); + var normalIceDepth = UniformIntProvider.create(2, 3); - for (int i = 0; i < 16; ++i) { - for (int j = 0; j < 16; ++j) { - int x = blockPos.getX() + i; - int z = blockPos.getZ() + j; + for (int i = 0; i < 16; ++i) { + for (int j = 0; j < 16; ++j) { + int x = blockPos.getX() + i; + int z = blockPos.getZ() + j; - /* ==================== */ - /* SURFACE GROUND LEVEL */ - /* ==================== */ - topMutable.set(x, world.getTopY(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, x, z), z); - Biome biome = world.getBiome(topMutable).value(); - groundMutable.set(topMutable).move(Direction.DOWN, 1); + /* ==================== */ + /* SURFACE GROUND LEVEL */ + /* ==================== */ + topMutable.set(x, world.getTopY(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, x, z), z); + Biome biome = world.getBiome(topMutable).value(); + groundMutable.set(topMutable).move(Direction.DOWN, 1); - // Layers of Snow - if (biome.canSetSnow(world, topMutable)) { - for (int n = 1; n <= snowDepth.get(random); n++) { - if (!biome.canSetSnow(world, topMutable)) { - break; - } - world.setBlockState(topMutable, Blocks.SNOW_BLOCK.getDefaultState(), Block.NOTIFY_LISTENERS); - topMutable.move(Direction.UP, 1); - } + // Layers of Snow + if (biome.canSetSnow(world, topMutable)) { + for (int n = 1; n <= snowDepth.get(random); n++) { + if (!biome.canSetSnow(world, topMutable)) { + break; + } + world.setBlockState(topMutable, Blocks.SNOW_BLOCK.getDefaultState(), Block.NOTIFY_LISTENERS); + topMutable.move(Direction.UP, 1); + } - BlockState blockState = world.getBlockState(groundMutable); - if (blockState.contains(SnowyBlock.SNOWY)) { - world.setBlockState(groundMutable, blockState.with(SnowyBlock.SNOWY, true), Block.NOTIFY_LISTENERS); - } - } + BlockState blockState = world.getBlockState(groundMutable); + if (blockState.contains(SnowyBlock.SNOWY)) { + world.setBlockState(groundMutable, blockState.with(SnowyBlock.SNOWY, true), Block.NOTIFY_LISTENERS); + } + } - // Water -> Ice - if (biome.canSetIce(world, groundMutable, false)) { - undergroundMutable.set(groundMutable); - for (int n = 1; n <= packedIceDepth.get(random); n++) { - if (!biome.canSetIce(world, undergroundMutable, false)) { - break; - } - world.setBlockState(undergroundMutable, Blocks.PACKED_ICE.getDefaultState(), Block.NOTIFY_LISTENERS); - undergroundMutable.move(Direction.DOWN, 1); - } - for (int n = 1; n <= normalIceDepth.get(random); n++) { - if (!biome.canSetIce(world, undergroundMutable, false)) { - break; - } - world.setBlockState(undergroundMutable, Blocks.ICE.getDefaultState(), Block.NOTIFY_LISTENERS); - undergroundMutable.move(Direction.DOWN, 1); - } - } + // Water -> Ice + if (biome.canSetIce(world, groundMutable, false)) { + undergroundMutable.set(groundMutable); + for (int n = 1; n <= packedIceDepth.get(random); n++) { + if (!biome.canSetIce(world, undergroundMutable, false)) { + break; + } + world.setBlockState(undergroundMutable, Blocks.PACKED_ICE.getDefaultState(), Block.NOTIFY_LISTENERS); + undergroundMutable.move(Direction.DOWN, 1); + } + for (int n = 1; n <= normalIceDepth.get(random); n++) { + if (!biome.canSetIce(world, undergroundMutable, false)) { + break; + } + world.setBlockState(undergroundMutable, Blocks.ICE.getDefaultState(), Block.NOTIFY_LISTENERS); + undergroundMutable.move(Direction.DOWN, 1); + } + } - /* ======================= */ - /* SURFACE MOTION BLOCKING */ - /* ======================= */ - topMutable.set(x, world.getTopY(Heightmap.Type.MOTION_BLOCKING, x, z), z); - groundMutable.set(topMutable).move(Direction.DOWN, 1); - biome = world.getBiome(topMutable).value(); // just in case I guess? + /* ======================= */ + /* SURFACE MOTION BLOCKING */ + /* ======================= */ + topMutable.set(x, world.getTopY(Heightmap.Type.MOTION_BLOCKING, x, z), z); + groundMutable.set(topMutable).move(Direction.DOWN, 1); + biome = world.getBiome(topMutable).value(); // just in case I guess? - // Thin Snow - if (biome.canSetSnow(world, topMutable)) { - world.setBlockState(topMutable, Blocks.SNOW.getDefaultState().with(SnowBlock.LAYERS, topSnowLayers.get(random)), Block.NOTIFY_LISTENERS); + // Thin Snow + if (biome.canSetSnow(world, topMutable)) { + world.setBlockState(topMutable, Blocks.SNOW.getDefaultState().with(SnowBlock.LAYERS, topSnowLayers.get(random)), Block.NOTIFY_LISTENERS); - BlockState blockState = world.getBlockState(groundMutable); - if (blockState.contains(SnowyBlock.SNOWY)) { - world.setBlockState(groundMutable, blockState.with(SnowyBlock.SNOWY, true), Block.NOTIFY_LISTENERS); - } - } - } - } - return true; - } + BlockState blockState = world.getBlockState(groundMutable); + if (blockState.contains(SnowyBlock.SNOWY)) { + world.setBlockState(groundMutable, blockState.with(SnowyBlock.SNOWY, true), Block.NOTIFY_LISTENERS); + } + } + } + } + return true; + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeature.java index 3eda3fc9..b51b9aa6 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeature.java @@ -1,31 +1,43 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; + import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.util.FeatureContext; public class NoisePickedFeature extends Feature { - public NoisePickedFeature(Codec codec) { - super(codec); - } + public NoisePickedFeature(Codec codec) { + super(codec); + } - @Override - public boolean generate(FeatureContext context) { - var pos = context.getOrigin(); - var random = context.getRandom(); - var structureWorldAccess = context.getWorld(); - var chunkGenerator = context.getGenerator(); - var config = context.getConfig(); + @Override + public boolean generate(FeatureContext context) { + var pos = context.getOrigin(); + var random = context.getRandom(); + var structureWorldAccess = context.getWorld(); + var chunkGenerator = context.getGenerator(); + var config = context.getConfig(); - double noiseValue = Biome.FOLIAGE_NOISE.sample((double) pos.getX() / config.noiseScale().x(), (double) pos.getZ() / config.noiseScale().z(), false); - var entries = config.entries().stream() - .filter(entry -> entry.min() < noiseValue && noiseValue < entry.max()) - .toList(); - if (entries.isEmpty()) { - return false; - } - var entry = entries.get(context.getRandom().nextInt(entries.size())); - return entry.generate(structureWorldAccess, chunkGenerator, random, pos); - } + double noiseValue = Biome.FOLIAGE_NOISE.sample((double) pos.getX() / config.noiseScale().x(), (double) pos.getZ() / config.noiseScale().z(), false); + var entries = config.entries().stream() + .filter(entry -> entry.min() < noiseValue && noiseValue < entry.max()) + .toList(); + if (entries.isEmpty()) { + return false; + } + var entry = entries.get(context.getRandom().nextInt(entries.size())); + return entry.generate(structureWorldAccess, chunkGenerator, random, pos); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureConfig.java b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureConfig.java index 8e79c96c..5bc29cb8 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureConfig.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureConfig.java @@ -1,25 +1,38 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; +import java.util.List; +import java.util.stream.Stream; + import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import fr.hugman.promenade.util.NoiseScale; + import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.FeatureConfig; -import java.util.List; -import java.util.stream.Stream; +import fr.hugman.promenade.util.NoiseScale; public record NoisePickedFeatureConfig( - NoiseScale noiseScale, - List entries + NoiseScale noiseScale, + List entries ) implements FeatureConfig { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - NoiseScale.CODEC.fieldOf("noise").forGetter(NoisePickedFeatureConfig::noiseScale), - NoisePickedFeatureEntry.CODEC.listOf().fieldOf("entries").forGetter(NoisePickedFeatureConfig::entries) - ).apply(instance, NoisePickedFeatureConfig::new)); + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + NoiseScale.CODEC.fieldOf("noise").forGetter(NoisePickedFeatureConfig::noiseScale), + NoisePickedFeatureEntry.CODEC.listOf().fieldOf("entries").forGetter(NoisePickedFeatureConfig::entries) + ).apply(instance, NoisePickedFeatureConfig::new)); - @Override - public Stream> getDecoratedFeatures() { - return entries.stream().flatMap(entry -> entry.feature().value().getDecoratedFeatures()); - } + @Override + public Stream> getDecoratedFeatures() { + return entries.stream().flatMap(entry -> entry.feature().value().getDecoratedFeatures()); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureEntry.java b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureEntry.java index dd8c8e26..d61aa405 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureEntry.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/NoisePickedFeatureEntry.java @@ -1,8 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import fr.hugman.promenade.codec.PromenadeCodecs; + import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; @@ -10,18 +21,20 @@ import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.PlacedFeature; +import fr.hugman.promenade.codec.PromenadeCodecs; + public record NoisePickedFeatureEntry( - RegistryEntry feature, - float min, - float max + RegistryEntry feature, + float min, + float max ) { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - PlacedFeature.REGISTRY_CODEC.fieldOf("feature").forGetter(NoisePickedFeatureEntry::feature), - PromenadeCodecs.SAMPLED_NOISE_VALUE.fieldOf("min").forGetter(NoisePickedFeatureEntry::min), - PromenadeCodecs.SAMPLED_NOISE_VALUE.fieldOf("max").forGetter(NoisePickedFeatureEntry::max) - ).apply(instance, NoisePickedFeatureEntry::new)); + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + PlacedFeature.REGISTRY_CODEC.fieldOf("feature").forGetter(NoisePickedFeatureEntry::feature), + PromenadeCodecs.SAMPLED_NOISE_VALUE.fieldOf("min").forGetter(NoisePickedFeatureEntry::min), + PromenadeCodecs.SAMPLED_NOISE_VALUE.fieldOf("max").forGetter(NoisePickedFeatureEntry::max) + ).apply(instance, NoisePickedFeatureEntry::new)); - public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos) { - return this.feature.value().generateUnregistered(world, chunkGenerator, random, pos); - } + public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos) { + return this.feature.value().generateUnregistered(world, chunkGenerator, random, pos); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeConfiguredFeatures.java b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeConfiguredFeatures.java index d8a77bc1..b1f1ccfd 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeConfiguredFeatures.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeConfiguredFeatures.java @@ -1,86 +1,98 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; -import fr.hugman.promenade.Promenade; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.world.gen.feature.ConfiguredFeature; +import fr.hugman.promenade.Promenade; + public class PromenadeConfiguredFeatures { - // Ores - public static final RegistryKey> PACKED_ICE_ORE = of("ore/packed_ice"); - public static final RegistryKey> BLUE_ICE_ORE = of("ore/blue_ice"); + // Ores + public static final RegistryKey> PACKED_ICE_ORE = of("ore/packed_ice"); + public static final RegistryKey> BLUE_ICE_ORE = of("ore/blue_ice"); - public static final RegistryKey> ASPHALT_ORE = of("ore/asphalt"); - public static final RegistryKey> BLUNITE_ORE = of("ore/blunite"); + public static final RegistryKey> ASPHALT_ORE = of("ore/asphalt"); + public static final RegistryKey> BLUNITE_ORE = of("ore/blunite"); - // Trees - public static final RegistryKey> BLUSH_SAKURA = of("tree/sakura/blush/regular"); - public static final RegistryKey> FANCY_BLUSH_SAKURA = of("tree/sakura/blush/fancy"); - public static final RegistryKey> BLUSH_SAKURA_BEES = of("tree/sakura/blush/bees"); - public static final RegistryKey> FANCY_BLUSH_SAKURA_BEES = of("tree/sakura/blush/fancy_bees"); + // Trees + public static final RegistryKey> BLUSH_SAKURA = of("tree/sakura/blush/regular"); + public static final RegistryKey> FANCY_BLUSH_SAKURA = of("tree/sakura/blush/fancy"); + public static final RegistryKey> BLUSH_SAKURA_BEES = of("tree/sakura/blush/bees"); + public static final RegistryKey> FANCY_BLUSH_SAKURA_BEES = of("tree/sakura/blush/fancy_bees"); - public static final RegistryKey> COTTON_SAKURA = of("tree/sakura/cotton/regular"); - public static final RegistryKey> FANCY_COTTON_SAKURA = of("tree/sakura/cotton/fancy"); - public static final RegistryKey> COTTON_SAKURA_BEES = of("tree/sakura/cotton/bees"); - public static final RegistryKey> FANCY_COTTON_SAKURA_BEES = of("tree/sakura/cotton/fancy_bees"); + public static final RegistryKey> COTTON_SAKURA = of("tree/sakura/cotton/regular"); + public static final RegistryKey> FANCY_COTTON_SAKURA = of("tree/sakura/cotton/fancy"); + public static final RegistryKey> COTTON_SAKURA_BEES = of("tree/sakura/cotton/bees"); + public static final RegistryKey> FANCY_COTTON_SAKURA_BEES = of("tree/sakura/cotton/fancy_bees"); - public static final RegistryKey> SAP_MAPLE = of("tree/maple/sap/regular"); - public static final RegistryKey> FANCY_SAP_MAPLE = of("tree/maple/sap/fancy"); - public static final RegistryKey> SAP_MAPLE_BEES = of("tree/maple/sap/bees"); - public static final RegistryKey> FANCY_SAP_MAPLE_BEES = of("tree/maple/sap/fancy_bees"); + public static final RegistryKey> SAP_MAPLE = of("tree/maple/sap/regular"); + public static final RegistryKey> FANCY_SAP_MAPLE = of("tree/maple/sap/fancy"); + public static final RegistryKey> SAP_MAPLE_BEES = of("tree/maple/sap/bees"); + public static final RegistryKey> FANCY_SAP_MAPLE_BEES = of("tree/maple/sap/fancy_bees"); - public static final RegistryKey> VERMILION_MAPLE = of("tree/maple/vermilion/regular"); - public static final RegistryKey> FANCY_VERMILION_MAPLE = of("tree/maple/vermilion/fancy"); - public static final RegistryKey> VERMILION_MAPLE_BEES = of("tree/maple/vermilion/bees"); - public static final RegistryKey> FANCY_VERMILION_MAPLE_BEES = of("tree/maple/vermilion/fancy_bees"); + public static final RegistryKey> VERMILION_MAPLE = of("tree/maple/vermilion/regular"); + public static final RegistryKey> FANCY_VERMILION_MAPLE = of("tree/maple/vermilion/fancy"); + public static final RegistryKey> VERMILION_MAPLE_BEES = of("tree/maple/vermilion/bees"); + public static final RegistryKey> FANCY_VERMILION_MAPLE_BEES = of("tree/maple/vermilion/fancy_bees"); - public static final RegistryKey> FULVOUS_MAPLE = of("tree/maple/fulvous/regular"); - public static final RegistryKey> FANCY_FULVOUS_MAPLE = of("tree/maple/fulvous/fancy"); - public static final RegistryKey> FULVOUS_MAPLE_BEES = of("tree/maple/fulvous/bees"); - public static final RegistryKey> FANCY_FULVOUS_MAPLE_BEES = of("tree/maple/fulvous/fancy_bees"); + public static final RegistryKey> FULVOUS_MAPLE = of("tree/maple/fulvous/regular"); + public static final RegistryKey> FANCY_FULVOUS_MAPLE = of("tree/maple/fulvous/fancy"); + public static final RegistryKey> FULVOUS_MAPLE_BEES = of("tree/maple/fulvous/bees"); + public static final RegistryKey> FANCY_FULVOUS_MAPLE_BEES = of("tree/maple/fulvous/fancy_bees"); - public static final RegistryKey> MIKADO_MAPLE = of("tree/maple/mikado/regular"); - public static final RegistryKey> FANCY_MIKADO_MAPLE = of("tree/maple/mikado/fancy"); - public static final RegistryKey> MIKADO_MAPLE_BEES = of("tree/maple/mikado/bees"); - public static final RegistryKey> FANCY_MIKADO_MAPLE_BEES = of("tree/maple/mikado/fancy_bees"); + public static final RegistryKey> MIKADO_MAPLE = of("tree/maple/mikado/regular"); + public static final RegistryKey> FANCY_MIKADO_MAPLE = of("tree/maple/mikado/fancy"); + public static final RegistryKey> MIKADO_MAPLE_BEES = of("tree/maple/mikado/bees"); + public static final RegistryKey> FANCY_MIKADO_MAPLE_BEES = of("tree/maple/mikado/fancy_bees"); - public static final RegistryKey> PALM = of("tree/palm"); + public static final RegistryKey> PALM = of("tree/palm"); - public static final RegistryKey> SNOWY_MEGA_SPRUCE = of("tree/snowy_mega_spruce"); + public static final RegistryKey> SNOWY_MEGA_SPRUCE = of("tree/snowy_mega_spruce"); - public static final RegistryKey> DARK_AMARANTH_FUNGUS = of("tree/dark_amaranth_fungus"); - public static final RegistryKey> PLANTED_DARK_AMARANTH_FUNGUS = of("tree/dark_amaranth_fungus_planted"); + public static final RegistryKey> DARK_AMARANTH_FUNGUS = of("tree/dark_amaranth_fungus"); + public static final RegistryKey> PLANTED_DARK_AMARANTH_FUNGUS = of("tree/dark_amaranth_fungus_planted"); - // Randomized trees - public static final RegistryKey> BLUSH_SAKURA_GROVE_TREE = of("tree/blush_sakura_grove"); - public static final RegistryKey> COTTON_SAKURA_GROVE_TREE = of("tree/cotton_sakura_grove"); + // Randomized trees + public static final RegistryKey> BLUSH_SAKURA_GROVE_TREE = of("tree/blush_sakura_grove"); + public static final RegistryKey> COTTON_SAKURA_GROVE_TREE = of("tree/cotton_sakura_grove"); - public static final RegistryKey> CARNELIAN_TREEWAY_SAP_TREE = of("tree/carnelian_treeway/sap"); - public static final RegistryKey> CARNELIAN_TREEWAY_VERMILION_TREE = of("tree/carnelian_treeway/vermilion"); - public static final RegistryKey> CARNELIAN_TREEWAY_FULVOUS_TREE = of("tree/carnelian_treeway/fulvous"); - public static final RegistryKey> CARNELIAN_TREEWAY_MIKADO_TREE = of("tree/carnelian_treeway/mikado"); + public static final RegistryKey> CARNELIAN_TREEWAY_SAP_TREE = of("tree/carnelian_treeway/sap"); + public static final RegistryKey> CARNELIAN_TREEWAY_VERMILION_TREE = of("tree/carnelian_treeway/vermilion"); + public static final RegistryKey> CARNELIAN_TREEWAY_FULVOUS_TREE = of("tree/carnelian_treeway/fulvous"); + public static final RegistryKey> CARNELIAN_TREEWAY_MIKADO_TREE = of("tree/carnelian_treeway/mikado"); - public static final RegistryKey> CARNELIAN_TREEWAY_TREE = of("tree/carnelian_treeway"); - public static final RegistryKey> CARNELIAN_TREEWAY_FALLEN_LEAVES = of("patch/carnelian_treeway/fallen_leaves"); + public static final RegistryKey> CARNELIAN_TREEWAY_TREE = of("tree/carnelian_treeway"); + public static final RegistryKey> CARNELIAN_TREEWAY_FALLEN_LEAVES = of("patch/carnelian_treeway/fallen_leaves"); - // Vegetation - public static final RegistryKey> WATER_POOL_GRAVEL_DECORATED = of("water_pool_gravel_decorated"); + // Vegetation + public static final RegistryKey> WATER_POOL_GRAVEL_DECORATED = of("water_pool_gravel_decorated"); - public static final RegistryKey> CUTE_LITTLE_ROCK = of("cute_little_rock"); + public static final RegistryKey> CUTE_LITTLE_ROCK = of("cute_little_rock"); - public static final RegistryKey> BAMBOO_PATCH = of("bamboo_patch"); - public static final RegistryKey> BLUEBERRY_BUSH_PATCH = of("blueberry_bush_patch"); + public static final RegistryKey> BAMBOO_PATCH = of("bamboo_patch"); + public static final RegistryKey> BLUEBERRY_BUSH_PATCH = of("blueberry_bush_patch"); - public static final RegistryKey> DARK_AMARANTH_FOREST_VEGETATION = of("dark_amaranth_forest_vegetation"); - public static final RegistryKey> DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION = of("dark_amaranth_forest_vegetation/bonemeal"); + public static final RegistryKey> DARK_AMARANTH_FOREST_VEGETATION = of("dark_amaranth_forest_vegetation"); + public static final RegistryKey> DARK_AMARANTH_FOREST_BONEMEAL_VEGETATION = of("dark_amaranth_forest_vegetation/bonemeal"); - public static final RegistryKey> COILED_VINES = of("coiled_vines"); + public static final RegistryKey> COILED_VINES = of("coiled_vines"); - public static final RegistryKey> FALLEN_VERMILION_MAPLE_LEAVES = of("patch/fallen_vermilion_maple_leaves"); - public static final RegistryKey> FALLEN_FULVOUS_MAPLE_LEAVES = of("patch/fallen_fulvous_maple_leaves"); - public static final RegistryKey> FALLEN_MIKADO_MAPLE_LEAVES = of("patch/fallen_mikado_maple_leaves"); + public static final RegistryKey> FALLEN_VERMILION_MAPLE_LEAVES = of("patch/fallen_vermilion_maple_leaves"); + public static final RegistryKey> FALLEN_FULVOUS_MAPLE_LEAVES = of("patch/fallen_fulvous_maple_leaves"); + public static final RegistryKey> FALLEN_MIKADO_MAPLE_LEAVES = of("patch/fallen_mikado_maple_leaves"); - private static RegistryKey> of(String path) { - return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, Promenade.id(path)); - } + private static RegistryKey> of(String path) { + return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, Promenade.id(path)); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeFeatures.java b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeFeatures.java index 598e9854..79a618fc 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeFeatures.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadeFeatures.java @@ -1,6 +1,16 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; -import fr.hugman.promenade.Promenade; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.world.gen.feature.DefaultFeatureConfig; @@ -8,15 +18,17 @@ import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.feature.HugeFungusFeatureConfig; +import fr.hugman.promenade.Promenade; + public class PromenadeFeatures { - public static final Feature TALL_HUGE_FUNGUS = of("tall_huge_fungus", new TallHugeFungusFeature(HugeFungusFeatureConfig.CODEC)); - public static final Feature COILED_VINES = of("coiled_vines", new CoiledVinesFeature(CoiledVinesFeatureConfig.CODEC)); - public static final Feature NOISE_PICKED = of("noised_picked", new NoisePickedFeature(NoisePickedFeatureConfig.CODEC)); - public static final Feature BOULDER = of("boulder", new BoulderFeature(BoulderFeatureConfig.CODEC)); - public static final FreezeTopLayerFeature FREEZE_TOP_LAYER = of("freeze_top_layer", new FreezeTopLayerFeature(DefaultFeatureConfig.CODEC)); + public static final Feature TALL_HUGE_FUNGUS = of("tall_huge_fungus", new TallHugeFungusFeature(HugeFungusFeatureConfig.CODEC)); + public static final Feature COILED_VINES = of("coiled_vines", new CoiledVinesFeature(CoiledVinesFeatureConfig.CODEC)); + public static final Feature NOISE_PICKED = of("noised_picked", new NoisePickedFeature(NoisePickedFeatureConfig.CODEC)); + public static final Feature BOULDER = of("boulder", new BoulderFeature(BoulderFeatureConfig.CODEC)); + public static final FreezeTopLayerFeature FREEZE_TOP_LAYER = of("freeze_top_layer", new FreezeTopLayerFeature(DefaultFeatureConfig.CODEC)); - private static > F of(String path, F feature) { - return Registry.register(Registries.FEATURE, Promenade.id(path), feature); - } + private static > F of(String path, F feature) { + return Registry.register(Registries.FEATURE, Promenade.id(path), feature); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadePlacedFeatures.java b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadePlacedFeatures.java index 858b54bd..f0a9b666 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadePlacedFeatures.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/PromenadePlacedFeatures.java @@ -1,11 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; -import fr.hugman.promenade.Promenade; -import fr.hugman.promenade.config.PromenadeConfig; -import fr.hugman.promenade.tag.PromenadeBiomeTags; -import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; -import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; +import java.util.function.Predicate; + import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.world.gen.GenerationStep; @@ -13,102 +20,108 @@ import net.minecraft.world.gen.feature.PlacedFeature; import net.minecraft.world.gen.feature.VegetationPlacedFeatures; -import java.util.function.Predicate; +import net.fabricmc.fabric.api.biome.v1.BiomeModifications; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; + +import fr.hugman.promenade.Promenade; +import fr.hugman.promenade.config.PromenadeConfig; +import fr.hugman.promenade.tag.PromenadeBiomeTags; public class PromenadePlacedFeatures { - // Ores - public static final RegistryKey ORE_ASPHALT_UPPER = of("ore/asphalt/upper"); - public static final RegistryKey ORE_ASPHALT_LOWER = of("ore/asphalt/lower"); - public static final RegistryKey ORE_BLUNITE_UPPER = of("ore/blunite/upper"); - public static final RegistryKey ORE_BLUNITE_LOWER = of("ore/blunite/lower"); + // Ores + public static final RegistryKey ORE_ASPHALT_UPPER = of("ore/asphalt/upper"); + public static final RegistryKey ORE_ASPHALT_LOWER = of("ore/asphalt/lower"); + public static final RegistryKey ORE_BLUNITE_UPPER = of("ore/blunite/upper"); + public static final RegistryKey ORE_BLUNITE_LOWER = of("ore/blunite/lower"); - public static final RegistryKey PACKED_ICE_ORE = of("ore/packed_ice"); - public static final RegistryKey BLUE_ICE_ORE = of("ore/blue_ice"); + public static final RegistryKey PACKED_ICE_ORE = of("ore/packed_ice"); + public static final RegistryKey BLUE_ICE_ORE = of("ore/blue_ice"); - // Trees - public static final RegistryKey BLUSH_SAKURA = of("tree/blush_sakura"); - public static final RegistryKey FANCY_BLUSH_SAKURA = of("tree/fancy_blush_sakura"); - public static final RegistryKey BLUSH_SAKURA_BEES = of("tree/blush_sakura_bees"); - public static final RegistryKey FANCY_BLUSH_SAKURA_BEES = of("tree/fancy_blush_sakura_bees"); + // Trees + public static final RegistryKey BLUSH_SAKURA = of("tree/blush_sakura"); + public static final RegistryKey FANCY_BLUSH_SAKURA = of("tree/fancy_blush_sakura"); + public static final RegistryKey BLUSH_SAKURA_BEES = of("tree/blush_sakura_bees"); + public static final RegistryKey FANCY_BLUSH_SAKURA_BEES = of("tree/fancy_blush_sakura_bees"); - public static final RegistryKey COTTON_SAKURA = of("tree/cotton_sakura"); - public static final RegistryKey FANCY_COTTON_SAKURA = of("tree/fancy_cotton_sakura"); - public static final RegistryKey COTTON_SAKURA_BEES = of("tree/cotton_sakura_bees"); - public static final RegistryKey FANCY_COTTON_SAKURA_BEES = of("tree/fancy_cotton_sakura_bees"); + public static final RegistryKey COTTON_SAKURA = of("tree/cotton_sakura"); + public static final RegistryKey FANCY_COTTON_SAKURA = of("tree/fancy_cotton_sakura"); + public static final RegistryKey COTTON_SAKURA_BEES = of("tree/cotton_sakura_bees"); + public static final RegistryKey FANCY_COTTON_SAKURA_BEES = of("tree/fancy_cotton_sakura_bees"); - public static final RegistryKey SAP_MAPLE = of("tree/sap_maple"); - public static final RegistryKey FANCY_SAP_MAPLE = of("tree/fancy_sap_maple"); - public static final RegistryKey SAP_MAPLE_BEES = of("tree/sap_maple_bees"); - public static final RegistryKey FANCY_SAP_MAPLE_BEES = of("tree/fancy_sap_maple_bees"); + public static final RegistryKey SAP_MAPLE = of("tree/sap_maple"); + public static final RegistryKey FANCY_SAP_MAPLE = of("tree/fancy_sap_maple"); + public static final RegistryKey SAP_MAPLE_BEES = of("tree/sap_maple_bees"); + public static final RegistryKey FANCY_SAP_MAPLE_BEES = of("tree/fancy_sap_maple_bees"); - public static final RegistryKey VERMILION_MAPLE = of("tree/vermilion_maple"); - public static final RegistryKey FANCY_VERMILION_MAPLE = of("tree/fancy_vermilion_maple"); - public static final RegistryKey VERMILION_MAPLE_BEES = of("tree/vermilion_maple_bees"); - public static final RegistryKey FANCY_VERMILION_MAPLE_BEES = of("tree/fancy_vermilion_maple_bees"); + public static final RegistryKey VERMILION_MAPLE = of("tree/vermilion_maple"); + public static final RegistryKey FANCY_VERMILION_MAPLE = of("tree/fancy_vermilion_maple"); + public static final RegistryKey VERMILION_MAPLE_BEES = of("tree/vermilion_maple_bees"); + public static final RegistryKey FANCY_VERMILION_MAPLE_BEES = of("tree/fancy_vermilion_maple_bees"); - public static final RegistryKey FULVOUS_MAPLE = of("tree/fulvous_maple"); - public static final RegistryKey FANCY_FULVOUS_MAPLE = of("tree/fancy_fulvous_maple"); - public static final RegistryKey FULVOUS_MAPLE_BEES = of("tree/fulvous_maple_bees"); - public static final RegistryKey FANCY_FULVOUS_MAPLE_BEES = of("tree/fancy_fulvous_maple_bees"); + public static final RegistryKey FULVOUS_MAPLE = of("tree/fulvous_maple"); + public static final RegistryKey FANCY_FULVOUS_MAPLE = of("tree/fancy_fulvous_maple"); + public static final RegistryKey FULVOUS_MAPLE_BEES = of("tree/fulvous_maple_bees"); + public static final RegistryKey FANCY_FULVOUS_MAPLE_BEES = of("tree/fancy_fulvous_maple_bees"); - public static final RegistryKey MIKADO_MAPLE = of("tree/mikado_maple"); - public static final RegistryKey FANCY_MIKADO_MAPLE = of("tree/fancy_mikado_maple"); - public static final RegistryKey MIKADO_MAPLE_BEES = of("tree/mikado_maple_bees"); - public static final RegistryKey FANCY_MIKADO_MAPLE_BEES = of("tree/fancy_mikado_maple_bees"); + public static final RegistryKey MIKADO_MAPLE = of("tree/mikado_maple"); + public static final RegistryKey FANCY_MIKADO_MAPLE = of("tree/fancy_mikado_maple"); + public static final RegistryKey MIKADO_MAPLE_BEES = of("tree/mikado_maple_bees"); + public static final RegistryKey FANCY_MIKADO_MAPLE_BEES = of("tree/fancy_mikado_maple_bees"); - // Vegetation - public static final RegistryKey BLUEBERRY_BUSH_COMMON_PATCH = of("patch/blueberry_bush/common"); - public static final RegistryKey BLUEBERRY_BUSH_RARE_PATCH = of("patch/blueberry_bush/rare"); + // Vegetation + public static final RegistryKey BLUEBERRY_BUSH_COMMON_PATCH = of("patch/blueberry_bush/common"); + public static final RegistryKey BLUEBERRY_BUSH_RARE_PATCH = of("patch/blueberry_bush/rare"); - public static final RegistryKey SAKURA_GROVE_BAMBOO = of("sakura_grove_bamboo"); + public static final RegistryKey SAKURA_GROVE_BAMBOO = of("sakura_grove_bamboo"); - public static final RegistryKey CUTE_LITTLE_ROCKS = of("cute_little_rocks"); + public static final RegistryKey CUTE_LITTLE_ROCKS = of("cute_little_rocks"); - public static final RegistryKey WATER_POOLS_GRAVEL_DECORATED = of("water_pools/gravel_decorated"); + public static final RegistryKey WATER_POOLS_GRAVEL_DECORATED = of("water_pools/gravel_decorated"); - public static final RegistryKey FREEZE_TOP_LAYER = of("freeze_top_layer"); + public static final RegistryKey FREEZE_TOP_LAYER = of("freeze_top_layer"); - public static final RegistryKey DARK_AMARANTH_FOREST_VEGETATION = of("dark_amaranth_forest_vegetation"); + public static final RegistryKey DARK_AMARANTH_FOREST_VEGETATION = of("dark_amaranth_forest_vegetation"); - public static final RegistryKey COILED_VINES = of("coiled_vines"); + public static final RegistryKey COILED_VINES = of("coiled_vines"); - public static final RegistryKey FALLEN_VERMILION_MAPLE_LEAVES = of("patch/fallen_vermilion_maple_leaves"); - public static final RegistryKey FALLEN_FULVOUS_MAPLE_LEAVES = of("patch/fallen_fulvous_maple_leaves"); - public static final RegistryKey FALLEN_MIKADO_MAPLE_LEAVES = of("patch/fallen_mikado_maple_leaves"); + public static final RegistryKey FALLEN_VERMILION_MAPLE_LEAVES = of("patch/fallen_vermilion_maple_leaves"); + public static final RegistryKey FALLEN_FULVOUS_MAPLE_LEAVES = of("patch/fallen_fulvous_maple_leaves"); + public static final RegistryKey FALLEN_MIKADO_MAPLE_LEAVES = of("patch/fallen_mikado_maple_leaves"); - // Grouped features - public static final RegistryKey BLUSH_SAKURA_GROVE_TREES = of("trees/blush_sakura_grove"); - public static final RegistryKey COTTON_SAKURA_GROVE_TREES = of("trees/cotton_sakura_grove"); + // Grouped features + public static final RegistryKey BLUSH_SAKURA_GROVE_TREES = of("trees/blush_sakura_grove"); + public static final RegistryKey COTTON_SAKURA_GROVE_TREES = of("trees/cotton_sakura_grove"); - public static final RegistryKey CARNELIAN_TREEWAY_TREES = of("trees/carnelian_treeway"); - public static final RegistryKey CARNELIAN_TREEWAY_FALLEN_LEAVES = of("patch/carnelian_treeway_fallen_leaves"); + public static final RegistryKey CARNELIAN_TREEWAY_TREES = of("trees/carnelian_treeway"); + public static final RegistryKey CARNELIAN_TREEWAY_FALLEN_LEAVES = of("patch/carnelian_treeway_fallen_leaves"); - public static final RegistryKey GLACARIAN_TAIGA_TREES = of("trees/glacarian_taiga"); + public static final RegistryKey GLACARIAN_TAIGA_TREES = of("trees/glacarian_taiga"); - public static final RegistryKey PALMS = of("trees/palms"); + public static final RegistryKey PALMS = of("trees/palms"); - public static final RegistryKey DARK_AMARANTH_FUNGI = of("trees/dark_amaranth_fungi"); + public static final RegistryKey DARK_AMARANTH_FUNGI = of("trees/dark_amaranth_fungi"); - private static RegistryKey of(String path) { - return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Promenade.id(path)); - } + private static RegistryKey of(String path) { + return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Promenade.id(path)); + } - public static void appendWorldGen() { - if (PromenadeConfig.get().worldFeatures().igneousRockPatches()) { - Predicate hasIgneousRocks = c -> c.hasFeature(OreConfiguredFeatures.ORE_ANDESITE) && c.hasFeature(OreConfiguredFeatures.ORE_DIORITE) && c.hasFeature(OreConfiguredFeatures.ORE_GRANITE); - BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_ASPHALT_UPPER); - BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_ASPHALT_LOWER); - BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_BLUNITE_UPPER); - BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_BLUNITE_LOWER); - } - if (PromenadeConfig.get().worldFeatures().palms()) { - BiomeModifications.addFeature(BiomeSelectors.tag(PromenadeBiomeTags.HAS_PALMS), GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.PALMS); - } + public static void appendWorldGen() { + if (PromenadeConfig.get().worldFeatures().igneousRockPatches()) { + Predicate hasIgneousRocks = c -> c.hasFeature(OreConfiguredFeatures.ORE_ANDESITE) && c.hasFeature(OreConfiguredFeatures.ORE_DIORITE) && c.hasFeature(OreConfiguredFeatures.ORE_GRANITE); + BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_ASPHALT_UPPER); + BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_ASPHALT_LOWER); + BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_BLUNITE_UPPER); + BiomeModifications.addFeature(hasIgneousRocks, GenerationStep.Feature.UNDERGROUND_ORES, PromenadePlacedFeatures.ORE_BLUNITE_LOWER); + } + if (PromenadeConfig.get().worldFeatures().palms()) { + BiomeModifications.addFeature(BiomeSelectors.tag(PromenadeBiomeTags.HAS_PALMS), GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.PALMS); + } - if (PromenadeConfig.get().worldFeatures().blueberryBushes()) { - BiomeModifications.addFeature(c -> c.hasPlacedFeature(VegetationPlacedFeatures.PATCH_BERRY_COMMON), GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.BLUEBERRY_BUSH_COMMON_PATCH); - BiomeModifications.addFeature(c -> c.hasPlacedFeature(VegetationPlacedFeatures.PATCH_BERRY_RARE), GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.BLUEBERRY_BUSH_RARE_PATCH); - } - } + if (PromenadeConfig.get().worldFeatures().blueberryBushes()) { + BiomeModifications.addFeature(c -> c.hasPlacedFeature(VegetationPlacedFeatures.PATCH_BERRY_COMMON), GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.BLUEBERRY_BUSH_COMMON_PATCH); + BiomeModifications.addFeature(c -> c.hasPlacedFeature(VegetationPlacedFeatures.PATCH_BERRY_RARE), GenerationStep.Feature.VEGETAL_DECORATION, PromenadePlacedFeatures.BLUEBERRY_BUSH_RARE_PATCH); + } + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/feature/TallHugeFungusFeature.java b/src/main/java/fr/hugman/promenade/world/gen/feature/TallHugeFungusFeature.java index bdb092c8..ed65ab88 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/feature/TallHugeFungusFeature.java +++ b/src/main/java/fr/hugman/promenade/world/gen/feature/TallHugeFungusFeature.java @@ -1,6 +1,18 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.feature; import com.mojang.serialization.Codec; + import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -17,169 +29,169 @@ import net.minecraft.world.gen.feature.util.FeatureContext; public class TallHugeFungusFeature extends Feature { - public TallHugeFungusFeature(Codec codec) { - super(codec); - } + public TallHugeFungusFeature(Codec codec) { + super(codec); + } - private static boolean isReplaceable(StructureWorldAccess world, BlockPos pos, HugeFungusFeatureConfig config, boolean checkConfig) { - if (world.testBlockState(pos, AbstractBlock.AbstractBlockState::isReplaceable)) { - return true; - } else { - return checkConfig && config.replaceableBlocks.test(world, pos); - } - } + private static boolean isReplaceable(StructureWorldAccess world, BlockPos pos, HugeFungusFeatureConfig config, boolean checkConfig) { + if (world.testBlockState(pos, AbstractBlock.AbstractBlockState::isReplaceable)) { + return true; + } else { + return checkConfig && config.replaceableBlocks.test(world, pos); + } + } - private static BlockPos.Mutable getStartPos(WorldAccess world, BlockPos origin, Block block) { - BlockPos.Mutable mutable = origin.mutableCopy(); - for (int i = origin.getY(); i >= 1; --i) { - mutable.setY(i); - Block block2 = world.getBlockState(mutable.down()).getBlock(); - if (block2 == block) { - return mutable; - } - } - return null; - } + private static BlockPos.Mutable getStartPos(WorldAccess world, BlockPos origin, Block block) { + BlockPos.Mutable mutable = origin.mutableCopy(); + for (int i = origin.getY(); i >= 1; --i) { + mutable.setY(i); + Block block2 = world.getBlockState(mutable.down()).getBlock(); + if (block2 == block) { + return mutable; + } + } + return null; + } - private static void generateVines(BlockPos blockPos, WorldAccess worldAccess, Random random) { - BlockPos.Mutable mutable = blockPos.mutableCopy().move(Direction.DOWN); - if (worldAccess.isAir(mutable)) { - int i = MathHelper.nextInt(random, 1, 5); - if (random.nextInt(7) == 0) { - i *= 2; - } - WeepingVinesFeature.generateVineColumn(worldAccess, random, mutable, i, 23, 25); - } - } + private static void generateVines(BlockPos blockPos, WorldAccess worldAccess, Random random) { + BlockPos.Mutable mutable = blockPos.mutableCopy().move(Direction.DOWN); + if (worldAccess.isAir(mutable)) { + int i = MathHelper.nextInt(random, 1, 5); + if (random.nextInt(7) == 0) { + i *= 2; + } + WeepingVinesFeature.generateVineColumn(worldAccess, random, mutable, i, 23, 25); + } + } - @Override - public boolean generate(FeatureContext context) { - Random random = context.getRandom(); - HugeFungusFeatureConfig config = context.getConfig(); - StructureWorldAccess world = context.getWorld(); - BlockPos pos = context.getOrigin(); - Block block = config.validBaseBlock.getBlock(); - BlockPos pos2 = null; - if (config.planted) { - Block block2 = world.getBlockState(pos.down()).getBlock(); - if (block2 == block) { - pos2 = pos; - } - } else { - pos2 = getStartPos(world, pos, block); - } - if (pos2 == null) { - return false; - } else { - int i = MathHelper.nextInt(random, 8, 16) * 2; - if (!config.planted) { - int j = world.getHeight(); - if (pos2.getY() + i + 1 >= j) { - return false; - } - } - boolean bl = !config.planted && random.nextFloat() < 0.16F; - world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4); - this.generateStem(world, random, config, pos2, i, bl); - this.generateHat(world, random, config, pos2, i, bl); - return true; - } - } + @Override + public boolean generate(FeatureContext context) { + Random random = context.getRandom(); + HugeFungusFeatureConfig config = context.getConfig(); + StructureWorldAccess world = context.getWorld(); + BlockPos pos = context.getOrigin(); + Block block = config.validBaseBlock.getBlock(); + BlockPos pos2 = null; + if (config.planted) { + Block block2 = world.getBlockState(pos.down()).getBlock(); + if (block2 == block) { + pos2 = pos; + } + } else { + pos2 = getStartPos(world, pos, block); + } + if (pos2 == null) { + return false; + } else { + int i = MathHelper.nextInt(random, 8, 16) * 2; + if (!config.planted) { + int j = world.getHeight(); + if (pos2.getY() + i + 1 >= j) { + return false; + } + } + boolean bl = !config.planted && random.nextFloat() < 0.16F; + world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4); + this.generateStem(world, random, config, pos2, i, bl); + this.generateHat(world, random, config, pos2, i, bl); + return true; + } + } - private void generateStem(StructureWorldAccess world, Random random, HugeFungusFeatureConfig config, BlockPos blockPos, int stemHeight, boolean thickStem) { - BlockPos.Mutable mutable = new BlockPos.Mutable(); - BlockState blockState = config.stemState; - int i = thickStem ? 1 : 0; - for (int j = -i; j <= i; ++j) { - for (int k = -i; k <= i; ++k) { - boolean bl = thickStem && MathHelper.abs(j) == i && MathHelper.abs(k) == i; - for (int l = 0; l < stemHeight; ++l) { - mutable.set(blockPos, j, l, k); - if (isReplaceable(world, mutable, config, true)) { - if (config.planted) { - if (!world.getBlockState(mutable.down()).isAir()) { - world.breakBlock(mutable, true); - } - world.setBlockState(mutable, blockState, 3); - } else if (bl) { - if (random.nextFloat() < 0.1F) { - this.setBlockState(world, mutable, blockState); - } - } else { - this.setBlockState(world, mutable, blockState); - } - } - } - } - } + private void generateStem(StructureWorldAccess world, Random random, HugeFungusFeatureConfig config, BlockPos blockPos, int stemHeight, boolean thickStem) { + BlockPos.Mutable mutable = new BlockPos.Mutable(); + BlockState blockState = config.stemState; + int i = thickStem ? 1 : 0; + for (int j = -i; j <= i; ++j) { + for (int k = -i; k <= i; ++k) { + boolean bl = thickStem && MathHelper.abs(j) == i && MathHelper.abs(k) == i; + for (int l = 0; l < stemHeight; ++l) { + mutable.set(blockPos, j, l, k); + if (isReplaceable(world, mutable, config, true)) { + if (config.planted) { + if (!world.getBlockState(mutable.down()).isAir()) { + world.breakBlock(mutable, true); + } + world.setBlockState(mutable, blockState, 3); + } else if (bl) { + if (random.nextFloat() < 0.1F) { + this.setBlockState(world, mutable, blockState); + } + } else { + this.setBlockState(world, mutable, blockState); + } + } + } + } + } - } + } - private void generateHat(StructureWorldAccess world, Random random, HugeFungusFeatureConfig config, BlockPos blockPos, int hatHeight, boolean thickStem) { - BlockPos.Mutable mutable = new BlockPos.Mutable(); - boolean bl = config.hatState.isOf(Blocks.NETHER_WART_BLOCK); - int i = Math.min(random.nextInt(1 + hatHeight / 3) + 5, hatHeight); - int j = hatHeight - i; - for (int k = j; k <= hatHeight; ++k) { - int l = k < hatHeight - random.nextInt(3) ? 2 : 1; - if (i > 8 && k < j + 4) { - l = 3; - } - if (thickStem) { - ++l; - } - for (int m = -l; m <= l; ++m) { - for (int n = -l; n <= l; ++n) { - boolean bl2 = m == -l || m == l; - boolean bl3 = n == -l || n == l; - boolean bl4 = !bl2 && !bl3 && k != hatHeight; - boolean bl5 = bl2 && bl3; - boolean bl6 = k < j + 3; - mutable.set(blockPos, m, k, n); - if (isReplaceable(world, mutable, config, false)) { - if (config.planted && !world.getBlockState(mutable.down()).isAir()) { - world.breakBlock(mutable, true); - } - if (bl6) { - if (!bl4) { - this.tryGenerateVines(world, random, mutable, config.hatState, bl); - } - } else if (bl4) { - this.generateHatBlock(world, random, config, mutable, 0.1F, 0.2F, bl ? 0.1F : 0.0F); - } else if (bl5) { - this.generateHatBlock(world, random, config, mutable, 0.01F, 0.7F, bl ? 0.083F : 0.0F); - } else { - this.generateHatBlock(world, random, config, mutable, 5.0E-4F, 0.98F, bl ? 0.07F : 0.0F); - } - } - } - } - } + private void generateHat(StructureWorldAccess world, Random random, HugeFungusFeatureConfig config, BlockPos blockPos, int hatHeight, boolean thickStem) { + BlockPos.Mutable mutable = new BlockPos.Mutable(); + boolean bl = config.hatState.isOf(Blocks.NETHER_WART_BLOCK); + int i = Math.min(random.nextInt(1 + hatHeight / 3) + 5, hatHeight); + int j = hatHeight - i; + for (int k = j; k <= hatHeight; ++k) { + int l = k < hatHeight - random.nextInt(3) ? 2 : 1; + if (i > 8 && k < j + 4) { + l = 3; + } + if (thickStem) { + ++l; + } + for (int m = -l; m <= l; ++m) { + for (int n = -l; n <= l; ++n) { + boolean bl2 = m == -l || m == l; + boolean bl3 = n == -l || n == l; + boolean bl4 = !bl2 && !bl3 && k != hatHeight; + boolean bl5 = bl2 && bl3; + boolean bl6 = k < j + 3; + mutable.set(blockPos, m, k, n); + if (isReplaceable(world, mutable, config, false)) { + if (config.planted && !world.getBlockState(mutable.down()).isAir()) { + world.breakBlock(mutable, true); + } + if (bl6) { + if (!bl4) { + this.tryGenerateVines(world, random, mutable, config.hatState, bl); + } + } else if (bl4) { + this.generateHatBlock(world, random, config, mutable, 0.1F, 0.2F, bl ? 0.1F : 0.0F); + } else if (bl5) { + this.generateHatBlock(world, random, config, mutable, 0.01F, 0.7F, bl ? 0.083F : 0.0F); + } else { + this.generateHatBlock(world, random, config, mutable, 5.0E-4F, 0.98F, bl ? 0.07F : 0.0F); + } + } + } + } + } - } + } - private void generateHatBlock(WorldAccess world, Random random, HugeFungusFeatureConfig config, BlockPos.Mutable pos, float decorationChance, float generationChance, float vineChance) { - if (random.nextFloat() < decorationChance) { - this.setBlockState(world, pos, config.decorationState); - } else if (random.nextFloat() < generationChance) { - this.setBlockState(world, pos, config.hatState); - if (random.nextFloat() < vineChance) { - generateVines(pos, world, random); - } - } + private void generateHatBlock(WorldAccess world, Random random, HugeFungusFeatureConfig config, BlockPos.Mutable pos, float decorationChance, float generationChance, float vineChance) { + if (random.nextFloat() < decorationChance) { + this.setBlockState(world, pos, config.decorationState); + } else if (random.nextFloat() < generationChance) { + this.setBlockState(world, pos, config.hatState); + if (random.nextFloat() < vineChance) { + generateVines(pos, world, random); + } + } - } + } - private void tryGenerateVines(WorldAccess world, Random random, BlockPos origin, BlockState state, boolean bl) { - BlockPos.Mutable mutable = origin.mutableCopy(); - if (world.getBlockState(mutable.down()).isOf(state.getBlock())) { - this.setBlockState(world, mutable, state); - } else if ((double) random.nextFloat() < 0.15D) { - this.setBlockState(world, origin, state); - if (bl && random.nextInt(11) == 0) { - generateVines(mutable, world, random); - } - } + private void tryGenerateVines(WorldAccess world, Random random, BlockPos origin, BlockState state, boolean bl) { + BlockPos.Mutable mutable = origin.mutableCopy(); + if (world.getBlockState(mutable.down()).isOf(state.getBlock())) { + this.setBlockState(world, mutable, state); + } else if ((double) random.nextFloat() < 0.15D) { + this.setBlockState(world, origin, state); + if (bl && random.nextInt(11) == 0) { + generateVines(mutable, world, random); + } + } - } + } } \ No newline at end of file diff --git a/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/NoiseIntervalCountPlacementModifier.java b/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/NoiseIntervalCountPlacementModifier.java index a4f3a3ea..5b603153 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/NoiseIntervalCountPlacementModifier.java +++ b/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/NoiseIntervalCountPlacementModifier.java @@ -1,8 +1,20 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.placement_modifier; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; import net.minecraft.world.biome.Biome; @@ -10,36 +22,36 @@ import net.minecraft.world.gen.placementmodifier.PlacementModifierType; public class NoiseIntervalCountPlacementModifier extends AbstractCountPlacementModifier { - public static final MapCodec MODIFIER_CODEC = RecordCodecBuilder.mapCodec((instance) -> instance.group( - Codec.DOUBLE.fieldOf("noise_level_min").forGetter((pm) -> pm.noiseLevelMin), - Codec.DOUBLE.fieldOf("noise_level_max").forGetter((pm) -> pm.noiseLevelMax), - Codec.INT.fieldOf("inside_value").forGetter((pm) -> pm.insideValue), - Codec.INT.fieldOf("outside_value").forGetter((pm) -> pm.outsideValue)) - .apply(instance, NoiseIntervalCountPlacementModifier::new)); - private final double noiseLevelMin; - private final double noiseLevelMax; - private final int insideValue; - private final int outsideValue; - - private NoiseIntervalCountPlacementModifier(double noiseLevelMin, double noiseLevelMax, int insideValue, int outsideValue) { - this.noiseLevelMin = noiseLevelMin; - this.noiseLevelMax = noiseLevelMax; - this.insideValue = insideValue; - this.outsideValue = outsideValue; - } - - public static NoiseIntervalCountPlacementModifier of(double noiseLevelMin, double noiseLevelMax, int insideValue, int outsideValue) { - return new NoiseIntervalCountPlacementModifier(noiseLevelMin, noiseLevelMax, insideValue, outsideValue); - } - - - @Override - protected int getCount(Random random, BlockPos pos) { - double d = Biome.FOLIAGE_NOISE.sample((double) pos.getX() / 200.0, (double) pos.getZ() / 200.0, false); - return (this.noiseLevelMin < d && d < this.noiseLevelMax) ? this.insideValue : this.outsideValue; - } - - public PlacementModifierType getType() { - return PromenadePlacementModifierTypes.NOISE_INTERVAL_COUNT; - } + public static final MapCodec MODIFIER_CODEC = RecordCodecBuilder.mapCodec((instance) -> instance.group( + Codec.DOUBLE.fieldOf("noise_level_min").forGetter((pm) -> pm.noiseLevelMin), + Codec.DOUBLE.fieldOf("noise_level_max").forGetter((pm) -> pm.noiseLevelMax), + Codec.INT.fieldOf("inside_value").forGetter((pm) -> pm.insideValue), + Codec.INT.fieldOf("outside_value").forGetter((pm) -> pm.outsideValue)) + .apply(instance, NoiseIntervalCountPlacementModifier::new)); + private final double noiseLevelMin; + private final double noiseLevelMax; + private final int insideValue; + private final int outsideValue; + + private NoiseIntervalCountPlacementModifier(double noiseLevelMin, double noiseLevelMax, int insideValue, int outsideValue) { + this.noiseLevelMin = noiseLevelMin; + this.noiseLevelMax = noiseLevelMax; + this.insideValue = insideValue; + this.outsideValue = outsideValue; + } + + public static NoiseIntervalCountPlacementModifier of(double noiseLevelMin, double noiseLevelMax, int insideValue, int outsideValue) { + return new NoiseIntervalCountPlacementModifier(noiseLevelMin, noiseLevelMax, insideValue, outsideValue); + } + + + @Override + protected int getCount(Random random, BlockPos pos) { + double d = Biome.FOLIAGE_NOISE.sample((double) pos.getX() / 200.0, (double) pos.getZ() / 200.0, false); + return (this.noiseLevelMin < d && d < this.noiseLevelMax) ? this.insideValue : this.outsideValue; + } + + public PlacementModifierType getType() { + return PromenadePlacementModifierTypes.NOISE_INTERVAL_COUNT; + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/PromenadePlacementModifierTypes.java b/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/PromenadePlacementModifierTypes.java index dbc1a0de..bc21de4b 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/PromenadePlacementModifierTypes.java +++ b/src/main/java/fr/hugman/promenade/world/gen/placement_modifier/PromenadePlacementModifierTypes.java @@ -1,16 +1,29 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.placement_modifier; import com.mojang.serialization.MapCodec; -import fr.hugman.promenade.Promenade; + import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.world.gen.placementmodifier.PlacementModifier; import net.minecraft.world.gen.placementmodifier.PlacementModifierType; +import fr.hugman.promenade.Promenade; + public class PromenadePlacementModifierTypes { - public static final PlacementModifierType NOISE_INTERVAL_COUNT = register("noise_interval_count", NoiseIntervalCountPlacementModifier.MODIFIER_CODEC); + public static final PlacementModifierType NOISE_INTERVAL_COUNT = register("noise_interval_count", NoiseIntervalCountPlacementModifier.MODIFIER_CODEC); - private static

PlacementModifierType

register(String path, MapCodec

codec) { - return Registry.register(Registries.PLACEMENT_MODIFIER_TYPE, Promenade.id(path), () -> codec); - } + private static

PlacementModifierType

register(String path, MapCodec

codec) { + return Registry.register(Registries.PLACEMENT_MODIFIER_TYPE, Promenade.id(path), () -> codec); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureKeys.java b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureKeys.java index ff556249..2174c196 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureKeys.java +++ b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureKeys.java @@ -1,14 +1,26 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.structure; -import fr.hugman.promenade.Promenade; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.world.gen.structure.Structure; +import fr.hugman.promenade.Promenade; + public class PromenadeStructureKeys { - public static final RegistryKey DARK_FOREST_WITCH_HUT = of("dark_forest_witch_hut"); + public static final RegistryKey DARK_FOREST_WITCH_HUT = of("dark_forest_witch_hut"); - private static RegistryKey of(String id) { - return RegistryKey.of(RegistryKeys.STRUCTURE, Promenade.id(id)); - } + private static RegistryKey of(String id) { + return RegistryKey.of(RegistryKeys.STRUCTURE, Promenade.id(id)); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructurePoolsKeys.java b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructurePoolsKeys.java index 26f1aa68..d756eb32 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructurePoolsKeys.java +++ b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructurePoolsKeys.java @@ -1,15 +1,27 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.structure; -import fr.hugman.promenade.Promenade; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.structure.pool.StructurePool; +import fr.hugman.promenade.Promenade; + public class PromenadeStructurePoolsKeys { - public static final RegistryKey DARK_FOREST_WITCH_HUTS = of("dark_forest_witch_huts"); - public static final RegistryKey WITCH_HUT_INTERIORS = of("witch_huts_interiors"); + public static final RegistryKey DARK_FOREST_WITCH_HUTS = of("dark_forest_witch_huts"); + public static final RegistryKey WITCH_HUT_INTERIORS = of("witch_huts_interiors"); - private static RegistryKey of(String id) { - return RegistryKey.of(RegistryKeys.TEMPLATE_POOL, Promenade.id(id)); - } + private static RegistryKey of(String id) { + return RegistryKey.of(RegistryKeys.TEMPLATE_POOL, Promenade.id(id)); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureSetKeys.java b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureSetKeys.java index 94395ec2..4ad29d96 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureSetKeys.java +++ b/src/main/java/fr/hugman/promenade/world/gen/structure/PromenadeStructureSetKeys.java @@ -1,14 +1,26 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.structure; -import fr.hugman.promenade.Promenade; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.structure.StructureSet; +import fr.hugman.promenade.Promenade; + public class PromenadeStructureSetKeys { - public static final RegistryKey WITCH_HUTS = of("witch_huts"); + public static final RegistryKey WITCH_HUTS = of("witch_huts"); - private static RegistryKey of(String id) { - return RegistryKey.of(RegistryKeys.STRUCTURE_SET, Promenade.id(id)); - } + private static RegistryKey of(String id) { + return RegistryKey.of(RegistryKeys.STRUCTURE_SET, Promenade.id(id)); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/MapleFoliagePlacer.java b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/MapleFoliagePlacer.java index 25772794..ef7d3d24 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/MapleFoliagePlacer.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/MapleFoliagePlacer.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.tree.foliage; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.intprovider.ConstantIntProvider; @@ -13,69 +25,70 @@ import net.minecraft.world.gen.foliage.FoliagePlacerType; public class MapleFoliagePlacer extends FoliagePlacer { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> - MapleFoliagePlacer.fillFoliagePlacerFields(instance).and( - IntProvider.createValidatingCodec(0, 32).optionalFieldOf("height", ConstantIntProvider.create(0)).forGetter(placer -> placer.height) - ).apply(instance, MapleFoliagePlacer::new)); - - protected final IntProvider height; - - public MapleFoliagePlacer(IntProvider radius, IntProvider offset, IntProvider height) { - super(radius, offset); - this.height = height; - } - - @Override - protected FoliagePlacerType getType() { - return PromenadeFoliagePlacerTypes.MAPLE; - } - - @Override - protected void generate(TestableWorld world, BlockPlacer placer, Random random, TreeFeatureConfig config, int trunkHeight, TreeNode treeNode, int foliageHeight, int radius, int offset) { - var pos = treeNode.getCenter().down(foliageHeight - offset); - - var curvature = radius; - - radius = Math.max( - (foliageHeight + 1) / 2, - (foliageHeight + 1) / 2 * (1 + curvature) - ); - - //TODO: does this support giant trunks? - for (int dx = -radius; dx <= radius; dx++) { - for (int dz = -radius; dz <= radius; dz++) { - - int d = Math.abs(dx) + Math.abs(dz); - int k = MathHelper.ceil(Math.abs(Math.abs(dx) - Math.abs(dz))); - - // the further we are from the trunk, the lower the height - int y1 = Math.max(0, d - 1); - int y2 = Math.min(foliageHeight, foliageHeight - d * curvature - k); - - if (y2 <= y1) continue; - - this.generateColumn(world, placer, config, random, pos, dz, dx, y1, y2); - } - } - } - - protected void generateColumn(TestableWorld world, BlockPlacer placer, TreeFeatureConfig config, Random random, BlockPos centerPos, int dx, int dz, int y1, int y2) { - BlockPos.Mutable mutable = new BlockPos.Mutable(); - mutable.set(centerPos, dz, y1, dx); - for (int y = y1; y < y2; y++) { - mutable.move(0, 1, 0); - FoliagePlacer.placeFoliageBlock(world, placer, random, config, mutable); - } - } - - @Override - public int getRandomHeight(Random random, int trunkHeight, TreeFeatureConfig config) { - return this.height.get(random); - } - - - @Override - protected boolean isInvalidForLeaves(Random random, int dx, int y, int dz, int radius, boolean giantTrunk) { - return false; - } + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + MapleFoliagePlacer.fillFoliagePlacerFields(instance).and( + IntProvider.createValidatingCodec(0, 32).optionalFieldOf("height", ConstantIntProvider.create(0)).forGetter(placer -> placer.height) + ).apply(instance, MapleFoliagePlacer::new)); + + protected final IntProvider height; + + public MapleFoliagePlacer(IntProvider radius, IntProvider offset, IntProvider height) { + super(radius, offset); + this.height = height; + } + + @Override + protected FoliagePlacerType getType() { + return PromenadeFoliagePlacerTypes.MAPLE; + } + + @Override + protected void generate(TestableWorld world, BlockPlacer placer, Random random, TreeFeatureConfig config, int trunkHeight, TreeNode treeNode, int foliageHeight, int radius, int offset) { + var pos = treeNode.getCenter().down(foliageHeight - offset); + + var curvature = radius; + + radius = Math.max( + (foliageHeight + 1) / 2, + (foliageHeight + 1) / 2 * (1 + curvature) + ); + + //TODO: does this support giant trunks? + for (int dx = -radius; dx <= radius; dx++) { + for (int dz = -radius; dz <= radius; dz++) { + + int d = Math.abs(dx) + Math.abs(dz); + int k = MathHelper.ceil(Math.abs(Math.abs(dx) - Math.abs(dz))); + + // the further we are from the trunk, the lower the height + int y1 = Math.max(0, d - 1); + int y2 = Math.min(foliageHeight, foliageHeight - d * curvature - k); + + if (y2 <= y1) + continue; + + this.generateColumn(world, placer, config, random, pos, dz, dx, y1, y2); + } + } + } + + protected void generateColumn(TestableWorld world, BlockPlacer placer, TreeFeatureConfig config, Random random, BlockPos centerPos, int dx, int dz, int y1, int y2) { + BlockPos.Mutable mutable = new BlockPos.Mutable(); + mutable.set(centerPos, dz, y1, dx); + for (int y = y1; y < y2; y++) { + mutable.move(0, 1, 0); + FoliagePlacer.placeFoliageBlock(world, placer, random, config, mutable); + } + } + + @Override + public int getRandomHeight(Random random, int trunkHeight, TreeFeatureConfig config) { + return this.height.get(random); + } + + + @Override + protected boolean isInvalidForLeaves(Random random, int dx, int y, int dz, int radius, boolean giantTrunk) { + return false; + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PalmFoliagePlacer.java b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PalmFoliagePlacer.java index b91e3881..f51c2a80 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PalmFoliagePlacer.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PalmFoliagePlacer.java @@ -1,7 +1,19 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.tree.foliage; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.intprovider.IntProvider; import net.minecraft.util.math.random.Random; @@ -11,76 +23,91 @@ import net.minecraft.world.gen.foliage.FoliagePlacerType; public class PalmFoliagePlacer extends FoliagePlacer { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> - PalmFoliagePlacer.fillFoliagePlacerFields(instance) - .apply(instance, PalmFoliagePlacer::new)); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + PalmFoliagePlacer.fillFoliagePlacerFields(instance) + .apply(instance, PalmFoliagePlacer::new)); - public PalmFoliagePlacer(IntProvider radius, IntProvider offset) { - super(radius, offset); - } + public PalmFoliagePlacer(IntProvider radius, IntProvider offset) { + super(radius, offset); + } - @Override - protected FoliagePlacerType getType() { - return PromenadeFoliagePlacerTypes.PALM; - } + @Override + protected FoliagePlacerType getType() { + return PromenadeFoliagePlacerTypes.PALM; + } - @Override - protected void generate(TestableWorld world, BlockPlacer placer, Random random, TreeFeatureConfig config, int trunkHeight, TreeNode treeNode, int foliageHeight, int radius, int offset) { - boolean bl = treeNode.isGiantTrunk(); - BlockPos blockPos = treeNode.getCenter().down(); + @Override + protected void generate(TestableWorld world, BlockPlacer placer, Random random, TreeFeatureConfig config, int trunkHeight, TreeNode treeNode, int foliageHeight, int radius, int offset) { + boolean bl = treeNode.isGiantTrunk(); + BlockPos blockPos = treeNode.getCenter().down(); - int i = radius + treeNode.getFoliageRadius(); - if (i > 1) this.generateSquare(world, placer, random, config, blockPos, i, 2, bl); - this.generateSquare(world, placer, random, config, blockPos, i + 1, 1, bl); - this.generateSquare(world, placer, random, config, blockPos, i + 2, 0, bl); - this.generateSquare(world, placer, random, config, blockPos, i + 2, -1, bl); - this.generateSquare(world, placer, random, config, blockPos, i + 1, -2, bl); - } + int i = radius + treeNode.getFoliageRadius(); + if (i > 1) + this.generateSquare(world, placer, random, config, blockPos, i, 2, bl); + this.generateSquare(world, placer, random, config, blockPos, i + 1, 1, bl); + this.generateSquare(world, placer, random, config, blockPos, i + 2, 0, bl); + this.generateSquare(world, placer, random, config, blockPos, i + 2, -1, bl); + this.generateSquare(world, placer, random, config, blockPos, i + 1, -2, bl); + } - @Override - public int getRandomHeight(Random random, int trunkHeight, TreeFeatureConfig config) { - return 0; - } + @Override + public int getRandomHeight(Random random, int trunkHeight, TreeFeatureConfig config) { + return 0; + } - @Override - protected boolean isInvalidForLeaves(Random random, int dx, int y, int dz, int radius, boolean giantTrunk) { - int d = dx + dz; // Distance from center + @Override + protected boolean isInvalidForLeaves(Random random, int dx, int y, int dz, int radius, boolean giantTrunk) { + int d = dx + dz; // Distance from center - if (y == 2) { - return (d <= radius - 2) || (d > radius); - } else if (y == 1) { - if (dx == radius) return dz != 0; - if (dz == radius) return dx != 0; + if (y == 2) { + return (d <= radius - 2) || (d > radius); + } else if (y == 1) { + if (dx == radius) + return dz != 0; + if (dz == radius) + return dx != 0; - return false; - } else if (y == 0) { - if (d <= 2) return false; + return false; + } else if (y == 0) { + if (d <= 2) + return false; - // NESW leafs - if (dx == radius) return dz != 0; - if (dx == radius - 1 && dz == 0) return false; - if (dz == radius) return dx != 0; - if (dz == radius - 1 && dx == 0) return false; + // NESW leafs + if (dx == radius) + return dz != 0; + if (dx == radius - 1 && dz == 0) + return false; + if (dz == radius) + return dx != 0; + if (dz == radius - 1 && dx == 0) + return false; - // Corner leafs - if (dx == radius - 2 && dz == radius - 2) return false; - if (dx == radius - 2 && dz == radius - 1) return false; - if (dx == radius - 1 && dz == radius - 2) return false; - return d != (radius - 1) * 2 || dx != dz; - } else if (y == -1) { - if (d == 0) return false; - if (d == 1) return radius <= 2; + // Corner leafs + if (dx == radius - 2 && dz == radius - 2) + return false; + if (dx == radius - 2 && dz == radius - 1) + return false; + if (dx == radius - 1 && dz == radius - 2) + return false; + return d != (radius - 1) * 2 || dx != dz; + } else if (y == -1) { + if (d == 0) + return false; + if (d == 1) + return radius <= 2; - // NESW leafs - if (dx == radius) return dz != 0; - if (dz == radius) return dx != 0; + // NESW leafs + if (dx == radius) + return dz != 0; + if (dz == radius) + return dx != 0; - // Corner leafs - return d != (radius - 1) * 2 || dx != dz; - } else if (y == -2) { - // Corner leafs - return d != radius * 2 || dx != dz; - } - return true; - } + // Corner leafs + return d != (radius - 1) * 2 || dx != dz; + } else if (y == -2) { + // Corner leafs + return d != radius * 2 || dx != dz; + } + return true; + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PromenadeFoliagePlacerTypes.java b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PromenadeFoliagePlacerTypes.java index a81ed2b9..24107439 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PromenadeFoliagePlacerTypes.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/foliage/PromenadeFoliagePlacerTypes.java @@ -1,18 +1,31 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.tree.foliage; import com.mojang.serialization.MapCodec; -import fr.hugman.promenade.Promenade; + import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.world.gen.foliage.FoliagePlacer; import net.minecraft.world.gen.foliage.FoliagePlacerType; +import fr.hugman.promenade.Promenade; + public class PromenadeFoliagePlacerTypes { - public static final FoliagePlacerType PALM = register("palm", PalmFoliagePlacer.CODEC); - public static final FoliagePlacerType MAPLE = register("maple", MapleFoliagePlacer.CODEC); + public static final FoliagePlacerType PALM = register("palm", PalmFoliagePlacer.CODEC); + public static final FoliagePlacerType MAPLE = register("maple", MapleFoliagePlacer.CODEC); - private static

FoliagePlacerType

register(String path, MapCodec

codec) { - return Registry.register(Registries.FOLIAGE_PLACER_TYPE, Promenade.id(path), new FoliagePlacerType<>(codec)); - } + private static

FoliagePlacerType

register(String path, MapCodec

codec) { + return Registry.register(Registries.FOLIAGE_PLACER_TYPE, Promenade.id(path), new FoliagePlacerType<>(codec)); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/BranchingStraightTrunkPlacer.java b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/BranchingStraightTrunkPlacer.java index 599f654a..dff7b9ca 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/BranchingStraightTrunkPlacer.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/BranchingStraightTrunkPlacer.java @@ -1,8 +1,23 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.tree.trunk; +import java.util.List; +import java.util.function.BiConsumer; + import com.google.common.collect.ImmutableList; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.block.BlockState; import net.minecraft.block.PillarBlock; import net.minecraft.util.math.BlockPos; @@ -14,55 +29,52 @@ import net.minecraft.world.gen.trunk.TrunkPlacer; import net.minecraft.world.gen.trunk.TrunkPlacerType; -import java.util.List; -import java.util.function.BiConsumer; - public class BranchingStraightTrunkPlacer extends TrunkPlacer { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( - instance -> fillTrunkPlacerFields(instance).apply(instance, BranchingStraightTrunkPlacer::new) - ); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( + instance -> fillTrunkPlacerFields(instance).apply(instance, BranchingStraightTrunkPlacer::new) + ); - public static final List HORIZONTAL = List.of(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST); + public static final List HORIZONTAL = List.of(Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST); - public BranchingStraightTrunkPlacer(int baseHeight, int firstRandomHeight, int secondRandomHeight) { - super(baseHeight, firstRandomHeight, secondRandomHeight); - } + public BranchingStraightTrunkPlacer(int baseHeight, int firstRandomHeight, int secondRandomHeight) { + super(baseHeight, firstRandomHeight, secondRandomHeight); + } - @Override - protected TrunkPlacerType getType() { - return PromenadeTrunkPlacerTypes.BRANCHING_STRAIGHT; - } + @Override + protected TrunkPlacerType getType() { + return PromenadeTrunkPlacerTypes.BRANCHING_STRAIGHT; + } - @Override - public List generate( - TestableWorld world, - BiConsumer replacer, - Random random, - int height, - BlockPos startPos, - TreeFeatureConfig config - ) { - setToDirt(world, replacer, random, startPos.down(), config); + @Override + public List generate( + TestableWorld world, + BiConsumer replacer, + Random random, + int height, + BlockPos startPos, + TreeFeatureConfig config + ) { + setToDirt(world, replacer, random, startPos.down(), config); - Direction branchDirection = null; - int branches = 0; + Direction branchDirection = null; + int branches = 0; - //TODO: configurability - for (int i = 0; i < height; i++) { - var pos = startPos.up(i); - this.getAndSetState(world, replacer, random, pos, config); - if (random.nextInt(6) == 0 && branches < 2 && i > 2) { - if (branchDirection != null) { - branchDirection = branchDirection.getOpposite(); - } else { - branchDirection = Direction.Type.HORIZONTAL.random(random); - } - Direction finalBranchDirection = branchDirection; - this.getAndSetState(world, replacer, random, pos.offset(branchDirection), config, state -> state.withIfExists(PillarBlock.AXIS, finalBranchDirection.getAxis())); - branches++; - } - } + //TODO: configurability + for (int i = 0; i < height; i++) { + var pos = startPos.up(i); + this.getAndSetState(world, replacer, random, pos, config); + if (random.nextInt(6) == 0 && branches < 2 && i > 2) { + if (branchDirection != null) { + branchDirection = branchDirection.getOpposite(); + } else { + branchDirection = Direction.Type.HORIZONTAL.random(random); + } + Direction finalBranchDirection = branchDirection; + this.getAndSetState(world, replacer, random, pos.offset(branchDirection), config, state -> state.withIfExists(PillarBlock.AXIS, finalBranchDirection.getAxis())); + branches++; + } + } - return ImmutableList.of(new FoliagePlacer.TreeNode(startPos.up(height), 0, false)); - } + return ImmutableList.of(new FoliagePlacer.TreeNode(startPos.up(height), 0, false)); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/LeapingTrunkPlacer.java b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/LeapingTrunkPlacer.java index 919df3bb..35c455af 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/LeapingTrunkPlacer.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/LeapingTrunkPlacer.java @@ -1,9 +1,24 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.tree.trunk; +import java.util.List; +import java.util.function.BiConsumer; + import com.google.common.collect.ImmutableList; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; + import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -16,66 +31,63 @@ import net.minecraft.world.gen.trunk.TrunkPlacer; import net.minecraft.world.gen.trunk.TrunkPlacerType; -import java.util.List; -import java.util.function.BiConsumer; - public class LeapingTrunkPlacer extends TrunkPlacer { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> fillTrunkPlacerFields(instance).and(instance.group( - IntProvider.createValidatingCodec(0, 80).fieldOf("straight_max").forGetter(placer -> placer.straightMax), - IntProvider.VALUE_CODEC.fieldOf("straight_difference").forGetter(placer -> placer.straightDifference), - Codec.FLOAT.fieldOf("decline_chance").forGetter(placer -> placer.declineChance), - Codec.INT.fieldOf("max_foliage_radius_bonus").forGetter(placer -> placer.maxFoliageRadiusBonus)) - ).apply(instance, LeapingTrunkPlacer::new)); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> fillTrunkPlacerFields(instance).and(instance.group( + IntProvider.createValidatingCodec(0, 80).fieldOf("straight_max").forGetter(placer -> placer.straightMax), + IntProvider.VALUE_CODEC.fieldOf("straight_difference").forGetter(placer -> placer.straightDifference), + Codec.FLOAT.fieldOf("decline_chance").forGetter(placer -> placer.declineChance), + Codec.INT.fieldOf("max_foliage_radius_bonus").forGetter(placer -> placer.maxFoliageRadiusBonus)) + ).apply(instance, LeapingTrunkPlacer::new)); - private final IntProvider straightMax; - private final IntProvider straightDifference; - private final float declineChance; - private final int maxFoliageRadiusBonus; + private final IntProvider straightMax; + private final IntProvider straightDifference; + private final float declineChance; + private final int maxFoliageRadiusBonus; - public LeapingTrunkPlacer(int baseHeight, int firstRandomHeight, int secondRandomHeight, IntProvider straightMax, IntProvider straightDifference, float declineChance, int maxFoliageRadiusBonus) { - super(baseHeight, firstRandomHeight, secondRandomHeight); - this.straightMax = straightMax; - this.straightDifference = straightDifference; - this.declineChance = declineChance; - this.maxFoliageRadiusBonus = maxFoliageRadiusBonus; - } + public LeapingTrunkPlacer(int baseHeight, int firstRandomHeight, int secondRandomHeight, IntProvider straightMax, IntProvider straightDifference, float declineChance, int maxFoliageRadiusBonus) { + super(baseHeight, firstRandomHeight, secondRandomHeight); + this.straightMax = straightMax; + this.straightDifference = straightDifference; + this.declineChance = declineChance; + this.maxFoliageRadiusBonus = maxFoliageRadiusBonus; + } - @Override - protected TrunkPlacerType getType() { - return PromenadeTrunkPlacerTypes.LEAPING; - } + @Override + protected TrunkPlacerType getType() { + return PromenadeTrunkPlacerTypes.LEAPING; + } - @Override - public List generate(TestableWorld world, BiConsumer replacer, Random random, int height, BlockPos startPos, TreeFeatureConfig config) { - Direction direction = Direction.Type.HORIZONTAL.random(random); - BlockPos.Mutable mutable = startPos.mutableCopy().move(Direction.DOWN); + @Override + public List generate(TestableWorld world, BiConsumer replacer, Random random, int height, BlockPos startPos, TreeFeatureConfig config) { + Direction direction = Direction.Type.HORIZONTAL.random(random); + BlockPos.Mutable mutable = startPos.mutableCopy().move(Direction.DOWN); - int j = this.straightMax.get(random); - int k = j; + int j = this.straightMax.get(random); + int k = j; - setToDirt(world, replacer, random, mutable, config); - for (int i = 0; i < height; ++i) { - mutable.move(Direction.UP); - if (k <= 0) { - j += this.straightDifference.get(random); - k = j; - if (random.nextFloat() < this.declineChance && i < height - 1) { - getAndSetState(world, replacer, random, mutable, config); - if (random.nextBoolean()) { - mutable.move(direction.rotateYClockwise()); - } else { - mutable.move(direction.rotateYCounterclockwise()); - } - } - mutable.move(direction); - } - getAndSetState(world, replacer, random, mutable, config); - k--; - } + setToDirt(world, replacer, random, mutable, config); + for (int i = 0; i < height; ++i) { + mutable.move(Direction.UP); + if (k <= 0) { + j += this.straightDifference.get(random); + k = j; + if (random.nextFloat() < this.declineChance && i < height - 1) { + getAndSetState(world, replacer, random, mutable, config); + if (random.nextBoolean()) { + mutable.move(direction.rotateYClockwise()); + } else { + mutable.move(direction.rotateYCounterclockwise()); + } + } + mutable.move(direction); + } + getAndSetState(world, replacer, random, mutable, config); + k--; + } - mutable.move(Direction.UP); + mutable.move(Direction.UP); - double heightRatio = MathHelper.clamp((height - this.baseHeight) / (double) (this.firstRandomHeight + this.secondRandomHeight), 0.0D, 0.999D); - return ImmutableList.of(new FoliagePlacer.TreeNode(mutable, MathHelper.floor((this.maxFoliageRadiusBonus + 1) * heightRatio), false)); - } + double heightRatio = MathHelper.clamp((height - this.baseHeight) / (double) (this.firstRandomHeight + this.secondRandomHeight), 0.0D, 0.999D); + return ImmutableList.of(new FoliagePlacer.TreeNode(mutable, MathHelper.floor((this.maxFoliageRadiusBonus + 1) * heightRatio), false)); + } } diff --git a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/PromenadeTrunkPlacerTypes.java b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/PromenadeTrunkPlacerTypes.java index 23ab8965..36344df1 100644 --- a/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/PromenadeTrunkPlacerTypes.java +++ b/src/main/java/fr/hugman/promenade/world/gen/tree/trunk/PromenadeTrunkPlacerTypes.java @@ -1,18 +1,31 @@ +/* + * Copyright (c) 2020, 2021, 2022, 2023, 2024, 2025 Hugman + * + * This software is licensed under the PolyForm Shield License 1.0.0. + * You may obtain a copy of the License at + * + * https://polyformproject.org/licenses/shield/1.0.0 + * + * You may use this software only for non-commercial purposes. + * For commercial use, you must obtain a separate commercial license. + */ package fr.hugman.promenade.world.gen.tree.trunk; import com.mojang.serialization.MapCodec; -import fr.hugman.promenade.Promenade; + import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.world.gen.trunk.TrunkPlacer; import net.minecraft.world.gen.trunk.TrunkPlacerType; +import fr.hugman.promenade.Promenade; + public class PromenadeTrunkPlacerTypes { - public static final TrunkPlacerType LEAPING = register("leaping", LeapingTrunkPlacer.CODEC); - public static final TrunkPlacerType BRANCHING_STRAIGHT = register("branching_straight", BranchingStraightTrunkPlacer.CODEC); + public static final TrunkPlacerType LEAPING = register("leaping", LeapingTrunkPlacer.CODEC); + public static final TrunkPlacerType BRANCHING_STRAIGHT = register("branching_straight", BranchingStraightTrunkPlacer.CODEC); - private static

TrunkPlacerType

register(String path, MapCodec

codec) { - return Registry.register(Registries.TRUNK_PLACER_TYPE, Promenade.id(path), new TrunkPlacerType<>(codec)); - } + private static

TrunkPlacerType

register(String path, MapCodec

codec) { + return Registry.register(Registries.TRUNK_PLACER_TYPE, Promenade.id(path), new TrunkPlacerType<>(codec)); + } }