Some sanity checks for get{Direction,Orientation}

Silly bodge, but should fix #600.
This commit is contained in:
SquidDev 2020-12-10 19:13:49 +00:00
parent ea3a160367
commit bb8f4c624b
1 changed files with 7 additions and 2 deletions

View File

@ -14,6 +14,7 @@
import dan200.computercraft.shared.network.client.TerminalState;
import dan200.computercraft.shared.util.CapabilityUtil;
import dan200.computercraft.shared.util.TickScheduler;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
@ -325,12 +326,16 @@ private void updateBlockState()
// region Sizing and placement stuff
public Direction getDirection()
{
return getBlockState().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 = getBlockState();
return state.has( BlockMonitor.FACING ) ? state.get( BlockMonitor.FACING ) : Direction.NORTH;
}
public Direction getOrientation()
{
return getBlockState().get( BlockMonitor.ORIENTATION );
BlockState state = getBlockState();
return state.has( BlockMonitor.ORIENTATION ) ? state.get( BlockMonitor.ORIENTATION ) : Direction.NORTH;
}
public Direction getFront()