Mods / No offline food spoil

Tags: #Food #QoL #Tweak
Author: Wiltoga
Side: Server
Created: Oct 10th 2023 at 7:43 AM
Last modified: Oct 14th at 7:27 PM
Downloads: 9131
Follow Unfollow 284

Latest release (for Vintage Story 1.19.8, 1.20.0, 1.20.12, 1.21.0 and 1.21.4, potentially outdated):
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.

Mod Version Mod IdentifierFor Game version Downloads Released Changelog Download 1-click mod install*
1.4.0 offlinefoodnospoil 5298 Dec 28th 2024 at 7:13 PM OfflineFoodNoSpoil_1.4.0-1.20.zip 1-click install

Added a MaxAllowedSkippedHours field

1.3.2 offlinefoodnospoil 192 Dec 28th 2024 at 6:43 PM OfflineFoodNoSpoil_1.3.2-1.20.zip 1-click install
  • Only prevents item spoiling if it is Perishable. It no longer prevent dryable items, or any other time defined transition to occur. That also means that a Perishable item that is also Dryable (the redmeat using the A Culinary Artillery mod for example) won't dry while offline.
  • Recursively prevent food spoil for complex spoilable items (if you somehow managed to put a cooking pot inside another one). For future proofing and compatibility with other mods.
1.3.1 OfflineFoodNoSpoil 402 Dec 18th 2024 at 6:37 PM OfflineFoodNoSpoil_1.3.1-1.19.zip 1-click install

- Fixed an issue ignoring the EnableMod configuration, making the mod always enabled.

1.3.0 OfflineFoodNoSpoil 290 Dec 15th 2024 at 8:42 PM OfflineFoodNoSpoil_1.3.0-1.19.zip 1-click install
  • Fixed client side crash and data corruption when using the butchering mod
  • Changed how the mod works : No longer increase the total food duration by the time the user went away. Instead, resets the last update time without decreasing the freshness to avoid potential bugs with other mods using the freshness.
  • Default settings disable logging.
1.2.0 OfflineFoodNoSpoil
1.18.14 - 1.18.15
1116 Jan 11th 2024 at 8:40 PM OfflineFoodNoSpoil_1.2.0.zip 1-click install

Added config file, to disable the mod entirely, toggle logs, or change the spoil rate if you don't want to disable it completely.

Configs are hot reloadable, you don't need to restart the server for them to take effect.

1.1.1 OfflineFoodNoSpoil 765 Oct 12th 2023 at 4:39 PM OfflineFoodNoSpoil_1.1.1.zip 1-click install

Fixed some crash client-side.

No more cache usage (no longer saves data on player disconnect).

No longer requires an initial player disconnect, now works out of the box even for currently offline players.

1.1.0 OfflineFoodNoSpoil 317 Oct 12th 2023 at 8:14 AM OfflineFoodNoSpoil_1.1.0.zip 1-click install

Fixed issues in creative mode

Added support for cooked pots and bowls

1.0.1 OfflineFoodNoSpoil 389 Oct 10th 2023 at 7:39 PM OfflineFoodNoSpoil_1.0.1.zip 1-click install

Added icon in vintage story mod menu.

1.0.0 OfflineFoodNoSpoil 362 Oct 10th 2023 at 7:46 AM Empty OfflineFoodNoSpoil_1.0.0.zip 1-click install

42 Comments (oldest first | newest first)

💬 SpacedInvader, Oct 26th at 5:03 AM

i have this installed, checked the values and they all seem to be "on"....but it does nothing for me, my food still spoils when i'm offline :(

💬 Wiltoga , Oct 17th at 4:11 PM

Hi @Liiw, sadly it is way waay more complicated to do such feature, and I'm not even sure it is possible to do. It has been requested a few times and while it is a great idea for a mod, it will make cellars op for other players. This mod aims to prevent your prepared food from decaying while you're out of base (which usually spoils faster than vegetables/grains in cellars), but I think that cellars are pretty balanced in vanilla already even in multiplayer (maybe adjust the foodSpoilSpeed worldconfig). In short, it's not the goal of the mod and it's more a server issue imo (and it will take me months to make).

