Creative
This commit is contained in:
@@ -202,3 +202,36 @@ Deno.test("how far players reach is an attribute, which their client is sent", a
|
||||
assertEquals(game.world.get_block_id(0, 99, 9), "cubi:air");
|
||||
cleanup();
|
||||
});
|
||||
|
||||
Deno.test("/creative places blocks without using them up and breaks blocks without drops", async () => {
|
||||
const { game, send, take, hold, cleanup } = await setup();
|
||||
const [alice] = game.players();
|
||||
hold("testmod:pillar");
|
||||
send(1, { type: "chat", text: "/creative" });
|
||||
game.tick();
|
||||
assert(take(1).some((m) => m.type === "creative" && m.creative), "the player hears they're in creative");
|
||||
|
||||
send(1, { type: "use_block", x: 1, y: 99, z: 1, face: "top" });
|
||||
send(1, { type: "use_block", x: 1, y: 100, z: 1, face: "top" });
|
||||
assertEquals(game.world.get_block_id(1, 101, 1), "testmod:pillar");
|
||||
assertEquals(alice.inventory.get_slot(alice.selected_slot).amount, 1);
|
||||
|
||||
game.set_block(2, 100, 1, "bworld:dirt");
|
||||
send(1, { type: "break_block", x: 2, y: 100, z: 1 });
|
||||
assertEquals(game.world.get_block_id(2, 100, 1), "cubi:air");
|
||||
assertEquals(game.item_entities(), []);
|
||||
// even ones that can't be broken otherwise
|
||||
game.set_block(2, 100, 1, "bworld:water");
|
||||
send(1, { type: "break_block", x: 2, y: 100, z: 1 });
|
||||
assertEquals(game.world.get_block_id(2, 100, 1), "cubi:air");
|
||||
|
||||
// out of it, placing uses the block up again and breaking drops
|
||||
send(1, { type: "chat", text: "/creative" });
|
||||
send(1, { type: "use_block", x: 1, y: 101, z: 1, face: "top" });
|
||||
assertEquals(game.world.get_block_id(1, 102, 1), "testmod:pillar");
|
||||
assert(!alice.inventory.get_slot(alice.selected_slot).has_item());
|
||||
game.set_block(2, 100, 1, "bworld:dirt");
|
||||
send(1, { type: "break_block", x: 2, y: 100, z: 1 });
|
||||
assertEquals(game.item_entities().length, 1);
|
||||
cleanup();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user