Add Large Cactus with Fruit and Strawberry

master
Juraj Vajda 2021-03-25 18:58:18 -04:00
parent b38ad104ae
commit 1b224cab3a
26 changed files with 334 additions and 21 deletions

View File

@ -165,7 +165,15 @@ Cocoa is planted on jungletree using cocoa bean and fully grown cocoa will drop
### Kiwi Tree
Kiwi tree can be found in savana and drops kiwi fruit and sapling from leaves. This tree adds new tree trunk and wood planks also (including stairs and slabs).
Kiwi tree can be found in savana and drops kiwi fruit and sapling from leaves. This tree adds new tree trunk and wood planks also (including stairs and slabs). Kiwi fruit will grow back on the tree after harvested from the tree enabling farming Kiwis. Can be placed as a decoration.
### Large Cactus with Fruit
Cactus with Fruits can be found in desert. You will need axe to harvest the fruit. Fruit will grow back on cactus after harvested - enabling harvesting Dragon Fruits. Can be placed as a decoration. Seedling can be crafted for more farming and harvesting.
### Strawberry
Strawberries can be found in coniferous forest. They drop seeds and strawberries.
## Seeds
@ -310,6 +318,10 @@ GNU Lesser General Public License v2.1 or later (see included LICENSE file)
- x_farming_kiwi_tree.png
- x_farming_kiwi_tree_top.png
- x_farming_kiwi_tree_wood.png
- x_farming_strawberry_1.png (modified by SaKeL)
- x_farming_strawberry_2.png (modified by SaKeL)
- x_farming_strawberry_3.png (modified by SaKeL)
- x_farming_strawberry_4.png (modified by SaKeL)
**LGPL-2.1-or-later, by SaKeL**
@ -337,6 +349,15 @@ GNU Lesser General Public License v2.1 or later (see included LICENSE file)
- x_farming_kiwi.png
- x_farming_kiwi_fruit.png
- x_farming_kiwi_sapling.png
- x_farming_cactus_fruit_bottom.png
- x_farming_cactus_fruit_sides.png
- x_farming_cactus_fruit_top.png
- x_farming_cactus_fruit_item.png
- x_farming_large_cactus_with_fruit_seedling.png
- x_farming_large_cactus_with_fruit_seedling
- x_farming_strawberry_seed.png
- x_farming_strawberry.png
**MIT**
- x_farming_kiwi_leaves.png

18
api.lua
View File

@ -7,8 +7,6 @@ x_farming = {
green = "#98E698"
}
}
MINLIGHT = 13
MAXLIGHT = default.LIGHT_MAX
-- how often node timers for plants will tick, +/- some random value
function x_farming.tick(pos)
@ -112,7 +110,7 @@ function x_farming.grow_block(pos, elapsed)
-- check light
local light = minetest.get_node_light(pos)
if not light or light < MINLIGHT or light > MAXLIGHT then
if not light or light < 13 or light > default.LIGHT_MAX then
x_farming.tick_short(pos)
return
end
@ -127,7 +125,7 @@ end
function x_farming.grow_kiwi_tree(pos)
local path = minetest.get_modpath("x_farming") ..
"/schematics/kiwi_tree_from_sapling.mts"
"/schematics/x_farming_kiwi_tree_from_sapling.mts"
minetest.place_schematic({x = pos.x - 2, y = pos.y, z = pos.z - 2},
path, "random", nil, false)
end
@ -147,4 +145,14 @@ function x_farming.grow_sapling(pos)
minetest.pos_to_string(pos))
x_farming.grow_kiwi_tree(pos)
end
end
end
-- Grow Large Cactus
function x_farming.grow_large_cactus(pos)
print(dump(pos))
local path = minetest.get_modpath("x_farming") ..
"/schematics/x_farming_large_cactus_from_seedling.mts"
minetest.place_schematic({x = pos.x, y = pos.y, z = pos.z},
path, "random", nil, false, "place_center_x, place_center_z")
end

205
cactus.lua Normal file
View File

