Jump to content

[Solved] [1.19.4] Changing block entity data from block entity renderer


Recommended Posts

Posted (edited)

Hi, I am trying to modify a block entity's variable from its block entity renderer class. The variable facing is direction of the entity in degrees. The renderer class access the variable facing and rotates it to face towards the entity it is tracking. However, the changes are not reflected in the block entity class. Printing out entity.facing to console in the block entity renderer class displays the correct output in degrees but printing out facing in the block entity class shows it is stuck at -1.

I figure it might be something to do with renderers being client side, if so, could someone point me in the right direction? Thanks

 

Block Entity 

  Reveal hidden contents

Block entity renderer

  Reveal hidden contents

 

Edited by PRYtheSheep

I bang my head against the keyboard every time I code

Posted

I figured that the Block Entity Renderer is client side only and changing the entity variables won't work. I added in packet handling to send a packet from client to server. 

ModMessages class

  Reveal hidden contents

Packets class

  Reveal hidden contents

The following line is called after changes is made to entity.facing in the renderer class to update the server side

ModMessages.sendToServer(new PRYBlockRendererC2SPacket(entity.facing, entity.getBlockPos()));

 

I bang my head against the keyboard every time I code

  • PRYtheSheep changed the title to [Solved] [1.19.4] Changing block entity data from block entity renderer

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.