#What is the best way to handle managing a multiblock structure?

10 messages · Page 1 of 1 (latest)

tame swallow
#

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)

deft saffron
#

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

GitHub

Minecraft fabric tech mod. Contribute to Rearth/Oritech development by creating an account on GitHub.

tame swallow
tame swallow
tame swallow
tame swallow
deft saffron
#

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

tame swallow