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.

Why is the capability not present on playerclone event if it is present before the player dies?

Featured Replies

Posted

Hello, I'm having trouble keeping player nbt data after death, this is my code currently:
 

@SubscribeEvent
    public static void onPlayerCloned(PlayerEvent.Clone event) {
        if(event.isWasDeath()) {
            System.out.println("Player died");
            System.out.println("Cloning wallet 0/2");
            System.out.println(event.getOriginal().getDisplayName().getString());
            System.out.println(event.getOriginal().getCapability(WalletProvider.WALLET_CAPABILITY).isPresent());
            event.getOriginal().getCapability(WalletProvider.WALLET_CAPABILITY).ifPresent(oldStore -> {
                System.out.println("Cloning wallet 1/2");
                event.getPlayer().getCapability(WalletProvider.WALLET_CAPABILITY).ifPresent(newStore -> {
                    System.out.println("Cloning wallet 2/2");
                    newStore.copyFrom(oldStore);
                });
            });
        }
    }

I have a /balance command, and when I give myself some money it displays the correct balance, but for some reason the capability is not present in the playerclone event, the

System.out.println(event.getOriginal().getCapability(WalletProvider.WALLET_CAPABILITY).isPresent());

prints "false".

I know that the capability is being attached properly and everything, this is my console:

Attached wallet to player
Player died
Cloning wallet 0/2
Dev
false
Attached wallet to player

Please anyone help

Edited by Anonomys
clarification

This is my signature. I don't really too much know about java but i try to help and i try to get help from others too. Thank you!

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

Thank you so much!

This is my signature. I don't really too much know about java but i try to help and i try to get help from others too. Thank you!

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.