Bees buzz from flower to flower on the Green. Put down a beehive (a workbench makes one from planks and hay) near flowers, and bees come to live in it and fill it with honey: use a full hive to take two jars of honey. Leave them be: bop a bee in survival and it stings.
| 1 | --!strict |
| 2 | local test = require("@potluck/test@0.6") |
| 3 | local world = require("@potluck/world@0.20") |
| 4 | |
| 5 | local function ground(x: number, z: number): vector |
| 6 | return vector.create(x, world.top(x, z) + 1, z) |
| 7 | end |
| 8 | |
| 9 | local function bees(): { number } |
| 10 | return world.creatures(test.kind("Bee")) |
| 11 | end |
| 12 | |
| 13 | -- a hive with flowers around it, put down by a player in creative |
| 14 | local function garden(p): vector |
| 15 | local x, z = p.position.x + 4, p.position.z |
| 16 | local hive = ground(x, z) |
| 17 | test.place(p, hive, "Beehive") |
| 18 | for i, d in { { 3, 0 }, { -3, 1 }, { 0, 3 }, { 1, -3 }, { 3, 3 } } do |
| 19 | local f = ground(x + d[1], z + d[2]) |
| 20 | if world.block(f) == "Air" then |
| 21 | test.place(p, f, if i % 2 == 0 then "Red flower" else "Violet flower") |
| 22 | end |
| 23 | end |
| 24 | return hive |
| 25 | end |
| 26 | |
| 27 | test.case("a hive brings two more bees", function() |
| 28 | local p = test.player("Ada") |
| 29 | test.wait(1) |
| 30 | test.same(#bees(), 4, "bees on the Green") |
| 31 | garden(p) |
| 32 | test.wait(1) |
| 33 | test.same(#bees(), 6, "two more for the hive") |
| 34 | end) |
| 35 | |
| 36 | test.case("bees fill a hive with honey, and a full one gives two jars", function() |
| 37 | local p = test.player("Ada") |
| 38 | local hive = garden(p) |
| 39 | test.wait(240) |
| 40 | test.same(world.block(hive), "Full beehive", "full of honey") |
| 41 | local s = test.player("Bo", { survival = true }) |
| 42 | test.use_block(s, hive) |
| 43 | test.same(world.has(s, "Honey"), 2, "two jars") |
| 44 | test.same(world.block(hive), "Beehive", "empty again") |
| 45 | end) |
| 46 | |
| 47 | test.case("a broken full hive gives a hive back, and is forgotten", function() |
| 48 | local p = test.player("Ada", { survival = true }) |
| 49 | local x, z = p.position.x + 3, p.position.z |
| 50 | local at = ground(x, z) |
| 51 | world.set_block(at, "Full beehive") |
| 52 | test.dig(p, at) |
| 53 | test.same(world.has(p, "Beehive"), 1, "a hive back") |
| 54 | test.same(world.has(p, "Full beehive"), 0, "not a full one") |
| 55 | end) |
| 56 | |
| 57 | test.case("a bopped bee stings in survival", function() |
| 58 | local p = test.player("Ada", { survival = true }) |
| 59 | test.wait(1) |
| 60 | local b = test.creature(bees()[1]) |
| 61 | test.hit(p, b) |
| 62 | test.wait(0.2) |
| 63 | test.same(test.health(p), 19, "stung") |
| 64 | end) |