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

You can't do this client-side only

if(button.id == this.btnNewtype.id) this.nt.setHumantype(EHumantypes.NEWTYPE);
if(button.id == this.btnOldtype.id) this.nt.setHumantype(EHumantypes.OLDTYPE);

This only sets your data on the client(and that data won't be persistent as one might guess). You need to send a packet to the server and set the data there.

 

https://github.com/SpaceboyRoss01/MSGundamMod/blob/master/src/main/java/com/spaceboyross/gundam/capabilities/providers/NewtypeProvider.java

The generic type for ICapabilitySerializable is either NBTBase or any of it's children. If you are using NBTTagCompound to begin with you should just use it as your generic type rather than casting all over the place.

And why are you introducing a HANDLER generic type You do not need it as far as I am concerned.

This makes absolutely zero sense. A capability of NBTBase? The generic constraint there is your capability interface, not the type it is serialized into. I have no idea how it is even working and not crashing you completely.

 

This line is useless. It just creates a final field that is assigned to null. If you want your capability to be injected there you need to add the annotation.

 

root.setInteger("humantype",instance.getHumantype() == EHumantypes.OLDTYPE ? 0 : (instance.getHumantype() == EHumantypes.CYBER_NEWTYPE ? 1 : 2));

=>

root.setInteger("humantype",instance.getHumantype().ordinal()));

 

instance.setHumantype((new EHumantypes[] {
					EHumantypes.OLDTYPE,
					EHumantypes.CYBER_NEWTYPE,
					EHumantypes.NEWTYPE
				})[root.getInteger("humantype")]);

=>

instance.setHumantype(EHumantype.values()[root.getInteger("humantype")]);

 

You also must copy the data from the old capability to the new capability upon PlayerEvent.Clone, otherwise your capability data will reset to defaults every time the player is cloned(respawns for example)

 

ResourceLocations should be all lower-case. In 1.13 the "should" turns into "must" as an exception will be thrown on non-lower-case ResourceLocations.

 

TL;DR: I think that your problem is not serialization but 

a) The fact that you only ever set the values on the client

b) That your capability provider is broken.

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.