Posted January 11, 20187 yr So, this is kinda related with other questions I made in the Forum. I have a block that onBlockActivated get some changes and those need to be notified so the client re-renders the model. So at the end of the onBlockActivated method I'm doing if (worldIn.isRemote) { // worldIn.markBlockRangeForRenderUpdate(pos, pos); worldIn.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ()); } Using that method, it's not until the 2nd time I right click the block, that the render updates correctly (I guess by the time it's called for some reason it still doesn't know about the changes) However if I use Minecraft.getMinecraft().renderGlobal.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ()); The model updates correctly. Why is this?
January 11, 20187 yr The scenario is: On right click, we update the tile entity and send that data down the line to the clients with a notifyBlockUpdate - which we call with the same, current blockstate twice as the actual blockstate of the block doesn't change; not sure if we should be doing something different here. In that same right click handler, we are tying to do a block render update, which most of the time causes timing issues since the new data we need for updating the rendering on the client has not been received by the client yet. What we ideally would need is a way to update the rendering of the block after we are sure we received the update data, so after handleUpdateTag happened. Is there an ideal way of doing this kind of thing? PS: I am working on the mod together with American2050. Edited January 11, 20187 yr by PureSpider
January 11, 20187 yr In our case it doesnt cause a re-render, since our block is an IBakedModel that we are updating depending on the TE data, via IExtendedBlockState produced by getExtendedState() on the block. Is there anything special we need to keep in mind for this case as our block right now definitely doesnt get re-rendered when we send a notifyBlockUpdate?
January 11, 20187 yr I just checked and getExtendedState only gets called when the world is first loaded, not on the update we send. I have no clue why not. We never manually call getExtendedState, we get that block state passed into getQuads. Here is log from the server and client confirming that the update is indeed reaching the client. I also made sure of this multiple times by reading the respective attributes on the TE after an update and made sure they updated correctly. The method writeDataToNbt takes care of serializing our TE state to NBT: [17:31:09] [Server thread/INFO] [org.bitbucket.factoryblock.LogHelper]: getUpdatePacket [17:31:09] [Server thread/INFO] [org.bitbucket.factoryblock.LogHelper]: getUpdateTag [17:31:09] [Server thread/INFO] [org.bitbucket.factoryblock.LogHelper]: writeDataToNbt [17:31:09] [main/INFO] [org.bitbucket.factoryblock.LogHelper]: onDataPacket [17:31:09] [main/INFO] [org.bitbucket.factoryblock.LogHelper]: handleUpdateTag [17:31:09] [main/INFO] [org.bitbucket.factoryblock.LogHelper]: readFromNBT
January 11, 20187 yr Nevermind that, fixed it, your hint nudged us in the right direction: @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { handleUpdateTag(pkt.getNbtCompound()); if (this.getWorld().isRemote) { this.getWorld().markBlockRangeForRenderUpdate(this.pos, this.pos); } } Thank you! Edited January 11, 20187 yr by PureSpider
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.