2021-03-22 11:29:28 -04:00
|
|
|
minetest.register_craftitem("fl_wildlife:nametag", {
|
|
|
|
description = "Name Tag",
|
|
|
|
inventory_image = "farlands_nametag.png",
|
|
|
|
--groups = {flammable = 2, nametag = 1},
|
2021-04-18 21:28:16 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_entity("fl_wildlife:chicken_egg_entity", {
|
|
|
|
initial_properties = {
|
2021-10-27 23:04:48 -04:00
|
|
|
physical = true,
|
2021-04-18 21:28:16 -04:00
|
|
|
--stepheight = 0.4,
|
|
|
|
collide_with_objects = true,
|
|
|
|
pointable = false,
|
2021-10-27 23:04:48 -04:00
|
|
|
collisionbox = {-0.01, -0.01, -0.01, 0.01, 0.01, 0.01},
|
2021-04-18 21:28:16 -04:00
|
|
|
visual = "wielditem",
|
|
|
|
textures = {"fl_wildlife:chicken_egg"},
|
|
|
|
visual_size = {x=0.2, y=0.2},
|
|
|
|
static_save = true,
|
|
|
|
--damage_texture_modifier = "^[colorize:#FF000040"
|
|
|
|
},
|
|
|
|
|
|
|
|
--[[
|
|
|
|
on_activate = function(self, staticdata, dtime_s)
|
|
|
|
local test = 1
|
|
|
|
end,
|
|
|
|
--]]
|
2021-10-27 23:04:48 -04:00
|
|
|
on_step = function(self, dtime, moveresult)
|
2021-04-18 21:28:16 -04:00
|
|
|
if not self.active_time then self.active_time = 0 end
|
|
|
|
self.active_time = self.active_time + dtime
|
|
|
|
if self.active_time >= 10 then
|
|
|
|
self.object:remove() --edge case prevention
|
|
|
|
end
|
|
|
|
|
2021-10-27 23:04:48 -04:00
|
|
|
if moveresult.collides then
|
|
|
|
local pos = vector.new(0,0,0)
|
|
|
|
if moveresult.collisions[1].type == "node" then
|
|
|
|
pos = moveresult.collisions[1].node_pos
|
|
|
|
elseif moveresult.collisions[1].type == "object" then
|
|
|
|
pos = moveresult.collisions[1].object:get_pos()
|
2021-04-18 21:28:16 -04:00
|
|
|
end
|
2021-10-27 23:04:48 -04:00
|
|
|
local vec = vector.normalize(moveresult.collisions[1].old_velocity)
|
|
|
|
minetest.add_entity(vector.add(pos, vector.multiply(vec, -1)), "fl_wildlife:chicken")
|
2021-04-18 21:28:16 -04:00
|
|
|
self.object:remove()
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craftitem("fl_wildlife:chicken_egg", {
|
|
|
|
description = "chicken egg",
|
|
|
|
inventory_image = "farlands_chicken_egg.png",
|
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
2021-10-27 22:36:31 -04:00
|
|
|
--minetest.chat_send_all("used")
|
2021-04-18 21:28:16 -04:00
|
|
|
if pointed_thing.type ~= "node" then return end
|
|
|
|
|
|
|
|
--note that this spawning location calculation is terrible and only works sometimes
|
|
|
|
local pt_pos = pointed_thing.under
|
|
|
|
pt_pos.y = pt_pos.y + 0.5
|
|
|
|
local p_pos = user:get_pos()
|
|
|
|
p_pos.y = p_pos.y + 1.5
|
2021-10-27 22:36:31 -04:00
|
|
|
--minetest.chat_send_all("player_pos: " .. minetest.pos_to_string(p_pos, 1))
|
|
|
|
--minetest.chat_send_all("pointed_thing_pos: " .. minetest.pos_to_string(pt_pos, 1))
|
2021-04-18 21:28:16 -04:00
|
|
|
local obj = minetest.add_entity(p_pos, "fl_wildlife:chicken_egg_entity")
|
|
|
|
obj:set_velocity(vector.subtract(pt_pos, p_pos))
|
|
|
|
obj:set_acceleration(vector.subtract(pt_pos, p_pos))
|
|
|
|
--[[
|
|
|
|
pt_pos.y = pt_pos.y + 1
|
|
|
|
|
|
|
|
if minetest.get_node(pt_pos).name ~= "air" then return end
|
|
|
|
|
|
|
|
if math.random(100) > 50 then
|
|
|
|
minetest.add_entity(pt_pos, "fl_wildlife:chicken")
|
|
|
|
end
|
|
|
|
--]]
|
|
|
|
if not minetest.settings:get_bool("creative_mode") then
|
|
|
|
itemstack:take_item(1)
|
|
|
|
end
|
|
|
|
return itemstack
|
|
|
|
end,
|
2021-11-05 19:33:37 -04:00
|
|
|
groups = {not_in_creative_inventory = 1},
|
2021-04-25 18:51:29 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craftitem("fl_wildlife:leather", {
|
|
|
|
description = "leather",
|
|
|
|
inventory_image = "farlands_leather.png",
|
2021-06-12 21:25:54 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craftitem(":fl_bucket:milk", {
|
|
|
|
description = "milk bucket",
|
|
|
|
stack_max = 1,
|
|
|
|
inventory_image = "farlands_bucket_milk.png",
|
|
|
|
groups = {bucket = 1},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craftitem("fl_wildlife:raw_riverfish", {
|
2021-06-26 23:12:18 -04:00
|
|
|
description = "raw riverfish",
|
2021-06-12 21:25:54 -04:00
|
|
|
inventory_image = "farlands_raw_riverfish.png",
|
|
|
|
})
|
|
|
|
|
2021-06-26 23:12:18 -04:00
|
|
|
minetest.register_craftitem("fl_wildlife:cooked_riverfish", {
|
|
|
|
description = "cooked riverfish",
|
|
|
|
inventory_image = "farlands_cooked_riverfish.png",
|
2021-07-04 22:37:05 -04:00
|
|
|
on_use = minetest.item_eat(5),
|
2021-06-26 23:12:18 -04:00
|
|
|
})
|
|
|
|
|
2021-06-12 21:25:54 -04:00
|
|
|
minetest.register_craftitem(":fl_bucket:riverfish", {
|
|
|
|
description = "bucket of riverfish",
|
|
|
|
inventory_image = "(farlands_bucket_water.png^[noalpha)^[brighten",
|
|
|
|
on_place = function(itemstack, user, pointed_thing)
|
|
|
|
local pos
|
|
|
|
|
|
|
|
if pointed_thing.type == "node" then
|
|
|
|
local node = minetest.get_node_or_nil(pointed_thing.under)
|
|
|
|
local def = node and minetest.registered_nodes[node.name]
|
|
|
|
|
|
|
|
if not user:get_player_control().sneak and def and def.on_rightclick then
|
|
|
|
return def.on_rightclick(pointed_thing.under, node, user, itemstack)
|
|
|
|
end
|
|
|
|
|
|
|
|
if def and def.buildable_to then pos = pointed_thing.under
|
|
|
|
else
|
|
|
|
pos = pointed_thing.above
|
|
|
|
local anode = minetest.get_node_or_nil(pos)
|
2021-06-27 13:01:59 -04:00
|
|
|
if not minetest.registered_nodes[anode.name]
|
|
|
|
or not minetest.registered_nodes[anode.name].buildable_to then
|
|
|
|
return itemstack
|
|
|
|
end
|
2021-06-12 21:25:54 -04:00
|
|
|
end
|
|
|
|
elseif pointed_thing.type == "object" then
|
|
|
|
pos = pointed_thing.ref:get_pos()
|
|
|
|
else return end
|
|
|
|
|
|
|
|
minetest.add_entity(pos, "fl_wildlife:riverfish")
|
|
|
|
minetest.set_node(pos, {name = "fl_liquids:water_source"})
|
|
|
|
return ItemStack("fl_bucket:bucket")
|
|
|
|
end,
|
2021-03-22 22:49:21 -04:00
|
|
|
})
|