mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-26 03:07:32 +01:00
Change stuff in mcl_core
Simply put, this commit changes some code so that leaves don't use `param2` to see if they rot or not, and will now use the biome colours. This commit also makes it so vines do the same (use biome colours).
This commit is contained in:
parent
c26cddeafc
commit
198375a18e
@ -820,6 +820,30 @@ function mcl_core.get_grass_block_type(pos)
|
||||
return {name = "mcl_core:dirt_with_grass", param2 = mcl_core.get_grass_palette_index(pos)}
|
||||
end
|
||||
|
||||
function mcl_core.get_foliage_name(pos)
|
||||
local nodename = minetest.get_node(pos).name
|
||||
return nodename
|
||||
end
|
||||
|
||||
function mcl_core.get_foliage_palette_index(pos)
|
||||
local biome_data = minetest.get_biome_data(pos)
|
||||
local index = 0
|
||||
if biome_data then
|
||||
local biome = biome_data.biome
|
||||
local biome_name = minetest.get_biome_name(biome)
|
||||
local reg_biome = minetest.registered_biomes[biome_name]
|
||||
if reg_biome then
|
||||
index = reg_biome._mcl_foliage_palette_index
|
||||
end
|
||||
end
|
||||
return index
|
||||
end
|
||||
|
||||
-- Return appropriate foliage block node for pos
|
||||
function mcl_core.get_foliage_block_type(pos)
|
||||
return {name = mcl_core.get_foliage_name(pos), param2 = mcl_core.get_foliage_palette_index(pos)}
|
||||
end
|
||||
|
||||
------------------------------
|
||||
-- Spread grass blocks and mycelium on neighbor dirt
|
||||
------------------------------
|
||||
|
@ -92,11 +92,13 @@ minetest.register_node("mcl_core:vine", {
|
||||
_doc_items_longdesc = S("Vines are climbable blocks which can be placed on the sides of solid full-cube blocks. Vines slowly grow and spread."),
|
||||
drawtype = "signlike",
|
||||
tiles = {"mcl_core_vine.png"},
|
||||
color = "#48B518",
|
||||
inventory_image = "mcl_core_vine.png",
|
||||
wield_image = "mcl_core_vine.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "wallmounted",
|
||||
paramtype2 = "colorwallmounted",
|
||||
palette = "[combine:16x2:0,0=mcl_core_palette_foliage.png",
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
buildable_to = true,
|
||||
@ -107,7 +109,7 @@ minetest.register_node("mcl_core:vine", {
|
||||
groups = {
|
||||
handy = 1, axey = 1, shearsy = 1, swordy = 1, deco_block = 1,
|
||||
dig_by_piston = 1, destroy_by_lava_flow = 1, compostability = 50,
|
||||
flammable = 2, fire_encouragement = 15, fire_flammability = 100
|
||||
flammable = 2, fire_encouragement = 15, fire_flammability = 100, foliage_palette_wallmounted = 1
|
||||
},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
drop = "",
|
||||
@ -155,6 +157,25 @@ minetest.register_node("mcl_core:vine", {
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
if mg_name ~= "v6" and mg_name ~= "singlenode" then
|
||||
local node = minetest.get_node(pos)
|
||||
local biome_data = minetest.get_biome_data(pos)
|
||||
local biome = biome_data.biome
|
||||
local biome_name = minetest.get_biome_name(biome)
|
||||
local reg_biome = minetest.registered_biomes[biome_name]
|
||||
if node.name == "mcl_core:vine" then
|
||||
local biome_param2 = reg_biome._mcl_foliage_palette_index
|
||||
local rotation_param2 = node.param2
|
||||
local final_param2 = (biome_param2 * 8) + rotation_param2
|
||||
if node.param2 ~= final_param2 and rotation_param2 < 6 then
|
||||
node.param2 = final_param2
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
-- If dug, also dig a “dependant” vine below it.
|
||||
-- A vine is dependant if it hangs from this node and has no supporting block.
|
||||
on_dig = function(pos, node, digger)
|
||||
|
@ -15,11 +15,10 @@ end
|
||||
--
|
||||
-- Whenever a trunk node is removed, all `group:leaves` nodes in a sphere
|
||||
-- with radius 6 are checked. Every such node that does not have a trunk
|
||||
-- node within a distance of 6 blocks is converted into a orphan leaf node.
|
||||
-- node within a distance of 6 blocks and wasn't placed by a player is
|
||||
-- converted into a orphan leaf node.
|
||||
-- An ABM will gradually decay these nodes.
|
||||
--
|
||||
-- If param2 of the node is set to a nonzero value, the node will always
|
||||
-- be preserved. This is set automatically when leaves are placed manually.
|
||||
--
|
||||
-- @param pos the position of the removed trunk node.
|
||||
-- @param oldnode the node table of the removed trunk node.
|
||||
@ -29,20 +28,16 @@ function mcl_core.update_leaves(pos, oldnode)
|
||||
local leaves = minetest.find_nodes_in_area(pos1, pos2, "group:leaves")
|
||||
for _, lpos in pairs(leaves) do
|
||||
lnode = minetest.get_node(lpos)
|
||||
-- skip already decaying leaf nodes
|
||||
if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 then
|
||||
-- skip already decaying leaf nodes and player leaves
|
||||
if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 and minetest.get_item_group(lnode.name, "player_leaves") ~= 1 then
|
||||
if not minetest.find_node_near(lpos, 6, "group:tree") then
|
||||
-- manually placed leaf nodes have param2
|
||||
-- set and will never decay automatically
|
||||
if lnode.param2 == 0 then
|
||||
local orphan_name = lnode.name .. "_orphan"
|
||||
local def = minetest.registered_nodes[orphan_name]
|
||||
if def then
|
||||
--minetest.log("Registered: ".. orphan_name)
|
||||
minetest.swap_node(lpos, {name = orphan_name})
|
||||
else
|
||||
--minetest.log("Not registered: ".. orphan_name)
|
||||
end
|
||||
local orphan_name = lnode.name .. "_orphan"
|
||||
local def = minetest.registered_nodes[orphan_name]
|
||||
if def then
|
||||
--minetest.log("Registered: ".. orphan_name)
|
||||
minetest.set_node(lpos, {name = orphan_name})
|
||||
else
|
||||
--minetest.log("Not registered: ".. orphan_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -149,7 +144,7 @@ local function register_wooden_planks(subname, description, tiles)
|
||||
})
|
||||
end
|
||||
|
||||
local function register_leaves(subname, description, longdesc, tiles, sapling, drop_apples, sapling_chances)
|
||||
local function register_leaves(subname, description, longdesc, tiles, color, paramtype2, sapling, drop_apples, sapling_chances, foliage_palette)
|
||||
local apple_chances = {200, 180, 160, 120, 40}
|
||||
local stick_chances = {50, 45, 30, 35, 10}
|
||||
|
||||
@ -180,20 +175,22 @@ local function register_leaves(subname, description, longdesc, tiles, sapling, d
|
||||
return drop
|
||||
end
|
||||
|
||||
local l_def = {
|
||||
local pl_def = {
|
||||
description = description,
|
||||
_doc_items_longdesc = longdesc,
|
||||
_doc_items_hidden = false,
|
||||
drawtype = "allfaces_optional",
|
||||
waving = 2,
|
||||
place_param2 = 1, -- Prevent leafdecay for placed nodes
|
||||
tiles = tiles,
|
||||
color = color,
|
||||
paramtype = "light",
|
||||
paramtype2 = paramtype2,
|
||||
palette = "mcl_core_palette_foliage.png",
|
||||
stack_max = 64,
|
||||
groups = {
|
||||
handy = 1, hoey = 1, shearsy = 1, swordy = 1, dig_by_piston = 1,
|
||||
flammable = 2, fire_encouragement = 30, fire_flammability = 60,
|
||||
leaves = 1, deco_block = 1, compostability = 30
|
||||
leaves = 1, deco_block = 1, compostability = 30, foliage_palette = foliage_palette, player_leaves = 1, not_in_creative_inventory = 0,
|
||||
},
|
||||
drop = get_drops(0),
|
||||
_mcl_shears_drop = true,
|
||||
@ -202,17 +199,33 @@ local function register_leaves(subname, description, longdesc, tiles, sapling, d
|
||||
_mcl_hardness = 0.2,
|
||||
_mcl_silk_touch_drop = true,
|
||||
_mcl_fortune_drop = { get_drops(1), get_drops(2), get_drops(3), get_drops(4) },
|
||||
on_construct = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.param2 == 0 then
|
||||
local new_node = mcl_core.get_foliage_block_type(pos)
|
||||
if new_node.param2 ~= 0 then
|
||||
minetest.swap_node(pos, new_node)
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
minetest.register_node("mcl_core:player" .. subname, pl_def)
|
||||
|
||||
local l_def = table.copy(pl_def)
|
||||
l_def.groups.player_leaves = nil
|
||||
l_def.groups.not_in_creative_inventory = 1
|
||||
l_def._mcl_shears_drop = {"mcl_core:player" .. subname}
|
||||
l_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname}
|
||||
|
||||
minetest.register_node("mcl_core:" .. subname, l_def)
|
||||
|
||||
local o_def = table.copy(l_def)
|
||||
o_def._doc_items_create_entry = false
|
||||
o_def.place_param2 = nil
|
||||
o_def.groups.not_in_creative_inventory = 1
|
||||
o_def.groups.orphan_leaves = 1
|
||||
o_def._mcl_shears_drop = {"mcl_core:" .. subname}
|
||||
o_def._mcl_silk_touch_drop = {"mcl_core:" .. subname}
|
||||
o_def._mcl_shears_drop = {"mcl_core:player" .. subname}
|
||||
o_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname}
|
||||
|
||||
minetest.register_node("mcl_core:" .. subname .. "_orphan", o_def)
|
||||
end
|
||||
@ -310,12 +323,12 @@ register_sapling("birchsapling", S("Birch Sapling"),
|
||||
"mcl_core_sapling_birch.png", {-4/16, -0.5, -4/16, 4/16, 0.5, 4/16})
|
||||
|
||||
|
||||
register_leaves("leaves", S("Oak Leaves"), S("Oak leaves are grown from oak trees."), {"default_leaves.png"}, "mcl_core:sapling", true, {20, 16, 12, 10})
|
||||
register_leaves("darkleaves", S("Dark Oak Leaves"), S("Dark oak leaves are grown from dark oak trees."), {"mcl_core_leaves_big_oak.png"}, "mcl_core:darksapling", true, {20, 16, 12, 10})
|
||||
register_leaves("jungleleaves", S("Jungle Leaves"), S("Jungle leaves are grown from jungle trees."), {"default_jungleleaves.png"}, "mcl_core:junglesapling", false, {40, 26, 32, 24, 10})
|
||||
register_leaves("acacialeaves", S("Acacia Leaves"), S("Acacia leaves are grown from acacia trees."), {"default_acacia_leaves.png"}, "mcl_core:acaciasapling", false, {20, 16, 12, 10})
|
||||
register_leaves("spruceleaves", S("Spruce Leaves"), S("Spruce leaves are grown from spruce trees."), {"mcl_core_leaves_spruce.png"}, "mcl_core:sprucesapling", false, {20, 16, 12, 10})
|
||||
register_leaves("birchleaves", S("Birch Leaves"), S("Birch leaves are grown from birch trees."), {"mcl_core_leaves_birch.png"}, "mcl_core:birchsapling", false, {20, 16, 12, 10})
|
||||
register_leaves("leaves", S("Oak Leaves"), S("Oak leaves are grown from oak trees."), {"default_leaves.png"}, "#48B518", "color", "mcl_core:sapling", true, {20, 16, 12, 10}, 1)
|
||||
register_leaves("darkleaves", S("Dark Oak Leaves"), S("Dark oak leaves are grown from dark oak trees."), {"mcl_core_leaves_big_oak.png"}, "#48B518", "color", "mcl_core:darksapling", true, {20, 16, 12, 10}, 1)
|
||||
register_leaves("jungleleaves", S("Jungle Leaves"), S("Jungle leaves are grown from jungle trees."), {"default_jungleleaves.png"}, "#48B518", "color", "mcl_core:junglesapling", false, {40, 26, 32, 24, 10}, 1)
|
||||
register_leaves("acacialeaves", S("Acacia Leaves"), S("Acacia leaves are grown from acacia trees."), {"default_acacia_leaves.png"}, "#48B518", "color", "mcl_core:acaciasapling", false, {20, 16, 12, 10}, 1)
|
||||
register_leaves("spruceleaves", S("Spruce Leaves"), S("Spruce leaves are grown from spruce trees."), {"mcl_core_leaves_spruce.png"}, "#619961", "none", "mcl_core:sprucesapling", false, {20, 16, 12, 10}, 0)
|
||||
register_leaves("birchleaves", S("Birch Leaves"), S("Birch leaves are grown from birch trees."), {"mcl_core_leaves_birch.png"}, "#80A755", "none", "mcl_core:birchsapling", false, {20, 16, 12, 10}, 0)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user