Jump to content

Projectile rendering incorrectly when given a high velocity


MysticalMike

Recommended Posts

When I spawn a projectile with a high velocity it seems to render in the incorrect location but it ends up hitting the correct block. Better explained by watching this clip: https://youtu.be/ENmASw9UQVQ

 

Here is the basic code I used to spawn the projectile:

spacer.png

 

The only thing that I could think of as the cause would be some kind of de-sync with the client because the projectile doesn't hit mobs or blocks that would be in the way if it was actually where it's rendering.

Any clues on how to fix this would be very helpful.

Link to comment
Share on other sites

On 2/19/2021 at 1:19 AM, diesieben07 said:

ArrowEntity uses SSpawnObjectPacket, which can only handle motion between -3.9 and +3.9.

Okay I see what you mean in SSpawnObjectPacket but I'm not sure how I could change that or if there's a different packet I could send. I tried creating a new packet extending SSpawnObjectPacket but minecraft doesn't render custom non-living entities with that packet. Before I was using 'NetworkHooks.getEntitySpawningPacket(this);' which ultimately creates a SCustomPayloadPlayPacket packet which does render custom non-living entities but I don't know how I could edit that packet either. (Both clamp the motion)

 

Edited by MysticalMike
Link to comment
Share on other sites

On 2/20/2021 at 12:03 PM, diesieben07 said:

Do not make your own "vanilla style" packet (i.e. subclass of IPacket). It won't work.

 

You can implement IEntityAdditionalSpawnData on your entity and encode the motion again, without clamping. This requires the use of NetworkHooks.getEntitySpawningPacket (like all modded entities).

Okay so I got it to write and read my data but how can I use that to actually change the speed for the client?

image.png.c8095e092bf03e14c283ddfea4f2838f.png

Link to comment
Share on other sites

3 hours ago, diesieben07 said:

I can't see why that would happen.

Can you post a Git repo of your mod?

Okay I posted it to my github: https://github.com/MysticalMike/GunMod

I use EMPGun to spawn the projectile: io/github/mysticalmike/gunmod/common/items/EMPGun

And BulletEntity is the projectile spawned: io/github/mysticalmike/gunmod/common/entities/BulletEntity

Edited by MysticalMike
Link to comment
Share on other sites

On 2/20/2021 at 12:03 PM, diesieben07 said:

Do not make your own "vanilla style" packet (i.e. subclass of IPacket). It won't work.

 

You can implement IEntityAdditionalSpawnData on your entity and encode the motion again, without clamping. This requires the use of NetworkHooks.getEntitySpawningPacket (like all modded entities).

How exactly does one write a packet and get forge to send it?

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.