From db126c959409f9b7d5b8e019bf5717dfbbe96403 Mon Sep 17 00:00:00 2001 From: Waterpicker Date: Sun, 29 Dec 2024 04:19:10 -0600 Subject: [PATCH] Shaderoot and Iceroot drop from carrots. --- .../loot_tables/blocks/calyrex_roots.json | 59 +++++++++ .../minecraft/tags/blocks/mineable/axe.json | 120 +++++++++--------- .../tags/blocks/mineable/pickaxe.json | 40 +++--- .../common/GenerationsCore.java | 17 ++- .../generationscore/common/config/Config.java | 3 +- .../common/config/SpeciesKey.java | 1 + .../world/loot/LootItemConditionTypes.java | 29 +++++ .../common/world/loot/SpeciesKeyCondition.kt | 59 +++++++++ .../generators/loot/GenerationsBlockLoot.java | 9 +- .../generators/loot/GenerationsChestLoot.java | 11 ++ .../generators/loot/LootTableDatagen.java | 40 +++++- 11 files changed, 301 insertions(+), 87 deletions(-) create mode 100644 common/src/main/generated/resources/data/generations_core/loot_tables/blocks/calyrex_roots.json create mode 100644 common/src/main/java/generations/gg/generations/core/generationscore/common/world/loot/LootItemConditionTypes.java create mode 100644 common/src/main/java/generations/gg/generations/core/generationscore/common/world/loot/SpeciesKeyCondition.kt diff --git a/common/src/main/generated/resources/data/generations_core/loot_tables/blocks/calyrex_roots.json b/common/src/main/generated/resources/data/generations_core/loot_tables/blocks/calyrex_roots.json new file mode 100644 index 000000000..e3bbb449f --- /dev/null +++ b/common/src/main/generated/resources/data/generations_core/loot_tables/blocks/calyrex_roots.json @@ -0,0 +1,59 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "generations_core:species_key", + "key": "cobblemon:spectrier" + }, + { + "chance": 0.001, + "condition": "minecraft:random_chance" + }, + { + "block": "minecraft:carrots", + "condition": "minecraft:block_state_property", + "properties": { + "age": "7" + } + } + ], + "name": "generations_core:shaderoot_carrot" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "generations_core:species_key", + "key": "cobblemon:glastrier" + }, + { + "chance": 0.001, + "condition": "minecraft:random_chance" + }, + { + "block": "minecraft:carrots", + "condition": "minecraft:block_state_property", + "properties": { + "age": "7" + } + } + ], + "name": "generations_core:iceroot_carrot" + } + ] + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "generations_core:blocks/calyrex_roots" +} \ No newline at end of file diff --git a/common/src/main/generated/resources/data/minecraft/tags/blocks/mineable/axe.json b/common/src/main/generated/resources/data/minecraft/tags/blocks/mineable/axe.json index a47a6deee..71bd68e93 100644 --- a/common/src/main/generated/resources/data/minecraft/tags/blocks/mineable/axe.json +++ b/common/src/main/generated/resources/data/minecraft/tags/blocks/mineable/axe.json @@ -56,101 +56,101 @@ "generations_core:cursed_carved_pumpkin", "generations_core:scarecrow", "generations_core:box", - "generations_core:orange_couch_arm_left", + "generations_core:yellow_couch_arm_left", + "generations_core:white_couch_arm_left", + "generations_core:light_gray_couch_arm_left", + "generations_core:black_couch_arm_left", "generations_core:light_blue_couch_arm_left", "generations_core:blue_couch_arm_left", - "generations_core:yellow_couch_arm_left", + "generations_core:pink_couch_arm_left", "generations_core:green_couch_arm_left", - "generations_core:light_gray_couch_arm_left", - "generations_core:white_couch_arm_left", + "generations_core:lime_couch_arm_left", + "generations_core:purple_couch_arm_left", + "generations_core:orange_couch_arm_left", "generations_core:red_couch_arm_left", - "generations_core:black_couch_arm_left", - "generations_core:magenta_couch_arm_left", - "generations_core:cyan_couch_arm_left", "generations_core:brown_couch_arm_left", - "generations_core:lime_couch_arm_left", - "generations_core:pink_couch_arm_left", "generations_core:gray_couch_arm_left", - "generations_core:purple_couch_arm_left", - "generations_core:orange_couch_arm_right", + "generations_core:cyan_couch_arm_left", + "generations_core:magenta_couch_arm_left", + "generations_core:yellow_couch_arm_right", + "generations_core:white_couch_arm_right", + "generations_core:light_gray_couch_arm_right", + "generations_core:black_couch_arm_right", "generations_core:light_blue_couch_arm_right", "generations_core:blue_couch_arm_right", - "generations_core:yellow_couch_arm_right", + "generations_core:pink_couch_arm_right", "generations_core:green_couch_arm_right", - "generations_core:light_gray_couch_arm_right", - "generations_core:white_couch_arm_right", + "generations_core:lime_couch_arm_right", + "generations_core:purple_couch_arm_right", + "generations_core:orange_couch_arm_right", "generations_core:red_couch_arm_right", - "generations_core:black_couch_arm_right", - "generations_core:magenta_couch_arm_right", - "generations_core:cyan_couch_arm_right", "generations_core:brown_couch_arm_right", - "generations_core:lime_couch_arm_right", - "generations_core:pink_couch_arm_right", "generations_core:gray_couch_arm_right", - "generations_core:purple_couch_arm_right", - "generations_core:orange_couch_corner_left", + "generations_core:cyan_couch_arm_right", + "generations_core:magenta_couch_arm_right", + "generations_core:yellow_couch_corner_left", + "generations_core:white_couch_corner_left", + "generations_core:light_gray_couch_corner_left", + "generations_core:black_couch_corner_left", "generations_core:light_blue_couch_corner_left", "generations_core:blue_couch_corner_left", - "generations_core:yellow_couch_corner_left", + "generations_core:pink_couch_corner_left", "generations_core:green_couch_corner_left", - "generations_core:light_gray_couch_corner_left", - "generations_core:white_couch_corner_left", + "generations_core:lime_couch_corner_left", + "generations_core:purple_couch_corner_left", + "generations_core:orange_couch_corner_left", "generations_core:red_couch_corner_left", - "generations_core:black_couch_corner_left", - "generations_core:magenta_couch_corner_left", - "generations_core:cyan_couch_corner_left", "generations_core:brown_couch_corner_left", - "generations_core:lime_couch_corner_left", - "generations_core:pink_couch_corner_left", "generations_core:gray_couch_corner_left", - "generations_core:purple_couch_corner_left", - "generations_core:orange_couch_corner_right", + "generations_core:cyan_couch_corner_left", + "generations_core:magenta_couch_corner_left", + "generations_core:yellow_couch_corner_right", + "generations_core:white_couch_corner_right", + "generations_core:light_gray_couch_corner_right", + "generations_core:black_couch_corner_right", "generations_core:light_blue_couch_corner_right", "generations_core:blue_couch_corner_right", - "generations_core:yellow_couch_corner_right", + "generations_core:pink_couch_corner_right", "generations_core:green_couch_corner_right", - "generations_core:light_gray_couch_corner_right", - "generations_core:white_couch_corner_right", + "generations_core:lime_couch_corner_right", + "generations_core:purple_couch_corner_right", + "generations_core:orange_couch_corner_right", "generations_core:red_couch_corner_right", - "generations_core:black_couch_corner_right", - "generations_core:magenta_couch_corner_right", - "generations_core:cyan_couch_corner_right", "generations_core:brown_couch_corner_right", - "generations_core:lime_couch_corner_right", - "generations_core:pink_couch_corner_right", "generations_core:gray_couch_corner_right", - "generations_core:purple_couch_corner_right", - "generations_core:orange_couch_middle", + "generations_core:cyan_couch_corner_right", + "generations_core:magenta_couch_corner_right", + "generations_core:yellow_couch_middle", + "generations_core:white_couch_middle", + "generations_core:light_gray_couch_middle", + "generations_core:black_couch_middle", "generations_core:light_blue_couch_middle", "generations_core:blue_couch_middle", - "generations_core:yellow_couch_middle", + "generations_core:pink_couch_middle", "generations_core:green_couch_middle", - "generations_core:light_gray_couch_middle", - "generations_core:white_couch_middle", + "generations_core:lime_couch_middle", + "generations_core:purple_couch_middle", + "generations_core:orange_couch_middle", "generations_core:red_couch_middle", - "generations_core:black_couch_middle", - "generations_core:magenta_couch_middle", - "generations_core:cyan_couch_middle", "generations_core:brown_couch_middle", - "generations_core:lime_couch_middle", - "generations_core:pink_couch_middle", "generations_core:gray_couch_middle", - "generations_core:purple_couch_middle", - "generations_core:orange_couch_ottoman", + "generations_core:cyan_couch_middle", + "generations_core:magenta_couch_middle", + "generations_core:yellow_couch_ottoman", + "generations_core:white_couch_ottoman", + "generations_core:light_gray_couch_ottoman", + "generations_core:black_couch_ottoman", "generations_core:light_blue_couch_ottoman", "generations_core:blue_couch_ottoman", - "generations_core:yellow_couch_ottoman", + "generations_core:pink_couch_ottoman", "generations_core:green_couch_ottoman", - "generations_core:light_gray_couch_ottoman", - "generations_core:white_couch_ottoman", + "generations_core:lime_couch_ottoman", + "generations_core:purple_couch_ottoman", + "generations_core:orange_couch_ottoman", "generations_core:red_couch_ottoman", - "generations_core:black_couch_ottoman", - "generations_core:magenta_couch_ottoman", - "generations_core:cyan_couch_ottoman", "generations_core:brown_couch_ottoman", - "generations_core:lime_couch_ottoman", - "generations_core:pink_couch_ottoman", "generations_core:gray_couch_ottoman", - "generations_core:purple_couch_ottoman" + "generations_core:cyan_couch_ottoman", + "generations_core:magenta_couch_ottoman" ] } \ No newline at end of file diff --git a/common/src/main/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/common/src/main/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json index 8cef2772f..c06cb240f 100644 --- a/common/src/main/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/common/src/main/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -802,38 +802,38 @@ "generations_core:pink_elevator", "generations_core:desk", "generations_core:fridge", - "generations_core:orange_street_lamp", + "generations_core:yellow_street_lamp", + "generations_core:white_street_lamp", + "generations_core:light_gray_street_lamp", + "generations_core:black_street_lamp", "generations_core:light_blue_street_lamp", "generations_core:blue_street_lamp", - "generations_core:yellow_street_lamp", + "generations_core:pink_street_lamp", "generations_core:green_street_lamp", - "generations_core:light_gray_street_lamp", - "generations_core:white_street_lamp", + "generations_core:lime_street_lamp", + "generations_core:purple_street_lamp", + "generations_core:orange_street_lamp", "generations_core:red_street_lamp", - "generations_core:black_street_lamp", - "generations_core:magenta_street_lamp", - "generations_core:cyan_street_lamp", "generations_core:brown_street_lamp", - "generations_core:lime_street_lamp", - "generations_core:pink_street_lamp", "generations_core:gray_street_lamp", - "generations_core:purple_street_lamp", - "generations_core:orange_pc", + "generations_core:cyan_street_lamp", + "generations_core:magenta_street_lamp", + "generations_core:yellow_pc", + "generations_core:white_pc", + "generations_core:light_gray_pc", + "generations_core:black_pc", "generations_core:light_blue_pc", "generations_core:blue_pc", - "generations_core:yellow_pc", + "generations_core:pink_pc", "generations_core:green_pc", - "generations_core:light_gray_pc", - "generations_core:white_pc", + "generations_core:lime_pc", + "generations_core:purple_pc", + "generations_core:orange_pc", "generations_core:red_pc", - "generations_core:black_pc", - "generations_core:magenta_pc", - "generations_core:cyan_pc", "generations_core:brown_pc", - "generations_core:lime_pc", - "generations_core:pink_pc", "generations_core:gray_pc", - "generations_core:purple_pc", + "generations_core:cyan_pc", + "generations_core:magenta_pc", "generations_core:empty_ball_display", "generations_core:poke_ball_display", "generations_core:great_ball_display", diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/GenerationsCore.java b/common/src/main/java/generations/gg/generations/core/generationscore/common/GenerationsCore.java index 421030a27..97f8281d1 100644 --- a/common/src/main/java/generations/gg/generations/core/generationscore/common/GenerationsCore.java +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/GenerationsCore.java @@ -23,6 +23,7 @@ import generations.gg.generations.core.generationscore.common.client.render.rarecandy.ModelRegistry; import generations.gg.generations.core.generationscore.common.config.Config; import generations.gg.generations.core.generationscore.common.config.ConfigLoader; +import generations.gg.generations.core.generationscore.common.config.LegendKeys; import generations.gg.generations.core.generationscore.common.recipe.GenerationsIngredidents; import generations.gg.generations.core.generationscore.common.world.container.GenerationsContainers; import generations.gg.generations.core.generationscore.common.world.entity.GenerationsEntities; @@ -34,7 +35,9 @@ import generations.gg.generations.core.generationscore.common.world.item.legends.EnchantableItem; import generations.gg.generations.core.generationscore.common.world.level.block.*; import generations.gg.generations.core.generationscore.common.world.level.block.entities.GenerationsBlockEntities; +import generations.gg.generations.core.generationscore.common.world.loot.LootItemConditionTypes; import generations.gg.generations.core.generationscore.common.world.loot.LootPoolEntryTypes; +import generations.gg.generations.core.generationscore.common.world.loot.SpeciesKeyCondition; import generations.gg.generations.core.generationscore.common.world.recipe.*; import generations.gg.generations.core.generationscore.common.world.sound.GenerationsSounds; import generations.gg.generations.core.generationscore.common.world.spawning.ZygardeCellDetail; @@ -44,10 +47,19 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.packs.PackType; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.world.level.storage.loot.*; +import net.minecraft.world.level.storage.loot.entries.AlternativesEntry; +import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.entries.LootTableReference; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; +import net.minecraft.world.level.storage.loot.predicates.LootItemEntityPropertyCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; +import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import org.apache.logging.log4j.util.TriConsumer; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -89,7 +101,9 @@ public static void init(GenerationsImplementation implementation) { if(id.getNamespace().equals("minecraft") && id.getPath().contains("chests") && !id.getPath().contains("inject")) { var inject = new ResourceLocation(id.getNamespace(), id.getPath().replace("chests", "chests/inject")); context.addPool(LootPool.lootPool().add(LootTableReference.lootTableReference(inject))); - } + } else if(id.toString().equals("minecraft:blocks/carrots")) { + context.addPool(LootPool.lootPool().add(LootTableReference.lootTableReference(GenerationsCore.id("blocks/calyrex_roots")))); + } }); SpawnDetail.Companion.registerSpawnType(ZygardeCellDetail.TYPE, ZygardeCellDetail.class); @@ -102,6 +116,7 @@ public static void init(GenerationsImplementation implementation) { GenerationsOres.init(); GenerationsDecorationBlocks.init(); LootPoolEntryTypes.init(); + LootItemConditionTypes.init(); GenerationsUtilityBlocks.init(); GenerationsShrines.init(); GenerationsItems.init(); diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/config/Config.java b/common/src/main/java/generations/gg/generations/core/generationscore/common/config/Config.java index 27d5246e0..56779bbde 100644 --- a/common/src/main/java/generations/gg/generations/core/generationscore/common/config/Config.java +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/config/Config.java @@ -82,7 +82,8 @@ public static class Caught { .setCount(TAPU_LELE, 1) .setCount(TAPU_BULU, 1) .setCount(TAPU_FINI, 1) - + .setCount(GLASTRIER, 1) + .setCount(SPECTRIER, 1) .build(); public boolean capped(Player player, SpeciesKey speciesKey) { diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/config/SpeciesKey.java b/common/src/main/java/generations/gg/generations/core/generationscore/common/config/SpeciesKey.java index 85f978c90..b8c09215e 100644 --- a/common/src/main/java/generations/gg/generations/core/generationscore/common/config/SpeciesKey.java +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/config/SpeciesKey.java @@ -5,6 +5,7 @@ import com.cobblemon.mod.common.pokemon.Species; import generations.gg.generations.core.generationscore.common.GenerationsCore; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import org.jetbrains.annotations.NotNull; import java.util.Arrays; diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/loot/LootItemConditionTypes.java b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/loot/LootItemConditionTypes.java new file mode 100644 index 000000000..5c798ddc2 --- /dev/null +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/loot/LootItemConditionTypes.java @@ -0,0 +1,29 @@ +package generations.gg.generations.core.generationscore.common.world.loot; + +import dev.architectury.registry.registries.DeferredRegister; +import dev.architectury.registry.registries.RegistrySupplier; +import generations.gg.generations.core.generationscore.common.GenerationsCore; +import generations.gg.generations.core.generationscore.common.config.SpeciesKey; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.level.storage.loot.Serializer; +import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer; +import net.minecraft.world.level.storage.loot.entries.LootPoolEntryType; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; + +import java.util.function.Supplier; + +public class LootItemConditionTypes { + public static final DeferredRegister REGISTER = DeferredRegister.create(GenerationsCore.MOD_ID, Registries.LOOT_CONDITION_TYPE); + + public static RegistrySupplier register(String name, Supplier> supplier) { + return REGISTER.register(name, () -> new LootItemConditionType(supplier.get())); + } + + public static final RegistrySupplier SPECIES_KEY = register("species_key", SpeciesKeyCondition.Serializer::new); + + public static void init() { + REGISTER.register(); + } + +} diff --git a/common/src/main/java/generations/gg/generations/core/generationscore/common/world/loot/SpeciesKeyCondition.kt b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/loot/SpeciesKeyCondition.kt new file mode 100644 index 000000000..ec3906a8a --- /dev/null +++ b/common/src/main/java/generations/gg/generations/core/generationscore/common/world/loot/SpeciesKeyCondition.kt @@ -0,0 +1,59 @@ +package generations.gg.generations.core.generationscore.common.world.loot + +import com.google.gson.JsonDeserializationContext +import com.google.gson.JsonObject +import com.google.gson.JsonSerializationContext +import generations.gg.generations.core.generationscore.common.GenerationsCore +import generations.gg.generations.core.generationscore.common.config.SpeciesKey +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.level.storage.loot.LootContext +import net.minecraft.world.level.storage.loot.Serializer +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 + +@JvmRecord +data class SpeciesKeyCondition(val key: SpeciesKey) : LootItemCondition { + override fun getType(): LootItemConditionType { + return LootItemConditionTypes.SPECIES_KEY.get() + } + + override fun test(lootContext: LootContext): Boolean { + val entity = lootContext.getParamOrNull(LootContextParams.THIS_ENTITY) + + if (entity is ServerPlayer) { + return GenerationsCore.CONFIG.caught.capped(entity, key) + } else { + return false + } + } + + class Serializer : net.minecraft.world.level.storage.loot.Serializer { + override fun serialize( + json: JsonObject, + value: SpeciesKeyCondition, + serializationContext: JsonSerializationContext, + ) { + json.addProperty("key", value.key.toString()) + } + + override fun deserialize( + json: JsonObject, + serializationContext: JsonDeserializationContext, + ): SpeciesKeyCondition = json.getAsString("key").let { SpeciesKey.fromString(it) }.let { SpeciesKeyCondition(it) } + } + + public class Builder : LootItemCondition.Builder { + lateinit var key: SpeciesKey + fun key(key: SpeciesKey): Builder { + this.key = key + return this + } + override fun build(): LootItemCondition { + return SpeciesKeyCondition(key) + } + + } +} + +private fun JsonObject.getAsString(name: String) = this.getAsJsonPrimitive(name).asString diff --git a/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/GenerationsBlockLoot.java b/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/GenerationsBlockLoot.java index e13c41586..48ab6a0e2 100644 --- a/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/GenerationsBlockLoot.java +++ b/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/GenerationsBlockLoot.java @@ -2,6 +2,7 @@ import com.cobblemon.mod.common.CobblemonItems; import dev.architectury.registry.registries.RegistrySupplier; +import generations.gg.generations.core.generationscore.common.config.LegendKeys; import generations.gg.generations.core.generationscore.common.world.item.GenerationsItems; import generations.gg.generations.core.generationscore.common.world.level.block.*; import generations.gg.generations.core.generationscore.common.world.level.block.generic.GenericRotatableModelBlock; @@ -10,6 +11,7 @@ import generations.gg.generations.core.generationscore.common.world.level.block.set.GenerationsOreSet; import generations.gg.generations.core.generationscore.common.world.level.block.set.GenerationsUltraBlockSet; import generations.gg.generations.core.generationscore.common.world.level.block.shrines.PrisonBottleStemBlock; +import generations.gg.generations.core.generationscore.common.world.loot.SpeciesKeyCondition; import generations.gg.generations.core.generationscore.forge.datagen.generators.blocks.BlockDatagen; import net.minecraft.advancements.critereon.StatePropertiesPredicate; import net.minecraft.data.loot.BlockLootSubProvider; @@ -17,17 +19,16 @@ import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.Item; import net.minecraft.world.item.enchantment.Enchantments; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.DoorBlock; -import net.minecraft.world.level.block.InfestedBlock; -import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.storage.loot.BuiltInLootTables; import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.entries.AlternativesEntry; import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.functions.ApplyBonusCount; import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction; import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; import net.minecraftforge.registries.ForgeRegistries; diff --git a/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/GenerationsChestLoot.java b/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/GenerationsChestLoot.java index f109b4806..a18934a71 100644 --- a/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/GenerationsChestLoot.java +++ b/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/GenerationsChestLoot.java @@ -2,17 +2,26 @@ import dev.architectury.registry.registries.RegistrySupplier; import generations.gg.generations.core.generationscore.common.GenerationsCore; +import generations.gg.generations.core.generationscore.common.config.LegendKeys; +import generations.gg.generations.core.generationscore.common.world.item.GenerationsItems; import generations.gg.generations.core.generationscore.common.world.loot.ResouceKeyEntry; +import generations.gg.generations.core.generationscore.common.world.loot.SpeciesKeyCondition; +import net.minecraft.advancements.critereon.StatePropertiesPredicate; import net.minecraft.core.registries.Registries; import net.minecraft.data.loot.LootTableSubProvider; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.CropBlock; import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.entries.AlternativesEntry; import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.entries.LootPoolSingletonContainer; +import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import net.minecraft.world.level.storage.loot.providers.number.NumberProvider; import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; @@ -65,6 +74,8 @@ class GenerationsChestLoot implements LootTableSubProvider { private static final ResourceLocation TIMER_BALL = GenerationsCore.id("chests/timer_ball"); private static final ResourceLocation ULTRA_BALL = GenerationsCore.id("chests/ultra_ball"); private static final ResourceLocation WING_BALL = GenerationsCore.id("chests/wing_ball"); + public static final ResourceLocation CALYREX_ROOTS = GenerationsCore.id("blocks/calyrex_roots"); + @Override public void generate(@NotNull BiConsumer output) { //output.accept(BuiltInLootTables.ABANDONED_MINESHAFT, LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)).name(GenerationsCore.id("chests/heavy_ball").toString()))); diff --git a/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/LootTableDatagen.java b/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/LootTableDatagen.java index 6b7c9d6c2..4f2082fd1 100644 --- a/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/LootTableDatagen.java +++ b/forge/src/main/java/generations/gg/generations/core/generationscore/forge/datagen/generators/loot/LootTableDatagen.java @@ -2,18 +2,56 @@ import com.google.common.collect.ImmutableList; import generations.gg.generations.core.generationscore.common.GenerationsCore; +import generations.gg.generations.core.generationscore.common.config.LegendKeys; +import generations.gg.generations.core.generationscore.common.world.item.GenerationsItems; +import generations.gg.generations.core.generationscore.common.world.loot.SpeciesKeyCondition; +import net.minecraft.advancements.critereon.StatePropertiesPredicate; import net.minecraft.data.PackOutput; import net.minecraft.data.loot.LootTableProvider; +import net.minecraft.data.loot.LootTableSubProvider; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.entries.AlternativesEntry; +import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; +import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; +import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.Supplier; + +import static generations.gg.generations.core.generationscore.forge.datagen.generators.loot.GenerationsChestLoot.CALYREX_ROOTS; public class LootTableDatagen extends LootTableProvider { public LootTableDatagen(PackOutput output) { super(output, Set.of(), ImmutableList.of( new SubProviderEntry(GenerationsBlockLoot::new, LootContextParamSets.BLOCK), - new SubProviderEntry(GenerationsChestLoot::new, LootContextParamSets.CHEST) + new SubProviderEntry(GenerationsChestLoot::new, LootContextParamSets.CHEST), + new SubProviderEntry(() -> op -> op.accept(CALYREX_ROOTS, LootTable.lootTable().withPool(LootPool.lootPool() + .setRolls(ConstantValue.exactly(1)) + .add( + AlternativesEntry.alternatives( + LootItem.lootTableItem(GenerationsItems.SHADEROOT_CARROT.get()) + .when(new SpeciesKeyCondition.Builder().key(LegendKeys.SPECTRIER)) + .when(LootItemRandomChanceCondition.randomChance(0.001f)) + .when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.CARROTS) + .setProperties(StatePropertiesPredicate.Builder.properties() + .hasProperty(CropBlock.AGE, 7))), + LootItem.lootTableItem(GenerationsItems.ICEROOT_CARROT.get()) + .when(new SpeciesKeyCondition.Builder().key(LegendKeys.GLASTRIER)) + .when(LootItemRandomChanceCondition.randomChance(0.001f)) + .when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.CARROTS) + .setProperties(StatePropertiesPredicate.Builder.properties() + .hasProperty(CropBlock.AGE, 7))) + ) + ) + )), LootContextParamSets.BLOCK) // Pair.of(ChestLoot::new, LootContextParamSets.CHEST), // Pair.of(EntityLoot::new, LootContextParamSets.ENTITY), // Pair.of(PiglinBarterLoot::new, LootContextParamSets.PIGLIN_BARTER),