Stormwind99 / FoodFunk

Minecraft mod: What is that funky smell in my backpack? Food spoils over time unless preserved. Configure any item to rot, any container to preserve items.
https://minecraft.curseforge.com/projects/food-funk
GNU Lesser General Public License v3.0
10 stars 8 forks source link

'Storage item' support aka melon support #22

Closed esotericist closed 6 years ago

esotericist commented 6 years ago

There's a lot of cases where you can craft edible items back and forth between a dense 'storage item'.

The simplest example is vanilla, where you can craft melon slices into a melon block for storage, which by default in FoodFunk doesn't rot.

But even outside of that, Forestry has its carton concept, Vanilla Food Pantry has both bags and cartons, all usable for medium to long-term storage.

Right now, in Food Funk, these are essentially crafting 'new items', so their rot timer is completely reset. It'd be nice to be able to specify transitional items that should preserve the rot percentage when crafting to/from that item.

As a completely arbitrary (and not realistic) example: if eggs last 7 days, and a carton of eggs last 14 days, spending 3 days as raw egg would have it as ~43% for the carton of eggs, as if it was ~ 6 days old. But then if you unpackage it (craft it back) four days later, at ~71%, you have eggs that are aged ~5 days instead of 7 (and thus rotted).

I wouldn't want this to be the case with all food items, though. My plan for my server's mod pack is for finished product foods (such as a sandwich) to decay faster than the ingredients that went into it (after all, you can often store deli meat and a loaf of bread for longer than you can successfully store the sandwich without special effort), which would make using up materials at the last minute essentially impossible (the food would likely rot faster than the person could eat it).

I don't know how feasible any of this is, but it'd help close off temptation to 'cheese' food funk without disabling these mechanisms entirely. If you were using NBT instead of capabilities, I could probably wing it with crafttweaker, but sadly that isn't feasible here. :)

Stormwind99 commented 6 years ago

Basic support for vanilla "storage item blocks" is in master branch now (not released yet).

Example: Melons last 14 days, breaking a melon gives slices that last 7 days, and re-crafting a melon from those slices gives a melon that lasts 7 days (or the shortest time of any component slice used to craft it).

Stormwind99 commented 6 years ago

Released in 4.2.0 (at least for vanilla items).

When a melon block is broken into slices, the rot expiration time for the slices will be the earliest of the source block's expiration time and the resulting items's normal rot expiration time. When crafting a melon from slices, the melon's expiration time will be the earliest of the component slices (and the resulting melon's normal expiration time, but that is so much larger that it won't have an effect in this example).

You wouldn't believe the amount of work to get everything working with block melons placed in worlds along with rot data staying with the object throughout its logical lifetime (from TileEntity/Block to EntityItem/ItemStack to ItemStack and back the other direction).

Should also work with other combo items if they don't have tileentity/block versions (just itemstacks). Due to MC/Forge limitations, a block has to have a tileentity to which to attach the rot capability and some don't have them, and the Block can't be overridden to support a 3rd party capability without code support. I hacked in something but it won't persist beyond one run lifetime - MC will filter out the placeholder tileentities it creates since the Block says it doesn't have a tileentity.

If you have any specific items from specific mods you'd like to suggest for testing and support, let me know. Or better yet, try them out and let me know the results! :-)