KeepInventory for players in certain scenarios

Started by Folkpizza on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
KeepInventory for players in certain scenarios

Hello!

 

I'm currently working on a mod with custom bosses in there own separate dimensions. (certain items teleport you and it's just a void with the arena at 0 0) I'm planning for these bosses to be kinda hard so the player will have to die a lot, but I don't want them losing there items in the arena. So I was wondering if there was a way to make it that if a player dies in a certain area or by a certain mob, it would keep there inventory. If that isn't possible I was also experimenting with just teleporting all items on the ground when players respawn to them but I couldn't get it to work, if someone could help me with that if the first isn't possible that would also be super helpful!!

Thank you in advance!

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The easy way is to trigger a…
Mon, 09/30/2024 - 19:03

The easy way is to trigger a command to turn on Keep Inventory whenever a player enters the arena, but this wouldn't really work for multiplayer. 

The cleaner albeit harder way would be to run a lengthy procedure (or a series of smaller ones) to get a copy of every item from every slot in a player's inventory when they enter the arena. With a different procedure, you could set up a scoreboard so that the game tracks if the player is in the arena by setting their score to 1. If they die, a "player respawns" trigger checks for that scoreboard, and if it's greater than 0 then a procedure runs to copy back all of the player's lost items into their inventory slot for slot. 

I know that's a lot, and frankly, I'm not about to test it, but unless I'm tripping, that should work.