diff --git a/mods/dye/README.txt b/mods/dye/README.txt new file mode 100644 index 0000000..b103541 --- /dev/null +++ b/mods/dye/README.txt @@ -0,0 +1,15 @@ +Minetest Game mod: dye +====================== + +See init.lua for documentation. + +License of source code and media files: +--------------------------------------- +Copyright (C) 2012 Perttu Ahola (celeron55) + +This program is free software. It comes without any warranty, to +the extent permitted by applicable law. You can redistribute it +and/or modify it under the terms of the Do What The Fuck You Want +To Public License, Version 2, as published by Sam Hocevar. See +http://sam.zoy.org/wtfpl/COPYING for more details. + diff --git a/mods/dye/init.lua b/mods/dye/init.lua new file mode 100644 index 0000000..d414d77 --- /dev/null +++ b/mods/dye/init.lua @@ -0,0 +1,109 @@ +-- Other mods can use these for looping through available colors + +dye = {} +dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"} +dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", + "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"} + +-- Make dye names and descriptions available globally + +dye.dyes = { + {"white", "White"}, + {"grey", "Grey"}, + {"dark_grey", "Dark grey"}, + {"black", "Black"}, + {"violet", "Violet"}, + {"blue", "Blue"}, + {"cyan", "Cyan"}, + {"dark_green", "Dark green"}, + {"green", "Green"}, + {"yellow", "Yellow"}, + {"brown", "Brown"}, + {"orange", "Orange"}, + {"red", "Red"}, + {"magenta", "Magenta"}, + {"pink", "Pink"}, +} + +-- This collection of colors is partly a historic thing, partly something else + +local dyes = { + {"white", "White dye", {dye=1, basecolor_white=1, excolor_white=1, unicolor_white=1}}, + {"grey", "Grey dye", {dye=1, basecolor_grey=1, excolor_grey=1, unicolor_grey=1}}, + {"dark_grey", "Dark grey dye", {dye=1, basecolor_grey=1, excolor_darkgrey=1, unicolor_darkgrey=1}}, + {"black", "Black dye", {dye=1, basecolor_black=1, excolor_black=1, unicolor_black=1}}, + {"violet", "Violet dye", {dye=1, basecolor_magenta=1, excolor_violet=1, unicolor_violet=1}}, + {"blue", "Blue dye", {dye=1, basecolor_blue=1, excolor_blue=1, unicolor_blue=1}}, + {"cyan", "Cyan dye", {dye=1, basecolor_cyan=1, excolor_cyan=1, unicolor_cyan=1}}, + {"dark_green", "Dark green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_dark_green=1}}, + {"green", "Green dye", {dye=1, basecolor_green=1, excolor_green=1, unicolor_green=1}}, + {"yellow", "Yellow dye", {dye=1, basecolor_yellow=1, excolor_yellow=1, unicolor_yellow=1}}, + {"brown", "Brown dye", {dye=1, basecolor_brown=1, excolor_orange=1, unicolor_dark_orange=1}}, + {"orange", "Orange dye", {dye=1, basecolor_orange=1, excolor_orange=1, unicolor_orange=1}}, + {"red", "Red dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_red=1}}, + {"magenta", "Magenta dye", {dye=1, basecolor_magenta=1, excolor_red_violet=1, unicolor_red_violet=1}}, + {"pink", "Pink dye", {dye=1, basecolor_red=1, excolor_red=1, unicolor_light_red=1}}, +} + +-- Define items + +for _, row in ipairs(dyes) do + local name = row[1] + local description = row[2] + local groups = row[3] + local item_name = "dye:" .. name + local item_image = "dye_" .. name .. ".png" + minetest.register_craftitem(item_name, { + inventory_image = item_image, + description = description, + groups = groups + }) + minetest.register_craft({ + type = "shapeless", + output = item_name .. " 4", + recipe = {"group:flower,color_" .. name}, + }) +end + +-- Manually add coal->black dye + +minetest.register_craft({ + type = "shapeless", + output = "dye:black 4", + recipe = {"group:coal"}, +}) + +-- Mix recipes +-- Just mix everything to everything somehow sanely + +local mixbases = {"pink", "magenta", "red", "orange", "brown", "yellow", "green", "dark_green", "cyan", "blue", "violet", "black", "dark_grey", "grey", "white"} + +local mixes = { + -- pink, magenta, red, orange, brown, yellow, green, dark_green, cyan, blue, violet, black, dark_grey, grey, white + white = {"pink", "pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet","grey", "grey", "grey","white"}, + grey = {"pink", "pink", "pink", "orange", "orange", "yellow", "green", "green", "grey", "cyan", "violet","dark_grey","grey", "grey"}, + dark_grey = {"brown", "brown", "brown", "brown", "brown", "brown", "dark_green","dark_green","blue", "blue", "violet","black", "dark_grey"}, + black = {"black", "black", "black", "black", "black", "black", "black", "black", "black","black", "black", "black"}, + violet = {"magenta","magenta","magenta","red", "brown", "red", "cyan", "brown", "blue", "violet","violet"}, + blue = {"violet", "violet", "magenta","brown", "brown", "dark_green","cyan", "cyan", "cyan", "blue"}, + cyan = {"brown", "blue", "brown", "dark_green","dark_grey", "green", "cyan", "dark_green","cyan"}, + dark_green = {"brown", "brown", "brown", "brown", "brown", "green", "green", "dark_green"}, + green = {"yellow", "brown", "yellow", "yellow", "dark_green","green", "green"}, + yellow = {"orange", "red", "orange", "yellow", "orange", "yellow"}, + brown = {"brown", "brown", "brown", "orange", "brown"}, + orange = {"orange", "red", "orange", "orange"}, + red = {"pink", "magenta","red"}, + magenta = {"magenta","magenta"}, + pink = {"pink"}, +} + +for one, results in pairs(mixes) do + for i, result in ipairs(results) do + local another = mixbases[i] + minetest.register_craft({ + type = "shapeless", + output = 'dye:' .. result .. ' 2', + recipe = {'dye:' .. one, 'dye:' .. another}, + }) + end +end diff --git a/mods/dye/textures/dye_black.png b/mods/dye/textures/dye_black.png new file mode 100644 index 0000000..1055b6c Binary files /dev/null and b/mods/dye/textures/dye_black.png differ diff --git a/mods/dye/textures/dye_blue.png b/mods/dye/textures/dye_blue.png new file mode 100644 index 0000000..d1377c6 Binary files /dev/null and b/mods/dye/textures/dye_blue.png differ diff --git a/mods/dye/textures/dye_brown.png b/mods/dye/textures/dye_brown.png new file mode 100644 index 0000000..77d475c Binary files /dev/null and b/mods/dye/textures/dye_brown.png differ diff --git a/mods/dye/textures/dye_cyan.png b/mods/dye/textures/dye_cyan.png new file mode 100644 index 0000000..239d66c Binary files /dev/null and b/mods/dye/textures/dye_cyan.png differ diff --git a/mods/dye/textures/dye_dark_green.png b/mods/dye/textures/dye_dark_green.png new file mode 100644 index 0000000..9606ccf Binary files /dev/null and b/mods/dye/textures/dye_dark_green.png differ diff --git a/mods/dye/textures/dye_dark_grey.png b/mods/dye/textures/dye_dark_grey.png new file mode 100644 index 0000000..060737b Binary files /dev/null and b/mods/dye/textures/dye_dark_grey.png differ diff --git a/mods/dye/textures/dye_green.png b/mods/dye/textures/dye_green.png new file mode 100644 index 0000000..0d99ee1 Binary files /dev/null and b/mods/dye/textures/dye_green.png differ diff --git a/mods/dye/textures/dye_grey.png b/mods/dye/textures/dye_grey.png new file mode 100644 index 0000000..5efb028 Binary files /dev/null and b/mods/dye/textures/dye_grey.png differ diff --git a/mods/dye/textures/dye_magenta.png b/mods/dye/textures/dye_magenta.png new file mode 100644 index 0000000..c84df62 Binary files /dev/null and b/mods/dye/textures/dye_magenta.png differ diff --git a/mods/dye/textures/dye_orange.png b/mods/dye/textures/dye_orange.png new file mode 100644 index 0000000..0844907 Binary files /dev/null and b/mods/dye/textures/dye_orange.png differ diff --git a/mods/dye/textures/dye_pink.png b/mods/dye/textures/dye_pink.png new file mode 100644 index 0000000..c3dec22 Binary files /dev/null and b/mods/dye/textures/dye_pink.png differ diff --git a/mods/dye/textures/dye_red.png b/mods/dye/textures/dye_red.png new file mode 100644 index 0000000..14eafbf Binary files /dev/null and b/mods/dye/textures/dye_red.png differ diff --git a/mods/dye/textures/dye_violet.png b/mods/dye/textures/dye_violet.png new file mode 100644 index 0000000..600cbb4 Binary files /dev/null and b/mods/dye/textures/dye_violet.png differ diff --git a/mods/dye/textures/dye_white.png b/mods/dye/textures/dye_white.png new file mode 100644 index 0000000..2a840a4 Binary files /dev/null and b/mods/dye/textures/dye_white.png differ diff --git a/mods/dye/textures/dye_yellow.png b/mods/dye/textures/dye_yellow.png new file mode 100644 index 0000000..fe75775 Binary files /dev/null and b/mods/dye/textures/dye_yellow.png differ diff --git a/mods/farming/README.txt b/mods/farming/README.txt new file mode 100644 index 0000000..143cf38 --- /dev/null +++ b/mods/farming/README.txt @@ -0,0 +1,48 @@ +Minetest Game mod: farming +========================== + +License of source code: +----------------------- +Copyright (C) 2014 webdesigner97 + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + +License of media (textures): +---------------------------- +Created by PilzAdam (License: WTFPL): + farming_bread.png + farming_soil.png + farming_soil_wet.png + farming_soil_wet_side.png + farming_string.png + +Created by BlockMen (License: CC BY 3.0): + farming_tool_diamondhoe.png + farming_tool_mesehoe.png + farming_tool_bronzehoe.png + farming_tool_steelhoe.png + farming_tool_stonehoe.png + farming_tool_woodhoe.png + +Created by MasterGollum (License: WTFPL): + farming_straw.png + +Created by Gambit (License: WTFPL): + farming_wheat.png + farming_wheat_*.png + farming_cotton_*.png + farming_flour.png + farming_cotton_seed.png + farming_wheat_seed.png diff --git a/mods/farming/api.lua b/mods/farming/api.lua new file mode 100644 index 0000000..68f7be7 --- /dev/null +++ b/mods/farming/api.lua @@ -0,0 +1,328 @@ +-- Wear out hoes, place soil +-- TODO Ignore group:flower +farming.hoe_on_use = function(itemstack, user, pointed_thing, uses) + local pt = pointed_thing + -- check if pointing at a node + if not pt then + return + end + if pt.type ~= "node" then + return + end + + local under = minetest.get_node(pt.under) + local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z} + local above = minetest.get_node(p) + + -- return if any of the nodes is not registered + if not minetest.registered_nodes[under.name] then + return + end + if not minetest.registered_nodes[above.name] then + return + end + + -- check if the node above the pointed thing is air + if above.name ~= "air" then + return + end + + -- check if pointing at soil + if minetest.get_item_group(under.name, "soil") ~= 1 then + return + end + + -- check if (wet) soil defined + local regN = minetest.registered_nodes + if regN[under.name].soil == nil or regN[under.name].soil.wet == nil or regN[under.name].soil.dry == nil then + return + end + + if minetest.is_protected(pt.under, user:get_player_name()) then + minetest.record_protection_violation(pt.under, user:get_player_name()) + return + end + if minetest.is_protected(pt.above, user:get_player_name()) then + minetest.record_protection_violation(pt.above, user:get_player_name()) + return + end + + + -- turn the node into soil, wear out item and play sound + minetest.set_node(pt.under, {name = regN[under.name].soil.dry}) + minetest.sound_play("default_dig_crumbly", { + pos = pt.under, + gain = 0.5, + }) + + if not minetest.setting_getbool("creative_mode") then + itemstack:add_wear(65535/(uses-1)) + end + return itemstack +end + +-- Register new hoes +farming.register_hoe = function(name, def) + -- Check for : prefix (register new hoes in your mod's namespace) + if name:sub(1,1) ~= ":" then + name = ":" .. name + end + -- Check def table + if def.description == nil then + def.description = "Hoe" + end + if def.inventory_image == nil then + def.inventory_image = "unknown_item.png" + end + if def.recipe == nil then + def.recipe = { + {"air","air",""}, + {"","group:stick",""}, + {"","group:stick",""} + } + end + if def.max_uses == nil then + def.max_uses = 30 + end + -- Register the tool + minetest.register_tool(name, { + description = def.description, + inventory_image = def.inventory_image, + on_use = function(itemstack, user, pointed_thing) + return farming.hoe_on_use(itemstack, user, pointed_thing, def.max_uses) + end + }) + -- Register its recipe + if def.material == nil then + minetest.register_craft({ + output = name:sub(2), + recipe = def.recipe + }) + else + minetest.register_craft({ + output = name:sub(2), + recipe = { + {def.material, def.material, ""}, + {"", "group:stick", ""}, + {"", "group:stick", ""} + } + }) + -- Reverse Recipe + minetest.register_craft({ + output = name:sub(2), + recipe = { + {"", def.material, def.material}, + {"", "group:stick", ""}, + {"", "group:stick", ""} + } + }) + end +end + +-- Seed placement +farming.place_seed = function(itemstack, placer, pointed_thing, plantname) + local pt = pointed_thing + -- check if pointing at a node + if not pt then + return + end + if pt.type ~= "node" then + return + end + + local under = minetest.get_node(pt.under) + local above = minetest.get_node(pt.above) + + if minetest.is_protected(pt.under, placer:get_player_name()) then + minetest.record_protection_violation(pt.under, placer:get_player_name()) + return + end + if minetest.is_protected(pt.above, placer:get_player_name()) then + minetest.record_protection_violation(pt.above, placer:get_player_name()) + return + end + + + -- return if any of the nodes is not registered + if not minetest.registered_nodes[under.name] then + return + end + if not minetest.registered_nodes[above.name] then + return + end + + -- check if pointing at the top of the node + if pt.above.y ~= pt.under.y+1 then + return + end + + -- check if you can replace the node above the pointed node + if not minetest.registered_nodes[above.name].buildable_to then + return + end + + -- check if pointing at soil + if minetest.get_item_group(under.name, "soil") < 2 then + return + end + + -- add the node and remove 1 item from the itemstack + minetest.add_node(pt.above, {name = plantname, param2 = 1}) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + return itemstack +end + +-- Register plants +farming.register_plant = function(name, def) + local mname = name:split(":")[1] + local pname = name:split(":")[2] + + -- Check def table + if not def.description then + def.description = "Seed" + end + if not def.inventory_image then + def.inventory_image = "unknown_item.png" + end + if not def.steps then + return nil + end + if not def.minlight then + def.minlight = 1 + end + if not def.maxlight then + def.maxlight = 14 + end + if not def.fertility then + def.fertility = {} + end + + -- Register seed + local g = {seed = 1, snappy = 3, attached_node = 1} + for k, v in pairs(def.fertility) do + g[v] = 1 + end + minetest.register_node(":" .. mname .. ":seed_" .. pname, { + description = def.description, + tiles = {def.inventory_image}, + inventory_image = def.inventory_image, + wield_image = def.inventory_image, + drawtype = "signlike", + groups = g, + paramtype = "light", + paramtype2 = "wallmounted", + walkable = false, + sunlight_propagates = true, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}, + }, + fertility = def.fertility, + sounds = default.node_sound_dirt_defaults({ + dug = {name = "default_grass_footstep", gain = 0.2}, + place = {name = "default_place_node", gain = 0.25}, + }), + + on_place = function(itemstack, placer, pointed_thing) + return farming.place_seed(itemstack, placer, pointed_thing, mname .. ":seed_" .. pname) + end, + }) + + -- Register harvest + minetest.register_craftitem(":" .. mname .. ":" .. pname, { + description = pname:gsub("^%l", string.upper), + inventory_image = mname .. "_" .. pname .. ".png", + }) + + -- Register growing steps + for i=1,def.steps do + local drop = { + items = { + {items = {mname .. ":" .. pname}, rarity = 9 - i}, + {items = {mname .. ":" .. pname}, rarity= 18 - i * 2}, + {items = {mname .. ":seed_" .. pname}, rarity = 9 - i}, + {items = {mname .. ":seed_" .. pname}, rarity = 18 - i * 2}, + } + } + local nodegroups = {snappy = 3, flammable = 2, plant = 1, not_in_creative_inventory = 1, attached_node = 1} + nodegroups[pname] = i + minetest.register_node(mname .. ":" .. pname .. "_" .. i, { + drawtype = "plantlike", + waving = 1, + tiles = {mname .. "_" .. pname .. "_" .. i .. ".png"}, + paramtype = "light", + walkable = false, + buildable_to = true, + drop = drop, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}, + }, + groups = nodegroups, + sounds = default.node_sound_leaves_defaults(), + }) + end + + -- Growing ABM + minetest.register_abm({ + nodenames = {"group:" .. pname, "group:seed"}, + neighbors = {"group:soil"}, + interval = 9, + chance = 20, + action = function(pos, node) + local plant_height = minetest.get_item_group(node.name, pname) + + -- return if already full grown + if plant_height == def.steps then + return + end + + local node_def = minetest.registered_items[node.name] or nil + + -- grow seed + if minetest.get_item_group(node.name, "seed") and node_def.fertility then + local can_grow = false + local soil_node = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z}) + if not soil_node then + return + end + for _, v in pairs(node_def.fertility) do + if minetest.get_item_group(soil_node.name, v) ~= 0 then + can_grow = true + end + end + if can_grow then + minetest.set_node(pos, {name = node.name:gsub("seed_", "") .. "_1"}) + end + return + end + + -- check if on wet soil + pos.y = pos.y - 1 + local n = minetest.get_node(pos) + if minetest.get_item_group(n.name, "soil") < 3 then + return + end + pos.y = pos.y + 1 + + -- check light + local ll = minetest.get_node_light(pos) + + if not ll or ll < def.minlight or ll > def.maxlight then + return + end + + -- grow + minetest.set_node(pos, {name = mname .. ":" .. pname .. "_" .. plant_height + 1}) + end + }) + + -- Return + local r = { + seed = mname .. ":seed_" .. pname, + harvest = mname .. ":" .. pname + } + return r +end diff --git a/mods/farming/depends.txt b/mods/farming/depends.txt new file mode 100644 index 0000000..470ec30 --- /dev/null +++ b/mods/farming/depends.txt @@ -0,0 +1,2 @@ +default +wool diff --git a/mods/farming/hoes.lua b/mods/farming/hoes.lua new file mode 100644 index 0000000..31da19f --- /dev/null +++ b/mods/farming/hoes.lua @@ -0,0 +1,41 @@ +farming.register_hoe(":farming:hoe_wood", { + description = "Wooden Hoe", + inventory_image = "farming_tool_woodhoe.png", + max_uses = 30, + material = "group:wood" +}) + +farming.register_hoe(":farming:hoe_stone", { + description = "Stone Hoe", + inventory_image = "farming_tool_stonehoe.png", + max_uses = 90, + material = "group:stone" +}) + +farming.register_hoe(":farming:hoe_steel", { + description = "Steel Hoe", + inventory_image = "farming_tool_steelhoe.png", + max_uses = 200, + material = "default:steel_ingot" +}) + +farming.register_hoe(":farming:hoe_bronze", { + description = "Bronze Hoe", + inventory_image = "farming_tool_bronzehoe.png", + max_uses = 220, + material = "default:bronze_ingot" +}) + +farming.register_hoe(":farming:hoe_mese", { + description = "Mese Hoe", + inventory_image = "farming_tool_mesehoe.png", + max_uses = 350, + material = "default:mese_crystal" +}) + +farming.register_hoe(":farming:hoe_diamond", { + description = "Diamond Hoe", + inventory_image = "farming_tool_diamondhoe.png", + max_uses = 500, + material = "default:diamond" +}) diff --git a/mods/farming/init.lua b/mods/farming/init.lua new file mode 100644 index 0000000..45370e7 --- /dev/null +++ b/mods/farming/init.lua @@ -0,0 +1,78 @@ +-- Global farming namespace +farming = {} +farming.path = minetest.get_modpath("farming") + +-- Load files +dofile(farming.path .. "/api.lua") +dofile(farming.path .. "/nodes.lua") +dofile(farming.path .. "/hoes.lua") + +-- WHEAT +farming.register_plant("farming:wheat", { + description = "Wheat seed", + inventory_image = "farming_wheat_seed.png", + steps = 8, + minlight = 13, + maxlight = default.LIGHT_MAX, + fertility = {"grassland"} +}) +minetest.register_craftitem("farming:flour", { + description = "Flour", + inventory_image = "farming_flour.png", +}) + +minetest.register_craftitem("farming:bread", { + description = "Bread", + inventory_image = "farming_bread.png", + on_use = minetest.item_eat(5), +}) + +minetest.register_craft({ + type = "shapeless", + output = "farming:flour", + recipe = {"farming:wheat", "farming:wheat", "farming:wheat", "farming:wheat"} +}) + +minetest.register_craft({ + type = "cooking", + cooktime = 15, + output = "farming:bread", + recipe = "farming:flour" +}) + +-- Cotton +farming.register_plant("farming:cotton", { + description = "Cotton seed", + inventory_image = "farming_cotton_seed.png", + steps = 8, + minlight = 13, + maxlight = default.LIGHT_MAX, + fertility = {"grassland", "desert"} +}) + +minetest.register_alias("farming:string", "farming:cotton") + +minetest.register_craft({ + output = "wool:white", + recipe = { + {"farming:cotton", "farming:cotton"}, + {"farming:cotton", "farming:cotton"}, + } +}) + +-- Straw +minetest.register_craft({ + output = "farming:straw 3", + recipe = { + {"farming:wheat", "farming:wheat", "farming:wheat"}, + {"farming:wheat", "farming:wheat", "farming:wheat"}, + {"farming:wheat", "farming:wheat", "farming:wheat"}, + } +}) + +minetest.register_craft({ + output = "farming:wheat 3", + recipe = { + {"farming:straw"}, + } +}) diff --git a/mods/farming/nodes.lua b/mods/farming/nodes.lua new file mode 100644 index 0000000..b55a1aa --- /dev/null +++ b/mods/farming/nodes.lua @@ -0,0 +1,165 @@ +minetest.override_item("default:dirt", { + groups = {crumbly=3, soil=1}, + soil = { + base = "default:dirt", + dry = "farming:soil", + wet = "farming:soil_wet" + } +}) + +minetest.override_item("default:dirt_with_grass", { + groups = {crumbly=3, soil=1}, + soil = { + base = "default:dirt_with_grass", + dry = "farming:soil", + wet = "farming:soil_wet" + } +}) + +minetest.override_item("default:dirt_with_dry_grass", { + groups = {crumbly=3, soil=1}, + soil = { + base = "default:dirt_with_dry_grass", + dry = "farming:soil", + wet = "farming:soil_wet" + } +}) + +minetest.register_node("farming:soil", { + description = "Soil", + tiles = {"default_dirt.png^farming_soil.png", "default_dirt.png"}, + drop = "default:dirt", + groups = {crumbly=3, not_in_creative_inventory=1, soil=2, grassland = 1, field = 1}, + sounds = default.node_sound_dirt_defaults(), + soil = { + base = "default:dirt", + dry = "farming:soil", + wet = "farming:soil_wet" + } +}) + +minetest.register_node("farming:soil_wet", { + description = "Wet Soil", + tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png^farming_soil_wet_side.png"}, + drop = "default:dirt", + groups = {crumbly=3, not_in_creative_inventory=1, soil=3, wet = 1, grassland = 1, field = 1}, + sounds = default.node_sound_dirt_defaults(), + soil = { + base = "default:dirt", + dry = "farming:soil", + wet = "farming:soil_wet" + } +}) + +minetest.override_item("default:desert_sand", { + groups = {crumbly=3, falling_node=1, sand=1, soil = 1}, + soil = { + base = "default:desert_sand", + dry = "farming:desert_sand_soil", + wet = "farming:desert_sand_soil_wet" + } +}) +minetest.register_node("farming:desert_sand_soil", { + description = "Desert Sand Soil", + drop = "default:desert_sand", + tiles = {"farming_desert_sand_soil.png", "default_desert_sand.png"}, + groups = {crumbly=3, not_in_creative_inventory = 1, falling_node=1, sand=1, soil = 2, desert = 1, field = 1}, + sounds = default.node_sound_sand_defaults(), + soil = { + base = "default:desert_sand", + dry = "farming:desert_sand_soil", + wet = "farming:desert_sand_soil_wet" + } +}) + +minetest.register_node("farming:desert_sand_soil_wet", { + description = "Wet Desert Sand Soil", + drop = "default:desert_sand", + tiles = {"farming_desert_sand_soil_wet.png", "farming_desert_sand_soil_wet_side.png"}, + groups = {crumbly=3, falling_node=1, sand=1, not_in_creative_inventory=1, soil=3, wet = 1, desert = 1, field = 1}, + sounds = default.node_sound_sand_defaults(), + soil = { + base = "default:desert_sand", + dry = "farming:desert_sand_soil", + wet = "farming:desert_sand_soil_wet" + } +}) + +minetest.register_node("farming:straw", { + description = "Straw", + tiles = {"farming_straw.png"}, + is_ground_content = false, + groups = {snappy=3, flammable=4}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_abm({ + nodenames = {"group:field"}, + interval = 15, + chance = 4, + action = function(pos, node) + local n_def = minetest.registered_nodes[node.name] or nil + local wet = n_def.soil.wet or nil + local base = n_def.soil.base or nil + local dry = n_def.soil.dry or nil + if not n_def or not n_def.soil or not wet or not base or not dry then + return + end + + pos.y = pos.y + 1 + local nn = minetest.get_node_or_nil(pos) + if not nn or not nn.name then + return + end + local nn_def = minetest.registered_nodes[nn.name] or nil + pos.y = pos.y - 1 + + if nn_def and nn_def.walkable and minetest.get_item_group(nn.name, "plant") == 0 then + minetest.set_node(pos, {name = base}) + return + end + -- check if there is water nearby + local wet_lvl = minetest.get_item_group(node.name, "wet") + if minetest.find_node_near(pos, 3, {"group:water"}) then + -- if it is dry soil and not base node, turn it into wet soil + if wet_lvl == 0 then + minetest.set_node(pos, {name = wet}) + end + else + -- only turn back if there are no unloaded blocks (and therefore + -- possible water sources) nearby + if not minetest.find_node_near(pos, 3, {"ignore"}) then + -- turn it back into base if it is already dry + if wet_lvl == 0 then + -- only turn it back if there is no plant/seed on top of it + if minetest.get_item_group(nn.name, "plant") == 0 and minetest.get_item_group(nn.name, "seed") == 0 then + minetest.set_node(pos, {name = base}) + end + + -- if its wet turn it back into dry soil + elseif wet_lvl == 1 then + minetest.set_node(pos, {name = dry}) + end + end + end + end, +}) + + +for i = 1, 5 do + minetest.override_item("default:grass_"..i, {drop = { + max_items = 1, + items = { + {items = {'farming:seed_wheat'},rarity = 5}, + {items = {'default:grass_1'}}, + } + }}) +end + +minetest.override_item("default:junglegrass", {drop = { + max_items = 1, + items = { + {items = {'farming:seed_cotton'},rarity = 8}, + {items = {'default:junglegrass'}}, + } +}}) diff --git a/mods/farming/textures/farming_bread.png b/mods/farming/textures/farming_bread.png new file mode 100644 index 0000000..0c25678 Binary files /dev/null and b/mods/farming/textures/farming_bread.png differ diff --git a/mods/farming/textures/farming_cotton.png b/mods/farming/textures/farming_cotton.png new file mode 100644 index 0000000..e2bbfd7 Binary files /dev/null and b/mods/farming/textures/farming_cotton.png differ diff --git a/mods/farming/textures/farming_cotton_1.png b/mods/farming/textures/farming_cotton_1.png new file mode 100644 index 0000000..5fc2180 Binary files /dev/null and b/mods/farming/textures/farming_cotton_1.png differ diff --git a/mods/farming/textures/farming_cotton_2.png b/mods/farming/textures/farming_cotton_2.png new file mode 100644 index 0000000..db4f4a3 Binary files /dev/null and b/mods/farming/textures/farming_cotton_2.png differ diff --git a/mods/farming/textures/farming_cotton_3.png b/mods/farming/textures/farming_cotton_3.png new file mode 100644 index 0000000..df3d7a7 Binary files /dev/null and b/mods/farming/textures/farming_cotton_3.png differ diff --git a/mods/farming/textures/farming_cotton_4.png b/mods/farming/textures/farming_cotton_4.png new file mode 100644 index 0000000..f314b07 Binary files /dev/null and b/mods/farming/textures/farming_cotton_4.png differ diff --git a/mods/farming/textures/farming_cotton_5.png b/mods/farming/textures/farming_cotton_5.png new file mode 100644 index 0000000..3e89085 Binary files /dev/null and b/mods/farming/textures/farming_cotton_5.png differ diff --git a/mods/farming/textures/farming_cotton_6.png b/mods/farming/textures/farming_cotton_6.png new file mode 100644 index 0000000..f4bd4fb Binary files /dev/null and b/mods/farming/textures/farming_cotton_6.png differ diff --git a/mods/farming/textures/farming_cotton_7.png b/mods/farming/textures/farming_cotton_7.png new file mode 100644 index 0000000..466d40a Binary files /dev/null and b/mods/farming/textures/farming_cotton_7.png differ diff --git a/mods/farming/textures/farming_cotton_8.png b/mods/farming/textures/farming_cotton_8.png new file mode 100644 index 0000000..f835ba5 Binary files /dev/null and b/mods/farming/textures/farming_cotton_8.png differ diff --git a/mods/farming/textures/farming_cotton_seed.png b/mods/farming/textures/farming_cotton_seed.png new file mode 100644 index 0000000..f1d5b8a Binary files /dev/null and b/mods/farming/textures/farming_cotton_seed.png differ diff --git a/mods/farming/textures/farming_desert_sand_soil.png b/mods/farming/textures/farming_desert_sand_soil.png new file mode 100644 index 0000000..3c09ef0 Binary files /dev/null and b/mods/farming/textures/farming_desert_sand_soil.png differ diff --git a/mods/farming/textures/farming_desert_sand_soil_wet.png b/mods/farming/textures/farming_desert_sand_soil_wet.png new file mode 100644 index 0000000..facc83e Binary files /dev/null and b/mods/farming/textures/farming_desert_sand_soil_wet.png differ diff --git a/mods/farming/textures/farming_desert_sand_soil_wet_side.png b/mods/farming/textures/farming_desert_sand_soil_wet_side.png new file mode 100644 index 0000000..41e5a04 Binary files /dev/null and b/mods/farming/textures/farming_desert_sand_soil_wet_side.png differ diff --git a/mods/farming/textures/farming_flour.png b/mods/farming/textures/farming_flour.png new file mode 100644 index 0000000..b1a9783 Binary files /dev/null and b/mods/farming/textures/farming_flour.png differ diff --git a/mods/farming/textures/farming_soil.png b/mods/farming/textures/farming_soil.png new file mode 100644 index 0000000..5cd3e68 Binary files /dev/null and b/mods/farming/textures/farming_soil.png differ diff --git a/mods/farming/textures/farming_soil_wet.png b/mods/farming/textures/farming_soil_wet.png new file mode 100644 index 0000000..0b4487d Binary files /dev/null and b/mods/farming/textures/farming_soil_wet.png differ diff --git a/mods/farming/textures/farming_soil_wet_side.png b/mods/farming/textures/farming_soil_wet_side.png new file mode 100644 index 0000000..f0b1bd4 Binary files /dev/null and b/mods/farming/textures/farming_soil_wet_side.png differ diff --git a/mods/farming/textures/farming_straw.png b/mods/farming/textures/farming_straw.png new file mode 100644 index 0000000..f9f5fe7 Binary files /dev/null and b/mods/farming/textures/farming_straw.png differ diff --git a/mods/farming/textures/farming_tool_bronzehoe.png b/mods/farming/textures/farming_tool_bronzehoe.png new file mode 100644 index 0000000..2802d11 Binary files /dev/null and b/mods/farming/textures/farming_tool_bronzehoe.png differ diff --git a/mods/farming/textures/farming_tool_diamondhoe.png b/mods/farming/textures/farming_tool_diamondhoe.png new file mode 100644 index 0000000..66f1042 Binary files /dev/null and b/mods/farming/textures/farming_tool_diamondhoe.png differ diff --git a/mods/farming/textures/farming_tool_mesehoe.png b/mods/farming/textures/farming_tool_mesehoe.png new file mode 100644 index 0000000..4534fba Binary files /dev/null and b/mods/farming/textures/farming_tool_mesehoe.png differ diff --git a/mods/farming/textures/farming_tool_steelhoe.png b/mods/farming/textures/farming_tool_steelhoe.png new file mode 100644 index 0000000..d057af2 Binary files /dev/null and b/mods/farming/textures/farming_tool_steelhoe.png differ diff --git a/mods/farming/textures/farming_tool_stonehoe.png b/mods/farming/textures/farming_tool_stonehoe.png new file mode 100644 index 0000000..55d8123 Binary files /dev/null and b/mods/farming/textures/farming_tool_stonehoe.png differ diff --git a/mods/farming/textures/farming_tool_woodhoe.png b/mods/farming/textures/farming_tool_woodhoe.png new file mode 100644 index 0000000..a287152 Binary files /dev/null and b/mods/farming/textures/farming_tool_woodhoe.png differ diff --git a/mods/farming/textures/farming_wheat.png b/mods/farming/textures/farming_wheat.png new file mode 100644 index 0000000..1e0ad3b Binary files /dev/null and b/mods/farming/textures/farming_wheat.png differ diff --git a/mods/farming/textures/farming_wheat_1.png b/mods/farming/textures/farming_wheat_1.png new file mode 100644 index 0000000..c16ad94 Binary files /dev/null and b/mods/farming/textures/farming_wheat_1.png differ diff --git a/mods/farming/textures/farming_wheat_2.png b/mods/farming/textures/farming_wheat_2.png new file mode 100644 index 0000000..baddb4c Binary files /dev/null and b/mods/farming/textures/farming_wheat_2.png differ diff --git a/mods/farming/textures/farming_wheat_3.png b/mods/farming/textures/farming_wheat_3.png new file mode 100644 index 0000000..36ebb19 Binary files /dev/null and b/mods/farming/textures/farming_wheat_3.png differ diff --git a/mods/farming/textures/farming_wheat_4.png b/mods/farming/textures/farming_wheat_4.png new file mode 100644 index 0000000..735ed77 Binary files /dev/null and b/mods/farming/textures/farming_wheat_4.png differ diff --git a/mods/farming/textures/farming_wheat_5.png b/mods/farming/textures/farming_wheat_5.png new file mode 100644 index 0000000..f40b5f0 Binary files /dev/null and b/mods/farming/textures/farming_wheat_5.png differ diff --git a/mods/farming/textures/farming_wheat_6.png b/mods/farming/textures/farming_wheat_6.png new file mode 100644 index 0000000..e9c78e0 Binary files /dev/null and b/mods/farming/textures/farming_wheat_6.png differ diff --git a/mods/farming/textures/farming_wheat_7.png b/mods/farming/textures/farming_wheat_7.png new file mode 100644 index 0000000..cc26ca9 Binary files /dev/null and b/mods/farming/textures/farming_wheat_7.png differ diff --git a/mods/farming/textures/farming_wheat_8.png b/mods/farming/textures/farming_wheat_8.png new file mode 100644 index 0000000..d050093 Binary files /dev/null and b/mods/farming/textures/farming_wheat_8.png differ diff --git a/mods/farming/textures/farming_wheat_seed.png b/mods/farming/textures/farming_wheat_seed.png new file mode 100644 index 0000000..a9031fb Binary files /dev/null and b/mods/farming/textures/farming_wheat_seed.png differ