Add farming, update mobs, farming, drop and textures
Before Width: | Height: | Size: 586 KiB After Width: | Height: | Size: 558 KiB |
Before Width: | Height: | Size: 231 KiB After Width: | Height: | Size: 230 KiB |
|
@ -107,6 +107,17 @@ Vattic's Terms:
|
|||
|
||||
--- --- ---
|
||||
|
||||
Copyright (C) 2014 HiTeeN
|
||||
|
||||
https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/resource-packs/1242446-faithful-64x64
|
||||
|
||||
You can use my texture pack on the following conditions:
|
||||
You must specify a link on this topic in their publications.
|
||||
If your package contains more than 80% of my textures, you have no right to publish them.
|
||||
|
||||
--- --- ---
|
||||
|
||||
|
||||
JThread:
|
||||
=================================
|
||||
|
||||
|
@ -264,5 +275,3 @@ product, an acknowledgment in the product documentation is required.
|
|||
be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
--- --- ---
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 99 KiB |
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 71 B |
Before Width: | Height: | Size: 1003 B After Width: | Height: | Size: 975 B |
Before Width: | Height: | Size: 991 B After Width: | Height: | Size: 962 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 184 B |
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 181 B |
|
@ -70,8 +70,15 @@ minetest.register_alias("default:pinewood", "default:pine_wood")
|
|||
|
||||
-- Gold nugget
|
||||
minetest.register_alias("default:gold_nugget", "default:gold_ingot")
|
||||
|
||||
-- Sandstone Carved
|
||||
minetest.register_alias("default:sandstonecarved", "default:sandstonesmooth")
|
||||
|
||||
-- Workbench
|
||||
minetest.register_alias("crafting:workbench", "default:workbench")
|
||||
|
||||
-- String
|
||||
minetest.register_alias("default:string", "farming:string")
|
||||
|
||||
-- Hay Bale
|
||||
minetest.register_alias("default:haybale", "farming:straw")
|
||||
|
|
|
@ -289,8 +289,8 @@ minetest.register_craft({
|
|||
output = "default:pole",
|
||||
recipe = {
|
||||
{'', '', 'default:stick'},
|
||||
{'', 'default:stick', 'default:string'},
|
||||
{'default:stick', '', 'default:string'},
|
||||
{'', 'default:stick', 'farming:string'},
|
||||
{'default:stick', '', 'farming:string'},
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -651,7 +651,6 @@ minetest.register_craft({
|
|||
})
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Fuels
|
||||
--
|
||||
|
@ -740,12 +739,8 @@ minetest.register_craft({
|
|||
burntime = 15,
|
||||
})
|
||||
|
||||
|
||||
--
|
||||
--Temporary
|
||||
--
|
||||
minetest.register_craft({
|
||||
output = "default:string",
|
||||
output = "farming:string",
|
||||
recipe = {{"default:paper", "default:paper"}},
|
||||
})
|
||||
|
||||
|
|
|
@ -111,13 +111,6 @@ minetest.register_craftitem("default:sugar", {
|
|||
groups = {materials = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:string",{
|
||||
description = "String",
|
||||
inventory_image = "default_string.png",
|
||||
groups = {materials = 1},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("default:quartz_crystal", {
|
||||
description = "Quartz Crystal",
|
||||
inventory_image = "default_quartz_crystal.png",
|
||||
|
|
|
@ -12,6 +12,7 @@ minetest.register_alias("mapgen_lava_source", "default:lava_source")
|
|||
minetest.register_alias("mapgen_gravel", "default:gravel")
|
||||
minetest.register_alias("mapgen_desert_stone", "default:redsandstone")
|
||||
minetest.register_alias("mapgen_desert_sand", "default:redsand")
|
||||
minetest.register_alias("default:desert_sand", "default:redsand")
|
||||
minetest.register_alias("mapgen_dirt_with_snow", "default:dirt_with_snow")
|
||||
minetest.register_alias("mapgen_snowblock", "default:snowblock")
|
||||
minetest.register_alias("mapgen_snow", "default:snow")
|
||||
|
|
|
@ -253,17 +253,6 @@ minetest.register_node("default:brick", {
|
|||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("default:haybale", {
|
||||
description = "Hay Bale",
|
||||
tiles = {"default_hayblock_top.png", "default_hayblock_top.png", "default_hayblock_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
on_place = minetest.rotate_node,
|
||||
groups = {tree=1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, building = 1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
|
||||
--
|
||||
-- Trees
|
||||
--
|
||||
|
@ -530,6 +519,13 @@ minetest.register_node("default:junglegrass", {
|
|||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
--{items = {'farming:seed_cotton'}, rarity = 8},
|
||||
{items = {'default:junglegrass'}},
|
||||
}
|
||||
},
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, flammable = 2, flora = 1, attached_node = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
|
@ -1195,7 +1191,7 @@ minetest.register_node("default:chest", {
|
|||
"list[current_name;main;0,0;9,3;]"..
|
||||
"list[current_player;main;0,4;9,3;9]"..
|
||||
"list[current_player;main;0,7.5.5;9,1;]")
|
||||
meta:set_string("infotext", "Coffre")
|
||||
meta:set_string("infotext", "Chest")
|
||||
end
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 9*3)
|
||||
|
@ -1259,7 +1255,7 @@ minetest.register_node("default:chest_left", {
|
|||
"list[current_name;main;0,0;9,3;]"..
|
||||
"list[current_player;main;0,4;9,3;9]"..
|
||||
"list[current_player;main;0,7.5.5;9,1;]")
|
||||
meta:set_string("infotext", "Coffre")
|
||||
meta:set_string("infotext", "Chest")
|
||||
hacky_swap_node(p, "default:chest")
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
|
@ -1469,21 +1465,13 @@ minetest.register_node("default:grass", {
|
|||
wield_image = "default_tallgrass.png",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
--drop = {
|
||||
--max_items = 1,
|
||||
--items = {
|
||||
-- {
|
||||
-- -- player will get sapling with 1/20 chance
|
||||
-- items = {'farming:wheat_seed'},
|
||||
-- rarity = 5,
|
||||
-- },
|
||||
-- {
|
||||
-- -- player will get leaves only if he get no saplings,
|
||||
-- -- this is because max_items is 1
|
||||
-- items = {''},
|
||||
-- }
|
||||
-- }
|
||||
--},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{items = {'farming:seed_wheat'}, rarity = 5},
|
||||
{items = {'default:grass'}},
|
||||
}
|
||||
},
|
||||
paramtype = "light",
|
||||
groups = {snappy = 3, flammable = 3,attached_node=1,dig_immediate=3, decorative=1, grass=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
|
|
Before Width: | Height: | Size: 870 B After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 823 B After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 661 B After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 840 B After Width: | Height: | Size: 839 B |
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 323 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 962 B After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 456 B After Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 521 B After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 498 B After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 631 B After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 428 B |
Before Width: | Height: | Size: 327 B After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 168 B After Width: | Height: | Size: 149 B |
Before Width: | Height: | Size: 160 B After Width: | Height: | Size: 142 B |
|
@ -100,5 +100,5 @@ dungeon_loot.seedlings_list = {
|
|||
if minetest.get_modpath("farming") then
|
||||
table.insert(dungeon_loot.consumables_list, {name="farming:bread", chance_and_amount = 10})
|
||||
table.insert(dungeon_loot.seedlings_list, {name="farming:seed_wheat", chance = 1, amount = 10})
|
||||
table.insert(dungeon_loot.seedlings_list, {name="farming:seed_cotton", chance = 20, amount = 5})
|
||||
-- table.insert(dungeon_loot.seedlings_list, {name="farming:seed_cotton", chance = 20, amount = 5})
|
||||
end
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
MultiCraft Game mod: farming
|
||||
==========================
|
||||
See license.txt for license information.
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Originally by PilzAdam (MIT)
|
||||
webdesigner97 (MIT)
|
||||
Various Minetest developers and contributors (MIT)
|
|
@ -0,0 +1,391 @@
|
|||
|
||||
-- Wear out hoes, place soil
|
||||
-- TODO Ignore group:flower
|
||||
farming.registered_plants = {}
|
||||
|
||||
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 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 (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(user:get_player_name())) then
|
||||
-- wear tool
|
||||
local wdef = itemstack:get_definition()
|
||||
itemstack:add_wear(65535/(uses-1))
|
||||
-- tool break sound
|
||||
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
||||
minetest.sound_play(wdef.sound.breaks, {pos = pt.above, gain = 0.5})
|
||||
end
|
||||
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.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,
|
||||
groups = def.groups,
|
||||
sound = {breaks = "default_tool_breaks"},
|
||||
})
|
||||
-- Register its recipe
|
||||
if def.recipe then
|
||||
minetest.register_craft({
|
||||
output = name:sub(2),
|
||||
recipe = def.recipe
|
||||
})
|
||||
elseif def.material then
|
||||
minetest.register_craft({
|
||||
output = name:sub(2),
|
||||
recipe = {
|
||||
{def.material, def.material},
|
||||
{"", "group:stick"},
|
||||
{"", "group:stick"}
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- how often node timers for plants will tick, +/- some random value
|
||||
local function tick(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(166, 286))
|
||||
end
|
||||
-- how often a growth failure tick is retried (e.g. too dark)
|
||||
local function tick_again(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(40, 80))
|
||||
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 itemstack
|
||||
end
|
||||
if pt.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local under = minetest.get_node(pt.under)
|
||||
local above = minetest.get_node(pt.above)
|
||||
|
||||
local player_name = placer and placer:get_player_name() or ""
|
||||
|
||||
if minetest.is_protected(pt.under, player_name) then
|
||||
minetest.record_protection_violation(pt.under, player_name)
|
||||
return
|
||||
end
|
||||
if minetest.is_protected(pt.above, player_name) then
|
||||
minetest.record_protection_violation(pt.above, player_name)
|
||||
return
|
||||
end
|
||||
|
||||
-- return if any of the nodes is not registered
|
||||
if not minetest.registered_nodes[under.name] then
|
||||
return itemstack
|
||||
end
|
||||
if not minetest.registered_nodes[above.name] then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- check if pointing at the top of the node
|
||||
if pt.above.y ~= pt.under.y+1 then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- check if you can replace the node above the pointed node
|
||||
if not minetest.registered_nodes[above.name].buildable_to then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- check if pointing at soil
|
||||
if minetest.get_item_group(under.name, "soil") < 2 then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- add the node and remove 1 item from the itemstack
|
||||
minetest.add_node(pt.above, {name = plantname, param2 = 1})
|
||||
tick(pt.above)
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(player_name)) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
farming.grow_plant = function(pos, elapsed)
|
||||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
local def = minetest.registered_nodes[name]
|
||||
|
||||
if not def.next_plant then
|
||||
-- disable timer for fully grown plant
|
||||
return
|
||||
end
|
||||
|
||||
-- grow seed
|
||||
if minetest.get_item_group(node.name, "seed") and def.fertility then
|
||||
local soil_node = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
if not soil_node then
|
||||
tick_again(pos)
|
||||
return
|
||||
end
|
||||
-- omitted is a check for light, we assume seeds can germinate in the dark.
|
||||
for _, v in pairs(def.fertility) do
|
||||
if minetest.get_item_group(soil_node.name, v) ~= 0 then
|
||||
local placenode = {name = def.next_plant}
|
||||
if def.place_param2 then
|
||||
placenode.param2 = def.place_param2
|
||||
end
|
||||
minetest.swap_node(pos, placenode)
|
||||
if minetest.registered_nodes[def.next_plant].next_plant then
|
||||
tick(pos)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- check if on wet soil
|
||||
local below = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
if minetest.get_item_group(below.name, "soil") < 3 then
|
||||
tick_again(pos)
|
||||
return
|
||||
end
|
||||
|
||||
-- check light
|
||||
local light = minetest.get_node_light(pos)
|
||||
if not light or light < def.minlight or light > def.maxlight then
|
||||
tick_again(pos)
|
||||
return
|
||||
end
|
||||
|
||||
-- grow
|
||||
local placenode = {name = def.next_plant}
|
||||
if def.place_param2 then
|
||||
placenode.param2 = def.place_param2
|
||||
end
|
||||
minetest.swap_node(pos, placenode)
|
||||
|
||||
-- new timer needed?
|
||||
if minetest.registered_nodes[def.next_plant].next_plant then
|
||||
tick(pos)
|
||||
end
|
||||
return
|
||||
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
|
||||
|
||||
farming.registered_plants[pname] = def
|
||||
|
||||
-- Register seed
|
||||
local lbm_nodes = {mname .. ":seed_" .. pname}
|
||||
local g = {seed = 1, snappy = 3, attached_node = 1, flammable = 2}
|
||||
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",
|
||||
place_param2 = def.place_param2 or nil, -- this isn't actually used for placement
|
||||
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({
|
||||
dig = {name = "", gain = 0},
|
||||
dug = {name = "default_grass_footstep", gain = 0.2},
|
||||
place = {name = "default_place_node", gain = 0.25},
|
||||
}),
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local under = pointed_thing.under
|
||||
local node = minetest.get_node(under)
|
||||
local udef = minetest.registered_nodes[node.name]
|
||||
if udef and udef.on_rightclick and
|
||||
not (placer and placer:is_player() and
|
||||
placer:get_player_control().sneak) then
|
||||
return udef.on_rightclick(under, node, placer, itemstack,
|
||||
pointed_thing) or itemstack
|
||||
end
|
||||
|
||||
return farming.place_seed(itemstack, placer, pointed_thing, mname .. ":seed_" .. pname)
|
||||
end,
|
||||
next_plant = mname .. ":" .. pname .. "_1",
|
||||
on_timer = farming.grow_plant,
|
||||
minlight = def.minlight,
|
||||
maxlight = def.maxlight,
|
||||
})
|
||||
|
||||
-- Register harvest
|
||||
minetest.register_craftitem(":" .. mname .. ":" .. pname, {
|
||||
description = pname:gsub("^%l", string.upper),
|
||||
inventory_image = mname .. "_" .. pname .. ".png",
|
||||
groups = def.groups or {flammable = 2},
|
||||
})
|
||||
|
||||
-- Register growing steps
|
||||
for i = 1, def.steps do
|
||||
local base_rarity = 1
|
||||
if def.steps ~= 1 then
|
||||
base_rarity = 8 - (i - 1) * 7 / (def.steps - 1)
|
||||
end
|
||||
local drop = {
|
||||
items = {
|
||||
{items = {mname .. ":" .. pname}, rarity = base_rarity},
|
||||
{items = {mname .. ":" .. pname}, rarity = base_rarity * 2},
|
||||
{items = {mname .. ":seed_" .. pname}, rarity = base_rarity},
|
||||
{items = {mname .. ":seed_" .. pname}, rarity = base_rarity * 2},
|
||||
}
|
||||
}
|
||||
local nodegroups = {snappy = 3, flammable = 2, plant = 1, not_in_creative_inventory = 1, attached_node = 1}
|
||||
nodegroups[pname] = i
|
||||
|
||||
local next_plant = nil
|
||||
|
||||
if i < def.steps then
|
||||
next_plant = mname .. ":" .. pname .. "_" .. (i + 1)
|
||||
lbm_nodes[#lbm_nodes + 1] = mname .. ":" .. pname .. "_" .. i
|
||||
end
|
||||
|
||||
minetest.register_node(":" .. mname .. ":" .. pname .. "_" .. i, {
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
tiles = {mname .. "_" .. pname .. "_" .. i .. ".png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = def.paramtype2 or nil,
|
||||
place_param2 = def.place_param2 or nil,
|
||||
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(),
|
||||
next_plant = next_plant,
|
||||
on_timer = farming.grow_plant,
|
||||
minlight = def.minlight,
|
||||
maxlight = def.maxlight,
|
||||
})
|
||||
end
|
||||
|
||||
-- replacement LBM for pre-nodetimer plants
|
||||
minetest.register_lbm({
|
||||
name = ":" .. mname .. ":start_nodetimer_" .. pname,
|
||||
nodenames = lbm_nodes,
|
||||
action = function(pos, node)
|
||||
tick_again(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Return
|
||||
local r = {
|
||||
seed = mname .. ":seed_" .. pname,
|
||||
harvest = mname .. ":" .. pname
|
||||
}
|
||||
return r
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
default
|
||||
wool
|
||||
stairs
|
|
@ -0,0 +1,36 @@
|
|||
farming.register_hoe(":farming:hoe_wood", {
|
||||
description = "Wooden Hoe",
|
||||
inventory_image = "farming_tool_woodhoe.png",
|
||||
max_uses = 30,
|
||||
material = "group:wood",
|
||||
groups = {flammable = 2},
|
||||
})
|
||||
|
||||
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 = 500,
|
||||
material = "default:steel_ingot"
|
||||
})
|
||||
|
||||
farming.register_hoe(":farming:gold_mese", {
|
||||
description = "Gold Hoe",
|
||||
inventory_image = "farming_tool_goldhoe.png",
|
||||
max_uses = 350,
|
||||
material = "default:gold_ingot"
|
||||
})
|
||||
|
||||
farming.register_hoe(":farming:hoe_diamond", {
|
||||
description = "Diamond Hoe",
|
||||
inventory_image = "farming_tool_diamondhoe.png",
|
||||
max_uses = 1000,
|
||||
material = "default:diamond"
|
||||
|
||||
})
|
|
@ -0,0 +1,140 @@
|
|||
-- 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",
|
||||
paramtype2 = "meshoptions",
|
||||
inventory_image = "farming_wheat_seed.png",
|
||||
steps = 8,
|
||||
minlight = 13,
|
||||
maxlight = default.LIGHT_MAX,
|
||||
fertility = {"grassland"},
|
||||
groups = {food_wheat = 1, flammable = 4},
|
||||
place_param2 = 3,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming:flour", {
|
||||
description = "Flour",
|
||||
inventory_image = "farming_flour.png",
|
||||
groups = {food_flour = 1, flammable = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming:bread", {
|
||||
description = "Bread",
|
||||
inventory_image = "farming_bread.png",
|
||||
on_use = minetest.item_eat(5),
|
||||
groups = {food_bread = 1, flammable = 2},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "farming:flour",
|
||||
recipe = {"farming:wheat", "farming:wheat", "farming:wheat"}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
cooktime = 15,
|
||||
output = "farming:bread",
|
||||
recipe = "farming:flour"
|
||||
})
|
||||
|
||||
-- String
|
||||
|
||||
minetest.register_craftitem("farming:string",{
|
||||
description = "String",
|
||||
inventory_image = "farming_string.png",
|
||||
groups = {materials = 1},
|
||||
})
|
||||
|
||||
-- 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"},
|
||||
groups = {flammable = 4},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "wool:white",
|
||||
recipe = {
|
||||
{"farming:cotton", "farming:cotton"},
|
||||
{"farming:cotton", "farming:cotton"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "farming:string 2",
|
||||
recipe = {
|
||||
{"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"},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- Fuels
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:straw",
|
||||
burntime = 3,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:wheat",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:cotton",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:string",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:hoe_wood",
|
||||
burntime = 5,
|
||||
})
|
|
@ -0,0 +1,26 @@
|
|||
License of source code
|
||||
----------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (C) 2012-2016 PilzAdam
|
||||
Copyright (C) 2014-2016 webdesigner97
|
||||
Copyright (C) 2012-2016 Various Minetest developers and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more details:
|
||||
https://opensource.org/licenses/MIT
|
|
@ -0,0 +1,171 @@
|
|||
minetest.override_item("default:dirt", {
|
||||
soil = {
|
||||
base = "default:dirt",
|
||||
dry = "farming:soil",
|
||||
wet = "farming:soil_wet"
|
||||
}
|
||||
})
|
||||
|
||||
minetest.override_item("default:dirt_with_grass", {
|
||||
soil = {
|
||||
base = "default:dirt_with_grass",
|
||||
dry = "farming:soil",
|
||||
wet = "farming:soil_wet"
|
||||
}
|
||||
})
|
||||
|
||||
minetest.override_item("default:dirt_with_dry_grass", {
|
||||
soil = {
|
||||
base = "default:dirt_with_dry_grass",
|
||||
dry = "farming:soil",
|
||||
wet = "farming:soil_wet"
|
||||
}
|
||||
})
|
||||
|
||||
--[[minetest.override_item("default:dirt_with_rainforest_litter", {
|
||||
soil = {
|
||||
base = "default:dirt_with_rainforest_litter",
|
||||
dry = "farming:soil",
|
||||
wet = "farming:soil_wet"
|
||||
}
|
||||
})
|
||||
|
||||
minetest.override_item("default:dirt_with_coniferous_litter", {
|
||||
soil = {
|
||||
base = "default:dirt_with_coniferous_litter",
|
||||
dry = "farming:soil",
|
||||
wet = "farming:soil_wet"
|
||||
}
|
||||
})]]--
|
||||
|
||||
minetest.register_node("farming:soil", {
|
||||
description = "Soil",
|
||||
tiles = {"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 = {"farming_soil_wet.png", "default_dirt.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_red_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_side.png", "farming_straw_top.png"},
|
||||
is_ground_content = false,
|
||||
groups = {snappy=3, flammable=4, fall_damage_add_percent=-30},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
--[[stairs.register_stair_and_slab(
|
||||
"straw",
|
||||
"farming:straw",
|
||||
{snappy = 3, flammable = 4},
|
||||
{"farming_straw.png"},
|
||||
"Straw Stair",
|
||||
"Straw Slab",
|
||||
default.node_sound_leaves_defaults(),
|
||||
true
|
||||
)]]--
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Farming soil",
|
||||
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,
|
||||
})
|
After Width: | Height: | Size: 253 B |
After Width: | Height: | Size: 394 B |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 499 B After Width: | Height: | Size: 499 B |
After Width: | Height: | Size: 333 B |
After Width: | Height: | Size: 333 B |
After Width: | Height: | Size: 334 B |
After Width: | Height: | Size: 334 B |
After Width: | Height: | Size: 333 B |
After Width: | Height: | Size: 360 B |
After Width: | Height: | Size: 181 B |
After Width: | Height: | Size: 262 B |
After Width: | Height: | Size: 510 B |
After Width: | Height: | Size: 696 B |
After Width: | Height: | Size: 834 B |
After Width: | Height: | Size: 811 B |
After Width: | Height: | Size: 861 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 200 B |
|
@ -25,13 +25,10 @@ if minetest.get_modpath("mobs") then
|
|||
register_food("mobs:chicken_cooked", 6)
|
||||
register_food("mobs:chicken_raw", 2, "", 3)
|
||||
register_food("mobs:chicken_egg_fried", 2)
|
||||
register_food("mobs_monster:rotten_flesh", 1, "", 4)
|
||||
if minetest.get_modpath("bucket") then
|
||||
register_food("mobs:bucket_milk", 3, "bucket:bucket_empty")
|
||||
end
|
||||
else
|
||||
register_food("mobs:meat", 6)
|
||||
register_food("mobs:meat_raw", 3)
|
||||
register_food("mobs:rat_cooked", 5)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,55 +1,47 @@
|
|||
local age = 1 --how old an item has to be before collecting
|
||||
local radius_magnet = 2.5 --radius of item magnet
|
||||
local player_collect_height = 1.3 --added to their pos y value
|
||||
local adjuster_collect = 0.01 --Delay before collecting to visualize moveme
|
||||
|
||||
--Item collection
|
||||
minetest.register_globalstep(function(dtime)
|
||||
--basic settings
|
||||
local age = 1 --how old an item has to be before collecting
|
||||
local radius_magnet = 2.0 --radius of item magnet
|
||||
local radius_collect = 0.3 --radius of collection
|
||||
local player_collect_height = 1.2 --added to their pos y value
|
||||
--collection
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
--don't magnetize to dead players
|
||||
if player:get_hp() > 0 then
|
||||
local pos = player:get_pos()
|
||||
local inv = player:get_inventory()
|
||||
--collection
|
||||
for _,object in ipairs(minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y + player_collect_height,z=pos.z}, radius_collect)) do
|
||||
--radial detection
|
||||
for _,object in ipairs(minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y + player_collect_height,z=pos.z}, radius_magnet)) do
|
||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||
if object:get_luaentity().age > age then
|
||||
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||
|
||||
--collect
|
||||
if object:get_luaentity().collectioner == true and object:get_luaentity().age > age and object:get_luaentity().age > object:get_luaentity().age_stamp + adjuster_collect then
|
||||
if object:get_luaentity().itemstring ~= "" then
|
||||
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||
minetest.sound_play("item_drop_pickup", {
|
||||
pos = pos,
|
||||
max_hear_distance = 50,
|
||||
max_hear_distance = 15,
|
||||
gain = 0.1,
|
||||
})
|
||||
object:get_luaentity().itemstring = ""
|
||||
object:remove()
|
||||
end
|
||||
|
||||
--magnet
|
||||
else
|
||||
--moveto for extreme speed boost
|
||||
local pos1 = pos
|
||||
pos1.y = pos1.y + player_collect_height
|
||||
object:moveto(pos1)
|
||||
object:get_luaentity().collectioner = true
|
||||
object:get_luaentity().age_stamp = object:get_luaentity().age
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--magnet
|
||||
for _,object in ipairs(minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y + player_collect_height,z=pos.z}, radius_magnet)) do
|
||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||
if object:get_luaentity().age > age then
|
||||
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||
local pos1 = pos
|
||||
local pos2 = object:getpos()
|
||||
local vec = {x=pos1.x-pos2.x, y=(pos1.y+player_collect_height)-pos2.y, z=pos1.z-pos2.z}
|
||||
vec.x = pos2.x + (vec.x/2)
|
||||
vec.y = pos2.y + (vec.y/2)
|
||||
vec.z = pos2.z + (vec.z/2)
|
||||
object:moveto(vec)
|
||||
object:get_luaentity().physical_state = false
|
||||
object:get_luaentity().object:set_properties({
|
||||
physical = false
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -59,10 +51,6 @@ end)
|
|||
--This only works in survival
|
||||
if minetest.setting_getbool("creative_mode") == false then
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
local inv
|
||||
if minetest.setting_getbool("creative_mode") and digger and digger:is_player() then
|
||||
inv = digger:get_inventory()
|
||||
end
|
||||
for _,item in ipairs(drops) do
|
||||
local count, name
|
||||
if type(item) == "string" then
|
||||
|
@ -72,52 +60,28 @@ if minetest.setting_getbool("creative_mode") == false then
|
|||
count = item:get_count()
|
||||
name = item:get_name()
|
||||
end
|
||||
if not inv or not inv:contains_item("main", ItemStack(name)) then
|
||||
--if not inv or not inv:contains_item("main", ItemStack(name)) then
|
||||
for i=1,count do
|
||||
local obj = minetest.env:add_item(pos, name)
|
||||
local obj = minetest.add_item(pos, name)
|
||||
if obj ~= nil then
|
||||
--obj:get_luaentity().timer =
|
||||
obj:get_luaentity().collect = true
|
||||
local x = math.random(1, 5)
|
||||
if math.random(1,2) == 1 then
|
||||
x = -x
|
||||
end
|
||||
local z = math.random(1, 5)
|
||||
if math.random(1,2) == 1 then
|
||||
z = -z
|
||||
end
|
||||
obj:setvelocity({x=1/x, y=obj:get_velocity().y, z=1/z})
|
||||
obj:get_luaentity().age = 0.6
|
||||
-- FIXME this doesnt work for deactiveted objects
|
||||
if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
|
||||
minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
|
||||
obj:remove()
|
||||
end, obj)
|
||||
end
|
||||
end
|
||||
obj:get_luaentity().age = age
|
||||
obj:setvelocity({x=math.random(-3,3), y=math.random(2,5), z=math.random(-3,3)})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--throw items using player's velocity
|
||||
function minetest.item_drop(itemstack, dropper, pos)
|
||||
--do this to prevent dispensers and other things using this function from breaking
|
||||
|
||||
--check if player
|
||||
local is_player = false
|
||||
if dropper then
|
||||
if minetest.get_player_information(dropper:get_player_name()) then
|
||||
is_player = true
|
||||
end
|
||||
end
|
||||
--Throw items using player's velocity
|
||||
function minetest.item_drop(itemstack, dropper, pos)
|
||||
|
||||
--if player then do modified item drop
|
||||
if dropper and is_player == true then
|
||||
if dropper and minetest.get_player_information(dropper:get_player_name()) then
|
||||
local v = dropper:get_look_dir()
|
||||
local vel = dropper:get_player_velocity()
|
||||
local p = {x=pos.x, y=pos.y+1.3, z=pos.z}
|
||||
|
||||
local p = {x=pos.x, y=pos.y+player_collect_height, z=pos.z}
|
||||
local item = itemstack:to_string()
|
||||
local obj = core.add_item(p, item)
|
||||
if obj then
|
||||
|
@ -126,25 +90,21 @@ function minetest.item_drop(itemstack, dropper, pos)
|
|||
v.z = (v.z*5)+vel.z
|
||||
obj:setvelocity(v)
|
||||
obj:get_luaentity().dropped_by = dropper:get_player_name()
|
||||
--obj:get_luaentity().collect = true
|
||||
itemstack:clear()
|
||||
return itemstack
|
||||
end
|
||||
else --if machine then use default item drop to not break mods - also extend reach
|
||||
--machine
|
||||
else
|
||||
local v = dropper:get_look_dir()
|
||||
local p = {x=pos.x+v.x, y=pos.y+1.5+v.y, z=pos.z+v.z}
|
||||
local cs = itemstack:get_count()
|
||||
if dropper:get_player_control().sneak then
|
||||
cs = 1
|
||||
end
|
||||
local item = itemstack:take_item(cs)
|
||||
local obj = core.add_item(p, item)
|
||||
local item = itemstack:to_string()
|
||||
local obj = minetest.add_item({x=pos.x,y=pos.y+1.5,z=pos.z}, item) --{x=pos.x+v.x,y=pos.y+v.y+1.5,z=pos.z+v.z}
|
||||
if obj then
|
||||
v.x = v.x*5
|
||||
v.y = v.y*5 + 2
|
||||
v.z = v.z*5
|
||||
v.x = (v.x*5)
|
||||
v.y = (v.y*5)
|
||||
v.z = (v.z*5)
|
||||
obj:setvelocity(v)
|
||||
obj:get_luaentity().dropped_by = dropper:get_player_name()
|
||||
obj:get_luaentity().dropped_by = nil
|
||||
itemstack:clear()
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
hp_max = 15,
|
||||
armor = 100,
|
||||
knock_back = 1,
|
||||
water_damage = 0,
|
||||
lava_damage = 10,
|
||||
fall_damage = 5,
|
||||
makes_footstep_sound = true,
|
||||
|
|
|
@ -21,7 +21,7 @@ mobs:register_mob("mobs_animal:chicken", {
|
|||
drops = {
|
||||
{name = "mobs:chicken_raw", chance = 1, min = 1, max = 1},
|
||||
},
|
||||
water_damage = 1,
|
||||
water_damage = 0,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
fall_damage = 0,
|
||||
|
@ -35,7 +35,7 @@ mobs:register_mob("mobs_animal:chicken", {
|
|||
run_start = 60,
|
||||
run_end = 80,
|
||||
},
|
||||
follow = {"farming:seed_wheat", "farming:seed_cotton"},
|
||||
follow = {"farming:seed_wheat"},
|
||||
view_range = 5,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
|
|
|
@ -31,7 +31,7 @@ mobs:register_mob("mobs_animal:cow", {
|
|||
{name = "mobs:leather", chance = 2, min = 1, max = 1},
|
||||
{name = "mobs:leather", chance = 2, min = 1, max = 1}
|
||||
},
|
||||
water_damage = 1,
|
||||
water_damage = 0,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
animation = {
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
hp_max = 10,
|
||||
armor = 100,
|
||||
knock_back = 2,
|
||||
water_damage = 0,
|
||||
lava_damage = 5,
|
||||
fall_damage = 4,
|
||||
makes_footstep_sound = true,
|
||||
|
@ -107,6 +108,7 @@ mobs:register_egg("mobs_animal:wolf", "Wolf", "wool_grey.png", 1)
|
|||
hp_max = 25,
|
||||
armor = 100,
|
||||
knock_back = 2,
|
||||
water_damage = 0,
|
||||
lava_damage = 5,
|
||||
fall_damage = 5,
|
||||
makes_footstep_sound = true,
|
||||
|
|
|
@ -26,9 +26,9 @@ mobs:register_mob("mobs_animal:kitten", {
|
|||
run_velocity = 2,
|
||||
runaway = true,
|
||||
jump = false,
|
||||
--drops = {
|
||||
-- {name = "farming:string", chance = 1, min = 1, max = 1},
|
||||
--},
|
||||
drops = {
|
||||
{name = "farming:string", chance = 1, min = 1, max = 1},
|
||||
},
|
||||
water_damage = 1,
|
||||
lava_damage = 5,
|
||||
fear_height = 3,
|
||||
|
|
|
@ -35,7 +35,7 @@ mobs:register_mob("mobs_animal:pig", {
|
|||
{name = "mobs:pork_raw",
|
||||
chance = 2, min = 1, max = 1}
|
||||
},
|
||||
water_damage = 1,
|
||||
water_damage = 0,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
fear_height = 2,
|
||||
|
|
|
@ -22,6 +22,7 @@ local all_colours = {
|
|||
for _, col in pairs(all_colours) do
|
||||
|
||||
mobs:register_mob("mobs_animal:sheep_"..col[1], {
|
||||
stepheight = 0.6,
|
||||
type = "animal",
|
||||
passive = true,
|
||||
hp_min = 6,
|
||||
|
@ -51,7 +52,7 @@ for _, col in pairs(all_colours) do
|
|||
{name = "mobs:meat_raw", chance = 2, min = 1, max = 1},
|
||||
{name = "wool:"..col[1], chance = 1, min = 1, max = 1}
|
||||
},
|
||||
water_damage = 1,
|
||||
water_damage = 0,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
animation = {
|
||||
|
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
@ -28,9 +28,9 @@ mobs:register_mob("mobs_monster:spider", {
|
|||
jump = true,
|
||||
view_range = 15,
|
||||
floats = 0,
|
||||
-- drops = {
|
||||
-- {name = "farming:string",
|
||||
-- chance = 1, min = 1, max = 2}, },
|
||||
drops = {
|
||||
{name = "farming:string",
|
||||
chance = 1, min = 1, max = 2}, },
|
||||
water_damage = 5,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
|
@ -103,9 +103,9 @@ mobs:register_mob("mobs_monster:small_spider", {
|
|||
jump = true,
|
||||
view_range = 10,
|
||||
floats = 0,
|
||||
-- drops = {
|
||||
-- {name = "farming:string",
|
||||
-- chance = 1, min = 1, max = 1}, },
|
||||
drops = {
|
||||
{name = "farming:string",
|
||||
chance = 1, min = 1, max = 1}, },
|
||||
water_damage = 5,
|
||||
lava_damage = 5,
|
||||
light_damage = 0,
|
||||
|
@ -161,7 +161,6 @@ minetest.register_node(":mobs:cobweb", {
|
|||
liquid_range = 0,
|
||||
walkable = false,
|
||||
groups = {snappy = 1, disable_jump = 1},
|
||||
--drop = "farming:cotton",
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
mobs = {
|
||||
mod = "redo",
|
||||
version = "20181220",
|
||||
version = "20190402",
|
||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||
}
|
||||
|
||||
|
@ -448,9 +448,39 @@ function mobs:line_of_sight(entity, pos1, pos2, stepsize)
|
|||
return mob_class.line_of_sight(entity, pos1, pos2, stepsize)
|
||||
end
|
||||
|
||||
function mob_class:attempt_flight_correction()
|
||||
|
||||
if self:flight_check() then return true end
|
||||
|
||||
-- We are not flying in what we are supposed to.
|
||||
-- See if we can find intended flight medium and return to it
|
||||
local pos = self.object:get_pos()
|
||||
local searchnodes = self.fly_in
|
||||
|
||||
if type(searchnodes) == "string" then
|
||||
searchnodes = {self.fly_in}
|
||||
end
|
||||
|
||||
local flyable_nodes = minetest.find_nodes_in_area(
|
||||
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
|
||||
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
|
||||
searchnodes)
|
||||
|
||||
if #flyable_nodes < 1 then
|
||||
return false
|
||||
end
|
||||
|
||||
local escape_target = flyable_nodes[math.random(1,#flyable_nodes)]
|
||||
local escape_direction = vector.direction(pos, escape_target)
|
||||
|
||||
self.object:set_velocity(
|
||||
vector.multiply(escape_direction, self.run_velocity))
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- are we flying in what we are suppose to? (taikedz)
|
||||
function mob_class:flight_check(pos_w)
|
||||
function mob_class:flight_check()
|
||||
|
||||
local def = minetest.registered_nodes[self.standing_in]
|
||||
|
||||
|
@ -483,6 +513,57 @@ function mob_class:flight_check(pos_w)
|
|||
end
|
||||
|
||||
|
||||
-- if self.stay_near set then check periodically for nodes and turn to face/move
|
||||
function mob_class:do_stay_near()
|
||||
|
||||
if not self.stay_near then return false end
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
local searchnodes = self.stay_near[1]
|
||||
local chance = self.stay_near[2] or 10
|
||||
|
||||
if random(1, chance) > 1 then
|
||||
return false
|
||||
end
|
||||
|
||||
if type(searchnodes) == "string" then
|
||||
searchnodes = {self.stay_near[1]}
|
||||
end
|
||||
|
||||
local r = self.view_range
|
||||
local nearby_nodes = minetest.find_nodes_in_area(
|
||||
{x = pos.x - r, y = pos.y - 1, z = pos.z - r},
|
||||
{x = pos.x + r, y = pos.y + 1, z = pos.z + r},
|
||||
searchnodes)
|
||||
|
||||
if #nearby_nodes < 1 then
|
||||
return false
|
||||
end
|
||||
|
||||
local target = nearby_nodes[math.random(1, #nearby_nodes)]
|
||||
local direction = vector.direction(pos, target)
|
||||
|
||||
local vec = {
|
||||
x = target.x - pos.x,
|
||||
z = target.z - pos.z
|
||||
}
|
||||
|
||||
yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate
|
||||
|
||||
if target.x > pos.x then
|
||||
yaw = yaw + pi
|
||||
end
|
||||
|
||||
yaw = self:set_yaw(yaw, 4)
|
||||
|
||||
self:set_animation("walk")
|
||||
|
||||
self:set_velocity(self.walk_velocity)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
-- custom particle effects
|
||||
local effect = function(pos, amount, texture, min_size, max_size, radius, gravity, glow)
|
||||
|
||||
|
@ -533,7 +614,6 @@ function mob_class:update_tag()
|
|||
nametag = self.nametag,
|
||||
nametag_color = col
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -970,6 +1050,7 @@ local entity_physics = function(pos, radius)
|
|||
obj_pos = objs[n]:get_pos()
|
||||
|
||||
dist = get_distance(pos, obj_pos)
|
||||
|
||||
if dist < 1 then dist = 1 end
|
||||
|
||||
local damage = floor((4 / dist) * radius)
|
||||
|
@ -1804,8 +1885,10 @@ function mob_class:follow_flop()
|
|||
|
||||
-- swimmers flop when out of their element, and swim again when back in
|
||||
if self.fly then
|
||||
|
||||
local s = self.object:get_pos()
|
||||
if not self:flight_check(s) then
|
||||
|
||||
if not self:attempt_flight_correction() then
|
||||
|
||||
self.state = "flop"
|
||||
self.object:set_velocity({x = 0, y = -5, z = 0})
|
||||
|
@ -2168,7 +2251,7 @@ function mob_class:do_states(dtime)
|
|||
local p_y = floor(p2.y + 1)
|
||||
local v = self.object:get_velocity()
|
||||
|
||||
if self:flight_check(s) then
|
||||
if self:flight_check() then
|
||||
|
||||
if me_y < p_y then
|
||||
|
||||
|
@ -2565,7 +2648,7 @@ end
|
|||
|
||||
if tr then
|
||||
if weapon_def.original_description then
|
||||
weapon:add_wear(toolranks.new_afteruse(weapon, hitter, nil, {wear = wear}))
|
||||
toolranks.new_afteruse(weapon, hitter, nil, {wear = wear})
|
||||
end
|
||||
else
|
||||
weapon:add_wear(wear)
|
||||
|
@ -2804,6 +2887,12 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||
end
|
||||
end
|
||||
|
||||
-- force current model into mob
|
||||
self.mesh = def.mesh
|
||||
self.base_mesh = def.mesh
|
||||
self.collisionbox = def.collisionbox
|
||||
self.selectionbox = def.selectionbox
|
||||
|
||||
-- select random texture, set model and size
|
||||
if not self.base_texture then
|
||||
|
||||
|
@ -2874,7 +2963,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||
end
|
||||
|
||||
if self.health == 0 then
|
||||
self.health = random (self.hp_min, self.hp_max)
|
||||
self.health = random(self.hp_min, self.hp_max)
|
||||
end
|
||||
|
||||
-- pathfinding init
|
||||
|
@ -2917,7 +3006,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||
|
||||
-- run after_activate
|
||||
if def.after_activate then
|
||||
def:after_activate(staticdata, def, dtime)
|
||||
def.after_activate(self, staticdata, def, dtime)
|
||||
end
|
||||
|
||||
if use_cmi then
|
||||
|
@ -3108,6 +3197,7 @@ function mob_class:on_step(dtime)
|
|||
|
||||
self:do_runaway_from(self)
|
||||
|
||||
self:do_stay_near()
|
||||
end
|
||||
|
||||
|
||||
|
@ -3217,6 +3307,7 @@ minetest.register_entity(name, setmetatable({
|
|||
runaway_from = def.runaway_from,
|
||||
owner_loyal = def.owner_loyal,
|
||||
pushable = def.pushable,
|
||||
stay_near = def.stay_near,
|
||||
|
||||
on_spawn = def.on_spawn,
|
||||
|
||||
|
@ -3291,7 +3382,8 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
|||
end
|
||||
|
||||
minetest.log("action",
|
||||
string.format("[mobs] Chance setting for %s changed to %s (total: %s)", name, chance, aoc))
|
||||
string.format("[mobs] Chance setting for %s changed to %s (total: %s)",
|
||||
name, chance, aoc))
|
||||
|
||||
end
|
||||
|
||||
|
@ -3910,12 +4002,12 @@ function mobs:protect(self, clicker)
|
|||
end
|
||||
|
||||
if self.tamed == false then
|
||||
minetest.chat_send_player(name, S("Not tamed!"))
|
||||
minetest.chat_send_player(name, "Not tamed!")
|
||||
return true -- false
|
||||
end
|
||||
|
||||
if self.protected == true then
|
||||
minetest.chat_send_player(name, S("Already protected!"))
|
||||
minetest.chat_send_player(name, "Already protected!")
|
||||
return true -- false
|
||||
end
|
||||
|
||||
|
@ -3943,12 +4035,9 @@ local mob_sta = {}
|
|||
-- feeding, taming and breeding (thanks blert2112)
|
||||
function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
||||
|
||||
if not self.follow then
|
||||
return false
|
||||
end
|
||||
|
||||
-- can eat/tame with item in hand
|
||||
if self:follow_holding(clicker) then
|
||||
if self.follow
|
||||
and self:follow_holding(clicker) then
|
||||
|
||||
-- if not in creative then take item
|
||||
if not mobs.is_creative(clicker:get_player_name()) then
|
||||
|
@ -3991,6 +4080,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||
|
||||
-- feed and tame
|
||||
self.food = (self.food or 0) + 1
|
||||
|
||||
if self.food >= feed_count then
|
||||
|
||||
self.food = 0
|
||||
|
@ -3999,8 +4089,6 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||
self.horny = true
|
||||
end
|
||||
|
||||
self.gotten = false
|
||||
|
||||
if tame then
|
||||
|
||||
if self.tamed == false then
|
||||
|
@ -4017,7 +4105,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||
end
|
||||
|
||||
-- make sound when fed so many times
|
||||
self:mob_sound(self.sounds.random)
|
||||
--self:mob_sound(self.sounds.random)
|
||||
end
|
||||
|
||||
return true
|
||||
|
|
|
@ -75,9 +75,9 @@ minetest.register_tool("mobs:lasso", {
|
|||
minetest.register_craft({
|
||||
output = "mobs:lasso",
|
||||
recipe = {
|
||||
{"default:string", "", "default:string"},
|
||||
{"farming:string", "", "farming:string"},
|
||||
{"", "default:diamond", ""},
|
||||
{"default:string", "", "default:string"},
|
||||
{"farming:string", "", "farming:string"},
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 89 B |
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 91 B |
Before Width: | Height: | Size: 86 B After Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 82 B After Width: | Height: | Size: 81 B |
Before Width: | Height: | Size: 89 B After Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 84 B After Width: | Height: | Size: 83 B |
Before Width: | Height: | Size: 94 B After Width: | Height: | Size: 92 B |
Before Width: | Height: | Size: 84 B After Width: | Height: | Size: 81 B |