Posted July 5, 20169 yr 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.
July 5, 20169 yr Author 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?
July 5, 20169 yr Author Awesome, thanks for the explanation. I now have everything setup and working correctly using the example: http://here https://github.com/MinecraftForge/FML/issues/64
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.