Crafting with item that's equipped

barnicled

Terrarian
Hey, I'm working on this accessory upgrading system where various equipment can be upgraded into several higher tiers. I would like to implement the following features to streamline this process:

Players can craft with the accessory they have equipped
Players cannot craft with any accessories in their inventory
Once crafted, the new accessory equips itself


Now, as a relative beginner, I'm not even sure if any of these things are possible. Base Terraria doesn't allow equipped items to be crafted with, and if there's away around that, I'm not sure how to make the game avoid crafting with the ones in the player's inventory. I believe replacing the previous equipment with the new one should be relatively easy, but I'd need to find what functions can change the player's inventory like that. This accessory has its own dedicated slot, so it only has to go to one place.

If the other two features get added, I think feature two can be mostly gotten around by only showing the recipe if the required item is equipped, using recipe conditions or something. Maybe even, feature one could be gotten around by requiring nothing in the crafting recipe, and having feature three delete the previous equipment in the slot, assuming feature two works how I just described. However, I have yet to look deeply into the features I could use because I want to hear what more experienced people have to think.

Are any of these ideas possible? If not exact code, what functions should I start looking at that might prove most fruitful? Any pointers in the right direction would be greatly appreciated, before I embark on this adventure.
 
The first part may be possible by detouring the vanilla method that determines what items are available for crafting, you'd have to look through the vanilla source to find it and see exactly what it does.

For the self-equipping part, you can try to do this in OnCraft() in your ModItem.
 
Back
Top Bottom