tModLoader Tombstone Item Recovery

Logicon

Terrarian
So I decided I was fed up with the insane amount of time it takes to manage your inventory every time you die on a medium-core character, especially when playing with multiple people. Someone dies and you vacuum up all their stuff, then you gotta figure out who has what and so on. This mod is something I've made that we've been using for a little while which causes a gold tombstone to spawn right where you die. You can respawn, find the tombstone and right click it and you'll immediately have your old equipment exactly where it used to be in the action bar/inventory, your armor, accessories, social, dyes, equipment will also be re-equipped exactly how you had it before you died. No more spending 10 minutes putting everything back to the way it was :D.

I'm calling this mod released, but as of right now there are some possible edge cases which may not be covered as I have not run into them myself. This mod is working exactly how I want it to and I don't really feel like continuing to work on it. But I will link the github source so all are welcome to make improvements if they like (Would be nice for a credit though).

Here's how it works:
  • On death it will place a golden tombstone right at the position you died if there's space. If there's no space it will destroy tiles around it enough to make space
  • If you die in mid air it will create 2 blocks to put the tombstone on
  • Only the player who died can click on their tombstone to get their stuff back.
  • IMPORTANT: The tombstone inventories are stored clientside at the moment and DO NOT persist if you close and reopen the game. They DO NOT persist if you leave and rejoin the server. The inventories at that point would be lost forever.
  • Another thing to note here is that you should not have this mod enabled if you're playing a soft-core character as this mod overwrites the death logic and will cause you to lose your items as if you were a medium-core character.

I've been playing on a server with this mod and 5 other people for about a week now and no one has permanently lost their inventories through these wierd edge cases but it's possible, so look out for these issues:
  • If you die on top of a chest with items in it. The chest will be destroyed. While it looks like the contents are also destroyed, if you put a chest back down exactly where the old one was then it actually returns the inventory to that chest
  • The tombstone that contains the player inventory can be destroyed, if it is before the player gets back to it, you can still get your inventory back if you place the tombstone in the exact position it was in before it was taken down
  • If 2 players die on the exact same spot, there is an issue where one of the players may lose their inventories. This is something that could be improved upon
  • And finally, I haven't at all tested what happens if you die on the far right/left/ceiling of the map, but I can only assume it won't be able to place the tombstone and thus you lose your inventory.


I realize that there might be more "what if's" than people might be comfortable with trying, these edge cases have yet to actually happen in the server I've been playing on for a while now but I know they do exist. I don't have any motivation to actually fix these since it's working enough for me at the moment. I would recommend backing up characters regularly if you're afraid to permanently lose your stuff, and if you're interested and willing please take a look at the source and make any improvements you see fit. This mod has drastically lowered the burden of time it takes to reorganize your inventory after dying during a boss fight, especially with multiple players.

Download link: Version 2
Github Source

UPDATE: exuvo has forked my original project and improved upon it immensely, he has fixed a lot of the edge cases with the mod and has it fallback to default behaviour if he can't spawn the tombstone properly. I recommend taking his version hosted here: exuvo/TModTombstone

If you have any questions about it I'm Logicon on the tModLoader Discord
 
Last edited:
This is a pretty nifty mod and useful mod. Personally I think a "death treasure bag" would be better instead of creating a new tile, this would probably fix most of your issues. Although this might be harder to do and it strays from the original title of this mod.
 
Just a heads up, I've updated this mod to work with the latest tModLoader version. Didn't realise it wasn't working until someone messaged me about it
 
Is there a way to change the blocks created on death? I ran into a situation where I stepped on a TNT detonator and got blown up. It also destroyed all the surrounding blocks which made it next to impossible to guess where the death occurred to replace the tombstone. Pretty sure stuff like lizard blocks can't be blown up.
 
Oh for sure, it's just changing an id from whatever dirt is to something else. Though changing it to an unbreakable block may cause problems if you were to die anywhere near your base for example. It would kind of get in your way.
 
The members of my group and I are finding a lot of edge cases, for this otherwise really good mod.

The dirt blocks that are normally placed under the tombstone will not replace a block that has been 'hammered'. It will not spawn a tombstone, which then requires one of us to place both a dirt block and a tombstone in the correct spot in order to recover the inventory.

This was an extremely noticeable problem when fighting Golem. We had a player die on the stairs in the temple. So, the dirt block was unable to replace the angled Lizhard block, nor were we able to mine the Lizhard block because the pickaxe required drops from the boss. To solve this problem we needed to inventory edit the pickaxe into someone's inventory to mine the angled Lizhard block, place a dirt block, and then place a golden tombstone.

The dirt blocks are also a minor inconvenience when you die on platforms in a boss arena (since they replace the platforms), and dying in your base (since they replace whatever blocks you were standing on).

I see that stated in the OP that:
  • "On death it will place a golden tombstone right at the position you died if there's space. If there's no space it will destroy tiles around it enough to make space"
