Skip to content

Commit

Permalink
Fixed edge case structure block issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon3055 committed Oct 10, 2023
1 parent 8d8eb43 commit 9830b77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Change Log.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
######## 3.0.30.x ########
- Added energy link module.
######## 3.0.30.528 ########
- Added energy link module. (Effectively wireless charging direct from an energy core)
- Fixed guardian damaging itself with its own projectiles.
- Fixed rare edge case energy pylon crash.
- Fixed energy sometimes getting voided when adding and then removing modules containing energy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,18 @@ public void toggleActivation() {
continue;
}

BlockState state = level.getBlockState(pos);
BlockState originalState = level.getBlockState(pos);
//Fixes edge case where core can deactivate without reverting structure blocks,
//Only ever happened once due to a crash that is now fixed, but just to be safe...
if (originalState.is(DEContent.structure_block)) {
deactivateCore();
LOGGER.error("Detected existing structure block when attempting to activate core...");
return;
}
level.setBlockAndUpdate(pos, DEContent.structure_block.defaultBlockState());
BlockEntity tile = level.getBlockEntity(pos);
if (tile instanceof TileStructureBlock) {
((TileStructureBlock) tile).blockName.set(state.getBlock().getRegistryName());
((TileStructureBlock) tile).blockName.set(originalState.getBlock().getRegistryName());
((TileStructureBlock) tile).setController(this);
}
}
Expand Down

0 comments on commit 9830b77

Please sign in to comment.