Show / Hide Table of Contents

Registering custom items

Items in Valheim are anything that the player is able to hold in their inventory.
Creation of custom items is done through the ObjectManager singleton class.

All items will always be loaded before all recipes. However, items will be loaded in the order that you call the RegisterItem function.

Note: You must only use names of existing prefabs (either ones you created or default Valheim ones). This can be prefabs that have already been registered by another mod, or that already exist in the game.

Example

To create a new item, you must first add a handler for the ObjectRegister event

private void Awake()
{
    ObjectManager.Instance.ObjectRegister += initObjects;
}

then, create the handler. You can register custom items and recipes from this handler

private void initObjects(object sender, EventArgs e)
{
    ObjectManager.Instance.RegisterItem("TestPrefab");
}

That's it! Now, we can type spawn TestPrefab in game, and we can see our pick-up-able item!

Our Item in Game

  • Improve this Doc
In This Article
Back to top Generated by DocFX