forked from VoxeLibre/VoxeLibre
Uproot plant when mycelium spreads to dirt below
This commit is contained in:
parent
6221b060fc
commit
04478e5cd3
|
@ -35,6 +35,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
|||
* `cultivatable=1`: Block will be turned into Dirt by using a hoe on it
|
||||
* `flammable`: Block helps spreading fire and gets destroyed by nearby fire (rating doesn't matter)
|
||||
* `spreading_dirt_type=1`: A dirt-type block with a cover (e.g. grass) which may spread to neighbor dirt blocks
|
||||
* `non_mycelium_plant=1`: A plant which can't grow on mycelium. Placing it on mycelium fails and if mycelium spreads below it, it uproots
|
||||
* `soil=1`: Saplings and other small plants can grow on it
|
||||
* `soil_sapling=2`: Soil for saplings. Intended to be natural soil. All saplings will grow on this
|
||||
* `soil_sapling=1`: Artificial soil (such as farmland) for saplings. Some saplings will not grow on this
|
||||
|
|
|
@ -393,30 +393,34 @@ minetest.register_abm({
|
|||
local can_change = false
|
||||
local above = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||
local abovenode = minetest.get_node(above)
|
||||
if (abovenode.name=="air") then
|
||||
can_change = true
|
||||
local light_self = minetest.get_node_light(above)
|
||||
if not light_self then return end
|
||||
--[[ Try to find a spreading dirt-type block (e.g. grass block or mycelium)
|
||||
within a 3×5×3 area, with the source block being on the 2nd-topmost layer.
|
||||
First we look around the source block, if we find nothing, we look below. ]]
|
||||
local p2 = minetest.find_node_near(pos, 1, "group:spreading_dirt_type")
|
||||
if not p2 then
|
||||
p2 = minetest.find_node_near({x=pos.x,y=pos.y+2,z=pos.z}, 1, "group:spreading_dirt_type")
|
||||
-- Nothing found on 2nd attempt? Bail out!
|
||||
if not p2 then return end
|
||||
end
|
||||
if can_change then
|
||||
local light_self = minetest.get_node_light(above)
|
||||
if not light_self then return end
|
||||
--[[ Try to find a spreading dirt-type block (e.g. grass block or mycelium)
|
||||
within a 3×5×3 area, with the source block being on the 2nd-topmost layer.
|
||||
First we look around the source block, if we find nothing, we look below. ]]
|
||||
local p2 = minetest.find_node_near(pos, 1, "group:spreading_dirt_type")
|
||||
if not p2 then
|
||||
p2 = minetest.find_node_near({x=pos.x,y=pos.y+2,z=pos.z}, 1, "group:spreading_dirt_type")
|
||||
-- Nothing found on 2nd attempt? Bail out!
|
||||
if not p2 then return end
|
||||
end
|
||||
|
||||
-- Found it! Now check light levels!
|
||||
local light_target = minetest.get_node_light({x=p2.x, y=p2.y+1, z=p2.z})
|
||||
if not light_target then return end
|
||||
-- Found it! Now check light levels!
|
||||
local source_above = {x=p2.x, y=p2.y+1, z=p2.z}
|
||||
local light_source = minetest.get_node_light(source_above)
|
||||
if not light_source then return end
|
||||
|
||||
if light_self >= 9 and light_target >= 4 then
|
||||
-- All checks passed! Let's spread the grass/mycelium!
|
||||
local n2 = minetest.get_node(p2)
|
||||
minetest.set_node(pos, {name=n2.name})
|
||||
if light_self >= 4 and light_source >= 9 then
|
||||
-- All checks passed! Let's spread the grass/mycelium!
|
||||
local n2 = minetest.get_node(p2)
|
||||
minetest.set_node(pos, {name=n2.name})
|
||||
|
||||
-- If this was mycelium, uproot plant above
|
||||
if n2.name == "mcl_core:mycelium" then
|
||||
local tad = minetest.registered_nodes[minetest.get_node(above).name]
|
||||
if tad.groups and tad.groups.non_mycelium_plant then
|
||||
minetest.dig_node(above)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -706,7 +706,7 @@ minetest.register_node("mcl_core:sapling", {
|
|||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
|
||||
},
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3, sapling=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
groups = {dig_immediate=3, sapling=1,non_mycelium_plant=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -790,7 +790,7 @@ minetest.register_node("mcl_core:darksapling", {
|
|||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
|
||||
},
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3, sapling=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
groups = {dig_immediate=3, sapling=1,non_mycelium_plant=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -932,7 +932,7 @@ minetest.register_node("mcl_core:junglesapling", {
|
|||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
|
||||
},
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3, sapling=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
groups = {dig_immediate=3, sapling=1,non_mycelium_plant=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -1014,7 +1014,7 @@ minetest.register_node("mcl_core:acaciasapling", {
|
|||
meta:set_int("stage", 0)
|
||||
end,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3, sapling=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
groups = {dig_immediate=3, sapling=1,non_mycelium_plant=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
_mcl_blast_resistance = 0,
|
||||
_mcl_hardness = 0,
|
||||
|
@ -1093,7 +1093,7 @@ minetest.register_node("mcl_core:sprucesapling", {
|
|||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
|
||||
},
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3, sapling=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
groups = {dig_immediate=3, sapling=1,non_mycelium_plant=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -1171,7 +1171,7 @@ minetest.register_node("mcl_core:birchsapling", {
|
|||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
|
||||
},
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3, sapling=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
groups = {dig_immediate=3, sapling=1,non_mycelium_plant=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -1794,7 +1794,7 @@ minetest.register_node("mcl_core:deadbush", {
|
|||
walkable = false,
|
||||
stack_max = 64,
|
||||
buildable_to = true,
|
||||
groups = {dig_immediate=3, flammable=3,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
groups = {dig_immediate=3, flammable=3,attached_node=1,non_mycelium_plant=1,dig_by_water=1,deco_block=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
|
|
|
@ -18,7 +18,7 @@ local function add_simple_flower(name, desc, image, simple_selection_box)
|
|||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,dig_by_water=1,dig_by_piston=1,deco_block=1},
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,dig_by_piston=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
|
@ -66,7 +66,7 @@ minetest.register_node("mcl_flowers:tallgrass", {
|
|||
buildable_to = true,
|
||||
is_ground_content = true,
|
||||
-- CHECKME: How does tall grass behave when pushed by a piston?
|
||||
groups = {dig_immediate=3, flammable=3,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
groups = {dig_immediate=3, flammable=3,attached_node=1,non_mycelium_plant=1,dig_by_water=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
drop = wheat_seed_drop,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, user)
|
||||
|
@ -92,7 +92,7 @@ minetest.register_node("mcl_flowers:fern", {
|
|||
walkable = false,
|
||||
stack_max = 64,
|
||||
-- CHECKME: How does a fern behave when pushed by a piston?
|
||||
groups = {dig_immediate=3,flammable=2,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
groups = {dig_immediate=3,flammable=2,attached_node=1,non_mycelium_plant=1,dig_by_water=1,deco_block=1},
|
||||
buildable_to = true,
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, user)
|
||||
|
@ -170,7 +170,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im
|
|||
minetest.remove_node(top)
|
||||
end
|
||||
end,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1, dig_by_water=1,dig_by_piston=1, double_plant=1,deco_block=1},
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,non_mycelium_plant=1,attached_node=1, dig_by_water=1,dig_by_piston=1, double_plant=1,deco_block=1},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
|
@ -193,7 +193,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im
|
|||
minetest.dig_node(bottom)
|
||||
end
|
||||
end,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1, dig_by_water=1,dig_by_piston=1, not_in_creative_inventory = 1, double_plant=2},
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,non_mycelium_plant=1,dig_by_water=1,dig_by_piston=1, not_in_creative_inventory = 1, double_plant=2},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue