Blockentity client rendering out of sync in 1.17 fabric #1800
-
Hi all, I am new to modding. Recently I am trying to make a blockentity following the example on fabric-wiki (https://fabricmc.net/wiki/tutorial:blockentityrenderers). I want to make a change that when I hold an item and right-click this blockentity, this item can show on top of it (like the item frame). However, the item won't show until I reload the chunk, which is due to the data is not sync between the server and client. I found that using the interface "BlockEntityClientSerializable" should help. So I implemented it and wrote the fromClientTag and toClientTag methods. However, it didn't have any effect. Then I copied MixinBlockEntity.java and MixinClientPlayNetworkHandler.java files in fabric-networking-blockentity-v0 into my own code. But Minecraft crashed. Could anyone tell me how could I render the changing of blockentity correctly? And what is happening for the Mixin files? Thank you very much! The crash report is attached here |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The MixinClientPlayNetworkHandler does a redirect, so both you and the fabric api can't do it at the same time. The symptoms of what you describe, make it sound like the data is not being sent to the client when you right click. Are you calling sync() when you change the block entity's state on the server? Try adding some debug messages to your "toClientNBT()" and "fromClientTag()" to see if they are being invoked and they contain the data you expect. |
Beta Was this translation helpful? Give feedback.
The MixinClientPlayNetworkHandler does a redirect, so both you and the fabric api can't do it at the same time.
If you want your own version, you would need to remove the fabric-api version.
The symptoms of what you describe, make it sound like the data is not being sent to the client when you right click.
But it is hard to say without seeing the code.
Are you calling sync() when you change the block entity's state on the server?
https://github.com/FabricMC/fabric/blob/1.17/fabric-networking-blockentity-v0/src/main/java/net/fabricmc/fabric/api/block/entity/BlockEntityClientSerializable.java
Try adding some debug messages to your "toClientNBT()" and "fromClientTag()" to see if they are bei…