parent
cd33d406b2
commit
95627f4304
|
@ -2,8 +2,6 @@
|
|||
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local math = math
|
||||
|
||||
local bobber_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
|
@ -36,8 +34,9 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
local pos = player:get_pos()
|
||||
|
||||
local objs = minetest.get_objects_inside_radius(pos, 125)
|
||||
local ent
|
||||
local noent = false
|
||||
local num = 0
|
||||
local ent = nil
|
||||
local noent = true
|
||||
|
||||
local durability = 65
|
||||
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||
|
@ -51,8 +50,11 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
if ent then
|
||||
if ent.player and ent.objtype=="fishing" then
|
||||
if (player:get_player_name() == ent.player) then
|
||||
noent = false
|
||||
if ent._dive == true then
|
||||
local itemname
|
||||
local items
|
||||
local itemcount = 1
|
||||
local pr = PseudoRandom(os.time() * math.random(1, 100))
|
||||
local r = pr:next(1, 100)
|
||||
local fish_values = {85, 84.8, 84.7, 84.5}
|
||||
|
@ -143,8 +145,7 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
end
|
||||
--Destroy bobber.
|
||||
ent.object:remove()
|
||||
noent = false
|
||||
break
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -162,12 +163,11 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
end
|
||||
end
|
||||
--If no bobber or flying_bobber exists then throw bobber.
|
||||
if noent then
|
||||
if noent == true then
|
||||
local playerpos = player:get_pos()
|
||||
local dir = player:get_look_dir()
|
||||
mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name())
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Movement function of bobber
|
||||
|
@ -331,11 +331,13 @@ minetest.register_entity("mcl_fishing:flying_bobber_entity", flying_bobber_ENTIT
|
|||
|
||||
mcl_throwing.register_throwable_object("mcl_fishing:flying_bobber", "mcl_fishing:flying_bobber_entity", 5)
|
||||
|
||||
local function remove_bobber(player)
|
||||
-- If player leaves area, remove bobber.
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local objs = minetest.get_objects_inside_radius(player:get_pos(), 250)
|
||||
|
||||
local ent = nil
|
||||
local noent = true
|
||||
for n = 1, #objs do
|
||||
local ent = objs[n]:get_luaentity()
|
||||
ent = objs[n]:get_luaentity()
|
||||
if ent then
|
||||
if ent.player and ent.objtype=="fishing" then
|
||||
ent.object:remove()
|
||||
|
@ -344,13 +346,26 @@ local function remove_bobber(player)
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- If player leaves area, remove bobber.
|
||||
minetest.register_on_leaveplayer(remove_bobber)
|
||||
end)
|
||||
|
||||
-- If player dies, remove bobber.
|
||||
minetest.register_on_dieplayer(remove_bobber)
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local objs = minetest.get_objects_inside_radius(player:get_pos(), 250)
|
||||
local num = 0
|
||||
local ent = nil
|
||||
local noent = true
|
||||
|
||||
for n = 1, #objs do
|
||||
ent = objs[n]:get_luaentity()
|
||||
if ent then
|
||||
if ent.player and ent.objtype=="fishing" then
|
||||
ent.object:remove()
|
||||
elseif ent._thrower and ent.objtype=="fishing" then
|
||||
ent.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Fishing Rod
|
||||
minetest.register_tool("mcl_fishing:fishing_rod", {
|
||||
|
|
Loading…
Reference in New Issue