@ -0,0 +1,205 @@
-- Large cactus
minetest.register_decoration({
name = "x_farming:large_cactus",
deco_type = "schematic",
place_on = {"default:desert_sand"},
sidelen = 16,
noise_params = {
offset = -0.0003,
scale = 0.0009,
spread = {x = 200, y = 200, z = 200},
seed = 230,
octaves = 3,
persist = 0.6
},
biomes = {"desert"},
y_max = 31000,
y_min = 4,
schematic = minetest.get_modpath("x_farming") .. "/schematics/x_farming_large_cactus.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
})
minetest.register_node("x_farming:cactus_fruit", {
description = "Dragon Fruit",
inventory_image = "x_farming_cactus_fruit_sides.png",
is_ground_content = false,
tiles = {
"x_farming_cactus_fruit_top.png",
"x_farming_cactus_fruit_bottom.png",
"x_farming_cactus_fruit_sides.png",
"x_farming_cactus_fruit_sides.png",
"x_farming_cactus_fruit_sides.png",
"x_farming_cactus_fruit_sides.png"
},
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, -0.25, 0.25, 0.0625, 0.25},
}
},
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.0625, 0.25},
},
drop = {
max_items = 1, -- Maximum number of items to drop.
items = { -- Choose max_items randomly from this list.
{
items = {"x_farming:cactus_fruit_item"}, -- Items to drop.
rarity = 1, -- Probability of dropping is 1 / rarity.
}
},
},
groups = {choppy = 3, flammable = 2, not_in_creative_inventory=1, leafdecay = 3, leafdecay_drop = 1},
sounds = default.node_sound_wood_defaults(),
after_dig_node = function(pos, oldnode, oldmetadata, digger)
print('oldnode.param2', oldnode.param2)
if oldnode.param2 == 20 then
print('starting timer ...')
minetest.set_node(pos, {name = "x_farming:cactus_fruit_mark"})
minetest.get_node_timer(pos):start(math.random(300, 1500))
end
end,
})
minetest.register_node("x_farming:cactus_fruit_mark", {
description = "Cactus Fruit Marker",
inventory_image = "x_farming_cactus_fruit_sides.png^default_invisible_node_overlay.png",
wield_image = "x_farming_cactus_fruit_sides.png^default_invisible_node_overlay.png",
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
groups = {not_in_creative_inventory = 1},
on_timer = function(pos, elapsed)
local n = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
if n.name ~= "default:cactus" then
minetest.remove_node(pos)
elseif minetest.get_node_light(pos) < 11 then
minetest.get_node_timer(pos):start(200)
else
minetest.set_node(pos, {name = "x_farming:cactus_fruit", param2 = 20})
end
end
})
minetest.register_node("x_farming:cactus_fruit_item", {
description = "Dragon Fruit" .. "\n" .. minetest.colorize(x_farming.colors.brown, "Hunger: 2"),
drawtype = "plantlike",
tiles = {"x_farming_cactus_fruit_item.png"},
inventory_image = "x_farming_cactus_fruit_item.png",
on_use = minetest.item_eat(2),
sounds = default.node_sound_leaves_defaults(),
after_place_node = function(pos, placer, itemstack)
minetest.set_node(pos, {name = "x_farming:cactus_fruit"})
end,
})
minetest.register_node("x_farming:large_cactus_with_fruit_seedling", {
description = "Large Cactus with Fruit Seedling",
drawtype = "plantlike",
tiles = {"x_farming_large_cactus_with_fruit_seedling.png"},
inventory_image = "x_farming_large_cactus_with_fruit_seedling.png",
wield_image = "x_farming_large_cactus_with_fruit_seedling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {
-5 / 16, -0.5, -5 / 16,
5 / 16, 0.5, 5 / 16
}
},
groups = {choppy = 3, dig_immediate = 3, attached_node = 1},
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
"x_farming:large_cactus_with_fruit_seedling",
{x = -3, y = 0, z = -3},
{x = 3, y = 6, z = 3},
4)
return itemstack
end,
on_construct = function(pos)
-- Normal cactus farming adds 1 cactus node by ABM,
-- interval 12s, chance 83.
-- Consider starting with 5 cactus nodes. We make sure that growing a
-- large cactus is not a faster way to produce new cactus nodes.
-- Confirmed by experiment, when farming 5 cacti, on average 1 new
-- cactus node is added on average every
-- 83 / 5 = 16.6 intervals = 16.6 * 12 = 199.2s.
-- Large cactus contains on average 14 cactus nodes.
-- 14 * 199.2 = 2788.8s.
-- Set random range to average to 2789s.
minetest.get_node_timer(pos):start(math.random(1859, 3719))
end,
on_timer = function(pos)
local node_under = minetest.get_node_or_nil(
{x = pos.x, y = pos.y - 1, z = pos.z})
if not node_under then
-- Node under not yet loaded, try later
minetest.get_node_timer(pos):start(300)
return
end
if minetest.get_item_group(node_under.name, "sand") == 0 then
-- Seedling dies
minetest.remove_node(pos)
return
end
local light_level = minetest.get_node_light(pos)
if not light_level or light_level < 13 then
-- Too dark for growth, try later in case it's night
minetest.get_node_timer(pos):start(300)
return
end
minetest.log("action", "A large cactus seedling grows into a large" ..
"cactus at ".. minetest.pos_to_string(pos))
x_farming.grow_large_cactus(pos)
end,
})
default.register_leafdecay({
trunks = {"default:cactus"},
leaves = {"x_farming:cactus_fruit"},
radius = 1,
})
minetest.register_craft({
output = "x_farming:large_cactus_with_fruit_seedling",
recipe = {
{"", "x_farming:cactus_fruit_item", ""},
{"x_farming:cactus_fruit_item", "default:large_cactus_seedling", "x_farming:cactus_fruit_item"},
{"", "x_farming:cactus_fruit_item", ""},
}
})
minetest.register_craft({
type = "fuel",
recipe = "x_farming:large_cactus_with_fruit_seedling",
burntime = 5,
})
minetest.register_craft({
type = "fuel",
recipe = "x_farming:cactus_fruit_item",
burntime = 10,
})

