Jump to content

Recommended Posts

Posted

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.

Posted

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?

Posted

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); 
requestModelDataUpdate();

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).

Posted
11 hours ago, diesieben07 said:

Call requestModelDataUpdate client-side

 

11 hours ago, Alpvax said:

the end of handleUpdateTag

I already do call it client side.

I have now removed the server side call, but nothing has changed.

Posted (edited)

I saw, thank you.

I'll hopefully test it tomorrow, but it looks good.

I've never managed to get my head around this, so thanks for helping.

Edited by Alpvax

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.