Jump to content

[1.16.4] Arrow entity rendering problems

Lemon Lord

Recommended Posts

My mod implements a custom arrow entity that does not appear client-side. It does exist server-side, I can confirm it hits entities and causes damage and can also confirm the entities' existence using commands. This issue seems to be identical to an older 1.15.2 issue presented here:


The solution given in this topic is to give the entity the following method override:

public IPacket<?> createSpawnPacket() {
  return NetworkHooks.getEntitySpawningPacket(this);


This works fine for rendering the entity, the texture appears, hitbox appears, everything except the entity's NBT is working. The main problem I can identify is that the arrow entity's Owner UUID (ProjectileEntity's field_234609_b_) is not transfered over (idk if that's correct terminology) by the createSpawnPacket override. This leads to the arrow not moving in the right direction, as the client-side thinks that this unowned arrow should've collided with the player, whereas the server-side knows that the arrow belongs to the player and therefore should not have collided with the player on the first tick of its existence.


I am unaware of how to proceed as my knowledge of how packets work is pretty limited. Entities - Forge Documentation is the closest documentation I can find but I don't see any relevance. What's most annoying is that other mods I have checked just work. No packets or anything, the renderer just renders it. I used IntelliJ to look at the classes for CoFH's Archer's Paradox and the implementation of their arrow item, arrow entity and arrow renderer is very simplistic and is identical to mine but without any packet nonsense (and some stuff I added after I got the rendering-with-packets 'working'). It's a 1.16.3 mod but load that mod up in 1.16.4 and everything just renders, it's ridiculous. I'm thinking this indicates something is wrong with my gradle setup?


Any help would be very much appreciated :)

  • Thanks 1
Link to comment
Share on other sites



You might find these working examples useful



Key points to note:

You need to have:

  • RenderingRegistry.registerEntityRenderingHandler
  • public IPacket<?> createSpawnPacket() {return NetworkHooks.getEntitySpawningPacket(this);}
  • public static void onEntityTypeRegistration(RegistryEvent.Register<EntityType<?>> entityTypeRegisterEvent) {...}
    If you forget any of these or get them incorrect, your code won't work and might fail silently.



Common errors

  • My entity doesn't appear on the client; no errors in the console
    You may have incorrectly implemented createSpawnPacket for your Entity

  • My entity doesn't appear on the client; there is a renderinghandler not found error in the console
    Your renderer is not registered properly.

Useful tips for debugging entity rendering:

  1. Does the entity exist on the client? Put a breakpoint into YourEntity::tick()
  2. Press F3+B to show entity outline (hitbox) and facing direction
  3. WorldRenderer::updateCameraAndRender() breakpoint at the iprofiler.endStartSection("entities");
    --> entity is present, is associated with the correct renderer, is within the viewing frustrum, is at the [x,y,z] that you expect


Link to comment
Share on other sites

Right, so, I've fixed it but as it turns out I was right about something and wrong about something else. In debugging I must've slipped up because whilst the problem I thought still exists, I forgot commands that use NBT are run server-side and came to the wrong conclusions from the debugging I performed. Also CoFH's 'Archer's Paradox' doesn't actually work, I was wrong about that too, so CoFH released a mod that's base mechanics are bugged haha sucked in :P


The owner-not-registering-client-side problem was as such: if you're moving in front of an arrow after firing it (not too difficult in creative, kinda tricky in survival) client-side thinks it bounces off you for about a second before realising it never actually touched you and going to wherever you shot it, syncing up with server-side. This is not just me guessing that there's a desync, I've tested it and the motion Vector3d for the entity is different on remote worlds. Also the ProjectileEntity field_234610_c_ field is null client-side.


Fix is as follow:

  1. Implement IEntityAdditionalSpawnData in your entity class.
  2. Assuming you're extending AbstractArrowEntity or ProjectileEntity
    public void writeSpawnData(PacketBuffer buffer) {
    public void readSpawnData(PacketBuffer additionalData) {
        int id = additionalData.readInt();
        Entity entity = EntityHelper.getEntityById(id);
        if (entity != null) {
    field_234610_c_ is the ID of the shooter entity and is private by default. You could change this with an access transformer (like I did) or get it using reflection, if you have the patience for that. EntityHelper.getEntityById does exactly what you think it would, implement however you like.
  3. Profit.

Still no idea why this fix is required or how vanilla arrows just don't need any of this. I understand IEntityAdditionalSpawnData is a MinecraftForge interface but there's just nothing, no replacement, no extra methods on the vanilla side and that somehow still works.


P.S. thanks The Grey Ghost :) I'll admit I actually found a lot of code from MBE to be really helpful when I was starting out modding (like 2-4 weeks ago) and am very grateful something like that exists and I also appreciate the assist here but it actually wasn't relevant. I'd already done everything in there that applied to my entity and the problem at hand wasn't anything to do with what you had in example 81.

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.

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.

  • Create New...

Important Information

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