No way to add `DrinkableProperty`s to external fluids
CammiePone opened this issue ยท 3 comments
So I was messing around with the TFC barrel's CraftTweaker support to add some other mods' alcohols to them (Growthcraft and Rustic), and it turns out that the jug is unable to hold any liquids that aren't programmed in through a mod.
So my suggestion was to add in CraftTweaker support for adding liquids that they can hold, along with the effects of drinking those liquids. This would be very useful for modpack makers who want to use TFC in their modpacks.
After some experimentation, this is entirely possible using our existing fluid APIs (and of 715c6f8 it's also possible to remove and/or replace drinking properties of existing fluids.)
FluidsTFC.getWrapper(FluidRegistry.LAVA).with(DrinkableProperty.DRINKABLE, player -> {
player.attackEntityFrom(DamageSource.ON_FIRE, 1.0f);
player.setFire(10);
});
While I see the utility of this, you're basically asking "can I execute custom code on drink" (as that's the level of complexity that the current drinkable implementation uses.) And given we're not doing any sizable craft tweaker additions to 1.12 (since none of it is getting taken with us to 1.15+), there's basically no chance that this will become scriptable.
Now, looking at our implementation, what definitely should be done is exposing the API to not only use a list of fluids hard coded to TFC and drinkable, but instead look for any fluid for which a drinkable property is exposed (essentially making this available to addons).
Huh, I could've sworn CraftTweaker supported potion effects... ah well, I also get it's unlikely to see the change even if it could be done. I fully expected 1.15 to be the priority, and 1.12 to be unlikely to receive future updates except maybe for game-breaking bugs, but thought who knows, maybe.
This was sorta what I had in mind btw for implementing it. Mostly pseudocode, but based on my own experience with CraftTweaker support. No idea if IPotionEffect exists, or if it would carry amplifier values, the two booleans, and/or the duration values, but I would think CraftTweaker would have something like it:
public static void addJug(IIngredient drink, int thirst, IPotionEffect[] effects)
{
for(IItemStack stack : drink.getItems())
{
for(IPotionEffect effect : effects.getPotionEffects())
{
// Do stuff to the player's thirst levels and apply potion effects with lengths and amplifiers).
}
}
}