From f9eb67b4cc3b3a3113c071cebc0ee8e4e9f9fdd4 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Tue, 11 May 2021 22:17:10 +0100 Subject: [PATCH] bonemeal: Try bonemealing everything that isn't an air block fixes #49 --- CHANGELOG.md | 1 + worldeditadditions/lib/bonemeal.lua | 31 +++++++++++------------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8353328..ea0d243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Note to self: See the bottom of this file for the release template text. - Add `//srect` (_select rectangle_), `//scol` (_select column_), `//scube` (_select cube_) - thanks, @VorTechnix! - Add `//scloud` (_select point cloud_), `//scentre` (_select centre node(s)_), `//srel` (_select relative_) - thanks, @VorTechnix! - Significantly refactored backend utility functions (more to come in future updates) +- `//bonemeal`: Try bonemealing everything that isn't an air block (#49) ## v1.11: The big data update (25th January 2021) diff --git a/worldeditadditions/lib/bonemeal.lua b/worldeditadditions/lib/bonemeal.lua index 7c4c75d..1b7fc7c 100644 --- a/worldeditadditions/lib/bonemeal.lua +++ b/worldeditadditions/lib/bonemeal.lua @@ -25,27 +25,20 @@ function worldeditadditions.bonemeal(pos1, pos2, strength, chance) local candidates = 0 for z = pos2.z, pos1.z, -1 do for x = pos2.x, pos1.x, -1 do - local found_air = false - for y = pos2.y, pos1.y, -1 do - if data[area:index(x, y, z)] ~= node_id_air then - if found_air then - -- We've found an air block previously, so this node definitely has air above it - - if math.random(0, chance - 1) == 0 then - bonemeal:on_use( - { x = x, y = y, z = z }, - strength, - nil - ) - nodes_bonemealed = nodes_bonemealed + 1 - end - - candidates = candidates + 1 - found_air = false + if not worldeditadditions.is_airlike(data[area:index(x, y, z)]) then + -- It's not an air node, so let's try to bonemeal it + + if math.random(0, chance - 1) == 0 then + bonemeal:on_use( + { x = x, y = y, z = z }, + strength, + nil + ) + nodes_bonemealed = nodes_bonemealed + 1 end - else - found_air = true + + candidates = candidates + 1 end end end