If this is the case, it isn't working as intended as it ALWAYS breaks the tiles and replaces them with dirt in an attempt to spawn the golden tombstone.

This mod is great at what it does, most of the time, but it has also been a hindrance at times as well.
 
So i started playing again and this mod is great most of the time. But we lost inventories twice now and that is quite annoying even with cheat menus to respawn items.

I took a look at the code and it seems really easy to add a fallback to default item drop behaviour when it is not possible to spawn the tombstone. I think that is an acceptable band aid for the rare cases it does not work normally.

Persisting the tombstone looks more difficult but a possible workaround might be that on disconnect the tombstone drops the items on the ground as if the player had died there.

I'll make another post if i get anywhere.
 
Well i spent around 10 hours on this and got it working really well now!

Attempts to spawn the tombstone in the vicinity of where the player died. May destroy small plants to ease placement but never terrain, trees or buildings. Message with coordinates is printed in chat to help finding tombstone during high speed death. If no ground position is found it tries to place 2 dirt blocks in the air and the tombstone on top of that.
If unable to place a tombstone the player dies as normal and items are dropped on the ground.
If you die twice in the same spot it only overwrites the old tombstone if the new death inventory had more valuable items (sum of armor, accessories and inventory value). Otherwise current stuff is dropped on the ground.

Save support: the most valuable tombstone is saved with the character and restored when loading.
A message is printed on world join, if a saved tomb stone was loaded, with its position so you can find it if it was a while ago or the tombstone is missing (just place a new one close by where it says).

I also fixed the problems with dying close to map edges.

Download from my github fork exuvo/TModTombstone
I'll look into publishing it tomorrow.
 
Last edited:
Finally got it uploaded to the mod browser, had to rename everything what a pain. Search for "Improved Tombstone Death Mod". Says it is uploaded but i can't see it so i assume it is waiting on approval or something.
 
That's awesome exuvo! I've been away from Terraria for a while but was going to come back and take a look at the updating the mod after 1.4 came out. It's great to see that you were able to fix up all the edge cases and even have it save the inventory between sessions.

I'm gonna check it out and see how it works, saving the inventory between sessions was a big one that I wasn't sure how to do. Sorry if my code was a pain to navigate, I kind of only did the bare minimum so that I could just get to playing the game :p
 
Last edited:
Hello! This is a great mod idea, thanks to both Logicon and Exuvo!
Quick question: Does it seem doable to edit Logicon's code so that it only drops inventory but not the items in equiped slots ( weapons and armors)?
Got a bit of coding experience but havent modded terraria before.

(I feel mediumcore would be perfect for me if I lost my pots, ore and stuff but not the equipment that s super rare / time consuming to create that I am wearing. )
 
During my most recent Terraria playthrough on Mediumcore I also hated how much inventory management I needed to do so I started creating a mod just like this one. I found this mod just after starting to create my own so I started updating this mod to fit how I think it should work but I have pretty much completely rewritten it and it works completely different. I very much appreciate the work done here and credit Logicon and Exuvo in my mod. The mods are different enough that people can choose which implementation they prefer.

My mod is called Mediumcore Ghost Inventories and below is the description.

Whenever a player dies a ghost will spawn where they died that can then be chatted with and will give the player the option to retrieve their inventory just as it was when they died.
The inventory will be restored with all items, equips, dyes, ammo and money in the exact positions they were and also whether they were favourited or not.
These inventories and positions will be saved with the world and when loading the world the ghosts will respawn in the saved positions.
Ghosts will only spawn when a mediumcore character dies and any type of character can be on a server together.
All items currently on the player (except the starter inventory) will drop when replaced by the ghosts stored inventory.
The only item that drops on the ground when you die is anything held outside the inventory on the mouse.
Only the player whos name matches the player whos inventory the ghost stores can retrieve it but anyone can remove the ghost and have it drop the items.
If two players die very close together the second ghost should search for a better position a little further away to the left or right, this stops them stacking on top of one another.
If you die off the edge of the map the ghost will spawn at the closest position it can within the bounds of the map.
The only inventories that will not spawn a ghost are an empty inventory or the exact default Terraria starting inventory of the three copper tools.

I plan to update this mod for 1.4 as soon as I can.

Here is the source code: Cooleyy/MediumcoreGhostInventories
Link to its own post tModLoader - Mediumcore Ghost Inventories
 
Last edited:
Finally back now that I see tmodloader 1.4 is out. Very excited to get into it again :).

I've updated Exuvo's branch to be 1.4 compatable and published the mod here: Steam Workshop::Tombstone Death Mod

I will be definitely following Cooley's variation of this mod for when they might update theirs to 1.4 as well because I really like the ghost idea. But until then I'm gonna be using the mod above. Enjoy :)
 
Back
Top Bottom