Fix rubber tree

This commit is contained in:
mrkubax10 2023-04-12 16:53:54 +03:00
parent f700a33a2a
commit a3bdc55b37
2 changed files with 11 additions and 43 deletions

View File

@ -14,45 +14,13 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local definition={
name="industrialtest:rubber_tree",
deco_type="schematic",
sidelen=16,
noise_params={
offset=0.024,
scale=0.015,
spread={x=250,y=250,z=250},
seed=2,
octaves=3,
persist=0.66
},
schematic={
size=vector.new(1,1,1),
data={
{
name="industrialtest:rubber_sapling",
param2=1
}
}
},
flags="place_center_x, place_center_z"
}
if industrialtest.mtgAvailable then
definition.place_on={"default:dirt_with_grass"}
definition.biomes={"deciduous_forest"}
definition.y_max=31000
definition.y_min=1
end
minetest.register_decoration(definition)
minetest.register_lbm({
label="Make rubber trees",
name="industrialtest:make_rubber_trees",
nodenames={"industrialtest:rubber_sapling"},
run_at_every_load=false,
action=function(pos)
local node=minetest.get_node(pos)
if node.param2==1 then
minetest.register_on_generated(function(minp,maxp,seed)
if industrialtest.random:next(1,100)>40 then
return
end
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,{"default:dirt_with_grass"})
if pos then
industrialtest.makeRubberTree(pos)
end
end
})
end)

View File

@ -214,9 +214,9 @@ end
industrialtest.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
minetest.chat_send_all("Making rubber sapling")
local height=industrialtest.random:next(4,5)
local tree=minetest.get_content_id("industrialtest:rubber_wood")
local treeWithRubber=minetest.get_content_id("industrialtest:rubber_wood_with_rubber")
local leaves=minetest.get_content_id("industrialtest:rubber_leaves")
local air=minetest.get_content_id("air")
local ignore=minetest.get_content_id("ignore")
@ -235,7 +235,7 @@ industrialtest.makeRubberTree=function(pos)
local index=area:index(pos.x,y,pos.z)
local id=data[index]
if id==air or id==ignore or id==leaves then
data[index]=tree
data[index]=(industrialtest.random:next(0,5)==1 and treeWithRubber or tree)
end
end
-- Force leaves near the trunk