Fix Rubber Sapling not growing in MCL
This commit is contained in:
parent
8a29704f5f
commit
62a3e2aa40
|
@ -21,6 +21,6 @@ minetest.register_on_generated(function(minp,maxp,seed)
|
||||||
local center=vector.new((maxp.x-minp.x)/2+ minp.x,(maxp.y-minp.y)/2+minp.y,(maxp.z-minp.z)/2+minp.z)
|
local center=vector.new((maxp.x-minp.x)/2+ minp.x,(maxp.y-minp.y)/2+minp.y,(maxp.z-minp.z)/2+minp.z)
|
||||||
local pos=minetest.find_node_near(center,maxp.x-minp.x,{industrialtest.elementKeys.grassBlock})
|
local pos=minetest.find_node_near(center,maxp.x-minp.x,{industrialtest.elementKeys.grassBlock})
|
||||||
if pos then
|
if pos then
|
||||||
industrialtest.makeRubberTree(pos)
|
industrialtest.internal.makeRubberTree(pos)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
2
mod.conf
2
mod.conf
|
@ -1,5 +1,5 @@
|
||||||
name=industrialtest
|
name=industrialtest
|
||||||
description=Adds various machinery
|
description=Adds various machinery
|
||||||
optional_depends=default,bucket,3d_armor,mcl_core,mcl_copper,mcl_armor,mcl_deepslate,mcl_nether,mcl_buckets,pipeworks
|
optional_depends=default,bucket,3d_armor,mcl_core,mcl_copper,mcl_armor,mcl_deepslate,mcl_nether,mcl_buckets,mcl_util,mcl_dye,mcl_rubber,pipeworks
|
||||||
author=IndustrialTest Team
|
author=IndustrialTest Team
|
||||||
title=IndustrialTest
|
title=IndustrialTest
|
91
nodes.lua
91
nodes.lua
|
@ -239,7 +239,7 @@ if not industrialtest.mods.mclRubber then
|
||||||
definition._mcl_silk_touch_drop={"industrialtest:rubber_leaves"}
|
definition._mcl_silk_touch_drop={"industrialtest:rubber_leaves"}
|
||||||
minetest.register_node("industrialtest:rubber_leaves_orphan",definition)
|
minetest.register_node("industrialtest:rubber_leaves_orphan",definition)
|
||||||
end
|
end
|
||||||
industrialtest.makeRubberTree=function(pos)
|
industrialtest.internal.makeRubberTree=function(pos)
|
||||||
-- FIXME: Replace this with placing schematic
|
-- FIXME: Replace this with placing schematic
|
||||||
-- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182
|
-- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182
|
||||||
local height=industrialtest.random:next(4,5)
|
local height=industrialtest.random:next(4,5)
|
||||||
|
@ -308,32 +308,7 @@ if not industrialtest.mods.mclRubber then
|
||||||
paramtype="light",
|
paramtype="light",
|
||||||
sunlight_propagates=true,
|
sunlight_propagates=true,
|
||||||
walkable=false,
|
walkable=false,
|
||||||
waving=1,
|
waving=1
|
||||||
on_timer=function(pos)
|
|
||||||
-- Use MTG can_grow function if available
|
|
||||||
local canGrow
|
|
||||||
if industrialtest.mtgAvailable then
|
|
||||||
canGrow=default.can_grow
|
|
||||||
elseif industrialtest.mclAvailable then
|
|
||||||
canGrow=function(pos)
|
|
||||||
local under=minetest.get_node_or_nil(vector.offset(pos,0,-1,0))
|
|
||||||
if not under then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
local lightLevel=minetest.get_node_light(pos)
|
|
||||||
return (minetest.get_item_group(under.name,"soil")>0 and lightLevel and lightLevel>=13)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not canGrow(pos) then
|
|
||||||
minetest.get_node_timer(pos):start(300)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
industrialtest.makeRubberTree(pos)
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
if industrialtest.mtgAvailable then
|
if industrialtest.mtgAvailable then
|
||||||
definition.sounds=default.node_sound_leaves_defaults()
|
definition.sounds=default.node_sound_leaves_defaults()
|
||||||
|
@ -344,6 +319,16 @@ if not industrialtest.mods.mclRubber then
|
||||||
definition.on_construct=function(pos)
|
definition.on_construct=function(pos)
|
||||||
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
|
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
|
||||||
end
|
end
|
||||||
|
definition.on_timer=function(pos)
|
||||||
|
if not default.can_grow(pos) then
|
||||||
|
minetest.get_node_timer(pos):start(300)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
industrialtest.internal.makeRubberTree(pos)
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
elseif industrialtest.mclAvailable then
|
elseif industrialtest.mclAvailable then
|
||||||
definition.sounds=mcl_sounds.node_sound_leaves_defaults()
|
definition.sounds=mcl_sounds.node_sound_leaves_defaults()
|
||||||
definition.groups={
|
definition.groups={
|
||||||
|
@ -359,6 +344,58 @@ if not industrialtest.mods.mclRubber then
|
||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
meta:set_int("stage",0)
|
meta:set_int("stage",0)
|
||||||
end
|
end
|
||||||
|
definition.on_place=mcl_util.generate_on_place_plant_function(function(pos,node)
|
||||||
|
local nodeBelow = minetest.get_node_or_nil(vector.new(pos.x,pos.y-1,pos.z))
|
||||||
|
if not nodeBelow then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local name = nodeBelow.name
|
||||||
|
return minetest.get_item_group(name,"grass_block")==1 or
|
||||||
|
name=="mcl_core:podzol" or name=="mcl_core:podzol_snow" or
|
||||||
|
name=="mcl_core:dirt" or name=="mcl_core:mycelium" or name=="mcl_core:coarse_dirt"
|
||||||
|
end)
|
||||||
|
minetest.register_abm({
|
||||||
|
label="Rubber sapling growing",
|
||||||
|
nodenames={"industrialtest:rubber_sapling"},
|
||||||
|
interval=120,
|
||||||
|
chance=1,
|
||||||
|
catch_up=false,
|
||||||
|
action=function(pos)
|
||||||
|
local under=minetest.get_node_or_nil(vector.offset(pos,0,-1,0))
|
||||||
|
if not under or minetest.get_item_group(under.name,"soil")==0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local lightLevel=minetest.get_node_light(pos)
|
||||||
|
if not lightLevel or lightLevel<13 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local meta=minetest.get_meta(pos)
|
||||||
|
local stage=meta:get_int("stage") or 0
|
||||||
|
stage=stage+1
|
||||||
|
if stage>=3 then
|
||||||
|
industrialtest.internal.makeRubberTree(pos)
|
||||||
|
else
|
||||||
|
meta:set_int("stage",stage)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
mcl_dye.register_on_bone_meal_apply(function(pointed)
|
||||||
|
local node=minetest.get_node(pointed.under)
|
||||||
|
if node.name~="industrialtest:rubber_sapling" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if industrialtest.random:next(1,100)>45 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local meta=minetest.get_meta(pointed.under)
|
||||||
|
local stage=meta:get_int("stage") or 0
|
||||||
|
stage=stage+1
|
||||||
|
if stage>=3 then
|
||||||
|
industrialtest.internal.makeRubberTree(pointed.under)
|
||||||
|
else
|
||||||
|
meta:set_int("stage",stage)
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
definition.groups.attached_node=1
|
definition.groups.attached_node=1
|
||||||
definition.groups.dig_immediate=3
|
definition.groups.dig_immediate=3
|
||||||
|
|
Loading…
Reference in New Issue