From df8576e77cf8e00b59d2ac1839565471340c75e2 Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 16 Feb 2022 23:11:39 +0100 Subject: [PATCH 01/15] mcl_composters initial commit Implements a composter block with crafting recipe, and some more uncraftable blocks representing various stages of filling. Adds a list of items that can be used with the composter and the chances of these items adding a layer to the composter. Implements methods to add compostable items to the composter, to update the composter to various levels of compost and to harvest an item of bone meal when the composter is ready. Textures were taken from XSSheep/Nova_Wostra Pixel Perfection texture pack. --- mods/ITEMS/mcl_composters/init.lua | 339 ++++++++++++++++++ mods/ITEMS/mcl_composters/locale/template.txt | 7 + mods/ITEMS/mcl_composters/mod.conf | 5 + .../textures/mcl_composter_bottom.png | Bin 0 -> 395 bytes .../textures/mcl_composter_compost.png | Bin 0 -> 409 bytes .../textures/mcl_composter_ready.png | Bin 0 -> 582 bytes .../textures/mcl_composter_side.png | Bin 0 -> 267 bytes .../textures/mcl_composter_top.png | Bin 0 -> 397 bytes 8 files changed, 351 insertions(+) create mode 100644 mods/ITEMS/mcl_composters/init.lua create mode 100644 mods/ITEMS/mcl_composters/locale/template.txt create mode 100644 mods/ITEMS/mcl_composters/mod.conf create mode 100644 mods/ITEMS/mcl_composters/textures/mcl_composter_bottom.png create mode 100644 mods/ITEMS/mcl_composters/textures/mcl_composter_compost.png create mode 100644 mods/ITEMS/mcl_composters/textures/mcl_composter_ready.png create mode 100644 mods/ITEMS/mcl_composters/textures/mcl_composter_side.png create mode 100644 mods/ITEMS/mcl_composters/textures/mcl_composter_top.png diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua new file mode 100644 index 000000000..d77fd4e31 --- /dev/null +++ b/mods/ITEMS/mcl_composters/init.lua @@ -0,0 +1,339 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +-- +-- Composter mod, adds composters. +-- +-- Copyleft 2022 by kabou +-- GNU General Public Licence 3.0 +-- + +local composter_description = S( + "Composter" +) +local composter_longdesc = S( + "Composters can convert various organic items into bonemeal." +) +local composter_usagehelp = S( + "Use organic items on the composter to fill it with layers of compost. " .. + "Every time an item is put in the composter, there is a chance that the " .. + "composter adds another layer of compost. Some items have a bigger chance " .. + "of adding an extra layer than other items. After filling up with 7 layers " .. + "of compost, the composter is full and bone meal can be retrieved from it. " .. + "Taking out the bone meal empties the composter." +) + +minetest.register_craft({ + output = "mcl_composters:composter", + recipe = { + {"group:wood_slab", "", "group:wood_slab"}, + {"group:wood_slab", "", "group:wood_slab"}, + {"group:wood_slab", "group:wood_slab", "group:wood_slab"}, + } +}) + +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, + -- missing: melon block? + -- 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:spruceapling"] = 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 function composter_add_item(pos, node, player, itemstack, pointed_thing) + -- + -- handle filling the composter when rightclicked + -- as an on_rightclick handles, it returns an itemstack + -- + if not player or player:get_player_control().sneak then + return itemstack + end + if not itemstack and itemstack:is_empty() then + return itemstack + end + local itemname = itemstack:get_name() + local chance = compostability[itemname] + if chance then + if not minetest.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["_compost_level"] + -- spawn green particles above new layer + mcl_dye.add_bone_meal_particle(vector.add(pos, {x=0, y=level/8, z=0})) + -- TODO: play some sounds + -- update composter block + if level < 7 then + level = level + 1 + else + level = "ready" + end + minetest.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) + timer:start(1) + end + end + end + return itemstack +end + +local function composter_ready(pos) + -- + -- update the composter block to ready for harvesting + -- this function is a 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 + -- + minetest.swap_node(pos, {name = "mcl_composters:composter_ready"}) + -- maybe spawn particles again? + -- TODO: play some sounds + return false +end + +local function composter_harvest(pos, node, player, itemstack, pointed_thing) + -- + -- handle harvesting bone meal from a ready composter when rightclicked + -- + if not player or player:get_player_control().sneak then + return + end + -- reset composter to empty + minetest.swap_node(pos, {name="mcl_composters:composter"}) + -- spawn bone meal item (wtf dye?! is this how the make white cocoa) + minetest.add_item(pos, "mcl_dye:white") + -- TODO play some sounds + +end + +local function composter_get_nodeboxes(level) + -- + -- Convenience function because the composter nodeboxes are very similar + -- + local top_y_tbl = {[0]=-7, -5, -3, -1, 1, 3, 5, 7} + local top_y = top_y_tbl[level] / 16 + return { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, -0.375, 0.5, 0.5}, -- Left wall + { 0.375, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Right wall + {-0.375, -0.5, 0.375, 0.375, 0.5, 0.5}, -- Back wall + {-0.375, -0.5, -0.5, 0.375, 0.5, -0.375}, -- Front wall + {-0.5, -0.5, -0.5, 0.5, top_y, 0.5}, -- Bottom level + } + } +end + +local composter_wieldimg = minetest.inventorycube("mcl_composter_top.png", "mcl_composter_side.png", "mcl_composter_side.png") +-- +-- Register empty composter +-- This is the base model that is craftable and can be placed in an inventory +-- +minetest.register_node("mcl_composters:composter", { + description = composter_description, + _tt_help = S("Converts organic items into bonemeal"), + _doc_items_longdesc = composter_longdesc, + _doc_items_usagehelp = composter_usagehelp, + -- FIXME: mcl_composter_side.png is fugly. maybe somehow use minetest.inventorycube(img1, img2, img3) + -- eeeww, that is also ugly and weird + inventory_image = composter_wieldimg, + --inventory_image = "mcl_composter_side.png", + paramtype = "light", + drawtype = "nodebox", + node_box = composter_get_nodeboxes(0), + selection_box = {type = "regular"}, + tiles = { + "mcl_composter_bottom.png^mcl_composter_top.png", + "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, + flammable=2, fire_encouragement=3, fire_flammability=4, + }, + sounds = mcl_sounds.node_sound_wood_defaults(), + _mcl_hardness = 2, + _mcl_blast_resistance = 2, + _compost_level = 0, + on_rightclick = composter_add_item +}) + +-- +-- Template function for composters with compost +-- For each fill level a custom node is registered +-- +local function register_filled_composter(level) + local id = "mcl_composters:composter_"..level + minetest.register_node(id, { + description = S("Composter") .. " (" .. level .. "/7 " .. S("filled") .. ")", + _doc_items_create_entry = false, + paramtype = "light", + drawtype = "nodebox", + node_box = composter_get_nodeboxes(level), + selection_box = {type = "regular"}, + tiles = { + "mcl_composter_compost.png^mcl_composter_top.png", + "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, + not_in_creative_inventory=1, not_in_craft_guide=1, + flammable=2, fire_encouragement=3, fire_flammability=4, + comparator_signal=level + }, + sounds = mcl_sounds.node_sound_wood_defaults(), + drop = "mcl_composters:composter", + _mcl_hardness = 2, + _mcl_blast_resistance = 2, + _compost_level = level, + on_rightclick = composter_add_item, + on_timer = composter_ready + }) + + -- Add entry aliases for the Help + if minetest.get_modpath("doc") then + doc.add_entry_alias("nodes", "mcl_composters:composter", "nodes", id) + end +end + +-- +-- Register filled composters (7 levels) +-- +for level = 1, 7 do + register_filled_composter(level) +end + +-- +-- Register composter ready to be harvested +-- +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), + selection_box = {type = "regular"}, + tiles = { + "mcl_composter_ready.png^mcl_composter_top.png", + "mcl_composter_bottom.png", + "mcl_composter_side.png" + }, + is_ground_content = false, + groups = { + handy=1, material_wood=1, deco_block=1, dirtifier=1, + not_in_creative_inventory=1, not_in_craft_guide=1, + flammable=2, fire_encouragement=3, fire_flammability=4, + comparator_signal=8 + }, + sounds = mcl_sounds.node_sound_wood_defaults(), + drop = "mcl_composters:composter", + _mcl_hardness = 2, + _mcl_blast_resistance = 2, + _compost_level = 7, + on_rightclick = composter_harvest +}) diff --git a/mods/ITEMS/mcl_composters/locale/template.txt b/mods/ITEMS/mcl_composters/locale/template.txt new file mode 100644 index 000000000..b882113c4 --- /dev/null +++ b/mods/ITEMS/mcl_composters/locale/template.txt @@ -0,0 +1,7 @@ +# textdomain: mcl_composters +Composter= +Composters can convert various organic items into bonemeal.= +Use organic items on the composter to fill it with layers of compost. Every time an item is put in the composter, there is a chance that the composter adds another layer of compost. Some items have a bigger chance of adding an extra layer than other items. After filling up with 7 layers of compost, the composter is full and bone meal can be retrieved from it. Taking out the bone meal empties the composter.= +filled= +ready for harvest= +Converts organic items into bonemeal= diff --git a/mods/ITEMS/mcl_composters/mod.conf b/mods/ITEMS/mcl_composters/mod.conf new file mode 100644 index 000000000..6ae5ff3e6 --- /dev/null +++ b/mods/ITEMS/mcl_composters/mod.conf @@ -0,0 +1,5 @@ +name = mcl_composters +author = kabou +description = composters +depends = mcl_core, mcl_sounds +optional_depends = doc diff --git a/mods/ITEMS/mcl_composters/textures/mcl_composter_bottom.png b/mods/ITEMS/mcl_composters/textures/mcl_composter_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..dc075789938b54b1f26881e9a101b71a6abc7fb0 GIT binary patch literal 395 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP-J2SJWoN?~e7zPGL2~QWt5R22T!H#~14Fu*ytaH5- z6;qM&|6>0a)j1P)6lMx4FfI~rX$s(2_t@j*!k(KJc{97;eyu9AS*?3*_0xv<8?B5C zCii7k{Ejj@Fgtv{+`M|NNs7+h+g`^vuQd_T?^(aGy0ZCy&GD~iYi*?CAAfu(y1m@r zVBfK_&peM`d#rE^^6tIH%5dQL^$@*-GP@1jnWF#Ns(1zWbm*m7i9M8N2r%(zI;rVl zrk{Q>#C39v`GP|C;%^K4udYau|Ft7Ow!=+p+p||iYg$781uwnS@VafYONgc71hrFH zJM$)#Tw#4#ux{3urKJx`#9y##U*7SiJVpG8>gu_NmvFC4(K31}-+5&TUR?6wdj_z*z{nlW&kTOT=zEFP4JS92ZL=aMmxt+E_o_=A_br2;IJptq zi){ki3qllxI5YT!(Yf%TI?f?tv_y4@5CxFd4MG$Qegb$dR{30Y`BJIbn!y8J!pI#) z!Z}0$+$CYO#P-jR$>mf-6jOt4UhwrjR%t50nPr)hSVTcn>~2ye7B)75h~O?5q6jHuF`@y9g~X%` zff!e?u&_}?qPC)y;wp&lPa#2Uf8QhbjTB~mbcpI9B zPhX<7=5h5k%9Zq6830;Am~5$9tEW7qlnNnu(P-k>20;kljp)xwYaCl9=ly@xFRV?e Ue>i!}+5i9m07*qoM6N<$g7W$OLjV8( literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_composters/textures/mcl_composter_side.png b/mods/ITEMS/mcl_composters/textures/mcl_composter_side.png new file mode 100644 index 0000000000000000000000000000000000000000..e70c05858a23413c1572b95eb0eb79d0d78660f3 GIT binary patch literal 267 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFv4DbnYm6sN`*41#gG|mrktBCSw zP4<~t9y7TzWo>`ng60e$iqEN!1uAAt@^*J&=wOxg0CG4BJR*x37`TN&n2}-D90{Nx zdx@v7EBj-1W@bK4$&T5KK%oLp7sn8e>%M0K1rHgBxLiES*vxFQCxGS2QOE6U5^=IA z?ChOQLfc#R-+ON?zIW@zU)vu~IJWS7!_0K=n-5ywEqPpb^i5Iot4*uh4rttIYEd=T z&bFF8L5%Z#?xf@QBa-G_pWGRKcd2@l_Q|yhv;9+Fvd25A$_hPg+y=Cp!PC{xWt~$( F698xdT!;Vw literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_composters/textures/mcl_composter_top.png b/mods/ITEMS/mcl_composters/textures/mcl_composter_top.png new file mode 100644 index 0000000000000000000000000000000000000000..6fb9df7ee2f70e60bf6362ba509a8d3fd78342a3 GIT binary patch literal 397 zcmV;80doF{P)wOosYT3qKEF!)@g^6S zcfzx4D|xtok*n)Racw2HH&5c)O8Cx9q!t!U=m7xlpL4kcbNtfn3;6QyAyGJ)6gpYh zNWwP&U}%sAlT)zRX|af=8k!Wk5p~#`v+IY*MkTv`i2Ek=(MZGAoS#jVkmWyBCJlsc zJX(k Date: Thu, 17 Feb 2022 13:22:54 +0100 Subject: [PATCH 02/15] Fix composter item image. * Less is more (thanks AFCMS) --- mods/ITEMS/mcl_composters/init.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index d77fd4e31..1fec4cf4a 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -223,7 +223,6 @@ local function composter_get_nodeboxes(level) } end -local composter_wieldimg = minetest.inventorycube("mcl_composter_top.png", "mcl_composter_side.png", "mcl_composter_side.png") -- -- Register empty composter -- This is the base model that is craftable and can be placed in an inventory @@ -233,10 +232,6 @@ minetest.register_node("mcl_composters:composter", { _tt_help = S("Converts organic items into bonemeal"), _doc_items_longdesc = composter_longdesc, _doc_items_usagehelp = composter_usagehelp, - -- FIXME: mcl_composter_side.png is fugly. maybe somehow use minetest.inventorycube(img1, img2, img3) - -- eeeww, that is also ugly and weird - inventory_image = composter_wieldimg, - --inventory_image = "mcl_composter_side.png", paramtype = "light", drawtype = "nodebox", node_box = composter_get_nodeboxes(0), From 64203c38a6dbac6433fe5160c0d2e0ae1ef61c95 Mon Sep 17 00:00:00 2001 From: kabou Date: Thu, 17 Feb 2022 13:37:58 +0100 Subject: [PATCH 03/15] Update documentation. * Make a mention of the one second delay before composter readies. --- mods/ITEMS/mcl_composters/init.lua | 5 +++-- mods/ITEMS/mcl_composters/locale/template.txt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 1fec4cf4a..0bb0dc969 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -18,8 +18,9 @@ local composter_usagehelp = S( "Every time an item is put in the composter, there is a chance that the " .. "composter adds another layer of compost. Some items have a bigger chance " .. "of adding an extra layer than other items. After filling up with 7 layers " .. - "of compost, the composter is full and bone meal can be retrieved from it. " .. - "Taking out the bone meal empties the composter." + "of compost, the composter is full. After a delay of approximately one " .. + "second the composter becomes ready and bone meal can be retrieved from it. " .. + "Right-clicking the composter takes out the bone meal empties the composter." ) minetest.register_craft({ diff --git a/mods/ITEMS/mcl_composters/locale/template.txt b/mods/ITEMS/mcl_composters/locale/template.txt index b882113c4..c5f9bb858 100644 --- a/mods/ITEMS/mcl_composters/locale/template.txt +++ b/mods/ITEMS/mcl_composters/locale/template.txt @@ -1,7 +1,7 @@ # textdomain: mcl_composters Composter= Composters can convert various organic items into bonemeal.= -Use organic items on the composter to fill it with layers of compost. Every time an item is put in the composter, there is a chance that the composter adds another layer of compost. Some items have a bigger chance of adding an extra layer than other items. After filling up with 7 layers of compost, the composter is full and bone meal can be retrieved from it. Taking out the bone meal empties the composter.= +Use organic items on the composter to fill it with layers of compost. Every time an item is put in the composter, there is a chance that the composter adds another layer of compost. Some items have a bigger chance of adding an extra layer than other items. After filling up with 7 layers of compost, the composter is full. After a delay of approximately one second the composter becomes ready and bone meal can be retrieved from it. Right-clicking the composter takes out the bone meal empties the composter."= filled= ready for harvest= Converts organic items into bonemeal= From 1f7697b6f5a36b63d88ae552141de0fc0e0298d2 Mon Sep 17 00:00:00 2001 From: kabou Date: Thu, 17 Feb 2022 13:53:28 +0100 Subject: [PATCH 04/15] Typo fix. * it's a spruceSapling (thanks NO11) --- mods/ITEMS/mcl_composters/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 0bb0dc969..819869876 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -125,7 +125,7 @@ local compostability = { ["mcl_core:birchsapling"] = 30, ["mcl_core:darksapling"] = 30, ["mcl_core:junglesapling"] = 30, - ["mcl_core:spruceapling"] = 30, + ["mcl_core:sprucesapling"] = 30, ["mcl_ocean:seagrass"] = 30, -- missing: small dripleaf ["mcl_sweet_berry:sweet_berry"] = 30, From 8d79d1653174e02568a2980958341a62f8cd4baf Mon Sep 17 00:00:00 2001 From: kabou Date: Thu, 17 Feb 2022 14:05:02 +0100 Subject: [PATCH 05/15] Update mod deps. * Add dpendency on mcl_dye for the bone meal particle spawner --- mods/ITEMS/mcl_composters/mod.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_composters/mod.conf b/mods/ITEMS/mcl_composters/mod.conf index 6ae5ff3e6..845a0d325 100644 --- a/mods/ITEMS/mcl_composters/mod.conf +++ b/mods/ITEMS/mcl_composters/mod.conf @@ -1,5 +1,5 @@ name = mcl_composters author = kabou description = composters -depends = mcl_core, mcl_sounds +depends = mcl_core, mcl_sounds, mcl_dye optional_depends = doc From 06274518bf467130ba5351faf51ef5cabf2ac363 Mon Sep 17 00:00:00 2001 From: kabou Date: Thu, 17 Feb 2022 14:23:50 +0100 Subject: [PATCH 06/15] Add player object check. * Handle the case where a mob somehow "clicks" on a composter and we get an invalid player object passed. --- mods/ITEMS/mcl_composters/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 819869876..e36d66641 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -139,7 +139,7 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing) -- handle filling the composter when rightclicked -- as an on_rightclick handles, it returns an itemstack -- - if not player or player:get_player_control().sneak then + 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 From 3257014e007a91cf0ed7fb413a290188260e8e05 Mon Sep 17 00:00:00 2001 From: kabou Date: Thu, 17 Feb 2022 14:37:37 +0100 Subject: [PATCH 07/15] Add missing melon block. * Add melon block to the compostabiles list. --- mods/ITEMS/mcl_composters/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index e36d66641..1accfe493 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -70,7 +70,7 @@ local compostability = { ["mcl_flowers:rose_bush"] = 65, ["mcl_flowers:sunflower"] = 65, ["mcl_flowers:waterlily"] = 65, - -- missing: melon block? + ["mcl_farming:melon"] = 65, -- missing: moss block? -- mushroom aliases below? ["mcl_farming:mushroom_brown"] = 65, From 64608f50f843ca9799b960cb3a73dcafe358bb26 Mon Sep 17 00:00:00 2001 From: kabou Date: Thu, 17 Feb 2022 15:37:37 +0100 Subject: [PATCH 08/15] Update mod description and fix comment. * Make mod description more descriptive. * Minor comment tweak. --- mods/ITEMS/mcl_composters/init.lua | 2 +- mods/ITEMS/mcl_composters/mod.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 1accfe493..7d2a05823 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -136,7 +136,7 @@ local compostability = { local function composter_add_item(pos, node, player, itemstack, pointed_thing) -- - -- handle filling the composter when rightclicked + -- handles filling the composter when rightclicked -- as an on_rightclick handles, it returns an itemstack -- if not player or (player:get_player_control() and player:get_player_control().sneak) then diff --git a/mods/ITEMS/mcl_composters/mod.conf b/mods/ITEMS/mcl_composters/mod.conf index 845a0d325..86d729887 100644 --- a/mods/ITEMS/mcl_composters/mod.conf +++ b/mods/ITEMS/mcl_composters/mod.conf @@ -1,5 +1,5 @@ name = mcl_composters author = kabou -description = composters +description = Composters can convert various organic items into bonemeal. depends = mcl_core, mcl_sounds, mcl_dye optional_depends = doc From cea821b2fa8bdfc14dbad8d2cda152f473ef8431 Mon Sep 17 00:00:00 2001 From: kabou Date: Thu, 17 Feb 2022 21:38:24 +0100 Subject: [PATCH 09/15] Comment fixes. * Improve comments, some typo fixes. --- mods/ITEMS/mcl_composters/init.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 7d2a05823..8a900a155 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -136,8 +136,9 @@ local compostability = { local function composter_add_item(pos, node, player, itemstack, pointed_thing) -- - -- handles filling the composter when rightclicked - -- as an on_rightclick handles, it returns an itemstack + -- 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 @@ -181,8 +182,9 @@ end local function composter_ready(pos) -- -- update the composter block to ready for harvesting - -- this function is a callback on_timer. + -- 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 -- minetest.swap_node(pos, {name = "mcl_composters:composter_ready"}) @@ -193,14 +195,14 @@ end local function composter_harvest(pos, node, player, itemstack, pointed_thing) -- - -- handle harvesting bone meal from a ready composter when rightclicked + -- handler for harvesting bone meal from a ready composter when rightclicked -- if not player or player:get_player_control().sneak then return end - -- reset composter to empty + -- reset ready type composter to empty type minetest.swap_node(pos, {name="mcl_composters:composter"}) - -- spawn bone meal item (wtf dye?! is this how the make white cocoa) + -- spawn bone meal item (wtf dye?! is this how they make white cocoa) minetest.add_item(pos, "mcl_dye:white") -- TODO play some sounds @@ -208,7 +210,7 @@ end local function composter_get_nodeboxes(level) -- - -- Convenience function because the composter nodeboxes are very similar + -- 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 @@ -225,7 +227,7 @@ local function composter_get_nodeboxes(level) end -- --- Register empty composter +-- Register empty composter node -- This is the base model that is craftable and can be placed in an inventory -- minetest.register_node("mcl_composters:composter", { From ffc2c9409618e19a59f299497fb29e966841e1cf Mon Sep 17 00:00:00 2001 From: kabou Date: Thu, 17 Feb 2022 21:52:11 +0100 Subject: [PATCH 10/15] Add help alias * Add help alias for the ready type composter --- mods/ITEMS/mcl_composters/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 8a900a155..2c95bc71e 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -335,3 +335,9 @@ minetest.register_node("mcl_composters:composter_ready", { _compost_level = 7, on_rightclick = composter_harvest }) + +-- Add entry aliases for the Help +if minetest.get_modpath("doc") then + doc.add_entry_alias("nodes", "mcl_composters:composter", + "nodes", "mcl_composters:composter_ready" ) +end From f22baafaa6aea035e899d035df826c4e07310416 Mon Sep 17 00:00:00 2001 From: kabou Date: Fri, 18 Feb 2022 16:51:25 +0100 Subject: [PATCH 11/15] Add player object check. * Add one more check if player object is an actual player. --- mods/ITEMS/mcl_composters/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 2c95bc71e..5684c2c2b 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -197,7 +197,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().sneak then + if not player or (player:get_player_control() and player:get_player_control().sneak) then return end -- reset ready type composter to empty type From 51ca60c09704b1b4708b8c67821e8185c7c9368c Mon Sep 17 00:00:00 2001 From: kabou Date: Sat, 19 Feb 2022 14:49:32 +0100 Subject: [PATCH 12/15] Change custom node attribute name. * Rename _compost_level to _mcl_compost_level --- mods/ITEMS/mcl_composters/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 5684c2c2b..abcc7fcb4 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -157,7 +157,7 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing) if chance >= rand then -- get current compost level local node_defs = minetest.registered_nodes[node.name] - local level = node_defs["_compost_level"] + local level = node_defs["_mcl_compost_level"] -- spawn green particles above new layer mcl_dye.add_bone_meal_particle(vector.add(pos, {x=0, y=level/8, z=0})) -- TODO: play some sounds @@ -253,7 +253,7 @@ minetest.register_node("mcl_composters:composter", { sounds = mcl_sounds.node_sound_wood_defaults(), _mcl_hardness = 2, _mcl_blast_resistance = 2, - _compost_level = 0, + _mcl_compost_level = 0, on_rightclick = composter_add_item }) @@ -287,7 +287,7 @@ local function register_filled_composter(level) drop = "mcl_composters:composter", _mcl_hardness = 2, _mcl_blast_resistance = 2, - _compost_level = level, + _mcl_compost_level = level, on_rightclick = composter_add_item, on_timer = composter_ready }) @@ -332,7 +332,7 @@ minetest.register_node("mcl_composters:composter_ready", { drop = "mcl_composters:composter", _mcl_hardness = 2, _mcl_blast_resistance = 2, - _compost_level = 7, + _mcl_compost_level = 7, on_rightclick = composter_harvest }) From 55009c257e253c49dacf017e4bd56bc36aca2e10 Mon Sep 17 00:00:00 2001 From: kabou Date: Sat, 19 Feb 2022 16:15:36 +0100 Subject: [PATCH 13/15] Use new vectors * Use vector.new instead of xyz table. --- mods/ITEMS/mcl_composters/init.lua | 2 +- mods/ITEMS/mcl_hoppers/init.lua | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index abcc7fcb4..7b6e9243b 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -159,7 +159,7 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing) local node_defs = minetest.registered_nodes[node.name] local level = node_defs["_mcl_compost_level"] -- spawn green particles above new layer - mcl_dye.add_bone_meal_particle(vector.add(pos, {x=0, y=level/8, z=0})) + mcl_dye.add_bone_meal_particle(vector.add(pos, vector.new(0, level/8, 0))) -- TODO: play some sounds -- update composter block if level < 7 then diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index 36a21ad95..8245a0b26 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -343,7 +343,7 @@ minetest.register_abm({ local abovenode = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}) if not minetest.registered_items[abovenode.name] then return end -- Don't bother checking item enties if node above is a container (should save some CPU) - if minetest.registered_items[abovenode.name].groups.container then + if minetest.get_item_group(abovenode.name, "container") then return end local meta = minetest.get_meta(pos) @@ -397,7 +397,7 @@ minetest.register_abm({ -- Suck an item from the container above into the hopper local upnode = minetest.get_node(uppos) if not minetest.registered_nodes[upnode.name] then return end - local g = minetest.registered_nodes[upnode.name].groups.container + local g = minetest.get_item_group(upnode.name, "container") local sucked = mcl_util.move_item_container(uppos, pos) -- Also suck in non-fuel items from furnace fuel slot @@ -442,7 +442,7 @@ minetest.register_abm({ -- Suck an item from the container above into the hopper local abovenode = minetest.get_node(above) if not minetest.registered_nodes[abovenode.name] then return end - local g = minetest.registered_nodes[abovenode.name].groups.container + local g = minetest.get_item_group(abovenode.name, "container") local sucked = mcl_util.move_item_container(above, pos) -- Also suck in non-fuel items from furnace fuel slot @@ -454,7 +454,7 @@ minetest.register_abm({ end -- Move an item from the hopper into the container to which the hopper points to - local g = minetest.registered_nodes[frontnode.name].groups.container + local g = minetest.get_item_group(frontnode.name, "container") if g == 2 or g == 3 or g == 5 or g == 6 then mcl_util.move_item_container(pos, front) elseif g == 4 then From f81980da51818610b95d39684e1395f14e875108 Mon Sep 17 00:00:00 2001 From: kabou Date: Sat, 19 Feb 2022 16:17:33 +0100 Subject: [PATCH 14/15] Fix hardness and blast resistance. * Use correct MC values for hardness and blast resistance. --- mods/ITEMS/mcl_composters/init.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_composters/init.lua b/mods/ITEMS/mcl_composters/init.lua index 7b6e9243b..b63931ad7 100644 --- a/mods/ITEMS/mcl_composters/init.lua +++ b/mods/ITEMS/mcl_composters/init.lua @@ -251,8 +251,8 @@ minetest.register_node("mcl_composters:composter", { flammable=2, fire_encouragement=3, fire_flammability=4, }, sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_hardness = 2, - _mcl_blast_resistance = 2, + _mcl_hardness = 0.6, + _mcl_blast_resistance = 0.6, _mcl_compost_level = 0, on_rightclick = composter_add_item }) @@ -285,8 +285,8 @@ local function register_filled_composter(level) }, sounds = mcl_sounds.node_sound_wood_defaults(), drop = "mcl_composters:composter", - _mcl_hardness = 2, - _mcl_blast_resistance = 2, + _mcl_hardness = 0.6, + _mcl_blast_resistance = 0.6, _mcl_compost_level = level, on_rightclick = composter_add_item, on_timer = composter_ready @@ -330,8 +330,8 @@ minetest.register_node("mcl_composters:composter_ready", { }, sounds = mcl_sounds.node_sound_wood_defaults(), drop = "mcl_composters:composter", - _mcl_hardness = 2, - _mcl_blast_resistance = 2, + _mcl_hardness = 0.6, + _mcl_blast_resistance = 0.6, _mcl_compost_level = 7, on_rightclick = composter_harvest }) From 8d18ab8a7a007d35d601dccbe93dfada9c2e5deb Mon Sep 17 00:00:00 2001 From: kabou Date: Sat, 19 Feb 2022 16:55:24 +0100 Subject: [PATCH 15/15] Optimize texture files. * Texture files were optimized with 'optipng -o7 -zm9 -strip all' . --- .../textures/mcl_composter_bottom.png | Bin 395 -> 213 bytes .../textures/mcl_composter_compost.png | Bin 409 -> 184 bytes .../textures/mcl_composter_ready.png | Bin 582 -> 276 bytes .../textures/mcl_composter_side.png | Bin 267 -> 209 bytes .../textures/mcl_composter_top.png | Bin 397 -> 223 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/mods/ITEMS/mcl_composters/textures/mcl_composter_bottom.png b/mods/ITEMS/mcl_composters/textures/mcl_composter_bottom.png index dc075789938b54b1f26881e9a101b71a6abc7fb0..cfed3a8a5c7fa7818d1cc06f534cc087fa8e1b91 100644 GIT binary patch delta 197 zcmV;$06PDR1JwbL7=Hu<0002(-QrRJ0016POjJc)OF?E(MQ>C_cv?t>V@!@|O_O-B**I>Qi|zG#c7HspE!L~$fM3{!0RS}L z9VAZ00YC#l^V5T?tu$mT-P=mXv#m4~FO09TdwGNZe8=_8eLNdqGg{XHZ~Q;di%W;zz(8vsx=NP@{JNH#BL(Nsl~ zTsNR`M|1X}k9F0kWFPvtZ(WE+Dz@h8a;$_^{!^vWfa`{{L{vE;kS5A%xo(hj)CK8q zuA20vb>Vau=mjg&xa@ai7vv?Yox`LHsbnh2nJ8n$dbJ$nu*jiF2Pv1MWwIPy{xNqa aRUZJLbDRHfYw#QZ0000ZKiFTVC>hD59(`=?h`_AByB^-Fpb_p&Ly+bm=levX0RfIP1W*Gk>p S<)uIi7(8A5T-G@yGywqImpVBB delta 395 zcmV;60d)Sj0ht4k7=H)`0000V^Z#K0000JJOGiWi{{a60|De66lK=n!32;bRa{vGf z6951U69E94oEQKA00(qQO+^Re2Ll5s7^(dUmH+?&CP_p=R5;7Eld*2YAQVN936>>b zi3g@k9n!Dp(EtB~4w*7Bq#XZht;L-+5&TUR?6wdj_z* zz{nlW&kTOT=zEFP4JS92ZL=aMmxt+E_o_=A_br2;IJptqi){ki3qllxI5YT!(Yf%T zI?f?tv_y4@5CxFd4MG$Qegb$dR{30Y`BJIbn!y8J!pI#)!Z}0$+$CYO#P-jR$>mf- z6j`<6G`Vs*0} zq+(-{qPkQY*Eu3@!>iN5xV)Y z2FHK1JP9=+V$Yt?hh}oe|&Z0(`z8Q`RVm7(Qm4S zKoc2Dg8YIR9G=}s19D0{T^vIsBzq5b3LY}35nwr(EV*7_(}4&6Pv&csO75^;Hz7tK zV2MXjr26ix?MgFCeb&|Wt@AjeKJRr=Ub*Wc-MqtccU=yxtvM#msl<7>T&%<6#Oi}@ zHB^P(?LV4!w=Z1fd#<=yzn{w8Suv|MH72o$umr_?V6O~g>2!LLa~|jb22WQ%mvv4F FO#p~BZcqRK delta 568 zcmV-80>}N70>%W88Gi-<001BJ|6u?C00v@9M??Vs0RI60puMM)00009a7bBm000XU z000XU0RWnu7ytkO2XskIMF-;t0|O})*GzRQ0005gNklJI4qyuNS+%hZ%- zrg>g(pj^plKF8gg57?zLC|h)QpxobbxE;M@8qD%b8)Ix@M{ zfn{n6Ln9n7PN4NqPEMW0v5f>$o;gpSBN^P2qgtzP1$Y~phfiOkwdQg4HOiIrTNwaa zL6~f*S~07qJfxHgA$ZYf;@Ad32;Yt9&q-?>TPElIf7LInO{sr4dCb}X0000S|zoLLZ^xL2VX)Z9k85Es{jiC002ovPDHLk FV1lhoJwE^d delta 209 zcmcb}*v&LSg;8;$s#5)e=8X89`d9`A2F4_BcNc~ZR#^`qhqJ&VvY3H^TNs2H8D`Cq z01C2~c>21sKW1lU=Hry?n9T?jD)4l14B@!$dnQoukb#KH#iNYP%qDvRSe_hp+|DKu zC!4~~-q|Fyy=DKs_r~ITw_g0U{qclj3(q&qO!vO|p!MAn*T;27-xM{!+O)dufX1Ds z7FA>IY^&K5#5mvQPC9-+B5B_B$(`YMm#Q~upIoaj+duUsd%TmXtkBcOZ9vNzJYD@< J);T3K0RVz4P6Yq} diff --git a/mods/ITEMS/mcl_composters/textures/mcl_composter_top.png b/mods/ITEMS/mcl_composters/textures/mcl_composter_top.png index 6fb9df7ee2f70e60bf6362ba509a8d3fd78342a3..fc6e202d3c90f2e7405c671392145fced2a74a3f 100644 GIT binary patch delta 207 zcmeBWzRx&8qMn7Bfq~)e-A6${N-n@B#5K;_F)hF~Kg6vf%A+;er!UiYW>L`O%9I7o z8EgCV8n0UK1FB>%3GxdD(jX9;@+tyIWqP_ehH%KT9(3eoaujg67=QN8ax=#RUJlHC z1&snNXQ#Go*vqDI?{e^F)7cZ1+2iLopZ`7Sy2snN72+;SkDV@)Jm|ktX5#shuYHCh zCd)LVbe2rwu#HWN7h7q;U~Bc}VM;-&wVc70T*uA-pLyysTsT+o5M;ZjtDnm{r-UW| D29!>d delta 382 zcmV-^0fGMC0gVHY7=H)`0000V^Z#K0000JJOGiWi{{a60|De66lK=n!32;bRa{vGf z6951U69E94oEQKA00(qQO+^Re2Ll5a6_$x^RsaA28c9S!R5;6pQ_D`nFc6%zT#JNS zT=>ZTM}MSW!WoGh7eIgnh+Ys1LLs<$Na0Y%Y#g`D#rAr=Gk>1d%4WS9@e99n0D$_d zgT|pa09XL1zXx#jrG<{Adtcgk_N9g4g=;I>KEF!)@g^6Scfzx4D|xtok*n)Racw2H zH&5c)O8Cx9q!t!U=m7xlpL4kcbNtfn3;6QyAyGJ)6gpYhNWwP&U}%sAlT)zRX|af= z8k!Wk5p~#`vv=!<$VMf*eu(=f^wCJe)|{VBm5}8>RVEFDZai9uDrW_>iJC3f4Hlhr zK|7pd)4nvJKima+L1r44{f_Q}z9ic*%({?DrjneAIwqU-YShD`hbA4QT#nVrdUW~6 c+?`ha1IdG&3+6y&UH||907*qoM6N<$f@RgH82|tP