From 363dea0e35c213f22a6070226dd08b4e79ed2ebc Mon Sep 17 00:00:00 2001 From: MoonFather Date: Mon, 21 Oct 2024 14:19:58 +0100 Subject: [PATCH] main part --- .../loot_modifiers/global_loot_modifiers.json | 3 +- .../bee_from_vanilla_bee_nest.json | 4 + .../grape_seeds_purple_from_grass.json | 8 +- .../grape_seeds_red_from_grass.json | 8 +- .../grape_seeds_white_from_grass.json | 8 +- ..._grass.json => hops_seeds_from_grass.json} | 6 +- .../loot_modifiers/rice_from_grass.json | 19 +- .../loot_modifiers/rice_from_grass_wet.json | 38 ++++ .../thistle_seeds_from_grass.json | 12 +- .../yeast_bayanus_from_grass.json | 6 +- .../yeast_brewers_from_grass.json | 6 +- .../yeast_ethereal_from_chorus_flower.json | 6 +- .../loot_modifiers/yeast_lager_from_snow.json | 6 +- .../deepslate_salt_ore_placed.json | 2 +- .../placed_feature/end_salt_ore_placed.json | 2 +- .../nether_salt_ore_placed.json | 2 +- .../recipes/decorations/bee_box_bamboo.json | 5 + .../recipes/bee_box_acacia.json | 6 + .../recipes/bee_box_bamboo.json | 8 +- .../recipes/bee_box_birch.json | 6 + .../recipes/bee_box_cherry.json | 6 + .../recipes/bee_box_crimson.json | 6 + .../recipes/bee_box_dark_oak.json | 6 + .../recipes/bee_box_jungle.json | 6 + .../recipes/bee_box_mangrove.json | 6 + .../recipes/bee_box_oak.json | 6 + .../recipes/bee_box_spruce.json | 6 + .../recipes/bee_box_warped.json | 6 + .../recipes/bees_wax_black.json | 6 + .../recipes/bees_wax_blue.json | 6 + .../recipes/bees_wax_brown.json | 6 + .../recipes/bees_wax_cyan.json | 6 + .../recipes/bees_wax_gray.json | 6 + .../recipes/bees_wax_green.json | 6 + .../recipes/bees_wax_light_blue.json | 6 + .../recipes/bees_wax_light_gray.json | 6 + .../recipes/bees_wax_lime.json | 6 + .../recipes/bees_wax_magenta.json | 6 + .../recipes/bees_wax_orange.json | 6 + .../recipes/bees_wax_pink.json | 6 + .../recipes/bees_wax_purple.json | 6 + .../recipes/bees_wax_red.json | 6 + .../recipes/bees_wax_white.json | 6 + .../recipes/bees_wax_yellow.json | 6 + .../recipes/apple_seeds.json | 6 + .../recipes/chicken_rice.json | 6 + .../growthcraft_rice/recipes/cultivator.json | 6 + .../immersiveengineering/cloche/rice.json | 10 ++ .../data/growthcraft_rice/recipes/knife.json | 6 + .../mekanism/crushing/biofuel/rice_stalk.json | 4 + .../growthcraft_rice/recipes/onigiri.json | 6 + .../data/growthcraft_rice/recipes/rice.json | 1 + .../growthcraft_rice/recipes/rice_grains.json | 1 + .../growthcraft_rice/recipes/sushi_roll.json | 6 + .../{food => building_blocks}/packed_mud.json | 0 .../data/minecraft/recipes/black_candle.json | 6 + .../data/minecraft/recipes/blue_candle.json | 6 + .../data/minecraft/recipes/brown_candle.json | 6 + .../data/minecraft/recipes/candle.json | 6 + .../data/minecraft/recipes/cyan_candle.json | 6 + .../data/minecraft/recipes/gray_candle.json | 6 + .../data/minecraft/recipes/green_candle.json | 6 + .../minecraft/recipes/light_blue_candle.json | 6 + .../minecraft/recipes/light_gray_candle.json | 6 + .../data/minecraft/recipes/lime_candle.json | 6 + .../minecraft/recipes/magenta_candle.json | 6 + .../data/minecraft/recipes/orange_candle.json | 6 + .../data/minecraft/recipes/packed_mud.json | 8 +- .../data/minecraft/recipes/pink_candle.json | 6 + .../data/minecraft/recipes/purple_candle.json | 6 + .../data/minecraft/recipes/red_candle.json | 6 + .../data/minecraft/recipes/white_candle.json | 6 + .../data/minecraft/recipes/yellow_candle.json | 6 + .../growthcraft/apiary/GrowthcraftApiary.java | 6 +- ...raftApiaryGlobalLootModifiersProvider.java | 26 --- .../providers/GrowthcraftApiaryRecipes.java | 55 +++--- .../apiary/init/GrowthcraftApiaryItems.java | 15 +- .../init/config/GrowthcraftApiaryConfig.java | 46 ++++- .../growthcraft/apples/GrowthcraftApples.java | 6 +- .../providers/GrowthcraftApplesRecipes.java | 15 +- .../apples/init/GrowthcraftApplesItems.java | 10 +- .../init/config/GrowthcraftApplesConfig.java | 22 ++- .../init/config/GrowthcraftCellarConfig.java | 22 ++- .../java/growthcraft/core/Growthcraft.java | 25 ++- ...hcraftCoreGlobalLootModifiersProvider.java | 120 +++++++++---- .../datagen/shared/BiomeTagLootCondition.java | 88 +++++++++ .../shared/GrowthcraftRecipeBuilder.java | 113 ++++++++++++ .../shared/ModuleLoadedLootCondition.java | 65 +++++++ .../init/GrowthcraftCreativeModeTabs.java | 2 +- .../core/init/GrowthcraftItems.java | 12 +- .../core/init/GrowthcraftLootModifiers.java | 4 + .../BooleanFromConfigFileCondition.java | 103 +++++++++++ .../core/init/config/GrowthcraftConfig.java | 6 + .../init/config/OptionalFeatureCondition.java | 104 +++++++++++ .../growthcraft/lib/loot/AddItemModifier.java | 30 ++-- .../lib/loot/AddItemReplaceSeedsModifier.java | 45 +++++ .../loot/WeightedSeedReplacementModifier.java | 62 +++++++ .../growthcraft/rice/GrowthcraftRice.java | 4 +- ...hcraftRiceGlobalLootModifiersProvider.java | 26 --- .../providers/GrowthcraftRiceRecipes.java | 169 ++++++++++-------- .../rice/init/GrowthcraftRiceItems.java | 35 ++-- .../init/config/GrowthcraftRiceConfig.java | 32 +++- ...brew_kettle_mead_must_honey_comb_full.json | 8 +- ...e_mead_must_vanilla_honeycomb_no_must.json | 37 ++++ ...e_mead_must_vanilla_honeycomb_normal.json} | 8 +- .../recipes/brew_kettle_wax_item.json | 8 +- .../fermentation_barrel_honey_mead.json | 8 +- .../mystical_agriculture_bee.json | 4 + .../mystical_agriculture_apple_log.json | 4 + ...ttle_rice_water_from_growthcraft_rice.json | 15 +- ..._starter_yeast_seishu_from_rice_water.json | 8 +- ...ture_jar_yeast_seishu_from_rice_water.json | 8 +- .../fermentation_barrel_rice_wine.json | 8 +- .../recipes/fermentation_barrel_sake.json | 8 +- .../mystical_agriculture_rice.json | 4 + 115 files changed, 1538 insertions(+), 325 deletions(-) rename src/generated/resources/data/growthcraft/loot_modifiers/{hops_seeds_white_from_grass.json => hops_seeds_from_grass.json} (68%) create mode 100644 src/generated/resources/data/growthcraft/loot_modifiers/rice_from_grass_wet.json rename src/generated/resources/data/minecraft/advancements/recipes/{food => building_blocks}/packed_mud.json (100%) delete mode 100644 src/main/java/growthcraft/apiary/datagen/providers/GrowthcraftApiaryGlobalLootModifiersProvider.java create mode 100644 src/main/java/growthcraft/core/datagen/shared/BiomeTagLootCondition.java create mode 100644 src/main/java/growthcraft/core/datagen/shared/GrowthcraftRecipeBuilder.java create mode 100644 src/main/java/growthcraft/core/datagen/shared/ModuleLoadedLootCondition.java create mode 100644 src/main/java/growthcraft/core/init/config/BooleanFromConfigFileCondition.java create mode 100644 src/main/java/growthcraft/core/init/config/OptionalFeatureCondition.java create mode 100644 src/main/java/growthcraft/lib/loot/AddItemReplaceSeedsModifier.java create mode 100644 src/main/java/growthcraft/lib/loot/WeightedSeedReplacementModifier.java delete mode 100644 src/main/java/growthcraft/rice/datagen/providers/GrowthcraftRiceGlobalLootModifiersProvider.java create mode 100644 src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb_no_must.json rename src/main/resources/data/growthcraft_apiary/recipes/{brew_kettle_mead_must_vanilla_honeycomb.json => brew_kettle_mead_must_vanilla_honeycomb_normal.json} (80%) diff --git a/src/generated/resources/data/forge/loot_modifiers/global_loot_modifiers.json b/src/generated/resources/data/forge/loot_modifiers/global_loot_modifiers.json index cfd7143c..12566348 100644 --- a/src/generated/resources/data/forge/loot_modifiers/global_loot_modifiers.json +++ b/src/generated/resources/data/forge/loot_modifiers/global_loot_modifiers.json @@ -2,16 +2,17 @@ "entries": [ "growthcraft:thistle_seeds_from_grass", "growthcraft:add_loot_village", - "growthcraft:hops_seeds_white_from_grass", "growthcraft:add_loot_buried_treasure", "growthcraft:yeast_bayanus_from_grass", "growthcraft:add_loot_pillager_outpost", "growthcraft:add_loot_shipwreck", "growthcraft:bee_from_vanilla_bee_nest", "growthcraft:grape_seeds_red_from_grass", + "growthcraft:rice_from_grass_wet", "growthcraft:yeast_lager_from_snow", "growthcraft:add_loot_woodland_mansion", "growthcraft:grape_seeds_white_from_grass", + "growthcraft:hops_seeds_from_grass", "growthcraft:add_loot_stronghold", "growthcraft:grape_seeds_purple_from_grass", "growthcraft:yeast_brewers_from_grass", diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/bee_from_vanilla_bee_nest.json b/src/generated/resources/data/growthcraft/loot_modifiers/bee_from_vanilla_bee_nest.json index b40f1452..1c45be9b 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/bee_from_vanilla_bee_nest.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/bee_from_vanilla_bee_nest.json @@ -8,6 +8,10 @@ { "block": "minecraft:bee_nest", "condition": "minecraft:block_state_property" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "apiary" } ], "item": "growthcraft_apiary:bee" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_purple_from_grass.json b/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_purple_from_grass.json index fca75621..2114614e 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_purple_from_grass.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_purple_from_grass.json @@ -1,13 +1,17 @@ { - "type": "growthcraft:add_item", + "type": "growthcraft:add_item_replacing_seeds", "conditions": [ { - "chance": 0.2, + "chance": 0.1, "condition": "minecraft:random_chance" }, { "block": "minecraft:grass", "condition": "minecraft:block_state_property" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "grapes" } ], "item": "growthcraft_cellar:grape_seeds_purple" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_red_from_grass.json b/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_red_from_grass.json index 0a402353..2e828b29 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_red_from_grass.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_red_from_grass.json @@ -1,13 +1,17 @@ { - "type": "growthcraft:add_item", + "type": "growthcraft:add_item_replacing_seeds", "conditions": [ { - "chance": 0.2, + "chance": 0.1, "condition": "minecraft:random_chance" }, { "block": "minecraft:grass", "condition": "minecraft:block_state_property" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "grapes" } ], "item": "growthcraft_cellar:grape_seeds_red" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_white_from_grass.json b/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_white_from_grass.json index 3e4f712d..a2b74fc9 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_white_from_grass.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/grape_seeds_white_from_grass.json @@ -1,13 +1,17 @@ { - "type": "growthcraft:add_item", + "type": "growthcraft:add_item_replacing_seeds", "conditions": [ { - "chance": 0.2, + "chance": 0.1, "condition": "minecraft:random_chance" }, { "block": "minecraft:grass", "condition": "minecraft:block_state_property" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "grapes" } ], "item": "growthcraft_cellar:grape_seeds_white" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/hops_seeds_white_from_grass.json b/src/generated/resources/data/growthcraft/loot_modifiers/hops_seeds_from_grass.json similarity index 68% rename from src/generated/resources/data/growthcraft/loot_modifiers/hops_seeds_white_from_grass.json rename to src/generated/resources/data/growthcraft/loot_modifiers/hops_seeds_from_grass.json index 65bc135d..afb6dff9 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/hops_seeds_white_from_grass.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/hops_seeds_from_grass.json @@ -2,12 +2,16 @@ "type": "growthcraft:add_item", "conditions": [ { - "chance": 0.2, + "chance": 0.07, "condition": "minecraft:random_chance" }, { "block": "minecraft:grass", "condition": "minecraft:block_state_property" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "cellar" } ], "item": "growthcraft_cellar:hops_seeds" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/rice_from_grass.json b/src/generated/resources/data/growthcraft/loot_modifiers/rice_from_grass.json index a60d4eea..9ec9ea1d 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/rice_from_grass.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/rice_from_grass.json @@ -2,12 +2,25 @@ "type": "growthcraft:add_item", "conditions": [ { - "chance": 0.2, + "chance": 0.005, "condition": "minecraft:random_chance" }, { - "block": "minecraft:grass", - "condition": "minecraft:block_state_property" + "condition": "minecraft:any_of", + "terms": [ + { + "block": "minecraft:grass", + "condition": "minecraft:block_state_property" + }, + { + "block": "minecraft:tall_grass", + "condition": "minecraft:block_state_property" + } + ] + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "rice" } ], "item": "growthcraft_rice:rice_grains" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/rice_from_grass_wet.json b/src/generated/resources/data/growthcraft/loot_modifiers/rice_from_grass_wet.json new file mode 100644 index 00000000..00fb3b3f --- /dev/null +++ b/src/generated/resources/data/growthcraft/loot_modifiers/rice_from_grass_wet.json @@ -0,0 +1,38 @@ +{ + "type": "growthcraft:weighted_seed_replacer", + "conditions": [ + { + "condition": "minecraft:any_of", + "terms": [ + { + "block": "minecraft:grass", + "condition": "minecraft:block_state_property" + }, + { + "block": "minecraft:tall_grass", + "condition": "minecraft:block_state_property" + } + ] + }, + { + "condition": "minecraft:any_of", + "terms": [ + { + "biome_tag": "forge:is_swamp", + "condition": "growthcraft:biome_loot_check" + }, + { + "biome_tag": "minecraft:is_river", + "condition": "growthcraft:biome_loot_check" + } + ] + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "rice" + } + ], + "item": "growthcraft_rice:rice_grains", + "percent_to_replace": 30, + "percent_to_void": 55 +} \ No newline at end of file diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/thistle_seeds_from_grass.json b/src/generated/resources/data/growthcraft/loot_modifiers/thistle_seeds_from_grass.json index 3edd8e72..b403a2a6 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/thistle_seeds_from_grass.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/thistle_seeds_from_grass.json @@ -1,13 +1,21 @@ { - "type": "growthcraft:add_item", + "type": "growthcraft:add_item_replacing_seeds", "conditions": [ { - "chance": 0.2, + "chance": 0.15, "condition": "minecraft:random_chance" }, { "block": "minecraft:grass", "condition": "minecraft:block_state_property" + }, + { + "biome_tag": "forge:is_cold/overworld", + "condition": "growthcraft:biome_loot_check" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "milk" } ], "item": "growthcraft_milk:thistle_seed" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/yeast_bayanus_from_grass.json b/src/generated/resources/data/growthcraft/loot_modifiers/yeast_bayanus_from_grass.json index 6a74823f..fa651e92 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/yeast_bayanus_from_grass.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/yeast_bayanus_from_grass.json @@ -1,5 +1,5 @@ { - "type": "growthcraft:add_item", + "type": "growthcraft:add_item_replacing_seeds", "conditions": [ { "chance": 0.1, @@ -8,6 +8,10 @@ { "block": "minecraft:grass", "condition": "minecraft:block_state_property" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "cellar" } ], "item": "growthcraft_cellar:yeast_bayanus" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/yeast_brewers_from_grass.json b/src/generated/resources/data/growthcraft/loot_modifiers/yeast_brewers_from_grass.json index 2fb5625d..85783034 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/yeast_brewers_from_grass.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/yeast_brewers_from_grass.json @@ -1,5 +1,5 @@ { - "type": "growthcraft:add_item", + "type": "growthcraft:add_item_replacing_seeds", "conditions": [ { "chance": 0.1, @@ -8,6 +8,10 @@ { "block": "minecraft:grass", "condition": "minecraft:block_state_property" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "cellar" } ], "item": "growthcraft_cellar:yeast_brewers" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/yeast_ethereal_from_chorus_flower.json b/src/generated/resources/data/growthcraft/loot_modifiers/yeast_ethereal_from_chorus_flower.json index f5c9ea45..d0c4a3a7 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/yeast_ethereal_from_chorus_flower.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/yeast_ethereal_from_chorus_flower.json @@ -2,12 +2,16 @@ "type": "growthcraft:add_item", "conditions": [ { - "chance": 0.4, + "chance": 0.2, "condition": "minecraft:random_chance" }, { "block": "minecraft:chorus_flower", "condition": "minecraft:block_state_property" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "cellar" } ], "item": "growthcraft_cellar:yeast_ethereal" diff --git a/src/generated/resources/data/growthcraft/loot_modifiers/yeast_lager_from_snow.json b/src/generated/resources/data/growthcraft/loot_modifiers/yeast_lager_from_snow.json index 6c5a3339..98bd5cdf 100644 --- a/src/generated/resources/data/growthcraft/loot_modifiers/yeast_lager_from_snow.json +++ b/src/generated/resources/data/growthcraft/loot_modifiers/yeast_lager_from_snow.json @@ -2,12 +2,16 @@ "type": "growthcraft:add_item", "conditions": [ { - "chance": 0.2, + "chance": 0.1, "condition": "minecraft:random_chance" }, { "block": "minecraft:snow", "condition": "minecraft:block_state_property" + }, + { + "condition": "growthcraft:module_loaded_loot_check", + "module": "cellar" } ], "item": "growthcraft_cellar:yeast_lager" diff --git a/src/generated/resources/data/growthcraft/worldgen/placed_feature/deepslate_salt_ore_placed.json b/src/generated/resources/data/growthcraft/worldgen/placed_feature/deepslate_salt_ore_placed.json index 2c4341da..3de5be1b 100644 --- a/src/generated/resources/data/growthcraft/worldgen/placed_feature/deepslate_salt_ore_placed.json +++ b/src/generated/resources/data/growthcraft/worldgen/placed_feature/deepslate_salt_ore_placed.json @@ -3,7 +3,7 @@ "placement": [ { "type": "minecraft:count", - "count": 50 + "count": 10 }, { "type": "minecraft:in_square" diff --git a/src/generated/resources/data/growthcraft/worldgen/placed_feature/end_salt_ore_placed.json b/src/generated/resources/data/growthcraft/worldgen/placed_feature/end_salt_ore_placed.json index 7441c9c5..6b4512f8 100644 --- a/src/generated/resources/data/growthcraft/worldgen/placed_feature/end_salt_ore_placed.json +++ b/src/generated/resources/data/growthcraft/worldgen/placed_feature/end_salt_ore_placed.json @@ -3,7 +3,7 @@ "placement": [ { "type": "minecraft:count", - "count": 50 + "count": 10 }, { "type": "minecraft:in_square" diff --git a/src/generated/resources/data/growthcraft/worldgen/placed_feature/nether_salt_ore_placed.json b/src/generated/resources/data/growthcraft/worldgen/placed_feature/nether_salt_ore_placed.json index dc347320..c49152f6 100644 --- a/src/generated/resources/data/growthcraft/worldgen/placed_feature/nether_salt_ore_placed.json +++ b/src/generated/resources/data/growthcraft/worldgen/placed_feature/nether_salt_ore_placed.json @@ -3,7 +3,7 @@ "placement": [ { "type": "minecraft:count", - "count": 50 + "count": 10 }, { "type": "minecraft:in_square" diff --git a/src/generated/resources/data/growthcraft_apiary/advancements/recipes/decorations/bee_box_bamboo.json b/src/generated/resources/data/growthcraft_apiary/advancements/recipes/decorations/bee_box_bamboo.json index 5990c775..71ba0be8 100644 --- a/src/generated/resources/data/growthcraft_apiary/advancements/recipes/decorations/bee_box_bamboo.json +++ b/src/generated/resources/data/growthcraft_apiary/advancements/recipes/decorations/bee_box_bamboo.json @@ -8,6 +8,11 @@ "items": [ "minecraft:bamboo_planks" ] + }, + { + "items": [ + "minecraft:bamboo_mosaic" + ] } ] }, diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_acacia.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_acacia.json index b97ec701..23a79425 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_acacia.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_acacia.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_bamboo.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_bamboo.json index c280868f..04564e31 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_bamboo.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_bamboo.json @@ -1,7 +1,13 @@ { "type": "minecraft:crafting_shaped", "category": "misc", - "group": "growthcraft_bamboo", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], + "group": "growthcraft_apiary", "key": { "B": [ { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_birch.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_birch.json index 18dc8c0b..98941a6b 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_birch.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_birch.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_cherry.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_cherry.json index c5cc176a..062ff181 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_cherry.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_cherry.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_crimson.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_crimson.json index f9e2cf8c..6eee43a0 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_crimson.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_crimson.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_dark_oak.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_dark_oak.json index ccca79bb..4b3a4d72 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_dark_oak.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_dark_oak.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_jungle.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_jungle.json index 5c2f92dc..ea5c5662 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_jungle.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_jungle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_mangrove.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_mangrove.json index 15793105..139f609d 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_mangrove.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_mangrove.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_oak.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_oak.json index f30b8998..ab8d9bb8 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_oak.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_oak.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_spruce.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_spruce.json index 8309eeac..12b19746 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_spruce.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_spruce.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_warped.json b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_warped.json index 33caf6be..de94e298 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_warped.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bee_box_warped.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "B": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_black.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_black.json index 34e4ec00..5e24e989 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_black.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_black.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_blue.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_blue.json index 070eb6cc..3b774422 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_blue.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_blue.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_brown.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_brown.json index e240eb53..21fc5416 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_brown.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_brown.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_cyan.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_cyan.json index 340cd270..c0ee623f 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_cyan.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_cyan.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_gray.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_gray.json index 0cd01ca8..694b6895 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_gray.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_gray.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_green.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_green.json index ec4f935f..2e04d623 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_green.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_green.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_light_blue.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_light_blue.json index b7e880f8..a3a72c95 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_light_blue.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_light_blue.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_light_gray.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_light_gray.json index 667a92c6..37b1b47b 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_light_gray.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_light_gray.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_lime.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_lime.json index 87486e72..6d8b74f6 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_lime.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_lime.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_magenta.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_magenta.json index 612c183e..5749321e 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_magenta.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_magenta.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_orange.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_orange.json index 82fcc770..713aab2b 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_orange.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_orange.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_pink.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_pink.json index 14fcdee0..47d25867 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_pink.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_pink.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_purple.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_purple.json index 5888b536..121c53a1 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_purple.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_purple.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_red.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_red.json index 996f4290..f31d15db 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_red.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_red.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_white.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_white.json index 90872d04..9904297e 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_white.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_white.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_yellow.json b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_yellow.json index bd9d5973..9f461bf5 100644 --- a/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_yellow.json +++ b/src/generated/resources/data/growthcraft_apiary/recipes/bees_wax_yellow.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "growthcraft_apiary", "key": { "A": { diff --git a/src/generated/resources/data/growthcraft_apples/recipes/apple_seeds.json b/src/generated/resources/data/growthcraft_apples/recipes/apple_seeds.json index 49d8ce05..89d0be0a 100644 --- a/src/generated/resources/data/growthcraft_apples/recipes/apple_seeds.json +++ b/src/generated/resources/data/growthcraft_apples/recipes/apple_seeds.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apples" + } + ], "group": "growthcraft_apples", "ingredients": [ { diff --git a/src/generated/resources/data/growthcraft_rice/recipes/chicken_rice.json b/src/generated/resources/data/growthcraft_rice/recipes/chicken_rice.json index 57f44006..7986fac0 100644 --- a/src/generated/resources/data/growthcraft_rice/recipes/chicken_rice.json +++ b/src/generated/resources/data/growthcraft_rice/recipes/chicken_rice.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice" + } + ], "group": "growthcraft_rice", "ingredients": [ { diff --git a/src/generated/resources/data/growthcraft_rice/recipes/cultivator.json b/src/generated/resources/data/growthcraft_rice/recipes/cultivator.json index e1d901ec..50b4a557 100644 --- a/src/generated/resources/data/growthcraft_rice/recipes/cultivator.json +++ b/src/generated/resources/data/growthcraft_rice/recipes/cultivator.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "equipment", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice" + } + ], "group": "growthcraft_rice", "key": { "I": { diff --git a/src/generated/resources/data/growthcraft_rice/recipes/immersiveengineering/cloche/rice.json b/src/generated/resources/data/growthcraft_rice/recipes/immersiveengineering/cloche/rice.json index 43cd76de..bce45a85 100644 --- a/src/generated/resources/data/growthcraft_rice/recipes/immersiveengineering/cloche/rice.json +++ b/src/generated/resources/data/growthcraft_rice/recipes/immersiveengineering/cloche/rice.json @@ -1,5 +1,15 @@ { "type": "immersiveengineering:cloche", + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "immersiveengineering" + }, + { + "type": "growthcraft:feature_enabled", + "feature": "rice" + } + ], "input": { "item": "growthcraft_rice:rice_grains" }, diff --git a/src/generated/resources/data/growthcraft_rice/recipes/knife.json b/src/generated/resources/data/growthcraft_rice/recipes/knife.json index 3d746ef9..5c682a69 100644 --- a/src/generated/resources/data/growthcraft_rice/recipes/knife.json +++ b/src/generated/resources/data/growthcraft_rice/recipes/knife.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "equipment", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice" + } + ], "group": "growthcraft_rice", "key": { "I": { diff --git a/src/generated/resources/data/growthcraft_rice/recipes/mekanism/crushing/biofuel/rice_stalk.json b/src/generated/resources/data/growthcraft_rice/recipes/mekanism/crushing/biofuel/rice_stalk.json index 00842664..b614c851 100644 --- a/src/generated/resources/data/growthcraft_rice/recipes/mekanism/crushing/biofuel/rice_stalk.json +++ b/src/generated/resources/data/growthcraft_rice/recipes/mekanism/crushing/biofuel/rice_stalk.json @@ -4,6 +4,10 @@ { "type": "forge:mod_loaded", "modid": "mekanism" + }, + { + "type": "growthcraft:feature_enabled", + "feature": "rice" } ], "input": { diff --git a/src/generated/resources/data/growthcraft_rice/recipes/onigiri.json b/src/generated/resources/data/growthcraft_rice/recipes/onigiri.json index c027fd80..b67316eb 100644 --- a/src/generated/resources/data/growthcraft_rice/recipes/onigiri.json +++ b/src/generated/resources/data/growthcraft_rice/recipes/onigiri.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice" + } + ], "group": "growthcraft_rice", "key": { "K": { diff --git a/src/generated/resources/data/growthcraft_rice/recipes/rice.json b/src/generated/resources/data/growthcraft_rice/recipes/rice.json index 1c727169..958b0ccb 100644 --- a/src/generated/resources/data/growthcraft_rice/recipes/rice.json +++ b/src/generated/resources/data/growthcraft_rice/recipes/rice.json @@ -1,6 +1,7 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [], "group": "growthcraft_rice", "ingredients": [ { diff --git a/src/generated/resources/data/growthcraft_rice/recipes/rice_grains.json b/src/generated/resources/data/growthcraft_rice/recipes/rice_grains.json index 7a1093cc..8b46a888 100644 --- a/src/generated/resources/data/growthcraft_rice/recipes/rice_grains.json +++ b/src/generated/resources/data/growthcraft_rice/recipes/rice_grains.json @@ -1,6 +1,7 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [], "group": "growthcraft_rice", "ingredients": [ { diff --git a/src/generated/resources/data/growthcraft_rice/recipes/sushi_roll.json b/src/generated/resources/data/growthcraft_rice/recipes/sushi_roll.json index ba3311df..a39f7d28 100644 --- a/src/generated/resources/data/growthcraft_rice/recipes/sushi_roll.json +++ b/src/generated/resources/data/growthcraft_rice/recipes/sushi_roll.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice" + } + ], "group": "growthcraft_rice", "key": { "F": { diff --git a/src/generated/resources/data/minecraft/advancements/recipes/food/packed_mud.json b/src/generated/resources/data/minecraft/advancements/recipes/building_blocks/packed_mud.json similarity index 100% rename from src/generated/resources/data/minecraft/advancements/recipes/food/packed_mud.json rename to src/generated/resources/data/minecraft/advancements/recipes/building_blocks/packed_mud.json diff --git a/src/generated/resources/data/minecraft/recipes/black_candle.json b/src/generated/resources/data/minecraft/recipes/black_candle.json index 78a2fc88..07b9f0fd 100644 --- a/src/generated/resources/data/minecraft/recipes/black_candle.json +++ b/src/generated/resources/data/minecraft/recipes/black_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/blue_candle.json b/src/generated/resources/data/minecraft/recipes/blue_candle.json index 799f55a1..1f06aef1 100644 --- a/src/generated/resources/data/minecraft/recipes/blue_candle.json +++ b/src/generated/resources/data/minecraft/recipes/blue_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/brown_candle.json b/src/generated/resources/data/minecraft/recipes/brown_candle.json index f131a94c..122cf673 100644 --- a/src/generated/resources/data/minecraft/recipes/brown_candle.json +++ b/src/generated/resources/data/minecraft/recipes/brown_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/candle.json b/src/generated/resources/data/minecraft/recipes/candle.json index 90bd85db..56b80604 100644 --- a/src/generated/resources/data/minecraft/recipes/candle.json +++ b/src/generated/resources/data/minecraft/recipes/candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shaped", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "key": { "H": { "tag": "growthcraft_apiary:honey_comb" diff --git a/src/generated/resources/data/minecraft/recipes/cyan_candle.json b/src/generated/resources/data/minecraft/recipes/cyan_candle.json index fff3399e..9c42272c 100644 --- a/src/generated/resources/data/minecraft/recipes/cyan_candle.json +++ b/src/generated/resources/data/minecraft/recipes/cyan_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/gray_candle.json b/src/generated/resources/data/minecraft/recipes/gray_candle.json index 308ee5b2..bc1eed67 100644 --- a/src/generated/resources/data/minecraft/recipes/gray_candle.json +++ b/src/generated/resources/data/minecraft/recipes/gray_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/green_candle.json b/src/generated/resources/data/minecraft/recipes/green_candle.json index fb8e4b6c..175295c6 100644 --- a/src/generated/resources/data/minecraft/recipes/green_candle.json +++ b/src/generated/resources/data/minecraft/recipes/green_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/light_blue_candle.json b/src/generated/resources/data/minecraft/recipes/light_blue_candle.json index fca8b602..3780dd75 100644 --- a/src/generated/resources/data/minecraft/recipes/light_blue_candle.json +++ b/src/generated/resources/data/minecraft/recipes/light_blue_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/light_gray_candle.json b/src/generated/resources/data/minecraft/recipes/light_gray_candle.json index 5e4c3565..c97028cd 100644 --- a/src/generated/resources/data/minecraft/recipes/light_gray_candle.json +++ b/src/generated/resources/data/minecraft/recipes/light_gray_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/lime_candle.json b/src/generated/resources/data/minecraft/recipes/lime_candle.json index 5b010067..e84fd738 100644 --- a/src/generated/resources/data/minecraft/recipes/lime_candle.json +++ b/src/generated/resources/data/minecraft/recipes/lime_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/magenta_candle.json b/src/generated/resources/data/minecraft/recipes/magenta_candle.json index 15de30c4..7098b84a 100644 --- a/src/generated/resources/data/minecraft/recipes/magenta_candle.json +++ b/src/generated/resources/data/minecraft/recipes/magenta_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/orange_candle.json b/src/generated/resources/data/minecraft/recipes/orange_candle.json index 3e879e96..29a6350a 100644 --- a/src/generated/resources/data/minecraft/recipes/orange_candle.json +++ b/src/generated/resources/data/minecraft/recipes/orange_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/packed_mud.json b/src/generated/resources/data/minecraft/recipes/packed_mud.json index 73d94097..5a737625 100644 --- a/src/generated/resources/data/minecraft/recipes/packed_mud.json +++ b/src/generated/resources/data/minecraft/recipes/packed_mud.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", - "category": "misc", + "category": "building", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice" + } + ], "group": "growthcraft_rice", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/pink_candle.json b/src/generated/resources/data/minecraft/recipes/pink_candle.json index 1937eb99..910eb825 100644 --- a/src/generated/resources/data/minecraft/recipes/pink_candle.json +++ b/src/generated/resources/data/minecraft/recipes/pink_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/purple_candle.json b/src/generated/resources/data/minecraft/recipes/purple_candle.json index ae5f0bfe..cb6c96e8 100644 --- a/src/generated/resources/data/minecraft/recipes/purple_candle.json +++ b/src/generated/resources/data/minecraft/recipes/purple_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/red_candle.json b/src/generated/resources/data/minecraft/recipes/red_candle.json index a756a385..31713a7b 100644 --- a/src/generated/resources/data/minecraft/recipes/red_candle.json +++ b/src/generated/resources/data/minecraft/recipes/red_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/white_candle.json b/src/generated/resources/data/minecraft/recipes/white_candle.json index 4b6ea4fa..0ee5cb53 100644 --- a/src/generated/resources/data/minecraft/recipes/white_candle.json +++ b/src/generated/resources/data/minecraft/recipes/white_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/generated/resources/data/minecraft/recipes/yellow_candle.json b/src/generated/resources/data/minecraft/recipes/yellow_candle.json index 66840f2f..5d32e86a 100644 --- a/src/generated/resources/data/minecraft/recipes/yellow_candle.json +++ b/src/generated/resources/data/minecraft/recipes/yellow_candle.json @@ -1,6 +1,12 @@ { "type": "minecraft:crafting_shapeless", "category": "misc", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ], "group": "dyed_candle", "ingredients": [ { diff --git a/src/main/java/growthcraft/apiary/GrowthcraftApiary.java b/src/main/java/growthcraft/apiary/GrowthcraftApiary.java index baa35ff2..a4b6fb1d 100644 --- a/src/main/java/growthcraft/apiary/GrowthcraftApiary.java +++ b/src/main/java/growthcraft/apiary/GrowthcraftApiary.java @@ -55,14 +55,14 @@ private void setup(final FMLCommonSetupEvent event) { @SubscribeEvent public void onServerStarting(ServerStartingEvent event) { - LOGGER.info("Growthcraft Apiary starting up server-side ..."); + //LOGGER.info("Growthcraft Apiary starting up server-side ..."); } public void buildCreativeTabContents(BuildCreativeModeTabContentsEvent event) { if (event.getTab() == GrowthcraftCreativeModeTabs.CREATIVE_TAB.get()) { GrowthcraftApiaryItems.ITEMS.getEntries().forEach(itemRegistryObject -> { - if (!GrowthcraftApiaryItems.excludeItemRegistry(itemRegistryObject.getId())) { - event.accept(new ItemStack(itemRegistryObject.get())); + if (GrowthcraftApiaryItems.includeInCreativeTab(itemRegistryObject)) { + event.accept(itemRegistryObject); } }); } diff --git a/src/main/java/growthcraft/apiary/datagen/providers/GrowthcraftApiaryGlobalLootModifiersProvider.java b/src/main/java/growthcraft/apiary/datagen/providers/GrowthcraftApiaryGlobalLootModifiersProvider.java deleted file mode 100644 index 6cf024aa..00000000 --- a/src/main/java/growthcraft/apiary/datagen/providers/GrowthcraftApiaryGlobalLootModifiersProvider.java +++ /dev/null @@ -1,26 +0,0 @@ -package growthcraft.apiary.datagen.providers; - -import growthcraft.apiary.init.GrowthcraftApiaryItems; -import growthcraft.apiary.shared.Reference; -import growthcraft.lib.loot.AddItemModifier; -import net.minecraft.data.PackOutput; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; -import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; -import net.minecraftforge.common.data.GlobalLootModifierProvider; - -public class GrowthcraftApiaryGlobalLootModifiersProvider extends GlobalLootModifierProvider{ - public GrowthcraftApiaryGlobalLootModifiersProvider(PackOutput output) { - super(output, Reference.MODID); - } - - @Override - protected void start() { - add("bee_from_vanilla_bee_nest", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.50f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.BEE_NEST).build()}, - GrowthcraftApiaryItems.BEE.get().asItem())); - } - -} diff --git a/src/main/java/growthcraft/apiary/datagen/providers/GrowthcraftApiaryRecipes.java b/src/main/java/growthcraft/apiary/datagen/providers/GrowthcraftApiaryRecipes.java index 64e7534a..7a32250f 100644 --- a/src/main/java/growthcraft/apiary/datagen/providers/GrowthcraftApiaryRecipes.java +++ b/src/main/java/growthcraft/apiary/datagen/providers/GrowthcraftApiaryRecipes.java @@ -1,11 +1,14 @@ package growthcraft.apiary.datagen.providers; +import java.util.Arrays; import java.util.function.Consumer; import growthcraft.apiary.init.GrowthcraftApiaryBlocks; import growthcraft.apiary.init.GrowthcraftApiaryItems; import growthcraft.apiary.init.GrowthcraftApiaryTags; import growthcraft.apiary.shared.Reference; +import growthcraft.core.datagen.shared.GrowthcraftRecipeBuilder; +import growthcraft.core.init.config.OptionalFeatureCondition; import growthcraft.lib.item.GrowthcraftItem; import net.minecraft.advancements.critereon.InventoryChangeTrigger; import net.minecraft.data.PackOutput; @@ -18,10 +21,12 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.Block; import net.minecraftforge.common.Tags; +import net.minecraftforge.common.crafting.conditions.OrCondition; import net.minecraftforge.registries.ForgeRegistries; import static growthcraft.lib.utils.FormatUtils.HAS_ITEM; @@ -55,22 +60,16 @@ protected void buildRecipes(Consumer consumer) { Items.SPRUCE_SLAB, Items.SPRUCE_PLANKS, Tags.Items.RODS_WOODEN); this.beeBoxRecipeBuilder(consumer, GrowthcraftApiaryBlocks.BEE_BOX_WARPED.get(), Items.WARPED_SLAB, Items.WARPED_PLANKS, Tags.Items.RODS_WOODEN); - - ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, GrowthcraftApiaryBlocks.BEE_BOX_BAMBOO.get()) - .pattern("SPS") - .pattern("PBP") - .pattern("SPS") - .define('B', Ingredient.of(Items.BAMBOO_SLAB, Items.BAMBOO_MOSAIC_SLAB)) - .define('P', Ingredient.of(Items.BAMBOO_PLANKS, Items.BAMBOO_MOSAIC)) - .define('S', Tags.Items.RODS_WOODEN) - .group(growthcraft.bamboo.shared.Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(Items.BAMBOO_PLANKS)) - .save(consumer); + this.beeBoxRecipeBuilder(consumer, GrowthcraftApiaryBlocks.BEE_BOX_BAMBOO.get(), + Ingredient.of(Items.BAMBOO_SLAB, Items.BAMBOO_MOSAIC_SLAB), + Ingredient.of(Items.BAMBOO_PLANKS, Items.BAMBOO_MOSAIC), + Tags.Items.RODS_WOODEN); // Bees Wax GrowthcraftApiaryItems.ITEMS.getEntries().forEach(item -> { - if(item.getId().getPath().contains("bees_wax_")) { - ShapedRecipeBuilder.shaped(RecipeCategory.MISC, item.get(), 8) + if (item.getId().getPath().contains("bees_wax_")) { + GrowthcraftRecipeBuilder.crafting_shaped(RecipeCategory.MISC, item.get(), 8) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) .pattern("AAA") .pattern("ABA") .pattern("AAA") @@ -83,7 +82,8 @@ protected void buildRecipes(Consumer consumer) { }); // Candle - ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, Items.CANDLE) + GrowthcraftRecipeBuilder.crafting_shaped(RecipeCategory.DECORATIONS, Items.CANDLE) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) .pattern("S") .pattern("H") .define('S', Items.STRING) @@ -93,7 +93,8 @@ protected void buildRecipes(Consumer consumer) { // Dyed Candles for (DyeColor dye : DyeColor.values()) { - ShapelessRecipeBuilder.shapeless(RecipeCategory.DECORATIONS, ForgeRegistries.ITEMS.getValue(new ResourceLocation("minecraft:"+dye+"_candle"))) + GrowthcraftRecipeBuilder.crafting_shapeless(RecipeCategory.DECORATIONS, ForgeRegistries.ITEMS.getValue(new ResourceLocation("minecraft:"+dye+"_candle"))) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) .requires(Items.CANDLE) .requires(dye.getTag()) .group("dyed_candle") @@ -111,17 +112,21 @@ protected void buildRecipes(Consumer consumer) { * @param planks The item representing the planks. * @param tagRod The tag key for the rod item. */ + private void beeBoxRecipeBuilder(Consumer consumer, Block beeBoxBlock, Ingredient slab, Ingredient planks, TagKey tagRod) { + GrowthcraftRecipeBuilder.crafting_shaped(RecipeCategory.DECORATIONS, beeBoxBlock) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) + .pattern("SPS") + .pattern("PBP") + .pattern("SPS") + .define('B', slab) + .define('P', planks) + .define('S', tagRod) + .group(Reference.MODID) + .unlockedBy("has_item", InventoryChangeTrigger.TriggerInstance.hasItems(Arrays.stream(planks.getItems()).map(ItemStack::getItem).toList().toArray(new Item[0]))) + .save(consumer); + } private void beeBoxRecipeBuilder(Consumer consumer, Block beeBoxBlock, Item slab, Item planks, TagKey tagRod) { - ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, beeBoxBlock) - .pattern("SPS") - .pattern("PBP") - .pattern("SPS") - .define('B', slab) - .define('P', planks) - .define('S', tagRod) - .group(Reference.MODID) - .unlockedBy("has_item", InventoryChangeTrigger.TriggerInstance.hasItems(planks)) - .save(consumer); + beeBoxRecipeBuilder(consumer, beeBoxBlock, Ingredient.of(slab), Ingredient.of(planks), tagRod); } @Override diff --git a/src/main/java/growthcraft/apiary/init/GrowthcraftApiaryItems.java b/src/main/java/growthcraft/apiary/init/GrowthcraftApiaryItems.java index 7165c690..20ebfeaf 100644 --- a/src/main/java/growthcraft/apiary/init/GrowthcraftApiaryItems.java +++ b/src/main/java/growthcraft/apiary/init/GrowthcraftApiaryItems.java @@ -1,8 +1,10 @@ package growthcraft.apiary.init; import growthcraft.apiary.shared.Reference; +import growthcraft.core.init.config.OptionalFeatureCondition; import growthcraft.lib.item.GrowthcraftItem; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Item; import net.minecraftforge.registries.DeferredRegister; @@ -10,6 +12,7 @@ import net.minecraftforge.registries.RegistryObject; import java.util.ArrayList; +import java.util.function.Supplier; public class GrowthcraftApiaryItems { public static final DeferredRegister ITEMS = DeferredRegister.create( @@ -101,9 +104,13 @@ private GrowthcraftApiaryItems() { /* Prevent default public constructor */ } - public static boolean excludeItemRegistry(ResourceLocation registryName) { - ArrayList excludeItems = new ArrayList<>(); - //excludeItems.add(Reference.MODID + ":" + Reference.UnlocalizedName.APPLE_TREE_FRUIT); - return excludeItems.contains(registryName.toString()); + public static boolean includeInCreativeTab(Supplier item) { + if (item.get() instanceof BucketItem) { + return OptionalFeatureCondition.testModuleOrModuleFeature("apiary/beverages"); + } + if (item.equals(BEES_WAX)) { + return OptionalFeatureCondition.testModuleOrModuleFeature("apiary/basic_wax"); + } + return OptionalFeatureCondition.testModuleOrModuleFeature("apiary"); } } diff --git a/src/main/java/growthcraft/apiary/init/config/GrowthcraftApiaryConfig.java b/src/main/java/growthcraft/apiary/init/config/GrowthcraftApiaryConfig.java index c655b0ff..f3556422 100644 --- a/src/main/java/growthcraft/apiary/init/config/GrowthcraftApiaryConfig.java +++ b/src/main/java/growthcraft/apiary/init/config/GrowthcraftApiaryConfig.java @@ -1,7 +1,6 @@ package growthcraft.apiary.init.config; import growthcraft.core.init.config.GrowthcraftConfig; -import growthcraft.lib.utils.FormatUtils; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.loading.FMLPaths; @@ -21,6 +20,10 @@ public class GrowthcraftApiaryConfig { private static ForgeConfigSpec.IntValue flowerReplicationChance; private static ForgeConfigSpec.IntValue flowerSaturationPercent; + private static ForgeConfigSpec.BooleanValue moduleEnabled; + private static ForgeConfigSpec.BooleanValue featureEnabledBeverages; + private static ForgeConfigSpec.BooleanValue featureEnabledBasicWax; + static { initServerConfig(SERVER_BUILDER); SERVER = SERVER_BUILDER.build(); @@ -39,24 +42,38 @@ public static void loadConfig(ForgeConfigSpec configSpec, String path) { } public static void initServerConfig(ForgeConfigSpec.Builder specBuilder) { + specBuilder.push("_master_switch_"); + moduleEnabled = specBuilder + .comment("This master-switch lets you disable the entire Apiary module - bees-as-items and bee boxes, colored wax, flower duplication. Since Minecraft includes bees as of 1.15, we actually expect you to disable this module.") + .define("module_enabled", true); + featureEnabledBeverages = specBuilder + .comment("In case master-switch is turned off, this exception allows you to still make mead from vanilla honeycombs.") + .define("feature_exception_beverages", true); + featureEnabledBasicWax = specBuilder + .comment("In case master-switch is turned off, this exception allows you to still make wax (uncolored kind), as it is usable in milk module (not essential, though).") + .define("feature_exception_basic_wax", false); + specBuilder.pop(); // master_switch + + specBuilder.push(CATEGORY_BEE_BOX); flowerReplicationRange = specBuilder .comment("Set the range for the bee box to look for flowers.") - .defineInRange(String.format(FormatUtils.STRING_DOT_STRING, CATEGORY_BEE_BOX, "flowerRange"), 4, 0, 18); + .defineInRange("flowerRange", 4, 0, 18); beeBoxCycleUpdateTicks = specBuilder .comment("Set the process time for the bee box to update. Default is once a minute.") - .defineInRange(String.format(FormatUtils.STRING_DOT_STRING, CATEGORY_BEE_BOX, "maxProcessingTime"), 1200, 200, 1728000); + .defineInRange("maxProcessingTime", 1200, 200, 1728000); beeBreedingChance = specBuilder .comment("Set the percentage chance to increment bee population in the Bee Box.") - .defineInRange(String.format(FormatUtils.STRING_DOT_STRING, CATEGORY_BEE_BOX, "chanceBeeIncrement"), 33, 1, 100); + .defineInRange("chanceBeeIncrement", 33, 1, 100); flowerReplicationChance = specBuilder .comment("Set the percentage chance to replicate a flower near by.") - .defineInRange(String.format(FormatUtils.STRING_DOT_STRING, CATEGORY_BEE_BOX, "chanceReplicateFlower"), 10, 1, 100); + .defineInRange("chanceReplicateFlower", 10, 1, 100); doFlowerReplication = specBuilder .comment("Set to false to disable flower replication by the bee box") - .define(String.format(FormatUtils.STRING_DOT_STRING, CATEGORY_BEE_BOX, "replicateFlowers"), true); + .define("replicateFlowers", true); flowerSaturationPercent = specBuilder .comment("Set the percentage of the area to be filled with replicated flowers.") - .defineInRange(String.format(FormatUtils.STRING_DOT_STRING, CATEGORY_BEE_BOX, "flowerReplicationAreaPercent"), 100, 1, 100); + .defineInRange("flowerReplicationAreaPercent", 100, 1, 100); + specBuilder.pop(); // bee_box } public static int getBeeBoxFlowerRange() { @@ -83,4 +100,19 @@ public static int getFlowerReplicationAreaPercent() { return flowerSaturationPercent.get(); } + /////////////// + + public static Boolean getFeatureEnabledBeverages() + { + return featureEnabledBeverages.get(); + } + + public static Boolean getFeatureEnabledBasicWax() { + return featureEnabledBasicWax.get(); + } + + public static Boolean getModuleEnabled() + { + return moduleEnabled.get(); + } } \ No newline at end of file diff --git a/src/main/java/growthcraft/apples/GrowthcraftApples.java b/src/main/java/growthcraft/apples/GrowthcraftApples.java index 72078202..2ae2660b 100644 --- a/src/main/java/growthcraft/apples/GrowthcraftApples.java +++ b/src/main/java/growthcraft/apples/GrowthcraftApples.java @@ -53,14 +53,14 @@ private void setup(final FMLCommonSetupEvent event) { @SubscribeEvent public void onServerStarting(ServerStartingEvent event) { - LOGGER.info("Growthcraft Apples starting up ..."); + //LOGGER.info("Growthcraft Apples starting up ..."); } public void buildCreativeTabContents(BuildCreativeModeTabContentsEvent event) { if (event.getTab() == GrowthcraftCreativeModeTabs.CREATIVE_TAB.get()) { GrowthcraftApplesItems.ITEMS.getEntries().forEach(itemRegistryObject -> { - if (!GrowthcraftApplesItems.excludeItemRegistry(itemRegistryObject.getId())) { - event.accept(new ItemStack(itemRegistryObject.get())); + if (GrowthcraftApplesItems.includeInCreativeTab(itemRegistryObject)) { + event.accept(itemRegistryObject); } }); } diff --git a/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesRecipes.java b/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesRecipes.java index f179203b..b0c6cd90 100644 --- a/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesRecipes.java +++ b/src/main/java/growthcraft/apples/datagen/providers/GrowthcraftApplesRecipes.java @@ -5,6 +5,8 @@ import growthcraft.apples.init.GrowthcraftApplesBlocks; import growthcraft.apples.init.GrowthcraftApplesItems; import growthcraft.apples.shared.Reference; +import growthcraft.core.datagen.shared.GrowthcraftRecipeBuilder; +import growthcraft.core.init.config.OptionalFeatureCondition; import net.minecraft.advancements.critereon.InventoryChangeTrigger; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.FinishedRecipe; @@ -94,12 +96,13 @@ protected void buildRecipes(Consumer consumer) { .group(Reference.MODID) .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(GrowthcraftApplesBlocks.APPLE_WOOD_LOG.get())) .save(consumer); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, GrowthcraftApplesItems.APPLE_SEEDS.get()) - .requires(Items.APPLE) - .group(Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(Items.APPLE)) - .save(consumer); + + GrowthcraftRecipeBuilder.crafting_shapeless(RecipeCategory.FOOD, GrowthcraftApplesItems.APPLE_SEEDS.get()) + .addCondition(new OptionalFeatureCondition("apples")) + .requires(Items.APPLE) + .group(Reference.MODID) + .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(Items.APPLE)) + .save(consumer); ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, GrowthcraftApplesBlocks.APPLE_WOOD.get(), 3) .pattern("##") diff --git a/src/main/java/growthcraft/apples/init/GrowthcraftApplesItems.java b/src/main/java/growthcraft/apples/init/GrowthcraftApplesItems.java index 5a4d3dc5..e155679c 100644 --- a/src/main/java/growthcraft/apples/init/GrowthcraftApplesItems.java +++ b/src/main/java/growthcraft/apples/init/GrowthcraftApplesItems.java @@ -2,15 +2,13 @@ import growthcraft.apples.item.AppleSeedsItem; import growthcraft.apples.shared.Reference; -import net.minecraft.resources.ResourceLocation; +import growthcraft.core.init.config.OptionalFeatureCondition; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.ComposterBlock; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; -import java.util.ArrayList; - public class GrowthcraftApplesItems { public static final DeferredRegister ITEMS = DeferredRegister.create( @@ -32,10 +30,8 @@ public static void registerCompostables() { ComposterBlock.COMPOSTABLES.put(GrowthcraftApplesItems.APPLE_SEEDS.get(), f1); } - public static boolean excludeItemRegistry(ResourceLocation registryName) { - ArrayList excludeItems = new ArrayList<>(); - //excludeBlocks.add(Reference.MODID + ":" + Reference.UnlocalizedName.APPLE_TREE_FRUIT); - return excludeItems.contains(registryName.toString()); + public static boolean includeInCreativeTab(RegistryObject item) { + return OptionalFeatureCondition.testModuleOrModuleFeature("apples"); } private GrowthcraftApplesItems() { diff --git a/src/main/java/growthcraft/apples/init/config/GrowthcraftApplesConfig.java b/src/main/java/growthcraft/apples/init/config/GrowthcraftApplesConfig.java index 9d4010a7..e3405f71 100644 --- a/src/main/java/growthcraft/apples/init/config/GrowthcraftApplesConfig.java +++ b/src/main/java/growthcraft/apples/init/config/GrowthcraftApplesConfig.java @@ -7,10 +7,6 @@ import java.io.File; -/** - * @deprecated (9.2.0, "This config does not have a use.") - */ -@Deprecated(since = "9.2.0", forRemoval = true) public class GrowthcraftApplesConfig { public static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder(); @@ -18,6 +14,8 @@ public class GrowthcraftApplesConfig { public static final String SERVER_CONFIG = "growthcraft-apples-server.toml"; + private static ForgeConfigSpec.BooleanValue moduleEnabled; + static { initServerConfig(SERVER_BUILDER); SERVER = SERVER_BUILDER.build(); @@ -31,7 +29,7 @@ public static void loadConfig() { loadConfig(SERVER, FMLPaths.CONFIGDIR.get().resolve(SERVER_CONFIG).toString()); } - public static void loadConfig(ForgeConfigSpec configSpec, String path) { + private static void loadConfig(ForgeConfigSpec configSpec, String path) { final CommentedFileConfig fileConfig = CommentedFileConfig.builder( new File(path)).sync().autosave().writingMode(WritingMode.REPLACE).build(); @@ -39,10 +37,18 @@ public static void loadConfig(ForgeConfigSpec configSpec, String path) { configSpec.setConfig(fileConfig); } - public static void initServerConfig(ForgeConfigSpec.Builder specBuilder) { - // Nothing to config yet + private static void initServerConfig(ForgeConfigSpec.Builder builder) { + builder.push("_master_switch_"); + moduleEnabled = builder + .comment("This master-switch lets you disable the Apples module - currently just apple trees and wooden blocks. Apples themselves or apple cider are not affected.") + .define("module_enabled", true); + builder.pop(); // master_switch } - // TODO: Add config for apple growth range check. + //////////////////////////////////////////////////////// + public static Boolean getModuleEnabled() + { + return moduleEnabled.get(); + } } diff --git a/src/main/java/growthcraft/cellar/init/config/GrowthcraftCellarConfig.java b/src/main/java/growthcraft/cellar/init/config/GrowthcraftCellarConfig.java index 1b2e703d..d3f7dea4 100644 --- a/src/main/java/growthcraft/cellar/init/config/GrowthcraftCellarConfig.java +++ b/src/main/java/growthcraft/cellar/init/config/GrowthcraftCellarConfig.java @@ -13,8 +13,6 @@ public class GrowthcraftCellarConfig { public static final ForgeConfigSpec SERVER; public static final String SERVER_CONFIG = "growthcraft-cellar-server.toml"; - private static final String CATEGORY_BREW_KETTLE = "brew_kettle"; - private static ForgeConfigSpec.IntValue lootChancePillagerOutpost; private static ForgeConfigSpec.IntValue lootChanceOceanRuin; private static ForgeConfigSpec.IntValue lootChanceShipwreck; @@ -44,30 +42,30 @@ public static void loadConfig(ForgeConfigSpec configSpec, String path) { configSpec.setConfig(fileConfig); } - public static void initLootConfig(ForgeConfigSpec.Builder server) { - server.push("bottles_in_loot_chest"); // spaces would be fine here but i'll follow the existing style. - lootChancePillagerOutpost = server + public static void initLootConfig(ForgeConfigSpec.Builder builder) { + builder.push("bottles_in_loot_chest"); // spaces would be fine here but i'll follow the existing style. + lootChancePillagerOutpost = builder .comment("Percentage chance you'll find a few bottles of mead in pillager tower chest. Number here seems high but that bum place has only one chest and this fits the theme.") .defineInRange("loot_chance_pillager_outpost", 90, 0, 100); - lootChanceOceanRuin = server + lootChanceOceanRuin = builder .comment("Percentage chance you'll find a few bottles of wine in underwater ruin chest. Default of 10% is not low because ruins will have half a dozen chests.") .defineInRange("loot_chance_underwater_ruins", 10, 0, 100); - lootChanceShipwreck = server + lootChanceShipwreck = builder .comment("Percentage chance you'll find a few bottles of ale in shipwreck chest.") .defineInRange("loot_chance_shipwreck", 60, 0, 100); - lootChanceVillage = server + lootChanceVillage = builder .comment("Percentage chance you'll find a few bottles of wine in villager home chest.") .defineInRange("loot_chance_village", 0, 0, 100); // default is 0 - disabled for now. - lootChanceBeachTreasure = server + lootChanceBeachTreasure = builder .comment("Percentage chance you'll find a few bottles of wine in buried beach chest.") .defineInRange("loot_chance_beach_treasure", 0, 0, 100); // default is 0 - disabled for now. - lootChanceDarkForestMansion = server + lootChanceDarkForestMansion = builder .comment("Percentage chance you'll find a few bottles of lager in woodland mansion chest.") .defineInRange("loot_chance_dark_forest_mansion", 15, 0, 100); - lootChanceStronghold = server + lootChanceStronghold = builder .comment("Percentage chance you'll find a few bottles of wine in stronghold chest.") .defineInRange("loot_chance_stronghold", 0, 0, 100); // default is 0 - disabled for now. some absorption won't be too bad. - server.pop(); + builder.pop(); } public static int getLootChancePillagerTower() { diff --git a/src/main/java/growthcraft/core/Growthcraft.java b/src/main/java/growthcraft/core/Growthcraft.java index 46723c89..2bd8dc9c 100644 --- a/src/main/java/growthcraft/core/Growthcraft.java +++ b/src/main/java/growthcraft/core/Growthcraft.java @@ -1,9 +1,18 @@ package growthcraft.core; +import growthcraft.core.datagen.shared.BiomeTagLootCondition; +import growthcraft.core.datagen.shared.ModuleLoadedLootCondition; import growthcraft.core.init.*; +import growthcraft.core.init.config.BooleanFromConfigFileCondition; import growthcraft.core.init.config.GrowthcraftConfig; +import growthcraft.core.init.config.OptionalFeatureCondition; import growthcraft.core.shared.Reference; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -11,6 +20,8 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegisterEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -23,6 +34,7 @@ public Growthcraft() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::setup); modEventBus.addListener(this::clientSetupEvent); + modEventBus.addListener(this::registrationHandler); GrowthcraftConfig.loadConfig(); @@ -42,12 +54,21 @@ private void clientSetupEvent(final FMLClientSetupEvent event) { } private void setup(final FMLCommonSetupEvent event) { - // Do Nothing + // Do nothing + } + + private void registrationHandler(RegisterEvent event) { + if (event.getRegistryKey().equals(ForgeRegistries.Keys.RECIPE_SERIALIZERS)) { + // not same things but we just need them registered once and early enough. + CraftingHelper.register(new OptionalFeatureCondition.Serializer(OptionalFeatureCondition.DEFAULT_ID)); // normal registry in 1.21 + CraftingHelper.register(new BooleanFromConfigFileCondition.Serializer(BooleanFromConfigFileCondition.DEFAULT_ID)); // normal registry in 1.21 + ModuleLoadedLootCondition.TYPE = Registry.register(BuiltInRegistries.LOOT_CONDITION_TYPE, new ResourceLocation(Reference.MODID, "module_loaded_loot_check"), new LootItemConditionType(ModuleLoadedLootCondition.Serializer.create())); + BiomeTagLootCondition.TYPE = Registry.register(BuiltInRegistries.LOOT_CONDITION_TYPE, new ResourceLocation(Reference.MODID, "biome_loot_check"), new LootItemConditionType(BiomeTagLootCondition.Serializer.create())); + } } @SubscribeEvent public void onServerStarting(ServerStartingEvent event) { // Do nothing } - } diff --git a/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreGlobalLootModifiersProvider.java b/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreGlobalLootModifiersProvider.java index 3c17649a..55b7640d 100644 --- a/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreGlobalLootModifiersProvider.java +++ b/src/main/java/growthcraft/core/datagen/providers/GrowthcraftCoreGlobalLootModifiersProvider.java @@ -2,18 +2,22 @@ import growthcraft.apiary.init.GrowthcraftApiaryItems; import growthcraft.cellar.init.GrowthcraftCellarItems; +import growthcraft.core.datagen.shared.BiomeTagLootCondition; +import growthcraft.core.datagen.shared.ModuleLoadedLootCondition; import growthcraft.core.shared.Reference; import growthcraft.lib.loot.AddItemModifier; +import growthcraft.lib.loot.AddItemReplaceSeedsModifier; import growthcraft.lib.loot.AddLootTableModifier; +import growthcraft.lib.loot.WeightedSeedReplacementModifier; import growthcraft.milk.init.GrowthcraftMilkItems; import growthcraft.rice.init.GrowthcraftRiceItems; import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.BiomeTags; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.storage.loot.BuiltInLootTables; -import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; -import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; +import net.minecraft.world.level.storage.loot.predicates.*; +import net.minecraftforge.common.Tags; import net.minecraftforge.common.data.GlobalLootModifierProvider; import net.minecraftforge.common.loot.LootModifier; import net.minecraftforge.common.loot.LootTableIdCondition; @@ -26,9 +30,11 @@ public GrowthcraftCoreGlobalLootModifiersProvider(PackOutput output) { @Override protected void start() { //GC Apiary - add("bee_from_vanilla_bee_nest", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.50f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.BEE_NEST).build()}, + add("bee_from_vanilla_bee_nest", new AddItemModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.50f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.BEE_NEST).build(), + ModuleLoadedLootCondition.isLoaded("apiary") + }, GrowthcraftApiaryItems.BEE.get().asItem())); //GC Cellar @@ -40,58 +46,98 @@ protected void start() { add("add_loot_"+ growthcraft.cellar.shared.Reference.LootTable.WOODLAND_MANSION_CHEST_LOOT , loot(name(growthcraft.cellar.shared.Reference.LootTable.WOODLAND_MANSION_CHEST_LOOT), LootTableIdCondition.builder(BuiltInLootTables.WOODLAND_MANSION).build())); add("add_loot_"+ growthcraft.cellar.shared.Reference.LootTable.STRONGHOLD_CHEST_LOOT , loot(name(growthcraft.cellar.shared.Reference.LootTable.STRONGHOLD_CHEST_LOOT), LootTableIdCondition.builder(BuiltInLootTables.STRONGHOLD_CORRIDOR).or(LootTableIdCondition.builder(BuiltInLootTables.STRONGHOLD_CROSSING)).build())); - add("grape_seeds_purple_from_grass", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.2f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build()}, + add("grape_seeds_purple_from_grass", new AddItemReplaceSeedsModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.10f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build(), + ModuleLoadedLootCondition.isLoaded("grapes") + }, GrowthcraftCellarItems.GRAPE_PURPLE_SEED.get().asItem())); - add("grape_seeds_red_from_grass", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.2f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build()}, + add("grape_seeds_red_from_grass", new AddItemReplaceSeedsModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.10f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build(), + ModuleLoadedLootCondition.isLoaded("grapes") + }, GrowthcraftCellarItems.GRAPE_RED_SEEDS.get().asItem())); - add("grape_seeds_white_from_grass", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.2f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build()}, + add("grape_seeds_white_from_grass", new AddItemReplaceSeedsModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.10f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build(), + ModuleLoadedLootCondition.isLoaded("grapes") + }, GrowthcraftCellarItems.GRAPE_WHITE_SEEDS.get().asItem())); - add("hops_seeds_white_from_grass", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.2f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build()}, + add("hops_seeds_from_grass", new AddItemModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.07f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build(), + ModuleLoadedLootCondition.isLoaded("cellar") + }, GrowthcraftCellarItems.HOPS_SEED.get().asItem())); - add("yeast_bayanus_from_grass", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.1f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build()}, + add("yeast_bayanus_from_grass", new AddItemReplaceSeedsModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.1f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build(), + ModuleLoadedLootCondition.isLoaded("cellar") + }, GrowthcraftCellarItems.YEAST_BAYANUS.get().asItem())); - add("yeast_brewers_from_grass", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.1f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build()}, + add("yeast_brewers_from_grass", new AddItemReplaceSeedsModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.1f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build(), + ModuleLoadedLootCondition.isLoaded("cellar") + }, GrowthcraftCellarItems.YEAST_BREWERS.get().asItem())); - add("yeast_ethereal_from_chorus_flower", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.4f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.CHORUS_FLOWER).build()}, + add("yeast_ethereal_from_chorus_flower", new AddItemModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.2f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.CHORUS_FLOWER).build(), + ModuleLoadedLootCondition.isLoaded("cellar") + }, GrowthcraftCellarItems.YEAST_ETHEREAL.get().asItem())); - add("yeast_lager_from_snow", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.2f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.SNOW).build()}, + add("yeast_lager_from_snow", new AddItemModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.1f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.SNOW).build(), + ModuleLoadedLootCondition.isLoaded("cellar") + }, GrowthcraftCellarItems.YEAST_LAGER.get().asItem())); // GC Milk - add("thistle_seeds_from_grass", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.2f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build()}, + add("thistle_seeds_from_grass", new AddItemReplaceSeedsModifier(new LootItemCondition[]{ + LootItemRandomChanceCondition.randomChance(0.15f).build(), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build(), + BiomeTagLootCondition.forTag(Tags.Biomes.IS_COLD_OVERWORLD), + ModuleLoadedLootCondition.isLoaded("milk") + }, GrowthcraftMilkItems.THISTLE_SEED.get().asItem())); // GC Rice - add("rice_from_grass", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.2f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build()}, + add("rice_from_grass", new AddItemModifier(new LootItemCondition[] { + LootItemRandomChanceCondition.randomChance(0.005f).build(), + // 3% (0.03 gives us about 20% compared to wheat... a 25x25 area full of grass (625 blocks) gives about 75 wheat and 15 rice seeds) + // we'll try 0.5% for now in any biome. way more given by other modifier below. (0.5% still gives 5-10 rice seeds from a 25x25 testbed) + AnyOfCondition.anyOf( + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.TALL_GRASS) + ).build(), + ModuleLoadedLootCondition.isLoaded("rice") + }, GrowthcraftRiceItems.RICE_GRAINS.get().asItem())); - + add("rice_from_grass_wet", new WeightedSeedReplacementModifier(new LootItemCondition[] { + // 100%; chance condition removed. + AnyOfCondition.anyOf( + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS), + LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.TALL_GRASS) + ).build(), + AnyOfCondition.anyOf( + BiomeTagLootCondition.getBuilder().forTag(Tags.Biomes.IS_SWAMP), + BiomeTagLootCondition.getBuilder().forTag(BiomeTags.IS_RIVER) + ).build(), + ModuleLoadedLootCondition.isLoaded("rice") + }, + GrowthcraftRiceItems.RICE_GRAINS.get().asItem(), + 30, 55)); // 15 stays intact + } private static LootModifier loot(ResourceLocation id, LootItemCondition... cond) { diff --git a/src/main/java/growthcraft/core/datagen/shared/BiomeTagLootCondition.java b/src/main/java/growthcraft/core/datagen/shared/BiomeTagLootCondition.java new file mode 100644 index 00000000..63a7e7f4 --- /dev/null +++ b/src/main/java/growthcraft/core/datagen/shared/BiomeTagLootCondition.java @@ -0,0 +1,88 @@ +package growthcraft.core.datagen.shared; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.TagKey; +import net.minecraft.util.GsonHelper; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; +import net.minecraft.world.phys.Vec3; + +import javax.annotation.Nullable; + +public class BiomeTagLootCondition implements LootItemCondition { + public static LootItemConditionType TYPE = null; + private final TagKey biomeTag; + + private BiomeTagLootCondition(String tag) { + this.biomeTag = TagKey.create(Registries.BIOME, new ResourceLocation(tag)); + } + private BiomeTagLootCondition(TagKey tag) { + this.biomeTag = tag; + } + + public static BiomeTagLootCondition forTag(TagKey biomeTag) { + return new BiomeTagLootCondition(biomeTag); + } + + @Override + public LootItemConditionType getType() { return TYPE; } + + ///////////////////////////////////////// + + @Override + public boolean test(LootContext lootContext) { + if (this.biomeTag == null) { + return false; + } + ServerLevel serverlevel = lootContext.getLevel(); + Vec3 origin = lootContext.getParamOrNull(LootContextParams.ORIGIN); + if (origin == null) { + Entity entity = lootContext.getParamOrNull(LootContextParams.THIS_ENTITY); + if (entity == null) { + return false; + } + origin = entity.position(); + } + return serverlevel.getBiome(BlockPos.containing(origin)).is(this.biomeTag); + } + + public static BiomeTagLootCondition.Builder getBuilder() { return new BiomeTagLootCondition.Builder(); } + + //////////////////////////////////////// + + public static class Builder implements LootItemCondition.Builder { + @Nullable + private TagKey biomeTag = null; + + public BiomeTagLootCondition.Builder forTag(TagKey biomeTag) { + this.biomeTag = biomeTag; + return this; + } + public BiomeTagLootCondition build() { + return new BiomeTagLootCondition(this.biomeTag); + } + } + + public static class Serializer implements net.minecraft.world.level.storage.loot.Serializer { + public void serialize(JsonObject jsonObject, BiomeTagLootCondition lootCondition, JsonSerializationContext context) { + jsonObject.addProperty("biome_tag", lootCondition.biomeTag.location().toString()); + } + + public BiomeTagLootCondition deserialize(JsonObject jsonObject, JsonDeserializationContext context) { + String module = jsonObject.has("biome_tag") ? GsonHelper.getAsString(jsonObject, "biome_tag") : ""; + return new BiomeTagLootCondition(module); + } + + public static Serializer create() { return new Serializer(); } + } +} diff --git a/src/main/java/growthcraft/core/datagen/shared/GrowthcraftRecipeBuilder.java b/src/main/java/growthcraft/core/datagen/shared/GrowthcraftRecipeBuilder.java new file mode 100644 index 00000000..b376d5c8 --- /dev/null +++ b/src/main/java/growthcraft/core/datagen/shared/GrowthcraftRecipeBuilder.java @@ -0,0 +1,113 @@ +package growthcraft.core.datagen.shared; + +import com.google.gson.JsonObject; +import net.minecraft.data.recipes.*; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.level.ItemLike; +import net.minecraftforge.common.crafting.CraftingHelper; +import net.minecraftforge.common.crafting.conditions.ICondition; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +public class GrowthcraftRecipeBuilder { + public static ExtendedShapelessRecipeBuilder crafting_shapeless(RecipeCategory category, ItemLike result) { + return crafting_shapeless(category, result, 1); + } + public static ExtendedShapelessRecipeBuilder crafting_shapeless(RecipeCategory category, ItemLike result, int count) { + return new ExtendedShapelessRecipeBuilder(category, result, count); + } + public static ExtendedShapedRecipeBuilder crafting_shaped(RecipeCategory category, ItemLike result) { + return crafting_shaped(category, result, 1); + } + public static ExtendedShapedRecipeBuilder crafting_shaped(RecipeCategory category, ItemLike result, int count) { + return new ExtendedShapedRecipeBuilder(category, result, count); + } + + /////////////////////////////////////////////////////////////////////// + + public static class ExtendedShapelessRecipeBuilder extends ShapelessRecipeBuilder { + + public ExtendedShapelessRecipeBuilder(RecipeCategory category, ItemLike result, int count) + { + super(category, result, count); + } + + public ExtendedShapelessRecipeBuilder addCondition(ICondition condition) + { + this.conditions.add(condition); + return this; + } + private final List conditions = new ArrayList<>(); + + @Override + public void save(Consumer recipeConsumer, ResourceLocation location) + { + super.save(recipe -> recipeConsumer.accept(this.appendConditions(recipe)), location); + } + + private FinishedRecipe appendConditions(FinishedRecipe recipeWithoutConditions) + { + ConditionWrapperForCraftingRecipe ourRecipe = new ConditionWrapperForCraftingRecipe(recipeWithoutConditions, this.conditions.toArray(new ICondition[0])); + return ourRecipe; + } + } + + public static class ExtendedShapedRecipeBuilder extends ShapedRecipeBuilder { + + public ExtendedShapedRecipeBuilder(RecipeCategory category, ItemLike result, int count) + { + super(category, result, count); + } + + public ExtendedShapedRecipeBuilder addCondition(ICondition condition) + { + this.conditions.add(condition); + return this; + } + private final List conditions = new ArrayList<>(); + + @Override + public void save(Consumer recipeConsumer, ResourceLocation location) + { + super.save(recipe -> recipeConsumer.accept(this.appendConditions(recipe)), location); + } + + private FinishedRecipe appendConditions(FinishedRecipe recipeWithoutConditions) + { + ConditionWrapperForCraftingRecipe ourRecipe = new ConditionWrapperForCraftingRecipe(recipeWithoutConditions, this.conditions.toArray(new ICondition[0])); + return ourRecipe; + } + } + + private static class ConditionWrapperForCraftingRecipe implements FinishedRecipe { + private final ICondition[] conditions; + private final FinishedRecipe original; + + protected ConditionWrapperForCraftingRecipe(FinishedRecipe original, ICondition... conditions) { + this.conditions = conditions; + this.original = original; + } + + @Override + public void serializeRecipeData(JsonObject jsonObject) { + this.original.serializeRecipeData(jsonObject); + jsonObject.add("conditions", CraftingHelper.serialize(conditions)); + } + ///////////////////// + @Override + public ResourceLocation getId() { return this.original.getId(); } + @Override + public RecipeSerializer getType() { return this.original.getType(); } + @Nullable + @Override + public JsonObject serializeAdvancement() { return this.original.serializeAdvancement(); } + @Nullable + @Override + public ResourceLocation getAdvancementId() { return this.original.getAdvancementId(); } + } +} diff --git a/src/main/java/growthcraft/core/datagen/shared/ModuleLoadedLootCondition.java b/src/main/java/growthcraft/core/datagen/shared/ModuleLoadedLootCondition.java new file mode 100644 index 00000000..3a4b7623 --- /dev/null +++ b/src/main/java/growthcraft/core/datagen/shared/ModuleLoadedLootCondition.java @@ -0,0 +1,65 @@ +package growthcraft.core.datagen.shared; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import growthcraft.core.init.config.OptionalFeatureCondition; +import net.minecraft.util.GsonHelper; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; + +import javax.annotation.Nullable; + +public class ModuleLoadedLootCondition implements LootItemCondition { + public static LootItemConditionType TYPE = null; + private final String moduleToCheck; + + private ModuleLoadedLootCondition(String module) { + this.moduleToCheck = module != null ? module : ""; + } + + public static ModuleLoadedLootCondition isLoaded(String module) { + return new ModuleLoadedLootCondition(module); + } + + @Override + public LootItemConditionType getType() { return TYPE; } + + //////////////////////////////////////// + + @Override + public boolean test(LootContext lootContext) { + return OptionalFeatureCondition.testModuleOrModuleFeature(this.moduleToCheck); + } + + public static ModuleLoadedLootCondition.Builder getBuilder() { return new Builder(); } + + ///////////////////////////////// + + public static class Builder implements LootItemCondition.Builder { + @Nullable + private String moduleToCheck = ""; + + public ModuleLoadedLootCondition.Builder checkIsLoaded(String module) { + this.moduleToCheck = module; + return this; + } + public ModuleLoadedLootCondition build() { + return new ModuleLoadedLootCondition(this.moduleToCheck); + } + } + + public static class Serializer implements net.minecraft.world.level.storage.loot.Serializer { + public void serialize(JsonObject jsonObject, ModuleLoadedLootCondition lootCondition, JsonSerializationContext context) { + jsonObject.addProperty("module", lootCondition.moduleToCheck); + } + + public ModuleLoadedLootCondition deserialize(JsonObject jsonObject, JsonDeserializationContext context) { + String module = jsonObject.has("module") ? GsonHelper.getAsString(jsonObject, "module") : ""; + return new ModuleLoadedLootCondition(module); + } + + public static Serializer create() { return new Serializer(); } + } +} diff --git a/src/main/java/growthcraft/core/init/GrowthcraftCreativeModeTabs.java b/src/main/java/growthcraft/core/init/GrowthcraftCreativeModeTabs.java index f57bec3e..5fd06758 100644 --- a/src/main/java/growthcraft/core/init/GrowthcraftCreativeModeTabs.java +++ b/src/main/java/growthcraft/core/init/GrowthcraftCreativeModeTabs.java @@ -28,7 +28,7 @@ public class GrowthcraftCreativeModeTabs { ); // Add items GrowthcraftItems.ITEMS.getEntries().forEach(itemRegistryObject -> { - if (!GrowthcraftItems.excludeItemRegistry(itemRegistryObject.getId())) { + if (GrowthcraftItems.includeInCreativeTab(itemRegistryObject)) { output.accept(new ItemStack(itemRegistryObject.get())); } }); diff --git a/src/main/java/growthcraft/core/init/GrowthcraftItems.java b/src/main/java/growthcraft/core/init/GrowthcraftItems.java index 84feb401..12858a26 100644 --- a/src/main/java/growthcraft/core/init/GrowthcraftItems.java +++ b/src/main/java/growthcraft/core/init/GrowthcraftItems.java @@ -1,18 +1,19 @@ package growthcraft.core.init; import growthcraft.core.block.RopeBlock; +import growthcraft.core.init.config.BooleanFromConfigFileCondition; import growthcraft.core.item.CrowbarItem; import growthcraft.core.item.RopeItem; import growthcraft.core.item.WrenchItem; import growthcraft.core.shared.Reference; import growthcraft.lib.item.GrowthcraftItem; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import java.util.ArrayList; +import java.util.function.Supplier; public class GrowthcraftItems { public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Reference.MODID); @@ -93,10 +94,11 @@ public class GrowthcraftItems { Reference.UnlocalizedName.WRENCH, WrenchItem::new ); - public static boolean excludeItemRegistry(ResourceLocation registryName) { - ArrayList excludeItems = new ArrayList<>(); - //excludeBlocks.add(Reference.MODID + ":" + Reference.UnlocalizedName.APPLE_TREE_FRUIT); - return excludeItems.contains(registryName.toString()); + public static boolean includeInCreativeTab(Supplier item) { + if (item.get() instanceof CrowbarItem) { + return BooleanFromConfigFileCondition.testConfigValue("core", "other.crowbars_enabled"); + } + return true; } } diff --git a/src/main/java/growthcraft/core/init/GrowthcraftLootModifiers.java b/src/main/java/growthcraft/core/init/GrowthcraftLootModifiers.java index e3a0e513..4233906b 100644 --- a/src/main/java/growthcraft/core/init/GrowthcraftLootModifiers.java +++ b/src/main/java/growthcraft/core/init/GrowthcraftLootModifiers.java @@ -4,7 +4,9 @@ import growthcraft.core.shared.Reference; import growthcraft.lib.loot.AddItemModifier; +import growthcraft.lib.loot.AddItemReplaceSeedsModifier; import growthcraft.lib.loot.AddLootTableModifier; +import growthcraft.lib.loot.WeightedSeedReplacementModifier; import net.minecraftforge.common.loot.IGlobalLootModifier; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; @@ -16,6 +18,8 @@ public class GrowthcraftLootModifiers { DeferredRegister.create(ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Reference.MODID); public static final RegistryObject> ADD_ITEM = LOOT_MODIFIER_SERIALIZERS.register("add_item", AddItemModifier.CODEC); + public static final RegistryObject> ADD_ITEM_REPLACING_SEEDS = LOOT_MODIFIER_SERIALIZERS.register("add_item_replacing_seeds", AddItemReplaceSeedsModifier.CODEC); + public static final RegistryObject> WEIGHTED_SEED_REPLACER = LOOT_MODIFIER_SERIALIZERS.register("weighted_seed_replacer", WeightedSeedReplacementModifier.CODEC); public static final RegistryObject> ADD_LOOT_TABLE = LOOT_MODIFIER_SERIALIZERS.register("add_loot_table", AddLootTableModifier.CODEC); public static void register(IEventBus bus) { diff --git a/src/main/java/growthcraft/core/init/config/BooleanFromConfigFileCondition.java b/src/main/java/growthcraft/core/init/config/BooleanFromConfigFileCondition.java new file mode 100644 index 00000000..bcc5fb43 --- /dev/null +++ b/src/main/java/growthcraft/core/init/config/BooleanFromConfigFileCondition.java @@ -0,0 +1,103 @@ +package growthcraft.core.init.config; + +import com.google.gson.JsonObject; +import growthcraft.apiary.init.config.GrowthcraftApiaryConfig; +import growthcraft.apples.init.config.GrowthcraftApplesConfig; +import growthcraft.cellar.init.config.GrowthcraftCellarConfig; +import growthcraft.core.Growthcraft; +import growthcraft.core.shared.Reference; +import growthcraft.milk.init.config.GrowthcraftMilkConfig; +import growthcraft.rice.init.config.GrowthcraftRiceConfig; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.common.crafting.conditions.ICondition; +import net.minecraftforge.common.crafting.conditions.IConditionSerializer; +import net.minecraftforge.fml.loading.moddiscovery.NightConfigWrapper; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +/* * +* This is to be used in recipes and worlgen jsons to turn off things player does not want. +* It's a normal forge condition, like forge:mod_loaded +* +* Will be registrated as growthcraft:config_value (type) +* Two fields. First one is called "name" and is one of our module names. +* Second field is called "name" and can be any boolean from config files. Separate categories using dots. +* Working examples: "core", "other.crowbars_enabled" "milk", "loot_modifiers.stomachLootEnabled" "apiary", "beeBox.replicateFlowers" +* */ +public class BooleanFromConfigFileCondition implements ICondition { + public static final ResourceLocation DEFAULT_ID = new ResourceLocation(Reference.MODID, "config_value"); // normally should be unknown to this, but we'll only have one type and we need to instantiate manually for datagen. doesn't matter 1.21 will do away with this. + private final String optionName, module; + private final ResourceLocation conditionId; // internal; removed in 1.21 + private static final Map wrappers = new HashMap<>(); + + public BooleanFromConfigFileCondition(String module, String name) { + this(DEFAULT_ID, module, name); + } + + private BooleanFromConfigFileCondition(ResourceLocation id, String module, String name) { + this.conditionId = id; + this.optionName = name; + this.module = module; + } + + @Override + public ResourceLocation getID() { return this.conditionId; } + + @Override + public boolean test(IContext context) { + return testConfigValue(this.module, this.optionName); + } + + public static boolean testConfigValue(String module, String optionName) { + if (wrappers.isEmpty()) { + wrappers.put("core", new NightConfigWrapper(GrowthcraftConfig.SERVER.getValues())); + wrappers.put("apiary", new NightConfigWrapper(GrowthcraftApiaryConfig.SERVER.getValues())); + wrappers.put("apples", new NightConfigWrapper(GrowthcraftApplesConfig.SERVER.getValues())); + wrappers.put("cellar", new NightConfigWrapper(GrowthcraftCellarConfig.SERVER.getValues())); + wrappers.put("milk", new NightConfigWrapper(GrowthcraftMilkConfig.SERVER.getValues())); + wrappers.put("rice", new NightConfigWrapper(GrowthcraftRiceConfig.SERVER.getValues())); + } + if (!wrappers.containsKey(module)) { + Growthcraft.LOGGER.error("Growthcraft condition error: invalid module " + module + " in one of the json files."); + return false; + } + Optional valueHolder = wrappers.get(module).getConfigElement(optionName.split("\\.")); + if (valueHolder.isPresent() && valueHolder.get() instanceof ForgeConfigSpec.BooleanValue value) { + return value.get(); + } + else { + Growthcraft.LOGGER.error("Growthcraft condition error: invalid config path " + optionName + " in one of the json files."); + return false; + } + } + + ///////////////////////////////////////////////////// + + public static class Serializer implements IConditionSerializer { + private final ResourceLocation conditionId; + + public Serializer(ResourceLocation id) + { + this.conditionId = id; + } + + @Override + public void write(JsonObject json, BooleanFromConfigFileCondition condition) { + json.addProperty("module", condition.module); + json.addProperty("name", condition.optionName); + } + + @Override + public BooleanFromConfigFileCondition read(JsonObject json) { + return new BooleanFromConfigFileCondition(this.conditionId, json.getAsJsonPrimitive("module").getAsString(), json.getAsJsonPrimitive("name").getAsString()); + } + + @Override + public ResourceLocation getID() { + return this.conditionId; + } + } +} diff --git a/src/main/java/growthcraft/core/init/config/GrowthcraftConfig.java b/src/main/java/growthcraft/core/init/config/GrowthcraftConfig.java index 7e4f4b5f..72c8b740 100644 --- a/src/main/java/growthcraft/core/init/config/GrowthcraftConfig.java +++ b/src/main/java/growthcraft/core/init/config/GrowthcraftConfig.java @@ -25,6 +25,8 @@ public class GrowthcraftConfig { private static ForgeConfigSpec.IntValue saltOreGenHeightMax; private static ForgeConfigSpec.IntValue saltOreGenSpreadAmount; + private static ForgeConfigSpec.BooleanValue crowbarsEnabled; + static { initServerConfig(SERVER_BUILDER); SERVER = SERVER_BUILDER.build(); @@ -72,6 +74,10 @@ public static void initServerConfig(ForgeConfigSpec.Builder specBuilder) { saltOreGenSpreadAmount = specBuilder .comment("Set to the satutration spread for salt ore generation within a chunk.") .defineInRange(String.format("%s.%s", CATEGORY_WORLDGEN, "saltOreGenSpreadAmount"), 10, 1, 20); + /////////////////////////////// + crowbarsEnabled = specBuilder + .comment("Enable or disable crowbar tools. Currently not used by any module.") //...but this is a community mod, not mine, so i can't get satisfaction from deleting them. MF + .define(String.format("%s.%s", "other", "crowbars_enabled"), false); } // TODO: Implement usage to allow server admins to prevent the salt generation. diff --git a/src/main/java/growthcraft/core/init/config/OptionalFeatureCondition.java b/src/main/java/growthcraft/core/init/config/OptionalFeatureCondition.java new file mode 100644 index 00000000..3c51b280 --- /dev/null +++ b/src/main/java/growthcraft/core/init/config/OptionalFeatureCondition.java @@ -0,0 +1,104 @@ +package growthcraft.core.init.config; + +import com.google.gson.JsonObject; +import growthcraft.apiary.init.config.GrowthcraftApiaryConfig; +import growthcraft.apples.init.config.GrowthcraftApplesConfig; +import growthcraft.core.shared.Reference; +import growthcraft.rice.init.config.GrowthcraftRiceConfig; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.common.crafting.conditions.ICondition; +import net.minecraftforge.common.crafting.conditions.IConditionSerializer; + +/* * +* This is to be used in recipes and worlgen jsons to turn off things player does not want. +* It's a normal forge condition, like forge:mod_loaded +* +* Will be registrated as growthcraft:feature_enabled (type) +* Value is called "feature" and can be "apples", "apiary", etc... - those are module names. if one is used (without slash), master switch will be considered. +* Also values can be something like "apiary/mead". In this case, condition passes if apiary module is enabled OR if apiary is disabled (master switch) but mead exception is enabled in config. +* Full list of sub-features: "apiary/mead", "apiary/beverages" (alias), "apiary/basic_wax", "rice/beverages" +* */ +public class OptionalFeatureCondition implements ICondition { + public static final ResourceLocation DEFAULT_ID = new ResourceLocation(Reference.MODID, "feature_enabled"); // normally should be unknown to this, but we'll only have one type and we need to instantiate manually for datagen. doesn't matter 1.21 will do away with this. + private final String feature; + private final ResourceLocation conditionId; // internal; removed in 1.21 + + public OptionalFeatureCondition(String feature) { + this(DEFAULT_ID, feature); + } + + private OptionalFeatureCondition(ResourceLocation id, String feature) { + this.conditionId = id; + this.feature = feature; + } + + @Override + public ResourceLocation getID() { return this.conditionId; } + + @Override + public boolean test(IContext context) { + return testModuleOrModuleFeature(this.feature); + } + + public static boolean testModuleOrModuleFeature(String feature) { + if (feature.equals("rice")) { + return GrowthcraftRiceConfig.getModuleEnabled(); + } + else if (feature.equals("rice/beverages")) { + return GrowthcraftRiceConfig.getModuleEnabled() || GrowthcraftRiceConfig.getFeatureEnabledBeverages(); + } + else if (feature.equals("apples")) { + return GrowthcraftApplesConfig.getModuleEnabled(); + } + else if (feature.equals("apiary")) { + return GrowthcraftApiaryConfig.getModuleEnabled(); + } + else if (feature.equals("apiary/mead") || feature.equals("apiary/beverages")) { // we have an alias here + return GrowthcraftApiaryConfig.getModuleEnabled() || GrowthcraftApiaryConfig.getFeatureEnabledBeverages(); + } + else if (feature.equals("apiary/basic_wax")) { + return GrowthcraftApiaryConfig.getModuleEnabled() || GrowthcraftApiaryConfig.getFeatureEnabledBasicWax(); + } + else if (feature.equals("cellar")) { + return true; // NYI + } + else if (feature.equals("grapes")) { + return true; // NYI. not sure if we'll be able to disable them separately from cellar. GLMs can be separate easily. + } + else if (feature.equals("milk")) { + return true; // NYI + } + else if (feature.equals("bamboo")) { + return true; // NYI + } + else { + return false; + } + } + + ///////////////////////////////////////////////////// + + public static class Serializer implements IConditionSerializer { + private final ResourceLocation conditionId; + + public Serializer(ResourceLocation id) + { + this.conditionId = id; + } + + @Override + public void write(JsonObject json, OptionalFeatureCondition condition) { + json.addProperty("feature", condition.feature); + } + + @Override + public OptionalFeatureCondition read(JsonObject json) { + return new OptionalFeatureCondition(this.conditionId, json.getAsJsonPrimitive("feature").getAsString()); + } + + @Override + public ResourceLocation getID() { + return this.conditionId; + } + } +} diff --git a/src/main/java/growthcraft/lib/loot/AddItemModifier.java b/src/main/java/growthcraft/lib/loot/AddItemModifier.java index c69a8309..9f5d8c8b 100644 --- a/src/main/java/growthcraft/lib/loot/AddItemModifier.java +++ b/src/main/java/growthcraft/lib/loot/AddItemModifier.java @@ -2,13 +2,11 @@ import java.util.function.Supplier; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import org.jetbrains.annotations.NotNull; - import com.google.common.base.Suppliers; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; - -import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.storage.loot.LootContext; @@ -17,33 +15,29 @@ import net.minecraftforge.common.loot.LootModifier; import net.minecraftforge.registries.ForgeRegistries; -public class AddItemModifier extends LootModifier{ +public class AddItemModifier extends LootModifier { - public static final Supplier> CODEC = Suppliers.memoize(() -> - RecordCodecBuilder.create(inst -> codecStart(inst) - .and(ForgeRegistries.ITEMS.getCodec().fieldOf("item").forGetter(m -> m.item)) - .apply(inst, AddItemModifier::new))); + public static final Supplier> CODEC = Suppliers.memoize(() -> + RecordCodecBuilder.create(inst -> codecStart(inst) + .and(ForgeRegistries.ITEMS.getCodec().fieldOf("item").forGetter(m -> m.item)) + .apply(inst, AddItemModifier::new))); private final Item item; public AddItemModifier(LootItemCondition[] conditionsIn, Item item) { super(conditionsIn); - this.item=item; + this.item = item; } + /////////////////////////////////////// + @Override protected @NotNull ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { - for(LootItemCondition condition : this.conditions) { - if(!condition.test(context)) { - return generatedLoot; - } - } generatedLoot.add(new ItemStack(this.item)); - return generatedLoot; } + ////////////////////////////////////////////////////// + @Override - public Codec codec() { - return CODEC.get(); - } + public Codec codec() { return CODEC.get(); } } diff --git a/src/main/java/growthcraft/lib/loot/AddItemReplaceSeedsModifier.java b/src/main/java/growthcraft/lib/loot/AddItemReplaceSeedsModifier.java new file mode 100644 index 00000000..9aa04298 --- /dev/null +++ b/src/main/java/growthcraft/lib/loot/AddItemReplaceSeedsModifier.java @@ -0,0 +1,45 @@ +package growthcraft.lib.loot; + +import com.google.common.base.Suppliers; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraftforge.common.Tags; +import net.minecraftforge.common.loot.IGlobalLootModifier; +import net.minecraftforge.common.loot.LootModifier; +import net.minecraftforge.registries.ForgeRegistries; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Supplier; + +public class AddItemReplaceSeedsModifier extends LootModifier { + + public static final Supplier> CODEC = Suppliers.memoize(() -> + RecordCodecBuilder.create(inst -> codecStart(inst) + .and(ForgeRegistries.ITEMS.getCodec().fieldOf("item").forGetter(m -> m.item)) + .apply(inst, AddItemReplaceSeedsModifier::new))); + private final Item item; + + public AddItemReplaceSeedsModifier(LootItemCondition[] conditionsIn, Item item) { + super(conditionsIn); + this.item = item; + } + + ///////////////////////////////////////////////////// + + @Override + protected @NotNull ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { + generatedLoot.removeIf(stack -> stack.is(Tags.Items.SEEDS)); + generatedLoot.add(new ItemStack(this.item)); + return generatedLoot; + } + + /////////////// technicalities below ///////////////////// + + @Override + public Codec codec() { return CODEC.get(); } +} diff --git a/src/main/java/growthcraft/lib/loot/WeightedSeedReplacementModifier.java b/src/main/java/growthcraft/lib/loot/WeightedSeedReplacementModifier.java new file mode 100644 index 00000000..f74e2c4b --- /dev/null +++ b/src/main/java/growthcraft/lib/loot/WeightedSeedReplacementModifier.java @@ -0,0 +1,62 @@ +package growthcraft.lib.loot; + +import com.google.common.base.Suppliers; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraftforge.common.Tags; +import net.minecraftforge.common.loot.IGlobalLootModifier; +import net.minecraftforge.common.loot.LootModifier; +import net.minecraftforge.registries.ForgeRegistries; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Supplier; + +public class WeightedSeedReplacementModifier extends LootModifier { + private final Item item; + private final int percentToReplace, percentToVoid; + + public WeightedSeedReplacementModifier(LootItemCondition[] conditionsIn, Item item, int percentToReplace, int percentToVoid) { + super(conditionsIn); + this.item = item; + this.percentToReplace = percentToReplace; + this.percentToVoid = percentToVoid; + } + + @Override + protected @NotNull ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { + int itemsToRemove = 0; + for (int i = 0; i < generatedLoot.size() - itemsToRemove; i++) { + if (generatedLoot.get(i).is(Tags.Items.SEEDS)) { + int roll = context.getRandom().nextInt(100); + if (roll < percentToReplace) { + generatedLoot.set(i, new ItemStack(this.item)); // replace + } + else if (roll < percentToReplace + percentToVoid) { + int lastIndex = generatedLoot.size() - itemsToRemove - 1; + generatedLoot.set(i, generatedLoot.get(lastIndex)); + itemsToRemove += 1; + } + } + } + generatedLoot.size(generatedLoot.size() - itemsToRemove); + return generatedLoot; + } + + /////////////// technicalities below ///////////////////// + + public static final Supplier> CODEC = Suppliers.memoize(() -> + RecordCodecBuilder.create(inst -> codecStart(inst) + .and(ForgeRegistries.ITEMS.getCodec().fieldOf("item").forGetter(m -> m.item)) + .and(ExtraCodecs.NON_NEGATIVE_INT.fieldOf("percent_to_replace").forGetter(m -> m.percentToReplace)) + .and(ExtraCodecs.NON_NEGATIVE_INT.fieldOf("percent_to_void").forGetter(m -> m.percentToVoid)) + .apply(inst, WeightedSeedReplacementModifier::new)));; + + @Override + public Codec codec() { return CODEC.get(); } +} diff --git a/src/main/java/growthcraft/rice/GrowthcraftRice.java b/src/main/java/growthcraft/rice/GrowthcraftRice.java index 9d4d7ef6..bf103a8b 100644 --- a/src/main/java/growthcraft/rice/GrowthcraftRice.java +++ b/src/main/java/growthcraft/rice/GrowthcraftRice.java @@ -48,13 +48,13 @@ private void clientSetupEvent(final FMLClientSetupEvent event) { } private void setup(final FMLCommonSetupEvent event) { - // Do Nothing for now ... + // Do nothing } public void buildCreativeTabContents(BuildCreativeModeTabContentsEvent event) { if (event.getTab() == GrowthcraftCreativeModeTabs.CREATIVE_TAB.get()) { GrowthcraftRiceItems.ITEMS.getEntries().forEach(itemRegistryObject -> { - if (!GrowthcraftRiceItems.excludeItemRegistry(itemRegistryObject.getId())) { + if (GrowthcraftRiceItems.includeInCreativeTab(itemRegistryObject)) { event.accept(new ItemStack(itemRegistryObject.get())); } }); diff --git a/src/main/java/growthcraft/rice/datagen/providers/GrowthcraftRiceGlobalLootModifiersProvider.java b/src/main/java/growthcraft/rice/datagen/providers/GrowthcraftRiceGlobalLootModifiersProvider.java deleted file mode 100644 index f5ec3d2b..00000000 --- a/src/main/java/growthcraft/rice/datagen/providers/GrowthcraftRiceGlobalLootModifiersProvider.java +++ /dev/null @@ -1,26 +0,0 @@ -package growthcraft.rice.datagen.providers; - -import growthcraft.rice.init.GrowthcraftRiceItems; -import growthcraft.rice.shared.Reference; -import growthcraft.lib.loot.AddItemModifier; -import net.minecraft.data.PackOutput; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; -import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; -import net.minecraftforge.common.data.GlobalLootModifierProvider; - -public class GrowthcraftRiceGlobalLootModifiersProvider extends GlobalLootModifierProvider{ - public GrowthcraftRiceGlobalLootModifiersProvider(PackOutput output) { - super(output, Reference.MODID); - } - - @Override - protected void start() { - add("thistle_seeds_from_grass", new AddItemModifier(new LootItemCondition[]{ - LootItemRandomChanceCondition.randomChance(0.01f).build(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.GRASS).build()}, - GrowthcraftRiceItems.RICE_STALK.get().asItem())); - } - -} diff --git a/src/main/java/growthcraft/rice/datagen/providers/GrowthcraftRiceRecipes.java b/src/main/java/growthcraft/rice/datagen/providers/GrowthcraftRiceRecipes.java index 3d17a8c9..55da03c1 100644 --- a/src/main/java/growthcraft/rice/datagen/providers/GrowthcraftRiceRecipes.java +++ b/src/main/java/growthcraft/rice/datagen/providers/GrowthcraftRiceRecipes.java @@ -8,7 +8,10 @@ import blusunrize.immersiveengineering.api.crafting.ClocheRenderFunction.ClocheRenderReference; import blusunrize.immersiveengineering.api.crafting.builders.ClocheRecipeBuilder; import blusunrize.immersiveengineering.client.utils.ClocheRenderFunctions.RenderFunctionCrop; +import growthcraft.core.Growthcraft; +import growthcraft.core.datagen.shared.GrowthcraftRecipeBuilder; import growthcraft.core.init.GrowthcraftTags; +import growthcraft.core.init.config.OptionalFeatureCondition; import growthcraft.rice.init.GrowthcraftRiceBlocks; import growthcraft.rice.init.GrowthcraftRiceItems; import growthcraft.rice.shared.Reference; @@ -40,91 +43,101 @@ public GrowthcraftRiceRecipes(PackOutput packOutput) { @Override protected void buildRecipes(Consumer consumer) { - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, GrowthcraftRiceItems.CULTIVATOR.get()) - .pattern("iIi") - .pattern("iSi") - .pattern(" S ") - .define('i', Tags.Items.NUGGETS_IRON) - .define('I', Tags.Items.INGOTS_IRON) - .define('S', Tags.Items.RODS_WOODEN) - .group(Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(Items.IRON_INGOT)) - .save(consumer); - - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, GrowthcraftRiceItems.KNIFE.get()) - .pattern(" I") - .pattern(" I ") - .pattern("S ") - .define('I', Tags.Items.INGOTS_IRON) - .define('S', Tags.Items.RODS_WOODEN) - .group(Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(Items.IRON_INGOT)) - .save(consumer); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, GrowthcraftRiceItems.RICE_GRAINS.get(), 4) - .requires(GrowthcraftRiceItems.RICE.get()) - .group(Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(GrowthcraftRiceItems.RICE.get()).build())) - .save(consumer); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, GrowthcraftRiceItems.RICE.get()) - .requires(GrowthcraftRiceItems.RICE_GRAINS.get(), 4) - .group(Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(GrowthcraftRiceItems.RICE.get()).build())) - .save(consumer); - - ShapedRecipeBuilder.shaped(RecipeCategory.FOOD, GrowthcraftRiceItems.SUSHI_ROLL.get(), 12) - .pattern(" F ") - .pattern("RRR") - .pattern("KKK") - .define('F', ItemTags.FISHES) - .define('R', GrowthcraftRiceItems.RICE_COOKED.get()) - .define('K', Items.DRIED_KELP) - .group(Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(GrowthcraftRiceItems.RICE_COOKED.get())) - .save(consumer); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, GrowthcraftRiceItems.CHICKEN_RICE.get()) - .requires(GrowthcraftRiceItems.RICE_COOKED.get()) - .requires(Items.COOKED_CHICKEN) - .requires(Items.BOWL) - .group(Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(GrowthcraftRiceItems.RICE_COOKED.get()).build())) - .save(consumer); - - ShapedRecipeBuilder.shaped(RecipeCategory.FOOD, GrowthcraftRiceItems.ONIGIRI.get(), 1) - .pattern(" R ") - .pattern(" S ") - .pattern(" K ") - .define('S', GrowthcraftTags.Items.SALT) - .define('R', GrowthcraftRiceItems.RICE_COOKED.get()) - .define('K', Items.DRIED_KELP) - .group(Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(GrowthcraftRiceItems.RICE_COOKED.get())) - .save(consumer); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, Blocks.PACKED_MUD) - .requires(GrowthcraftRiceItems.RICE_STALK.get()) - .requires(Blocks.MUD) - .group(Reference.MODID) - .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(GrowthcraftRiceItems.RICE_STALK.get()).build())) - .save(consumer); + GrowthcraftRecipeBuilder.crafting_shaped(RecipeCategory.TOOLS, GrowthcraftRiceItems.CULTIVATOR.get()) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) + .pattern("iIi") + .pattern("iSi") + .pattern(" S ") + .define('i', Tags.Items.NUGGETS_IRON) + .define('I', Tags.Items.INGOTS_IRON) + .define('S', Tags.Items.RODS_WOODEN) + .group(Reference.MODID) + .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(Items.IRON_INGOT)) + .save(consumer); + + GrowthcraftRecipeBuilder.crafting_shaped(RecipeCategory.TOOLS, GrowthcraftRiceItems.KNIFE.get()) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) + .pattern(" I") + .pattern(" I ") + .pattern("S ") + .define('I', Tags.Items.INGOTS_IRON) + .define('S', Tags.Items.RODS_WOODEN) + .group(Reference.MODID) + .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(Items.IRON_INGOT)) + .save(consumer); + + GrowthcraftRecipeBuilder.crafting_shapeless(RecipeCategory.FOOD, GrowthcraftRiceItems.RICE_GRAINS.get(), 4) + .requires(GrowthcraftRiceItems.RICE.get()) + .group(Reference.MODID) + .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(GrowthcraftRiceItems.RICE.get()).build())) + .save(consumer); + + GrowthcraftRecipeBuilder.crafting_shapeless(RecipeCategory.FOOD, GrowthcraftRiceItems.RICE.get()) + .requires(GrowthcraftRiceItems.RICE_GRAINS.get(), 4) + .group(Reference.MODID) + .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(GrowthcraftRiceItems.RICE.get()).build())) + .save(consumer); + + GrowthcraftRecipeBuilder.crafting_shaped(RecipeCategory.FOOD, GrowthcraftRiceItems.SUSHI_ROLL.get(), 12) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) + .pattern(" F ") + .pattern("RRR") + .pattern("KKK") + .define('F', ItemTags.FISHES) + .define('R', GrowthcraftRiceItems.RICE_COOKED.get()) + .define('K', Items.DRIED_KELP) + .group(Reference.MODID) + .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(GrowthcraftRiceItems.RICE_COOKED.get())) + .save(consumer); + + GrowthcraftRecipeBuilder.crafting_shapeless(RecipeCategory.FOOD, GrowthcraftRiceItems.CHICKEN_RICE.get()) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) + .requires(GrowthcraftRiceItems.RICE_COOKED.get()) + .requires(Items.COOKED_CHICKEN) + .requires(Items.BOWL) + .group(Reference.MODID) + .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(GrowthcraftRiceItems.RICE_COOKED.get()).build())) + .save(consumer); + + GrowthcraftRecipeBuilder.crafting_shaped(RecipeCategory.FOOD, GrowthcraftRiceItems.ONIGIRI.get(), 1) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) + .pattern(" R ") + .pattern(" S ") + .pattern(" K ") + .define('S', GrowthcraftTags.Items.SALT) + .define('R', GrowthcraftRiceItems.RICE_COOKED.get()) + .define('K', Items.DRIED_KELP) + .group(Reference.MODID) + .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(GrowthcraftRiceItems.RICE_COOKED.get())) + .save(consumer); + + GrowthcraftRecipeBuilder.crafting_shapeless(RecipeCategory.BUILDING_BLOCKS, Blocks.PACKED_MUD) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) + .requires(GrowthcraftRiceItems.RICE_STALK.get()) + .requires(Blocks.MUD) + .group(Reference.MODID) + .unlockedBy(HAS_ITEM, InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(GrowthcraftRiceItems.RICE_STALK.get()).build())) + .save(consumer); - //Mekanism Bio Fule recipe, may not be needed in 1.21 + //Mekanism Bio Fuel recipe, may not be needed in 1.21 ItemStackToItemStackRecipeBuilder.crushing( IngredientCreatorAccess.item().from(GrowthcraftRiceItems.RICE_STALK.get()), MekanismItems.BIO_FUEL.getItemStack(2) - ).addCondition(new ModLoadedCondition("mekanism")) - .build(consumer, new ResourceLocation(Reference.MODID, Mekanism.MODID + "/crushing/biofuel/" + GrowthcraftRiceItems.RICE_STALK.get())); + ) + .addCondition(new ModLoadedCondition("mekanism")) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) + .build(consumer, new ResourceLocation(Reference.MODID, Mekanism.MODID + "/crushing/biofuel/" + GrowthcraftRiceItems.RICE_STALK.get())); //ImmersiveEngineering ClocheRecipeBuilder.builder(new ItemStack(GrowthcraftRiceItems.RICE.get(), 2)) - .addResult(new ItemStack(GrowthcraftRiceItems.RICE_STALK.get(), 3)) - .addInput(GrowthcraftRiceItems.RICE_GRAINS.get()) - .addSoil(Blocks.DIRT) - .setTime(1000) - .setRender(new ClocheRenderReference("crop", GrowthcraftRiceBlocks.RICE_CROP.get())) - .build(consumer, new ResourceLocation(Reference.MODID, ImmersiveEngineering.MODID + "/cloche/rice")); + .addCondition(new ModLoadedCondition("immersiveengineering")) + .addCondition(new OptionalFeatureCondition(Reference.NAME_SHORT)) + .addResult(new ItemStack(GrowthcraftRiceItems.RICE_STALK.get(), 3)) + .addInput(GrowthcraftRiceItems.RICE_GRAINS.get()) + .addSoil(Blocks.DIRT) + .setTime(1000) + .setRender(new ClocheRenderReference("crop", GrowthcraftRiceBlocks.RICE_CROP.get())) + .build(consumer, new ResourceLocation(Reference.MODID, ImmersiveEngineering.MODID + "/cloche/rice")); } @Override diff --git a/src/main/java/growthcraft/rice/init/GrowthcraftRiceItems.java b/src/main/java/growthcraft/rice/init/GrowthcraftRiceItems.java index 592e023e..efb7875f 100644 --- a/src/main/java/growthcraft/rice/init/GrowthcraftRiceItems.java +++ b/src/main/java/growthcraft/rice/init/GrowthcraftRiceItems.java @@ -1,19 +1,20 @@ package growthcraft.rice.init; +import growthcraft.core.init.config.OptionalFeatureCondition; import growthcraft.lib.item.GrowthcraftBowlFoodItem; import growthcraft.lib.item.GrowthcraftFoodItem; import growthcraft.lib.item.GrowthcraftItem; import growthcraft.rice.item.CultivatorItem; import growthcraft.rice.item.RiceSeedItem; import growthcraft.rice.shared.Reference; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.ComposterBlock; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; -import java.util.ArrayList; +import java.util.function.Supplier; public class GrowthcraftRiceItems { public static final DeferredRegister ITEMS = DeferredRegister.create( @@ -70,24 +71,24 @@ public class GrowthcraftRiceItems { ); public static void registerCompostables() { - float f = 0.3F; - float f1 = 0.5F; - float f2 = 0.65F; - float f3 = 0.85F; - float f4 = 1.0F; - + float chanceLow = 0.1F; + float chanceMedium = 0.4F; + float chanceHigh = 0.85F; + float definitely = 1.0F; // Add rice as a compostable - ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.RICE.get(), f2); - ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.RICE_COOKED.get(), f3); - ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.RICE_STALK.get(), f1); - ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.SUSHI_ROLL.get(), f4); - ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.YEAST_SEISHU.get(), f4); + ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.RICE.get(), chanceLow); + ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.RICE_GRAINS.get(), chanceMedium); + ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.RICE_COOKED.get(), chanceMedium); + ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.RICE_STALK.get(), chanceMedium); + ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.SUSHI_ROLL.get(), chanceHigh); + ComposterBlock.COMPOSTABLES.put(GrowthcraftRiceItems.YEAST_SEISHU.get(), definitely); } - public static boolean excludeItemRegistry(ResourceLocation registryName) { - ArrayList excludeItems = new ArrayList<>(); - //excludeItems.add(Reference.MODID + ":" + Reference.UnlocalizedName.APPLE_TREE_FRUIT); - return excludeItems.contains(registryName.toString()); + public static boolean includeInCreativeTab(Supplier item) { + if (item.get() instanceof BucketItem) { + return OptionalFeatureCondition.testModuleOrModuleFeature("rice/beverages"); + } + return OptionalFeatureCondition.testModuleOrModuleFeature("rice"); } private GrowthcraftRiceItems() { diff --git a/src/main/java/growthcraft/rice/init/config/GrowthcraftRiceConfig.java b/src/main/java/growthcraft/rice/init/config/GrowthcraftRiceConfig.java index 2b1f8800..f9589c85 100644 --- a/src/main/java/growthcraft/rice/init/config/GrowthcraftRiceConfig.java +++ b/src/main/java/growthcraft/rice/init/config/GrowthcraftRiceConfig.java @@ -7,16 +7,15 @@ import java.io.File; -/** - * @deprecated (9.2.0, "This config does not have a use.") - */ -@Deprecated(since = "9.2.0", forRemoval = true) public class GrowthcraftRiceConfig { public static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder(); public static final ForgeConfigSpec SERVER; public static final String SERVER_CONFIG = "growthcraft-rice-server.toml"; + private static ForgeConfigSpec.BooleanValue moduleEnabled; + private static ForgeConfigSpec.BooleanValue featureEnabledBeverages; + static { initServerConfig(SERVER_BUILDER); SERVER = SERVER_BUILDER.build(); @@ -30,7 +29,7 @@ public static void loadConfig() { loadConfig(SERVER, FMLPaths.CONFIGDIR.get().resolve(SERVER_CONFIG).toString()); } - public static void loadConfig(ForgeConfigSpec configSpec, String path) { + private static void loadConfig(ForgeConfigSpec configSpec, String path) { final CommentedFileConfig fileConfig = CommentedFileConfig.builder( new File(path)).sync().autosave().writingMode(WritingMode.REPLACE).build(); @@ -38,7 +37,26 @@ public static void loadConfig(ForgeConfigSpec configSpec, String path) { configSpec.setConfig(fileConfig); } - public static void initServerConfig(ForgeConfigSpec.Builder specBuilder) { - // Init Server Side Configuration + private static void initServerConfig(ForgeConfigSpec.Builder builder) { + builder.push("_master_switch_"); + moduleEnabled = builder + .comment("This master-switch lets you disable the entire Rice module - seeds dropping from grass, farming tool and products.") + .define("module_enabled", true); + featureEnabledBeverages = builder + .comment("In case master-switch is turned off, this exception allows you to still make rice wine and sake (assuming some other mod provides rice).") + .define("feature_exception_beverages", true); + builder.pop(); // master_switch + } + + ////////////////////////////////// + + public static Boolean getFeatureEnabledBeverages() + { + return featureEnabledBeverages.get(); + } + + public static Boolean getModuleEnabled() + { + return moduleEnabled.get(); } } diff --git a/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_honey_comb_full.json b/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_honey_comb_full.json index 79f5d75b..9f6a5b78 100644 --- a/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_honey_comb_full.json +++ b/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_honey_comb_full.json @@ -19,5 +19,11 @@ "by_product": { "item": "growthcraft_apiary:honey_comb_empty", "count": 1 - } + }, + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb_no_must.json b/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb_no_must.json new file mode 100644 index 00000000..1d316ef9 --- /dev/null +++ b/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb_no_must.json @@ -0,0 +1,37 @@ +{ + "type": "growthcraft_cellar:brew_kettle_recipe", + "requires_heat": true, + "requires_lid": "false", + "processing_time": 600, + "by_product_chance": 100, + "input_fluid": { + "fluid": "minecraft:water", + "amount": 500 + }, + "input_item": { + "item": "minecraft:honeycomb", + "count": 1 + }, + "output_fluid": { + "fluid": "minecraft:air", + "amount": 100 + }, + "by_product": { + "item": "growthcraft_apiary:honey_comb_empty", + "count": 1 + }, + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary/basic_wax" + }, + { + "type": "forge:not", + "value": + { + "type": "growthcraft:feature_enabled", + "feature": "apiary/beverages" + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb.json b/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb_normal.json similarity index 80% rename from src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb.json rename to src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb_normal.json index b66f58b1..942ecd6f 100644 --- a/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb.json +++ b/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_mead_must_vanilla_honeycomb_normal.json @@ -19,5 +19,11 @@ "by_product": { "item": "growthcraft_apiary:honey_comb_empty", "count": 1 - } + }, + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary/beverages" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_wax_item.json b/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_wax_item.json index f48a11e6..89ec91ad 100644 --- a/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_wax_item.json +++ b/src/main/resources/data/growthcraft_apiary/recipes/brew_kettle_wax_item.json @@ -19,5 +19,11 @@ "by_product": { "item": "growthcraft_apiary:bees_wax", "count": 1 - } + }, + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary/basic_wax" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_apiary/recipes/fermentation_barrel_honey_mead.json b/src/main/resources/data/growthcraft_apiary/recipes/fermentation_barrel_honey_mead.json index f0380547..628ca4ba 100644 --- a/src/main/resources/data/growthcraft_apiary/recipes/fermentation_barrel_honey_mead.json +++ b/src/main/resources/data/growthcraft_apiary/recipes/fermentation_barrel_honey_mead.json @@ -23,5 +23,11 @@ "bottle": { "item": "growthcraft_cellar:potion_wine" }, - "color": "0xE5C7A2" + "color": "0xE5C7A2", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "apiary/beverages" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_apiary/recipes/mystical_agriculture/mystical_agriculture_bee.json b/src/main/resources/data/growthcraft_apiary/recipes/mystical_agriculture/mystical_agriculture_bee.json index 34324a46..63de8af0 100644 --- a/src/main/resources/data/growthcraft_apiary/recipes/mystical_agriculture/mystical_agriculture_bee.json +++ b/src/main/resources/data/growthcraft_apiary/recipes/mystical_agriculture/mystical_agriculture_bee.json @@ -8,6 +8,10 @@ { "type": "mysticalagriculture:crop_enabled", "crop": "mysticalagriculture:honey" + }, + { + "type": "growthcraft:feature_enabled", + "feature": "apiary" } ], "pattern": [ diff --git a/src/main/resources/data/growthcraft_apples/recipes/mystical_agriculture/mystical_agriculture_apple_log.json b/src/main/resources/data/growthcraft_apples/recipes/mystical_agriculture/mystical_agriculture_apple_log.json index a073954d..868ae897 100644 --- a/src/main/resources/data/growthcraft_apples/recipes/mystical_agriculture/mystical_agriculture_apple_log.json +++ b/src/main/resources/data/growthcraft_apples/recipes/mystical_agriculture/mystical_agriculture_apple_log.json @@ -8,6 +8,10 @@ { "type": "mysticalagriculture:crop_enabled", "crop": "mysticalagriculture:wood" + }, + { + "type": "growthcraft:feature_enabled", + "feature": "apples" } ], "pattern": [ diff --git a/src/main/resources/data/growthcraft_rice/recipes/brew_kettle_rice_water_from_growthcraft_rice.json b/src/main/resources/data/growthcraft_rice/recipes/brew_kettle_rice_water_from_growthcraft_rice.json index 01590a5c..a91c8366 100644 --- a/src/main/resources/data/growthcraft_rice/recipes/brew_kettle_rice_water_from_growthcraft_rice.json +++ b/src/main/resources/data/growthcraft_rice/recipes/brew_kettle_rice_water_from_growthcraft_rice.json @@ -19,5 +19,18 @@ "by_product": { "item": "growthcraft_rice:rice_cooked", "count": 1 - } + }, + "conditions": [ + { + "type": "forge:not", + "value": { + "type": "forge:tag_empty", + "tag": "forge:crops/rice" + } + }, + { + "type": "growthcraft:feature_enabled", + "feature": "rice/beverages" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_rice/recipes/culture_jar_starter_yeast_seishu_from_rice_water.json b/src/main/resources/data/growthcraft_rice/recipes/culture_jar_starter_yeast_seishu_from_rice_water.json index 7dc664a6..21547427 100644 --- a/src/main/resources/data/growthcraft_rice/recipes/culture_jar_starter_yeast_seishu_from_rice_water.json +++ b/src/main/resources/data/growthcraft_rice/recipes/culture_jar_starter_yeast_seishu_from_rice_water.json @@ -9,5 +9,11 @@ "output_item": { "item": "growthcraft_rice:yeast_seishu", "count": 1 - } + }, + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice/beverages" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_rice/recipes/culture_jar_yeast_seishu_from_rice_water.json b/src/main/resources/data/growthcraft_rice/recipes/culture_jar_yeast_seishu_from_rice_water.json index cedd6eaf..96adb760 100644 --- a/src/main/resources/data/growthcraft_rice/recipes/culture_jar_yeast_seishu_from_rice_water.json +++ b/src/main/resources/data/growthcraft_rice/recipes/culture_jar_yeast_seishu_from_rice_water.json @@ -9,5 +9,11 @@ "input_item": { "item": "growthcraft_rice:yeast_seishu", "count": 1 - } + }, + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice/beverages" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_rice/recipes/fermentation_barrel_rice_wine.json b/src/main/resources/data/growthcraft_rice/recipes/fermentation_barrel_rice_wine.json index 26673c5b..7aa604d0 100644 --- a/src/main/resources/data/growthcraft_rice/recipes/fermentation_barrel_rice_wine.json +++ b/src/main/resources/data/growthcraft_rice/recipes/fermentation_barrel_rice_wine.json @@ -23,5 +23,11 @@ "bottle": { "item": "growthcraft_cellar:potion_wine" }, - "color": "0xEAA6D2" + "color": "0xEAA6D2", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice/beverages" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_rice/recipes/fermentation_barrel_sake.json b/src/main/resources/data/growthcraft_rice/recipes/fermentation_barrel_sake.json index 6b686cd7..fa8abad4 100644 --- a/src/main/resources/data/growthcraft_rice/recipes/fermentation_barrel_sake.json +++ b/src/main/resources/data/growthcraft_rice/recipes/fermentation_barrel_sake.json @@ -23,5 +23,11 @@ "bottle": { "item": "growthcraft_cellar:potion_wine" }, - "color": "0xE0E2DC" + "color": "0xE0E2DC", + "conditions": [ + { + "type": "growthcraft:feature_enabled", + "feature": "rice/beverages" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/growthcraft_rice/recipes/mystical_agriculture/mystical_agriculture_rice.json b/src/main/resources/data/growthcraft_rice/recipes/mystical_agriculture/mystical_agriculture_rice.json index e742d82f..1f0c7179 100644 --- a/src/main/resources/data/growthcraft_rice/recipes/mystical_agriculture/mystical_agriculture_rice.json +++ b/src/main/resources/data/growthcraft_rice/recipes/mystical_agriculture/mystical_agriculture_rice.json @@ -8,6 +8,10 @@ { "type": "mysticalagriculture:crop_enabled", "crop": "mysticalagriculture:nature" + }, + { + "type": "growthcraft:feature_enabled", + "feature": "rice" } ], "pattern": [