Food Spoilage and Preserved Foods

7 days to die food spoilage and preserved foods, 7 days to die recipes, 7 days to die food

Introduces food spoilage to the game, and new preserved foods that do not spoil.

  • ❌ NOT Server side only (clients do need to install the mod)
  • ❌ NOT EAC safe (clients and servers do need to disable Easy Anti-Cheat)

Features

  • Most foods that are not canned or otherwise preserved can now spoil.
  • Prepared drinks (such as teas) can now spoil.
  • Battery-powered refrigerators and beverage coolers can be crafted.
  • Recipes are unlocked in the same perk and level as battery banks.
  • New canned/preserved foods:
    • IPA (India Pale Ale). Beer that takes more hops to craft and doesn’t spoil.
    • Recipe unlocked in the same perk and level as the vanilla beer recipe.
    • Canned corn, mushrooms, potato, and pumpkin.
    • Recipes unlocked in the same perk and level as blueberry pie.
    • Preserved blueberries. Recipes unlocked in the same perk and level as blueberry pie.
    • “Shamway Fruit Pie” (in box, similar to Hostess or Drake’s). Loot only, cannot be crafted.
    • Smoked/cured meat. Recipe unlocked in the same perk and level as grilled meat.
  • Advanced recipes (stews, pies, etc.) have additional recipes that use the new canned vegetables and preserved blueberries.
  • Spoilable foods are removed from (non-Twitch) loot groups, and replaced with canned/preserved equivalents.

Dependent and Compatible Mods

Requires SCore version1.0.15.1402 or above. Earlier versions will not work!

Technical Details

This mod uses XPath to modify XML files, and does not require C#.

However, the 0-SCore mod does require C# code. It is not compatible with EAC.

Additionally, this mod contains new assets (icons). It must be installed on both clients and servers.

After installation, you absolutely must start a new game!

If you load up an existing game after installing this mod, it will become corrupted and you will lose the game world.

How Food Spoilage Works

This mod depends upon the food spoilage code provided by the 0-SCore mod. That mod has custom C# code that is configurable via XML. It is loosely based on item degradation from the vanilla game.

Food spoilage is calculated when the player opens a container with one or more stacks of consumable items in it. The term SpereII uses for this calculation is loss calculation.

A loss calculation can only happen after a certain number of game ticks since the last time the loss was calculated. This number of ticks is called ticks per loss. The ticks per loss is configurable in XML, and can be set individually per consumable item.

The loss caluclation can happen multiple times at once, if the ticks per loss would have been reached multiple times since the container was last opened. For example, if ticks per loss is 100, and it has been 1000 ticks since the user last opened the container, then the loss calculation will happen 10 times when the user opens that container.

Each time the loss calculation occurs, it uses a number of different values to determine the amount of food spoilage:

  • The spoilage amount starts as an amount specified for that consumable item in the item’s XML. This amount is called spoilage per tick (though it should probably be called “spoilage per loss” or “spoilage per calculation”).
  • The stack of consumable items is always located in some container, and that container adds a number to the spoilage amount. The container can be the player’s backpack, the player’s toolbar, or a loot container. All three of these locations have their values set globally in XML.
  • If the item stack is located in a loot container, that container can offset the global amount of spoilage that is added for all loot containers. This is called the preserve bonus of the container. The preserve bonus is subtracted from the spoilage amount.

Once that amount is calculated, it is compared against the total amount of spoilage that can occur before one consumable item spoils. That total amount of spoilage is called the maximum spoilage.

This process happens until the calculated spoilage amount is less than the maximum spoilage:

  • One consumable item is removed from the item stack.
  • A spoiled item, representing a spoiled version of the original item, is created.
  • The spoiled item can be specified in the XML for each consumable item, or defaults to rotten meat. If this is set to the consumable item itself, then the consumable item spoils into nothing.
  • The spoiled item is placed in the player’s backpack, creating a new stack if necessary. (It goes into the player’s backpack regardless of which container held the original item.) If there is no room in the player’s backpack, the spoiled item is dropped on the ground.
  • The maximum spoilage is subtracted from the calculated spoilage amount.

Here are the details about configuring all this in the XML files.

Feature Configuration Block XML

SphereII created a block in blocks.xml that is designed to hold feature configuration data for the entire Core mod. Each property node in that block is devoted to one feature, and that node has child property nodes that hold the configuration data.

