1
0
Fork 0

Uproot plant when mycelium spreads to dirt below

This commit is contained in:
Wuzzy 2017-05-14 00:42:20 +02:00
parent 6221b060fc
commit 04478e5cd3
4 changed files with 38 additions and 33 deletions

View File

@ -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 * `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) * `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 * `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=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=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 * `soil_sapling=1`: Artificial soil (such as farmland) for saplings. Some saplings will not grow on this

View File

@ -393,30 +393,34 @@ minetest.register_abm({
local can_change = false local can_change = false
local above = {x=pos.x, y=pos.y+1, z=pos.z} local above = {x=pos.x, y=pos.y+1, z=pos.z}
local abovenode = minetest.get_node(above) local abovenode = minetest.get_node(above)
if (abovenode.name=="air") then local light_self = minetest.get_node_light(above)
can_change = true 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 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! -- Found it! Now check light levels!
local light_target = minetest.get_node_light({x=p2.x, y=p2.y+1, z=p2.z}) local source_above = {x=p2.x, y=p2.y+1, z=p2.z}
if not light_target then return end 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 if light_self >= 4 and light_source >= 9 then
-- All checks passed! Let's spread the grass/mycelium! -- All checks passed! Let's spread the grass/mycelium!
local n2 = minetest.get_node(p2) local n2 = minetest.get_node(p2)
minetest.set_node(pos, {name=n2.name}) 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 end
end end

View File

@ -706,7 +706,7 @@ minetest.register_node("mcl_core:sapling", {
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
}, },
stack_max = 64, 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(), sounds = mcl_sounds.node_sound_leaves_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(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} fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
}, },
stack_max = 64, 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(), sounds = mcl_sounds.node_sound_leaves_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(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} fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
}, },
stack_max = 64, 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(), sounds = mcl_sounds.node_sound_leaves_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -1014,7 +1014,7 @@ minetest.register_node("mcl_core:acaciasapling", {
meta:set_int("stage", 0) meta:set_int("stage", 0)
end, end,
stack_max = 64, 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(), sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0, _mcl_blast_resistance = 0,
_mcl_hardness = 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} fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
}, },
stack_max = 64, 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(), sounds = mcl_sounds.node_sound_leaves_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(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} fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
}, },
stack_max = 64, 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(), sounds = mcl_sounds.node_sound_leaves_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -1794,7 +1794,7 @@ minetest.register_node("mcl_core:deadbush", {
walkable = false, walkable = false,
stack_max = 64, stack_max = 64,
buildable_to = true, 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 = { drop = {
max_items = 1, max_items = 1,
items = { items = {

View File

@ -18,7 +18,7 @@ local function add_simple_flower(name, desc, image, simple_selection_box)
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
stack_max = 64, 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(), sounds = mcl_sounds.node_sound_leaves_defaults(),
selection_box = { selection_box = {
type = "fixed", type = "fixed",
@ -66,7 +66,7 @@ minetest.register_node("mcl_flowers:tallgrass", {
buildable_to = true, buildable_to = true,
is_ground_content = true, is_ground_content = true,
-- CHECKME: How does tall grass behave when pushed by a piston? -- 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(), sounds = mcl_sounds.node_sound_leaves_defaults(),
drop = wheat_seed_drop, drop = wheat_seed_drop,
after_dig_node = function(pos, oldnode, oldmetadata, user) after_dig_node = function(pos, oldnode, oldmetadata, user)
@ -92,7 +92,7 @@ minetest.register_node("mcl_flowers:fern", {
walkable = false, walkable = false,
stack_max = 64, stack_max = 64,
-- CHECKME: How does a fern behave when pushed by a piston? -- 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, buildable_to = true,
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
after_dig_node = function(pos, oldnode, oldmetadata, user) 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) minetest.remove_node(top)
end end
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(), 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) minetest.dig_node(bottom)
end end
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(), sounds = mcl_sounds.node_sound_leaves_defaults(),
}) })