master
Yiu Man Ho 2020-09-06 14:37:20 +08:00
parent 5a0d5fcbc1
commit 5c81a2728a
No known key found for this signature in database
GPG Key ID: 7939838BC85BF618
4 changed files with 73 additions and 0 deletions

70
init.lua Normal file
View File

@ -0,0 +1,70 @@
-- a tool to convert a mushroom biome into green forest with thick trees and flowers
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
minetest.register_craftitem("antishroom:antishroom",{
description = "Mushroom biome converter",
inventory_image = "antishroom.png",
wield_image = "antishroom_wield.png",
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local pos = pointed_thing.under
local target = minetest.get_node_or_nil(pos)
if target and target.name == "ethereal:mushroom_dirt" then
local start_pos = {
x = pos.x - 16,
z = pos.z - 16,
y = pos.y - 5
}
local end_pos = {
x = pos.x + 16,
z = pos.z + 16,
y = pos.y + 15
}
local rlist = {
["ethereal:mushroom_dirt"] = "default:dirt_with_grass",
["ethereal:mushroom_trunk"] = "default:tree",
["ethereal:mushroom"] = "default:leaves",
["ethereal:mushroom_pore"] = "default:apple"
}
local mlist = {}
for t,r in pairs(rlist) do
table.insert(mlist, t)
end
local found_mushroom_parts = minetest.find_nodes_in_area(start_pos, end_pos, mlist)
for _, f in ipairs(found_mushroom_parts) do
local node = minetest.get_node(f)
if not minetest.is_protected(f, user:get_player_name()) then
minetest.swap_node(f, { name = rlist[node.name] } )
if minetest.get_modpath("bonemeal") and node.name == "ethereal:mushroom_dirt" then
if math.random(1,5) > 4 then
bonemeal:on_use(f, 1, nil)
end
end
end
end
itemstack:take_item()
return itemstack
else
return itemstack
end
end,
})

3
mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = antishroom
description = Convert Mushroom Biome to other
depends = ethereal

BIN
textures/antishroom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B