Jump to content

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


Recommended Posts

Posted

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/

Posted

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/

Posted

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

Posted

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/

Posted

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 ;)

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.