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

So, I have a capability storing some data, so I want to keep the data when the player dies (if resetOnDeath is false) or when he comes back from the end dimension.

Here's my code:

    @SubscribeEvent
    public void onPlayerClone(PlayerEvent.@NotNull Clone event) {
        if (!event.isWasDeath() || !ServerConfig.resetOnDeath.get()) {
            Player original = event.getOriginal();
            original.reviveCaps();
            original.getCapability(PlayerCapabilityProvider.PLAYER_CAP).ifPresent(oldCap -> {
                event.getEntity().getCapability(PlayerCapabilityProvider.PLAYER_CAP).ifPresent(newCap -> {
                    newCap.setNBTData(oldCap.getNBTData());
                });
            });
            original.invalidateCaps();
        }
    }

Event is registered though the Forge EventBus, registration is located at FMLCommonSetupEvent.

When testing in a singleplayer world, everything seems to be perfectly working. When I join a server however and die, the respawn button does nothing. Any ideas?

PS: I'm using latest Forge version 43.1.43 for 1.19.2.

Edited by Darkorg69
PS

7 hours ago, Darkorg69 said:
PlayerEvent.@NotNull Clone

This is badly formatted.

7 hours ago, Darkorg69 said:

When I join a server however and die, the respawn button does nothing.

Do you mean the respawn button doesn't work? Or that the data isn't copied?

Can you check your debug.log to see if there is any error occurring when you press the button? Nothing in the method provided immediately jumps out to me with an error.

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.