💬 Liiw, Oct 15th at 6:46 AM

Hello!

I have used this mod extensively in the past and I have liked it. I had a question regarding a possible feature. How hard would it be to set a similar "stasis" on food that is located in a claim? For example, I put a bunch of food in my cellar that is in my claimed territory and now I log out. And while I'm logged out, the food does not spoil. Once I log back in, the food starts "ticking" again.

I have been playing in servers where there is constantly someone online. I log out one evening and because of life, I am not able to log in the following evening. When I finally do log back in, all my food has gone bad. I was thinking that would be one solution for this issue.

💬 OneOnlyKIHA, Oct 9th at 8:18 PM

Does the mod work on 1.21.4?

 

💬 Ensorcelled, Sep 26th at 4:51 PM

Kudo's works like a champ. Tested heavily, no issues we could see.

💬 El_Neuman, Sep 26th at 2:18 PM

Love you man, thank's for an update!)

💬 Remiska, Sep 14th at 4:58 AM

Does this work on version 1.21.1?

💬 Wiltoga , Aug 31st at 6:15 AM

Tried on my server with 4 friends, it works as expected. But no bug has been fixed about the issues some people brought up.

💬 jimtown, Aug 29th at 5:21 PM

Does this work on 1.21?

💬 Wiltoga , Jul 31st at 7:13 PM

This may be a decent theory.

There are other means to bypass this, such as adding huge freshness to food on disconnect then patching it back upon reconnecting, not sure if it works and IF it fails, it will pretty much either make food infinite or spoils it instantly.

I don't have much experience modding this game, so I don't know every possibility. Anyway, if your theory is right, I fear it will be pretty tricky to fix it. I remember testing my mod with another event (not PlayerJoin but one that fires a bit later) and it still worked. Maybe this is it, but as I fail to reproduce the bug, it will be pretty hard to garantee the fix of the issue.

💬 dizzyd, Jul 27th at 6:43 PM

Hi Wiltoga - I have a theory for what's going on with servers. I do not believe that mods are loaded in any specific order (and may even have race conditions when loading), so adding your event handler to the PlayerJoin event isn't guaranteed to fire before other mods which may interact with the inventory. Any interaction with the inventory when the player joins would trigger the spoil calculations (e.g. another mod calls MarkDirty() on the inventory before you get the PlayerJoin event would cause everything to spoil). If you could ensure your event handler runs first, that's likely to resolve the problem.

 

In terms of how to ensure your handler runs first -- it's hacky. You'd need to intercept whatever fires the delegate using a monkey patch and run your code prior to the allowing it to fire any other delegates. Other options include intercepting Collectible.UpdateAndGetTransitionStates and track if your code has had a chance to run yet - you'd need to keep an eye on the player join events and track once your code has had a chance to run per-player, per-join. 

Of course, all this is just a theory. :)

Rythillian DerricGrayrat SecretFoxfire - if you can provide a list of the mods you're using, I can try to reproduce and validate this theory.

💬 Rythillian, Jul 5th at 6:16 PM

Doesn't appear to be working on 1.20.12? Players on my server are still having food in their inventory rot.

💬 Wiltoga , May 19th at 4:33 PM

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, May 18th at 4:36 PM

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)
Основной веб-сайт | Почтовый сервер | FTP сервер | Административная панель | API интерфейс | Content Delivery Network | Статические файлы | Ресурсы сайта | Изображения | Файловое хранилище | Блог | Интернет-магазин | Техническая поддержка | Справочная система | Документация | Форум | Новости | Загрузки | Демонстрация | Тестовая среда | Приложение | Медиа контент | Разработка | Промежуточная среда | Бета версия | Безопасная зона | Вход в систему | Панель управления | Портал | Система управления контентом