1
0
Fork 0

Revert "[mcl_fishing] fix warnings"

This reverts commit a1acf6d3c1.
formspec-v4^2
AFCMS 2021-05-29 16:15:30 +02:00
parent cd33d406b2
commit 95627f4304
1 changed files with 146 additions and 131 deletions

View File

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