forked from MineClone5/MineClone5
#11 Spawn buds
This commit is contained in:
parent
1a78fde1a0
commit
adbde60b10
|
@ -78,13 +78,13 @@ mcl_structures.register_structure({
|
||||||
})
|
})
|
||||||
|
|
||||||
local decrease_scan_area = 1
|
local decrease_scan_area = 1
|
||||||
local mapblock_opacity_placement_threshold = 0.9
|
local mapblock_opacity_placement_threshold = 0.98
|
||||||
local threshold = math.floor(((mcl_mapgen.BS - 2 * decrease_scan_area)^3) * mapblock_opacity_placement_threshold)
|
local threshold = math.floor(((mcl_mapgen.BS - 2 * decrease_scan_area)^3) * mapblock_opacity_placement_threshold)
|
||||||
mcl_mapgen.register_mapgen_block(function(minp, maxp, blockseed)
|
mcl_mapgen.register_mapgen_block(function(minp, maxp, blockseed)
|
||||||
local y = minp.y
|
local y = minp.y
|
||||||
if y < 0 then return end
|
if y < 0 then return end
|
||||||
local pr = PseudoRandom(blockseed + 143)
|
local pr = PseudoRandom(blockseed + 143)
|
||||||
if pr:next(120) ~= 54 then return end
|
if pr:next(1, 120) ~= 54 then return end
|
||||||
local opacity_counter = #minetest.find_nodes_in_area(vector.add(minp, decrease_scan_area), vector.subtract(maxp, decrease_scan_area), "group:opaque")
|
local opacity_counter = #minetest.find_nodes_in_area(vector.add(minp, decrease_scan_area), vector.subtract(maxp, decrease_scan_area), "group:opaque")
|
||||||
if opacity_counter < threshold then return end
|
if opacity_counter < threshold then return end
|
||||||
place(minp, nil, pr)
|
place(minp, nil, pr)
|
||||||
|
|
|
@ -1,49 +1,54 @@
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
|
||||||
function mcl_amethyst.grow_amethyst_bud(pos, ignore_budding_amethyst)
|
local interval = 10
|
||||||
local node = minetest.get_node(pos)
|
local chance = 5
|
||||||
|
|
||||||
|
local function grow(pos, node)
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
if not (def and def.groups and def.groups.amethyst_buds) then return end
|
|
||||||
local next_gen = def._mcl_amethyst_next_grade
|
local next_gen = def._mcl_amethyst_next_grade
|
||||||
if not next_gen then return end
|
if not next_gen then return end
|
||||||
|
|
||||||
-- Check Budding Amethyst
|
|
||||||
if not ignore_budding_amethyst then
|
|
||||||
local dir = minetest.wallmounted_to_dir(node.param2)
|
local dir = minetest.wallmounted_to_dir(node.param2)
|
||||||
local ba_pos = vector.add(pos, dir)
|
local ba_pos = vector.add(pos, dir)
|
||||||
local ba_node = minetest.get_node(ba_pos)
|
local ba_node = minetest.get_node(ba_pos)
|
||||||
if ba_node.name ~= "mcl_amethyst:budding_amethyst_block" then return end
|
if ba_node.name ~= "mcl_amethyst:budding_amethyst_block" then return end
|
||||||
end
|
|
||||||
local swap_result = table.copy(node)
|
local swap_result = table.copy(node)
|
||||||
swap_result.name = next_gen
|
swap_result.name = next_gen
|
||||||
minetest.swap_node(pos, swap_result)
|
minetest.swap_node(pos, swap_result)
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_growing_tool_handle(ignore)
|
minetest.register_abm({
|
||||||
return function(itemstack, user, pointed_thing)
|
label = "Amethyst Bud Growth",
|
||||||
if not user:is_player() then return end
|
nodenames = {"group:amethyst_buds"},
|
||||||
local name = user:get_player_name()
|
neighbors = {"mcl_amethyst:budding_amethyst_block"},
|
||||||
local pos = minetest.get_pointed_thing_position(pointed_thing)
|
interval = interval,
|
||||||
if minetest.is_protected(pos, name) then
|
chance = chance,
|
||||||
minetest.record_protection_violation(pos, name)
|
action = grow,
|
||||||
minetest.chat_send_player(name, S("Not allowed to use Amethyst Growing Tool in a protected area!"))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if not mcl_amethyst.grow_amethyst_bud(pos, ignore) then
|
|
||||||
minetest.chat_send_player(name, S("Growing Failed"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_tool("mcl_amethyst:growing_tool",{
|
|
||||||
description = S("Amethyst Growing Tool"),
|
|
||||||
on_use = get_growing_tool_handle(true),
|
|
||||||
on_place = get_growing_tool_handle(false),
|
|
||||||
inventory_image = "amethyst_cluster.png^amethyst_shard.png",
|
|
||||||
groups = {
|
|
||||||
tool = 1,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mcl_wip.register_experimental_item("mcl_amethyst:growing_tool")
|
local all_directions = {
|
||||||
|
vector.new(1,0,0),
|
||||||
|
vector.new(0,1,0),
|
||||||
|
vector.new(0,0,1),
|
||||||
|
vector.new(-1,0,0),
|
||||||
|
vector.new(0,-1,0),
|
||||||
|
vector.new(0,0,-1),
|
||||||
|
}
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
label = "Spawn Amethyst Bud",
|
||||||
|
nodenames = {"mcl_amethyst:budding_amethyst_block"},
|
||||||
|
neighbors = {"air", "group:water"},
|
||||||
|
interval = 20,
|
||||||
|
chance = 2,
|
||||||
|
action = function(pos)
|
||||||
|
local check_pos = vector.add(all_directions[math.random(1, #all_directions)], pos)
|
||||||
|
local check_node = minetest.get_node(check_pos)
|
||||||
|
local check_node_name = check_node.name
|
||||||
|
if check_node_name ~= "air" and minetest.get_item_group(check_node_name, "water") == 0 then return end
|
||||||
|
local param2 = minetest.dir_to_wallmounted(vector.subtract(pos, check_pos))
|
||||||
|
local new_node = {name = "mcl_amethyst:medium_amethyst_bud", param2 = param2}
|
||||||
|
minetest.swap_node(check_pos, new_node)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name = mcl_amethyst
|
name = mcl_amethyst
|
||||||
author = Emojiminetest
|
author = Emojiminetest, kay27
|
||||||
description = Amethyst related stuff for MCL5
|
description = Amethyst related stuff for MCL5
|
||||||
depends = mcl_init, mcl_core, mcl_wip, mcl_mapgen, mcl_structures, mcl_blackstone
|
depends = mcl_init, mcl_core, mcl_wip, mcl_mapgen, mcl_structures, mcl_blackstone
|
||||||
optional_depends = mcl_spyglass, mcl_copper
|
optional_depends = mcl_spyglass, mcl_copper
|
||||||
|
|
Loading…
Reference in New Issue