Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

  • Author

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.

Look at PlayerEvent for more events about player actions.

 

PlayerEvent.PlayerLoggedInEvent    
PlayerEvent.PlayerLoggedOutEvent    

You can use these 2 events for your issues.

  • Author

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.

  • Author

/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.

  • Author

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.