Skip to content
Merged
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 @@ -34,6 +34,7 @@
import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.capability.IFluidHandler.FluidAction;
import net.neoforged.neoforge.fluids.capability.IFluidHandlerItem;
import net.neoforged.neoforge.fluids.crafting.DataComponentFluidIngredient;
import net.neoforged.neoforge.fluids.crafting.SizedFluidIngredient;

@ParametersAreNonnullByDefault
Expand All @@ -52,9 +53,11 @@ public static void consumeRecipes(Consumer<RecipeHolder<FillingRecipe>> consumer
FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack);
Ingredient bottle = Ingredient.of(Items.GLASS_BOTTLE);
ResourceLocation id = Create.asResource("potions");
SizedFluidIngredient fluidIngredient = new SizedFluidIngredient(
DataComponentFluidIngredient.of(false, fluidFromPotionItem), fluidFromPotionItem.getAmount());
FillingRecipe recipe = new StandardProcessingRecipe.Builder<>(FillingRecipe::new, id)
.withItemIngredients(bottle)
.withFluidIngredients(SizedFluidIngredient.of(fluidFromPotionItem))
.withFluidIngredients(fluidIngredient)
.withSingleItemOutput(stack)
.build();
consumer.accept(new RecipeHolder<>(id, recipe));
Expand Down Expand Up @@ -93,9 +96,11 @@ public static void consumeRecipes(Consumer<RecipeHolder<FillingRecipe>> consumer
ResourceLocation fluidName = RegisteredObjectsHelper.getKeyOrThrow(fluidCopy.getFluid());
ResourceLocation id = Create.asResource("fill_" + itemName.getNamespace() + "_" + itemName.getPath()
+ "_with_" + fluidName.getNamespace() + "_" + fluidName.getPath());
SizedFluidIngredient fluidIngredient = new SizedFluidIngredient(
DataComponentFluidIngredient.of(false, fluidCopy), fluidCopy.getAmount());
FillingRecipe recipe = new StandardProcessingRecipe.Builder<>(FillingRecipe::new, id)
.withItemIngredients(bucket)
.withFluidIngredients(SizedFluidIngredient.of(fluidCopy))
.withFluidIngredients(fluidIngredient)
.withSingleItemOutput(container)
.build();
consumer.accept(new RecipeHolder<>(id, recipe));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.neoforged.neoforge.common.brewing.BrewingRecipe;
import net.neoforged.neoforge.common.brewing.IBrewingRecipe;
import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.crafting.DataComponentFluidIngredient;
import net.neoforged.neoforge.fluids.crafting.SizedFluidIngredient;

public class PotionMixingRecipes {
Expand Down Expand Up @@ -149,7 +150,7 @@ private static RecipeHolder<MixingRecipe> createRecipe(String id, Ingredient ing
ResourceLocation recipeId = Create.asResource(id);
MixingRecipe recipe = new Builder<>(MixingRecipe::new, recipeId)
.require(ingredient)
.require(SizedFluidIngredient.of(fromFluid))
.require(new SizedFluidIngredient(DataComponentFluidIngredient.of(false, fromFluid), fromFluid.getAmount()))
.output(toFluid)
.requiresHeat(HeatCondition.HEATED)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class CreateGameTestHelper extends GameTestHelper {
public static final int TEN_SECONDS = 10 * TICKS_PER_SECOND;
public static final int FIFTEEN_SECONDS = 15 * TICKS_PER_SECOND;
public static final int TWENTY_SECONDS = 20 * TICKS_PER_SECOND;
public static final int THIRTY_SECONDS = 30 * TICKS_PER_SECOND;

private CreateGameTestHelper(GameTestInfo testInfo) {
super(testInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ public static void brassMixing2(CreateGameTestHelper helper) {
helper.succeedWhen(() -> helper.assertContainerContains(output, AllItems.BRASS_INGOT.get()));
}

@GameTest(template = "potion_brewing", timeoutTicks = CreateGameTestHelper.THIRTY_SECONDS)
public static void potionBrewing(CreateGameTestHelper helper) {
BlockPos chest = new BlockPos(8, 3, 5);
BlockPos potionLever = new BlockPos(2, 3, 4);
BlockPos bottleLever = new BlockPos(7, 3, 2);
ItemStack expected = PotionContents.createItemStack(Items.POTION, Potions.HEALING);

helper.pullLever(potionLever);
helper.whenSecondsPassed(15, () -> helper.pullLever(bottleLever));
helper.succeedWhen(() -> helper.assertContainerContains(chest, expected));
}

@GameTest(template = "spout_crafting", timeoutTicks = CreateGameTestHelper.TEN_SECONDS)
public static void spoutCrafting(CreateGameTestHelper helper) {
BlockPos chest = new BlockPos(5, 3, 1);
helper.pullLever(2, 3, 2);
helper.succeedWhen(() -> helper.assertContainerContains(chest, Items.REDSTONE));
}

@GameTest(template = "crushing_wheel_crafting", timeoutTicks = CreateGameTestHelper.TEN_SECONDS)
public static void crushingWheelCrafting(CreateGameTestHelper helper) {
BlockPos chest = new BlockPos(1, 4, 3);
Expand Down
Binary file not shown.
Binary file not shown.