Jump to content

Recommended Posts

Posted

Edit: Initial issue not actually an issue as there were more than 1 entity in the world which I overlooked. New issue is this:

 

If I am to send a packet during the readEntityFromNBT method, the client won't update, however if I am to send packets during the update method it will update. Could you explain the reason behind this?

 

------------------------------------------------------------------------------------------------------------------------------------------

 

Whenever I reload a world, the readEntityFromNBT method is called a total of 4 times for one entity.

 

- The first time it is called, when I use compound.getInt("skin") it returns a default value of 0, which is not the one I want.

- Then the second time it is called it returns 5, the actual value I want my skin field to be and the one it was set to before reloading.

- Then the next to two times it is called it again returns 0, which is again not what I am looking for.

 

So when logging this information in the console I end up with this:

 

[iNFO] 0
[iNFO] 5
[iNFO] 0
[iNFO] 0

 

I cannot for the life of my figure out why this is happening and don't know what code to provide that could be of help apart from the NBT methods:

 

@Override
public void writeEntityToNBT(NBTTagCompound compound) 
{
super.writeEntityToNBT(compound);

compound.setInteger("level", level);
compound.setInteger("xp", xp);
compound.setDouble("health", health);
compound.setDouble("damage", damage);
compound.setDouble("speed", speed);
compound.setInteger("type", type);
compound.setInteger("skin", skin);
}

@Override
public void readEntityFromNBT(NBTTagCompound compound) 
{
super.readEntityFromNBT(compound);

setLevel(compound.getInteger("level"));
setXP(compound.getInteger("xp"));
setMaximumHealth(compound.getDouble("health"));
setDamage(compound.getDouble("damage"));
setSpeed(compound.getDouble("speed"));
setType(compound.getInteger("type"));
setSkin(compound.getInteger("skin"));

Log.info(compound.getInteger("skin"));
}

 

Any ideas would be much appreciated, thanks.

Posted

As it turns out, no there were more than one in the world, so I managed to overlook that. New issue though regarding packets.

 

If I am to send a packet during the readEntityFromNBT method, the client won't update, however if I am to send packets during the update method it will update. Could you explain the reason behind this?

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.

Announcements



×
×
  • Create New...

Important Information

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