Jump to content

Proper way to render multiblock. 1.15.2


AntonBespoiasov

Recommended Posts

My mod uses master-slave multiblock system. But I still don't know how should the multiblock be rendered. I have some possible solutions for this problem:

  1. Each block of a multiblock stores ID of its model as property of block state. Then using blockstate JSON files I can map corresponding models to corresponding block of multiblock. Here comes another question: should each multiblock have its own implementation of slave and master, just its own instances of an existing implementation of slave and master or one instance of each implementation of slave and master will be used for all multiblocks.
  2. I will create my own implementation of IBakedModel. Where one block will render entire multiblock while all other blocks in the multiblock will have no model and render nothing. But I'm not sure if IBakedModel is allowed to render something outside of its block.
  3. I will use TER to render entire multiblock like in previous solution but using TER instead of implementation of IBakedModel
  4. Each block of a multiblock will be separate block instance, have its own registry name and therefore its own blockstate JSON where I will be able to map corresponding model. 

If you have some other ideas share them. If its possible could you attach some example implementations and explain the solution better because I'm not really good at rendering and implementing IBakedModel.

 

Edited by AntonBespoiasov
Link to comment
Share on other sites

Hi

 

There are some example implementations here for IBakedModel and custom IModelData to pass information to a block renderer.

https://github.com/TheGreyGhost/MinecraftByExample

(mbe03, mbe04, mbe05)

 

My first thought: make the master block a tileentity and the slave blocks normal blocks.  If your slaves don't have too many different states, then store them as a blockstate.  Use the master tileentity to coordinate the slaves and keep them up-to-date.   If at all possible, avoid having the slaves try to talk to the master because they may be in different chunks which may be loaded at different times (i.e. the master may not be loaded).

 

If you describe your multiblock structure in more detail (i.e. in gameplay terms - from the point of view of someone playing the game, not from the point of view of what you think the code should look like) then we could make some more concrete suggestions...

 

Cheers

  TGG

 

 

 

Link to comment
Share on other sites

1 hour ago, TheGreyGhost said:

If you describe your multiblock structure in more detail (i.e. in gameplay terms - from the point of view of someone playing the game, not from the point of view of what you think the code should look like) then we could make some more concrete suggestions...

The multiblocks are pretty similar to those ones in Immersive Engineering. They can be rotated(but not mirrored yet), they look like solid machine and blocks of resulting multiblock mostly don't look similar to blocks that have stood on their places before the multiblock was formed. Clicking on different blocks of multiblock may trigger different actions. There will also be different additions to multiblock: items input/output block, pattern chest and pattern creator(they allow you to put some recipe in the machine they attached to and then perform this recipe automatically, like that crafting table from BuildCraft) and probably more. Some of them will be dynamic(e.g. altar that may have different amount of pedestals, pillars that may have different length), the look of the dynamic parts will mostly blend with entire multiblock.

 

System that is used to form multiblocks is already done and is based on events that will make some method iterate through multimap of multiblock creators(factories) instances associated with class of the event and call trigger method of the multiblock creators passing the event as a parameter. Things that will happen in the trigger method are all based on utils for scanning possible multiblock structure. Briefly: weird mix of Vanilla recipes system and Forge events system.

 

So when a player builds structure needed to form multiblock he will need to click(or perform some other key action in formation of multiblock) on certain block of the multiblock to trigger its creation.

Link to comment
Share on other sites

Howdy

Based on your description, I'd recommend using standard Blocks and Blockstates for all the slaves and TileEntities for the masters.

Your Multimap cache idea sounds ok but you will need to pay careful attention to Chunk loading, i.e. you will need to synchronise your multimap to the currently loaded chunks somehow.   That is more difficult than it sounds because they are multithreaded.

 

-TGG

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.

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.