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.

[1.7.2]Is IExtendedEntityProperties just for saving, or also client-server sync?

Featured Replies

Posted

I understand what IExtendedEntityProperties does in terms of NBTCompound for saving and loading.  But do I still need to send packets between client-server if I'm keeping these extended properties up to date?  Or is the client-server synchronization also handled automatically?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

If you need the data on the client, you must handle it yourself.

 

I kinda figured that.  I need info on client to control render animations.  I was hoping that with a built in extended properties interface they might have taken the trouble to sync it too ... but guess IExtendedEntityProperties is mostly just meant to provide consistency to NBT methods.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

CoolAlias, I was looking at your tutorial for the IExtendedEntityProperties.  You had the following saveNBT() method:

// Save any custom data that needs saving here
@Override
public void saveNBTData(NBTTagCompound compound)
{
// We need to create a new tag compound that will save everything for our Extended Properties
NBTTagCompound properties = new NBTTagCompound();
// We only have 2 variables currently; save them both to the new tag
properties.setInteger("CurrentMana", this.currentMana);
properties.setInteger("MaxMana", this.maxMana);
/*Now add our custom tag to the player's tag with a unique name (our property's name). This will allow you to save multiple types of properties and distinguish between them. If you only have one type, it isn't as important, but it will still avoid conflicts between your tag names and vanilla tag names. For instance, if you add some "Items" tag, that will conflict with vanilla. Not good. So just use a unique tag name.*/
compound.setTag(EXT_PROP_NAME, properties);
}

 

Why did you create a new compound rather than just adding your CurrentMana and MaxMana tags to the compound passed into the method?  I understand that compounds can be hierarchical, but isn't the compound passed in already a compound specific to the extended entities?

 

Anyway, except for hierarchy organization, is there any problem with adding the custom tags directly to the passed compound without creating a new sub-compound?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

CoolAlias, I was looking at your tutorial for the IExtendedEntityProperties.  You had the following saveNBT() method:

// Save any custom data that needs saving here
@Override
public void saveNBTData(NBTTagCompound compound)
{
// We need to create a new tag compound that will save everything for our Extended Properties
NBTTagCompound properties = new NBTTagCompound();
// We only have 2 variables currently; save them both to the new tag
properties.setInteger("CurrentMana", this.currentMana);
properties.setInteger("MaxMana", this.maxMana);
/*Now add our custom tag to the player's tag with a unique name (our property's name). This will allow you to save multiple types of properties and distinguish between them. If you only have one type, it isn't as important, but it will still avoid conflicts between your tag names and vanilla tag names. For instance, if you add some "Items" tag, that will conflict with vanilla. Not good. So just use a unique tag name.*/
compound.setTag(EXT_PROP_NAME, properties);
}

 

Why did you create a new compound rather than just adding your CurrentMana and MaxMana tags to the compound passed into the method?  I understand that compounds can be hierarchical, but isn't the compound passed in already a compound specific to the extended entities?

 

Anyway, except for hierarchy organization, is there any problem with adding the custom tags directly to the passed compound without creating a new sub-compound?

I did that to prevent possible conflicts; imagine if everyone is adding custom properties, chances are probably pretty good that there will be some overlap in the NBT tags people want to use, especially if people are not careful to use fairly unique names. By storing all of my data in a new tag, I only have to add a single new key to the original player NBT data, and I can do so with a pretty much guaranteed to be unique key. Otherwise, no, there is no particular reason to do that :P

  • Author

Okay, for compatibility between mods that makes sense.

 

In my case, I'm adding these to my own entity so I don't think there is a chance of conflict with other mods, but probably good practice to do it your way so if I copy the method onto a vanilla entity I won't forget.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Okay, for compatibility between mods that makes sense.

 

In my case, I'm adding these to my own entity so I don't think there is a chance of conflict with other mods, but probably good practice to do it your way so if I copy the method onto a vanilla entity I won't forget.

Keep in mind that many mods may add extended properties even to your custom entities; my Zelda mod, for example, adds some extended properties to all entities that extend EntityLivingBase, which obviously also includes any modded entities that extend that class. Same goes for any other mods that do something similar, or to the innumerable mods (including my own) that add extended properties to EntityPlayer. I wouldn't ever assume that my properties are the only ones being added, unless you are sure that people will not be playing with any other mods installed ;)

  • Author

Okay, for compatibility between mods that makes sense.

 

In my case, I'm adding these to my own entity so I don't think there is a chance of conflict with other mods, but probably good practice to do it your way so if I copy the method onto a vanilla entity I won't forget.

Keep in mind that many mods may add extended properties even to your custom entities; my Zelda mod, for example, adds some extended properties to all entities that extend EntityLivingBase, which obviously also includes any modded entities that extend that class. Same goes for any other mods that do something similar, or to the innumerable mods (including my own) that add extended properties to EntityPlayer. I wouldn't ever assume that my properties are the only ones being added, unless you are sure that people will not be playing with any other mods installed ;)

 

Okay, that's also a good point.

 

Right now my mods are mostly for my kids' personal entertainment, and my field names are usually quite unique/descriptive, so chances are low of conflict.  But in anticipation of becoming hugely popular, I'll code my mods to play nicely with other mods!

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.