The property node that deals with food spoilage has the “FoodSpoilage” class. These are the names of child property nodes and the features they configure:

  • “Logging”: Enables or disables verbose logging.
  • “FoodSpoilage”: Enables or disables food spoilage in the game.
  • “Toolbelt”: The amount of spoilage to add, per loss calculation, when consumable item stacks are located in the player’s toolbelt.
  • “Backpack”: The amount of spoilage to add, per loss calculation, when consumable item stacks are located in the player’s backpack.
  • “Container”: The amount of spoilage to add, per loss calculation, when consumable item stacks are located in loot containers.
  • “MinimumSpoilage”: The absolute minimum spoilage per loss calculation.
  • “TickPerLoss”: The default ticks per loss.
  • “SpoiledItem”: The default item that consumable items turn into when they spoil.
  • “UseAlternateItemValue”: Use the item’s meta value rather than use time for the current spoilage. This was introduced in 1.0, and is a technical workaround for split item stacks sharing the same spoilage, even in different containers. khzmusik enabled it, but it is still technically experimental.

Consumable Item XML

These can be added as new properties to each item in items.xml that is consumable.

  • “Spoilable”: Enables or disables food spoilage on this item.
  • “ShowQuality”: Whether to only show the quality bar underneath the item.
  • “QualityTierColor”: The tier number for the color of the quality bar underneath the item. This can be an integer from 0 through 7.
  • “SpoiledItem”: The item that this consumable item turns into when it spoils.
  • “TickPerLoss”: The ticks per loss for this consumable item.
  • “SpoilageMax”: The maximum spoilage before one consumable item spoils.
  • “SpoilagePerTick”: The spoilage “per tick” (actually, per loss).

Container Block XML

This can be added as a new property to each container in blocks.xml, as desired.

“PreserveBonus”: The preservation bonus, per loss calculation, for this container.

Hints for Customizing

khzmusik recommend that you keep SpoilageMax and SpoilagePerTick at their default values of 1000 and 1, respectively. This makes the math easier.

If SpoilageMax is 1000 and SpoilagePerTick is 1, then TickPerLoss should be the number of in-game hours that it takes for one item to spoil in ideal conditions. (The math works out because there are 1000 ticks per in-game hour.)

If we want n items to spoil in those in-game hours, set SpoilagePerTick to n (but don’t adjust TickPerLoss).

There will be an extra number of items spoiled according to the stack location, and the container block’s PreserveBonus value (if any). For instance, if the stack is in a “Container” (set to 4 in the config block), and the container block has a PreserveBonus of 1, an extra 3 items will spoil in that number of in-game hours. (The spoilage will not occur until the next loss tick, as determined by TickPerLoss.)

This actually makes some fairly complicated things possible. For example, let’s say that you don’t want corn bread to be affected very much by the container it’s in. But you still want as many items to spoil as any other food – say, 3 times per week.

In this case, you can use a longer number of in-game hours to represent the time it takes for one piece of cornbread to spoil – say, 4 weeks. To make up for it, you set the SpoilagePerTick to 12, so it still averages out to 3 per week.

Even if an extra 4 pieces of cornbread spoil because it’s in a container with no PreserveBonus value, those 4 pieces are spread out over 4 weeks, so they’re much less noticable to players.

On the other hand, if you want meat stew to be very affected by the container it’s in, use a short number of in-game hours – say, 2 days – and set SpoilagePerTick to 1. If it’s in a container with no PreserveBonus value, an extra 4 bowls of stew will spoil during those 2 days. But if it’s in a container with a PreserveBonus value of 2, only 2 extra bowls of stew will spoil during those same two in-game days.

Changelog

  • (new) Disable UseAlternateItemValue(this is causing issues where items spoiling in the backpack continuously generate spoiled items.)
  • Updated for V1.0.
  • Food skill magazines no longer spoil; bump patch version.
  • Updated for A21.

DOWNLOAD (8,5 MB)

The forum topic of the mod is here.

Credits: khzmusik

Share this with your friends:
Subscribe
Notify of
guest

If you have any questions or have any problems/bugs, please use the support link (Discord, Forum Topic, GitHub Issues, etc.) in the post. If there is no support link in the post, please use the comments section.

7 Comments
Inline Feedbacks
View all comments
shrader971
shrader971
October 28, 2024 2:22 am

my i use and alter your mod for my overhaul.

Mübarek SUNGUR
Mübarek SUNGUR
August 2, 2024 2:47 pm

Mod yapmasını bilen biri lazım bana yardımcı olacak

SOBEK
SOBEK
July 30, 2024 12:10 am

Helo. All canned food have”unit_iron” in recipes, you need change this to”resourceScrapIron” because it dont work with “unit_iron”. Stay save.

joni
joni
September 5, 2023 5:00 pm

hello can you update mods please

MK Casero
MK Casero
July 17, 2023 9:16 am

needs update, essential immersion mod

Takiktos
Takiktos
December 1, 2022 5:11 pm

(By the way. Great mod, adds immersion and food management requirement)

How do I do that

I want to make the refrigerators allow almost or completely disable the effect of food spoilage.
Is it enough to change the lines of code “preservedbonus from 1.5 to e.g. 1000 000 000” in the blocks.xml file?

To be honest, when checking, it doesn’t seem to work

Takiktos
Takiktos
January 4, 2023 3:41 pm
Reply to  Takiktos

Will there be another update?