Skip to content

Commit 7d77d80

Browse files
authored
Fix potion-based fluid recipes (#9563)
1 parent 1980b4f commit 7d77d80

File tree

6 files changed

+29
-3
lines changed

6 files changed

+29
-3
lines changed

src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import net.neoforged.neoforge.fluids.FluidStack;
3535
import net.neoforged.neoforge.fluids.capability.IFluidHandler.FluidAction;
3636
import net.neoforged.neoforge.fluids.capability.IFluidHandlerItem;
37+
import net.neoforged.neoforge.fluids.crafting.DataComponentFluidIngredient;
3738
import net.neoforged.neoforge.fluids.crafting.SizedFluidIngredient;
3839

3940
@ParametersAreNonnullByDefault
@@ -52,9 +53,11 @@ public static void consumeRecipes(Consumer<RecipeHolder<FillingRecipe>> consumer
5253
FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack);
5354
Ingredient bottle = Ingredient.of(Items.GLASS_BOTTLE);
5455
ResourceLocation id = Create.asResource("potions");
56+
SizedFluidIngredient fluidIngredient = new SizedFluidIngredient(
57+
DataComponentFluidIngredient.of(false, fluidFromPotionItem), fluidFromPotionItem.getAmount());
5558
FillingRecipe recipe = new StandardProcessingRecipe.Builder<>(FillingRecipe::new, id)
5659
.withItemIngredients(bottle)
57-
.withFluidIngredients(SizedFluidIngredient.of(fluidFromPotionItem))
60+
.withFluidIngredients(fluidIngredient)
5861
.withSingleItemOutput(stack)
5962
.build();
6063
consumer.accept(new RecipeHolder<>(id, recipe));
@@ -93,9 +96,11 @@ public static void consumeRecipes(Consumer<RecipeHolder<FillingRecipe>> consumer
9396
ResourceLocation fluidName = RegisteredObjectsHelper.getKeyOrThrow(fluidCopy.getFluid());
9497
ResourceLocation id = Create.asResource("fill_" + itemName.getNamespace() + "_" + itemName.getPath()
9598
+ "_with_" + fluidName.getNamespace() + "_" + fluidName.getPath());
99+
SizedFluidIngredient fluidIngredient = new SizedFluidIngredient(
100+
DataComponentFluidIngredient.of(false, fluidCopy), fluidCopy.getAmount());
96101
FillingRecipe recipe = new StandardProcessingRecipe.Builder<>(FillingRecipe::new, id)
97102
.withItemIngredients(bucket)
98-
.withFluidIngredients(SizedFluidIngredient.of(fluidCopy))
103+
.withFluidIngredients(fluidIngredient)
99104
.withSingleItemOutput(container)
100105
.build();
101106
consumer.accept(new RecipeHolder<>(id, recipe));

src/main/java/com/simibubi/create/content/fluids/potion/PotionMixingRecipes.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import net.neoforged.neoforge.common.brewing.BrewingRecipe;
3131
import net.neoforged.neoforge.common.brewing.IBrewingRecipe;
3232
import net.neoforged.neoforge.fluids.FluidStack;
33+
import net.neoforged.neoforge.fluids.crafting.DataComponentFluidIngredient;
3334
import net.neoforged.neoforge.fluids.crafting.SizedFluidIngredient;
3435

3536
public class PotionMixingRecipes {
@@ -149,7 +150,7 @@ private static RecipeHolder<MixingRecipe> createRecipe(String id, Ingredient ing
149150
ResourceLocation recipeId = Create.asResource(id);
150151
MixingRecipe recipe = new Builder<>(MixingRecipe::new, recipeId)
151152
.require(ingredient)
152-
.require(SizedFluidIngredient.of(fromFluid))
153+
.require(new SizedFluidIngredient(DataComponentFluidIngredient.of(false, fromFluid), fromFluid.getAmount()))
153154
.output(toFluid)
154155
.requiresHeat(HeatCondition.HEATED)
155156
.build();

src/main/java/com/simibubi/create/infrastructure/gametest/CreateGameTestHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class CreateGameTestHelper extends GameTestHelper {
6666
public static final int TEN_SECONDS = 10 * TICKS_PER_SECOND;
6767
public static final int FIFTEEN_SECONDS = 15 * TICKS_PER_SECOND;
6868
public static final int TWENTY_SECONDS = 20 * TICKS_PER_SECOND;
69+
public static final int THIRTY_SECONDS = 30 * TICKS_PER_SECOND;
6970

7071
private CreateGameTestHelper(GameTestInfo testInfo) {
7172
super(testInfo);

src/main/java/com/simibubi/create/infrastructure/gametest/tests/TestProcessing.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@ public static void brassMixing2(CreateGameTestHelper helper) {
4242
helper.succeedWhen(() -> helper.assertContainerContains(output, AllItems.BRASS_INGOT.get()));
4343
}
4444

45+
@GameTest(template = "potion_brewing", timeoutTicks = CreateGameTestHelper.THIRTY_SECONDS)
46+
public static void potionBrewing(CreateGameTestHelper helper) {
47+
BlockPos chest = new BlockPos(8, 3, 5);
48+
BlockPos potionLever = new BlockPos(2, 3, 4);
49+
BlockPos bottleLever = new BlockPos(7, 3, 2);
50+
ItemStack expected = PotionContents.createItemStack(Items.POTION, Potions.HEALING);
51+
52+
helper.pullLever(potionLever);
53+
helper.whenSecondsPassed(15, () -> helper.pullLever(bottleLever));
54+
helper.succeedWhen(() -> helper.assertContainerContains(chest, expected));
55+
}
56+
57+
@GameTest(template = "spout_crafting", timeoutTicks = CreateGameTestHelper.TEN_SECONDS)
58+
public static void spoutCrafting(CreateGameTestHelper helper) {
59+
BlockPos chest = new BlockPos(5, 3, 1);
60+
helper.pullLever(2, 3, 2);
61+
helper.succeedWhen(() -> helper.assertContainerContains(chest, Items.REDSTONE));
62+
}
63+
4564
@GameTest(template = "crushing_wheel_crafting", timeoutTicks = CreateGameTestHelper.TEN_SECONDS)
4665
public static void crushingWheelCrafting(CreateGameTestHelper helper) {
4766
BlockPos chest = new BlockPos(1, 4, 3);
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)