A bucket carries water: use it on water to fill it, and on a block to pour the water out on top. A fishing rod catches fish in any water: use it on the water, keep it in hand, and wait for a bite. Perch and trout bite in rivers and ponds, mackerel and flounder out in deep water, and now and then something else comes up: driftwood, an old tangle of line, or treasure. Fish cook in a furnace or on a campfire. Make both at a workbench.
| 1 | --!strict |
| 2 | -- Buckets and fishing's own tests: `potluck-server --test=water`. |
| 3 | |
| 4 | local test = require("@potluck/test@0.4") |
| 5 | local world = require("@potluck/world@0.17") |
| 6 | |
| 7 | local UP = vector.create(0, 1, 0) |
| 8 | |
| 9 | -- a survival player carrying `carrying`, and a pool of water beside them |
| 10 | local function by_water(carrying: { [string]: number }): (any, vector) |
| 11 | local p = test.player("Ada", { survival = true, carrying = carrying }) |
| 12 | local x, z = p.position.x + 2, p.position.z |
| 13 | local at = vector.create(x, world.top(x, z) + 1, z) |
| 14 | world.set_block(at, "Water") |
| 15 | return p, at |
| 16 | end |
| 17 | |
| 18 | -- everything they carry but `but`, counted |
| 19 | local function besides(p, but: string): number |
| 20 | local n = 0 |
| 21 | for thing, count in world.pockets(p) or {} do |
| 22 | if thing ~= but then |
| 23 | n += count |
| 24 | end |
| 25 | end |
| 26 | return n |
| 27 | end |
| 28 | |
| 29 | test.case("a bucket fills at water and pours it out on a block", function() |
| 30 | local p, water = by_water({ Bucket = 1 }) |
| 31 | test.hold(p, "Bucket") |
| 32 | test.use_block(p, water) |
| 33 | test.same(world.has(p, "Water bucket"), 1, "full") |
| 34 | test.same(world.has(p, "Bucket"), 0, "not empty") |
| 35 | test.hold(p, "Water bucket") |
| 36 | local x, z = p.position.x - 2, p.position.z |
| 37 | local ground = vector.create(x, world.top(x, z) + 1, z) |
| 38 | world.set_block(ground, "Stone") |
| 39 | world.set_block(ground + UP, "Air") |
| 40 | test.use_block(p, ground) |
| 41 | test.same(world.block(ground + UP), "Water", "poured out on top") |
| 42 | test.same(world.has(p, "Bucket"), 1, "empty again") |
| 43 | test.check(test.heard("splash") >= 2, "splashes") |
| 44 | end) |
| 45 | |
| 46 | test.case("a water bucket leaves a table alone", function() |
| 47 | local p = test.player("Ada", { survival = true, carrying = { ["Water bucket"] = 1 } }) |
| 48 | test.hold(p, "Water bucket") |
| 49 | local x, z = p.position.x + 2, p.position.z |
| 50 | local at = vector.create(x, world.top(x, z) + 1, z) |
| 51 | world.set_block(at, "Table") |
| 52 | world.set_block(at + UP, "Air") |
| 53 | test.use_block(p, at) |
| 54 | test.same(world.block(at + UP), "Air", "nothing poured") |
| 55 | test.same(world.has(p, "Water bucket"), 1, "still full") |
| 56 | end) |
| 57 | |
| 58 | test.case("a rod in hand catches something after a while", function() |
| 59 | local p, water = by_water({ ["Fishing rod"] = 1 }) |
| 60 | test.hold(p, "Fishing rod") |
| 61 | test.use_block(p, water) |
| 62 | test.check(test.shown(p, "water") ~= nil, "it says it's fishing") |
| 63 | test.same(test.heard("cast"), 1, "the line goes in") |
| 64 | test.wait(12) |
| 65 | test.same(besides(p, "Fishing rod"), 1, "one catch") |
| 66 | test.same(test.heard("bite"), 1, "a bite") |
| 67 | test.same(world.has(p, "Fishing rod"), 1, "the rod's still there") |
| 68 | end) |
| 69 | |
| 70 | test.case("putting the rod away loses the bite", function() |
| 71 | local p, water = by_water({ ["Fishing rod"] = 1 }) |
| 72 | test.hold(p, "Fishing rod") |
| 73 | test.use_block(p, water) |
| 74 | test.hold(p, nil) |
| 75 | test.wait(12) |
| 76 | test.same(besides(p, "Fishing rod"), 0, "nothing caught") |
| 77 | end) |