2015-06-29 19:55:56 +02:00
-- To make recipes that will work with any dye ever made by anybody, define
-- them based on groups.
-- You can select any group of groups, based on your need for amount of colors.
-- basecolor: 9, excolor: 17, unicolor: 89
--
-- Example of one shapeless recipe using a color group:
-- Note: As this uses basecolor_*, you'd need 9 of these.
-- minetest.register_craft({
-- type = "shapeless",
2021-05-29 16:12:33 +02:00
-- output = "<mod>:item_yellow",
-- recipe = {"<mod>:item_no_color", "group:basecolor_yellow"},
2015-06-29 19:55:56 +02:00
-- })
2017-02-14 18:20:54 +01:00
mcl_dye = { }
2018-05-31 05:45:57 +02:00
2021-05-29 16:12:33 +02:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
local math = math
local string = string
2019-03-08 00:00:09 +01:00
2018-05-31 05:45:57 +02:00
-- Other mods can use these for looping through available colors
mcl_dye.basecolors = { " white " , " grey " , " black " , " red " , " yellow " , " green " , " cyan " , " blue " , " magenta " }
mcl_dye.excolors = { " white " , " lightgrey " , " grey " , " darkgrey " , " black " , " red " , " orange " , " yellow " , " lime " , " green " , " aqua " , " cyan " , " sky_blue " , " blue " , " violet " , " magenta " , " red_violet " }
2015-06-29 19:55:56 +02:00
-- Base color groups:
-- - basecolor_white
-- - basecolor_grey
-- - basecolor_black
-- - basecolor_red
-- - basecolor_yellow
-- - basecolor_green
-- - basecolor_cyan
-- - basecolor_blue
-- - basecolor_magenta
-- Extended color groups (* = equal to a base color):
-- * excolor_white
-- - excolor_lightgrey
-- * excolor_grey
-- - excolor_darkgrey
-- * excolor_black
-- * excolor_red
-- - excolor_orange
-- * excolor_yellow
-- - excolor_lime
-- * excolor_green
-- - excolor_aqua
-- * excolor_cyan
-- - excolor_sky_blue
-- * excolor_blue
-- - excolor_violet
-- * excolor_magenta
-- - excolor_red_violet
-- The whole unifieddyes palette as groups:
-- - unicolor_<excolor>
-- For the following, no white/grey/black is allowed:
-- - unicolor_medium_<excolor>
-- - unicolor_dark_<excolor>
-- - unicolor_light_<excolor>
-- - unicolor_<excolor>_s50
-- - unicolor_medium_<excolor>_s50
-- - unicolor_dark_<excolor>_s50
-- Local stuff
local dyelocal = { }
-- This collection of colors is partly a historic thing, partly something else.
dyelocal.dyes = {
2019-03-08 00:00:09 +01:00
{ " white " , " mcl_dye_white " , S ( " Bone Meal " ) , { dye = 1 , craftitem = 1 , basecolor_white = 1 , excolor_white = 1 , unicolor_white = 1 } } ,
{ " grey " , " dye_grey " , S ( " Light Grey Dye " ) , { dye = 1 , craftitem = 1 , basecolor_grey = 1 , excolor_grey = 1 , unicolor_grey = 1 } } ,
{ " dark_grey " , " dye_dark_grey " , S ( " Grey Dye " ) , { dye = 1 , craftitem = 1 , basecolor_grey = 1 , excolor_darkgrey = 1 , unicolor_darkgrey = 1 } } ,
{ " black " , " mcl_dye_black " , S ( " Ink Sac " ) , { dye = 1 , craftitem = 1 , basecolor_black = 1 , excolor_black = 1 , unicolor_black = 1 } } ,
{ " violet " , " dye_violet " , S ( " Purple Dye " ) , { dye = 1 , craftitem = 1 , basecolor_magenta = 1 , excolor_violet = 1 , unicolor_violet = 1 } } ,
{ " blue " , " mcl_dye_blue " , S ( " Lapis Lazuli " ) , { dye = 1 , craftitem = 1 , basecolor_blue = 1 , excolor_blue = 1 , unicolor_blue = 1 } } ,
{ " lightblue " , " mcl_dye_light_blue " , S ( " Light Blue Dye " ) , { dye = 1 , craftitem = 1 , basecolor_blue = 1 , excolor_blue = 1 , unicolor_light_blue = 1 } } ,
{ " cyan " , " dye_cyan " , S ( " Cyan Dye " ) , { dye = 1 , craftitem = 1 , basecolor_cyan = 1 , excolor_cyan = 1 , unicolor_cyan = 1 } } ,
{ " dark_green " , " dye_dark_green " , S ( " Cactus Green " ) , { dye = 1 , craftitem = 1 , basecolor_green = 1 , excolor_green = 1 , unicolor_dark_green = 1 } } ,
{ " green " , " mcl_dye_lime " , S ( " Lime Dye " ) , { dye = 1 , craftitem = 1 , basecolor_green = 1 , excolor_green = 1 , unicolor_green = 1 } } ,
{ " yellow " , " dye_yellow " , S ( " Dandelion Yellow " ) , { dye = 1 , craftitem = 1 , basecolor_yellow = 1 , excolor_yellow = 1 , unicolor_yellow = 1 } } ,
{ " brown " , " mcl_dye_brown " , S ( " Cocoa Beans " ) , { dye = 1 , craftitem = 1 , basecolor_brown = 1 , excolor_orange = 1 , unicolor_dark_orange = 1 } } ,
{ " orange " , " dye_orange " , S ( " Orange Dye " ) , { dye = 1 , craftitem = 1 , basecolor_orange = 1 , excolor_orange = 1 , unicolor_orange = 1 } } ,
{ " red " , " dye_red " , S ( " Rose Red " ) , { dye = 1 , craftitem = 1 , basecolor_red = 1 , excolor_red = 1 , unicolor_red = 1 } } ,
{ " magenta " , " dye_magenta " , S ( " Magenta Dye " ) , { dye = 1 , craftitem = 1 , basecolor_magenta = 1 , excolor_red_violet = 1 , unicolor_red_violet = 1 } } ,
{ " pink " , " dye_pink " , S ( " Pink Dye " ) , { dye = 1 , craftitem = 1 , basecolor_red = 1 , excolor_red = 1 , unicolor_light_red = 1 } } ,
2015-06-29 19:55:56 +02:00
}
2019-03-23 00:19:17 +01:00
local mg_name = minetest.get_mapgen_setting ( " mg_name " )
2018-05-31 05:45:57 +02:00
dyelocal.unicolor_to_dye_id = { }
for d = 1 , # dyelocal.dyes do
2019-02-07 07:10:10 +01:00
for k , _ in pairs ( dyelocal.dyes [ d ] [ 4 ] ) do
2018-05-31 05:45:57 +02:00
if string.sub ( k , 1 , 9 ) == " unicolor_ " then
dyelocal.unicolor_to_dye_id [ k ] = dyelocal.dyes [ d ] [ 1 ]
end
end
end
-- Takes an unicolor group name (e.g. “unicolor_white”) and returns a corresponding dye name (if it exists), nil otherwise.
2021-05-29 16:12:33 +02:00
function mcl_dye . unicolor_to_dye ( unicolor_group )
2019-03-15 00:10:07 +01:00
local color = dyelocal.unicolor_to_dye_id [ unicolor_group ]
if color then
return " mcl_dye: " .. color
else
return nil
end
2018-05-31 05:45:57 +02:00
end
2015-06-29 19:55:56 +02:00
-- Define items
for _ , row in ipairs ( dyelocal.dyes ) do
local name = row [ 1 ]
2017-02-18 16:06:18 +01:00
-- White and brown dyes are defined explicitly below
if name ~= " white " and name ~= " brown " then
2019-02-07 07:10:10 +01:00
local img = row [ 2 ]
local description = row [ 3 ]
local groups = row [ 4 ]
2017-02-18 16:06:18 +01:00
local item_name = " mcl_dye: " .. name
2019-02-07 07:10:10 +01:00
local item_image = img .. " .png "
2017-02-18 16:06:18 +01:00
minetest.register_craftitem ( item_name , {
inventory_image = item_image ,
description = description ,
2019-03-08 00:00:09 +01:00
_doc_items_longdesc = S ( " This item is a dye which is used for dyeing and crafting. " ) ,
_doc_items_usagehelp = S ( " Rightclick on a sheep to dye its wool. Other things are dyed by crafting. " ) ,
2017-02-18 16:06:18 +01:00
groups = groups ,
stack_max = 64 ,
} )
end
2015-06-29 19:55:56 +02:00
end
2017-02-11 19:03:26 +01:00
-- Bone Meal
2021-11-06 14:12:03 +01:00
function mcl_dye . add_bone_meal_particle ( pos , def )
if not def then
def = { }
end
2021-06-03 20:13:13 +02:00
minetest.add_particlespawner ( {
2021-11-06 14:12:03 +01:00
amount = def.amount or 10 ,
time = def.time or 0.1 ,
minpos = def.minpos or vector.subtract ( pos , 0.5 ) ,
maxpos = def.maxpos or vector.add ( pos , 0.5 ) ,
2021-11-12 16:41:09 +01:00
minvel = def.minvel or vector.new ( - 0.01 , 0.01 , - 0.01 ) ,
maxvel = def.maxvel or vector.new ( 0.01 , 0.01 , 0.01 ) ,
2021-11-06 14:12:03 +01:00
minacc = def.minacc or vector.new ( 0 , 0 , 0 ) ,
2021-11-08 14:16:20 +01:00
maxacc = def.maxacc or vector.new ( 0 , 0 , 0 ) ,
2021-11-06 14:12:03 +01:00
minexptime = def.minexptime or 1 ,
maxexptime = def.maxexptime or 4 ,
minsize = def.minsize or 0.7 ,
maxsize = def.maxsize or 2.4 ,
2021-06-03 20:13:13 +02:00
texture = " mcl_particles_bonemeal.png^[colorize:#00EE00:125 " , -- TODO: real MC color
2021-11-12 16:41:09 +01:00
glow = def.glow or 1 ,
2021-06-03 20:13:13 +02:00
} )
end
2017-02-11 19:03:26 +01:00
2021-11-06 14:12:03 +01:00
mcl_dye.bone_meal_callbacks = { }
function mcl_dye . register_on_bone_meal_apply ( func )
table.insert ( mcl_dye.bone_meal_callbacks , func )
end
local function apply_bone_meal ( pointed_thing )
2017-09-13 05:52:26 +02:00
-- Bone meal currently spawns all flowers found in the plains.
2019-03-23 00:19:17 +01:00
local flowers_table_plains = {
2017-02-11 19:03:26 +01:00
" mcl_flowers:dandelion " ,
2017-05-26 21:52:41 +02:00
" mcl_flowers:dandelion " ,
" mcl_flowers:poppy " ,
2017-02-11 19:03:26 +01:00
" mcl_flowers:oxeye_daisy " ,
" mcl_flowers:tulip_orange " ,
" mcl_flowers:tulip_red " ,
" mcl_flowers:tulip_white " ,
" mcl_flowers:tulip_pink " ,
" mcl_flowers:azure_bluet " ,
}
2019-03-23 00:19:17 +01:00
local flowers_table_simple = {
" mcl_flowers:dandelion " ,
" mcl_flowers:poppy " ,
}
local flowers_table_swampland = {
" mcl_flowers:blue_orchid " ,
}
local flowers_table_flower_forest = {
2017-11-14 23:52:03 +01:00
" mcl_flowers:dandelion " ,
" mcl_flowers:poppy " ,
2019-03-23 00:19:17 +01:00
" mcl_flowers:oxeye_daisy " ,
" mcl_flowers:tulip_orange " ,
" mcl_flowers:tulip_red " ,
" mcl_flowers:tulip_white " ,
" mcl_flowers:tulip_pink " ,
" mcl_flowers:azure_bluet " ,
" mcl_flowers:allium " ,
2017-11-14 23:52:03 +01:00
}
2017-02-11 19:03:26 +01:00
2017-09-13 06:12:56 +02:00
local pos = pointed_thing.under
local n = minetest.get_node ( pos )
2017-02-11 19:03:26 +01:00
if n.name == " " then return false end
2021-11-06 14:12:03 +01:00
for _ , func in pairs ( mcl_dye.bone_meal_callbacks ) do
if func ( pointed_thing , user ) then
return true
end
end
2017-04-01 02:29:36 +02:00
if minetest.get_item_group ( n.name , " sapling " ) >= 1 then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
-- Saplings: 45% chance to advance growth stage
2017-04-01 02:29:36 +02:00
if math.random ( 1 , 100 ) <= 45 then
return mcl_core.grow_sapling ( pos , n )
end
2017-08-03 18:58:35 +02:00
elseif minetest.get_item_group ( n.name , " mushroom " ) == 1 then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-08-03 18:58:35 +02:00
-- Try to grow huge mushroom
-- Must be on a dirt-type block
local below = minetest.get_node ( { x = pos.x , y = pos.y - 1 , z = pos.z } )
2017-11-14 23:44:53 +01:00
if below.name ~= " mcl_core:mycelium " and below.name ~= " mcl_core:dirt " and minetest.get_item_group ( below.name , " grass_block " ) ~= 1 and below.name ~= " mcl_core:coarse_dirt " and below.name ~= " mcl_core:podzol " then
2017-08-03 18:58:35 +02:00
return false
end
-- Select schematic
local schematic , offset , height
if n.name == " mcl_mushrooms:mushroom_brown " then
schematic = minetest.get_modpath ( " mcl_mushrooms " ) .. " /schematics/mcl_mushrooms_huge_brown.mts "
2017-09-08 22:17:03 +02:00
offset = { x = - 3 , y = - 1 , z = - 3 }
2017-08-03 18:58:35 +02:00
height = 8
elseif n.name == " mcl_mushrooms:mushroom_red " then
schematic = minetest.get_modpath ( " mcl_mushrooms " ) .. " /schematics/mcl_mushrooms_huge_red.mts "
2017-09-08 22:17:03 +02:00
offset = { x = - 2 , y = - 1 , z = - 2 }
2017-08-03 18:58:35 +02:00
height = 8
else
return false
end
-- 40% chance
2021-06-03 20:13:13 +02:00
if math.random ( 1 , 100 ) <= 40 then
2017-08-03 18:58:35 +02:00
-- Check space requirements
for i = 1 , 3 do
local cpos = vector.add ( pos , { x = 0 , y = i , z = 0 } )
if minetest.get_node ( cpos ) . name ~= " air " then
return false
end
end
local yoff = 3
local minp , maxp = { x = pos.x - 3 , y = pos.y + yoff , z = pos.z - 3 } , { x = pos.x + 3 , y = pos.y + yoff + ( height - 3 ) , z = pos.z + 3 }
local diff = vector.subtract ( maxp , minp )
diff = vector.add ( diff , { x = 1 , y = 1 , z = 1 } )
local totalnodes = diff.x * diff.y * diff.z
local goodnodes = minetest.find_nodes_in_area ( minp , maxp , { " air " , " group:leaves " } )
if # goodnodes < totalnodes then
return false
end
-- Place the huge mushroom
minetest.remove_node ( pos )
local place_pos = vector.add ( pos , offset )
local ok = minetest.place_schematic ( place_pos , schematic , 0 , nil , false )
return ok ~= nil
end
return false
2017-04-01 03:54:58 +02:00
-- Wheat, Potato, Carrot, Pumpkin Stem, Melon Stem: Advance by 2-5 stages
2021-05-29 16:12:33 +02:00
elseif string.find ( n.name , " mcl_farming:wheat_ " ) then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
local stages = math.random ( 2 , 5 )
2019-02-08 05:36:43 +01:00
return mcl_farming : grow_plant ( " plant_wheat " , pos , n , stages , true )
2021-05-29 16:12:33 +02:00
elseif string.find ( n.name , " mcl_farming:potato_ " ) then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
local stages = math.random ( 2 , 5 )
2019-02-08 05:36:43 +01:00
return mcl_farming : grow_plant ( " plant_potato " , pos , n , stages , true )
2021-05-29 16:12:33 +02:00
elseif string.find ( n.name , " mcl_farming:carrot_ " ) then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
local stages = math.random ( 2 , 5 )
2019-02-08 05:36:43 +01:00
return mcl_farming : grow_plant ( " plant_carrot " , pos , n , stages , true )
2021-05-29 16:12:33 +02:00
elseif string.find ( n.name , " mcl_farming:pumpkin_ " ) then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
local stages = math.random ( 2 , 5 )
2019-02-08 05:36:43 +01:00
return mcl_farming : grow_plant ( " plant_pumpkin_stem " , pos , n , stages , true )
2021-05-29 16:12:33 +02:00
elseif string.find ( n.name , " mcl_farming:melontige_ " ) then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
local stages = math.random ( 2 , 5 )
2019-02-08 05:36:43 +01:00
return mcl_farming : grow_plant ( " plant_melon_stem " , pos , n , stages , true )
2021-05-29 16:12:33 +02:00
elseif string.find ( n.name , " mcl_farming:beetroot_ " ) then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
-- Beetroot: 75% chance to advance to next stage
2021-05-29 16:12:33 +02:00
if math.random ( 1 , 100 ) <= 75 then
2019-02-08 05:36:43 +01:00
return mcl_farming : grow_plant ( " plant_beetroot " , pos , n , 1 , true )
2017-02-11 19:03:26 +01:00
end
2017-02-18 20:23:26 +01:00
elseif n.name == " mcl_cocoas:cocoa_1 " or n.name == " mcl_cocoas:cocoa_2 " then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
-- Cocoa: Advance by 1 stage
2017-02-18 20:23:26 +01:00
mcl_cocoas.grow ( pos )
2017-02-18 19:25:34 +01:00
return true
2017-11-14 23:44:53 +01:00
elseif minetest.get_item_group ( n.name , " grass_block " ) == 1 then
2017-04-01 03:54:58 +02:00
-- Grass Block: Generate tall grass and random flowers all over the place
2021-11-10 18:15:27 +01:00
for i = - 7 , 7 do
for j = - 7 , 7 do
for y = - 1 , 1 do
pos = vector.offset ( pointed_thing.above , i , y , j )
n = minetest.get_node ( pos )
local n2 = minetest.get_node ( vector.offset ( pos , 0 , - 1 , 0 ) )
2017-02-11 19:03:26 +01:00
2021-11-10 18:15:27 +01:00
if n.name ~= " " and n.name == " air " and ( minetest.get_item_group ( n2.name , " grass_block_no_snow " ) == 1 ) then
-- Randomly generate flowers, tall grass or nothing
if math.random ( 1 , 100 ) <= 90 / ( ( math.abs ( i ) + math.abs ( j ) ) / 2 ) then
-- 90% tall grass, 10% flower
mcl_dye.add_bone_meal_particle ( pos , { amount = 4 } )
if math.random ( 1 , 100 ) <= 90 then
local col = n2.param2
minetest.add_node ( pos , { name = " mcl_flowers:tallgrass " , param2 = col } )
2017-11-14 23:52:03 +01:00
else
2021-11-10 18:15:27 +01:00
local flowers_table
if mg_name == " v6 " then
2019-03-23 00:19:17 +01:00
flowers_table = flowers_table_plains
else
2021-11-10 18:15:27 +01:00
local biome = minetest.get_biome_name ( minetest.get_biome_data ( pos ) . biome )
if biome == " Swampland " or biome == " Swampland_shore " or biome == " Swampland_ocean " or biome == " Swampland_deep_ocean " or biome == " Swampland_underground " then
flowers_table = flowers_table_swampland
elseif biome == " FlowerForest " or biome == " FlowerForest_beach " or biome == " FlowerForest_ocean " or biome == " FlowerForest_deep_ocean " or biome == " FlowerForest_underground " then
flowers_table = flowers_table_flower_forest
elseif biome == " Plains " or biome == " Plains_beach " or biome == " Plains_ocean " or biome == " Plains_deep_ocean " or biome == " Plains_underground " or biome == " SunflowerPlains " or biome == " SunflowerPlains_ocean " or biome == " SunflowerPlains_deep_ocean " or biome == " SunflowerPlains_underground " then
flowers_table = flowers_table_plains
else
flowers_table = flowers_table_simple
end
2019-03-23 00:19:17 +01:00
end
2021-11-10 18:15:27 +01:00
minetest.add_node ( pos , { name = flowers_table [ math.random ( 1 , # flowers_table ) ] } )
2017-11-14 23:52:03 +01:00
end
2017-05-26 21:52:41 +02:00
end
2017-02-11 19:03:26 +01:00
end
end
end
end
return true
2017-03-14 19:40:49 +01:00
-- Double flowers: Drop corresponding item
elseif n.name == " mcl_flowers:rose_bush " or n.name == " mcl_flowers:rose_bush_top " then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-03-14 19:40:49 +01:00
minetest.add_item ( pos , " mcl_flowers:rose_bush " )
return true
elseif n.name == " mcl_flowers:peony " or n.name == " mcl_flowers:peony_top " then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-03-14 19:40:49 +01:00
minetest.add_item ( pos , " mcl_flowers:peony " )
return true
elseif n.name == " mcl_flowers:lilac " or n.name == " mcl_flowers:lilac_top " then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-03-14 19:40:49 +01:00
minetest.add_item ( pos , " mcl_flowers:lilac " )
return true
elseif n.name == " mcl_flowers:sunflower " or n.name == " mcl_flowers:sunflower_top " then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-03-14 19:40:49 +01:00
minetest.add_item ( pos , " mcl_flowers:sunflower " )
return true
2017-03-14 20:05:07 +01:00
elseif n.name == " mcl_flowers:tallgrass " then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
-- Tall Grass: Grow into double tallgrass
2017-03-14 19:35:37 +01:00
local toppos = { x = pos.x , y = pos.y + 1 , z = pos.z }
local topnode = minetest.get_node ( toppos )
if minetest.registered_nodes [ topnode.name ] . buildable_to then
2017-11-16 03:13:19 +01:00
minetest.set_node ( pos , { name = " mcl_flowers:double_grass " , param2 = n.param2 } )
minetest.set_node ( toppos , { name = " mcl_flowers:double_grass_top " , param2 = n.param2 } )
2017-11-14 23:44:53 +01:00
return true
end
2017-03-14 19:40:49 +01:00
2017-03-14 19:35:37 +01:00
elseif n.name == " mcl_flowers:fern " then
2021-11-06 14:12:03 +01:00
mcl_dye.add_bone_meal_particle ( pos )
2017-04-01 03:54:58 +02:00
-- Fern: Grow into large fern
2017-03-14 19:35:37 +01:00
local toppos = { x = pos.x , y = pos.y + 1 , z = pos.z }
local topnode = minetest.get_node ( toppos )
if minetest.registered_nodes [ topnode.name ] . buildable_to then
2017-11-16 03:13:19 +01:00
minetest.set_node ( pos , { name = " mcl_flowers:double_fern " , param2 = n.param2 } )
minetest.set_node ( toppos , { name = " mcl_flowers:double_fern_top " , param2 = n.param2 } )
2017-11-14 23:44:53 +01:00
return true
end
2021-07-19 10:13:52 +02:00
elseif n.name == " mcl_nether:netherrack " then
local ni = 0 -- stand for neigbour item
for x = pos.x - 1 , pos.x + 1 do
local node = minetest.get_node ( { x = x , y = pos.y , z = pos.z } )
if ni == 0 then
if node.name == " mcl_mushroom:warped_nylium " then ni = 1
elseif node.name == " mcl_mushroom:crimson_nylium " then ni = 2 end
elseif ni == 1 and node.name == " mcl_mushroom:crimson_nylium " then ni = 3
elseif ni == 2 and node.name == " mcl_mushroom:warped_nylium " then ni = 3 end
end
for z = pos.z - 1 , pos.z + 1 do
local node = minetest.get_node ( { x = pos.x , y = pos.y , z = z } )
if ni == 0 then
if node.name == " mcl_mushroom:warped_nylium " then ni = 1
elseif node.name == " mcl_mushroom:crimson_nylium " then ni = 2 end
elseif ni == 1 and node.name == " mcl_mushroom:crimson_nylium " then ni = 3
elseif ni == 2 and node.name == " mcl_mushroom:warped_nylium " then ni = 3 end
end
if ni == 3 then ni = math.random ( 1 , 2 ) end
if ni == 1 then minetest.set_node ( { x = pos.x , y = pos.y , z = pos.z } , { name = " mcl_mushroom:warped_nylium " } )
elseif ni == 2 then minetest.set_node ( { x = pos.x , y = pos.y , z = pos.z } , { name = " mcl_mushroom:crimson_nylium " } ) end
elseif n.name == " mcl_mushroom:warped_nylium " then
for x = pos.x - 2 , pos.x + 2 do
for z = pos.z - 2 , pos.z + 2 do
if minetest.get_node ( { x = x , y = pos.y + 1 , z = z } ) . name == " air " and minetest.get_node ( { x = x , y = pos.y , z = z } ) . name == " mcl_mushroom:warped_nylium " then
local randomg = math.random ( 1 , 35 )
if randomg <= 5 then
minetest.set_node ( { x = x , y = pos.y + 1 , z = z } , { name = " mcl_mushroom:warped_fungus " } )
elseif randomg > 5 and randomg <= 10 then
grow_twisting_vines ( { x = x , y = pos.y , z = z } , math.random ( 1 , 4 ) )
elseif randomg > 10 and randomg <= 20 then
minetest.set_node ( { x = x , y = pos.y + 1 , z = z } , { name = " mcl_mushroom:nether_sprouts " } )
elseif randomg > 20 and randomg <= 30 then
minetest.set_node ( { x = x , y = pos.y + 1 , z = z } , { name = " mcl_mushroom:warped_roots " } )
end
end
end
end
end
2017-03-14 19:35:37 +01:00
return false
2017-02-11 19:03:26 +01:00
end
2017-01-30 15:33:04 +01:00
minetest.register_craftitem ( " mcl_dye:white " , {
2019-02-07 07:10:10 +01:00
inventory_image = " mcl_dye_white.png " ,
2019-03-08 00:00:09 +01:00
description = S ( " Bone Meal " ) ,
2020-02-19 04:54:17 +01:00
_tt_help = S ( " Speeds up plant growth " ) ,
2019-03-08 00:00:09 +01:00
_doc_items_longdesc = S ( " Bone meal is a white dye and also useful as a fertilizer to speed up the growth of many plants. " ) ,
_doc_items_usagehelp = S ( " Rightclick a sheep to turn its wool white. Rightclick a plant to speed up its growth. Note that not all plants can be fertilized like this. When you rightclick a grass block, tall grass and flowers will grow all over the place. " ) ,
2015-06-29 19:55:56 +02:00
stack_max = 64 ,
2019-02-07 07:10:10 +01:00
groups = dyelocal.dyes [ 1 ] [ 4 ] ,
2021-05-23 00:01:53 +02:00
on_place = function ( itemstack , user , pointed_thing )
2017-03-02 16:09:13 +01:00
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node ( pointed_thing.under )
if user and not user : get_player_control ( ) . sneak then
if minetest.registered_nodes [ node.name ] and minetest.registered_nodes [ node.name ] . on_rightclick then
return minetest.registered_nodes [ node.name ] . on_rightclick ( pointed_thing.under , node , user , itemstack ) or itemstack
end
end
-- Use the bone meal on the ground
2021-11-06 14:12:03 +01:00
if ( apply_bone_meal ( pointed_thing , user ) and ( not minetest.is_creative_enabled ( user : get_player_name ( ) ) ) ) then
2017-01-05 07:23:25 +01:00
itemstack : take_item ( )
end
return itemstack
2015-06-29 19:55:56 +02:00
end ,
2018-02-01 22:45:19 +01:00
_on_dispense = function ( stack , pos , droppos , dropnode , dropdir )
-- Apply bone meal, if possible
local pointed_thing
if dropnode.name == " air " then
pointed_thing = { above = droppos , under = { x = droppos.x , y = droppos.y - 1 , z = droppos.z } }
else
pointed_thing = { above = pos , under = droppos }
end
2021-11-06 14:12:03 +01:00
local success = apply_bone_meal ( pointed_thing , nil )
2018-02-01 22:45:19 +01:00
if success then
stack : take_item ( )
end
return stack
end ,
2021-03-08 10:56:43 +01:00
_dispense_into_walkable = true
2015-06-29 19:55:56 +02:00
} )
2017-02-18 16:06:18 +01:00
minetest.register_craftitem ( " mcl_dye:brown " , {
2019-02-07 07:10:10 +01:00
inventory_image = " mcl_dye_brown.png " ,
2020-02-19 04:54:17 +01:00
_tt_help = S ( " Grows at the side of jungle trees " ) ,
2019-03-08 00:00:09 +01:00
_doc_items_longdesc = S ( " Cocoa beans are a brown dye and can be used to plant cocoas. " ) ,
_doc_items_usagehelp = S ( " Rightclick a sheep to turn its wool brown. Rightclick on the side of a jungle tree trunk (Jungle Wood) to plant a young cocoa. " ) ,
description = S ( " Cocoa Beans " ) ,
2017-02-18 16:06:18 +01:00
stack_max = 64 ,
2019-02-07 07:10:10 +01:00
groups = dyelocal.dyes [ 12 ] [ 4 ] ,
2017-03-02 15:50:53 +01:00
on_place = function ( itemstack , placer , pointed_thing )
2017-02-18 20:23:26 +01:00
return mcl_cocoas.place ( itemstack , placer , pointed_thing , " mcl_cocoas:cocoa_1 " )
2017-02-18 16:06:18 +01:00
end ,
} )
2017-01-05 07:23:25 +01:00
-- Dye mixing
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:dark_grey 2 " ,
recipe = { " mcl_dye:black " , " mcl_dye:white " } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:lightblue 2 " ,
recipe = { " mcl_dye:blue " , " mcl_dye:white " } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:grey 3 " ,
recipe = { " mcl_dye:black " , " mcl_dye:white " , " mcl_dye:white " } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:grey 2 " ,
recipe = { " mcl_dye:dark_grey " , " mcl_dye:white " } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:green 2 " ,
recipe = { " mcl_dye:dark_green " , " mcl_dye:white " } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:magenta 4 " ,
recipe = { " mcl_dye:blue " , " mcl_dye:white " , " mcl_dye:red " , " mcl_dye:red " } ,
2017-01-05 07:23:25 +01:00
} )
2017-03-15 00:51:11 +01:00
minetest.register_craft ( {
type = " shapeless " ,
output = " mcl_dye:magenta 3 " ,
recipe = { " mcl_dye:pink " , " mcl_dye:red " , " mcl_dye:blue " } ,
} )
minetest.register_craft ( {
type = " shapeless " ,
output = " mcl_dye:magenta 2 " ,
recipe = { " mcl_dye:violet " , " mcl_dye:pink " } ,
} )
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:pink 2 " ,
recipe = { " mcl_dye:red " , " mcl_dye:white " } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:cyan 2 " ,
recipe = { " mcl_dye:blue " , " mcl_dye:dark_green " } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:violet 2 " ,
recipe = { " mcl_dye:blue " , " mcl_dye:red " } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
type = " shapeless " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:orange 2 " ,
recipe = { " mcl_dye:yellow " , " mcl_dye:red " } ,
2017-01-05 07:23:25 +01:00
} )
-- Dye creation
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:yellow " ,
2017-01-31 23:32:56 +01:00
recipe = { { " mcl_flowers:dandelion " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:yellow 2 " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:sunflower " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:lightblue " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:blue_orchid " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:grey " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:azure_bluet " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:grey " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:oxeye_daisy " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:grey " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:tulip_white " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:magenta " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:allium " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:magenta 2 " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:lilac " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:orange " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:tulip_orange " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:pink " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:tulip_pink " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:pink 2 " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:peony " } } ,
2017-01-05 07:23:25 +01:00
} )
2017-03-15 00:51:11 +01:00
minetest.register_craft ( {
output = " mcl_dye:red " ,
recipe = { { " mcl_farming:beetroot_item " } } ,
} )
2017-01-05 07:23:25 +01:00
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:red " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:poppy " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:red " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:tulip_red " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:red 2 " ,
2017-01-31 12:03:18 +01:00
recipe = { { " mcl_flowers:rose_bush " } } ,
2017-01-05 07:23:25 +01:00
} )
minetest.register_craft ( {
type = " cooking " ,
2017-01-30 15:33:04 +01:00
output = " mcl_dye:dark_green " ,
2017-01-31 23:32:56 +01:00
recipe = " mcl_core:cactus " ,
2017-01-05 07:23:25 +01:00
cooktime = 10 ,
} )
minetest.register_craft ( {
2017-01-30 15:33:04 +01:00
output = " mcl_dye:white 3 " ,
2017-02-01 17:59:15 +01:00
recipe = { { " mcl_mobitems:bone " } } ,
2017-01-05 07:23:25 +01:00
} )