Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potion unlocking rework (v2) #671

Open
wants to merge 5 commits into
base: 1.20.1-aria-for-painters
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ private static boolean hasUniqueReagents(PotionWorkshopBlockEntity potionWorksho

private static boolean isBrewingRecipeApplicable(PotionWorkshopBrewingRecipe recipe, ItemStack baseIngredient, PotionWorkshopBlockEntity potionWorkshopBlockEntity) {
PotionMod potionMod = getPotionModFromReagents(potionWorkshopBlockEntity);
return hasUniqueReagents(potionWorkshopBlockEntity) && recipe.recipeData.isApplicableTo(baseIngredient, potionMod)
&& !(potionMod.incurable && SpectrumStatusEffectTags.cannotBeIncurable(recipe.recipeData.statusEffect()));
return hasUniqueReagents(potionWorkshopBlockEntity)
&& canPlayerUseReagents(potionWorkshopBlockEntity)
&& recipe.recipeData.isApplicableTo(baseIngredient, potionMod)
&& !(potionMod.incurable && SpectrumStatusEffectTags.cannotBeIncurable(recipe.recipeData.statusEffect()));
}

private static void craftRecipe(PotionWorkshopBlockEntity potionWorkshopBlockEntity, PotionWorkshopCraftingRecipe recipe) {
Expand Down Expand Up @@ -325,6 +327,18 @@ private static void fillPotionFillable(PotionWorkshopBlockEntity potionWorkshopB
potionWorkshopBlockEntity.lastBrewedRecipe = brewingRecipe;
}
}

private static boolean canPlayerUseReagents(PotionWorkshopBlockEntity potionWorkshopBlockEntity) {
World world = potionWorkshopBlockEntity.getWorld();
List<PotionWorkshopReactingRecipe> reagentRecipes = world.getRecipeManager().getAllMatches(SpectrumRecipeTypes.POTION_WORKSHOP_REACTING, potionWorkshopBlockEntity, world);
SpectrumCommon.logError("Found "+reagentRecipes.size()+" matching reagent recipes");
for (PotionWorkshopReactingRecipe recipe : reagentRecipes) {
if (!recipe.canPlayerCraft(potionWorkshopBlockEntity.getOwnerIfOnline())) {
return false;
}
}
return true;
}

private static PotionMod getPotionModFromReagents(PotionWorkshopBlockEntity potionWorkshopBlockEntity) {
World world = potionWorkshopBlockEntity.getWorld();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.dafuqs.spectrum.api.recipe.*;
import de.dafuqs.spectrum.recipe.*;
import de.dafuqs.spectrum.registries.*;
import de.dafuqs.spectrum.blocks.potion_workshop.*;
import net.minecraft.inventory.*;
import net.minecraft.item.*;
import net.minecraft.recipe.*;
Expand Down Expand Up @@ -35,6 +36,12 @@ public PotionWorkshopReactingRecipe(Identifier id, String group, boolean secret,

@Override
public boolean matches(@NotNull Inventory inv, World world) {
for (int i : PotionWorkshopBlockEntity.REAGENT_SLOTS) {
ItemStack itemStack = inv.getStack(i);
if (!itemStack.isEmpty() && itemStack.getItem() == item) {
return true;
}
}
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/spectrum/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -3586,8 +3586,8 @@
"book.spectrum.guidebook.potion_workshop_crafting.page9.title": "Bottles o' Enchanting",
"book.spectrum.guidebook.potion_workshop_reagents.name": "Using Reagents",
"book.spectrum.guidebook.potion_workshop_reagents.page0.name": "Reagents",
"book.spectrum.guidebook.potion_workshop_reagents.page0.text": "Instead of adding ingredients to the potion bit by bit, as in the [#](bb00bb)Brewing Stand[#](), I experimented with dissolving all the ingredients in the liquid contained in [Mermaid's Gems](entry://general/mermaids_brush) all at once and adding some of my magical collectibles as reagents.\\\n**Breakthrough!**\\\n\\\nEach reagent will have an unique effect on the [#](bb00bb)Potion[#]().",
"book.spectrum.guidebook.potion_workshop_reagents.page1.text": "- the order in which I arrange the reagents will not matter\n- flat bonuses get applied first, percentage-based bonuses modify that value afterwards\n- the same reagent cannot be stacked",
"book.spectrum.guidebook.potion_workshop_reagents.page0.text": "Instead of adding ingredients to the potion bit by bit, as in the [#](bb00bb)Brewing Stand[#](), I can dissolve all the ingredients at once in the liquid contained in [Mermaid's Gems](entry://general/mermaids_brush). This includes the reagents!\\\n\\\nThe [Potion Workshop](entry://brewing/potion_workshop) has multiple reagent slots, allowing me to apply a variety of improvements at once, but I can only use each reagent once per brew.",
"book.spectrum.guidebook.potion_workshop_reagents.page1.text": "**Breakthrough!** I can use my magical collectibles as reagents, for a wide array of additional bonuses.\\\n\\\nWhen combining them, the following rules apply:\n- the order of the reagents does not matter\n- flat bonuses apply first, percentage-based bonuses modify that value afterwards",
"book.spectrum.guidebook.potion_workshop_reagents.page1.title": "Rules of Application",
"book.spectrum.guidebook.potion_workshop_reagents.redstone.text": "- +100%% duration",
"book.spectrum.guidebook.potion_workshop_reagents.pure_redstone.text": "- +200%% duration\n- -50%% potency\n- -1 yield",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
}
]
}
},
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
}
},
"fabric:load_conditions": [
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"criteria": {
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
},
"obtained_ash_flakes": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:hidden/collect_ash"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"criteria": {
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
},
"broke_decayed_bedrock": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/break_decayed_bedrock"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"criteria": {
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
},
"obtained_bismuth": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:lategame/collect_bismuth"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"criteria": {
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
},
"broke_cracked_dragonbone": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:break_cracked_dragonbone"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"criteria": {
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
},
"obtained_fissure_plum": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:hidden/collect_fissure_plum"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"criteria": {
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
},
"obtained_four_leaf_clover": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:collect_four_leaf_clover"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"criteria": {
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
},
"obtained_jadeite_petals": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:hidden/collect_jadeite"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"criteria": {
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
},
"obtained_midnight_chip": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/collect_midnight_chip"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"criteria": {
"crafted_potion_in_potion_brewery": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:midgame/brew_potion_in_potion_workshop"
}
},
"obtained_moonstone": {
"trigger": "revelationary:advancement_gotten",
"conditions": {
"advancement_identifier": "spectrum:lategame/collect_moonstone"
}
}
}
}
Loading