How to convert ItemDefinition to Item type?

WesleyCody

Steampunker
I have a config in my mod, one of the configurable values I am trying to add is an ItemDefinition. The player would be able to select an item which later will be given via QuickSpawnItem. However, after looking through Tmodloader documentation and code online I can't figure out how to either convert a ItemDefintion type to the Item type so I can spawn it in, or to create an Item value based off of an ItemDefinition value. Any help or any other ideas on how I could have an item chosen in config which later is spawned by using an item is appreciated. I have already made a configurable item choice via selecting a item ID and it works fine however I would much rather have it so the player can scroll through the visualized list of items and click on one which is provided by the itemdefinion value, than have players have to look up or find ItemIDs and type in numbers or strings to a input field.
 
C#:
ItemDefinition itemDefinition = new ItemDefinition(ItemID.DirtBlock); // 2
int type = itemDefinition.Type; // ItemID.DirtBlock / 2

// All of these do the same thing.
player.QuickSpawnItem(type);
player.QuickSpawnItem(itemDefinition.Type);
player.QuickSpawnItem(ItemID.DirtBlock);
player.QuickSpawnItem(2);
 
Back
Top Bottom