Add sugar cane colorisation

This commit is contained in:
Lizzy Fleckenstein 2021-08-04 12:41:25 +02:00
parent 34f329a9d5
commit 970988cb39
Signed by untrusted user: LizzyFleckenstein03
GPG Key ID: 06927A5199D6C9B2
3 changed files with 20 additions and 3 deletions

View File

@ -773,8 +773,7 @@ end
local grass_spread_randomizer = PseudoRandom(minetest.get_mapgen_setting("seed")) local grass_spread_randomizer = PseudoRandom(minetest.get_mapgen_setting("seed"))
-- Return appropriate grass block node for pos function mcl_core.get_grass_palette_index(pos)
function mcl_core.get_grass_block_type(pos)
local biome_data = minetest.get_biome_data(pos) local biome_data = minetest.get_biome_data(pos)
local index = 0 local index = 0
if biome_data then if biome_data then
@ -785,7 +784,12 @@ function mcl_core.get_grass_block_type(pos)
index = reg_biome._mcl_palette_index index = reg_biome._mcl_palette_index
end end
end end
return {name="mcl_core:dirt_with_grass", param2=index} return index
end
-- Return appropriate grass block node for pos
function mcl_core.get_grass_block_type(pos)
return {name = "mcl_core:dirt_with_grass", param2 = mcl_core.get_grass_palette_index(pos)}
end end
------------------------------ ------------------------------

View File

@ -53,7 +53,10 @@ minetest.register_node("mcl_core:reeds", {
_doc_items_longdesc = S("Sugar canes are a plant which has some uses in crafting. Sugar canes will slowly grow up to 3 blocks when they are next to water and are placed on a grass block, dirt, sand, red sand, podzol or coarse dirt. When a sugar cane is broken, all sugar canes connected above will break as well."), _doc_items_longdesc = S("Sugar canes are a plant which has some uses in crafting. Sugar canes will slowly grow up to 3 blocks when they are next to water and are placed on a grass block, dirt, sand, red sand, podzol or coarse dirt. When a sugar cane is broken, all sugar canes connected above will break as well."),
_doc_items_usagehelp = S("Sugar canes can only be placed top of other sugar canes and on top of blocks on which they would grow."), _doc_items_usagehelp = S("Sugar canes can only be placed top of other sugar canes and on top of blocks on which they would grow."),
drawtype = "plantlike", drawtype = "plantlike",
paramtype2 = "color",
tiles = {"default_papyrus.png"}, tiles = {"default_papyrus.png"},
palette = "mcl_core_palette_grass.png",
palette_index = 0,
inventory_image = "mcl_core_reeds.png", inventory_image = "mcl_core_reeds.png",
wield_image = "mcl_core_reeds.png", wield_image = "mcl_core_reeds.png",
paramtype = "light", paramtype = "light",
@ -79,6 +82,7 @@ minetest.register_node("mcl_core:reeds", {
groups = {dig_immediate=3, craftitem=1, deco_block=1, plant=1, non_mycelium_plant=1, dig_by_piston=1}, groups = {dig_immediate=3, craftitem=1, deco_block=1, plant=1, non_mycelium_plant=1, dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(), sounds = mcl_sounds.node_sound_leaves_defaults(),
node_placement_prediction = "", node_placement_prediction = "",
drop = "mcl_core:reeds", -- to prevent color inheritation
on_place = mcl_util.generate_on_place_plant_function(function(place_pos, place_node) on_place = mcl_util.generate_on_place_plant_function(function(place_pos, place_node)
local soil_pos = {x=place_pos.x, y=place_pos.y-1, z=place_pos.z} local soil_pos = {x=place_pos.x, y=place_pos.y-1, z=place_pos.z}
local soil_node = minetest.get_node_or_nil(soil_pos) local soil_node = minetest.get_node_or_nil(soil_pos)
@ -114,6 +118,15 @@ minetest.register_node("mcl_core:reeds", {
return false return false
end), end),
on_construct = function(pos)
local node = minetest.get_node(pos)
if node.param2 == 0 then
node.param2 = mcl_core.get_grass_palette_index(pos)
if node.param2 ~= 0 then
minetest.set_node(pos, node)
end
end
end,
_mcl_blast_resistance = 0, _mcl_blast_resistance = 0,
_mcl_hardness = 0, _mcl_hardness = 0,
}) })

Binary file not shown.

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 1.9 KiB