tModLoader Randomizing chests on world gen?

Bananamander

Terrarian
TL;DR I want to try to create a mod that takes all the chests placed during world gen (in cabins, ocean, dungeon, etc.) and also completely randomize their contents.

I'm guessing it wont be too hard to do the actual randomizing - First, I guess I'd make it retrieve the largest item ID the game has saved, so it has a chance of picking modded items as well as vanilla. Then, for each chest placed, pick a random number X between 1-40 for the number of items in the chest and then make a loop that runs X times and picks a random number between 0-(largest item ID) each time to choose what item to place in the chest. Lastly, I'd want it to retrieve the type of item it picked and make it so it places a larger stack of that item if it's, say, a block or any type of ammo that obviously wouldn't be too useful if there was just 1 of it.

So, with all that out of the way, can anyone point me in the direction of some info about how Terraria places items in its chests, and how I could override that with my own junky code? Also, how I could retrieve the largest item ID the game has to use for the randomization?

Any help at all is greatly appreciated!!!
 
Back
Top Bottom