Skip to content

Commit

Permalink
fix: make multiblock parts break when the base block explodes (#348)
Browse files Browse the repository at this point in the history
Closes #333 

* Fixed solar panel part blocks not breaking when the solar panel base was destroyed from an explosion.
* Fixed issues as requested
  • Loading branch information
DuckyProgrammer authored Aug 25, 2024
1 parent 094dcd9 commit c1ce0e2
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -57,6 +58,18 @@ public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state,
return returnState;
}

@Override
public void wasExploded(Level world, BlockPos pos, Explosion explosion) {
for (BlockPos part : this.getOtherParts(world.getBlockState(pos))) {
part = pos.immutable().offset(part);
if (!(world.getBlockEntity(part) instanceof MultiBlockPart)) {
continue;
}
world.removeBlock(part, false);
}
super.wasExploded(world, pos, explosion);
}

@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
for (BlockPos otherPart : this.getOtherParts(state)) {
Expand Down

0 comments on commit c1ce0e2

Please sign in to comment.