From 2b2a735d6da90c8def7c15b959954b25ea09cc0e Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 18 Feb 2017 16:06:18 +0100 Subject: [PATCH] Add very basic cocoas (mostly node defs so far) --- mods/ITEMS/mcl_cocoa/README.txt | 5 + mods/ITEMS/mcl_cocoa/depends.txt | 2 + mods/ITEMS/mcl_cocoa/description.txt | 1 + mods/ITEMS/mcl_cocoa/init.lua | 129 ++++++++++++++++++ mods/ITEMS/mcl_cocoa/mod.conf | 1 + .../textures/mcl_cocoa_cocoa_stage_0.png | Bin 0 -> 677 bytes .../textures/mcl_cocoa_cocoa_stage_1.png | Bin 0 -> 1018 bytes .../textures/mcl_cocoa_cocoa_stage_2.png | Bin 0 -> 1498 bytes mods/ITEMS/mcl_dye/depends.txt | 1 + mods/ITEMS/mcl_dye/init.lua | 35 +++-- 10 files changed, 163 insertions(+), 11 deletions(-) create mode 100644 mods/ITEMS/mcl_cocoa/README.txt create mode 100644 mods/ITEMS/mcl_cocoa/depends.txt create mode 100644 mods/ITEMS/mcl_cocoa/description.txt create mode 100644 mods/ITEMS/mcl_cocoa/init.lua create mode 100644 mods/ITEMS/mcl_cocoa/mod.conf create mode 100644 mods/ITEMS/mcl_cocoa/textures/mcl_cocoa_cocoa_stage_0.png create mode 100644 mods/ITEMS/mcl_cocoa/textures/mcl_cocoa_cocoa_stage_1.png create mode 100644 mods/ITEMS/mcl_cocoa/textures/mcl_cocoa_cocoa_stage_2.png diff --git a/mods/ITEMS/mcl_cocoa/README.txt b/mods/ITEMS/mcl_cocoa/README.txt new file mode 100644 index 000000000..2f00b68fe --- /dev/null +++ b/mods/ITEMS/mcl_cocoa/README.txt @@ -0,0 +1,5 @@ +This mod adds cocoas. +Cocoas grow at jungle trees in 3 stages and can be harvested for cocoa beans. +Cocoa beans can be used to plant new cocoas at jungle trees. + +Partially based on the cocoas from Farming Redo by TenPlus1. diff --git a/mods/ITEMS/mcl_cocoa/depends.txt b/mods/ITEMS/mcl_cocoa/depends.txt new file mode 100644 index 000000000..115fd3340 --- /dev/null +++ b/mods/ITEMS/mcl_cocoa/depends.txt @@ -0,0 +1,2 @@ +mcl_sounds +mcl_core diff --git a/mods/ITEMS/mcl_cocoa/description.txt b/mods/ITEMS/mcl_cocoa/description.txt new file mode 100644 index 000000000..1af5d7ce0 --- /dev/null +++ b/mods/ITEMS/mcl_cocoa/description.txt @@ -0,0 +1 @@ +Cocoa pods which grow at jungle trees. Does not include cocoa beans. diff --git a/mods/ITEMS/mcl_cocoa/init.lua b/mods/ITEMS/mcl_cocoa/init.lua new file mode 100644 index 000000000..b65061dcf --- /dev/null +++ b/mods/ITEMS/mcl_cocoa/init.lua @@ -0,0 +1,129 @@ +mcl_cocoa = {} + +-- place cocoa +function mcl_cocoa.place_cocoa(itemstack, placer, pointed_thing, plantname) + + local pt = pointed_thing + + -- check if pointing at a node + if not pt or pt.type ~= "node" then + return + end + + local under = minetest.get_node(pt.under) + + -- return if any of the nodes are not registered + if not minetest.registered_nodes[under.name] then + return + end + + -- am I right-clicking on something that has a custom on_place set? + -- thanks to Krock for helping with this issue :) + local def = minetest.registered_nodes[under.name] + if def and def.on_rightclick then + return def.on_rightclick(pt.under, under, placer, itemstack) + end + + -- check if pointing at jungletree + if under.name ~= "mcl_core:jungletree" + or minetest.get_node(pt.above).name ~= "air" then + return + end + + -- add the node and remove 1 item from the itemstack + minetest.set_node(pt.above, {name = plantname}) + + minetest.sound_play("default_place_node", {pos = pt.above, gain = 1.0}) + + if not minetest.setting_getbool("creative_mode") then + + itemstack:take_item() + + -- check for refill + if itemstack:get_count() == 0 then + + minetest.after(0.20, + farming.refill_plant, + placer, + "mcl_dye:brown", + placer:get_wield_index() + ) + end + end + + return itemstack +end + +-- Note: cocoa beans are implemented as mcl_dye:brown + +-- Cocoa definition +local crop_def = { + drawtype = "plantlike", + tiles = {"mcl_cocoa_cocoa_stage_0.png"}, + paramtype = "light", + paramtype2 = "facedir", + walkable = true, + drop = "mcl_dye:brown", + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} + }, + groups = { + choppy=3, not_in_creative_inventory=1, dig_by_water = 1, + }, + sounds = mcl_sounds.node_sound_wood_defaults() +} + +-- stage 1 +minetest.register_node("mcl_cocoa:cocoa_1", table.copy(crop_def)) + +-- stage2 +crop_def.tiles = {"mcl_cocoa_cocoa_stage_1.png"} +minetest.register_node("mcl_cocoa:cocoa_2", table.copy(crop_def)) + +-- stage 3 (final) +crop_def.tiles = {"mcl_cocoa_cocoa_stage_2.png"} +crop_def.drop = "mcl_dye:brown 3", +minetest.register_node("mcl_cocoa:cocoa_3", table.copy(crop_def)) + +-- Add random cocoa pods to jungle trees +minetest.register_on_generated(function(minp, maxp) + + if maxp.y < 0 then + return + end + + local pos, dir + local cocoa = minetest.find_nodes_in_area(minp, maxp, "mcl_core:jungletree") + + for n = 1, #cocoa do + + pos = cocoa[n] + + if minetest.find_node_near(pos, 1, {"mcl_core:jungleleaves"}) then + + dir = math.random(1, 80) + + if dir == 1 then + pos.x = pos.x + 1 + elseif dir == 2 then + pos.x = pos.x - 1 + elseif dir == 3 then + pos.z = pos.z + 1 + elseif dir == 4 then + pos.z = pos.z -1 + end + + if dir < 5 + and minetest.get_node(pos).name == "air" + and minetest.get_node_light(pos) > 12 then + + minetest.swap_node(pos, { + name = "mcl_cocoa:cocoa_" .. tostring(math.random(1, 3)) + }) + end + + end + end +end) + diff --git a/mods/ITEMS/mcl_cocoa/mod.conf b/mods/ITEMS/mcl_cocoa/mod.conf new file mode 100644 index 000000000..9dde388af --- /dev/null +++ b/mods/ITEMS/mcl_cocoa/mod.conf @@ -0,0 +1 @@ +name = mcl_cocoa diff --git a/mods/ITEMS/mcl_cocoa/textures/mcl_cocoa_cocoa_stage_0.png b/mods/ITEMS/mcl_cocoa/textures/mcl_cocoa_cocoa_stage_0.png new file mode 100644 index 0000000000000000000000000000000000000000..110c5b321ff0c4ad5445c09b932700d870b5bde7 GIT binary patch literal 677 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4rT@h2A3sW#~2tGSkfJR9T^xl_H+M9WCckk zdj$D1FjT2AFf_C}372GLuEi{g$r@oHoO)w8EsK+H~8VsD;bD=PvS|IL&S5T#w#~&gEsM3zzs!pX=7r zVbjoLHGiS+rtOjCrKVL?W($`1O`7T4*=tu_ZN79>U`L-_NuhCNnR!cxU2~^xaj|h; zrosRJ|6_eGK44&AU@Qsp3ubV5b|VeMN%D4gVd!9$^}fB4~l??GL2 zyU@uHspM9L$eBE@k)ffczQIq7mv%gvv2L@?v^P_v+CDN^C8zCExT|~Gsf9a0$Fm`^ z)7!$>_Zw%N^(M>bPm4A(G35v^dXV*2wu4LnK4WuB7c#_op%Wv?#u8M%E&twSj`r{zyIEa{qtY( zsXP%bXjsHu&A`B*TH+c}l9E`GYL#4+npl#`U}Ruuu4`bVYiJQ-Xli9-W@TuuZD43+ lVDQ`N;}aAOx%nxXX_dG&bjf>0FfcGMc)I$ztaD0e0sz?a_#*%S literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_cocoa/textures/mcl_cocoa_cocoa_stage_1.png b/mods/ITEMS/mcl_cocoa/textures/mcl_cocoa_cocoa_stage_1.png new file mode 100644 index 0000000000000000000000000000000000000000..086df18d4e5f95b80996f198f361fe9646f07eb3 GIT binary patch literal 1018 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4rT@h2A3sW#~2tGSkfJR9T^xl_H+M9WCckk zdj$D1FjT2AFf_C}uQX{m!eKtde}Brj}aH zsdYFu+vD(L`=#~9nc-S_kxC2eo%@T-{2gT~;tcu=EoW8Rom~>TYg$lNxJ+@h=Eg49 z{79ve7|rw`xe0kD%j#|V^Gs8`R1QtFnN??55KEK?e*Rh?j1602Dlt(xkt6mP4z zro(YVk6&k=#q45>+2v;OuCi%?^Z7GtX~XlWl~n z$n<*eFh`LjZ@Kk7-UpZGFRrx?v=UD7l}`^;T-oNfsKz4NSt>JF@zjEdZPVgv)6EZ0 zbxrV)%L!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3v)drKgjEC~8(8&mVv{K*|6u<#+<9r=9b7KDhTjHrDpadh|Qjb35u!2>&tsewLxf@1i_2S6DYA_7|RP?w!6WyEFePhB0J^pS5H@ zzgEo19BqFUGYT!t-8j>s`C};{St2QgRLe03>tL**%Fu{lA`TMhgG{ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_dye/depends.txt b/mods/ITEMS/mcl_dye/depends.txt index 0172fb67c..77bac790d 100644 --- a/mods/ITEMS/mcl_dye/depends.txt +++ b/mods/ITEMS/mcl_dye/depends.txt @@ -1,3 +1,4 @@ mcl_core mcl_flowers mcl_mobitems +mcl_cocoa diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index fd15df96b..2449ab3e7 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -85,16 +85,19 @@ dyelocal.dyes = { -- Define items for _, row in ipairs(dyelocal.dyes) do local name = row[1] - local description = row[2] - local groups = row[3] - local item_name = "mcl_dye:"..name - local item_image = "dye_"..name..".png" - minetest.register_craftitem(item_name, { - inventory_image = item_image, - description = description, - groups = groups, - stack_max = 64, - }) + -- White and brown dyes are defined explicitly below + if name ~= "white" and name ~= "brown" then + local description = row[2] + local groups = row[3] + local item_name = "mcl_dye:"..name + local item_image = "dye_"..name..".png" + minetest.register_craftitem(item_name, { + inventory_image = item_image, + description = description, + groups = groups, + stack_max = 64, + }) + end end -- Bone Meal @@ -209,7 +212,7 @@ minetest.register_craftitem("mcl_dye:white", { inventory_image = "dye_white.png", description = "Bone Meal", stack_max = 64, - groups = {dye=1, craftitem=1, basecolor_white=1, excolor_white=1, unicolor_white=1}, + groups = dyelocal.dyes[1][3], on_place = function(itemstack, user, pointed_thing) if(mcl_dye.apply_bone_meal(pointed_thing) and not minetest.setting_getbool("creative_mode")) then itemstack:take_item() @@ -218,6 +221,16 @@ minetest.register_craftitem("mcl_dye:white", { end, }) +minetest.register_craftitem("mcl_dye:brown", { + inventory_image = "dye_brown.png", + description = "Cocoa Beans", + stack_max = 64, + groups = dyelocal.dyes[4][3], + on_place = function(itemstack, user, pointed_thing) + return mcl_cocoa.place_cocoa(itemstack, placer, pointed_thing, "mcl_cocoa:cocoa_1") + end, +}) + -- Dye mixing minetest.register_craft({ type = "shapeless",