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!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10;!=Q5i0l9V{}ZA$QnIwu zigZ%*wUaZnvU2pwi%pN7PG7S&JU`oT#satgY0mQ&dM;k!w{d%L-(;sn^8>mjI%XE= z)>m3jo$l7$ZBtrrT##>A+iY1-W{{Gum7bzqlxtMqVAf-V>*}&7AAeJJGqk%yi)rzv*+`S~_eRnylt8 z^xd>Qvb@x^s>*D^62D0^ojZH&s;kYHt_tkvvnweyt}HWe>9A|=v@I?+&dW3adMDQR z;sc=X7)yfuf*Bm1-ADs*lDyqr7&=&GJ%Akc5>H=O_J>SD{8EArca5I|g${eVIEGl9 zetXVctjR#6^oXU7ZgcRHS6JFKt3aj3wA?O=-5 zfgC=jPb}OLI?9Y;3K98>H151h*l=HluTVzbvA}A!`2GF&F6^KGicjTUO_QmvAUQh^kMk%6JPu7Q!Rp+$(Hsg;qLm7%$|fuWUw!EdLJPf#@E=BH$) XRpQprCGQyl)WG2B>gTe~DWM4f*z@=! 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!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+0817ll&Pl)UP|NleGB$B+P zGQ*@hbM$7ETlD3dR>tY)2C9cxNbH#B-jHM5o~=K-+ID-t^Xew6Bp<1%rIvGQ9gfZR zI6T>YX}xh~xK>`I(!zS@{vtDfN12K^gZ@IxS=DxDmxS(`7L*k(Qyi_ivCB0-QmG_H zGd)OdLY~R8dYk?{(-be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