Q to drop
This commit is contained in:
@@ -85,3 +85,32 @@ Deno.test("stacks next to each other merge, and items on the ground are saved wi
|
||||
const joined = reloaded.join(2, "bob");
|
||||
assertEquals(joined.entities.map((entity: { item: unknown }) => entity.item), [{ id: "bworld:dirt", count: 6 }]);
|
||||
});
|
||||
|
||||
Deno.test("q throws one of an item the way the player looks, ctrl throws the whole stack", async () => {
|
||||
const { game, take, send, join } = await test_game("mods");
|
||||
join(1, "alice");
|
||||
build_floor(game);
|
||||
// looking straight along -z (yaw 0)
|
||||
send(1, { type: "move", x: 0.5, y: 100, z: 0.5, yaw: 0, pitch: 0 });
|
||||
send(1, { type: "chat", text: "/give bworld:stone 5" });
|
||||
take(1);
|
||||
|
||||
send(1, { type: "drop_item", container: "inventory", index: 0, all: false });
|
||||
const [thrown] = game.item_entities();
|
||||
assertEquals(thrown.item.amount, 1);
|
||||
assert(thrown.vz < -5 && Math.abs(thrown.vx) < 1, "thrown forwards");
|
||||
assertEquals(inventory_count(take(1), "bworld:stone"), 4);
|
||||
|
||||
for (let i = 0; i < 20; i++) game.tick();
|
||||
assert(thrown.z < -1, "it flew away from the player");
|
||||
assertEquals(game.item_entities().length, 1, "and isn't picked straight back up");
|
||||
|
||||
send(1, { type: "drop_item", container: "inventory", index: 0, all: true });
|
||||
assertEquals(game.item_entities().map((entity) => entity.item.amount).sort(), [1, 4]);
|
||||
assertEquals(inventory_count(take(1), "bworld:stone"), 0);
|
||||
|
||||
// empty slots and the crafting result don't throw anything
|
||||
send(1, { type: "drop_item", container: "inventory", index: 0, all: true });
|
||||
send(1, { type: "drop_item", container: "crafting", index: 9, all: true });
|
||||
assertEquals(game.item_entities().length, 2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user