Mods / No offline food spoil

Tags: #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: 5278
Follow Unfollow 169

Latest release (for outdated Vintage Story 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 2440 Dec 28th 2024 at 7:13 PM Show OfflineFoodNoSpoil_1.4.0-1.20.zip 1-click install
v1.3.2 59 Dec 28th 2024 at 6:43 PM Show OfflineFoodNoSpoil_1.3.2-1.20.zip 1-click install
v1.3.1 286 Dec 18th 2024 at 6:37 PM Show OfflineFoodNoSpoil_1.3.1-1.19.zip 1-click install
v1.3.0 162 Dec 15th 2024 at 8:42 PM Show OfflineFoodNoSpoil_1.3.0-1.19.zip 1-click install
v1.2.0 1003 Jan 11th 2024 at 8:40 PM Show OfflineFoodNoSpoil_1.2.0.zip 1-click install
v1.1.1 642 Oct 12th 2023 at 4:39 PM Show OfflineFoodNoSpoil_1.1.1.zip 1-click install
v1.1.0 190 Oct 12th 2023 at 8:14 AM Show OfflineFoodNoSpoil_1.1.0.zip 1-click install
v1.0.1 258 Oct 10th 2023 at 7:39 PM Show OfflineFoodNoSpoil_1.0.1.zip 1-click install
v1.0.0 238 Oct 10th 2023 at 7:46 AM Show OfflineFoodNoSpoil_1.0.0.zip 1-click install

30 Comments (oldest first | newest first)

💬 Wiltoga , 2 days ago

Hi everyone, I tried the mod in 1.4.0 version on a 1.20.10 game server (hosted locally and on remote). I again had no issue, so I can't fix a bug I can't reproduce sadly. I you ever encounter an issue, give me as much details as possible, including the logs (if any), the current player inventory would be very useful (preferrably as a screenshot, as modded inventories are not yet supported). The player count would be great too, just to know if it is related to server performances. If you are using a mod adding custom player inventories (like new bags, or more slots), they may not work. Technically, every kind of inventory has a 'class' (like "hotbar", "backpack", but also "creative", ...) Right now, only "hotbar" and "backpack" are allowed, maybe the problem comes from here

💬 DerricGrayrat, 3 days ago

Hey everyone,
I run Vintage Saga and I’m a bit concerned some of you may be experiencing issues with the No Spoilage mod not working correctly. If that's the case or if you need access to logs for troubleshooting, please reach out to me directly. I want to make sure we get this resolved as quickly as possible.

💬 Scorives, May 8th at 8:58 AM

Server Error] Exception: Object reference not set to an instance of an object.
at Wiltoga.OfflineFoodNoSpoil.ItemPerishValue..ctor(ItemStack stack)
at Wiltoga.OfflineFoodNoSpoil.ItemPerishValue..ctor(ItemStack stack)
at Wiltoga.OfflineFoodNoSpoil.PerishService.PreventInventorySpoil(IInventory inventory, Settings settings)

 

issue works only half of the time.

💬 Pr0fesseur, Mar 13th at 10:18 AM

would you be able to add the functionality to apply this effect always for a single player?

💬 SecretFoxfire, Mar 6th at 10:05 PM

+1 to this not always working on servers. On my (1.20.4) server, it only seems to work some of the time. Half the food people log out with is spoiled when they log back in. On the other hand, about half the time it works fine. No idea why. :(

💬 Wiltoga , Feb 6th at 5:54 PM

I do use Expanded Foods on my server and the mod is working fine. One way I think it may break, is if the server fully computes the food decay before my mod can patch it. If it is the case, then I fear it is unlikely to be fixed as this is a core mechanic of the game

💬 Exodus7656, Feb 4th at 5:39 AM

Could this mod, by chance, not work with Expanded Foods?

💬 Exodus7656, Feb 4th at 5:38 AM

The file "OfflineFoodNoSpoil.json" in the ModConfig folder contains this exact text:

{
"EnableMod": true,
"UseLogs": false,
"FoodSpoilMultiplier": 0.0
}

💬 Wiltoga , Feb 3rd at 7:48 PM

Tested on my 1.20.3 server, everything works fine. Can you provide me with the full config file ? Perhaps contact me on the official discord of the game so I can look deeper into it

💬 madcatandrew, Feb 3rd at 6:44 PM

Same case on my 1.20.3 server, mod seems to not be functioning for any players.

💬 Exodus7656, Feb 1st at 11:51 PM

I have this mod on my server and my food spoiled while I was offline.  The mod is enabled and has all default values set.

Game version 1.20.3

💬 Wiltoga , Jan 27th at 8:40 PM
  1. Nothing is easy when you don't know yet how to do it (at the technical level).
  2. This mod is only for offline players inventory. Allowing unperishable infinite storage is absolutely unbalanced.
  3. This is in no way the goal of this mod, nor is it my goal. I made this mod for me and my friends on our server before anything.
  4. Again, if you have such a problem with food rotting on a multiplayer server, just disable rotting already instead of introducing storage shenanigans. 
💬 Luke_16, Jan 25th at 11:46 PM

Maybe, if padlocks, when used on chests (and hopefully storage vessels could set lockable to ture,) would only have their contexts rot when the player who locked it is on! Would that be easier?

💬 Luke_16, Jan 25th at 11:33 PM

* without a ritualistic log-off routine of filling your inventory with food

💬 Luke_16, Jan 25th at 11:30 PM

Wiltoga: Yes, but drops the rate of decay to 0. Multiply any food decay rate by a number, and my boss's surprise overtime will find a way to outlast it, so having something that, with enough effort, can create a small reserve for when one logs back on in winter after a week is the goal?

💬 Wiltoga , Jan 25th at 1:55 PM

Luke_16 Something like this mod ?

💬 Luke_16, Jan 23rd at 6:47 AM

@Wiltoga. My friends want to preserve rotting as mechanics but don't want to be punished for having a life throughout the whole game. Would it be easier to create a new craftable block to store food without rot? Say, needing temporal gears, copper-nickel, gold... late game items to craft and maybe* powered as a late-game solution? Like mashing a recolored chest with the sound of a storage vessel and having the power requirements pasted from a helve hammer or something? You know, before I ask someone politely or hopefully not fail while trying myself:) 

💬 Wiltoga , Jan 20th at 10:24 PM

A mod that prevents spoil in chests just because someone claimed it is a lot of work for little to no benefit at all.

If you really have a multi-player issue with rot in chest, the only true solution is to adjust the server config or disable chest spoilage at all. User claimed area will just raise more issues or bugs.

 

And again, if you find a bug and want me to fix it, I'm all good, but do provide me with more data than just "doesn't work in 1.20". Tell me your mod list, how you managed to find the bug, how to reproduce, with which item, EVERY step can be useful. 

💬 Luke_16, Jan 20th at 12:52 AM

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, Jan 18th at 11:53 PM

does not work in 1.20.

The only food mod we are using is A culinary artillery 

💬 Wiltoga , Jan 17th at 6:17 PM

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, Jan 17th at 3:50 PM

The latest version isn't working with pies

💬 GlooMeGlo, Jan 15th at 11:56 PM

doesn't work in 1.20.0-rc.9

💬 Wiltoga , 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?

💬 Wiltoga , 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)