Create Fabric

Create Fabric

7M Downloads

Spout won't fill Buckets

fabien-gigante opened this issue ยท 17 comments

commented

Describe the Bug

A spout will not fill empty buckets placed on either a depot or conveyor belt. Same behavior with all fluids.
(Empty bottles are correctly filled however.)

Reproduction Steps

  1. Place a spout over a depot (or over an running conveyor belt)
  2. Fill the spout with water (or any other appropriate liquid that a bucket can take)
  3. Place empty buckets on the depot (or the belt)
  4. Output buckets are empty

Expected Result

Output buckets should be filled with water (or any other appropriate liquid).

Screenshots and Videos

2024-02-18_14 47 06
2024-02-18_14 52 47

Crash Report or Log

crash-2024-02-18_15.16.11-client.txt

Operating System

Windows 10

Mod Version

0.5.1f

Minecraft Version

1.20.1

Other Mods

Removed all other mods. Same issue.

Additional Context

Using build create-fabric-0.5.1-f-build.1242+mc1.20.1.jar

commented

please crash your game by holding F3+C for 10s and attach the crash report

commented

Crash report attached :
crash-2024-02-18_15.16.11-client.txt

commented

please downgrade fabric api to 0.88.1

They are using the 0.5.1f builds so they dont need to do that.

commented

please downgrade fabric api to 0.88.1

commented

ah indeed. dev build I guess.

commented

I tried anyway (forcing build.1242 to take fabric api to 0.88.1 by altering its json file). But still the same problem.

Interestingly, the recipe "empty bucket -> water bucket" doesn't show up in JEI.
2024-02-18_15 26 12

I also noticed (don't know if related, but it might), that item drains are outputing buckets that are still full.

commented

I managed to temporarilly hack my way :

public class GenericItemFilling {
	public static ItemStack fillItem(Level world, long requiredAmount, ItemStack stack, FluidStack availableFluid) {
		FluidStack toFill = availableFluid.copy();
                Fluid fluid = toFill.getFluid();
                ...

                        t.commit();
			stack.shrink(1);

                        ItemVariant itemVariant = ctx.getItemVariant();
                        ItemStack container;
                        if (itemVariant.getItem() == Items.BUCKET) {
                            if (FluidHelper.isWater(fluid)) container = new ItemStack(Items.WATER_BUCKET);
                            else if (FluidHelper.isLava(fluid)) container = new ItemStack(Items.LAVA_BUCKET);
                            else if (fluid == Milk.STILL_MILK) container = new ItemStack(Items.MILK_BUCKET);
                        }
                        else container = itemVariant.toStack((int)ctx.getAmount());

                        return container;
               ...

Not a good solution , I know. But I didn't understand what the root cause was.

commented

I managed to temporarilly hack my way :

public class GenericItemFilling {
	public static ItemStack fillItem(Level world, long requiredAmount, ItemStack stack, FluidStack availableFluid) {
		FluidStack toFill = availableFluid.copy();
                Fluid fluid = toFill.getFluid();
                ...

                        t.commit();
			stack.shrink(1);

                        ItemVariant itemVariant = ctx.getItemVariant();
                        ItemStack container;
                        if (itemVariant.getItem() == Items.BUCKET) {
                            if (FluidHelper.isWater(fluid)) container = new ItemStack(Items.WATER_BUCKET);
                            else if (FluidHelper.isLava(fluid)) container = new ItemStack(Items.LAVA_BUCKET);
                            else if (fluid == Milk.STILL_MILK) container = new ItemStack(Items.MILK_BUCKET);
                        }
                        else container = itemVariant.toStack((int)ctx.getAmount());

                        return container;
               ...

Not a good solution , I know. But I didn't understand what the root cause was.

Yeah the issue is ctx.getItemVariant returns a empty bucket, need to somehow apply the filled tank to it and grab the filled bucket

commented

Isn't the exchange in the context supposed to happen here ? Do you know why it's not happening ?

public final class EmptyItemFluidStorage implements InsertionOnlyStorage<FluidVariant> {
   public long insert(FluidVariant resource, long maxAmount, TransactionContext transaction) {
   ...
			ItemVariant newVariant = emptyToFullMapping.apply(context.getItemVariant());
			if (context.exchange(newVariant, 1, transaction) == 1) {
commented

because the context is constant

commented

Thanks, very clear. The latest version of porting_lib defines a MutableContainerItemContext that would be quite useful here. Not available on 1.20.1 though.

commented

Just confirmed that replacing

       ContainerItemContext ctx = ContainerItemContext.withConstant(split);`

by

        ContainerItemContext ctx = new MutableContainerItemContext(split);

works like a charm indeed !

Need to find a way to properly bring this to 1.20.1, I guess...

commented

Just confirmed that replacing

       ContainerItemContext ctx = ContainerItemContext.withConstant(split);`

by

        ContainerItemContext ctx = new MutableContainerItemContext(split);

works like a charm indeed !

Need to find a way to properly bring this to 1.20.1, I guess...

im working on porting it to 1.19.2 & 1.20.1 already

commented

Impressive reponsiveness !

Do you need a distinct issue to fix "Drain won't empty Buckets" ?
Same root cause, same fix, but in GenericItemEmptying this time, I think.

commented

Impressive reponsiveness !

Do you need a distinct issue to fix "Drain won't empty Buckets" ? Same root cause, same fix, but in GenericItemEmptying this time, I think.

nah its fine ill fix that aswell

commented

To fix JEI, the same modification should be made to SpoutCategory.consumeRecipes and ItemDrainCategory.consumeRecipes .
(In each method, the first context creation used for test can stay constant, but the second one needs to be mutable.)

Are you including those as well, while you're at it ? Or do you prefer a distinct issue to log and fix the JEI problem separately ?

commented

To fix JEI, the same modification should be made to SpoutCategory.consumeRecipes and ItemDrainCategory.consumeRecipes . (In each method, the first context creation used for test can stay constant, but the second one needs to be mutable.)

Are you including those as well, while you're at it ? Or do you prefer a distinct issue to log and fix the JEI problem separately ?

Fixed that aswell