Mods / No offline food spoil

Category: #Food #QoL #Tweak
Author: Wiltoga
Side: Server
Created: Oct 10th 2023 at 7:43 AM
Last modified: Dec 28th 2024 at 7:13 PM
Downloads: 3054
Follow Unfollow 114

Latest file for v1.20.0:
OfflineFoodNoSpoil_1.4.0-1.20.zip 1-click install


Imagine, you are going for an aventure outside your home. You hunt a few deers and other animals. But there are UFO outside your house (IRL), and need a quick military negociation with them. But when you log back into the multiplayer server in Vintage Story, all your food has perished, thanks to those aliens because you spent too much time offline with food in  your inventory.

When a player is disconnected from a server, all its food stored in its hotbar and backpacks (not the chests nor anything accessible from other players) no longer spoils. It also prevents items to progress any other timed transition, such as drying if it is a spoilable item.

Only works server-side, no need to install on client.

Configuration

The mod can be configured by tweaking a few parameters in the VintagestoryData/ModConfig folder (OfflineFoodNoSpoil.json).

The configuration is Hot-Reloaded, meaning that a change to the configuration file won't require a server restart. It will work out of the box.

Field Description
EnableMod

Set to true to enable the mod. If  set to false, the mod will do nothing.

Default: true.

UseLogs

Enable or disable logging in the terminal. Used for debugging.

Default: false.

FoodSpoilMultiplier

A value between 0 and 1. Custom multiplier for the elapsed offline time.

0 means that there will be 0% of the elapsed time used for the spoil rate. Basically, the food spoil rate will be entirely stopped.
A value of 1 means that there will be 100% of the elapsed time used for the spoil time, basically disabling the mod and no spoil rate will be slowed at all.

Default: 0.0.

MaxAllowedSkippedHours

(Optional) A final max amount of hours allowed of skipping. If the skipped time is bigger than this value, it will be clamped.

 

Default: null.

Time computation

The skipped time is computed this way, with a offline duration of 48 hours :

  • First get the elapsed time while offline. Here 48 hours.
  • Apply the multiplier. Here let's say we have a multipler of 0.25. That means 25% of the elapsed time will be applied on the food.
    48 hours * (1 - 0.25) = 36 skipped hours
  • Then if MaxAllowedSkippedHours is defined, we use it to clamp the value. Here the value is 30 hours.
    Since 36 is bigger than 30, we get 30 skipped hours. Otherwise, we would get 36 hours.

Each perishable item in the inventory will skip 30 hours before applying the remaining time : 48 - 30 = 18 actual hours applied on the perishable food.

Version For Game version Downloads Release date Changelog Download 1-click mod install*
v1.4.0 608 Dec 28th 2024 at 7:13 PM Show OfflineFoodNoSpoil_1.4.0-1.20.zip Install now
v1.3.2 23 Dec 28th 2024 at 6:43 PM Show OfflineFoodNoSpoil_1.3.2-1.20.zip Install now
v1.3.1 246 Dec 18th 2024 at 6:37 PM Show OfflineFoodNoSpoil_1.3.1-1.19.zip Install now
v1.3.0 115 Dec 15th 2024 at 8:42 PM Show OfflineFoodNoSpoil_1.3.0-1.19.zip Install now
v1.2.0 951 Jan 11th 2024 at 8:40 PM Show OfflineFoodNoSpoil_1.2.0.zip Install now
v1.1.1 596 Oct 12th 2023 at 4:39 PM Show OfflineFoodNoSpoil_1.1.1.zip Install now
v1.1.0 142 Oct 12th 2023 at 8:14 AM Show OfflineFoodNoSpoil_1.1.0.zip Install now
v1.0.1 186 Oct 10th 2023 at 7:39 PM Show OfflineFoodNoSpoil_1.0.1.zip Install now
v1.0.0 187 Oct 10th 2023 at 7:46 AM Show OfflineFoodNoSpoil_1.0.0.zip Install now

12 Comments (oldest first | newest first)

💬 Luke_16, 21 hours ago

I've been looking. Is there any mod that would make it so that every time I log off, all my animals and food don't disappear and rot? Maybe tie rotting to a claimed area or create a tag for anyone who touched the food so that it would only rot when they are on?

💬 GlooMeGlo, 1 day ago

does not work in 1.20.

The only food mod we are using is A culinary artillery 

💬 WiltogaAuthor, 3 days ago

I have not tried in 1.20-rc.9 and will not fix if any bug is found in this version of the game since the stable 1.20 is out.

I tried my mod in 1.20 and everything is working as intended so far, including pies.

 

If you find an issue, please also provide additional informations such as the logs, your mods list (especially if a mod changes how food works) or any context that could help me reproduce the bug.

Even better, send an issue in the issue tracker (if you have a github account), or ping me in the Vintage Story official discord

💬 Tlecuauhtli, 3 days ago

The latest version isn't working with pies

💬 GlooMeGlo, 4 days ago

doesn't work in 1.20.0-rc.9

💬 WiltogaAuthor, Dec 28th 2024 at 7:41 PM

MishkaSnep Done in 1.4.0+ versions.

💬 MishkaSnep, Dec 28th 2024 at 6:49 PM

Is it possible to have it configurable? to stop abuse of someone just grabbing all the food they have everytime they log off? Like it only just slows it down a bunch or it keeps decaying for a day then stops?

💬 WiltogaAuthor, Dec 15th 2024 at 8:44 PM

After a year without updates, I fixed bug with the Butchering mod.

💬 Klos, Jun 2nd 2024 at 6:47 PM

I second the player data corruption with Butchering mod. We've had to wipe player data quite a few times. WhiskeySunshine

💬 WhiskeySunshine, May 5th 2024 at 11:57 PM

The mod works fine in 1.19.7 stable but is incompatible with butchering in that, if you have animal corpses in a backpack slot, it will cause an "object reference not set to an instance of an object" null reference exception that requires wiping player data to reconnect to the world or server.

💬 KonaCoffeeDrgn, Jan 21st 2024 at 5:42 AM

Seems to work for 1.19.1 (At least does not crash to desktop)

💬 Telemachus, Oct 21st 2023 at 12:44 PM

Had a crash with this mod enabled. Crash log here.

Context: I was knapping a flint knife head - using Nats Survival Expanded mod. The last piece of flint I had broke, and then I CTD'd. 

I could not load the world again after this. It immediately CTD'd with that same crash log each time. The crash log does not indicate any specific mod to be the cause, however, after painstakingly trying to load the world a few mods at a time, I narrowed it down to the OfflineNoFoodSpoil mod. Once that was removed, I could finally load the world again, and I've been playing as normal. 

I'm not well versed in C# whatsoever, so I doubt that I'm interpreting the crash log correctly, but it almost seems like there was some issue in the base game code itself. I hope you'll be able to make something of it. I'd really like to add this mod back to our server. ✌🙏

(edit comment delete)