Timberborn

Timberborn

Not enough ratings
Moddable and Unlockable Recipe [U7 Only ✅]
   
Award
Favorite
Favorited
Unfavorite
Mod
File Size
Posted
Updated
84.204 KB
17 Mar @ 12:19pm
11 Apr @ 10:18pm
6 Change Notes ( view )

Subscribe to download
Moddable and Unlockable Recipe [U7 Only ✅]

In 1 collection by Luke ✞ Jesus Saves ✞
U7 Compatible Mods (My mods only)
75 items
Description
For players:

This mod is mainly for modders but when subscribing to this mod, you can have a new recipe called Inferior Treating in the Gear Workshop (moved from Lumber Mill (Folktails) and Industrial Lumber Mill due to compatibility issue). It's locked by default but you can unlock it by unlocking the Tapper's Shack.

Inferior Treating: 2x Planks + 2x Pine Resin + 9 hours = 1x Treated Plank. This recipe is much more expensive and time-consuming than the normal Treating recipe but it costs you less power and you can do it right away in the Gear Workshop without unlocking the Wood Workshop yet.

Known issue:
1. If you use a mod that add recipes then remove it when your save is using it, the game may crash. The devs are aware of this and this mod contains a temporary fix for it. Therefore if you have this issue, keep this mod on, change the recipe to the vanilla ones, save, then you can remove this mod.
2. If you pick a recipe that is locked, the select box may bug out a bit. Just unselect the building and select it again. It's only a visual bug.

3. Note that you CANNOT have a whole building (like Lumbermill) to have recipes where the same Good may appear in both Ingredients and Products even across recipes. For example, Inferior Treating cannot be in the Lumbermill because it uses Planks, which is the output of the default Plank recipe.

For modders:

Make adding and removing recipes easy for modders. Also add Locking & Unlocking recipes feature. If you need any help, please ping me on the Timberborn's Official Discord server.

Adding & Removing recipes

To make new recipes, simply create RecipeSpec like usual, then add/remove them with this code:

New method: codeless way

From v7.1.0, you can make Spec-file (Blueprint-file?) only mods to create, then add and remove recipes. For example, see AddInferiorTreating.json file:

{ "RecipeModderSpec": { "PrefabNames": [ "LumberMill.Folktails", "IndustrialLumberMill.IronTeeth" ], "RecipeIds": [ "InferiorTreatedPlank" ], "Remove": false // optional for adding, you don't actually need this line } }

Or an example RemovePlank.json file (just a demo, not actually in the release of the mod):

{ "RecipeModderSpec": { "PrefabNames": [ "LumberMill.Folktails", "IndustrialLumberMill.IronTeeth" ], "RecipeIds": [ "Plank" ], "Remove": true } }

Code-based way:

// Adding MultiBind<RecipeAdder>() .ToProvider(() => new RecipeAdder() .Add("LumberMill.Folktails", UnlockableRecipeModUtils.InferiorTreatedPlankRecipeId) .Add("IndustrialLumberMill.IronTeeth", UnlockableRecipeModUtils.InferiorTreatedPlankRecipeId) ) .AsSingleton(); // Removing (just for demo, not in the actual code): MultiBind<RecipeRemover>() .ToProvider(() => new RecipeRemover() .Remove("LumberMill.Folktails", "Plank") ) .AsSingleton();

Note:
- You MUST configure those in MainMenu context ([Context("MainMenu")]) because I need to gather all the modifications at the Main Menu and patch it. Game context would be too late.
- Try not to remove recipes down to 0 or to only locked recipe. It might cause the game to act weird.
- Tell the players using your mod about the above known issues.

Locking & Unlocking recipes

For simple scenarios where you will just lock and unlock a recipe, you can use DefaultRecipeLockerController (a singleton provided through the game's DI). See InferiorTreatingLocker.cs for the implementation:

public class InferiorTreatingLocker : IDefaultRecipeLocker { public ImmutableHashSet<string> MayLockRecipeIds { get; } = [UnlockableRecipeModUtils.InferiorTreatedPlankRecipeId]; public string GetLockReasonFor(string id, ILoc t) { return id switch { UnlockableRecipeModUtils.InferiorTreatedPlankRecipeId => t.T("LV.UR.InferiorTreatingLock", t.T("LV.UR.InferiorTreating")), _ => throw this.ThrowUnknownRecipeId(id), }; } } // Configuration Bind<InferiorTreatingUnlocker>().AsSingleton(); // For processing the unlocking MultiBind<IDefaultRecipeLocker>().To<InferiorTreatingLocker>().AsSingleton(); // For registering it as a locker that DefaultRecipeLockerController can manage

The InferiorTreatingUnlocker[github.com] shows how to unlock a recipe.

If you need more complex logic, you can implement ICustomRecipeLocker instead and register it with MultiBind<ICustomRecipeLocker>. All members are XML documented so you can see what they do.

===
v7.1.4: Should work with U7 April 10 update now.
v7.1.3: Updated the fix for recipe removal. Added railguard against recipes with both Ingredients and Products of the same Good. Moved Inferior Treating to the Gear Workshop instead.
v7.1.2: Minor fixes and support for other mods.
v7.1.1: Should work with U7 April 02 update now.
v7.1.0: Added a code-less way to add and remove recipes.

Source code is available at: https://github.com/datvm/TimberbornMods/tree/master/UnlockableRecipe
6 Comments
Luke ✞ Jesus Saves ✞  [author] 11 May @ 3:39am 
It's in your SteamLibrary\steamapps\workshop\content\1062090 but note that if you edit it, it may get overwritten if this mod is updated.
Belthazor 10 May @ 4:33pm 
Where does the AddInferiorTreating.json file end up?

My \Documents\Timberborn\Mods remains empty even though I got many mods installed.

Basically I just want to add/edit recipes in the easiest way.
jamesfcooper1 12 Apr @ 2:47pm 
but yes updating did work thx my bad
jamesfcooper1 12 Apr @ 2:47pm 
i forgot to unsub and resub but are u saying that there is a button to do that all for me cuz i cant find it
Luke ✞ Jesus Saves ✞  [author] 12 Apr @ 8:08am 
Hi that would be from this mod before today's update. Could you make sure this mod is at v7.1.4 (you should use Steam update button mod or Steam's Verifying Game files feature to ensure all mods are updated). That one occurs after April 10th update.
jamesfcooper1 12 Apr @ 2:32am 
hey luke im getting this error message i think it might be this mod but im not sure any help would be great
v0.7.4.0-2655e64-xsw
MissingMethodException: Method not found: bool Timberborn.WorldPersistence.ISingletonLoader.HasSingleton(Timberborn.WorldPersistence.SingletonKey)
UnlockableRecipe.DefaultRecipeLockerController.Load () (at D:/Personal/Mods/Timberborn/TimberbornMods/UnlockableRecipe/LockerManagers/DefaultRecipeLockerController.cs:65)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.Timberborn.SingletonSystem.SingletonLifecycleService.LoadSingletons_Patch2(Timberborn.SingletonSystem.SingletonLifecycleService)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.Timberborn.SingletonSystem.SingletonLifecycleService.LoadAll_Patch1(Timberborn.SingletonSystem.SingletonLifecycleService)
Timberborn.SingletonSystem.SingletonLifecycleUnityAdapter.Start () (at <a00d649e079a4a109c9d6aef3597daa8>:0)