Jump to content

[1.7.2] Changing Entity Motion


RSQ

Recommended Posts

Hello,

I have a tile entity that is changing the motion of certain entities around it, like snowballs. If I change the motionX/Y/Z of the snowball, the movement is pretty strange. First it goes like it should, then goes hyperspeed in the middle of flight(almost teleports) and then returns back to normal.

6891dd0d25.png

Is this a bug in vanilla minecraft/forge, or am I changing the motion incorrectly? This is basically all I'm doing:

entity.motionX = someForceVariable;

Any help is appreciated.

Link to comment
Share on other sites

After some experimenting, I also discovered that when I only push the entity on the client side(worldObj.isRemote), it goes the first half of the flight, and the opposite for the server.

ff70a6fb8c.png

I guess that means that without an isRemote or !isRemote check, the two are combined into one, so the snowball has to move quickly to get to the server bit after the client part is done, which explains the fast zone.

Link to comment
Share on other sites

Dude those diagrams are awesome, seriously!  I wish all posters were so clear about describing their problem :)

 

Sounds like you've run into a client-server synchronisation problem.  Anything you do to the entity on the client side will only last a short time until the server resynchronises it and your client changes are lost/overwritten.  There is a similar problem I wrestled with quite some time ago for EntityArrow http://www.minecraftforge.net/forum/index.php/topic,14315.msg73758.html#msg73758

 

Changes are often done to both the client and the server at the same time to reduce the apparent lag caused by packet transmission time, normally they stay in synch closely enough that when the resynch occurs the difference is small and you don't notice it.  It looks like there's something slightly different about Snowball so that when you push on both client and server, they have different effects so there is a big desynchronisation happening.  Unfortunately I don't know why that is.  The easiest fix might be to push the Entity on the server only and force a resynch (1.6.4 this was by sending Packet28 and/or Packet34, which will be slightly different in 1.7.2 but probably still very similar)

 

-TGG

 

Link to comment
Share on other sites

After exploring some random classes, I found this piece of code:

WorldServer ws = (WorldServer) e.worldObj;
ws.getEntityTracker().func_151248_b(e, new S12PacketEntityVelocity(e));

Also, a method .func_151247_a() exists but has similar features. Unsure about which to use. After putting that after my push code, and inserting an !isRemote, the issue seemed to be fixed for long distances, but still exists if the snowball is close to the player.

Link to comment
Share on other sites

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.