diff --git a/patchwork.md b/patchwork.md index 84ab9a376..40a7ddb96 100644 --- a/patchwork.md +++ b/patchwork.md @@ -435,3 +435,10 @@ ea3a16036794357c3a44edffc90fdb652e03881e Remove a couple of todos ``` + +``` +bb8f4c624bf87169b73fb631d8250cfc38181e15 + +Some sanity checks for get{Direction,Orientation} +``` +Use `getCachedState` instead of forge's `getBlockState` and `contains` instead of `has`. \ No newline at end of file diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java index aa520479d..d677099f3 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java @@ -218,7 +218,10 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile { // region Sizing and placement stuff public Direction getDirection() { - return this.getCachedState().get(BlockMonitor.FACING); + // Ensure we're actually a monitor block. This _should_ always be the case, but sometimes there's + // fun problems with the block being missing on the client. + BlockState state = getCachedState(); + return state.contains( BlockMonitor.FACING ) ? state.get( BlockMonitor.FACING ) : Direction.NORTH; } public Direction getOrientation() {