-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: damage multiBlock Structures #231
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this is not a default feature of MultiBlocks 👀 What does MB do with attacks to a multi-block structure?
if (entity.hasComponent(MultiBlockMainComponent.class)) { | ||
blocks = entity.getComponent(MultiBlockMainComponent.class).getMultiBlockMembers(); | ||
} else if (entity.hasComponent(MultiBlockMemberComponent.class)) { | ||
blocks = blockEntityRegistry.getBlockEntityAt(entity.getComponent(MultiBlockMemberComponent.class).getMainBlockLocation()).getComponent(MultiBlockMainComponent.class).getMultiBlockMembers(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd do this in two separate steps:
- find the main multi-block, if any
- derive the
blocks
from that main block
To make the code easier to comprehend I'd additionally move this to a method which returns an Optional<Collection<Vector3i>>
with the multi-block member positions, if any multi-block is hit.
As it does not make any difference for us whether we iterate over an empty collection (and thus don't damage any other blocks) or check if the collection is present we may even get rid of the optional here and just return a collection that may or may not contain any entries.
Whenever a block in a multiBlock structure is damaged all the others blocks in the multiBlock structure are also damaged.