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.

[SOLVED] [1.12.2] Modifying player capabilities for offline players?

Featured Replies

Posted

Hey!

 

Is there any way to modify capability values for offline players (where EntityPlayerMP instance is null essentially) without using JSON? Is there like a way to make capabilities for GameProfile?

 

Any help is appreciated!

 

Thanks! :D

Edited by Differentiation

  • Author
3 hours ago, diesieben07 said:

How is JSON applicable at all here? Capabilities use NBT...

You can probably do something similar to what SaveHandler#readPlayerData does. You can't use it directly, because it requires an EntityPlayerMP. Then you can modify the data and save it back. Note however that you need to take to only do this if the player isn't logged in or your changes will go away.

I mean, it isn't necessarily capabilities that I'm trying to store, it's just raw data (some boolean, integer variables, etc.) and that's what I meant by using JSON.

 

So the way I currently do it is make a temporary entry in my JSON file for offline player. Then when they log on, I move the values to NBT (the player capability class) and remove the JSON entry.

Edited by Differentiation

  • Author
1 minute ago, diesieben07 said:

In that case you could just store a Map<UUID, YourDataClass> somewhere and load/unloaded from that as needed. And then you can use whatever data format you want.

Yes, but what if the Dedicated Server is, say, closed before the player gets to log on?

  • Author
7 minutes ago, diesieben07 said:

The one the world is also saved to?

 

Like I said, which file format you use is completely up to you here.

Ah I see. I think now the JSON much is way simpler xD

 

Thanks for the help! :)

Edited by Differentiation

  • Author
8 minutes ago, diesieben07 said:

The one the world is also saved to?

 

Like I said, which file format you use is completely up to you here.

The thing is I was trying to figure out if there's any way to accomplish this without having to save data to a file.

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.