Jump to content

[SOLVED] [1.18] Custom entity only spawns in client when reading additional save data, not on item use.


Recommended Posts

Posted (edited)

Hello everyone! 

There's this entity I've created that extends HangingEntity, along with its item that extends HangingEntityItem. Works pretty much like a painting would.

I'm getting this unusual behavior in which, when right-clicking to place it, the entity seems to get created on the server but not on the client. However, upon saving and reloading the world, the entity is actually right there, perfectly as intended.

At some point I came across getAddEntityPacket so I did override it with a call to NetworkHooks.getEntitySpawningPacket, but it appears to never be called and I'm not sure why. I'd even included IEntityAdditionalSpawnData to sync stuff such as the painting's facing direction to no avail.

Since the Entity's working fine when loading the world (and even when summoning directly with /summon), I'm inclined to think there's something up with the Item, but there's not that much going on there.

I've attached it below along with the entity.

  Reveal hidden contents

--------------

Moreover, I was able to verify that addFreshEntity was indeed called on the server, and the entity's constructor is being called on both sides. Just to make sure I also checked the entity's remove method and it was not being called. (which makes sense since the entity gets saved with the world)

I'll appreciate any and all help including pointers on where to poke next for clues. 

Thanks a bunch!

Edited by Virtu
Issue solved.
Posted

Thanks for the swift response! 

To make matters easier I made a repo to reproduce the issue minimally, linked here.

The original goal was to create some paintings that couldn't be obtained from the regular pool. In short the approach I attempted was:

  • Creating a registry for the custom painting motives (at core/ModPaintings.java)
  • Stitching the registered motive's textures in the painting atlas (at client/event/ClientModEvents.java)
  • Referencing the included sprites in a renderer based off PaintingRenderer (at client/renderer/SpecialPaintingRenderer.java)

There are still some quirks such as the entity initially displaying slightly offset and then popping into the correct position after a few seconds, the back texture not being loaded properly and stuff, but I'll hopefully get to those once this issue is down. 

Posted
  Quote

You are not calling setDirection when creating your entity

Expand  

Absolutely hit the nail on the head. Can't believe I overlooked that. lol

Everything is working flawlessly now. Also thanks for the extra tips, I've applied them both with success and the unnecessary code is now gone.

  • Virtu changed the title to [SOLVED] [1.18] Custom entity only spawns in client when reading additional save data, not on item use.

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.