From de16eb3c5ad5e659eb8abc8ef7471180743e9080 Mon Sep 17 00:00:00 2001 From: kabou Date: Tue, 29 Mar 2022 12:54:51 +0200 Subject: [PATCH 1/9] Add `compostability` to node definition group. * mcl_cake/init.lua (cake); * mcl_core/craftitems.lua (apple); * mcl_core/nodes_base.lua (dirt with grass); * mcl_core/nodes_cactuscane.lua (cactus, sugarcane); * mcl_core/nodes_climb.lua (vines); * mcl_core/nodes_trees.lua (leaves, saplings); * mcl_dye/init.lua (cocoa beans); * mcl_farming/beetroot.lua (beetroot, & seeds); * mcl_farming/carrots.lua (carrot); * mcl_farming/melon.lua (melon, & slice, & seeds); * mcl_farming/potatoes.lua (potato, baked potato); * mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie); * mcl_farming/wheat.lua (wheat, cookie, bread, hay block); * mcl_flowers/init.lua (flowers, ferns, grass, & tall variants); * mcl_mushrooms/small.lua (red and brown mushrooms); * mcl_mushrooms/huge.lua (red and brown huge mushrooms); * mcl_nether/init.lua (nether wart block); * mcl_nether/nether_wart.lua (nether wart); * mcl_ocean/kelp.lua (kelp, dried &, & block); * mcl_ocean/sea_pickle.lua (sea pickle); * mcl_ocean/seagrass.lua (seagrass). --- mods/ITEMS/mcl_cake/init.lua | 11 +++++++-- mods/ITEMS/mcl_core/craftitems.lua | 2 +- mods/ITEMS/mcl_core/nodes_base.lua | 7 +++++- mods/ITEMS/mcl_core/nodes_cactuscane.lua | 10 ++++++-- mods/ITEMS/mcl_core/nodes_climb.lua | 6 ++++- mods/ITEMS/mcl_core/nodes_trees.lua | 23 ++++++++---------- mods/ITEMS/mcl_dye/init.lua | 4 +-- mods/ITEMS/mcl_farming/beetroot.lua | 4 +-- mods/ITEMS/mcl_farming/carrots.lua | 2 +- mods/ITEMS/mcl_farming/melon.lua | 9 ++++--- mods/ITEMS/mcl_farming/potatoes.lua | 4 +-- mods/ITEMS/mcl_farming/pumpkin.lua | 9 ++++--- mods/ITEMS/mcl_farming/wheat.lua | 15 +++++++----- mods/ITEMS/mcl_flowers/init.lua | 31 +++++++++++++++++++++--- mods/ITEMS/mcl_mushrooms/huge.lua | 7 +++++- mods/ITEMS/mcl_mushrooms/small.lua | 12 +++++++-- mods/ITEMS/mcl_nether/init.lua | 2 +- mods/ITEMS/mcl_nether/nether_wart.lua | 2 +- mods/ITEMS/mcl_ocean/kelp.lua | 9 ++++--- mods/ITEMS/mcl_ocean/sea_pickle.lua | 5 +++- mods/ITEMS/mcl_ocean/seagrass.lua | 2 +- 21 files changed, 122 insertions(+), 54 deletions(-) diff --git a/mods/ITEMS/mcl_cake/init.lua b/mods/ITEMS/mcl_cake/init.lua index 104071064..f3a69f413 100644 --- a/mods/ITEMS/mcl_cake/init.lua +++ b/mods/ITEMS/mcl_cake/init.lua @@ -52,7 +52,10 @@ minetest.register_node("mcl_cake:cake", { fixed = full_cake }, stack_max = 1, - groups = {handy=1, cake=7, food=2,no_eat_delay=1, attached_node=1, dig_by_piston=1, comparator_signal=14}, + groups = { + handy = 1, attached_node = 1, dig_by_piston = 1, comparator_signal = 14, + cake = 7, food = 2, no_eat_delay = 1, compostability = 100 + }, drop = "", on_rightclick = function(pos, node, clicker, itemstack) -- Cake is subject to protection @@ -125,7 +128,11 @@ local register_slice = function(level, nodebox, desc) type = "fixed", fixed = nodebox, }, - groups = {handy=1, cake=level, food=2,no_eat_delay=1,attached_node=1,not_in_creative_inventory=1,dig_by_piston=1,comparator_signal=level*2}, + groups = { + handy = 1, attached_node = 1, not_in_creative_inventory = 1, + dig_by_piston = 1, cake = level, comparator_signal = level * 2, + food = 2, no_eat_delay = 1 + }, drop = "", on_rightclick = on_rightclick, sounds = mcl_sounds.node_sound_leaves_defaults(), diff --git a/mods/ITEMS/mcl_core/craftitems.lua b/mods/ITEMS/mcl_core/craftitems.lua index 85a078766..fc84c50f5 100644 --- a/mods/ITEMS/mcl_core/craftitems.lua +++ b/mods/ITEMS/mcl_core/craftitems.lua @@ -139,7 +139,7 @@ minetest.register_craftitem("mcl_core:apple", { stack_max = 64, on_place = minetest.item_eat(4), on_secondary_use = minetest.item_eat(4), - groups = { food = 2, eatable = 4 }, + groups = { food = 2, eatable = 4, compostability = 65 }, _mcl_saturation = 2.4, }) diff --git a/mods/ITEMS/mcl_core/nodes_base.lua b/mods/ITEMS/mcl_core/nodes_base.lua index fe1ee58c2..b4edc5045 100644 --- a/mods/ITEMS/mcl_core/nodes_base.lua +++ b/mods/ITEMS/mcl_core/nodes_base.lua @@ -368,7 +368,12 @@ minetest.register_node("mcl_core:dirt_with_grass", { color = "#8EB971", is_ground_content = true, stack_max = 64, - groups = {handy=1,shovely=1,dirt=2,grass_block=1, grass_block_no_snow=1, soil=1, soil_sapling=2, soil_sugarcane=1, cultivatable=2, spreading_dirt_type=1, enderman_takable=1, building_block=1}, + groups = { + handy = 1, shovely = 1, dirt = 2, grass_block = 1, grass_block_no_snow = 1, + soil = 1, soil_sapling = 2, soil_sugarcane = 1, cultivatable = 2, + spreading_dirt_type = 1, enderman_takable = 1, building_block = 1, + compostability = 30 + }, drop = "mcl_core:dirt", sounds = mcl_sounds.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.1}, diff --git a/mods/ITEMS/mcl_core/nodes_cactuscane.lua b/mods/ITEMS/mcl_core/nodes_cactuscane.lua index 9c46c3323..62d5cc2b5 100644 --- a/mods/ITEMS/mcl_core/nodes_cactuscane.lua +++ b/mods/ITEMS/mcl_core/nodes_cactuscane.lua @@ -12,7 +12,10 @@ minetest.register_node("mcl_core:cactus", { tiles = {"mcl_core_cactus_top.png", "mcl_core_cactus_bottom.png", "mcl_core_cactus_side.png"}, is_ground_content = true, stack_max = 64, - groups = {handy=1, attached_node=1, plant=1, deco_block=1, dig_by_piston=1, enderman_takable=1}, + groups = { + handy = 1, attached_node = 1, deco_block = 1, dig_by_piston = 1, + plant = 1, enderman_takable = 1, compostability = 50 + }, sounds = mcl_sounds.node_sound_wood_defaults(), paramtype = "light", sunlight_propagates = true, @@ -79,7 +82,10 @@ minetest.register_node("mcl_core:reeds", { }, }, stack_max = 64, - 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, dig_by_piston = 1, + plant = 1, non_mycelium_plant = 1, compostability = 50 + }, sounds = mcl_sounds.node_sound_leaves_defaults(), node_placement_prediction = "", drop = "mcl_core:reeds", -- to prevent color inheritation diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index 9505bb19a..1a6780618 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -104,7 +104,11 @@ minetest.register_node("mcl_core:vine", { type = "wallmounted", }, stack_max = 64, - groups = {handy=1,axey=1,shearsy=1,swordy=1, flammable=2,deco_block=1,destroy_by_lava_flow=1,dig_by_piston=1, fire_encouragement=15, fire_flammability=100}, + 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 + }, sounds = mcl_sounds.node_sound_leaves_defaults(), drop = "", _mcl_shears_drop = true, diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index a5ef7aa97..e4903958e 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -152,17 +152,10 @@ local function register_leaves(subname, description, longdesc, tiles, sapling, d paramtype = "light", stack_max = 64, groups = { - handy=1, - hoey=1, - shearsy=1, - swordy=1, - leafdecay=leafdecay_distance, - flammable=2, - leaves=1, - deco_block=1, - dig_by_piston=1, - fire_encouragement=30, - fire_flammability=60 + handy = 1, hoey = 1, shearsy = 1, swordy = 1, dig_by_piston = 1, + leaves = 1, leafdecay = leafdecay_distance, deco_block = 1, + flammable = 2, fire_encouragement = 30, fire_flammability = 60, + compostability = 30 }, drop = get_drops(0), _mcl_shears_drop = true, @@ -194,7 +187,11 @@ local function register_sapling(subname, description, longdesc, tt_help, texture fixed = selbox }, stack_max = 64, - groups = {dig_immediate=3, plant=1,sapling=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,dig_by_piston=1,destroy_by_lava_flow=1,deco_block=1}, + groups = { + plant = 1, sapling = 1, non_mycelium_plant = 1, attached_node = 1, + deco_block = 1, dig_immediate = 3, dig_by_water = 1, dig_by_piston = 1, + destroy_by_lava_flow = 1, compostability = 30 + }, sounds = mcl_sounds.node_sound_leaves_defaults(), on_construct = function(pos) local meta = minetest.get_meta(pos) @@ -275,4 +272,4 @@ register_leaves("birchleaves", S("Birch Leaves"), S("Birch leaves are grown from -- Node aliases minetest.register_alias("default:acacia_tree", "mcl_core:acaciatree") -minetest.register_alias("default:acacia_leaves", "mcl_core:acacialeaves") \ No newline at end of file +minetest.register_alias("default:acacia_leaves", "mcl_core:acacialeaves") diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index dfb962446..727a78460 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -78,7 +78,7 @@ dyelocal.dyes = { {"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}}, + {"brown", "mcl_dye_brown", S("Cocoa Beans"), {dye=1, craftitem=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1, compostability = 65}}, {"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}}, @@ -561,5 +561,3 @@ minetest.register_craft({ output = "mcl_dye:white 3", recipe = {{"mcl_mobitems:bone"}}, }) - - diff --git a/mods/ITEMS/mcl_farming/beetroot.lua b/mods/ITEMS/mcl_farming/beetroot.lua index e312aa262..21096042b 100644 --- a/mods/ITEMS/mcl_farming/beetroot.lua +++ b/mods/ITEMS/mcl_farming/beetroot.lua @@ -5,7 +5,7 @@ minetest.register_craftitem("mcl_farming:beetroot_seeds", { _tt_help = S("Grows on farmland"), _doc_items_longdesc = S("Grows into a beetroot plant. Chickens like beetroot seeds."), _doc_items_usagehelp = S("Place the beetroot seeds on farmland (which can be created with a hoe) to plant a beetroot plant. They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it beetroot seeds."), - groups = { craftitem=1 }, + groups = {craftitem = 1, compostability = 30}, inventory_image = "mcl_farming_beetroot_seeds.png", wield_image = "mcl_farming_beetroot_seeds.png", on_place = function(itemstack, placer, pointed_thing) @@ -133,7 +133,7 @@ minetest.register_craftitem("mcl_farming:beetroot_item", { wield_image = "mcl_farming_beetroot.png", on_place = minetest.item_eat(1), on_secondary_use = minetest.item_eat(1), - groups = { food = 2, eatable = 1 }, + groups = {food = 2, eatable = 1, compostability = 65}, _mcl_saturation = 1.2, }) diff --git a/mods/ITEMS/mcl_farming/carrots.lua b/mods/ITEMS/mcl_farming/carrots.lua index 7983c58a2..1c3ebcdfa 100644 --- a/mods/ITEMS/mcl_farming/carrots.lua +++ b/mods/ITEMS/mcl_farming/carrots.lua @@ -86,7 +86,7 @@ minetest.register_craftitem("mcl_farming:carrot_item", { _doc_items_longdesc = S("Carrots can be eaten and planted. Pigs and rabbits like carrots."), _doc_items_usagehelp = S("Hold it in your hand and rightclick to eat it. Place it on top of farmland to plant the carrot. It grows in sunlight and grows faster on hydrated farmland. Rightclick an animal to feed it."), inventory_image = "farming_carrot.png", - groups = { food = 2, eatable = 3 }, + groups = {food = 2, eatable = 3, compostability = 65}, _mcl_saturation = 3.6, on_secondary_use = minetest.item_eat(3), on_place = function(itemstack, placer, pointed_thing) diff --git a/mods/ITEMS/mcl_farming/melon.lua b/mods/ITEMS/mcl_farming/melon.lua index b3e49a61f..6bbc507ec 100644 --- a/mods/ITEMS/mcl_farming/melon.lua +++ b/mods/ITEMS/mcl_farming/melon.lua @@ -7,7 +7,7 @@ minetest.register_craftitem("mcl_farming:melon_seeds", { _doc_items_longdesc = S("Grows into a melon stem which in turn grows melons. Chickens like melon seeds."), _doc_items_usagehelp = S("Place the melon seeds on farmland (which can be created with a hoe) to plant a melon stem. Melon stems grow in sunlight and grow faster on hydrated farmland. When mature, the stem will attempt to grow a melon at the side. Rightclick an animal to feed it melon seeds."), stack_max = 64, - groups = { craftitem=1 }, + groups = {craftitem = 1, compostability = 30}, inventory_image = "mcl_farming_melon_seeds.png", on_place = function(itemstack, placer, pointed_thing) return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:melontige_1") @@ -21,7 +21,10 @@ local melon_base_def = { _doc_items_longdesc = S("A melon is a block which can be grown from melon stems, which in turn are grown from melon seeds. It can be harvested for melon slices."), stack_max = 64, tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png", "farming_melon_side.png", "farming_melon_side.png", "farming_melon_side.png"}, - groups = {handy=1,axey=1, plant=1,building_block=1,enderman_takable=1,dig_by_piston=1}, + groups = { + handy = 1, axey = 1, plant = 1, building_block = 1, dig_by_piston = 1, + enderman_takable = 1, compostability = 65 + }, drop = { max_items = 1, items = { @@ -134,7 +137,7 @@ minetest.register_craftitem("mcl_farming:melon_item", { inventory_image = "farming_melon.png", on_place = minetest.item_eat(2), on_secondary_use = minetest.item_eat(2), - groups = { food = 2, eatable = 2 }, + groups = {food = 2, eatable = 2, compostability = 50}, _mcl_saturation = 1.2, }) diff --git a/mods/ITEMS/mcl_farming/potatoes.lua b/mods/ITEMS/mcl_farming/potatoes.lua index 79cd13115..04a971de8 100644 --- a/mods/ITEMS/mcl_farming/potatoes.lua +++ b/mods/ITEMS/mcl_farming/potatoes.lua @@ -91,7 +91,7 @@ minetest.register_craftitem("mcl_farming:potato_item", { _doc_items_longdesc = S("Potatoes are food items which can be eaten, cooked in the furnace and planted. Pigs like potatoes."), _doc_items_usagehelp = S("Hold it in your hand and rightclick to eat it. Place it on top of farmland to plant it. It grows in sunlight and grows faster on hydrated farmland. Rightclick an animal to feed it."), inventory_image = "farming_potato.png", - groups = { food = 2, eatable = 1 }, + groups = {food = 2, eatable = 1, compostability = 65}, _mcl_saturation = 0.6, stack_max = 64, on_secondary_use = minetest.item_eat(1), @@ -112,7 +112,7 @@ minetest.register_craftitem("mcl_farming:potato_item_baked", { inventory_image = "farming_potato_baked.png", on_place = minetest.item_eat(5), on_secondary_use = minetest.item_eat(5), - groups = { food = 2, eatable = 5 }, + groups = {food = 2, eatable = 5, compostability = 85}, _mcl_saturation = 6.0, }) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index 0eb71ac91..a38f11862 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -15,7 +15,7 @@ minetest.register_craftitem("mcl_farming:pumpkin_seeds", { _doc_items_usagehelp = S("Place the pumpkin seeds on farmland (which can be created with a hoe) to plant a pumpkin stem. Pumpkin stems grow in sunlight and grow faster on hydrated farmland. When mature, the stem attempts to grow a pumpkin next to it. Rightclick an animal to feed it pumpkin seeds."), stack_max = 64, inventory_image = "mcl_farming_pumpkin_seeds.png", - groups = { craftitem=1 }, + groups = {craftitem=1, compostability = 30}, on_place = function(itemstack, placer, pointed_thing) return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:pumpkin_1") end @@ -99,7 +99,10 @@ local pumpkin_base_def = { stack_max = 64, paramtype2 = "facedir", tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png"}, - groups = {handy=1,axey=1, plant=1,building_block=1, dig_by_piston=1, enderman_takable=1}, + groups = { + handy = 1, axey = 1, plant = 1, building_block = 1, dig_by_piston = 1, + enderman_takable = 1, compostability = 65 + }, sounds = mcl_sounds.node_sound_wood_defaults(), on_rotate = on_rotate, _mcl_blast_resistance = 1, @@ -230,7 +233,7 @@ minetest.register_craftitem("mcl_farming:pumpkin_pie", { wield_image = "mcl_farming_pumpkin_pie.png", on_place = minetest.item_eat(8), on_secondary_use = minetest.item_eat(8), - groups = { food = 2, eatable = 8 }, + groups = {food = 2, eatable = 8, compostability = 100}, _mcl_saturation = 4.8, }) diff --git a/mods/ITEMS/mcl_farming/wheat.lua b/mods/ITEMS/mcl_farming/wheat.lua index da1b84b2d..a254ed36c 100644 --- a/mods/ITEMS/mcl_farming/wheat.lua +++ b/mods/ITEMS/mcl_farming/wheat.lua @@ -9,7 +9,7 @@ minetest.register_craftitem("mcl_farming:wheat_seeds", { Place the wheat seeds on farmland (which can be created with a hoe) to plant a wheat plant. They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it wheat seeds. ]]), - groups = { craftitem=1 }, + groups = {craftitem = 1, compostability = 30}, inventory_image = "mcl_farming_wheat_seeds.png", on_place = function(itemstack, placer, pointed_thing) return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:wheat_1") @@ -104,7 +104,7 @@ minetest.register_craftitem("mcl_farming:wheat_item", { _doc_items_longdesc = S("Wheat is used in crafting. Some animals like wheat."), _doc_items_usagehelp = S("Use the “Place” key on an animal to try to feed it wheat."), inventory_image = "farming_wheat_harvested.png", - groups = { craftitem = 1 }, + groups = {craftitem = 1, compostability = 65}, }) minetest.register_craft({ @@ -125,7 +125,7 @@ minetest.register_craftitem("mcl_farming:cookie", { description = S("Cookie"), _doc_items_longdesc = S("This is a food item which can be eaten."), inventory_image = "farming_cookie.png", - groups = {food=2, eatable=2}, + groups = {food = 2, eatable = 2, compostability = 85}, _mcl_saturation = 0.4, on_place = minetest.item_eat(2), on_secondary_use = minetest.item_eat(2), @@ -136,7 +136,7 @@ minetest.register_craftitem("mcl_farming:bread", { description = S("Bread"), _doc_items_longdesc = S("This is a food item which can be eaten."), inventory_image = "farming_bread.png", - groups = {food=2, eatable=5}, + groups = {food = 2, eatable = 5, compostability = 85}, _mcl_saturation = 6.0, on_place = minetest.item_eat(5), on_secondary_use = minetest.item_eat(5), @@ -156,8 +156,11 @@ minetest.register_node("mcl_farming:hay_block", { stack_max = 64, paramtype2 = "facedir", on_place = mcl_util.rotate_axis, - groups = {handy=1, hoey=1, flammable=2, fire_encouragement=60, - fire_flammability=20, building_block=1, fall_damage_add_percent=-80}, + groups = { + handy = 1, hoey = 1, building_block = 1, fall_damage_add_percent = -80, + flammable = 2, fire_encouragement = 60, fire_flammability = 20, + compostability = 85 + }, sounds = mcl_sounds.node_sound_leaves_defaults(), on_rotate = on_rotate, _mcl_blast_resistance = 0.5, diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 14e0df5cb..d5112a36d 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -80,7 +80,13 @@ function mcl_flowers.register_simple_flower(name, def) walkable = false, stack_max = 64, drop = def.drop, - groups = {dig_immediate=3,flammable=2,fire_encouragement=60,fire_flammability=100,plant=1,flower=1,place_flowerlike=1,non_mycelium_plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1}, + groups = { + attached_node = 1, deco_block = 1, dig_by_piston = 1, dig_immediate = 3, + dig_by_water = 1, destroy_by_lava_flow = 1, enderman_takable = 1, + plant = 1, flower = 1, place_flowerlike = 1, non_mycelium_plant = 1, + flammable = 2, fire_encouragement = 60, fire_flammability = 100, + compostability = 65 + }, sounds = mcl_sounds.node_sound_leaves_defaults(), node_placement_prediction = "", on_place = on_place_flower, @@ -143,7 +149,12 @@ local def_tallgrass = { walkable = false, buildable_to = true, is_ground_content = true, - groups = {handy=1,shearsy=1, flammable=3,fire_encouragement=60,fire_flammability=100,attached_node=1,plant=1,place_flowerlike=2,non_mycelium_plant=1,dig_by_water=1,destroy_by_lava_flow=1,deco_block=1}, + groups = { + handy = 1, shearsy = 1, attached_node = 1, deco_block = 1, + plant = 1, place_flowerlike = 2, non_mycelium_plant = 1, + flammable = 3, fire_encouragement = 60, fire_flammability = 100, + dig_by_water = 1, destroy_by_lava_flow = 1, compostability = 30 + }, sounds = mcl_sounds.node_sound_leaves_defaults(), drop = wheat_seed_drop, _mcl_shears_drop = true, @@ -167,6 +178,7 @@ def_fern.selection_box = { type = "fixed", fixed = { -6/16, -0.5, -6/16, 6/16, 5/16, 6/16 }, } +def_fern.groups.compostability = 65 minetest.register_node("mcl_flowers:fern", def_fern) @@ -187,7 +199,15 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im is_flower = true end - local bottom_groups = {flammable=2, fire_encouragement=60, fire_flammability=100, non_mycelium_plant=1, attached_node=1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1, plant=1, double_plant=1, deco_block=1} + local bottom_groups = { + attached_node = 1, deco_block = 1, + dig_by_water = 1, destroy_by_lava_flow = 1, dig_by_piston = 1, + flammable = 2, fire_encouragement = 60, fire_flammability = 100, + plant = 1, double_plant = 1, non_mycelium_plant = 1, compostability = 65 + } + if name == "double_grass" then + bottom_groups.compostability = 50 + end if is_flower then bottom_groups.flower = 1 bottom_groups.place_flowerlike = 1 @@ -410,7 +430,10 @@ minetest.register_node("mcl_flowers:waterlily", { liquids_pointable = true, walkable = true, sunlight_propagates = true, - groups = {dig_immediate = 3, plant=1, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1, deco_block=1, dig_by_boat=1}, + groups = { + deco_block = 1, plant = 1, compostability = 65, destroy_by_lava_flow = 1, + dig_immediate = 3, dig_by_water = 1, dig_by_piston = 1, dig_by_boat = 1, + }, sounds = mcl_sounds.node_sound_leaves_defaults(), node_placement_prediction = "", node_box = { diff --git a/mods/ITEMS/mcl_mushrooms/huge.lua b/mods/ITEMS/mcl_mushrooms/huge.lua index 617f12810..0e99ae0be 100644 --- a/mods/ITEMS/mcl_mushrooms/huge.lua +++ b/mods/ITEMS/mcl_mushrooms/huge.lua @@ -3,7 +3,10 @@ local S = minetest.get_translator(minetest.get_current_modname()) local vector = vector local template = { - groups = {handy=1,axey=1, building_block = 1, material_wood = 1, flammable = -1 }, + groups = { + handy = 1, axey = 1, building_block = 1, material_wood = 1, + flammable = -1, compostability = 85 + }, sounds = mcl_sounds.node_sound_wood_defaults(), is_ground_content = true, _mcl_blast_resistance = 0.2, @@ -51,6 +54,7 @@ local function register_mushroom(color, species_id, template, d_cap, d_stem, d_s stem_full.tiles = { "mcl_mushrooms_mushroom_block_skin_stem.png" } stem_full.groups.huge_mushroom = species_id stem_full.groups.huge_mushroom_stem = 2 + stem_full.groups.compostability = 65 minetest.register_node("mcl_mushrooms:"..color.."_mushroom_block_stem_full", stem_full) -- Stem @@ -60,6 +64,7 @@ local function register_mushroom(color, species_id, template, d_cap, d_stem, d_s stem.tiles = { "mcl_mushrooms_mushroom_block_inside.png", "mcl_mushrooms_mushroom_block_inside.png", "mcl_mushrooms_mushroom_block_skin_stem.png" } stem.groups.huge_mushroom = species_id stem.groups.huge_mushroom_stem = 1 + stem.groups.compostability = 65 minetest.register_node("mcl_mushrooms:"..color.."_mushroom_block_stem", stem) -- Mushroom block (cap) diff --git a/mods/ITEMS/mcl_mushrooms/small.lua b/mods/ITEMS/mcl_mushrooms/small.lua index c6d7edcdc..f6fbd2909 100644 --- a/mods/ITEMS/mcl_mushrooms/small.lua +++ b/mods/ITEMS/mcl_mushrooms/small.lua @@ -38,7 +38,11 @@ minetest.register_node("mcl_mushrooms:mushroom_brown", { sunlight_propagates = true, paramtype = "light", walkable = false, - groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1}, + groups = { + attached_node = 1, deco_block = 1, destroy_by_lava_flow = 1, + dig_immediate = 3, dig_by_water = 1, dig_by_piston = 1, + mushroom = 1, enderman_takable = 1, compostability = 65 + }, sounds = mcl_sounds.node_sound_leaves_defaults(), light_source = 1, selection_box = { @@ -62,7 +66,11 @@ minetest.register_node("mcl_mushrooms:mushroom_red", { sunlight_propagates = true, paramtype = "light", walkable = false, - groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1}, + groups = { + attached_node = 1, deco_block = 1, destroy_by_lava_flow = 1, + dig_immediate = 3, dig_by_water = 1, dig_by_piston = 1, + mushroom = 1, enderman_takable = 1, compostability = 65 + }, sounds = mcl_sounds.node_sound_leaves_defaults(), selection_box = { type = "fixed", diff --git a/mods/ITEMS/mcl_nether/init.lua b/mods/ITEMS/mcl_nether/init.lua index bd983d72b..b474065a5 100644 --- a/mods/ITEMS/mcl_nether/init.lua +++ b/mods/ITEMS/mcl_nether/init.lua @@ -174,7 +174,7 @@ minetest.register_node("mcl_nether:nether_wart_block", { stack_max = 64, tiles = {"mcl_nether_nether_wart_block.png"}, is_ground_content = false, - groups = {handy=1, hoey=1, building_block=1}, + groups = {handy=1, hoey=1, building_block=1, compostability = 85}, sounds = mcl_sounds.node_sound_leaves_defaults( { footstep={name="default_dirt_footstep", gain=0.7}, diff --git a/mods/ITEMS/mcl_nether/nether_wart.lua b/mods/ITEMS/mcl_nether/nether_wart.lua index 41b23f662..f6eb0c03c 100644 --- a/mods/ITEMS/mcl_nether/nether_wart.lua +++ b/mods/ITEMS/mcl_nether/nether_wart.lua @@ -110,6 +110,7 @@ minetest.register_craftitem("mcl_nether:nether_wart_item", { _doc_items_usagehelp = S("Place this item on soul sand to plant it and watch it grow."), inventory_image = "mcl_nether_nether_wart.png", wield_image = "mcl_nether_nether_wart.png", + groups = {craftitem = 1, brewitem = 1, compostability = 30}, on_place = function(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then return itemstack @@ -143,7 +144,6 @@ minetest.register_craftitem("mcl_nether:nether_wart_item", { end end end, - groups = { craftitem = 1, brewitem=1 }, }) local names = {"mcl_nether:nether_wart_0", "mcl_nether:nether_wart_1", "mcl_nether:nether_wart_2"} diff --git a/mods/ITEMS/mcl_ocean/kelp.lua b/mods/ITEMS/mcl_ocean/kelp.lua index 422f475ac..ae273abe9 100644 --- a/mods/ITEMS/mcl_ocean/kelp.lua +++ b/mods/ITEMS/mcl_ocean/kelp.lua @@ -741,7 +741,7 @@ minetest.register_craftitem("mcl_ocean:kelp", { inventory_image = "mcl_ocean_kelp_item.png", wield_image = "mcl_ocean_kelp_item.png", on_place = kelp.kelp_on_place, - groups = { deco_block = 1 }, + groups = {deco_block = 1, compostability = 30}, }) if mod_doc then @@ -756,7 +756,7 @@ minetest.register_craftitem("mcl_ocean:dried_kelp", { _doc_items_longdesc = S("Dried kelp is a food item."), inventory_image = "mcl_ocean_dried_kelp.png", wield_image = "mcl_ocean_dried_kelp.png", - groups = { food = 2, eatable = 1 }, + groups = {food = 2, eatable = 1, compostability = 30}, on_place = minetest.item_eat(1), on_secondary_use = minetest.item_eat(1), _mcl_saturation = 0.6, @@ -773,7 +773,10 @@ minetest.register_node("mcl_ocean:dried_kelp_block", { description = S("Dried Kelp Block"), _doc_items_longdesc = S("A decorative block that serves as a great furnace fuel."), tiles = { "mcl_ocean_dried_kelp_top.png", "mcl_ocean_dried_kelp_bottom.png", "mcl_ocean_dried_kelp_side.png" }, - groups = { handy = 1, hoey = 1, building_block = 1, flammable = 2, fire_encouragement = 30, fire_flammability = 60 }, + groups = { + handy = 1, hoey = 1, building_block = 1, compostability = 50, + flammable = 2, fire_encouragement = 30, fire_flammability = 60 + }, sounds = mcl_sounds.node_sound_leaves_defaults(), paramtype2 = "facedir", on_place = mcl_util.rotate_axis, diff --git a/mods/ITEMS/mcl_ocean/sea_pickle.lua b/mods/ITEMS/mcl_ocean/sea_pickle.lua index d215fd3b3..6a4e4a751 100644 --- a/mods/ITEMS/mcl_ocean/sea_pickle.lua +++ b/mods/ITEMS/mcl_ocean/sea_pickle.lua @@ -106,7 +106,10 @@ for s=1,4 do }, inventory_image = img, wield_image = img, - groups = { dig_immediate = 3, deco_block = 1, sea_pickle=1, not_in_creative_inventory=nici }, + groups = { + dig_immediate = 3, deco_block = 1, sea_pickle = 1, + not_in_creative_inventory=nici, compostability = 65 + }, -- Light level: 6 at size 1, +3 for each additional stage light_source = math.min(6 + (s-1)*3, minetest.LIGHT_MAX), selection_box = { diff --git a/mods/ITEMS/mcl_ocean/seagrass.lua b/mods/ITEMS/mcl_ocean/seagrass.lua index 5fd382775..2f58a2812 100644 --- a/mods/ITEMS/mcl_ocean/seagrass.lua +++ b/mods/ITEMS/mcl_ocean/seagrass.lua @@ -85,7 +85,7 @@ minetest.register_craftitem("mcl_ocean:seagrass", { inventory_image = "mcl_ocean_seagrass.png^[verticalframe:12:0", wield_image = "mcl_ocean_seagrass.png^[verticalframe:12:0", on_place = seagrass_on_place, - groups = { deco_block = 1 }, + groups = {deco_block = 1, compostability = 30}, }) -- Seagrass nodes: seagrass on a surface node From 4335d0d6595695d2fd69113677071078c95dee47 Mon Sep 17 00:00:00 2001 From: kabou Date: Tue, 29 Mar 2022 16:27:31 +0200 Subject: [PATCH 2/9] Use compostability group from node definitions. * Replace use of local table with compostability values with a call to `minetest.get_item_group()`. * Define local alias for `minetest.get_item_group`. * Remove the now unused static compostabilty values table. --- mods/ITEMS/mcl_composters/init.lua | 106 +---------------------------- 1 file changed, 3 insertions(+), 103 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 18cd992dc..5d307156b 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -38,107 +38,7 @@ minetest.register_craft({ burntime = 15, }) -local compostability = { - ["mcl_cake:cake"] = 100, - ["mcl_farming:pumpkin_pie"] = 100, - - ["mcl_farming:potato_item_baked"] = 85, - ["mcl_farming:bread"] = 85, - ["mcl_farming:cookie"] = 85, - ["mcl_farming:hay_block"] = 85, - -- mushroom cap block have 64 variants, wtf!? - ["mcl_mushrooms:brown_mushroom_block_cap_111111"] = 85, - ["mcl_mushrooms:red_mushroom_block_cap_111111"] = 85, - ["mcl_nether:nether_wart_block"] = 85, - ["mcl_mushroom:warped_wart_block"] = 85, - - ["mcl_core:apple"] = 65, - -- missing: azalea - ["mcl_farming:beetroot_item"] = 65, - -- missing: big dripleaf - ["mcl_farming:carrot_item"] = 65, - -- what's up with cocoa beans? - ["mcl_dye:brown"] = 65, - ["mcl_flowers:fern"] = 65, - ["mcl_flowers:double_fern"] = 65, - ["mcl_flowers:allium"] = 65, - ["mcl_flowers:azure_bluet"] = 65, - ["mcl_flowers:blue_orchid"] = 65, - ["mcl_flowers:dandelion"] = 65, - ["mcl_flowers:lilac"] = 65, - ["mcl_flowers:oxeye_daisy"] = 65, - ["mcl_flowers:poppy"] = 65, - ["mcl_flowers:tulip_orange"] = 65, - ["mcl_flowers:tulip_pink"] = 65, - ["mcl_flowers:tulip_red"] = 65, - ["mcl_flowers:tulip_white"] = 65, - ["mcl_flowers:peony"] = 65, - ["mcl_flowers:rose_bush"] = 65, - ["mcl_flowers:sunflower"] = 65, - ["mcl_flowers:waterlily"] = 65, - ["mcl_farming:melon"] = 65, - -- missing: moss block? - -- mushroom aliases below? - ["mcl_farming:mushroom_brown"] = 65, - ["mcl_mushrooms:mushroom_brown"] = 65, - ["mcl_farming:mushroom_red"] = 65, - ["mcl_mushrooms:mushroom_red"] = 65, - ["mcl_mushrooms:brown_mushroom_block_stem_full"] = 65, - ["mcl_mushrooms:red_mushroom_block_stem_full"] = 65, - -- nether wart - ["mcl_farming:potato_item"] = 65, - ["mcl_farming:pumpkin"] = 65, - ["mcl_farming:pumpkin_face_light"] = 65, - ["mcl_ocean:sea_pickle_"] = 65, - ["mcl_mushroom:shroomlight"] = 65, - -- missing: spore blossom - ["mcl_farming:wheat_item"] = 65, - ["mcl_mushroom:crimson_fungus"] = 65, - ["mcl_mushroom:warped_fungus"] = 65, - ["mcl_mushroom:crimson_roots"] = 65, - ["mcl_mushroom:warped_roots"] = 65, - - ["mcl_core:cactus"] = 50, - ["mcl_ocean:dried_kelp_block"] = 50, - -- missing: flowering azalea leaves - -- missing: glow lichen - ["mcl_farming:melon_item"] = 50, - ["mcl_mushroom:nether_sprouts"] = 50, - ["mcl_core:reeds"] = 50, - ["mcl_flowers:double_grass"] = 50, - ["mcl_core:vine"] = 50, - -- missing: weeping vines - ["mcl_mushroom:twisting_vines"] = 50, - - ["mcl_flowers:tallgrass"] = 30, - ["mcl_farming:beetroot_seeds"] = 30, - ["mcl_core:dirt_with_grass"] = 30, - ["mcl_core:tallgrass"] = 30, - ["mcl_ocean:dried_kelp"] = 30, - ["mcl_ocean:kelp"] = 30, - ["mcl_core:leaves"] = 30, - ["mcl_core:acacialeaves"] = 30, - ["mcl_core:birchleaves"] = 30, - ["mcl_core:darkleaves"] = 30, - ["mcl_core:jungleleaves"] = 30, - ["mcl_core:spruceleaves"] = 30, - -- - ["mcl_farming:melon_seeds"] = 30, - -- missing: moss carpet - ["mcl_farming:pumpkin_seeds"] = 30, - ["mcl_core:sapling"] = 30, - ["mcl_core:acaciasapling"] = 30, - ["mcl_core:birchsapling"] = 30, - ["mcl_core:darksapling"] = 30, - ["mcl_core:junglesapling"] = 30, - ["mcl_core:sprucesapling"] = 30, - ["mcl_ocean:seagrass"] = 30, - -- missing: small dripleaf - ["mcl_sweet_berry:sweet_berry"] = 30, - ["mcl_farming:sweet_berry"] = 30, - ["mcl_farming:wheat_seeds"] = 30, - -} +local get_item_group = minetest.get_item_group local function composter_add_item(pos, node, player, itemstack, pointed_thing) -- @@ -153,8 +53,8 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing) return itemstack end local itemname = itemstack:get_name() - local chance = compostability[itemname] - if chance then + local chance = get_item_group(itemname, "compostability") + if chance > 0 then if not minetest.is_creative_enabled(player:get_player_name()) then itemstack:take_item() end From cd12e1d78cc0b8c0dbb913e55a9e2de395ceb571 Mon Sep 17 00:00:00 2001 From: kabou Date: Tue, 29 Mar 2022 16:40:51 +0200 Subject: [PATCH 3/9] Various little fixes. * Remove trailing whitespace. * Remove `use_texture_alpha` setting from node definitions, the default value is already the correct one. --- mods/ITEMS/mcl_composters/init.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 5d307156b..7e24c2f12 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -150,7 +150,6 @@ minetest.register_node("mcl_composters:composter", { "mcl_composter_bottom.png", "mcl_composter_side.png" }, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, is_ground_content = false, groups = { handy=1, material_wood=1, deco_block=1, dirtifier=1, @@ -181,7 +180,6 @@ local function register_filled_composter(level) "mcl_composter_bottom.png", "mcl_composter_side.png" }, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, is_ground_content = false, groups = { handy=1, material_wood=1, deco_block=1, dirtifier=1, @@ -217,7 +215,6 @@ end minetest.register_node("mcl_composters:composter_ready", { description = S("Composter") .. "(" .. S("ready for harvest") .. ")", _doc_items_create_entry = false, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, paramtype = "light", drawtype = "nodebox", node_box = composter_get_nodeboxes(7), @@ -244,6 +241,6 @@ minetest.register_node("mcl_composters:composter_ready", { -- Add entry aliases for the Help if minetest.get_modpath("doc") then - doc.add_entry_alias("nodes", "mcl_composters:composter", + doc.add_entry_alias("nodes", "mcl_composters:composter", "nodes", "mcl_composters:composter_ready" ) end From 541a805a48611f07665ccdc848703772523231f7 Mon Sep 17 00:00:00 2001 From: kabou Date: Tue, 29 Mar 2022 17:34:47 +0200 Subject: [PATCH 4/9] Logix fix and some simple optimizations. * Fix silly and mostly inconsequential logic bug that had gone unnoticed up till now. * Condense a single use variable away by using a slightly more elaborate assignment statement. * Add a few more local aliases for global minetest.* functions. --- mods/ITEMS/mcl_composters/init.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 7e24c2f12..f3b27787e 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -39,6 +39,11 @@ minetest.register_craft({ }) local get_item_group = minetest.get_item_group +local is_creative_enabled = minetest.is_creative_enabled +local registered_nodes = minetest.registered_nodes +local swap_node = minetest.swap_node +local get_node_timer = minetest.get_node_timer +local add_item = minetest.add_item local function composter_add_item(pos, node, player, itemstack, pointed_thing) -- @@ -49,21 +54,20 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing) if not player or (player:get_player_control() and player:get_player_control().sneak) then return itemstack end - if not itemstack and itemstack:is_empty() then + if not itemstack or itemstack:is_empty() then return itemstack end local itemname = itemstack:get_name() local chance = get_item_group(itemname, "compostability") if chance > 0 then - if not minetest.is_creative_enabled(player:get_player_name()) then + if not is_creative_enabled(player:get_player_name()) then itemstack:take_item() end -- calculate leveling up chance local rand = math.random(0,100) if chance >= rand then -- get current compost level - local node_defs = minetest.registered_nodes[node.name] - local level = node_defs["_mcl_compost_level"] + local level = registered_nodes[node.name]["_mcl_compost_level"] -- spawn green particles above new layer mcl_dye.add_bone_meal_particle(vector.add(pos, vector.new(0, level/8, 0))) -- TODO: play some sounds @@ -73,11 +77,11 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing) else level = "ready" end - minetest.swap_node(pos, {name = "mcl_composters:composter_" .. level}) + swap_node(pos, {name = "mcl_composters:composter_" .. level}) -- a full composter becomes ready for harvest after one second -- the block will get updated by the node timer callback set in node reg def if level == 7 then - local timer = minetest.get_node_timer(pos) + local timer = get_node_timer(pos) timer:start(1) end end @@ -93,7 +97,7 @@ local function composter_ready(pos) -- -- returns false in order to cancel further activity of the timer -- - minetest.swap_node(pos, {name = "mcl_composters:composter_ready"}) + swap_node(pos, {name = "mcl_composters:composter_ready"}) -- maybe spawn particles again? -- TODO: play some sounds return false @@ -107,9 +111,9 @@ local function composter_harvest(pos, node, player, itemstack, pointed_thing) return end -- reset ready type composter to empty type - minetest.swap_node(pos, {name="mcl_composters:composter"}) + swap_node(pos, {name="mcl_composters:composter"}) -- spawn bone meal item (wtf dye?! is this how they make white cocoa) - minetest.add_item(pos, "mcl_dye:white") + add_item(pos, "mcl_dye:white") -- TODO play some sounds end From 19eb31f3895f8be793adf5fcf1c71ec4c5ea8c8b Mon Sep 17 00:00:00 2001 From: kabou Date: Tue, 29 Mar 2022 20:12:36 +0200 Subject: [PATCH 5/9] Streamline use of vector ops. * Use vector.offset instead of vector.add. * Define and use local alias for vector.offset. --- mods/ITEMS/mcl_composters/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index f3b27787e..80afce259 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -44,6 +44,7 @@ local registered_nodes = minetest.registered_nodes local swap_node = minetest.swap_node local get_node_timer = minetest.get_node_timer local add_item = minetest.add_item +local vector_offset = vector.offset local function composter_add_item(pos, node, player, itemstack, pointed_thing) -- @@ -69,7 +70,7 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing) -- get current compost level local level = registered_nodes[node.name]["_mcl_compost_level"] -- spawn green particles above new layer - mcl_dye.add_bone_meal_particle(vector.add(pos, vector.new(0, level/8, 0))) + mcl_dye.add_bone_meal_particle(vector_offset(pos, 0, level/8, 0)) -- TODO: play some sounds -- update composter block if level < 7 then From bba3aabb598b9dedf60bcf815d554de560a240ee Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 30 Mar 2022 02:04:51 +0200 Subject: [PATCH 6/9] Add `compostability` to GROUPS.md --- GROUPS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/GROUPS.md b/GROUPS.md index 8ff75bbda..b2c009b47 100644 --- a/GROUPS.md +++ b/GROUPS.md @@ -72,6 +72,7 @@ Please read to learn how digging times * `coral_block=X`: Coral block (1 = alive, 2 = dead) * `coral_species=X`: Specifies the species of a coral; equal X means equal species * `set_on_fire=X`: Sets any (not fire-resistant) mob or player on fire for X seconds when touching +* `compostability=X`: Item can be used on a composter block; X (1-100) is the % chance of adding a level of compost #### Footnotes From 2ba801dfc700decfde9e7f011a7b1b11f92062de Mon Sep 17 00:00:00 2001 From: kabou Date: Sat, 2 Apr 2022 00:31:22 +0200 Subject: [PATCH 7/9] Add protection support to composter. * Add checks for `minetest.is_protected()` and log any violations. * Add local aliases for global functions. --- mods/ITEMS/mcl_composters/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 80afce259..2729ffb8e 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -45,6 +45,8 @@ local swap_node = minetest.swap_node local get_node_timer = minetest.get_node_timer local add_item = minetest.add_item local vector_offset = vector.offset +local is_protected = minetest.is_protected +local record_protection_violation = minetest.record_protection_violation local function composter_add_item(pos, node, player, itemstack, pointed_thing) -- @@ -55,6 +57,11 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing) if not player or (player:get_player_control() and player:get_player_control().sneak) then return itemstack end + local name = player:get_player_name() + if is_protected(pos, name) then + record_protection_violation(pos, name) + return itemstack + end if not itemstack or itemstack:is_empty() then return itemstack end @@ -111,6 +118,11 @@ local function composter_harvest(pos, node, player, itemstack, pointed_thing) if not player or (player:get_player_control() and player:get_player_control().sneak) then return end + local name = player:get_player_name() + if is_protected(pos, name) then + record_protection_violation(pos, name) + return itemstack + end -- reset ready type composter to empty type swap_node(pos, {name="mcl_composters:composter"}) -- spawn bone meal item (wtf dye?! is this how they make white cocoa) From f37f8b6bca87fce71f592b996acc64d639f576fc Mon Sep 17 00:00:00 2001 From: kabou Date: Sat, 2 Apr 2022 00:35:51 +0200 Subject: [PATCH 8/9] Return itemstack in `composter_harvest()`. * `composter_harvest()` is a `on_rightclick` handler and should return what remains of the ItemStack that was passed to it. --- mods/ITEMS/mcl_composters/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 2729ffb8e..53f8757bb 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -116,7 +116,7 @@ local function composter_harvest(pos, node, player, itemstack, pointed_thing) -- handler for harvesting bone meal from a ready composter when rightclicked -- if not player or (player:get_player_control() and player:get_player_control().sneak) then - return + return itemstack end local name = player:get_player_name() if is_protected(pos, name) then @@ -128,7 +128,7 @@ local function composter_harvest(pos, node, player, itemstack, pointed_thing) -- spawn bone meal item (wtf dye?! is this how they make white cocoa) add_item(pos, "mcl_dye:white") -- TODO play some sounds - + return itemstack end local function composter_get_nodeboxes(level) From f3b28df6ccf06f48f702136c4e8a6ab4f89ccbc7 Mon Sep 17 00:00:00 2001 From: kabou Date: Sat, 2 Apr 2022 00:39:36 +0200 Subject: [PATCH 9/9] Rework function comments. * Move descriptive function comments to above the function definition. * Adopt some luadoc styles. * Update a stale reference to a renamed function in comments. --- mods/ITEMS/mcl_composters/init.lua | 65 ++++++++++++++++++------------ 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 53f8757bb..56422d8b5 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -48,12 +48,18 @@ local vector_offset = vector.offset local is_protected = minetest.is_protected local record_protection_violation = minetest.record_protection_violation +--- Fill the composter when rightclicked. +-- +-- `on_rightclick` handler for composter blocks of all fill levels except +-- for the "ready" composter (see: composter_harvest). +-- If the item used on the composter block is compostable, there is a chance +-- that the level of the composter may increase, depending on the value of +-- compostability of the item. +-- +-- parameters are the standard parameters passed to `on_rightclick`. +-- returns the remaining itemstack. +-- local function composter_add_item(pos, node, player, itemstack, pointed_thing) - -- - -- handler for filling the composter when rightclicked - -- - -- as an on_rightclick handler, it returns an itemstack - -- if not player or (player:get_player_control() and player:get_player_control().sneak) then return itemstack end @@ -97,24 +103,31 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing) return itemstack end +--- Update a full composter block to ready for harvesting. +-- +-- `on_timer` handler. The timer is set in function 'composter_add_item' +-- when the composter level has reached 7. +-- +-- pos: position of the composter block. +-- returns false, thereby cancelling further activity of the timer. +-- local function composter_ready(pos) - -- - -- update the composter block to ready for harvesting - -- this function is a node callback on_timer. - -- the timer is set in function 'composter_fill' when composter level is 7 - -- - -- returns false in order to cancel further activity of the timer - -- swap_node(pos, {name = "mcl_composters:composter_ready"}) -- maybe spawn particles again? -- TODO: play some sounds return false end +--- Spawn bone meal item and reset composter block. +-- +-- `on_rightclick` handler for the "ready" composter block. Causes a +-- bone meal item to be spawned from the composter and resets the +-- composter block to an empty composter block. +-- +-- parameterss are the standard parameters passed to `on_rightclick`. +-- returns itemstack (unchanged in this function). +-- local function composter_harvest(pos, node, player, itemstack, pointed_thing) - -- - -- handler for harvesting bone meal from a ready composter when rightclicked - -- if not player or (player:get_player_control() and player:get_player_control().sneak) then return itemstack end @@ -131,10 +144,12 @@ local function composter_harvest(pos, node, player, itemstack, pointed_thing) return itemstack end +--- Construct composter nodeboxes with varying levels of compost. +-- +-- level: compost level in the composter +-- returns a nodebox definition table. +-- local function composter_get_nodeboxes(level) - -- - -- Convenience function to construct the nodeboxes for varying levels of compost - -- local top_y_tbl = {[0]=-7, -5, -3, -1, 1, 3, 5, 7} local top_y = top_y_tbl[level] / 16 return { @@ -149,9 +164,9 @@ local function composter_get_nodeboxes(level) } end +--- Register empty composter node. -- --- Register empty composter node --- This is the base model that is craftable and can be placed in an inventory +-- This is the craftable base model that can be placed in an inventory. -- minetest.register_node("mcl_composters:composter", { description = composter_description, @@ -179,9 +194,9 @@ minetest.register_node("mcl_composters:composter", { on_rightclick = composter_add_item }) +--- Template function for composters with compost. -- --- Template function for composters with compost --- For each fill level a custom node is registered +-- For each fill level a custom node is registered. -- local function register_filled_composter(level) local id = "mcl_composters:composter_"..level @@ -219,15 +234,13 @@ local function register_filled_composter(level) end end --- --- Register filled composters (7 levels) +--- Register filled composters (7 levels). -- for level = 1, 7 do register_filled_composter(level) end --- --- Register composter ready to be harvested +--- Register composter that is ready to be harvested. -- minetest.register_node("mcl_composters:composter_ready", { description = S("Composter") .. "(" .. S("ready for harvest") .. ")",