Frag Posted October 25, 2015 Share Posted October 25, 2015 Hi guys, following CoolAlias good recommendation, I have set this line in my mobs constructor, so its animation will not be in synch with all other mobs of the same type and it worked. But I was wondering. By adding this line in the constructor ... ticksExisted=rand.nextInt(1000); It does mean that the tickExisted value will not be the same on the server and on the client side. Could it cause me some issues somewhere? I am wondering because my IMessage seems to be unstable the first few ticks after the creation of the mob ...some variable does not synch correctly between the server and the client (just for a very short time). I was wondering if it could be related. Quote Link to comment Share on other sites More sharing options...
jabelar Posted October 25, 2015 Share Posted October 25, 2015 ticksExisted is used is several places in the code. If you ever want to understand how vanilla is using something you should use Eclipse to show you the "call hierarchy" for it. You'll see that it is used for things like experience gathering, despawning when no longer within tracking range, and so forth. It may be that none of those are critical for you entity, but better not to muck with it. Instead, what you should do in your entity is have a separate public int field and in your constructor set THAT to a random value. Then whenever your animation needs an index to its animation you can just add the value of the field to ticksExisted. In other words, don't change ticksExisted itself but instead have another field representing the randomness. In fact you could go all the way and not use ticksExisted but rather use your own field and increment that every tick instead. Basically create your own ticksExisted field that starts with some random offset. Regarding packets during the first few ticks, yeah it can be a problem. I've found you cannot send packets to affect entities that were created in the same tick because often the packet will get to the other side and not be able to find the entity. Some people use the entity spawn data to transfer that initial stuff, but I tend to delay a tick or two before sending any sync messages. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
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.