Jump to content

TileEntity Multipart model


Recommended Posts

I am in the process of converting my existing blockstate based model to a tileentity due to excessive use of blockstates (4-value EnumProperty for each direction = 4096 + waterlogged = 8192 permutations!)

I have an existing (generated) multipart blockstate json, is there any way to easily convert it to the same model, just using the data from the tileentity instead of the blockstate?


I'm assuming I need to create a custom BakedModel, but I would ideally like to keep the current data-driven approach (one model for each of the 4 enum values).


It's the first time I've started looking into custom models, and I think a TileEntityRenderer is overkill for static models. Please correct me if I'm wrong.

Link to comment
Share on other sites

Almost fully working.

Only thing I'm now struggling with is forcing my TileEntity to sync.

I'm calling markDirty and requestModelDataUpdate after changing the property, but the client side data doesn't refresh until I close and reopen the world.

Do I need to send a custom packet, or is there an easier way of forcing a resync?

Link to comment
Share on other sites

Even closer now.

I do not want to update neighbours, as the property is changed from Block#neighborChanged, and I do not want to cause an infinite loop.

//Called after updating property
BlockState blockState = getBlockState();
//Do not update neighbours
getWorld().notifyBlockUpdate(getPos(), blockState, blockState, Constants.BlockFlags.BLOCK_UPDATE | Constants.BlockFlags.RERENDER_MAIN_THREAD); 

I also call requestModelDataUpdate at the end of handleUpdateTag.

The data is now correct on the client (displayed when right clicked), but the render is always 1 step behind (Only updates once another block is placed).

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.