From b733b5ec73c7a3b96105b2c97089b41ea8d22b62 Mon Sep 17 00:00:00 2001 From: Fox Date: Sun, 20 Oct 2024 00:04:27 +0200 Subject: [PATCH 1/7] add parchment for better parameter names --- build.gradle | 1 + gradle.properties | 4 ++-- settings.gradle | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 2c3625fc..d111a12f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ plugins { id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id "org.sonarqube" version "4.3.0.3225" + id 'org.parchmentmc.librarian.forgegradle' version '1.+' } version = "${minecraft_version}-${mod_version}" diff --git a/gradle.properties b/gradle.properties index dc55160b..a187c4fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,8 +10,8 @@ minecraft_version_range=[1.20.1,1.21) forge_version=47.2.0 forge_version_range=47,) loader_version_range=[47,) -mapping_channel=official -mapping_version=1.20.1 +mapping_channel=parchment +mapping_version=1.20.1-2023.09.03-1.20.1 # ------------------------------------------------ # Mod Properties # ------------------------------------------------ diff --git a/settings.gradle b/settings.gradle index a54af735..4aa3b629 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,6 +6,7 @@ pluginManagement { url = 'https://maven.minecraftforge.net/' } maven {url 'https://repo.spongepowered.org/repository/maven-public/'} + maven { url = 'https://maven.parchmentmc.org' } } } From 4b065b27a40088ccc5c90389fa60d93d0981e36d Mon Sep 17 00:00:00 2001 From: Fox Date: Sun, 20 Oct 2024 00:05:19 +0200 Subject: [PATCH 2/7] add cork tree --- .../forge/biome_modifier/add_cork_tree.json | 6 + .../loot_tables/blocks/cork_tree_leaves.json | 136 ++++++++++++++++++ .../loot_tables/blocks/cork_tree_sapling.json | 21 +++ .../loot_tables/blocks/cork_wood.json | 21 +++ .../loot_tables/blocks/cork_wood_log.json | 21 +++ .../blocks/cork_wood_log_stripped.json | 21 +++ .../blocks/cork_wood_stripped.json | 21 +++ .../tags/worldgen/biome/has_cork_tree.json | 6 + .../configured_feature/cork_tree.json | 53 +++++++ .../placed_feature/cork_tree_placed.json | 47 ++++++ .../growthcraft/cellar/GrowthcraftCellar.java | 6 +- .../GrowthcraftCellarDataGenerators.java | 7 +- .../GrowthcraftCellarBlockLootTables.java | 7 + .../GrowthcraftCellarWorldGenProvider.java | 31 ++++ .../cellar/init/GrowthcraftCellarBlocks.java | 53 ++++++- .../cellar/init/GrowthcraftCellarTags.java | 17 +++ .../growthcraft/cellar/shared/Reference.java | 8 ++ .../GrowthcraftCellarBiomeModifiers.java | 32 +++++ .../GrowthcraftCellarConfiguredFeatures.java | 51 +++++++ .../GrowthcraftCellarPlacedFeatures.java | 38 +++++ .../world/feature/tree/CorkTreeGrower.java | 18 +++ .../blockstates/cork_tree_leaves.json | 5 + .../blockstates/cork_tree_sapling.json | 5 + .../blockstates/cork_wood.json | 7 + .../blockstates/cork_wood_log.json | 7 + .../blockstates/cork_wood_log_stripped.json | 7 + .../blockstates/cork_wood_stripped.json | 7 + .../assets/growthcraft_cellar/lang/en_us.json | 6 + .../models/block/cork_tree_leaves.json | 6 + .../models/block/cork_tree_sapling.json | 7 + .../models/block/cork_wood.json | 7 + .../models/block/cork_wood_log.json | 7 + .../models/block/cork_wood_log_stripped.json | 7 + .../models/block/cork_wood_stripped.json | 7 + .../models/item/cork_tree_leaves.json | 3 + .../models/item/cork_tree_sapling.json | 6 + .../models/item/cork_wood.json | 3 + .../models/item/cork_wood_log.json | 3 + .../models/item/cork_wood_log_stripped.json | 3 + .../models/item/cork_wood_stripped.json | 3 + .../cork_leaves_opaque.png | Bin .../cork_tree_leaves.png} | Bin .../cork_tree_sapling.png} | Bin .../cork_wood_log.png} | Bin .../cork_wood_log_top.png} | Bin .../stripped_cork_log.png} | Bin .../block/cork/stripped_cork_log_top.png | Bin 0 -> 1963 bytes 47 files changed, 722 insertions(+), 5 deletions(-) create mode 100644 src/generated/resources/data/growthcraft_cellar/forge/biome_modifier/add_cork_tree.json create mode 100644 src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_tree_leaves.json create mode 100644 src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_tree_sapling.json create mode 100644 src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood.json create mode 100644 src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_log.json create mode 100644 src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_log_stripped.json create mode 100644 src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_stripped.json create mode 100644 src/generated/resources/data/growthcraft_cellar/tags/worldgen/biome/has_cork_tree.json create mode 100644 src/generated/resources/data/growthcraft_cellar/worldgen/configured_feature/cork_tree.json create mode 100644 src/generated/resources/data/growthcraft_cellar/worldgen/placed_feature/cork_tree_placed.json create mode 100644 src/main/java/growthcraft/cellar/datagen/providers/GrowthcraftCellarWorldGenProvider.java create mode 100644 src/main/java/growthcraft/cellar/world/GrowthcraftCellarBiomeModifiers.java create mode 100644 src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java create mode 100644 src/main/java/growthcraft/cellar/world/GrowthcraftCellarPlacedFeatures.java create mode 100644 src/main/java/growthcraft/cellar/world/feature/tree/CorkTreeGrower.java create mode 100644 src/main/resources/assets/growthcraft_cellar/blockstates/cork_tree_leaves.json create mode 100644 src/main/resources/assets/growthcraft_cellar/blockstates/cork_tree_sapling.json create mode 100644 src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood.json create mode 100644 src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_log.json create mode 100644 src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_log_stripped.json create mode 100644 src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_stripped.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/block/cork_tree_leaves.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/block/cork_tree_sapling.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/block/cork_wood.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_log.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_log_stripped.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_stripped.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/item/cork_tree_leaves.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/item/cork_tree_sapling.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/item/cork_wood.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_log.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_log_stripped.json create mode 100644 src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_stripped.json rename src/main/resources/assets/growthcraft_cellar/textures/block/{cork_leaves => cork}/cork_leaves_opaque.png (100%) rename src/main/resources/assets/growthcraft_cellar/textures/block/{cork_leaves/cork_leaves.png => cork/cork_tree_leaves.png} (100%) rename src/main/resources/assets/growthcraft_cellar/textures/block/{cork_sapling.png => cork/cork_tree_sapling.png} (100%) rename src/main/resources/assets/growthcraft_cellar/textures/block/{cork_log/cork_log_side.png => cork/cork_wood_log.png} (100%) rename src/main/resources/assets/growthcraft_cellar/textures/block/{cork_log/cork_log_end.png => cork/cork_wood_log_top.png} (100%) rename src/main/resources/assets/growthcraft_cellar/textures/block/{cork_log/cork_log_grain.png => cork/stripped_cork_log.png} (100%) create mode 100644 src/main/resources/assets/growthcraft_cellar/textures/block/cork/stripped_cork_log_top.png diff --git a/src/generated/resources/data/growthcraft_cellar/forge/biome_modifier/add_cork_tree.json b/src/generated/resources/data/growthcraft_cellar/forge/biome_modifier/add_cork_tree.json new file mode 100644 index 00000000..24fc7191 --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/forge/biome_modifier/add_cork_tree.json @@ -0,0 +1,6 @@ +{ + "type": "forge:add_features", + "biomes": "#growthcraft_cellar:has_cork_tree", + "features": "growthcraft_cellar:cork_tree_placed", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_tree_leaves.json b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_tree_leaves.json new file mode 100644 index 00000000..d9484c8a --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_tree_leaves.json @@ -0,0 +1,136 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:any_of", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "items": [ + "minecraft:shears" + ] + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "growthcraft_cellar:cork_tree_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ], + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune" + } + ], + "name": "growthcraft_cellar:cork_tree_sapling" + } + ] + } + ], + "rolls": 1.0 + }, + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:any_of", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "items": [ + "minecraft:shears" + ] + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ], + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ], + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune" + } + ], + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 2.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "growthcraft_cellar:blocks/cork_tree_leaves" +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_tree_sapling.json b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_tree_sapling.json new file mode 100644 index 00000000..ea8a3690 --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_tree_sapling.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "growthcraft_cellar:cork_tree_sapling" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "growthcraft_cellar:blocks/cork_tree_sapling" +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood.json b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood.json new file mode 100644 index 00000000..a19e64f2 --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "growthcraft_cellar:cork_wood" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "growthcraft_cellar:blocks/cork_wood" +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_log.json b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_log.json new file mode 100644 index 00000000..2c0f4754 --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_log.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "growthcraft_cellar:cork_wood_log" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "growthcraft_cellar:blocks/cork_wood_log" +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_log_stripped.json b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_log_stripped.json new file mode 100644 index 00000000..60851e54 --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_log_stripped.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "growthcraft_cellar:cork_wood_log_stripped" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "growthcraft_cellar:blocks/cork_wood_log_stripped" +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_stripped.json b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_stripped.json new file mode 100644 index 00000000..b0c78188 --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/loot_tables/blocks/cork_wood_stripped.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "growthcraft_cellar:cork_wood_stripped" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "growthcraft_cellar:blocks/cork_wood_stripped" +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_cellar/tags/worldgen/biome/has_cork_tree.json b/src/generated/resources/data/growthcraft_cellar/tags/worldgen/biome/has_cork_tree.json new file mode 100644 index 00000000..f58a458f --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/tags/worldgen/biome/has_cork_tree.json @@ -0,0 +1,6 @@ +{ + "values": [ + "minecraft:dark_forest", + "minecraft:meadow" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_cellar/worldgen/configured_feature/cork_tree.json b/src/generated/resources/data/growthcraft_cellar/worldgen/configured_feature/cork_tree.json new file mode 100644 index 00000000..ed45abc0 --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/worldgen/configured_feature/cork_tree.json @@ -0,0 +1,53 @@ +{ + "type": "minecraft:tree", + "config": { + "decorators": [], + "dirt_provider": { + "type": "minecraft:simple_state_provider", + "state": { + "Name": "minecraft:dirt" + } + }, + "foliage_placer": { + "type": "minecraft:fancy_foliage_placer", + "height": 3, + "offset": 3, + "radius": 3 + }, + "foliage_provider": { + "type": "minecraft:simple_state_provider", + "state": { + "Name": "growthcraft_cellar:cork_tree_leaves", + "Properties": { + "distance": "7", + "persistent": "false", + "waterlogged": "false" + } + } + }, + "force_dirt": false, + "ignore_vines": false, + "minimum_size": { + "type": "minecraft:two_layers_feature_size", + "limit": 0, + "lower_size": 0, + "min_clipped_height": 4, + "upper_size": 0 + }, + "trunk_placer": { + "type": "minecraft:fancy_trunk_placer", + "base_height": 9, + "height_rand_a": 4, + "height_rand_b": 0 + }, + "trunk_provider": { + "type": "minecraft:simple_state_provider", + "state": { + "Name": "growthcraft_cellar:cork_wood_log", + "Properties": { + "axis": "y" + } + } + } + } +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_cellar/worldgen/placed_feature/cork_tree_placed.json b/src/generated/resources/data/growthcraft_cellar/worldgen/placed_feature/cork_tree_placed.json new file mode 100644 index 00000000..4958234e --- /dev/null +++ b/src/generated/resources/data/growthcraft_cellar/worldgen/placed_feature/cork_tree_placed.json @@ -0,0 +1,47 @@ +{ + "feature": "growthcraft_cellar:cork_tree", + "placement": [ + { + "type": "minecraft:count", + "count": { + "type": "minecraft:weighted_list", + "distribution": [ + { + "data": 0, + "weight": 19 + }, + { + "data": 1, + "weight": 1 + } + ] + } + }, + { + "type": "minecraft:in_square" + }, + { + "type": "minecraft:surface_water_depth_filter", + "max_water_depth": 0 + }, + { + "type": "minecraft:heightmap", + "heightmap": "OCEAN_FLOOR" + }, + { + "type": "minecraft:biome" + }, + { + "type": "minecraft:block_predicate_filter", + "predicate": { + "type": "minecraft:would_survive", + "state": { + "Name": "growthcraft_cellar:cork_tree_sapling", + "Properties": { + "stage": "0" + } + } + } + } + ] +} \ No newline at end of file diff --git a/src/main/java/growthcraft/cellar/GrowthcraftCellar.java b/src/main/java/growthcraft/cellar/GrowthcraftCellar.java index 055636b3..ee2fff5e 100644 --- a/src/main/java/growthcraft/cellar/GrowthcraftCellar.java +++ b/src/main/java/growthcraft/cellar/GrowthcraftCellar.java @@ -13,7 +13,11 @@ import growthcraft.cellar.init.client.GrowthcraftCellarBlockRenderers; import growthcraft.cellar.init.config.GrowthcraftCellarConfig; import growthcraft.cellar.lib.networking.GrowthcraftCellarMessages; -import growthcraft.cellar.screen.*; +import growthcraft.cellar.screen.BrewKettleScreen; +import growthcraft.cellar.screen.CultureJarScreen; +import growthcraft.cellar.screen.FermentationBarrelScreen; +import growthcraft.cellar.screen.FruitPressScreen; +import growthcraft.cellar.screen.RoasterScreen; import growthcraft.cellar.shared.Reference; import growthcraft.core.init.GrowthcraftCreativeModeTabs; import net.minecraft.client.gui.screens.MenuScreens; diff --git a/src/main/java/growthcraft/cellar/datagen/GrowthcraftCellarDataGenerators.java b/src/main/java/growthcraft/cellar/datagen/GrowthcraftCellarDataGenerators.java index 779dbbfb..4de30e47 100644 --- a/src/main/java/growthcraft/cellar/datagen/GrowthcraftCellarDataGenerators.java +++ b/src/main/java/growthcraft/cellar/datagen/GrowthcraftCellarDataGenerators.java @@ -1,9 +1,12 @@ package growthcraft.cellar.datagen; -import growthcraft.cellar.datagen.providers.GrowthcraftCellarGlobalLootModifiersProvider; +import java.util.concurrent.CompletableFuture; + import growthcraft.cellar.datagen.providers.GrowthcraftCellarLootTableProvider; import growthcraft.cellar.datagen.providers.GrowthcraftCellarRecipes; +import growthcraft.cellar.datagen.providers.GrowthcraftCellarWorldGenProvider; import growthcraft.cellar.shared.Reference; +import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; import net.minecraft.data.PackOutput; import net.minecraftforge.data.event.GatherDataEvent; @@ -21,9 +24,11 @@ private GrowthcraftCellarDataGenerators() { public static void gatherData(GatherDataEvent event) { DataGenerator generator = event.getGenerator(); PackOutput packOutput = generator.getPackOutput(); + CompletableFuture lookupProvider = event.getLookupProvider(); generator.addProvider(event.includeServer(), new GrowthcraftCellarRecipes(packOutput)); generator.addProvider(event.includeServer(), new GrowthcraftCellarLootTableProvider(packOutput)); + generator.addProvider(event.includeServer(), new GrowthcraftCellarWorldGenProvider(packOutput, lookupProvider)); // generator.addProvider(event.includeServer(), new GrowthcraftCellarGlobalLootModifiersProvider(packOutput)); } } diff --git a/src/main/java/growthcraft/cellar/datagen/providers/GrowthcraftCellarBlockLootTables.java b/src/main/java/growthcraft/cellar/datagen/providers/GrowthcraftCellarBlockLootTables.java index 847b2470..9d05cb48 100644 --- a/src/main/java/growthcraft/cellar/datagen/providers/GrowthcraftCellarBlockLootTables.java +++ b/src/main/java/growthcraft/cellar/datagen/providers/GrowthcraftCellarBlockLootTables.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.stream.Collectors; +import growthcraft.apples.init.GrowthcraftApplesBlocks; import growthcraft.cellar.init.GrowthcraftCellarBlockEntities; import growthcraft.cellar.init.GrowthcraftCellarBlocks; import growthcraft.cellar.init.GrowthcraftCellarFluids; @@ -37,6 +38,12 @@ protected void generate() { add(GrowthcraftCellarBlocks.PURPLE_GRAPE_VINE_LEAVES.get(), createMangroveLeavesDrops(GrowthcraftCellarBlocks.PURPLE_GRAPE_VINE_LEAVES.get())); add(GrowthcraftCellarBlocks.RED_GRAPE_VINE_LEAVES.get(), createMangroveLeavesDrops(GrowthcraftCellarBlocks.RED_GRAPE_VINE_LEAVES.get())); add(GrowthcraftCellarBlocks.WHITE_GRAPE_VINE_LEAVES.get(), createMangroveLeavesDrops(GrowthcraftCellarBlocks.WHITE_GRAPE_VINE_LEAVES.get())); + add(GrowthcraftCellarBlocks.CORK_TREE_LEAVES.get(), createLeavesDrops(GrowthcraftCellarBlocks.CORK_TREE_LEAVES.get(), GrowthcraftCellarBlocks.CORK_TREE_SAPLING.get(), NORMAL_LEAVES_SAPLING_CHANCES)); + dropSelf(GrowthcraftCellarBlocks.CORK_TREE_SAPLING.get()); + dropSelf(GrowthcraftCellarBlocks.CORK_WOOD.get()); + dropSelf(GrowthcraftCellarBlocks.CORK_WOOD_LOG.get()); + dropSelf(GrowthcraftCellarBlocks.CORK_WOOD_LOG_STRIPPED.get()); + dropSelf(GrowthcraftCellarBlocks.CORK_WOOD_STRIPPED.get()); } @Override diff --git a/src/main/java/growthcraft/cellar/datagen/providers/GrowthcraftCellarWorldGenProvider.java b/src/main/java/growthcraft/cellar/datagen/providers/GrowthcraftCellarWorldGenProvider.java new file mode 100644 index 00000000..4b7dc9ba --- /dev/null +++ b/src/main/java/growthcraft/cellar/datagen/providers/GrowthcraftCellarWorldGenProvider.java @@ -0,0 +1,31 @@ +package growthcraft.cellar.datagen.providers; + +import java.util.Set; +import java.util.concurrent.CompletableFuture; + +import growthcraft.cellar.shared.Reference; +import growthcraft.cellar.world.GrowthcraftCellarBiomeModifiers; +import growthcraft.cellar.world.GrowthcraftCellarConfiguredFeatures; +import growthcraft.cellar.world.GrowthcraftCellarPlacedFeatures; +import net.minecraft.core.HolderLookup.Provider; +import net.minecraft.core.RegistrySetBuilder; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.PackOutput; +import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider; +import net.minecraftforge.registries.ForgeRegistries; + +public class GrowthcraftCellarWorldGenProvider extends DatapackBuiltinEntriesProvider{ + public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder() + .add(Registries.CONFIGURED_FEATURE, GrowthcraftCellarConfiguredFeatures::bootstrap) + .add(Registries.PLACED_FEATURE, GrowthcraftCellarPlacedFeatures::bootstrap) + .add(ForgeRegistries.Keys.BIOME_MODIFIERS, GrowthcraftCellarBiomeModifiers::bootstrap); + + public GrowthcraftCellarWorldGenProvider(PackOutput output, CompletableFuture registries) { + super(output, registries, BUILDER, Set.of(Reference.MODID)); + } + + @Override + public String getName() { + return "Growthcraft Cellar WorldGen"; + } +} diff --git a/src/main/java/growthcraft/cellar/init/GrowthcraftCellarBlocks.java b/src/main/java/growthcraft/cellar/init/GrowthcraftCellarBlocks.java index 38ef3233..11db6ab3 100644 --- a/src/main/java/growthcraft/cellar/init/GrowthcraftCellarBlocks.java +++ b/src/main/java/growthcraft/cellar/init/GrowthcraftCellarBlocks.java @@ -1,16 +1,31 @@ package growthcraft.cellar.init; -import growthcraft.cellar.block.*; +import java.util.function.Supplier; + +import growthcraft.cellar.block.BrewKettleBlock; +import growthcraft.cellar.block.CultureJarBlock; +import growthcraft.cellar.block.FermentationBarrelBlock; +import growthcraft.cellar.block.FruitPressBlock; +import growthcraft.cellar.block.FruitPressPistonBlock; +import growthcraft.cellar.block.GrapeVineCropBlock; +import growthcraft.cellar.block.GrapeVineFruitBlock; +import growthcraft.cellar.block.GrapeVineLeavesCropBlock; +import growthcraft.cellar.block.HopsCropBlock; +import growthcraft.cellar.block.RoasterBlock; import growthcraft.cellar.shared.Reference; +import growthcraft.cellar.world.feature.tree.CorkTreeGrower; +import growthcraft.lib.block.GrowthcraftLogBlock; +import growthcraft.lib.block.GrowthcraftSaplingBlock; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; -import java.util.function.Supplier; - public class GrowthcraftCellarBlocks { public static final DeferredRegister BLOCKS = DeferredRegister.create( @@ -92,6 +107,38 @@ public class GrowthcraftCellarBlocks { public static final RegistryObject HOPS_VINE = registerBlock( Reference.UnlocalizedName.HOPS_VINE, HopsCropBlock::new, true ); + + public static final RegistryObject CORK_TREE_SAPLING = registerBlock( + Reference.UnlocalizedName.CORK_TREE_SAPLING, + () -> new GrowthcraftSaplingBlock( + new CorkTreeGrower() + ) + ); + + public static final RegistryObject CORK_WOOD = registerBlock( + Reference.UnlocalizedName.CORK_WOOD, + GrowthcraftLogBlock::new + ); + + public static final RegistryObject CORK_WOOD_LOG = registerBlock( + Reference.UnlocalizedName.CORK_WOOD_LOG, + GrowthcraftLogBlock::new + ); + + public static final RegistryObject CORK_WOOD_LOG_STRIPPED = registerBlock( + Reference.UnlocalizedName.CORK_WOOD_LOG_STRIPPED, + GrowthcraftLogBlock::new + ); + + public static final RegistryObject CORK_WOOD_STRIPPED = registerBlock( + Reference.UnlocalizedName.CORK_WOOD_STRIPPED, + GrowthcraftLogBlock::new + ); + + public static final RegistryObject CORK_TREE_LEAVES = registerBlock( + Reference.UnlocalizedName.CORK_TREE_LEAVES, + () -> new LeavesBlock(BlockBehaviour.Properties.copy(Blocks.OAK_LEAVES)) + ); private static RegistryObject registerBlock(String name, Supplier block) { return registerBlock(name, block, false); diff --git a/src/main/java/growthcraft/cellar/init/GrowthcraftCellarTags.java b/src/main/java/growthcraft/cellar/init/GrowthcraftCellarTags.java index 5c90fbce..f4448d90 100644 --- a/src/main/java/growthcraft/cellar/init/GrowthcraftCellarTags.java +++ b/src/main/java/growthcraft/cellar/init/GrowthcraftCellarTags.java @@ -1,12 +1,15 @@ package growthcraft.cellar.init; import growthcraft.cellar.shared.Reference; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BiomeTags; import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; +import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.material.Fluid; @@ -17,6 +20,7 @@ public static void init() { GrowthcraftCellarTags.Items.init(); GrowthcraftCellarTags.Fluids.init(); GrowthcraftCellarTags.EntityTypes.init(); + GrowthcraftCellarTags.Biomes.init(); } public static class Blocks { @@ -75,5 +79,18 @@ private static void init() { // return TagKey.create(Registry.ENTITY_TYPE_REGISTRY, new ResourceLocation(Reference.MODID, name)); //} } + + public static class Biomes { + + public static final TagKey HAS_CORK_TREE = tag(Reference.UnlocalizedName.HAS_CORK_TREE); + + private static void init() { + // Do nothing, simply instantiate static variables + } + + private static TagKey tag(String name) { + return TagKey.create(Registries.BIOME, new ResourceLocation(Reference.MODID, name)); + } + } } diff --git a/src/main/java/growthcraft/cellar/shared/Reference.java b/src/main/java/growthcraft/cellar/shared/Reference.java index 68cb614f..6effda0e 100644 --- a/src/main/java/growthcraft/cellar/shared/Reference.java +++ b/src/main/java/growthcraft/cellar/shared/Reference.java @@ -111,6 +111,14 @@ public static class UnlocalizedName { public static final String TAG_BARLEY = "grain/barley"; public static final String TAG_GRAPE_SEEDS = "seeds/grapes"; public static final String TAG_GRAPE_FRUITS = "fruits/grapes"; + public static final String CORK_TREE = "cork_tree"; + public static final String CORK_TREE_LEAVES = "cork_tree_leaves"; + public static final String CORK_TREE_SAPLING = "cork_tree_sapling"; + public static final String CORK_WOOD = "cork_wood"; + public static final String CORK_WOOD_STRIPPED = "cork_wood_stripped"; + public static final String CORK_WOOD_LOG = "cork_wood_log"; + public static final String CORK_WOOD_LOG_STRIPPED = "cork_wood_log_stripped"; + public static final String HAS_CORK_TREE = "has_cork_tree"; private UnlocalizedName() { /* Disable Automatic Creation of Public Constructor */ diff --git a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarBiomeModifiers.java b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarBiomeModifiers.java new file mode 100644 index 00000000..520e1083 --- /dev/null +++ b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarBiomeModifiers.java @@ -0,0 +1,32 @@ +package growthcraft.cellar.world; + +import growthcraft.cellar.init.GrowthcraftCellarTags; +import growthcraft.cellar.shared.Reference; +import net.minecraft.core.HolderSet; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraftforge.common.world.BiomeModifier; +import net.minecraftforge.common.world.ForgeBiomeModifiers; +import net.minecraftforge.registries.ForgeRegistries; + +public class GrowthcraftCellarBiomeModifiers { + + public static final ResourceKey ADD_CORK_TREE = registerKey("add_cork_tree"); + + public static void bootstrap(BootstapContext context) { + var placedFeatures = context.lookup(Registries.PLACED_FEATURE); + var biomes = context.lookup(Registries.BIOME); + + context.register(ADD_CORK_TREE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( + biomes.getOrThrow(GrowthcraftCellarTags.Biomes.HAS_CORK_TREE), + HolderSet.direct(placedFeatures.getOrThrow(GrowthcraftCellarPlacedFeatures.CORK_TREE_PLACED_KEY)), + GenerationStep.Decoration.VEGETAL_DECORATION)); + } + + private static ResourceKey registerKey(String name) { + return ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(Reference.MODID, name)); + } +} diff --git a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java new file mode 100644 index 00000000..e146dd38 --- /dev/null +++ b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java @@ -0,0 +1,51 @@ +package growthcraft.cellar.world; + +import java.util.OptionalInt; + +import growthcraft.cellar.init.GrowthcraftCellarBlocks; +import growthcraft.cellar.shared.Reference; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.valueproviders.ConstantInt; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; +import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize; +import net.minecraft.world.level.levelgen.feature.foliageplacers.FancyFoliagePlacer; +import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; +import net.minecraft.world.level.levelgen.feature.trunkplacers.FancyTrunkPlacer; + +public class GrowthcraftCellarConfiguredFeatures { + public static final ResourceKey> CORK_TREE_KEY = registerKey(Reference.UnlocalizedName.CORK_TREE); + + public static void bootstrap(BootstapContext> context) { + register(context, CORK_TREE_KEY, Feature.TREE, new TreeConfiguration.TreeConfigurationBuilder( + // Trunk block + BlockStateProvider.simple(GrowthcraftCellarBlocks.CORK_WOOD_LOG.get()), + // Trunk placer (baseHeight, heightRandA, heightRandB) + new FancyTrunkPlacer(9, 4, 0), + // Leaves block + BlockStateProvider.simple(GrowthcraftCellarBlocks.CORK_TREE_LEAVES.get()), + // Leaves placer (radius, offset, height) + new FancyFoliagePlacer(ConstantInt.of(3), ConstantInt.of(3), 3), + // Spawn Area Saturation (limit, lowerSize, upperSize) + new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4))).build() + ); + } + + private static ResourceKey> registerKey(String name) { + return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(Reference.MODID, name)); + } + + private static > void register( + BootstapContext> context, + ResourceKey> key, + FeatureType feature, + FeatureConfig configuration + ) { + context.register(key, new ConfiguredFeature<>(feature, configuration)); + } +} diff --git a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarPlacedFeatures.java b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarPlacedFeatures.java new file mode 100644 index 00000000..9fab1425 --- /dev/null +++ b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarPlacedFeatures.java @@ -0,0 +1,38 @@ +package growthcraft.cellar.world; + +import java.util.List; + +import growthcraft.cellar.init.GrowthcraftCellarBlocks; +import growthcraft.cellar.shared.Reference; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderGetter; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.data.worldgen.placement.PlacementUtils; +import net.minecraft.data.worldgen.placement.VegetationPlacements; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; +import net.minecraft.world.level.levelgen.placement.PlacementModifier; + +public class GrowthcraftCellarPlacedFeatures { + + public static final ResourceKey CORK_TREE_PLACED_KEY = createKey(Reference.UnlocalizedName.CORK_TREE + "_placed"); + + public static void bootstrap(BootstapContext context) { + HolderGetter> configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE); + + register(context, CORK_TREE_PLACED_KEY, configuredFeatures.getOrThrow(GrowthcraftCellarConfiguredFeatures.CORK_TREE_KEY), + VegetationPlacements.treePlacement(PlacementUtils.countExtra(0, 0.05F, 1), GrowthcraftCellarBlocks.CORK_TREE_SAPLING.get())); + } + + private static ResourceKey createKey(String name) { + return ResourceKey.create(Registries.PLACED_FEATURE, new ResourceLocation(Reference.MODID, name)); + } + + private static void register(BootstapContext context, ResourceKey key, Holder> configuration, + List modifiers) { + context.register(key, new PlacedFeature(configuration, List.copyOf(modifiers))); + } +} diff --git a/src/main/java/growthcraft/cellar/world/feature/tree/CorkTreeGrower.java b/src/main/java/growthcraft/cellar/world/feature/tree/CorkTreeGrower.java new file mode 100644 index 00000000..77d8fff0 --- /dev/null +++ b/src/main/java/growthcraft/cellar/world/feature/tree/CorkTreeGrower.java @@ -0,0 +1,18 @@ +package growthcraft.cellar.world.feature.tree; + +import org.jetbrains.annotations.Nullable; + +import growthcraft.cellar.world.GrowthcraftCellarConfiguredFeatures; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.grower.AbstractTreeGrower; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; + +public class CorkTreeGrower extends AbstractTreeGrower { + + @Nullable + @Override + protected ResourceKey> getConfiguredFeature(RandomSource randomSource, boolean largeHive) { + return GrowthcraftCellarConfiguredFeatures.CORK_TREE_KEY; + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/blockstates/cork_tree_leaves.json b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_tree_leaves.json new file mode 100644 index 00000000..b0289b50 --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_tree_leaves.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "growthcraft_cellar:block/cork_tree_leaves" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/growthcraft_cellar/blockstates/cork_tree_sapling.json b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_tree_sapling.json new file mode 100644 index 00000000..7e4cd73f --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_tree_sapling.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "growthcraft_cellar:block/cork_tree_sapling" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood.json b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood.json new file mode 100644 index 00000000..b09d40d8 --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood.json @@ -0,0 +1,7 @@ +{ + "variants": { + "axis=y": { "model": "growthcraft_cellar:block/cork_wood" }, + "axis=z": { "model": "growthcraft_cellar:block/cork_wood", "x": 90 }, + "axis=x": { "model": "growthcraft_cellar:block/cork_wood", "x": 90, "y": 90 } + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_log.json b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_log.json new file mode 100644 index 00000000..1082bece --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_log.json @@ -0,0 +1,7 @@ +{ + "variants": { + "axis=y": { "model": "growthcraft_cellar:block/cork_wood_log" }, + "axis=z": { "model": "growthcraft_cellar:block/cork_wood_log", "x": 90 }, + "axis=x": { "model": "growthcraft_cellar:block/cork_wood_log", "x": 90, "y": 90 } + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_log_stripped.json b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_log_stripped.json new file mode 100644 index 00000000..2f169a4b --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_log_stripped.json @@ -0,0 +1,7 @@ +{ + "variants": { + "axis=y": { "model": "growthcraft_cellar:block/cork_wood_log_stripped" }, + "axis=z": { "model": "growthcraft_cellar:block/cork_wood_log_stripped", "x": 90 }, + "axis=x": { "model": "growthcraft_cellar:block/cork_wood_log_stripped", "x": 90, "y": 90 } + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_stripped.json b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_stripped.json new file mode 100644 index 00000000..ebd91f64 --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/blockstates/cork_wood_stripped.json @@ -0,0 +1,7 @@ +{ + "variants": { + "axis=y": { "model": "growthcraft_cellar:block/cork_wood_stripped" }, + "axis=z": { "model": "growthcraft_cellar:block/cork_wood_stripped", "x": 90 }, + "axis=x": { "model": "growthcraft_cellar:block/cork_wood_stripped", "x": 90, "y": 90 } + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/lang/en_us.json b/src/main/resources/assets/growthcraft_cellar/lang/en_us.json index 38bf3434..500b8597 100644 --- a/src/main/resources/assets/growthcraft_cellar/lang/en_us.json +++ b/src/main/resources/assets/growthcraft_cellar/lang/en_us.json @@ -18,6 +18,12 @@ "block.growthcraft_cellar.white_grape_vine": "White Grape Vine", "block.growthcraft_cellar.white_grape_vine_crop": "White Grape Vine", "block.growthcraft_cellar.white_grape_vine_leaves": "White Grape Vine", + "block.growthcraft_cellar.cork_tree_leaves": "Cork Tree Leaves", + "block.growthcraft_cellar.cork_tree_sapling": "Cork Tree Sapling", + "block.growthcraft_cellar.cork_wood": "Cork Wood", + "block.growthcraft_cellar.cork_wood_log": "Cork Log", + "block.growthcraft_cellar.cork_wood_log_stripped": "Stripped Cork Log", + "block.growthcraft_cellar.cork_wood_stripped": "Stripped Cork Wood", "container.growthcraft_cellar.brew_kettle": "Brew Kettle", "container.growthcraft_cellar.culture_jar": "Culture Jar", "container.growthcraft_cellar.fermentation_barrel": "Fermentation Barrel", diff --git a/src/main/resources/assets/growthcraft_cellar/models/block/cork_tree_leaves.json b/src/main/resources/assets/growthcraft_cellar/models/block/cork_tree_leaves.json new file mode 100644 index 00000000..c58f33aa --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/block/cork_tree_leaves.json @@ -0,0 +1,6 @@ +{ + "parent": "block/leaves", + "textures": { + "all": "growthcraft_cellar:block/cork/cork_tree_leaves" + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/block/cork_tree_sapling.json b/src/main/resources/assets/growthcraft_cellar/models/block/cork_tree_sapling.json new file mode 100644 index 00000000..c8a834eb --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/block/cork_tree_sapling.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cross", + "render_type": "cutout", + "textures": { + "cross": "growthcraft_cellar:block/cork/cork_tree_sapling" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood.json b/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood.json new file mode 100644 index 00000000..3fc9c3cc --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_column", + "textures": { + "end": "growthcraft_cellar:block/cork/cork_wood_log", + "side": "growthcraft_cellar:block/cork/cork_wood_log" + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_log.json b/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_log.json new file mode 100644 index 00000000..0349a54d --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_log.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_column", + "textures": { + "end": "growthcraft_cellar:block/cork/cork_wood_log_top", + "side": "growthcraft_cellar:block/cork/cork_wood_log" + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_log_stripped.json b/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_log_stripped.json new file mode 100644 index 00000000..fc92332f --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_log_stripped.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_column", + "textures": { + "end": "growthcraft_cellar:block/cork/stripped_cork_log_top", + "side": "growthcraft_cellar:block/cork/stripped_cork_log" + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_stripped.json b/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_stripped.json new file mode 100644 index 00000000..075693f5 --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/block/cork_wood_stripped.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_column", + "textures": { + "end": "growthcraft_cellar:block/cork/stripped_cork_log", + "side": "growthcraft_cellar:block/cork/stripped_cork_log" + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/item/cork_tree_leaves.json b/src/main/resources/assets/growthcraft_cellar/models/item/cork_tree_leaves.json new file mode 100644 index 00000000..06c5ae5f --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/item/cork_tree_leaves.json @@ -0,0 +1,3 @@ +{ + "parent": "growthcraft_cellar:block/cork_tree_leaves" +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/item/cork_tree_sapling.json b/src/main/resources/assets/growthcraft_cellar/models/item/cork_tree_sapling.json new file mode 100644 index 00000000..100aee2a --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/item/cork_tree_sapling.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "growthcraft_cellar:block/cork/cork_tree_sapling" + } +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood.json b/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood.json new file mode 100644 index 00000000..7e0485b6 --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood.json @@ -0,0 +1,3 @@ +{ + "parent": "growthcraft_cellar:block/cork_wood" +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_log.json b/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_log.json new file mode 100644 index 00000000..cf4ca437 --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_log.json @@ -0,0 +1,3 @@ +{ + "parent": "growthcraft_cellar:block/cork_wood_log" +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_log_stripped.json b/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_log_stripped.json new file mode 100644 index 00000000..1aca7f61 --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_log_stripped.json @@ -0,0 +1,3 @@ +{ + "parent": "growthcraft_cellar:block/cork_wood_log_stripped" +} diff --git a/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_stripped.json b/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_stripped.json new file mode 100644 index 00000000..5113abaa --- /dev/null +++ b/src/main/resources/assets/growthcraft_cellar/models/item/cork_wood_stripped.json @@ -0,0 +1,3 @@ +{ + "parent": "growthcraft_cellar:block/cork_wood_stripped" +} diff --git a/src/main/resources/assets/growthcraft_cellar/textures/block/cork_leaves/cork_leaves_opaque.png b/src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_leaves_opaque.png similarity index 100% rename from src/main/resources/assets/growthcraft_cellar/textures/block/cork_leaves/cork_leaves_opaque.png rename to src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_leaves_opaque.png diff --git a/src/main/resources/assets/growthcraft_cellar/textures/block/cork_leaves/cork_leaves.png b/src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_tree_leaves.png similarity index 100% rename from src/main/resources/assets/growthcraft_cellar/textures/block/cork_leaves/cork_leaves.png rename to src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_tree_leaves.png diff --git a/src/main/resources/assets/growthcraft_cellar/textures/block/cork_sapling.png b/src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_tree_sapling.png similarity index 100% rename from src/main/resources/assets/growthcraft_cellar/textures/block/cork_sapling.png rename to src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_tree_sapling.png diff --git a/src/main/resources/assets/growthcraft_cellar/textures/block/cork_log/cork_log_side.png b/src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_wood_log.png similarity index 100% rename from src/main/resources/assets/growthcraft_cellar/textures/block/cork_log/cork_log_side.png rename to src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_wood_log.png diff --git a/src/main/resources/assets/growthcraft_cellar/textures/block/cork_log/cork_log_end.png b/src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_wood_log_top.png similarity index 100% rename from src/main/resources/assets/growthcraft_cellar/textures/block/cork_log/cork_log_end.png rename to src/main/resources/assets/growthcraft_cellar/textures/block/cork/cork_wood_log_top.png diff --git a/src/main/resources/assets/growthcraft_cellar/textures/block/cork_log/cork_log_grain.png b/src/main/resources/assets/growthcraft_cellar/textures/block/cork/stripped_cork_log.png similarity index 100% rename from src/main/resources/assets/growthcraft_cellar/textures/block/cork_log/cork_log_grain.png rename to src/main/resources/assets/growthcraft_cellar/textures/block/cork/stripped_cork_log.png diff --git a/src/main/resources/assets/growthcraft_cellar/textures/block/cork/stripped_cork_log_top.png b/src/main/resources/assets/growthcraft_cellar/textures/block/cork/stripped_cork_log_top.png new file mode 100644 index 0000000000000000000000000000000000000000..9302290147b6facc50294322bb7d1b886327c5db GIT binary patch literal 1963 zcmV;c2UPfpP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2S7&%wJ&)j8cw=7_XU;h+Rx zM1)xxM-uTV=PX|~O-ZN6)n|*~d>fubllU=oOerNDYN2*aySwZJ*GX>s(0xeFe%bo- z$;$3=9`R?$u|h68W(;e(=eBujHkSaWR)&)Oz8wQAi|HZ%GW~@cq}Y< zQa*OOHL&qy1`_8oD0YtNYMM+5ku8moea5v*n@W)nWp0`JxQ3z{aPB=GOmAa`rBgOB zp4ay#*Pc>}bEQtb?s{)^&T5IE*_zl+GsQky+=sdZjZ)E#qJvi+q}%>fvhjUR&7)YN z-ydVX&vK0#xr78T^f7DoLOQF3BmM2$FL$>oaY^a>E_aGk+48LFkD2CklLQ3u$r+lu z@|Jkoz_Xpzx%bwhl)9evpgmhQ6U{~)q(n4}FGXGwob&S{C^VgPvL+r{up}SZq7%?; z-^b34$$p2L_XgwAL+%gR&lx7HWC2wS z3VL_lTUgO7@w&(NgKJWs00@OhepdQFdXMC(?4#ZegH4b={qs-H^o>rmVW(mUid>5k z9dzg)r3P&fqxY}~5^^#I3$iGtAX+d8n~jA5Jru zrgo3Fj=EtBIM5RP2`Z|9^|a+@`ds3&q|U+nNHe%Yo|2!Ezc(VN-TG=2_sny4)nM+CYk z{Q8*rT+@M3EDgAvQJ{pXSur#fb`$Knsg zH!j97R7xT!eU4L}j~tot+Uz#dYcId;Si}$>u&Bze4=`;C3Xn zJRh*qzyAD8dVf5PQm71W^b@S*#QLLhs5jems_dU+#63~qsy#vIShI{c7@!FhVvdjv z$BHDYne4UIbUHNOkR_KIG{vp5rgNfbPKPBB+NBVK}zV3 z+>XV}pEMFY4Hh64CR8DvQ?<%O23S$dN0WcCK^ysaDd}s?4>g@if+Ac8^5zrWanJLE~>cDB{s4+{-$1*Vhz-9a*mHRSt zLJu$`KYFs|#W6ZmaY+h|MqP66^X-m_F?%64Ge7^VgdL0)zFn%1D zZm@YE0vru$qAQAKIHpW`a`j$P)Vf58gWA~wI?;ORneIn}_=9%i3UTx`1D@(^eXO0}G{0^KF2~R& z3JVgrE{{NwjD!O@#HaJXLB;{nL7{;t?hH2O)nWt+$K2fyCdpbk7^h4$>Ij(dHZrywU$%2$YvIo287yJ+ z@Vv|y=E2G(;l-6$L_l;9l7#t%WOrvDSSukeu}&q7dyTP`J76t^s$Dx<5Q`wM>F9Yg zxn!snpH?3q2m7Kt78<}FMiFah5zeR-L~wAQ@a4kLUi;P3%-Yj}t%Au-W~^*$eyuUW zU}AInan-#qt)4gV0H5;SAc$WoK7Z%zir1$Z2)k1!YFUY+Rt$-NK0lO@qft}pwl{d)dm0n002ovPDHLkV1mx}t%3jm literal 0 HcmV?d00001 From 28542fd26de86d50990dc79e6579b7360fffb1b7 Mon Sep 17 00:00:00 2001 From: Fox Date: Sun, 20 Oct 2024 00:07:39 +0200 Subject: [PATCH 3/7] use datagen for apple tree, add biome modifier to let it be placed in the world --- .../forge/biome_modifier/add_apple_tree.json | 6 ++ .../tags/worldgen/biome/has_apple_tree.json | 6 ++ .../configured_feature/apple_tree.json | 91 +++++++++++++++++++ .../placed_feature/apple_tree_placed.json | 6 +- .../GrowthcraftApplesDataGenerators.java | 7 +- .../GrowthcraftApplesLootTables.java | 1 - .../GrowthcraftApplesWorldGenProvider.java | 31 +++++++ .../apples/init/GrowthcraftApplesTags.java | 17 +++- .../growthcraft/apples/shared/Reference.java | 1 + .../GrowthcraftApplesBiomeModifiers.java | 32 +++++++ .../GrowthcraftApplesConfiguredFeatures.java | 12 ++- .../GrowthcraftApplesPlacedFeatures.java | 14 +-- .../world/feature/tree/AppleTreeGrower.java | 2 +- .../configured_feature/apple_tree.json | 52 ----------- 14 files changed, 204 insertions(+), 74 deletions(-) create mode 100644 src/generated/resources/data/growthcraft_apples/forge/biome_modifier/add_apple_tree.json create mode 100644 src/generated/resources/data/growthcraft_apples/tags/worldgen/biome/has_apple_tree.json create mode 100644 src/generated/resources/data/growthcraft_apples/worldgen/configured_feature/apple_tree.json rename src/{main => generated}/resources/data/growthcraft_apples/worldgen/placed_feature/apple_tree_placed.json (92%) create mode 100644 src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesWorldGenProvider.java create mode 100644 src/main/java/growthcraft/apples/world/GrowthcraftApplesBiomeModifiers.java delete mode 100644 src/main/resources/data/growthcraft_apples/worldgen/configured_feature/apple_tree.json diff --git a/src/generated/resources/data/growthcraft_apples/forge/biome_modifier/add_apple_tree.json b/src/generated/resources/data/growthcraft_apples/forge/biome_modifier/add_apple_tree.json new file mode 100644 index 00000000..d500acba --- /dev/null +++ b/src/generated/resources/data/growthcraft_apples/forge/biome_modifier/add_apple_tree.json @@ -0,0 +1,6 @@ +{ + "type": "forge:add_features", + "biomes": "#growthcraft_apples:has_apple_tree", + "features": "growthcraft_apples:apple_tree_placed", + "step": "vegetal_decoration" +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_apples/tags/worldgen/biome/has_apple_tree.json b/src/generated/resources/data/growthcraft_apples/tags/worldgen/biome/has_apple_tree.json new file mode 100644 index 00000000..0b3d11c5 --- /dev/null +++ b/src/generated/resources/data/growthcraft_apples/tags/worldgen/biome/has_apple_tree.json @@ -0,0 +1,6 @@ +{ + "values": [ + "minecraft:forest", + "minecraft:plains" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft_apples/worldgen/configured_feature/apple_tree.json b/src/generated/resources/data/growthcraft_apples/worldgen/configured_feature/apple_tree.json new file mode 100644 index 00000000..7adff5be --- /dev/null +++ b/src/generated/resources/data/growthcraft_apples/worldgen/configured_feature/apple_tree.json @@ -0,0 +1,91 @@ +{ + "type": "minecraft:tree", + "config": { + "decorators": [], + "dirt_provider": { + "type": "minecraft:simple_state_provider", + "state": { + "Name": "minecraft:dirt" + } + }, + "foliage_placer": { + "type": "minecraft:cherry_foliage_placer", + "corner_hole_chance": 0.25, + "hanging_leaves_chance": 0.0, + "hanging_leaves_extension_chance": 0.0, + "height": 5, + "offset": 0, + "radius": 4, + "wide_bottom_layer_hole_chance": 0.25 + }, + "foliage_provider": { + "type": "minecraft:simple_state_provider", + "state": { + "Name": "growthcraft_apples:apple_tree_leaves", + "Properties": { + "distance": "7", + "persistent": "false", + "waterlogged": "false" + } + } + }, + "force_dirt": false, + "ignore_vines": false, + "minimum_size": { + "type": "minecraft:two_layers_feature_size", + "limit": 1, + "lower_size": 0, + "upper_size": 2 + }, + "trunk_placer": { + "type": "minecraft:cherry_trunk_placer", + "base_height": 6, + "branch_count": { + "type": "minecraft:weighted_list", + "distribution": [ + { + "data": 1, + "weight": 1 + }, + { + "data": 2, + "weight": 1 + }, + { + "data": 3, + "weight": 1 + } + ] + }, + "branch_end_offset_from_top": { + "type": "minecraft:uniform", + "value": { + "max_inclusive": 0, + "min_inclusive": -1 + } + }, + "branch_horizontal_length": { + "type": "minecraft:uniform", + "value": { + "max_inclusive": 4, + "min_inclusive": 2 + } + }, + "branch_start_offset_from_top": { + "max_inclusive": -3, + "min_inclusive": -4 + }, + "height_rand_a": 1, + "height_rand_b": 0 + }, + "trunk_provider": { + "type": "minecraft:simple_state_provider", + "state": { + "Name": "growthcraft_apples:apple_wood_log", + "Properties": { + "axis": "y" + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_apples/worldgen/placed_feature/apple_tree_placed.json b/src/generated/resources/data/growthcraft_apples/worldgen/placed_feature/apple_tree_placed.json similarity index 92% rename from src/main/resources/data/growthcraft_apples/worldgen/placed_feature/apple_tree_placed.json rename to src/generated/resources/data/growthcraft_apples/worldgen/placed_feature/apple_tree_placed.json index baa0f553..5ef75870 100644 --- a/src/main/resources/data/growthcraft_apples/worldgen/placed_feature/apple_tree_placed.json +++ b/src/generated/resources/data/growthcraft_apples/worldgen/placed_feature/apple_tree_placed.json @@ -7,11 +7,11 @@ "type": "minecraft:weighted_list", "distribution": [ { - "data": 3, - "weight": 9 + "data": 0, + "weight": 19 }, { - "data": 5, + "data": 1, "weight": 1 } ] diff --git a/src/main/java/growthcraft/apples/datagen/GrowthcraftApplesDataGenerators.java b/src/main/java/growthcraft/apples/datagen/GrowthcraftApplesDataGenerators.java index 28b02f73..bb417a46 100644 --- a/src/main/java/growthcraft/apples/datagen/GrowthcraftApplesDataGenerators.java +++ b/src/main/java/growthcraft/apples/datagen/GrowthcraftApplesDataGenerators.java @@ -1,9 +1,12 @@ package growthcraft.apples.datagen; -import growthcraft.apiary.datagen.GrowthcraftApiaryDataGenerators; +import java.util.concurrent.CompletableFuture; + import growthcraft.apples.datagen.providers.GrowthcraftApplesLootTableProvider; import growthcraft.apples.datagen.providers.GrowthcraftApplesRecipes; +import growthcraft.apples.datagen.providers.GrowthcraftApplesWorldGenProvider; import growthcraft.apples.shared.Reference; +import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; import net.minecraft.data.PackOutput; import net.minecraftforge.data.event.GatherDataEvent; @@ -21,8 +24,10 @@ private GrowthcraftApplesDataGenerators() { public static void gatherData(GatherDataEvent event) { DataGenerator generator = event.getGenerator(); PackOutput packOutput = generator.getPackOutput(); + CompletableFuture lookupProvider = event.getLookupProvider(); generator.addProvider(event.includeServer(), new GrowthcraftApplesRecipes(packOutput)); generator.addProvider(event.includeServer(), new GrowthcraftApplesLootTableProvider(packOutput)); + generator.addProvider(event.includeServer(), new GrowthcraftApplesWorldGenProvider(packOutput, lookupProvider)); } } diff --git a/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesLootTables.java b/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesLootTables.java index 3d9edcf7..2b2424ee 100644 --- a/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesLootTables.java +++ b/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesLootTables.java @@ -6,7 +6,6 @@ import growthcraft.apples.block.AppleTreeLeaves; import growthcraft.apples.init.GrowthcraftApplesBlocks; import growthcraft.apples.shared.Reference; -import growthcraft.core.Growthcraft; import growthcraft.core.block.RopeBlock; import growthcraft.core.init.GrowthcraftItems; import growthcraft.lib.block.GrowthcraftDoorBlock; diff --git a/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesWorldGenProvider.java b/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesWorldGenProvider.java new file mode 100644 index 00000000..c8e1ef56 --- /dev/null +++ b/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesWorldGenProvider.java @@ -0,0 +1,31 @@ +package growthcraft.apples.datagen.providers; + +import java.util.Set; +import java.util.concurrent.CompletableFuture; + +import growthcraft.apples.shared.Reference; +import growthcraft.apples.world.GrowthcraftApplesBiomeModifiers; +import growthcraft.apples.world.GrowthcraftApplesConfiguredFeatures; +import growthcraft.apples.world.GrowthcraftApplesPlacedFeatures; +import net.minecraft.core.HolderLookup.Provider; +import net.minecraft.core.RegistrySetBuilder; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.PackOutput; +import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider; +import net.minecraftforge.registries.ForgeRegistries; + +public class GrowthcraftApplesWorldGenProvider extends DatapackBuiltinEntriesProvider{ + public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder() + .add(Registries.CONFIGURED_FEATURE, GrowthcraftApplesConfiguredFeatures::bootstrap) + .add(Registries.PLACED_FEATURE, GrowthcraftApplesPlacedFeatures::bootstrap) + .add(ForgeRegistries.Keys.BIOME_MODIFIERS, GrowthcraftApplesBiomeModifiers::bootstrap); + + public GrowthcraftApplesWorldGenProvider(PackOutput output, CompletableFuture registries) { + super(output, registries, BUILDER, Set.of(Reference.MODID)); + } + + @Override + public String getName() { + return "Growthcraft Apples WorldGen"; + } +} diff --git a/src/main/java/growthcraft/apples/init/GrowthcraftApplesTags.java b/src/main/java/growthcraft/apples/init/GrowthcraftApplesTags.java index 7a11255f..937917d8 100644 --- a/src/main/java/growthcraft/apples/init/GrowthcraftApplesTags.java +++ b/src/main/java/growthcraft/apples/init/GrowthcraftApplesTags.java @@ -1,18 +1,20 @@ package growthcraft.apples.init; import growthcraft.apples.shared.Reference; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.tags.FluidTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; +import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.material.Fluid; public class GrowthcraftApplesTags { - private GrowthcraftApplesTags() { + private GrowthcraftApplesTags() { /* Prevent generation of public constructor */ } @@ -86,4 +88,17 @@ private static void init() { // return TagKey.create(Registry.ENTITY_TYPE_REGISTRY, new ResourceLocation(Reference.MODID, name)); //} } + + public static class Biomes { + + public static final TagKey HAS_APPLE_TREE = tag(Reference.UnlocalizedName.HAS_APPLE_TREE); + + private static void init() { + // Do nothing, simply instantiate static variables + } + + private static TagKey tag(String name) { + return TagKey.create(Registries.BIOME, new ResourceLocation(Reference.MODID, name)); + } + } } diff --git a/src/main/java/growthcraft/apples/shared/Reference.java b/src/main/java/growthcraft/apples/shared/Reference.java index 62b45273..1a43912b 100644 --- a/src/main/java/growthcraft/apples/shared/Reference.java +++ b/src/main/java/growthcraft/apples/shared/Reference.java @@ -40,6 +40,7 @@ public static class UnlocalizedName { public static final String BEE_BOX_APPLE = "bee_box_apple"; public static final String APPLE_TREE = "apple_tree"; public static final String TAG_APPLE_WOOD_LOG = "apple_wood_logs"; + public static final String HAS_APPLE_TREE = "has_apple_tree"; private UnlocalizedName() { /* Disable Automatic Creation of Public Constructor */ diff --git a/src/main/java/growthcraft/apples/world/GrowthcraftApplesBiomeModifiers.java b/src/main/java/growthcraft/apples/world/GrowthcraftApplesBiomeModifiers.java new file mode 100644 index 00000000..c0a552d2 --- /dev/null +++ b/src/main/java/growthcraft/apples/world/GrowthcraftApplesBiomeModifiers.java @@ -0,0 +1,32 @@ +package growthcraft.apples.world; + +import growthcraft.apples.init.GrowthcraftApplesTags; +import growthcraft.apples.shared.Reference; +import net.minecraft.core.HolderSet; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraftforge.common.world.BiomeModifier; +import net.minecraftforge.common.world.ForgeBiomeModifiers; +import net.minecraftforge.registries.ForgeRegistries; + +public class GrowthcraftApplesBiomeModifiers { + + public static final ResourceKey ADD_APPLE_TREE = registerKey("add_apple_tree"); + + public static void bootstrap(BootstapContext context) { + var placedFeatures = context.lookup(Registries.PLACED_FEATURE); + var biomes = context.lookup(Registries.BIOME); + + context.register(ADD_APPLE_TREE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( + biomes.getOrThrow(GrowthcraftApplesTags.Biomes.HAS_APPLE_TREE), + HolderSet.direct(placedFeatures.getOrThrow(GrowthcraftApplesPlacedFeatures.APPLE_TREE_PLACED_KEY)), + GenerationStep.Decoration.VEGETAL_DECORATION)); + } + + private static ResourceKey registerKey(String name) { + return ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(Reference.MODID, name)); + } +} diff --git a/src/main/java/growthcraft/apples/world/GrowthcraftApplesConfiguredFeatures.java b/src/main/java/growthcraft/apples/world/GrowthcraftApplesConfiguredFeatures.java index abcaf809..434f9a84 100644 --- a/src/main/java/growthcraft/apples/world/GrowthcraftApplesConfiguredFeatures.java +++ b/src/main/java/growthcraft/apples/world/GrowthcraftApplesConfiguredFeatures.java @@ -6,15 +6,19 @@ import net.minecraft.data.worldgen.BootstapContext; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.random.SimpleWeightedRandomList; import net.minecraft.util.valueproviders.ConstantInt; +import net.minecraft.util.valueproviders.IntProvider; +import net.minecraft.util.valueproviders.UniformInt; +import net.minecraft.util.valueproviders.WeightedListInt; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize; -import net.minecraft.world.level.levelgen.feature.foliageplacers.BlobFoliagePlacer; +import net.minecraft.world.level.levelgen.feature.foliageplacers.CherryFoliagePlacer; import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; -import net.minecraft.world.level.levelgen.feature.trunkplacers.StraightTrunkPlacer; +import net.minecraft.world.level.levelgen.feature.trunkplacers.CherryTrunkPlacer; public class GrowthcraftApplesConfiguredFeatures { @@ -25,11 +29,11 @@ public static void bootstrap(BootstapContext> context) { // Trunk block BlockStateProvider.simple(GrowthcraftApplesBlocks.APPLE_WOOD_LOG.get()), // Trunk placer (baseHeight, heightRandA, heightRandB) - new StraightTrunkPlacer(5, 2, 0), + new CherryTrunkPlacer(6, 1, 0, new WeightedListInt(SimpleWeightedRandomList.builder().add(ConstantInt.of(1), 1).add(ConstantInt.of(2), 1).add(ConstantInt.of(3), 1).build()), UniformInt.of(2, 4), UniformInt.of(-4, -3), UniformInt.of(-1, 0)), // Leaves block BlockStateProvider.simple(GrowthcraftApplesBlocks.APPLE_TREE_LEAVES.get()), // Leaves placer (radius, offset, height) - new BlobFoliagePlacer(ConstantInt.of(2), ConstantInt.of(0), 3), + new CherryFoliagePlacer(ConstantInt.of(4), ConstantInt.of(0), ConstantInt.of(5), 0.25F, 0.5F, 0F, 0F), // Spawn Area Saturation (limit, lowerSize, upperSize) new TwoLayersFeatureSize(1, 0, 2)).build() ); diff --git a/src/main/java/growthcraft/apples/world/GrowthcraftApplesPlacedFeatures.java b/src/main/java/growthcraft/apples/world/GrowthcraftApplesPlacedFeatures.java index 35d73d0e..f912741a 100644 --- a/src/main/java/growthcraft/apples/world/GrowthcraftApplesPlacedFeatures.java +++ b/src/main/java/growthcraft/apples/world/GrowthcraftApplesPlacedFeatures.java @@ -1,5 +1,7 @@ package growthcraft.apples.world; +import java.util.List; + import growthcraft.apples.init.GrowthcraftApplesBlocks; import growthcraft.apples.shared.Reference; import net.minecraft.core.Holder; @@ -14,18 +16,15 @@ import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.placement.PlacementModifier; -import java.util.List; - public class GrowthcraftApplesPlacedFeatures { public static final ResourceKey APPLE_TREE_PLACED_KEY = createKey(Reference.UnlocalizedName.APPLE_TREE + "_placed"); - public static void bootstrap(BootstapContext context) { HolderGetter> configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE); register(context, APPLE_TREE_PLACED_KEY, configuredFeatures.getOrThrow(GrowthcraftApplesConfiguredFeatures.APPLE_TREE_KEY), - VegetationPlacements.treePlacement(PlacementUtils.countExtra(3, 0.1f, 2), GrowthcraftApplesBlocks.APPLE_TREE_SAPLING.get())); + VegetationPlacements.treePlacement(PlacementUtils.countExtra(0, 0.05F, 1), GrowthcraftApplesBlocks.APPLE_TREE_SAPLING.get())); } private static ResourceKey createKey(String name) { @@ -36,11 +35,4 @@ private static void register(BootstapContext context, ResourceKey List modifiers) { context.register(key, new PlacedFeature(configuration, List.copyOf(modifiers))); } - - private static void register(BootstapContext context, ResourceKey key, Holder> configuration, - PlacementModifier... modifiers) { - register(context, key, configuration, List.of(modifiers)); - } - - } diff --git a/src/main/java/growthcraft/apples/world/feature/tree/AppleTreeGrower.java b/src/main/java/growthcraft/apples/world/feature/tree/AppleTreeGrower.java index 8edb4696..398f11ab 100644 --- a/src/main/java/growthcraft/apples/world/feature/tree/AppleTreeGrower.java +++ b/src/main/java/growthcraft/apples/world/feature/tree/AppleTreeGrower.java @@ -11,7 +11,7 @@ public class AppleTreeGrower extends AbstractTreeGrower { @Nullable @Override - protected ResourceKey> getConfiguredFeature(RandomSource randomSource, boolean largeHive) { + protected ResourceKey> getConfiguredFeature(RandomSource randomSource, boolean pHasFlowers) { return GrowthcraftApplesConfiguredFeatures.APPLE_TREE_KEY; } } diff --git a/src/main/resources/data/growthcraft_apples/worldgen/configured_feature/apple_tree.json b/src/main/resources/data/growthcraft_apples/worldgen/configured_feature/apple_tree.json deleted file mode 100644 index 62d7b062..00000000 --- a/src/main/resources/data/growthcraft_apples/worldgen/configured_feature/apple_tree.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "type": "minecraft:tree", - "config": { - "decorators": [], - "dirt_provider": { - "type": "minecraft:simple_state_provider", - "state": { - "Name": "minecraft:dirt" - } - }, - "foliage_placer": { - "type": "minecraft:blob_foliage_placer", - "height": 3, - "offset": 0, - "radius": 2 - }, - "foliage_provider": { - "type": "minecraft:simple_state_provider", - "state": { - "Name": "growthcraft_apples:apple_tree_leaves", - "Properties": { - "distance": "7", - "persistent": "false", - "waterlogged": "false" - } - } - }, - "force_dirt": false, - "ignore_vines": false, - "minimum_size": { - "type": "minecraft:two_layers_feature_size", - "limit": 1, - "lower_size": 0, - "upper_size": 2 - }, - "trunk_placer": { - "type": "minecraft:straight_trunk_placer", - "base_height": 5, - "height_rand_a": 2, - "height_rand_b": 0 - }, - "trunk_provider": { - "type": "minecraft:simple_state_provider", - "state": { - "Name": "growthcraft_apples:apple_wood_log", - "Properties": { - "axis": "y" - } - } - } - } -} \ No newline at end of file From 56d6db4b0ec30ba51116693e27b2ee3aebbf0874 Mon Sep 17 00:00:00 2001 From: Fox Date: Sun, 20 Oct 2024 00:08:50 +0200 Subject: [PATCH 4/7] add new blocks to tags, added biome tags to control, where our trees can be placed --- .../data/minecraft/tags/blocks/leaves.json | 3 +- .../data/minecraft/tags/blocks/logs.json | 6 +++- .../minecraft/tags/blocks/mineable/axe.json | 2 +- .../GrowthcraftCoreDataGenerators.java | 4 ++- .../GrowthcraftCoreBiomeTagsProvider.java | 30 +++++++++++++++++++ .../providers/GrowthcraftCoreBlockTags.java | 9 ++++-- 6 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreBiomeTagsProvider.java diff --git a/src/generated/resources/data/minecraft/tags/blocks/leaves.json b/src/generated/resources/data/minecraft/tags/blocks/leaves.json index d7eb08f1..200b854f 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/leaves.json +++ b/src/generated/resources/data/minecraft/tags/blocks/leaves.json @@ -1,5 +1,6 @@ { "values": [ - "growthcraft_apples:apple_tree_leaves" + "growthcraft_apples:apple_tree_leaves", + "growthcraft_cellar:cork_tree_leaves" ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/blocks/logs.json b/src/generated/resources/data/minecraft/tags/blocks/logs.json index 4a37bc8b..fcf88961 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/logs.json +++ b/src/generated/resources/data/minecraft/tags/blocks/logs.json @@ -3,6 +3,10 @@ "growthcraft_apples:apple_wood_log", "growthcraft_apples:apple_wood_log_stripped", "growthcraft_apples:apple_wood", - "growthcraft_apples:apple_wood_stripped" + "growthcraft_apples:apple_wood_stripped", + "growthcraft_cellar:cork_wood_log", + "growthcraft_cellar:cork_wood_log_stripped", + "growthcraft_cellar:cork_wood", + "growthcraft_cellar:cork_wood_stripped" ] } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json index 2a1911f8..879ec692 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json @@ -31,8 +31,8 @@ "growthcraft_bamboo:bamboo_post_horizontal", "growthcraft_milk:churn", "growthcraft_milk:hanging_sign_1_oak", - "growthcraft_milk:hanging_sign_2_oak", "growthcraft_milk:hanging_sign_2_spruce", + "growthcraft_milk:hanging_sign_2_oak", "growthcraft_milk:hanging_sign_1_spruce" ] } \ No newline at end of file diff --git a/src/main/java/growthcraft/core/datagen/GrowthcraftCoreDataGenerators.java b/src/main/java/growthcraft/core/datagen/GrowthcraftCoreDataGenerators.java index 45669eb0..3ded963d 100644 --- a/src/main/java/growthcraft/core/datagen/GrowthcraftCoreDataGenerators.java +++ b/src/main/java/growthcraft/core/datagen/GrowthcraftCoreDataGenerators.java @@ -2,6 +2,7 @@ import java.util.concurrent.CompletableFuture; +import growthcraft.core.datagen.providers.GrowthcraftCoreBiomeTagsProvider; import growthcraft.core.datagen.providers.GrowthcraftCoreBlockTags; import growthcraft.core.datagen.providers.GrowthcraftCoreGlobalLootModifiersProvider; import growthcraft.core.datagen.providers.GrowthcraftCoreItemTags; @@ -32,11 +33,12 @@ public static void gatherData(GatherDataEvent event) { GrowthcraftCoreBlockTags blockTags = new GrowthcraftCoreBlockTags(packOutput, lookupProvider, existingFileHelper); generator.addProvider(event.includeServer(), blockTags); - generator.addProvider(event.includeServer(), new GrowthcraftCoreItemTags(packOutput, lookupProvider, blockTags, existingFileHelper)); + generator.addProvider(event.includeServer(), new GrowthcraftCoreItemTags(packOutput, lookupProvider, blockTags, existingFileHelper)); generator.addProvider(event.includeServer(), new GrowthcraftCoreRecipes(packOutput)); generator.addProvider(event.includeServer(), new GrowthcraftCoreLootTableProvider(packOutput)); generator.addProvider(event.includeServer(), new GrowthcraftCoreGlobalLootModifiersProvider(packOutput)); generator.addProvider(event.includeServer(), new GrowthcraftCoreWorldGenProvider(packOutput, lookupProvider)); + generator.addProvider(event.includeServer(), new GrowthcraftCoreBiomeTagsProvider(packOutput, lookupProvider, existingFileHelper)); // generator.addProvider(event.includeServer(), new LootTableProvider(packOutput, Collections.emptySet(), // List.of(new LootTableProvider.SubProviderEntry(GrowthcraftCoreLootTables::new, LootContextParamSets.BLOCK)))); } diff --git a/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreBiomeTagsProvider.java b/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreBiomeTagsProvider.java new file mode 100644 index 00000000..67b0d5c5 --- /dev/null +++ b/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreBiomeTagsProvider.java @@ -0,0 +1,30 @@ +package growthcraft.core.datagen.providers; + +import java.util.concurrent.CompletableFuture; + +import javax.annotation.Nullable; + +import growthcraft.apples.init.GrowthcraftApplesTags; +import growthcraft.cellar.init.GrowthcraftCellarTags; +import growthcraft.cellar.shared.Reference; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.HolderLookup.Provider; +import net.minecraft.data.PackOutput; +import net.minecraft.data.tags.BiomeTagsProvider; +import net.minecraft.world.level.biome.Biomes; +import net.minecraftforge.common.data.ExistingFileHelper; + +public class GrowthcraftCoreBiomeTagsProvider extends BiomeTagsProvider{ + + public GrowthcraftCoreBiomeTagsProvider(PackOutput output, CompletableFuture completableFuture, @Nullable ExistingFileHelper existingFileHelper) { + super(output, completableFuture, Reference.MODID, existingFileHelper); + } + + @Override + protected void addTags(HolderLookup.Provider provider) { + tag(GrowthcraftCellarTags.Biomes.HAS_CORK_TREE).add(Biomes.DARK_FOREST); + tag(GrowthcraftCellarTags.Biomes.HAS_CORK_TREE).add(Biomes.MEADOW); + tag(GrowthcraftApplesTags.Biomes.HAS_APPLE_TREE).add(Biomes.FOREST); + tag(GrowthcraftApplesTags.Biomes.HAS_APPLE_TREE).add(Biomes.PLAINS); + } +} diff --git a/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreBlockTags.java b/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreBlockTags.java index c848fe70..fca31e46 100644 --- a/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreBlockTags.java +++ b/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreBlockTags.java @@ -93,7 +93,11 @@ protected void addTags(HolderLookup.Provider provider) { .add(GrowthcraftApplesBlocks.APPLE_WOOD_LOG.get()) .add(GrowthcraftApplesBlocks.APPLE_WOOD_LOG_STRIPPED.get()) .add(GrowthcraftApplesBlocks.APPLE_WOOD.get()) - .add(GrowthcraftApplesBlocks.APPLE_WOOD_STRIPPED.get()); + .add(GrowthcraftApplesBlocks.APPLE_WOOD_STRIPPED.get()) + .add(GrowthcraftCellarBlocks.CORK_WOOD_LOG.get()) + .add(GrowthcraftCellarBlocks.CORK_WOOD_LOG_STRIPPED.get()) + .add(GrowthcraftCellarBlocks.CORK_WOOD.get()) + .add(GrowthcraftCellarBlocks.CORK_WOOD_STRIPPED.get()); tag(BlockTags.WOODEN_STAIRS) .add(GrowthcraftApplesBlocks.APPLE_PLANK_STAIRS.get()); tag(BlockTags.WOODEN_FENCES) @@ -105,7 +109,8 @@ protected void addTags(HolderLookup.Provider provider) { tag(BlockTags.WOODEN_TRAPDOORS) .add(GrowthcraftApplesBlocks.APPLE_PLANK_TRAPDOOR.get()); tag(BlockTags.LEAVES) - .add(GrowthcraftApplesBlocks.APPLE_TREE_LEAVES.get()); + .add(GrowthcraftApplesBlocks.APPLE_TREE_LEAVES.get()) + .add(GrowthcraftCellarBlocks.CORK_TREE_LEAVES.get()); tag(BlockTags.MINEABLE_WITH_AXE) .add(GrowthcraftCellarBlocks.FERMENTATION_BARREL_OAK.get()) .add(GrowthcraftBlocks.ROPE_LINEN_ACACIA_FENCE.get()) From 387ff805fc88c3dfec14eb87582e1a0eb772714d Mon Sep 17 00:00:00 2001 From: Fox Date: Sun, 20 Oct 2024 14:40:57 +0200 Subject: [PATCH 5/7] code quality improvements --- .../apples/init/GrowthcraftApplesTags.java | 9 +++++++-- .../world/GrowthcraftApplesBiomeModifiers.java | 4 ++++ .../world/GrowthcraftApplesConfiguredFeatures.java | 4 ++++ .../world/GrowthcraftApplesPlacedFeatures.java | 4 ++++ .../cellar/init/GrowthcraftCellarTags.java | 14 +++++++++----- .../world/GrowthcraftCellarBiomeModifiers.java | 4 ++++ .../world/GrowthcraftCellarConfiguredFeatures.java | 8 ++++++-- .../world/GrowthcraftCellarPlacedFeatures.java | 4 ++++ 8 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/main/java/growthcraft/apples/init/GrowthcraftApplesTags.java b/src/main/java/growthcraft/apples/init/GrowthcraftApplesTags.java index 937917d8..598cd340 100644 --- a/src/main/java/growthcraft/apples/init/GrowthcraftApplesTags.java +++ b/src/main/java/growthcraft/apples/init/GrowthcraftApplesTags.java @@ -23,6 +23,7 @@ public static void init() { Items.init(); Fluids.init(); EntityTypes.init(); + Biomes.init(); } public static class Blocks { @@ -65,7 +66,7 @@ private Fluids() { /* Prevent generation of public constructor */ } - private static void init() { + public static void init() { // Do nothing, simply instantiate static variables } @@ -91,9 +92,13 @@ private static void init() { public static class Biomes { + private Biomes() { + /* Prevent generation of public constructor */ + } + public static final TagKey HAS_APPLE_TREE = tag(Reference.UnlocalizedName.HAS_APPLE_TREE); - private static void init() { + public static void init() { // Do nothing, simply instantiate static variables } diff --git a/src/main/java/growthcraft/apples/world/GrowthcraftApplesBiomeModifiers.java b/src/main/java/growthcraft/apples/world/GrowthcraftApplesBiomeModifiers.java index c0a552d2..65b4ffe6 100644 --- a/src/main/java/growthcraft/apples/world/GrowthcraftApplesBiomeModifiers.java +++ b/src/main/java/growthcraft/apples/world/GrowthcraftApplesBiomeModifiers.java @@ -14,6 +14,10 @@ public class GrowthcraftApplesBiomeModifiers { + private GrowthcraftApplesBiomeModifiers() { + /* Prevent generation of public constructor */ + } + public static final ResourceKey ADD_APPLE_TREE = registerKey("add_apple_tree"); public static void bootstrap(BootstapContext context) { diff --git a/src/main/java/growthcraft/apples/world/GrowthcraftApplesConfiguredFeatures.java b/src/main/java/growthcraft/apples/world/GrowthcraftApplesConfiguredFeatures.java index 434f9a84..3e559141 100644 --- a/src/main/java/growthcraft/apples/world/GrowthcraftApplesConfiguredFeatures.java +++ b/src/main/java/growthcraft/apples/world/GrowthcraftApplesConfiguredFeatures.java @@ -21,6 +21,10 @@ import net.minecraft.world.level.levelgen.feature.trunkplacers.CherryTrunkPlacer; public class GrowthcraftApplesConfiguredFeatures { + + private GrowthcraftApplesConfiguredFeatures() { + /* Prevent generation of public constructor */ + } public static final ResourceKey> APPLE_TREE_KEY = registerKey(Reference.UnlocalizedName.APPLE_TREE); diff --git a/src/main/java/growthcraft/apples/world/GrowthcraftApplesPlacedFeatures.java b/src/main/java/growthcraft/apples/world/GrowthcraftApplesPlacedFeatures.java index f912741a..05718010 100644 --- a/src/main/java/growthcraft/apples/world/GrowthcraftApplesPlacedFeatures.java +++ b/src/main/java/growthcraft/apples/world/GrowthcraftApplesPlacedFeatures.java @@ -17,6 +17,10 @@ import net.minecraft.world.level.levelgen.placement.PlacementModifier; public class GrowthcraftApplesPlacedFeatures { + + private GrowthcraftApplesPlacedFeatures() { + /* Prevent generation of public constructor */ + } public static final ResourceKey APPLE_TREE_PLACED_KEY = createKey(Reference.UnlocalizedName.APPLE_TREE + "_placed"); diff --git a/src/main/java/growthcraft/cellar/init/GrowthcraftCellarTags.java b/src/main/java/growthcraft/cellar/init/GrowthcraftCellarTags.java index f4448d90..4436bab0 100644 --- a/src/main/java/growthcraft/cellar/init/GrowthcraftCellarTags.java +++ b/src/main/java/growthcraft/cellar/init/GrowthcraftCellarTags.java @@ -16,11 +16,11 @@ public class GrowthcraftCellarTags { public static void init() { - GrowthcraftCellarTags.Blocks.init(); - GrowthcraftCellarTags.Items.init(); - GrowthcraftCellarTags.Fluids.init(); - GrowthcraftCellarTags.EntityTypes.init(); - GrowthcraftCellarTags.Biomes.init(); + Blocks.init(); + Items.init(); + Fluids.init(); + EntityTypes.init(); + Biomes.init(); } public static class Blocks { @@ -82,6 +82,10 @@ private static void init() { public static class Biomes { + private Biomes() { + /* Prevent generation of public constructor */ + } + public static final TagKey HAS_CORK_TREE = tag(Reference.UnlocalizedName.HAS_CORK_TREE); private static void init() { diff --git a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarBiomeModifiers.java b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarBiomeModifiers.java index 520e1083..03a3ad41 100644 --- a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarBiomeModifiers.java +++ b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarBiomeModifiers.java @@ -14,6 +14,10 @@ public class GrowthcraftCellarBiomeModifiers { + private GrowthcraftCellarBiomeModifiers() { + /* Prevent generation of public constructor */ + } + public static final ResourceKey ADD_CORK_TREE = registerKey("add_cork_tree"); public static void bootstrap(BootstapContext context) { diff --git a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java index e146dd38..6512db9f 100644 --- a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java +++ b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java @@ -21,6 +21,10 @@ public class GrowthcraftCellarConfiguredFeatures { public static final ResourceKey> CORK_TREE_KEY = registerKey(Reference.UnlocalizedName.CORK_TREE); + private GrowthcraftCellarConfiguredFeatures() { + /* Prevent generation of public constructor */ + } + public static void bootstrap(BootstapContext> context) { register(context, CORK_TREE_KEY, Feature.TREE, new TreeConfiguration.TreeConfigurationBuilder( // Trunk block @@ -40,11 +44,11 @@ public static void bootstrap(BootstapContext> context) { return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(Reference.MODID, name)); } - private static > void register( + private static > void register( BootstapContext> context, ResourceKey> key, FeatureType feature, - FeatureConfig configuration + FEATURECONFIG configuration ) { context.register(key, new ConfiguredFeature<>(feature, configuration)); } diff --git a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarPlacedFeatures.java b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarPlacedFeatures.java index 9fab1425..1da5899b 100644 --- a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarPlacedFeatures.java +++ b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarPlacedFeatures.java @@ -18,6 +18,10 @@ public class GrowthcraftCellarPlacedFeatures { + private GrowthcraftCellarPlacedFeatures() { + /* Prevent generation of public constructor */ + } + public static final ResourceKey CORK_TREE_PLACED_KEY = createKey(Reference.UnlocalizedName.CORK_TREE + "_placed"); public static void bootstrap(BootstapContext context) { From 57a083a384ed26236fd14c60cbeb9f2de0134a07 Mon Sep 17 00:00:00 2001 From: Fox Date: Sun, 20 Oct 2024 15:16:42 +0200 Subject: [PATCH 6/7] make logs strippable --- .../lib/block/GrowthcraftLogBlock.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/growthcraft/lib/block/GrowthcraftLogBlock.java b/src/main/java/growthcraft/lib/block/GrowthcraftLogBlock.java index b9f3eb42..2c7975e0 100644 --- a/src/main/java/growthcraft/lib/block/GrowthcraftLogBlock.java +++ b/src/main/java/growthcraft/lib/block/GrowthcraftLogBlock.java @@ -1,13 +1,20 @@ package growthcraft.lib.block; +import org.jetbrains.annotations.Nullable; + +import growthcraft.apples.init.GrowthcraftApplesBlocks; +import growthcraft.cellar.init.GrowthcraftCellarBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.item.AxeItem; +import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.ToolAction; public class GrowthcraftLogBlock extends RotatedPillarBlock { public GrowthcraftLogBlock() { @@ -39,5 +46,26 @@ public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Di public int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, Direction direction) { return 5; } + + //since vanilla uses a proteced map, to specify the which logs turn into which stripped version, this is the best way i found. + //we could also do sub classes or our own map to match logs&stripped logs, but for 4 blocks, this should be enough + @Override + public @Nullable BlockState getToolModifiedState(BlockState state, UseOnContext context, ToolAction toolAction, boolean simulate) { + if (context.getItemInHand().getItem() instanceof AxeItem) { + if(state.is(GrowthcraftApplesBlocks.APPLE_WOOD_LOG.get())) { + return GrowthcraftApplesBlocks.APPLE_WOOD_LOG_STRIPPED.get().defaultBlockState().setValue(AXIS, state.getValue(AXIS)); + } + if(state.is(GrowthcraftApplesBlocks.APPLE_WOOD.get())) { + return GrowthcraftApplesBlocks.APPLE_WOOD_STRIPPED.get().defaultBlockState().setValue(AXIS, state.getValue(AXIS)); + } + if(state.is(GrowthcraftCellarBlocks.CORK_WOOD_LOG.get())) { + return GrowthcraftCellarBlocks.CORK_WOOD_LOG_STRIPPED.get().defaultBlockState().setValue(AXIS, state.getValue(AXIS)); + } + if(state.is(GrowthcraftCellarBlocks.CORK_WOOD.get())) { + return GrowthcraftCellarBlocks.CORK_WOOD_STRIPPED.get().defaultBlockState().setValue(AXIS, state.getValue(AXIS)); + } + } + return super.getToolModifiedState(state, context, toolAction, simulate); + } } From 09370a2467b190239d57884d2d40fec5bdcbb9a2 Mon Sep 17 00:00:00 2001 From: Fox Date: Sun, 20 Oct 2024 15:20:00 +0200 Subject: [PATCH 7/7] fix generic name --- .../cellar/world/GrowthcraftCellarConfiguredFeatures.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java index 6512db9f..57c9abf5 100644 --- a/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java +++ b/src/main/java/growthcraft/cellar/world/GrowthcraftCellarConfiguredFeatures.java @@ -44,11 +44,11 @@ public static void bootstrap(BootstapContext> context) { return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(Reference.MODID, name)); } - private static > void register( + private static > void register( BootstapContext> context, ResourceKey> key, - FeatureType feature, - FEATURECONFIG configuration + F feature, + FC configuration ) { context.register(key, new ConfiguredFeature<>(feature, configuration)); }