1 --Quick definition of hoes
2 local material = {"wood","stone","iron","gold","diamond"}
4 local function till_soil(pos)
5 local is_dirt = minetest.get_node_group(minetest.get_node(pos).name, "farm_tillable") > 0
6 local is_farmland = minetest.get_node_group(minetest.get_node(pos).name, "farmland") > 0
7 if is_dirt and not is_farmland then
8 minetest.sound_play("dirt",{pos=pos})
9 minetest.set_node(pos,{name="farming:farmland_dry"})
14 for level,material in pairs(material) do
15 local wear = 100*(6-level)
17 if material == "wood" then
19 dirt = {times={[1]=0.4,[2]=1.5,[3]=3,[4]=6,[5]=12}, uses=59, maxlevel=1},
20 snow = {times={[1]=0.4,[2]=1.5,[3]=3,[4]=6,[5]=12}, uses=59, maxlevel=1},
21 grass = {times={[1]=0.45,[2]=1.5,[3]=3,[4]=6,[5]=12}, uses=59, maxlevel=1},
22 sand = {times={[1]=0.4,[2]=1.5,[3]=3,[4]=6,[5]=12}, uses=59, maxlevel=1},
25 elseif material == "stone" then
27 dirt = {times={[1]=0.2,[2]=0.2,[3]=1.5,[4]=3,[5]=6}, uses=131, maxlevel=1},
28 snow = {times={[1]=0.2,[2]=0.2,[3]=1.5,[4]=3,[5]=6}, uses=131, maxlevel=1},
29 grass = {times={[1]=0.25,[2]=0.25,[3]=1.5,[4]=3,[5]=6}, uses=131, maxlevel=1},
30 sand = {times={[1]=0.2,[2]=0.2,[3]=1.5,[4]=3,[5]=6}, uses=131, maxlevel=1},
33 elseif material == "iron" then
35 dirt = {times={[1]=0.15,[2]=0.15,[3]=0.15,[4]=1.5,[5]=3}, uses=250, maxlevel=1},
36 snow = {times={[1]=0.15,[2]=0.15,[3]=0.15,[4]=1.5,[5]=3}, uses=250, maxlevel=1},
37 grass = {times={[1]=0.15,[2]=0.15,[3]=0.15,[4]=1.5,[5]=3}, uses=250, maxlevel=1},
38 sand = {times={[1]=0.15,[2]=0.15,[3]=0.15,[4]=1.5,[5]=3}, uses=250, maxlevel=1},
41 elseif material == "gold" then
43 dirt = {times={[1]=0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=32, maxlevel=1},
44 snow = {times={[1]=0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=32, maxlevel=1},
45 grass = {times={[1]=0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=32, maxlevel=1},
46 sand = {times={[1]=0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=32, maxlevel=1},
49 elseif material == "diamond" then
51 dirt = {times={[1]= 0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=1561, maxlevel=1},
52 snow = {times={[1]= 0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=1561, maxlevel=1},
53 grass = {times={[1]= 0.15,[2]=0.15,[3]=0.15,[4]=0.15,[5]=1.5}, uses=1561, maxlevel=1},
54 sand = {times={[1]= 0.1,[2]=0.1,[3]=0.1,[4]=0.1,[5]=1.5}, uses=1561, maxlevel=1},
58 minetest.register_tool("farming:"..material.."hoe", {
59 description = material:gsub("^%l", string.upper).." Hoe",
60 inventory_image = material.."hoe.png",
62 --full_punch_interval = 1.2,
65 damage_groups = {damage=damage},
67 sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
68 groups = {flammable = 2, tool=1 },
70 on_place = function(itemstack, placer, pointed_thing)
71 local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name]
72 local sneak = placer:get_player_control().sneak
74 if not sneak and noddef.on_rightclick then
75 minetest.item_place(itemstack, placer, pointed_thing)
79 local tilled = till_soil(pointed_thing.under)
80 if tilled == true then
81 if minetest.registered_nodes[minetest.get_node(vector.new(pointed_thing.under.x,pointed_thing.under.y+1,pointed_thing.under.z)).name].buildable_to then
82 minetest.dig_node(vector.new(pointed_thing.under.x,pointed_thing.under.y+1,pointed_thing.under.z))
84 itemstack:add_wear(wear)
87 local damage = itemstack:get_wear()
89 if damage <= 0 and tilled == true then
90 minetest.sound_play("tool_break",{object=placer})
95 minetest.register_craft({
96 output = "farming:"..material.."hoe",
98 {"","main:"..material, "main:"..material},
99 {"","main:stick", ""},
100 {"", "main:stick", ""}
103 minetest.register_craft({
104 output = "farming:"..material.."hoe",
106 {"main:"..material,"main:"..material, ""},
107 {"","main:stick", ""},
108 {"", "main:stick", ""}
113 local farmland = {"wet","dry"}
115 for level,dryness in pairs(farmland) do
116 local coloring = 160/level
118 minetest.register_node("farming:farmland_"..dryness,{
119 description = "Farmland",
121 drawtype = "nodebox",
122 sounds = main.dirtSound(),
123 --paramtype2 = "wallmounted",
126 --{xmin, ymin, zmin, xmax, ymax, zmax}
128 fixed = {-0.5, -0.5, -0.5, 0.5, 6/16, 0.5},
130 wetness = math.abs(level-2),
133 --{xmin, ymin, zmin, xmax, ymax, zmax}
135 fixed = {-0.5, -0.5, -0.5, 0.5, 6/16, 0.5},
137 tiles = {"dirt.png^farmland.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring},
138 groups = {dirt = 1, soft = 1, shovel = 1, hand = 1, soil=1,farmland=1},
144 --drying and wetting abm for farmland
145 minetest.register_abm({
146 label = "Farmland Wet",
147 nodenames = {"farming:farmland_dry"},
148 neighbors = {"air","group:crop"},
151 action = function(pos)
152 local found = minetest.find_node_near(pos, 3, {"main:water","main:waterflow"})
154 minetest.set_node(pos,{name="farming:farmland_wet"})
156 minetest.set_node(pos,{name="main:dirt"})
160 minetest.register_abm({
161 label = "Farmland dry",
162 nodenames = {"farming:farmland_wet"},
166 action = function(pos)
167 local found = minetest.find_node_near(pos, 3, {"main:water","main:waterflow"})
169 minetest.set_node(pos,{name="farming:farmland_dry"})
175 minetest.register_node("farming:grass", {
176 description = "Tall Grass",
177 drawtype = "plantlike",
182 is_ground_content = false,
183 tiles = {"tallgrass.png"},
184 paramtype2 = "degrotate",
186 groups = {leaves = 1, plant = 1, axe = 1, hand = 0,dig_immediate=1,attached_node=1},
187 sounds = main.grassSound(),
190 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 4 / 16, 4 / 16}
196 -- Only drop if using a tool whose name is identical to one
199 items = {"farming:seeds"},
200 -- Whether all items in the dropped item list inherit the
201 -- hardware coloring palette color from the dug node.
202 -- Default is 'false'.
203 --inherit_color = true,
212 minetest.register_abm({
213 label = "crops grow",
214 nodenames = {"group:crops"},
215 neighbors = {"group:farmland"},
218 action = function(pos)
220 local node_under = minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name
221 local wetness = minetest.registered_nodes[node_under].wetness
223 if wetness == 0 or not wetness then
227 local node = minetest.get_node(pos).name
228 local stage = minetest.registered_nodes[node].grow_stage
229 if stage < wheat_max then
230 minetest.set_node(pos,{name="farming:wheat_"..stage+1})
234 for i = 0,wheat_max do
236 if i == wheat_max then
241 -- Only drop if using a tool whose name is identical to one
244 items = {"farming:wheat"},
245 -- Whether all items in the dropped item list inherit the
246 -- hardware coloring palette color from the dug node.
247 -- Default is 'false'.
248 --inherit_color = true,
251 -- Only drop if using a tool whose name is identical to one
254 items = {"farming:seeds"},
255 -- Whether all items in the dropped item list inherit the
256 -- hardware coloring palette color from the dug node.
257 -- Default is 'false'.
258 --inherit_color = true,
266 minetest.register_node("farming:wheat_"..i, {
267 description = "Wheat Stage "..i,
268 drawtype = "plantlike",
273 is_ground_content = false,
274 tiles = {"wheat_stage_"..i..".png"},
275 paramtype2 = "degrotate",
278 groups = {leaves = 1, plant = 1, axe = 1, hand = 0,dig_immediate=1,attached_node=1,crops=1},
279 sounds = main.grassSound(),
282 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 4 / 16, 4 / 16}
289 minetest.register_craftitem("farming:seeds", {
290 description = "Seeds",
291 inventory_image = "seeds.png",
292 on_place = function(itemstack, placer, pointed_thing)
293 if pointed_thing.type ~= "node" then
296 local pb = pointed_thing.above
297 if minetest.get_node_group(minetest.get_node(vector.new(pb.x,pb.y-1,pb.z)).name, "farmland") == 0 or minetest.get_node(pointed_thing.above).name ~= "air" then
301 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
303 local fakestack = itemstack
306 retval = fakestack:set_name("farming:wheat_0")
311 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
312 itemstack:set_name("farming:seeds")
315 minetest.sound_play("leaves", {pos=pointed_thing.above, gain = 1.0})
323 minetest.register_decoration({
324 deco_type = "simple",
325 place_on = "main:grass",
328 --biomes = {"grassland"},
329 decoration = "farming:grass",
334 minetest.register_craftitem("farming:wheat", {
335 description = "Wheat",
336 inventory_image = "wheat_harvested.png",
340 minetest.register_craftitem("farming:bread", {
341 description = "Bread",
342 inventory_image = "bread.png",
346 minetest.register_craftitem("farming:toast", {
347 description = "Toast",
348 inventory_image = "bread.png^[colorize:black:100",
352 minetest.register_craft({
353 output = "farming:bread",
355 {"farming:wheat", "farming:wheat", "farming:wheat"}
360 minetest.register_craft({
362 output = "farming:toast",
363 recipe = "farming:bread",