AMethyst Growing

This commit is contained in:
1F616EMO 2021-07-28 20:44:30 +08:00
parent 9122fe40c6
commit c4808b3b1c
Signed by untrusted user: Emojigit
GPG Key ID: 2443E5F619026B90
2 changed files with 102 additions and 1 deletions

View File

@ -0,0 +1,47 @@
function mcl_amethyst.grow_amethyst_bud(pos,ignore_budding_amethyst)
local node = minetest.get_node(pos)
if not node.name then return false end
local def = minetest.registered_nodes[node.name]
if not def then return false end
if not def.groups and def.groups.amethyst_buds then return false end
local next_gen = def._mcl_amethyst_next_grade
if not next_gen then return false end
-- Check Budding Amethyst
if not ignore_budding_amethyst then
local dir = minetest.wallmounted_to_dir(node.param2)
local ba_pos = vector.add(pos,dir)
local ba_node = minetest.get_node(ba_pos)
if ba_node.name ~= "mcl_amethyst:budding_amethyst_block" then return false end
end
local swap_result = table.copy(node)
swap_result.name = next_gen
minetest.swap_node(pos,swap_result)
return true
end
local function get_growing_tool_handle(ignore)
return function(itemstack, user, pointed_thing)
if not user:is_player() then return end
local name = user:get_player_name()
local pos = minetest.get_pointed_thing_position(pointed_thing)
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
minetest.chat_send_player(name,"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,"Growing Failed")
end
end
end
minetest.register_tool("mcl_amethyst:growing_tool",{
description = "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")

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator(minetest.get_current_modname())
mcl_amethyst = {}
-- Amethyst block
minetest.register_node("mcl_amethyst:amethyst_block",{
@ -90,11 +91,13 @@ local bud_def = {
}
for x,y in pairs(bud_def) do
minetest.register_node("mcl_amethyst:" .. y[1] .. "_amethyst_bud",{
description = y[2] .. "Amethyst Bud",
description = y[2] .. " Amethyst Bud",
_mcl_hardness = 1.5,
_mcl_blast_resistance = 1.5,
drop = "",
tiles = {y[1] .. "_amethyst_bud.png",},
inventory_image = y[1] .. "_amethyst_bud.png",
paramtype1 = "light",
paramtype2 = "wallmounted",
drawtype = "plantlike",
use_texture_alpha = "clip",
@ -105,6 +108,8 @@ for x,y in pairs(bud_def) do
dig_by_piston = 1,
pickaxey = 1,
deco_block = 1,
amethyst_buds = 1,
attached_node = 1,
},
selection_box = {
type = "fixed",
@ -118,9 +123,55 @@ for x,y in pairs(bud_def) do
},
_mcl_silk_touch_drop = true,
_mcl_amethyst_next_grade = y[3],
_doc_items_longdesc = S(y[2] .. " Amethyst Bud is the " .. y[1] .. " grouth of amethyst bud."),
})
end
minetest.register_node("mcl_amethyst:amethyst_cluster",{
description = "Amethyst Cluster",
_mcl_hardness = 1.5,
_mcl_blast_resistance = 1.5,
_doc_items_longdesc = S("Amethyst Cluster is the final grouth of amethyst bud."),
drop = {
max_items = 1,
items = {
{
tools = {"~mcl_tools:pick_"},
items = {"mcl_amethyst:amethyst_shard 4"},
},
{
items = {"mcl_amethyst:amethyst_shard 2"},
},
}
},
tiles = {"amethyst_cluster.png",},
inventory_image = "amethyst_cluster.png",
paramtype2 = "wallmounted",
drawtype = "plantlike",
paramtype1 = "light",
use_texture_alpha = "clip",
sunlight_propagates = true,
groups = {
dig_by_water = 1,
destroy_by_lava_flow = 1,
dig_by_piston = 1,
pickaxey = 1,
deco_block = 1,
attached_node = 1,
},
selection_box = {
type = "fixed",
-- fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
},
collision_box = {
type = "fixed",
-- fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
},
_mcl_silk_touch_drop = true,
})
-- Register Crafts
minetest.register_craft({
output = "mcl_amethyst:amethyst_block",
@ -157,3 +208,6 @@ if minetest.get_modpath("mcl_spyglass") then
craft_spyglass("mcl_core:iron_ingot")
end
end
-- Amethyst Growing
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/grow.lua")