Skip to content

Commit

Permalink
fix: Crash when playing with Starlight installed
Browse files Browse the repository at this point in the history
Solution is the same as is in FramedBlocks, as was the original Flywheel fix.

Closes: GH-764
  • Loading branch information
Rover656 committed Sep 28, 2024
1 parent d401bca commit febf741
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,17 @@ public boolean canConnectRedstone(BlockState state, BlockGetter level, BlockPos
@Override
public int getLightEmission(BlockState state, BlockGetter level, BlockPos pos) {
BlockEntity existingBlockEntity;
if (ModList.get().isLoaded("flywheel")) {
existingBlockEntity = FlywheelCompat.getExistingBlockEntity(level, pos);

// Using IForgeBlockGetter#getExistingBlockEntity() with Starlight causes chunk-loading deadlocks
// Credit: https://github.com/XFactHD/FramedBlocks/blob/1.20/src/main/java/xfacthd/framedblocks/common/util/InternalApiImpl.java#L13-L20
if (ModList.get().isLoaded("starlight")) {
existingBlockEntity = level.getBlockEntity(pos);
} else if (ModList.get().isLoaded("flywheel")) {
existingBlockEntity = FlywheelCompat.getExistingBlockEntity(level, pos);
} else {
existingBlockEntity = level.getExistingBlockEntity(pos);
}

if (existingBlockEntity instanceof MachineBlockEntity machineBlock) {
return machineBlock.getLightEmission();
}
Expand Down

0 comments on commit febf741

Please sign in to comment.