From 4e15afa25440baa7d457bd208f3aa034d9419975 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 5 May 2021 21:49:25 +0100 Subject: [PATCH] Add tests for placing monitors from turtles (#691) --- .../dan200/computercraft/ingame/TurtleTest.kt | 18 +- .../computers/computer/10/startup.lua | 10 + .../structures/turtle_test.place_monitor.snbt | 604 ++++++++++++++++++ 3 files changed, 627 insertions(+), 5 deletions(-) create mode 100644 src/test/server-files/computers/computer/10/startup.lua create mode 100644 src/test/server-files/structures/turtle_test.place_monitor.snbt diff --git a/src/test/java/dan200/computercraft/ingame/TurtleTest.kt b/src/test/java/dan200/computercraft/ingame/TurtleTest.kt index 9f00e29ff..822c1d9fc 100644 --- a/src/test/java/dan200/computercraft/ingame/TurtleTest.kt +++ b/src/test/java/dan200/computercraft/ingame/TurtleTest.kt @@ -13,7 +13,7 @@ class TurtleTest { * * @see [#537](https://github.com/SquidDev-CC/CC-Tweaked/issues/537) */ - @GameTest(required = false) + @GameTest suspend fun `Shears sheep`(context: TestContext) = context.checkComputerOk(5) /** @@ -21,7 +21,7 @@ class TurtleTest { * * @see [#518](https://github.com/SquidDev-CC/CC-Tweaked/issues/518) */ - @GameTest(required = false) + @GameTest suspend fun `Place lava`(context: TestContext) = context.checkComputerOk(5) /** @@ -29,7 +29,7 @@ class TurtleTest { * * @see [#385](https://github.com/SquidDev-CC/CC-Tweaked/issues/385) */ - @GameTest(required = false) + @GameTest suspend fun `Place waterlogged`(context: TestContext) = context.checkComputerOk(7) /** @@ -37,7 +37,7 @@ class TurtleTest { * * @see [#297](https://github.com/SquidDev-CC/CC-Tweaked/issues/297) */ - @GameTest(required = false) + @GameTest suspend fun `Gather lava`(context: TestContext) = context.checkComputerOk(8) /** @@ -45,6 +45,14 @@ class TurtleTest { * * @see [#258](https://github.com/SquidDev-CC/CC-Tweaked/issues/258) */ - @GameTest(required = false) + @GameTest suspend fun `Hoe dirt`(context: TestContext) = context.checkComputerOk(9) + + /** + * Checks turtles can place monitors + * + * @see [#691](https://github.com/SquidDev-CC/CC-Tweaked/issues/691) + */ + @GameTest + suspend fun `Place monitor`(context: TestContext) = context.checkComputerOk(10) } diff --git a/src/test/server-files/computers/computer/10/startup.lua b/src/test/server-files/computers/computer/10/startup.lua new file mode 100644 index 000000000..81a5bb018 --- /dev/null +++ b/src/test/server-files/computers/computer/10/startup.lua @@ -0,0 +1,10 @@ +-- Turtle.`Place Monitor` + +test.assert(turtle.place()) + +local has_block, block = turtle.inspect() +test.assert(has_block, "Has block") +test.eq("computercraft:monitor_advanced", block.name) +test.eq("lr", block.state.state) + +test.ok() diff --git a/src/test/server-files/structures/turtle_test.place_monitor.snbt b/src/test/server-files/structures/turtle_test.place_monitor.snbt new file mode 100644 index 000000000..966912798 --- /dev/null +++ b/src/test/server-files/structures/turtle_test.place_monitor.snbt @@ -0,0 +1,604 @@ +{ + size: [5, 5, 5], + entities: [], + blocks: [ + { + pos: [0, 0, 0], + state: 0 + }, + { + pos: [1, 0, 0], + state: 0 + }, + { + pos: [2, 0, 0], + state: 0 + }, + { + pos: [3, 0, 0], + state: 0 + }, + { + pos: [4, 0, 0], + state: 0 + }, + { + pos: [0, 0, 1], + state: 0 + }, + { + pos: [1, 0, 1], + state: 0 + }, + { + pos: [2, 0, 1], + state: 0 + }, + { + pos: [3, 0, 1], + state: 0 + }, + { + pos: [4, 0, 1], + state: 0 + }, + { + pos: [0, 0, 2], + state: 0 + }, + { + pos: [1, 0, 2], + state: 0 + }, + { + pos: [2, 0, 2], + state: 0 + }, + { + pos: [3, 0, 2], + state: 0 + }, + { + pos: [4, 0, 2], + state: 0 + }, + { + pos: [0, 0, 3], + state: 0 + }, + { + pos: [1, 0, 3], + state: 0 + }, + { + pos: [2, 0, 3], + state: 0 + }, + { + pos: [3, 0, 3], + state: 0 + }, + { + pos: [4, 0, 3], + state: 0 + }, + { + pos: [0, 0, 4], + state: 0 + }, + { + pos: [1, 0, 4], + state: 0 + }, + { + pos: [2, 0, 4], + state: 0 + }, + { + pos: [3, 0, 4], + state: 0 + }, + { + pos: [4, 0, 4], + state: 0 + }, + { + pos: [1, 1, 4], + state: 1 + }, + { + nbt: { + Owner: { + UpperId: 4039158846114182220L, + LowerId: -6876936588741668278L, + Name: "Dev" + }, + Fuel: 0, + Slot: 0, + Items: [ + { + Slot: 0b, + id: "computercraft:monitor_advanced", + Count: 1b + } + ], + id: "computercraft:turtle_normal", + ComputerId: 10, + On: 1b + }, + pos: [1, 1, 2], + state: 2 + }, + { + nbt: { + XIndex: 0, + Height: 1, + id: "computercraft:monitor_advanced", + Width: 1, + YIndex: 0 + }, + pos: [0, 1, 3], + state: 3 + }, + { + nbt: { + XIndex: 2, + Height: 1, + id: "computercraft:monitor_advanced", + Width: 3, + YIndex: 0 + }, + pos: [2, 1, 3], + state: 4 + }, + { + nbt: { + XIndex: 1, + Height: 1, + id: "computercraft:monitor_advanced", + Width: 3, + YIndex: 0 + }, + pos: [3, 1, 3], + state: 5 + }, + { + nbt: { + XIndex: 0, + Height: 1, + id: "computercraft:monitor_advanced", + Width: 3, + YIndex: 0 + }, + pos: [4, 1, 3], + state: 6 + }, + { + pos: [0, 1, 0], + state: 7 + }, + { + pos: [1, 1, 0], + state: 7 + }, + { + pos: [2, 1, 0], + state: 7 + }, + { + pos: [3, 1, 0], + state: 7 + }, + { + pos: [4, 1, 0], + state: 7 + }, + { + pos: [0, 2, 0], + state: 7 + }, + { + pos: [1, 2, 0], + state: 7 + }, + { + pos: [2, 2, 0], + state: 7 + }, + { + pos: [3, 2, 0], + state: 7 + }, + { + pos: [4, 2, 0], + state: 7 + }, + { + pos: [0, 3, 0], + state: 7 + }, + { + pos: [1, 3, 0], + state: 7 + }, + { + pos: [2, 3, 0], + state: 7 + }, + { + pos: [3, 3, 0], + state: 7 + }, + { + pos: [4, 3, 0], + state: 7 + }, + { + pos: [0, 4, 0], + state: 7 + }, + { + pos: [1, 4, 0], + state: 7 + }, + { + pos: [2, 4, 0], + state: 7 + }, + { + pos: [3, 4, 0], + state: 7 + }, + { + pos: [4, 4, 0], + state: 7 + }, + { + pos: [0, 1, 1], + state: 7 + }, + { + pos: [1, 1, 1], + state: 7 + }, + { + pos: [2, 1, 1], + state: 7 + }, + { + pos: [3, 1, 1], + state: 7 + }, + { + pos: [4, 1, 1], + state: 7 + }, + { + pos: [0, 2, 1], + state: 7 + }, + { + pos: [1, 2, 1], + state: 7 + }, + { + pos: [2, 2, 1], + state: 7 + }, + { + pos: [3, 2, 1], + state: 7 + }, + { + pos: [4, 2, 1], + state: 7 + }, + { + pos: [0, 3, 1], + state: 7 + }, + { + pos: [1, 3, 1], + state: 7 + }, + { + pos: [2, 3, 1], + state: 7 + }, + { + pos: [3, 3, 1], + state: 7 + }, + { + pos: [4, 3, 1], + state: 7 + }, + { + pos: [0, 4, 1], + state: 7 + }, + { + pos: [1, 4, 1], + state: 7 + }, + { + pos: [2, 4, 1], + state: 7 + }, + { + pos: [3, 4, 1], + state: 7 + }, + { + pos: [4, 4, 1], + state: 7 + }, + { + pos: [0, 1, 2], + state: 7 + }, + { + pos: [2, 1, 2], + state: 7 + }, + { + pos: [3, 1, 2], + state: 7 + }, + { + pos: [4, 1, 2], + state: 7 + }, + { + pos: [0, 2, 2], + state: 7 + }, + { + pos: [1, 2, 2], + state: 7 + }, + { + pos: [2, 2, 2], + state: 7 + }, + { + pos: [3, 2, 2], + state: 7 + }, + { + pos: [4, 2, 2], + state: 7 + }, + { + pos: [0, 3, 2], + state: 7 + }, + { + pos: [1, 3, 2], + state: 7 + }, + { + pos: [2, 3, 2], + state: 7 + }, + { + pos: [3, 3, 2], + state: 7 + }, + { + pos: [4, 3, 2], + state: 7 + }, + { + pos: [0, 4, 2], + state: 7 + }, + { + pos: [1, 4, 2], + state: 7 + }, + { + pos: [2, 4, 2], + state: 7 + }, + { + pos: [3, 4, 2], + state: 7 + }, + { + pos: [4, 4, 2], + state: 7 + }, + { + pos: [1, 1, 3], + state: 7 + }, + { + pos: [0, 2, 3], + state: 7 + }, + { + pos: [1, 2, 3], + state: 7 + }, + { + pos: [2, 2, 3], + state: 7 + }, + { + pos: [3, 2, 3], + state: 7 + }, + { + pos: [4, 2, 3], + state: 7 + }, + { + pos: [0, 3, 3], + state: 7 + }, + { + pos: [1, 3, 3], + state: 7 + }, + { + pos: [2, 3, 3], + state: 7 + }, + { + pos: [3, 3, 3], + state: 7 + }, + { + pos: [4, 3, 3], + state: 7 + }, + { + pos: [0, 4, 3], + state: 7 + }, + { + pos: [1, 4, 3], + state: 7 + }, + { + pos: [2, 4, 3], + state: 7 + }, + { + pos: [3, 4, 3], + state: 7 + }, + { + pos: [4, 4, 3], + state: 7 + }, + { + pos: [0, 1, 4], + state: 7 + }, + { + pos: [2, 1, 4], + state: 7 + }, + { + pos: [3, 1, 4], + state: 7 + }, + { + pos: [4, 1, 4], + state: 7 + }, + { + pos: [0, 2, 4], + state: 7 + }, + { + pos: [1, 2, 4], + state: 7 + }, + { + pos: [2, 2, 4], + state: 7 + }, + { + pos: [3, 2, 4], + state: 7 + }, + { + pos: [4, 2, 4], + state: 7 + }, + { + pos: [0, 3, 4], + state: 7 + }, + { + pos: [1, 3, 4], + state: 7 + }, + { + pos: [2, 3, 4], + state: 7 + }, + { + pos: [3, 3, 4], + state: 7 + }, + { + pos: [4, 3, 4], + state: 7 + }, + { + pos: [0, 4, 4], + state: 7 + }, + { + pos: [1, 4, 4], + state: 7 + }, + { + pos: [2, 4, 4], + state: 7 + }, + { + pos: [3, 4, 4], + state: 7 + }, + { + pos: [4, 4, 4], + state: 7 + } + ], + palette: [ + { + Name: "minecraft:polished_andesite" + }, + { + Name: "minecraft:dark_oak_planks" + }, + { + Properties: { + waterlogged: "false", + facing: "south" + }, + Name: "computercraft:turtle_normal" + }, + { + Properties: { + orientation: "north", + facing: "north", + state: "none" + }, + Name: "computercraft:monitor_advanced" + }, + { + Properties: { + orientation: "north", + facing: "north", + state: "l" + }, + Name: "computercraft:monitor_advanced" + }, + { + Properties: { + orientation: "north", + facing: "north", + state: "lr" + }, + Name: "computercraft:monitor_advanced" + }, + { + Properties: { + orientation: "north", + facing: "north", + state: "r" + }, + Name: "computercraft:monitor_advanced" + }, + { + Name: "minecraft:air" + } + ], + DataVersion: 2230 +}