Fix Rubber Sapling not growing in MCL

This commit is contained in:
mrkubax10 2024-03-06 19:21:36 +01:00
parent 8a29704f5f
commit 62a3e2aa40
3 changed files with 67 additions and 30 deletions

View File

@ -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 pos=minetest.find_node_near(center,maxp.x-minp.x,{industrialtest.elementKeys.grassBlock})
if pos then
industrialtest.makeRubberTree(pos)
industrialtest.internal.makeRubberTree(pos)
end
end)

View File

@ -1,5 +1,5 @@
name=industrialtest
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
title=IndustrialTest

View File

@ -239,7 +239,7 @@ if not industrialtest.mods.mclRubber then
definition._mcl_silk_touch_drop={"industrialtest:rubber_leaves"}
minetest.register_node("industrialtest:rubber_leaves_orphan",definition)
end
industrialtest.makeRubberTree=function(pos)
industrialtest.internal.makeRubberTree=function(pos)
-- FIXME: Replace this with placing schematic
-- Taken and adapted from https://github.com/minetest/minetest_game/blob/master/mods/default/trees.lua#L182
local height=industrialtest.random:next(4,5)
@ -308,32 +308,7 @@ if not industrialtest.mods.mclRubber then
paramtype="light",
sunlight_propagates=true,
walkable=false,
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
waving=1
}
if industrialtest.mtgAvailable then
definition.sounds=default.node_sound_leaves_defaults()
@ -344,6 +319,16 @@ if not industrialtest.mods.mclRubber then
definition.on_construct=function(pos)
minetest.get_node_timer(pos):start(industrialtest.random:next(300,1500))
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
definition.sounds=mcl_sounds.node_sound_leaves_defaults()
definition.groups={
@ -359,6 +344,58 @@ if not industrialtest.mods.mclRubber then
local meta=minetest.get_meta(pos)
meta:set_int("stage",0)
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
definition.groups.attached_node=1
definition.groups.dig_immediate=3