diff --git a/src/main/scala/li/cil/oc/server/command/SpawnComputerCommand.scala b/src/main/scala/li/cil/oc/server/command/SpawnComputerCommand.scala index a50fbcb59..79e95473b 100644 --- a/src/main/scala/li/cil/oc/server/command/SpawnComputerCommand.scala +++ b/src/main/scala/li/cil/oc/server/command/SpawnComputerCommand.scala @@ -41,15 +41,35 @@ object SpawnComputerCommand extends SimpleCommand("oc_spawnComputer") { return } + def rotateProperly(pos: BlockPosition):tileentity.traits.Rotatable = { + world.getTileEntity(pos) match { + case rotatable: tileentity.traits.Rotatable => + rotatable.setFromEntityPitchAndYaw(player) + if (!rotatable.validFacings.contains(rotatable.pitch)) { + rotatable.pitch = rotatable.validFacings.headOption.getOrElse(EnumFacing.NORTH) + } + rotatable.invertRotation() + rotatable + case _ => null // not rotatable + } + } + world.setBlock(casePos, api.Items.get(Constants.BlockName.CaseCreative).block()) + rotateProperly(casePos) world.setBlock(screenPos, api.Items.get(Constants.BlockName.ScreenTier2).block()) - world.setBlock(keyboardPos, api.Items.get(Constants.BlockName.Keyboard).block()) - world.getTileEntity(keyboardPos) match { - case t: tileentity.traits.Rotatable => t.setFromFacing(EnumFacing.UP) + rotateProperly(screenPos) match { + case rotatable: tileentity.traits.Rotatable => rotatable.pitch match { + case EnumFacing.UP | EnumFacing.DOWN => + rotatable.pitch = EnumFacing.NORTH + case _ => // nothing to do here, pitch is fine + } case _ => // ??? } - world.getTileEntity(screenPos) match { - case t: tileentity.traits.Rotatable => t.setFromFacing(EnumFacing.NORTH) + world.setBlock(keyboardPos, api.Items.get(Constants.BlockName.Keyboard).block()) + world.getTileEntity(keyboardPos) match { + case t: tileentity.traits.Rotatable => + t.setFromEntityPitchAndYaw(player) + t.setFromFacing(EnumFacing.UP) case _ => // ??? }