From eb8bd31b428c2bf731be82479fd702c3d9b9c8e8 Mon Sep 17 00:00:00 2001 From: Vexatos Date: Sat, 2 Apr 2016 20:27:04 +0200 Subject: [PATCH] Improved rotation of computer spawning command. --- .../server/command/SpawnComputerCommand.scala | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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 690e47056..ef67919be 100644 --- a/src/main/scala/li/cil/oc/server/command/SpawnComputerCommand.scala +++ b/src/main/scala/li/cil/oc/server/command/SpawnComputerCommand.scala @@ -41,11 +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(ForgeDirection.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()) + rotateProperly(screenPos) match { + case rotatable: tileentity.traits.Rotatable => rotatable.pitch match { + case ForgeDirection.UP | ForgeDirection.DOWN => + rotatable.pitch = ForgeDirection.NORTH + case _ => // nothing to do here, pitch is fine + } + case _ => // ??? + } world.setBlock(keyboardPos, api.Items.get(Constants.BlockName.Keyboard).block()) world.getTileEntity(keyboardPos) match { - case t: tileentity.traits.Rotatable => t.setFromFacing(ForgeDirection.UP) + case t: tileentity.traits.Rotatable => + t.setFromEntityPitchAndYaw(player) + t.setFromFacing(ForgeDirection.UP) case _ => // ??? }