diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 629b0ca2..2be77bdb 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -1,4 +1,8 @@ eaf9ea781f5220889d762b91e1267309994f1634 data/forge/tags/items/bookshelves.json +3088ccc19c30daf124b3795ff65ba77605a95cea data/forge/tags/items/lingering_bottles.json +f5dc7e8c8dd318fce50ee36315076b34ecaf4d07 data/forge/tags/items/splash_bottles.json +f6375af75aa7a5e3da90bb1ee1af92443bf60456 data/inspirations/advancements/recipes/brewing/recipes/cauldron/potion/lingering_bottle.json +6d0a7b30a3a2a3b282d8b9a02bbb56f4cd4ed464 data/inspirations/advancements/recipes/brewing/recipes/cauldron/potion/splash_bottle.json 7279248197a56ff412d8a80fd981ed6c021d16b6 data/inspirations/advancements/recipes/building_blocks/building/mulch/black.json ebecb02211e59e8ed475caeae6dc5bdfbd66206b data/inspirations/advancements/recipes/building_blocks/building/mulch/blue.json d981441c4b29a75e92e33bab9f6ebee026cea21f data/inspirations/advancements/recipes/building_blocks/building/mulch/brown.json @@ -86,6 +90,13 @@ b9010ec1e26acf04ccbb3a7a122fbd5874f6f087 data/inspirations/advancements/recipes/ f08cd1437741421130a7937fcf59f9581fc5cb6e data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potato_soup/fill_bowl.json 9735ec5ccd7939a23975b42b0088d8559b1f4620 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potato_soup/stew_large.json 9180848560d143f76a49b4d6361bafce00b6cf29 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potato_soup/stew_small.json +b94d4ebfe6caac455ed26e1e509d5a484c48e747 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/lingering_empty.json +201b988649fbf9d9067bfc7d7f522bf7009d6726 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/lingering_fill.json +cd55675de03a5ab74f198d74976afc957dd55fbd data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/normal_empty.json +d36129581391dc083d7061f6f981cd155f96dd91 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/normal_fill.json +50f957e7802ea60f4f0a0fba06404cec70454c08 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/splash_empty.json +a58eb8c6f7edc206d86a81595a5cfcd96c123b67 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/splash_fill.json +e976a2112852c14b09e56aa3e98fc8b425c33252 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/tipped_arrow.json 210cfb462de45158e288e671965cc15ff04b6af2 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/rabbit_stew/empty_bowl.json 87f388997184b6119f0c587b0837b6055c5ed461 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/rabbit_stew/fill_bowl.json bbbb91bd5f75332abff0f00a3df6f419a1dfcc59 data/inspirations/advancements/recipes/cauldron/recipes/cauldron/rabbit_stew/stew_large.json @@ -416,6 +427,15 @@ c56b9b6571bce9b432e1d895f992f7704264e2aa data/inspirations/recipes/recipes/cauld 55b751b5237c3c8dbe171f55604e7c7a94df5923 data/inspirations/recipes/recipes/cauldron/potato_soup/item.json 5c712884b3d032ee7763ea4058017d676380b666 data/inspirations/recipes/recipes/cauldron/potato_soup/stew_large.json 9b94bd430988d108d41d966db905382d9d0e7564 data/inspirations/recipes/recipes/cauldron/potato_soup/stew_small.json +c9de2e3800af3d019d81be1eace6d08e6deb7195 data/inspirations/recipes/recipes/cauldron/potion/lingering_bottle.json +3c4d644f1f1072d8a9ada2ff147de2b0bcf15354 data/inspirations/recipes/recipes/cauldron/potion/lingering_empty.json +d9c611348b17634f9ea886a154104241a274db34 data/inspirations/recipes/recipes/cauldron/potion/lingering_fill.json +47424706c9c3dd50cc12453931821682d18a9f5c data/inspirations/recipes/recipes/cauldron/potion/normal_empty.json +49b05c1a42d06cfe853c8519028b6cfe07c2b8d9 data/inspirations/recipes/recipes/cauldron/potion/normal_fill.json +f8323b474fafb97b99f72e735540059420e4daf3 data/inspirations/recipes/recipes/cauldron/potion/splash_bottle.json +19f63976122e48ba4c58d5966fc3e3f88ba2633b data/inspirations/recipes/recipes/cauldron/potion/splash_empty.json +c7e3e2f5fd5b1366c14b1877727c3ba4e2e3dde6 data/inspirations/recipes/recipes/cauldron/potion/splash_fill.json +428ab43caf3f63b0d89be0a41282c6a77872fcad data/inspirations/recipes/recipes/cauldron/potion/tipped_arrow.json 7a8180559d3948ba9cdf3f90f1f9ba75ca9e6628 data/inspirations/recipes/recipes/cauldron/rabbit_stew/empty_bowl.json aad3506b0cc731722e532198acdb319c5435efa4 data/inspirations/recipes/recipes/cauldron/rabbit_stew/fill_bowl.json 58afa39737eecfe66d86f840732217ca757c6b05 data/inspirations/recipes/recipes/cauldron/rabbit_stew/stew_large.json diff --git a/src/generated/resources/data/forge/tags/items/lingering_bottles.json b/src/generated/resources/data/forge/tags/items/lingering_bottles.json new file mode 100644 index 00000000..03c0b31a --- /dev/null +++ b/src/generated/resources/data/forge/tags/items/lingering_bottles.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "inspirations:lingering_bottle" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/forge/tags/items/splash_bottles.json b/src/generated/resources/data/forge/tags/items/splash_bottles.json new file mode 100644 index 00000000..e53a6842 --- /dev/null +++ b/src/generated/resources/data/forge/tags/items/splash_bottles.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "inspirations:splash_bottle" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/advancements/recipes/brewing/recipes/cauldron/potion/lingering_bottle.json b/src/generated/resources/data/inspirations/advancements/recipes/brewing/recipes/cauldron/potion/lingering_bottle.json new file mode 100644 index 00000000..266378b7 --- /dev/null +++ b/src/generated/resources/data/inspirations/advancements/recipes/brewing/recipes/cauldron/potion/lingering_bottle.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "inspirations:recipes/cauldron/potion/lingering_bottle" + ] + }, + "criteria": { + "has_item": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "minecraft:dragon_breath" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "inspirations:recipes/cauldron/potion/lingering_bottle" + } + } + }, + "requirements": [ + [ + "has_item", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/advancements/recipes/brewing/recipes/cauldron/potion/splash_bottle.json b/src/generated/resources/data/inspirations/advancements/recipes/brewing/recipes/cauldron/potion/splash_bottle.json new file mode 100644 index 00000000..ed370e99 --- /dev/null +++ b/src/generated/resources/data/inspirations/advancements/recipes/brewing/recipes/cauldron/potion/splash_bottle.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "inspirations:recipes/cauldron/potion/splash_bottle" + ] + }, + "criteria": { + "has_item": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "tag": "forge:gunpowder" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "inspirations:recipes/cauldron/potion/splash_bottle" + } + } + }, + "requirements": [ + [ + "has_item", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/lingering_empty.json b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/lingering_empty.json new file mode 100644 index 00000000..e8ba542f --- /dev/null +++ b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/lingering_empty.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "inspirations:recipes/cauldron/potion/lingering_empty" + ] + }, + "criteria": { + "has_item": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "minecraft:lingering_potion" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "inspirations:recipes/cauldron/potion/lingering_empty" + } + } + }, + "requirements": [ + [ + "has_item", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/lingering_fill.json b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/lingering_fill.json new file mode 100644 index 00000000..20726fa4 --- /dev/null +++ b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/lingering_fill.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "inspirations:recipes/cauldron/potion/lingering_fill" + ] + }, + "criteria": { + "has_item": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "tag": "forge:lingering_bottles" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "inspirations:recipes/cauldron/potion/lingering_fill" + } + } + }, + "requirements": [ + [ + "has_item", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/normal_empty.json b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/normal_empty.json new file mode 100644 index 00000000..0b7d44cb --- /dev/null +++ b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/normal_empty.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "inspirations:recipes/cauldron/potion/normal_empty" + ] + }, + "criteria": { + "has_item": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "minecraft:potion" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "inspirations:recipes/cauldron/potion/normal_empty" + } + } + }, + "requirements": [ + [ + "has_item", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/normal_fill.json b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/normal_fill.json new file mode 100644 index 00000000..a864204c --- /dev/null +++ b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/normal_fill.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "inspirations:recipes/cauldron/potion/normal_fill" + ] + }, + "criteria": { + "has_item": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "minecraft:glass_bottle" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "inspirations:recipes/cauldron/potion/normal_fill" + } + } + }, + "requirements": [ + [ + "has_item", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/splash_empty.json b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/splash_empty.json new file mode 100644 index 00000000..74aea387 --- /dev/null +++ b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/splash_empty.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "inspirations:recipes/cauldron/potion/splash_empty" + ] + }, + "criteria": { + "has_item": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "minecraft:splash_potion" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "inspirations:recipes/cauldron/potion/splash_empty" + } + } + }, + "requirements": [ + [ + "has_item", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/splash_fill.json b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/splash_fill.json new file mode 100644 index 00000000..fc873dae --- /dev/null +++ b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/splash_fill.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "inspirations:recipes/cauldron/potion/splash_fill" + ] + }, + "criteria": { + "has_item": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "tag": "forge:splash_bottles" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "inspirations:recipes/cauldron/potion/splash_fill" + } + } + }, + "requirements": [ + [ + "has_item", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/tipped_arrow.json b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/tipped_arrow.json new file mode 100644 index 00000000..1b3566cb --- /dev/null +++ b/src/generated/resources/data/inspirations/advancements/recipes/cauldron/recipes/cauldron/potion/tipped_arrow.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "inspirations:recipes/cauldron/potion/tipped_arrow" + ] + }, + "criteria": { + "has_item": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "minecraft:arrow" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "inspirations:recipes/cauldron/potion/tipped_arrow" + } + } + }, + "requirements": [ + [ + "has_item", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/lingering_bottle.json b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/lingering_bottle.json new file mode 100644 index 00000000..c049f263 --- /dev/null +++ b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/lingering_bottle.json @@ -0,0 +1,30 @@ +{ + "type": "minecraft:crafting_shapeless", + "conditions": [ + { + "prop": "recipes_module", + "type": "inspirations:config" + }, + { + "prop": "cauldron_potions", + "type": "inspirations:config" + } + ], + "ingredients": [ + { + "tag": "forge:splash_bottles" + }, + { + "tag": "forge:splash_bottles" + }, + { + "tag": "forge:splash_bottles" + }, + { + "item": "minecraft:dragon_breath" + } + ], + "result": { + "item": "inspirations:lingering_bottle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/lingering_empty.json b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/lingering_empty.json new file mode 100644 index 00000000..82a11004 --- /dev/null +++ b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/lingering_empty.json @@ -0,0 +1,15 @@ +{ + "type": "inspirations:cauldron_empty_potion", + "conditions": [ + { + "prop": "recipes_module", + "type": "inspirations:config" + }, + { + "prop": "cauldron_potions", + "type": "inspirations:config" + } + ], + "potion": "minecraft:lingering_potion", + "bottle": "inspirations:lingering_bottle" +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/lingering_fill.json b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/lingering_fill.json new file mode 100644 index 00000000..3395679a --- /dev/null +++ b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/lingering_fill.json @@ -0,0 +1,17 @@ +{ + "type": "inspirations:cauldron_fill_potion", + "conditions": [ + { + "prop": "recipes_module", + "type": "inspirations:config" + }, + { + "prop": "cauldron_potions", + "type": "inspirations:config" + } + ], + "bottle": { + "tag": "forge:lingering_bottles" + }, + "potion": "minecraft:lingering_potion" +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/normal_empty.json b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/normal_empty.json new file mode 100644 index 00000000..06893d57 --- /dev/null +++ b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/normal_empty.json @@ -0,0 +1,15 @@ +{ + "type": "inspirations:cauldron_empty_potion", + "conditions": [ + { + "prop": "recipes_module", + "type": "inspirations:config" + }, + { + "prop": "cauldron_potions", + "type": "inspirations:config" + } + ], + "potion": "minecraft:potion", + "bottle": "minecraft:glass_bottle" +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/normal_fill.json b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/normal_fill.json new file mode 100644 index 00000000..22c5011f --- /dev/null +++ b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/normal_fill.json @@ -0,0 +1,17 @@ +{ + "type": "inspirations:cauldron_fill_potion", + "conditions": [ + { + "prop": "recipes_module", + "type": "inspirations:config" + }, + { + "prop": "cauldron_potions", + "type": "inspirations:config" + } + ], + "bottle": { + "item": "minecraft:glass_bottle" + }, + "potion": "minecraft:potion" +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/splash_bottle.json b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/splash_bottle.json new file mode 100644 index 00000000..7c648fae --- /dev/null +++ b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/splash_bottle.json @@ -0,0 +1,30 @@ +{ + "type": "minecraft:crafting_shapeless", + "conditions": [ + { + "prop": "recipes_module", + "type": "inspirations:config" + }, + { + "prop": "cauldron_potions", + "type": "inspirations:config" + } + ], + "ingredients": [ + { + "item": "minecraft:glass_bottle" + }, + { + "item": "minecraft:glass_bottle" + }, + { + "item": "minecraft:glass_bottle" + }, + { + "tag": "forge:gunpowder" + } + ], + "result": { + "item": "inspirations:splash_bottle" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/splash_empty.json b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/splash_empty.json new file mode 100644 index 00000000..900248cf --- /dev/null +++ b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/splash_empty.json @@ -0,0 +1,15 @@ +{ + "type": "inspirations:cauldron_empty_potion", + "conditions": [ + { + "prop": "recipes_module", + "type": "inspirations:config" + }, + { + "prop": "cauldron_potions", + "type": "inspirations:config" + } + ], + "potion": "minecraft:splash_potion", + "bottle": "inspirations:splash_bottle" +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/splash_fill.json b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/splash_fill.json new file mode 100644 index 00000000..a878f17a --- /dev/null +++ b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/splash_fill.json @@ -0,0 +1,17 @@ +{ + "type": "inspirations:cauldron_fill_potion", + "conditions": [ + { + "prop": "recipes_module", + "type": "inspirations:config" + }, + { + "prop": "cauldron_potions", + "type": "inspirations:config" + } + ], + "bottle": { + "tag": "forge:splash_bottles" + }, + "potion": "minecraft:splash_potion" +} \ No newline at end of file diff --git a/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/tipped_arrow.json b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/tipped_arrow.json new file mode 100644 index 00000000..a5892974 --- /dev/null +++ b/src/generated/resources/data/inspirations/recipes/recipes/cauldron/potion/tipped_arrow.json @@ -0,0 +1,18 @@ +{ + "type": "inspirations:cauldron_fill_potion", + "conditions": [ + { + "prop": "recipes_module", + "type": "inspirations:config" + }, + { + "prop": "cauldron_potions", + "type": "inspirations:config" + } + ], + "bottle": { + "item": "minecraft:arrow" + }, + "amount": 16, + "potion": "minecraft:tipped_arrow" +} \ No newline at end of file diff --git a/src/main/java/knightminer/inspirations/common/datagen/InspirationsItemTagsProvider.java b/src/main/java/knightminer/inspirations/common/datagen/InspirationsItemTagsProvider.java index a7257d06..98c2acf6 100644 --- a/src/main/java/knightminer/inspirations/common/datagen/InspirationsItemTagsProvider.java +++ b/src/main/java/knightminer/inspirations/common/datagen/InspirationsItemTagsProvider.java @@ -3,6 +3,7 @@ import knightminer.inspirations.Inspirations; import knightminer.inspirations.building.InspirationsBuilding; import knightminer.inspirations.library.InspirationsTags; +import knightminer.inspirations.recipes.InspirationsRecipes; import knightminer.inspirations.tools.InspirationsTools; import net.minecraft.data.BlockTagsProvider; import net.minecraft.data.DataGenerator; @@ -71,6 +72,9 @@ private void registerInspTags() { private void registerForgeTags() { this.getOrCreateBuilder(Tags.Items.BOOKSHELVES).addTag(InspirationsTags.Items.BOOKSHELVES); + this.getOrCreateBuilder(InspirationsTags.Items.SPLASH_BOTTLES).add(InspirationsRecipes.splashBottle); + this.getOrCreateBuilder(InspirationsTags.Items.LINGERING_BOTTLES).add(InspirationsRecipes.lingeringBottle); + /* for(DyeColor color : DyeColor.values()) { INamedTag tag = ItemTags.makeWrapperTag("forge:dyes/" + color.getString()); diff --git a/src/main/java/knightminer/inspirations/library/InspirationsTags.java b/src/main/java/knightminer/inspirations/library/InspirationsTags.java index e8b53b65..1e955b94 100644 --- a/src/main/java/knightminer/inspirations/library/InspirationsTags.java +++ b/src/main/java/knightminer/inspirations/library/InspirationsTags.java @@ -63,11 +63,18 @@ public static class Items { public static final INamedTag WAYPOINT_COMPASSES = tag("waypoint_compasses"); public static final INamedTag DYE_BOTTLES = tag("dyed_water_bottles"); + /* Inputs for potion cauldron recipes */ + public static final INamedTag SPLASH_BOTTLES = forgeTag("splash_bottles"); + public static final INamedTag LINGERING_BOTTLES = forgeTag("lingering_bottles"); + /** * Creates an item tag for Inspirations */ private static INamedTag tag(String name) { return ItemTags.makeWrapperTag(Inspirations.modID + ":" + name); } + private static INamedTag forgeTag(String name) { + return ItemTags.makeWrapperTag("forge:" + name); + } } } diff --git a/src/main/java/knightminer/inspirations/library/Util.java b/src/main/java/knightminer/inspirations/library/Util.java index b8f358a7..84ab7b33 100644 --- a/src/main/java/knightminer/inspirations/library/Util.java +++ b/src/main/java/knightminer/inspirations/library/Util.java @@ -1,5 +1,7 @@ package knightminer.inspirations.library; +import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -15,7 +17,9 @@ import net.minecraft.potion.EffectUtils; import net.minecraft.potion.Potion; import net.minecraft.util.Direction; +import net.minecraft.util.JSONUtils; import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.VoxelShape; @@ -27,6 +31,7 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nullable; import java.util.Arrays; @@ -34,7 +39,6 @@ @SuppressWarnings("deprecation") public class Util { - public static boolean clickedAABB(AxisAlignedBB aabb, Vector3d hit) { return aabb.minX <= hit.x && hit.x <= aabb.maxX && aabb.minY <= hit.y && hit.y <= aabb.maxY @@ -198,4 +202,20 @@ public static DyeColor getDyeForColor(int color) { } return null; } + + /** + * Reads an iem from a string + * @param parent Parent object + * @param key JSON key of object + * @return Item + * @throws JsonSyntaxException If item is invalid or missing + */ + public static Item deserializeItem(JsonObject parent, String key) { + String name = JSONUtils.getString(parent, key); + Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(name)); + if (item == null) { + throw new JsonSyntaxException("Invalid " + key + ": Unknown item " + name + "'"); + } + return item; + } } diff --git a/src/main/java/knightminer/inspirations/library/recipe/cauldron/contents/ICauldronContents.java b/src/main/java/knightminer/inspirations/library/recipe/cauldron/contents/ICauldronContents.java index f3ab0f34..d66a14e7 100644 --- a/src/main/java/knightminer/inspirations/library/recipe/cauldron/contents/ICauldronContents.java +++ b/src/main/java/knightminer/inspirations/library/recipe/cauldron/contents/ICauldronContents.java @@ -59,6 +59,16 @@ public interface ICauldronContents { @Override int hashCode(); + /** + * Checks if the contents contain the given type + * @param type Content type + * @param Content class + * @return True if get would return this value + */ + default boolean contains(CauldronContentType type) { + return get(type).isPresent(); + } + /** * Checks if the contents contain the given value. Unlike {@link #matches(CauldronContentType, Object)}, supports overrides. * @param type Content type diff --git a/src/main/java/knightminer/inspirations/library/recipe/cauldron/inventory/IModifyableCauldronInventory.java b/src/main/java/knightminer/inspirations/library/recipe/cauldron/inventory/IModifyableCauldronInventory.java index 4e9cac05..4d305b79 100644 --- a/src/main/java/knightminer/inspirations/library/recipe/cauldron/inventory/IModifyableCauldronInventory.java +++ b/src/main/java/knightminer/inspirations/library/recipe/cauldron/inventory/IModifyableCauldronInventory.java @@ -39,16 +39,30 @@ public interface IModifyableCauldronInventory extends ICauldronInventory { /** * Decreases the size of the held stack * @param amount Amount to shrink by - * @return updated stack + * @return true if the stack is now empty, false otherwise */ - default ItemStack shrinkStack(int amount) { + default boolean shrinkStack(int amount) { ItemStack stack = getStack(); stack.shrink(amount); if (stack.isEmpty()) { stack = ItemStack.EMPTY; } setStack(stack); - return stack; + return stack.isEmpty(); + } + + /** + * Sets the given stack if the stack is empty, gives otherwise + * @param stack New stack to give + */ + default void setOrGiveStack(ItemStack stack) { + if (!stack.isEmpty()) { + if (getStack().isEmpty()) { + setStack(stack); + } else { + giveStack(stack); + } + } } /** @@ -61,4 +75,15 @@ default boolean updateLevel(IntUnaryOperator updater) { setLevel(newLevel); return newLevel == 0; } + + /** + * Adds the given amount to the cauldron level + * @param amount Amount to add, can be negative + * @return True if the cauldron is now empty, false otherwise + */ + default boolean addLevel(int amount) { + int newLevel = getLevel() + amount; + setLevel(newLevel); + return newLevel == 0; + } } diff --git a/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/CauldronRecipe.java b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/CauldronRecipe.java index 063b1bc6..74359098 100644 --- a/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/CauldronRecipe.java +++ b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/CauldronRecipe.java @@ -104,22 +104,16 @@ public void handleRecipe(IModifyableCauldronInventory inventory) { if (!container.isEmpty()) { container.setCount(amount); } + } else { + container = container.copy(); } // update hand item and container item - ItemStack hand = inventory.shrinkStack(amount); - if (!container.isEmpty()) { - if (hand.isEmpty()) { - inventory.setStack(container.copy()); - } else { - inventory.giveStack(container.copy()); - } - } + inventory.shrinkStack(amount); + inventory.setOrGiveStack(container); // give output - if (!output.isEmpty()) { - inventory.giveStack(output.copy()); - } + inventory.setOrGiveStack(output.copy()); } @Override diff --git a/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/EmptyPotionCauldronRecipe.java b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/EmptyPotionCauldronRecipe.java new file mode 100644 index 00000000..d8c062f7 --- /dev/null +++ b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/EmptyPotionCauldronRecipe.java @@ -0,0 +1,109 @@ +package knightminer.inspirations.library.recipe.cauldron.recipe; + +import com.google.gson.JsonObject; +import knightminer.inspirations.library.Util; +import knightminer.inspirations.library.recipe.cauldron.CauldronContentTypes; +import knightminer.inspirations.library.recipe.cauldron.inventory.ICauldronInventory; +import knightminer.inspirations.library.recipe.cauldron.inventory.IModifyableCauldronInventory; +import knightminer.inspirations.recipes.InspirationsRecipes; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.network.PacketBuffer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionUtils; +import net.minecraft.potion.Potions; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.registries.ForgeRegistryEntry; +import slimeknights.mantle.recipe.RecipeHelper; + +import javax.annotation.Nullable; + +public class EmptyPotionCauldronRecipe implements ICauldronRecipe { + private final ResourceLocation id; + private final Item potionItem; + private final Item bottle; + + public EmptyPotionCauldronRecipe(ResourceLocation id, Item potion, Item bottle) { + this.id = id; + this.potionItem = potion; + this.bottle = bottle; + } + + @Override + public boolean matches(ICauldronInventory inv, World worldIn) { + // not too full + if (inv.getLevel() == MAX) { + return false; + } + // item must be a potion + ItemStack stack = inv.getStack(); + if (stack.getItem() != potionItem) { + return false; + } + Potion potion = PotionUtils.getPotionFromItem(stack); + if (potion == Potions.EMPTY) { + return false; + } + + // contents must be empty or match the given potion + return inv.getLevel() == 0 || inv.getContents() + .get(CauldronContentTypes.POTION) + .map(potion::equals) + .orElse(false); + } + + @Override + public void handleRecipe(IModifyableCauldronInventory inv) { + Potion potion = PotionUtils.getPotionFromItem(inv.getStack()); + if (potion != Potions.EMPTY) { + // add levels + inv.addLevel(1); + // update contents + inv.setContents(CauldronContentTypes.POTION.of(potion)); + + // shrink stack + inv.shrinkStack(1); + inv.setOrGiveStack(new ItemStack(bottle)); + } + } + + @Override + public ResourceLocation getId() { + return id; + } + + @Override + public ItemStack getRecipeOutput() { + return new ItemStack(bottle); + } + + @Override + public IRecipeSerializer getSerializer() { + return InspirationsRecipes.emptyPotionSerializer; + } + + public static class Serializer extends ForgeRegistryEntry> implements IRecipeSerializer { + @Override + public EmptyPotionCauldronRecipe read(ResourceLocation id, JsonObject json) { + Item potion = Util.deserializeItem(json, "potion"); + Item bottle = Util.deserializeItem(json, "bottle"); + return new EmptyPotionCauldronRecipe(id, potion, bottle); + } + + @Nullable + @Override + public EmptyPotionCauldronRecipe read(ResourceLocation id, PacketBuffer buffer) { + Item potion = RecipeHelper.readItem(buffer); + Item bottle = RecipeHelper.readItem(buffer); + return new EmptyPotionCauldronRecipe(id, potion, bottle); + } + + @Override + public void write(PacketBuffer buffer, EmptyPotionCauldronRecipe recipe) { + RecipeHelper.writeItem(buffer, recipe.potionItem); + RecipeHelper.writeItem(buffer, recipe.bottle); + } + } +} diff --git a/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/EmptyPotionCauldronRecipeBuilder.java b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/EmptyPotionCauldronRecipeBuilder.java new file mode 100644 index 00000000..f1928bfb --- /dev/null +++ b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/EmptyPotionCauldronRecipeBuilder.java @@ -0,0 +1,92 @@ +package knightminer.inspirations.library.recipe.cauldron.recipe; + +import com.google.gson.JsonObject; +import knightminer.inspirations.recipes.InspirationsRecipes; +import net.minecraft.advancements.Advancement; +import net.minecraft.data.IFinishedRecipe; +import net.minecraft.item.Item; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.util.IItemProvider; +import net.minecraft.util.ResourceLocation; +import slimeknights.mantle.recipe.data.AbstractRecipeBuilder; + +import javax.annotation.Nullable; +import java.util.Objects; +import java.util.function.Consumer; + +/** + * Builder for a recipe that fills a bottle with a potion + */ +public class EmptyPotionCauldronRecipeBuilder extends AbstractRecipeBuilder { + private final Item bottle; + private final Item potionItem; + + private EmptyPotionCauldronRecipeBuilder(Item potionItem, Item bottle) { + this.potionItem = potionItem; + this.bottle = bottle; + } + + /** + * Creates a new builder instance + * @param potionItem Potion item for input + * @param bottle Bottle output + * @return Builder instance + */ + public static EmptyPotionCauldronRecipeBuilder empty(IItemProvider potionItem, IItemProvider bottle) { + return new EmptyPotionCauldronRecipeBuilder(potionItem.asItem(), bottle.asItem()); + } + + @Override + public void build(Consumer consumer) { + build(consumer, Objects.requireNonNull(bottle.getRegistryName())); + } + + @Override + public void build(Consumer consumer, ResourceLocation id) { + ResourceLocation advancementID = this.buildAdvancement(id, "cauldron"); + consumer.accept(new Result(id, potionItem, bottle, advancementBuilder, advancementID)); + } + + private static class Result implements IFinishedRecipe { + private final ResourceLocation id; + private final Item potionItem; + private final Item bottle; + private final Advancement.Builder advancementBuilder; + private final ResourceLocation advancementId; + private Result(ResourceLocation id, Item potionItem, Item bottle, Advancement.Builder advancementBuilder, ResourceLocation advancementId) { + this.id = id; + this.potionItem = potionItem; + this.bottle = bottle; + this.advancementBuilder = advancementBuilder; + this.advancementId = advancementId; + } + + @Override + public void serialize(JsonObject json) { + json.addProperty("potion", Objects.requireNonNull(potionItem.getRegistryName()).toString()); + json.addProperty("bottle", Objects.requireNonNull(bottle.getRegistryName()).toString()); + } + + @Override + public ResourceLocation getID() { + return id; + } + + @Override + public IRecipeSerializer getSerializer() { + return InspirationsRecipes.emptyPotionSerializer; + } + + @Nullable + @Override + public ResourceLocation getAdvancementID() { + return advancementId; + } + + @Nullable + @Override + public JsonObject getAdvancementJson() { + return advancementBuilder.serialize(); + } + } +} diff --git a/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/FillPotionCauldronRecipe.java b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/FillPotionCauldronRecipe.java new file mode 100644 index 00000000..a9dd6e79 --- /dev/null +++ b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/FillPotionCauldronRecipe.java @@ -0,0 +1,122 @@ +package knightminer.inspirations.library.recipe.cauldron.recipe; + +import com.google.gson.JsonObject; +import knightminer.inspirations.library.Util; +import knightminer.inspirations.library.recipe.cauldron.CauldronContentTypes; +import knightminer.inspirations.library.recipe.cauldron.inventory.ICauldronInventory; +import knightminer.inspirations.library.recipe.cauldron.inventory.IModifyableCauldronInventory; +import knightminer.inspirations.recipes.InspirationsRecipes; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.network.PacketBuffer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionUtils; +import net.minecraft.potion.Potions; +import net.minecraft.util.JSONUtils; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.crafting.CraftingHelper; +import net.minecraftforge.registries.ForgeRegistryEntry; +import slimeknights.mantle.recipe.RecipeHelper; +import slimeknights.mantle.util.JsonHelper; + +import javax.annotation.Nullable; + +/** + * Recipe to fill a potion bottle using a cauldron + */ +public class FillPotionCauldronRecipe implements ICauldronRecipe { + private final ResourceLocation id; + private final Ingredient bottle; + private final int amount; + private final Item potionItem; + + /** + * Creates a new potion fill recipe + * @param id Recipe ID + * @param bottle Potion bottle + * @param amount Number of the bottle needed and count of the output + * @param potionItem Item to output + */ + public FillPotionCauldronRecipe(ResourceLocation id, Ingredient bottle, int amount, Item potionItem) { + this.id = id; + this.potionItem = potionItem; + this.amount = amount; + this.bottle = bottle; + } + + @Override + public boolean matches(ICauldronInventory inv, World world) { + // must have at least one level, contain any potion, and be using the correct item + ItemStack stack = inv.getStack(); + return inv.getLevel() > 0 && inv.getContents().contains(CauldronContentTypes.POTION) && stack.getCount() >= amount && bottle.test(stack); + } + + @Override + public void handleRecipe(IModifyableCauldronInventory inv) { + inv.getContents().get(CauldronContentTypes.POTION).ifPresent(potion -> { + // give player potion, removing a bottle + inv.shrinkStack(amount); + inv.setOrGiveStack(PotionUtils.addPotionToItemStack(new ItemStack(potionItem, amount), potion)); + + // update level + inv.addLevel(-1); + }); + } + + /** + * @deprecated use {@link #getCraftingResult(IInventory)} + */ + @Deprecated + @Override + public ItemStack getRecipeOutput() { + return new ItemStack(potionItem, amount); + } + + @Override + public ItemStack getCraftingResult(ICauldronInventory inv) { + Potion potion = inv.getContents() + .get(CauldronContentTypes.POTION) + .orElse(Potions.EMPTY); + return PotionUtils.addPotionToItemStack(new ItemStack(potionItem, amount), potion); + } + + @Override + public ResourceLocation getId() { + return id; + } + + @Override + public IRecipeSerializer getSerializer() { + return InspirationsRecipes.fillPotionSerializer; + } + + public static class Serializer extends ForgeRegistryEntry> implements IRecipeSerializer { + @Override + public FillPotionCauldronRecipe read(ResourceLocation id, JsonObject json) { + Ingredient bottle = CraftingHelper.getIngredient(JsonHelper.getElement(json, "bottle")); + int amount = JSONUtils.getInt(json, "amount", 1); + Item potion = Util.deserializeItem(json, "potion"); + return new FillPotionCauldronRecipe(id, bottle, amount, potion); + } + + @Nullable + @Override + public FillPotionCauldronRecipe read(ResourceLocation id, PacketBuffer buffer) { + Ingredient bottle = Ingredient.read(buffer); + int amount = buffer.readVarInt(); + Item potion = RecipeHelper.readItem(buffer); + return new FillPotionCauldronRecipe(id, bottle, amount, potion); + } + + @Override + public void write(PacketBuffer buffer, FillPotionCauldronRecipe recipe) { + recipe.bottle.write(buffer); + buffer.writeVarInt(recipe.amount); + RecipeHelper.writeItem(buffer, recipe.potionItem); + } + } +} diff --git a/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/FillPotionCauldronRecipeBuilder.java b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/FillPotionCauldronRecipeBuilder.java new file mode 100644 index 00000000..2411f3eb --- /dev/null +++ b/src/main/java/knightminer/inspirations/library/recipe/cauldron/recipe/FillPotionCauldronRecipeBuilder.java @@ -0,0 +1,114 @@ +package knightminer.inspirations.library.recipe.cauldron.recipe; + +import com.google.gson.JsonObject; +import knightminer.inspirations.recipes.InspirationsRecipes; +import net.minecraft.advancements.Advancement; +import net.minecraft.data.IFinishedRecipe; +import net.minecraft.item.Item; +import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.IItemProvider; +import net.minecraft.util.ResourceLocation; +import slimeknights.mantle.recipe.data.AbstractRecipeBuilder; + +import javax.annotation.Nullable; +import java.util.Objects; +import java.util.function.Consumer; + +/** + * Builder for a recipe that fills a bottle with a potion + */ +public class FillPotionCauldronRecipeBuilder extends AbstractRecipeBuilder { + private final Ingredient bottle; + private final int amount; + private final Item potionItem; + + private FillPotionCauldronRecipeBuilder(Ingredient bottle, int amount, Item potionItem) { + this.bottle = bottle; + this.amount = amount; + this.potionItem = potionItem; + } + + /** + * Creates a new builder with a specific amount + * @param bottle Bottle ingredient + * @param amount Amount needed and crafted + * @param potionItem Potion item for output + * @return Builder instance + */ + public static FillPotionCauldronRecipeBuilder fill(Ingredient bottle, int amount, IItemProvider potionItem) { + return new FillPotionCauldronRecipeBuilder(bottle, amount, potionItem.asItem()); + } + + /** + * Creates a new builder with an amount of 1 + * @param bottle Bottle ingredient + * @param potionItem Potion item for output + * @return Builder instance + */ + public static FillPotionCauldronRecipeBuilder fill(Ingredient bottle, IItemProvider potionItem) { + return fill(bottle, 1, potionItem); + } + + @Override + public void build(Consumer consumer) { + build(consumer, Objects.requireNonNull(potionItem.getRegistryName())); + } + + @Override + public void build(Consumer consumer, ResourceLocation id) { + if (amount < 1) { + throw new IllegalStateException("Amount must be at least 1"); + } + ResourceLocation advancementID = this.buildAdvancement(id, "cauldron"); + consumer.accept(new Result(id, bottle, amount, potionItem, advancementBuilder, advancementID)); + } + + private static class Result implements IFinishedRecipe { + private final ResourceLocation id; + private final Ingredient bottle; + private final int amount; + private final Item potionItem; + private final Advancement.Builder advancementBuilder; + private final ResourceLocation advancementId; + private Result(ResourceLocation id, Ingredient bottle, int amount, Item potionItem, Advancement.Builder advancementBuilder, ResourceLocation advancementId) { + this.id = id; + this.bottle = bottle; + this.amount = amount; + this.potionItem = potionItem; + this.advancementBuilder = advancementBuilder; + this.advancementId = advancementId; + } + + @Override + public void serialize(JsonObject json) { + json.add("bottle", bottle.serialize()); + if (amount != 1) { + json.addProperty("amount", amount); + } + json.addProperty("potion", Objects.requireNonNull(potionItem.getRegistryName()).toString()); + } + + @Override + public ResourceLocation getID() { + return id; + } + + @Override + public IRecipeSerializer getSerializer() { + return InspirationsRecipes.fillPotionSerializer; + } + + @Nullable + @Override + public ResourceLocation getAdvancementID() { + return advancementId; + } + + @Nullable + @Override + public JsonObject getAdvancementJson() { + return advancementBuilder.serialize(); + } + } +} diff --git a/src/main/java/knightminer/inspirations/recipes/InspirationsRecipes.java b/src/main/java/knightminer/inspirations/recipes/InspirationsRecipes.java index 69016353..ec1c56f5 100644 --- a/src/main/java/knightminer/inspirations/recipes/InspirationsRecipes.java +++ b/src/main/java/knightminer/inspirations/recipes/InspirationsRecipes.java @@ -3,12 +3,14 @@ import knightminer.inspirations.Inspirations; import knightminer.inspirations.common.Config; import knightminer.inspirations.common.ModuleBase; -import knightminer.inspirations.common.item.HidableItem; import knightminer.inspirations.library.recipe.cauldron.CauldronContentTypes; import knightminer.inspirations.library.recipe.cauldron.contents.ICauldronContents; import knightminer.inspirations.library.recipe.cauldron.recipe.CauldronRecipe; +import knightminer.inspirations.library.recipe.cauldron.recipe.EmptyPotionCauldronRecipe; +import knightminer.inspirations.library.recipe.cauldron.recipe.FillPotionCauldronRecipe; import knightminer.inspirations.recipes.block.EnhancedCauldronBlock; import knightminer.inspirations.recipes.data.RecipesRecipeProvider; +import knightminer.inspirations.recipes.item.EmptyBottleItem; import knightminer.inspirations.recipes.item.MixedDyedBottleItem; import knightminer.inspirations.recipes.item.SimpleDyedBottleItem; import knightminer.inspirations.recipes.recipe.cauldron.EmptyBucketCauldronRecipe; @@ -87,6 +89,8 @@ public class InspirationsRecipes extends ModuleBase { // cauldron serializers public static CauldronRecipe.Serializer cauldronSerializer; + public static EmptyPotionCauldronRecipe.Serializer emptyPotionSerializer; + public static FillPotionCauldronRecipe.Serializer fillPotionSerializer; public static SpecialRecipeSerializer emptyBucketSerializer; public static SpecialRecipeSerializer fillBucketSerializer; @@ -152,8 +156,8 @@ void registerItems(Register event) { // empty bottles Item.Properties brewingProps = new Item.Properties().group(ItemGroup.BREWING); - splashBottle = registry.register(new HidableItem(brewingProps, Config.enableCauldronPotions), "splash_bottle"); - lingeringBottle = registry.register(new HidableItem(brewingProps, Config.enableCauldronPotions), "lingering_bottle"); + splashBottle = registry.register(new EmptyBottleItem(brewingProps, Items.SPLASH_POTION.delegate), "splash_bottle"); + lingeringBottle = registry.register(new EmptyBottleItem(brewingProps, Items.LINGERING_POTION.delegate), "lingering_bottle"); // dyed bottles Item.Properties bottleProps = new Item.Properties() @@ -176,9 +180,7 @@ void registerTileEntities(Register> event) { TileEntityTypeRegistryAdapter registry = new TileEntityTypeRegistryAdapter(event.getRegistry()); if (Config.extendedCauldron.get()) { - tileCauldron = registry.register(CauldronTileEntity::new, "cauldron", blocks -> { - blocks.add(cauldron, boilingCauldron); - }); + tileCauldron = registry.register(CauldronTileEntity::new, "cauldron", blocks -> blocks.add(cauldron, boilingCauldron)); } } @@ -192,6 +194,8 @@ void registerParticleTypes(Register> event) { void registerSerializers(Register> event) { RegistryAdapter> registry = new RegistryAdapter<>(event.getRegistry()); cauldronSerializer = registry.register(new CauldronRecipe.Serializer(), "cauldron"); + emptyPotionSerializer = registry.register(new EmptyPotionCauldronRecipe.Serializer(), "cauldron_empty_potion"); + fillPotionSerializer = registry.register(new FillPotionCauldronRecipe.Serializer(), "cauldron_fill_potion"); emptyBucketSerializer = registry.register(new SpecialRecipeSerializer<>(EmptyBucketCauldronRecipe::new), "cauldron_empty_bucket"); fillBucketSerializer = registry.register(new SpecialRecipeSerializer<>(FillBucketCauldronRecipe::new), "cauldron_fill_bucket"); diff --git a/src/main/java/knightminer/inspirations/recipes/data/RecipesRecipeProvider.java b/src/main/java/knightminer/inspirations/recipes/data/RecipesRecipeProvider.java index 4b5b315a..a06cbfa2 100644 --- a/src/main/java/knightminer/inspirations/recipes/data/RecipesRecipeProvider.java +++ b/src/main/java/knightminer/inspirations/recipes/data/RecipesRecipeProvider.java @@ -11,6 +11,8 @@ import knightminer.inspirations.library.recipe.cauldron.ingredient.FluidCauldronIngredient; import knightminer.inspirations.library.recipe.cauldron.ingredient.ICauldronIngredient; import knightminer.inspirations.library.recipe.cauldron.recipe.CauldronRecipeBuilder; +import knightminer.inspirations.library.recipe.cauldron.recipe.EmptyPotionCauldronRecipeBuilder; +import knightminer.inspirations.library.recipe.cauldron.recipe.FillPotionCauldronRecipeBuilder; import knightminer.inspirations.library.recipe.cauldron.util.TemperaturePredicate; import knightminer.inspirations.recipes.InspirationsRecipes; import knightminer.inspirations.shared.InspirationsShared; @@ -101,6 +103,7 @@ protected void registerRecipes(Consumer consumer) { .maxLevels(2) .addLevels(1) .setOutput(Items.GLASS_BOTTLE) + .setOutput(CauldronContentTypes.FLUID.of(Fluids.WATER)) .noContainer() .addCriterion("has_item", hasItem( ItemPredicate.Builder.create() @@ -167,8 +170,51 @@ protected void registerRecipes(Consumer consumer) { // potions // - // TODO: potion bottling - // TODO: tipped arrow recipe (might be same internal logic, just uses a stack of 16) + String potionFolder = folder + "potion/"; + Consumer potionConsumer = withCondition(ConfigEnabledCondition.CAULDRON_POTIONS); + // normal + EmptyPotionCauldronRecipeBuilder.empty(Items.POTION, Items.GLASS_BOTTLE) + .addCriterion("has_item", hasItem(Items.POTION)) + .build(potionConsumer, resource(potionFolder + "normal_empty")); + FillPotionCauldronRecipeBuilder.fill(Ingredient.fromItems(Items.GLASS_BOTTLE), Items.POTION) + .addCriterion("has_item", hasItem(Items.GLASS_BOTTLE)) + .build(potionConsumer, resource(potionFolder + "normal_fill")); + // splash + EmptyPotionCauldronRecipeBuilder.empty(Items.SPLASH_POTION, InspirationsRecipes.splashBottle) + .addCriterion("has_item", hasItem(Items.SPLASH_POTION)) + .build(potionConsumer, resource(potionFolder + "splash_empty")); + FillPotionCauldronRecipeBuilder.fill(Ingredient.fromTag(InspirationsTags.Items.SPLASH_BOTTLES), Items.SPLASH_POTION) + .addCriterion("has_item", hasItem(InspirationsTags.Items.SPLASH_BOTTLES)) + .build(potionConsumer, resource(potionFolder + "splash_fill")); + // lingering + EmptyPotionCauldronRecipeBuilder.empty(Items.LINGERING_POTION, InspirationsRecipes.lingeringBottle) + .addCriterion("has_item", hasItem(Items.LINGERING_POTION)) + .build(potionConsumer, resource(potionFolder + "lingering_empty")); + FillPotionCauldronRecipeBuilder.fill(Ingredient.fromTag(InspirationsTags.Items.LINGERING_BOTTLES), Items.LINGERING_POTION) + .addCriterion("has_item", hasItem(InspirationsTags.Items.LINGERING_BOTTLES)) + .build(potionConsumer, resource(potionFolder + "lingering_fill")); + // tipped arrows + FillPotionCauldronRecipeBuilder.fill(Ingredient.fromItems(Items.ARROW), 16, Items.TIPPED_ARROW) + .addCriterion("has_item", hasItem(Items.ARROW)) + .build(potionConsumer, resource(potionFolder + "tipped_arrow")); + + // craft the bottles + ShapelessRecipeBuilder.shapelessRecipe(InspirationsRecipes.splashBottle) + .addIngredient(Items.GLASS_BOTTLE) + .addIngredient(Items.GLASS_BOTTLE) + .addIngredient(Items.GLASS_BOTTLE) + .addIngredient(Tags.Items.GUNPOWDER) + .addCriterion("has_item", hasItem(Tags.Items.GUNPOWDER)) + .build(potionConsumer, prefix(InspirationsRecipes.splashBottle, potionFolder)); + ShapelessRecipeBuilder.shapelessRecipe(InspirationsRecipes.lingeringBottle) + .addIngredient(InspirationsTags.Items.SPLASH_BOTTLES) + .addIngredient(InspirationsTags.Items.SPLASH_BOTTLES) + .addIngredient(InspirationsTags.Items.SPLASH_BOTTLES) + .addIngredient(Items.DRAGON_BREATH) + .addCriterion("has_item", hasItem(Items.DRAGON_BREATH)) + .build(potionConsumer, prefix(InspirationsRecipes.lingeringBottle, potionFolder)); + + // TODO: potion brewing // fluid recipes // // beetroot is just water based diff --git a/src/main/java/knightminer/inspirations/recipes/item/EmptyBottleItem.java b/src/main/java/knightminer/inspirations/recipes/item/EmptyBottleItem.java new file mode 100644 index 00000000..078c5a78 --- /dev/null +++ b/src/main/java/knightminer/inspirations/recipes/item/EmptyBottleItem.java @@ -0,0 +1,75 @@ +package knightminer.inspirations.recipes.item; + +import knightminer.inspirations.common.Config; +import knightminer.inspirations.common.IHidable; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.GlassBottleItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionUtils; +import net.minecraft.potion.Potions; +import net.minecraft.tags.FluidTags; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.NonNullList; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvents; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.RayTraceContext; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.World; + +import java.util.function.Supplier; + +/** + * Item representing an empty potion bottle. Can be filled with water from a source block + */ +public class EmptyBottleItem extends GlassBottleItem implements IHidable { + private final Supplier filled; + + /** + * Creates a new bottle instance + * @param properties Item properties + * @param filled Supplier returning the filled potion item + */ + public EmptyBottleItem(Properties properties, Supplier filled) { + super(properties); + this.filled = filled; + } + + @Override + public boolean isEnabled() { + return Config.enableCauldronPotions.getAsBoolean(); + } + + @Override + public void fillItemGroup(ItemGroup group, NonNullList items) { + if (shouldAddtoItemGroup(group)) { + super.fillItemGroup(group, items); + } + } + + @Override + public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { + ItemStack stack = player.getHeldItem(hand); + + // must hit a block + BlockRayTraceResult trace = rayTrace(world, player, RayTraceContext.FluidMode.SOURCE_ONLY); + if (trace.getType() == RayTraceResult.Type.BLOCK) { + BlockPos pos = trace.getPos(); + if (!world.isBlockModifiable(player, pos)) { + return ActionResult.resultPass(stack); + } + + // if the block contains water, give filled stack + if (world.getFluidState(pos).isTagged(FluidTags.WATER)) { + world.playSound(player, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F); + return ActionResult.func_233538_a_(this.turnBottleIntoItem(stack, player, PotionUtils.addPotionToItemStack(new ItemStack(filled.get()), Potions.WATER)), world.isRemote()); + } + } + + return ActionResult.resultPass(stack); + } +} diff --git a/src/main/java/knightminer/inspirations/recipes/recipe/cauldron/EmptyBucketCauldronRecipe.java b/src/main/java/knightminer/inspirations/recipes/recipe/cauldron/EmptyBucketCauldronRecipe.java index beb994bf..b8147ff1 100644 --- a/src/main/java/knightminer/inspirations/recipes/recipe/cauldron/EmptyBucketCauldronRecipe.java +++ b/src/main/java/knightminer/inspirations/recipes/recipe/cauldron/EmptyBucketCauldronRecipe.java @@ -75,7 +75,8 @@ public void handleRecipe(IModifyableCauldronInventory inv) { // update contents inv.setContents(CauldronContentTypes.FLUID.of(drained.getFluid())); // replace held item with container - inv.setStack(handler.getContainer()); + inv.shrinkStack(1); + inv.setOrGiveStack(handler.getContainer()); } }); } diff --git a/src/main/java/knightminer/inspirations/recipes/recipe/cauldron/FillBucketCauldronRecipe.java b/src/main/java/knightminer/inspirations/recipes/recipe/cauldron/FillBucketCauldronRecipe.java index 3bfd418c..e958e6ac 100644 --- a/src/main/java/knightminer/inspirations/recipes/recipe/cauldron/FillBucketCauldronRecipe.java +++ b/src/main/java/knightminer/inspirations/recipes/recipe/cauldron/FillBucketCauldronRecipe.java @@ -52,7 +52,8 @@ public void handleRecipe(IModifyableCauldronInventory inv) { // if we successfully fill the handler, update the cauldron if (handler.fill(new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME), FluidAction.EXECUTE) == FluidAttributes.BUCKET_VOLUME) { inv.setLevel(0); - inv.setStack(handler.getContainer()); + inv.shrinkStack(1); + inv.setOrGiveStack(handler.getContainer()); } })); }