Mods / No offline food spoil
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 Default: |
UseLogs |
Enable or disable logging in the terminal. Used for debugging. Default: |
FoodSpoilMultiplier |
A value between
Default: |
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: |
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
MaxAllowedSkippedHoursis 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 Identifier | For 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 | ||
| |||||||
| 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 | |||||||
| 1.3.0 | OfflineFoodNoSpoil | 290 | Dec 15th 2024 at 8:42 PM | OfflineFoodNoSpoil_1.3.0-1.19.zip | 1-click install | ||
| |||||||
| 1.2.0 | OfflineFoodNoSpoil | 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 | |
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 :(
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).
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.
Does the mod work on 1.21.4?
Kudo's works like a champ. Tested heavily, no issues we could see.
Love you man, thank's for an update!)
Does this work on version 1.21.1?
Tried on my server with 4 friends, it works as expected. But no bug has been fixed about the issues some people brought up.
Does this work on 1.21?
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.
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.
Doesn't appear to be working on 1.20.12? Players on my server are still having food in their inventory rot.
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
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.
would you be able to add the functionality to apply this effect always for a single player?
+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. :(
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
Could this mod, by chance, not work with Expanded Foods?
The file "OfflineFoodNoSpoil.json" in the ModConfig folder contains this exact text:
{
"EnableMod": true,
"UseLogs": false,
"FoodSpoilMultiplier": 0.0
}
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
Same case on my 1.20.3 server, mod seems to not be functioning for any players.
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
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?
* without a ritualistic log-off routine of filling your inventory with food
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?
Luke_16 Something like this mod ?
@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:)
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.
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?
does not work in 1.20.
The only food mod we are using is A culinary artillery
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
The latest version isn't working with pies
doesn't work in 1.20.0-rc.9
MishkaSnep Done in 1.4.0+ versions.
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?
After a year without updates, I fixed bug with the Butchering mod.
I second the player data corruption with Butchering mod. We've had to wipe player data quite a few times. WhiskeySunshine
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.
Seems to work for 1.19.1 (At least does not crash to desktop)
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. ✌🙏