Supplementaries

Supplementaries

127M Downloads

[๐Ÿž]: Thirst was Taken Purity component not propagated to Cauldrons by Faucet

Closed this issue ยท 6 comments

commented

Before Continuing:

  • Check you are using the latest version of the mods and its dependencies
  • Always include a latest.log if you are crashing
  • Remove mod that enhances Minecraft: Optifine, Sodium, others. The issue persists.
  • If you are unsure which mod is the culprit.
    Disable all of your mods and enable them 1-2 mods each time to isolate the culprit
  • Confirm that there is no existing issue with a similar description submitted in the list of issues.

Version

1.21.1-NEOFORGE

Supplementaries Version

1.21-3.1.7

Moonlight Lib Version

1.21-2.18.13

Describe Issue

Thirst was Taken works great with Supplementaries for the most part, but unfortunately there is a bit of an exploit where passing water through a faucet to a Cauldron doesn't propagate its thirst component. The vanilla Cauldron doesn't store fluids the same as any modded container so it requires some extra work to not cause exploits.

I tried fixing this myself by making the following mixin for my Thirst was Fixed mod, but unfortunately WaterCauldronInteraction is package-private so I can't.

@Mixin(WaterCauldronInteraction.class)
public class WaterCauldronInteractionMixin {

    //filling empty cauldron
    @Inject(method="fill(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/mehvahdjukaar/supplementaries/common/block/faucet/FluidOffer;)Ljava/lang/Integer;", at= @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/Level;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z", ordinal = 0))
    private void thirstwasfixed$fillCauldron(Level level, BlockPos pos, BlockState state, FluidOffer offer, CallbackInfoReturnable<Integer> cir) {
        int purity;
        try {
            purity = offer.fluid().get(ThirstComponent.PURITY);
        } catch (NullPointerException e) {
            //No purity? set to default
            purity = CommonConfig.DEFAULT_PURITY.get();
        }
        level.setBlock(pos, state.setValue(WaterPurity.BLOCK_PURITY, purity + 1), 3);
        //block purity is offset by 1
    }

    //filling water cauldron
    @Inject(method="fill(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/mehvahdjukaar/supplementaries/common/block/faucet/FluidOffer;)Ljava/lang/Integer;", at= @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/Level;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z", ordinal = 1))
    private void thirstwasfixed$fillCauldron2(Level level, BlockPos pos, BlockState state, FluidOffer offer, CallbackInfoReturnable<Integer> cir) {
        //etc
    }
}

Can this be made public (or even better, add native compatibility to Supplementaries)?

commented

There's a water.json in moonlight lib. That contains a list of component names to preserve from items to liwuid

commented

That's correct, and why it works so well most of the time - the issue is that the purity of water in a cauldron is stored in the blockstate of the vanilla water cauldron block. Unlike, say, Amendments' dye cauldron, there's no block entity to store a fluid stack here, so there's currently no way to preserve components from item to fluid.

commented

True, I could swear amendments replaced that with the tile entity one. Maybe not

commented

can you make a PR with this?

commented

btw you can still target package private classes with string reference in their mixin target. mixin way is also an option

commented

I got this working with Thirst Was Fixed 1.3.0