I'm looking to make a mod that involves making a large multiblock structure (kind of like Draconic Evolution's Energy Core);
what is the best way to handle managing registering a structure correctly and verifying every block's placement?
secondly, what would be the best way to verify a block is part of the structure? (say maybe for opening the structure's GUI or handling input/output to the base tile entity)
#What is the best way to handle managing a multiblock structure?
10 messages · Page 1 of 1 (latest)
Hm, there's a lot of ways to handle this, depending on your goals. First question is how to render the multiblock. I assume you want a block entity for this energy core. The easiest way for this would probably then be to have a single block be the "controller" blockentity, where all the logic happens. Then all the other blocks of the multiblock are just proxies for this one block. Depending on your rendering setup, you'll probably want to turn the non-controller blocks invisible when they're part of the multiblock, and then render a model that covers all the other blocks (if it's a custom model you're using). In the proxy blocks, you need to store the location of the controller, and in the controller you need to store where you expect the proxy blocks to be, and then check them both. To check if the structure is active, you can check from the controller block whether a proxy block is at each expected location, and if it is, turn them all invisible and store the controller location in all the proxies. when interacting with the proxies, you just forward that interaction to the stored controller if they have any stored.
At least that's the best option that came to mind when builing something similar for my mod, although depending on how you want to assemble/break the block might require you to do it differently. If you want you can take a look at the implementation of my approach here: https://github.com/Rearth/Oritech/blob/1.21/src/main/java/rearth/oritech/util/MultiblockMachineController.java#L117
Then all the other blocks of the multiblock are just proxies for this one block
ohh so is that why the multiblocks I've seen in other mods are some form of different block type then the placeable kind
that makes a lot of sense actually
render a model that covers all the other blocks
ah that makes sense, though the only way I know how to make models is through Blockbench, and I think it only supports a max size of 3x3x3 per model, which my structure is definitely a lot bigger than
I'm not sure if I'll completely do this specifically but if I wanted the multiblock structure to be dynamically sized? how would the "global model" work for that? it seems like it would scale improperly for the sides or something like that
uh oops think I accidentally left ping on for that last comment sorry about that :D
How do you plan to display it? If you want it to render as individual blocks then just keep rendering the "proxies". If not then marking it dynamically sized is rather hard.
For rendering larger sizes you can either create a custom renderer or use something like geckolib
well currently I only have the individual block textures, don't have ones specifically for the structure yet lol
but yeah rendering the specific blocks still isn't completely unreasonable to do still