View File

@ -17,6 +17,8 @@ dofile(path.."/cocoa.lua")
dofile(path.."/seeds.lua")
dofile(path.."/crafting.lua")
dofile(path.."/kiwi_tree.lua")
dofile(path.."/cactus.lua")
dofile(path.."/strawberry.lua")
-- hbhunger
if x_farming.hbhunger ~= nil then
if hbhunger.register_food ~= nil then

View File

@ -20,7 +20,7 @@ minetest.register_decoration({
biomes = {"savanna"},
y_max = 31000,
y_min = 1,
schematic = minetest.get_modpath("x_farming") .. "/schematics/kiwi_tree.mts",
schematic = minetest.get_modpath("x_farming") .. "/schematics/x_farming_kiwi_tree.mts",
flags = "place_center_x, place_center_z",
rotation = "random",
})
@ -95,8 +95,8 @@ minetest.register_node("x_farming:kiwi_sapling", {
"x_farming:kiwi_sapling",
-- minp, maxp to be checked, relative to sapling pos
-- minp_relative.y = 1 because sapling pos has been checked
{x = -3, y = 1, z = -3},
{x = 3, y = 6, z = 3},
{x = -2, y = 1, z = -2},
{x = 2, y = 4, z = 2},
-- maximum interval of interior volume check
4)
@ -132,10 +132,6 @@ minetest.register_node("x_farming:kiwi", {
leafdecay = 3, leafdecay_drop = 1, food_apple = 1, not_in_creative_inventory=1},
sounds = default.node_sound_leaves_defaults(),
after_place_node = function(pos, placer, itemstack)
minetest.set_node(pos, {name = "x_farming:kiwi", param2 = 1})
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldnode.param2 == 0 then
minetest.set_node(pos, {name = "x_farming:kiwi_mark"})

View File

@ -3,8 +3,8 @@ farming.register_plant("x_farming:melon", {
description = "Melon Seed",
inventory_image = "x_farming_melon_seed.png",
steps = 8,
minlight = MINLIGHT,
maxlight = MAXLIGHT,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {flammable = 4},
place_param2 = 3,

View File

@ -21,8 +21,8 @@ farming.register_plant("x_farming:pumpkin", {
description = "Pumpkin Seed",
inventory_image = "x_farming_pumpkin_seed.png",
steps = 8,
minlight = MINLIGHT,
maxlight = MAXLIGHT,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland", "desert"},
groups = {flammable = 4},
place_param2 = 3,

View File

@ -36,4 +36,10 @@ hbhunger.register_food("x_farming:cookie", 2)
hbhunger.register_food("x_farming:chocolate", 3)
-- kiwi
hbhunger.register_food("x_farming:kiwi_fruit", 2)
hbhunger.register_food("x_farming:kiwi_fruit", 2)
-- Dragon fruit
hbhunger.register_food("x_farming:cactus_fruit_item", 2)
-- Strawberry
hbhunger.register_food("x_farming:strawberry", 2)

View File

@ -9,7 +9,7 @@ local M = {name = "x_farming:kiwi_leaves", prob = 255}
local F = {name = "x_farming:kiwi", prob = 127}
local Y = {name = "x_farming:kiwi_tree", prob = 255, force_place = true}
mts_save("kiwi_tree", {
mts_save("x_farming_kiwi_tree", {
size = {x = 5, y = 5, z = 5},
data = {
_, _, _, _, _,
@ -46,7 +46,7 @@ mts_save("kiwi_tree", {
-- Kiwi tree from sapling
mts_save("kiwi_tree_from_sapling", {
mts_save("x_farming_kiwi_tree_from_sapling", {
size = {x = 5, y = 4, z = 5},
data = {
_, _, _, _, _,
@ -74,4 +74,39 @@ mts_save("kiwi_tree_from_sapling", {
_, _, _, _, _,
_, _, _, _, _,
}
})
})
-- Mapgen Large cactus with Fruit
local C = {name = "default:cactus", prob = 255, param2 = 20}
local R = {name = "default:cactus", prob = 255, param2 = 20, force_place = true}
local E = {name = "default:cactus", prob = 127, param2 = 20}
local FR = {name = "x_farming:cactus_fruit", prob = 170, param2 = 20}
mts_save("x_farming_large_cactus", {
size = {x = 7, y = 7, z = 1},
data = {
_, _, _, R, _, _, _,
_, _, _, C, _, _, _,
C, C, C, C, C, C, C,
C, FR, FR, C, FR, FR, C,
E, _, _, C, _, _, E,
_, _, _, C, _, _, _,
_, _, _, FR, _, _, _,
},
})
-- Large cactus with Fruit from Seedling
mts_save("x_farming_large_cactus_from_seedling", {
size = {x = 7, y = 6, z = 1},
data = {
_, _, _, R, _, _, _,
C, C, C, C, C, C, C,
C, FR, FR, C, FR, FR, C,
E, _, _, C, _, _, E,
_, _, _, C, _, _, _,
_, _, _, FR, _, _, _,
},
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 669 KiB

After

Width:  |  Height:  |  Size: 494 KiB

40
strawberry.lua Normal file
View File

@ -0,0 +1,40 @@
-- STRAWBERRY
farming.register_plant("x_farming:strawberry", {
description = "Strawberry Seed",
paramtype2 = "meshoptions",
inventory_image = "x_farming_strawberry_seed.png",
steps = 4,
minlight = 13,
maxlight = default.LIGHT_MAX,
fertility = {"grassland"},
groups = {flammable = 4},
place_param2 = 0
})
-- needed
minetest.override_item("x_farming:strawberry", {
description = "Strawberry" .. "\n" .. minetest.colorize(x_farming.colors.brown, "Hunger: 2"),
on_use = minetest.item_eat(2),
})
-- decorations
for length = 1, 4 do
minetest.register_decoration({
name = "x_farming:strawberry_"..length,
deco_type = "simple",
place_on = {"default:dirt_with_coniferous_litter"},
sidelen = 16,
noise_params = {
offset = 0,
scale = 0.01,
spread = {x = 100, y = 100, z = 100},
seed = 2,
octaves = 3,
persist = 0.7
},
biomes = {"coniferous_forest"},
y_max = 30,
y_min = 1,
decoration = "x_farming:strawberry_"..length,
})
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B