0
0
Fork 0

Add peony and large plant support

This commit is contained in:
Wuzzy 2017-03-14 18:45:21 +01:00
parent e3af138f14
commit 24006e7832
4 changed files with 74 additions and 59 deletions

View File

@ -38,7 +38,6 @@ add_simple_flower("tulip_pink", "Pink Tulip", "mcl_flowers_tulip_pink", box_tuli
add_simple_flower("tulip_red", "Red Tulip", "mcl_flowers_tulip_red", box_tulip) add_simple_flower("tulip_red", "Red Tulip", "mcl_flowers_tulip_red", box_tulip)
add_simple_flower("tulip_white", "White Tulip", "mcl_flowers_tulip_white", box_tulip) add_simple_flower("tulip_white", "White Tulip", "mcl_flowers_tulip_white", box_tulip)
add_simple_flower("allium", "Allium", "mcl_flowers_allium", { -0.2, -0.5, -0.2, 0.2, 6/16, 0.2 }) add_simple_flower("allium", "Allium", "mcl_flowers_allium", { -0.2, -0.5, -0.2, 0.2, 6/16, 0.2 })
add_simple_flower("peony", "Peony", "mcl_flowers_peony", { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 })
add_simple_flower("azure_bluet", "Azure Bluet", "mcl_flowers_azure_bluet", { -3/16, -0.5, -3/16, 3/16, 2/16, 3/16 }) add_simple_flower("azure_bluet", "Azure Bluet", "mcl_flowers_azure_bluet", { -3/16, -0.5, -3/16, 3/16, 2/16, 3/16 })
add_simple_flower("blue_orchid", "Blue Orchid", "mcl_flowers_blue_orchid", { -5/16, -0.5, -5/16, 5/16, 6/16, 5/16 }) add_simple_flower("blue_orchid", "Blue Orchid", "mcl_flowers_blue_orchid", { -5/16, -0.5, -5/16, 5/16, 6/16, 5/16 })
@ -72,66 +71,83 @@ minetest.register_node("mcl_flowers:fern", {
}, },
}) })
function register_large(name, desc, inv_img, bot_img, colr) --change in function local function add_large_flower(name, desc, longdesc, inv_img, bottom_img, top_img)
minetest.register_node("mcl_flowers:"..name.."_bottom", { minetest.register_node("mcl_flowers:"..name, {
description = desc.." Bottom", description = desc,
drawtype = "plantlike", _doc_items_longdesc = longdesc,
tiles = { "double_plant_"..name.."_bottom.png" }, drawtype = "plantlike",
inventory_image = "flowers_"..inv_img..".png", tiles = { bottom_img },
wield_image = "flowers_"..inv_img..".png", inventory_image = inv_img,
sunlight_propagates = true, wield_image = inv_img,
paramtype = "light", sunlight_propagates = true,
walkable = false, paramtype = "light",
buildable_to = true, walkable = false,
--[[ node_placement_prediction = "",
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
pointed_thing.under = pointed_thing.under-1 -- We can only place on nodes
local name = minetest.get_node({x=pointed_thing.under, y=pointed_thing.under-1, z=pointed_thing.under}).name if pointed_thing.type ~= "node" then
if minetest.get_item_group(name, "soil") ~= 0 then --return
pointed_thing.under = pointed_thing.under+1 end
local height = 0 -- Check for a floor and a space of 1×2×1
while minetest.get_node(pointed_thing.under).name == "mcl_flowers:"..name.."_bottom" and height < 2 do local ptu_node = minetest.get_node(pointed_thing.under)
height = height+1 local bottom
pointed_thing.under = pointed_thing.under+1 if minetest.registered_nodes[ptu_node.name].buildable_to then
end bottom = pointed_thing.under
if height <2 then else
if minetest.get_node(pointed_thing.under).name == "air" then bottom = pointed_thing.above
minetest.set_node(pointed_thing.under, {name="mcl_flowers:"..name.."_top"}) end
end local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
end local bottom_buildable = minetest.registered_nodes[minetest.get_node(bottom).name].buildable_to
end local top_buildable = minetest.registered_nodes[minetest.get_node(top).name].buildable_to
end, local floorname = minetest.get_node({x=bottom.x, y=bottom.y-1, z=bottom.z}).name
]] if minetest.registered_nodes[floorname].walkable and bottom_buildable and top_buildable then
drop = "mcl_flowers:"..name, -- Success! We can now place the flower
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,colr=1, dig_by_water=1, double_bottom =1,deco_block=1,deco_block=1}, minetest.sound_play(minetest.registered_nodes["mcl_flowers:"..name].sounds.place, {pos = bottom, gain=1})
sounds = mcl_sounds.node_sound_leaves_defaults(), minetest.set_node(bottom, {name="mcl_flowers:"..name})
selection_box = { minetest.set_node(top, {name="mcl_flowers:"..name.."_top"})
type = "fixed", if not minetest.setting_getbool("creative_mode") then
fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 }, itemstack:take_item()
}, end
}) end
return itemstack
end,
after_destruct = function(pos, oldnode)
-- Remove top half of flower (if it exists)
local bottom = pos
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
if minetest.get_node(top).name == "mcl_flowers:"..name.."_top" then
minetest.remove_node(top)
end
end,
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1, dig_by_water=1, double_plant=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
})
-- Top -- Top
minetest.register_node("mcl_flowers:"..name.."_top", { minetest.register_node("mcl_flowers:"..name.."_top", {
description = desc.." Top", description = desc.." (Top Part)",
drawtype = "plantlike", _doc_items_create_entry = false,
tiles = { "double_plant_"..name.."_top.png" }, drawtype = "plantlike",
inventory_image = "double_plant_"..inv_img.."_top.png", tiles = { top_img },
wield_image = "double_plant_"..inv_img.."_top.png", sunlight_propagates = true,
sunlight_propagates = true, paramtype = "light",
paramtype = "light", walkable = false,
walkable = false, drop = "",
buildable_to = true, after_destruct = function(pos, oldnode)
drop = "mcl_flowers:"..name, -- "Dig" bottom half of flower (if it exists)
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,colr=1, dig_by_water=1, not_in_creative_inventory = 1, double_top =1}, local top = pos
sounds = mcl_sounds.node_sound_leaves_defaults(), local bottom = { x = top.x, y = top.y - 1, z = top.z }
selection_box = { if minetest.get_node(bottom).name == "mcl_flowers:"..name then
type = "fixed", minetest.dig_node(bottom)
fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 }, end
}, end,
}) groups = {dig_immediate=3,flammable=2,flower=1, dig_by_water=1, not_in_creative_inventory = 1, double_plant=2},
sounds = mcl_sounds.node_sound_leaves_defaults(),
})
end end
add_large_flower("peony", "Peony", nil, "mcl_flowers_double_plant_paeonia_top.png", "mcl_flowers_double_plant_paeonia_bottom.png", "mcl_flowers_double_plant_paeonia_top.png")
-- Lily Pad -- Lily Pad
minetest.register_node("mcl_flowers:waterlily", { minetest.register_node("mcl_flowers:waterlily", {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -18,7 +18,6 @@ local wip_items = {
"mcl_end:chorus_fruit", "mcl_end:chorus_fruit",
"mcl_end:chorus_flower", "mcl_end:chorus_flower",
"mcl_end:chorus_flower_dead", "mcl_end:chorus_flower_dead",
"mcl_flowers:peony",
"mcl_fishing:fishing_rod", "mcl_fishing:fishing_rod",
"mcl_fishing:pufferfish_raw", "mcl_fishing:pufferfish_raw",
"mcl_maps:filled_map", "mcl_maps:filled_map",