Jump to content

Soulbound items help (solved)


Recommended Posts

I'm working on a mod and have been stuck the past few days searching for a simple way to make one of my items soulbound such that if a player dies it stays in their inventory instead of being dropped.

Does anyone have a good tutorial they could point me to, or a good set of ideas I can use to get this done?

Link to comment
Share on other sites

Okay, I tried using LivingDeathEvent to check if the player had the item upon death and remove it from their inventory and using then PlayerRespawnEvent to give the item back to the player. This does seem to work, but I accidentally noticed if the player dies and doesn't respawn but exits instead, then when they return to the world and respawn, they don't get the item given to them.

Link to comment
Share on other sites

coolboy4531,

I feel like I'm supposed to use the loggedIn/Out events to save the data about the soulbound item to the server while the player is away, but I'm at a loss when trying to figure out how to do it. Or did you mean for me to use those methods to do something else?

 

diesieben07,

I can't seem to do anything successful with that event. The annotation I found on it says I can cancel it to stop all drops from entering the world, but I only want to prevent the soulbound items from dropping.

Upon further review, using "System.out.println()" I can see, this event isn't even being called when a player dies.

Link to comment
Share on other sites

/facepalm/

I forgot to preface my method with "@SubscribeEvent". No wonder I couldn't get it to do anything.

 

Okay, yes, removing the item from the list prevents it from dropping, but it doesn't keep it in the player's inventory. The item is just deleted.

I tried adding the item back into the inventory after removing it from the drops list, and now I can see it in the inventory hotbar when the player is dead and the respawn menu is up while all the other items have been dropped to the ground, but once I respawn, the item is gone again. And it still didn't drop.

Link to comment
Share on other sites

I see. Back to square one.

In that sense, it's really no different than using the LivingDeathEvent to check if the item is present and removing it form their inventory at that point. Using either LivingDeathEvent or PlayerDropsEvent, I still have to use PlayerRespawnEvent to give the item back.

So now we return to the issue where coolboy4531 suggested I use the player LoggedIn/Out events to (I assume) save the soulbound item data in case the player logs off instead of respawning.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.