2019-07-31 05:47:40 +02:00
--Fishing Rod, Bobber, and Flying Bobber mechanics and Bobber artwork by Rootyjr.
2021-05-29 16:12:33 +02:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
2024-05-22 20:55:07 +02:00
local FISHING_ROD_DURABILITY = 65
2019-03-08 00:00:09 +01:00
2019-07-31 04:22:28 +02:00
local bobber_ENTITY = {
physical = false ,
timer = 0 ,
textures = { " mcl_fishing_bobber.png " } ,
visual_size = { x = 0.5 , y = 0.5 } ,
collisionbox = { 0.45 , 0.45 , 0.45 , 0.45 , 0.45 , 0.45 } ,
pointable = false ,
2019-11-19 01:19:47 +01:00
static_save = false ,
2019-07-31 04:22:28 +02:00
_lastpos = { } ,
_dive = false ,
2020-11-09 18:59:08 +01:00
_waittime = nil ,
_time = 0 ,
2019-07-31 04:22:28 +02:00
player = nil ,
_oldy = nil ,
objtype = " fishing " ,
}
2021-01-04 20:23:14 +01:00
local fish = function ( itemstack , player , pointed_thing )
if pointed_thing and pointed_thing.type == " node " then
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node ( pointed_thing.under )
if player and not player : get_player_control ( ) . sneak then
if minetest.registered_nodes [ node.name ] and minetest.registered_nodes [ node.name ] . on_rightclick then
return minetest.registered_nodes [ node.name ] . on_rightclick ( pointed_thing.under , node , player , itemstack ) or itemstack
end
end
end
2021-05-29 16:15:30 +02:00
local pos = player : get_pos ( )
2021-01-04 20:23:14 +01:00
2021-05-29 16:15:30 +02:00
local objs = minetest.get_objects_inside_radius ( pos , 125 )
local num = 0
local ent = nil
local noent = true
2021-11-03 19:36:57 +01:00
2024-05-22 20:55:07 +02:00
local durability = FISHING_ROD_DURABILITY
2021-05-29 16:15:30 +02:00
local unbreaking = mcl_enchanting.get_enchantment ( itemstack , " unbreaking " )
if unbreaking > 0 then
durability = durability * ( unbreaking + 1 )
end
2021-05-22 23:49:03 +02:00
2021-05-29 16:15:30 +02:00
--Check for bobber if so handle.
for n = 1 , # objs do
ent = objs [ n ] : get_luaentity ( )
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 }
local junk_values = { 10 , 8.1 , 6.1 , 4.2 }
local luck_of_the_sea = math.min ( mcl_enchanting.get_enchantment ( itemstack , " luck_of_the_sea " ) , 3 )
local index = luck_of_the_sea + 1
2024-03-24 05:46:01 +01:00
local fish_value = fish_values [ index ] - mcl_luck.get_luck ( ent.player )
local junk_value = junk_values [ index ] + fish_value - mcl_luck.get_luck ( ent.player )
2021-05-29 16:15:30 +02:00
if r <= fish_value then
-- Fish
items = mcl_loot.get_loot ( {
items = {
{ itemstring = " mcl_fishing:fish_raw " , weight = 60 } ,
{ itemstring = " mcl_fishing:salmon_raw " , weight = 25 } ,
{ itemstring = " mcl_fishing:clownfish_raw " , weight = 2 } ,
{ itemstring = " mcl_fishing:pufferfish_raw " , weight = 13 } ,
2021-12-07 17:57:18 +01:00
} ,
stacks_min = 1 ,
stacks_max = 1 ,
2021-05-29 16:15:30 +02:00
} , pr )
2022-06-11 22:07:57 +02:00
awards.unlock ( player : get_player_name ( ) , " mcl:fishyBusiness " )
2021-05-29 16:15:30 +02:00
elseif r <= junk_value then
-- Junk
items = mcl_loot.get_loot ( {
items = {
{ itemstring = " mcl_core:bowl " , weight = 10 } ,
{ itemstring = " mcl_fishing:fishing_rod " , weight = 2 , wear_min = 6554 , wear_max = 65535 } , -- 10%-100% damage
{ itemstring = " mcl_mobitems:leather " , weight = 10 } ,
{ itemstring = " mcl_armor:boots_leather " , weight = 10 , wear_min = 6554 , wear_max = 65535 } , -- 10%-100% damage
{ itemstring = " mcl_mobitems:rotten_flesh " , weight = 10 } ,
{ itemstring = " mcl_core:stick " , weight = 5 } ,
{ itemstring = " mcl_mobitems:string " , weight = 5 } ,
{ itemstring = " mcl_potions:water " , weight = 10 } ,
{ itemstring = " mcl_mobitems:bone " , weight = 10 } ,
2022-12-22 17:26:13 +01:00
{ itemstring = " mcl_mobitems:ink_sac " , weight = 1 , amount_min = 10 , amount_max = 10 } ,
2021-05-29 16:15:30 +02:00
{ itemstring = " mcl_mobitems:string " , weight = 10 } , -- TODO: Tripwire Hook
2022-12-29 07:29:25 +01:00
{ itemstring = " mcl_bamboo:bamboo " , weight = 10 } ,
2021-12-07 17:57:18 +01:00
} ,
stacks_min = 1 ,
stacks_max = 1 ,
2021-05-29 16:15:30 +02:00
} , pr )
else
-- Treasure
items = mcl_loot.get_loot ( {
items = {
2021-12-07 17:57:18 +01:00
{ itemstring = " mcl_bows:bow " , wear_min = 49144 , wear_max = 65535 , func = function ( stack , pr )
mcl_enchanting.enchant_randomly ( stack , 30 , true , false , false , pr )
end } , -- 75%-100% damage
{ itemstring = " mcl_books:book " , func = function ( stack , pr )
mcl_enchanting.enchant_randomly ( stack , 30 , true , true , false , pr )
end } ,
{ itemstring = " mcl_fishing:fishing_rod " , wear_min = 49144 , wear_max = 65535 , func = function ( stack , pr )
mcl_enchanting.enchant_randomly ( stack , 30 , true , false , false , pr )
end } , -- 75%-100% damage
2021-05-29 16:15:30 +02:00
{ itemstring = " mcl_mobs:nametag " , } ,
{ itemstring = " mcl_mobitems:saddle " , } ,
{ itemstring = " mcl_flowers:waterlily " , } ,
2022-06-25 23:42:52 +02:00
{ itemstring = " mcl_mobitems:nautilus_shell " , } ,
2021-12-07 17:57:18 +01:00
} ,
stacks_min = 1 ,
stacks_max = 1 ,
2021-05-29 16:15:30 +02:00
} , pr )
end
local item
if # items >= 1 then
item = ItemStack ( items [ 1 ] )
else
item = ItemStack ( )
end
local inv = player : get_inventory ( )
if inv : room_for_item ( " main " , item ) then
inv : add_item ( " main " , item )
2022-06-11 22:07:57 +02:00
if item : get_name ( ) == " mcl_mobitems:leather " then
awards.unlock ( player : get_player_name ( ) , " mcl:killCow " )
end
2021-05-29 16:15:30 +02:00
else
minetest.add_item ( pos , item )
end
2021-11-03 19:36:57 +01:00
if mcl_experience.throw_xp then
2023-06-19 13:49:58 +02:00
minetest.after ( 0.7 , mcl_experience.throw_xp , pos , math.random ( 1 , 6 ) )
2021-05-29 16:15:30 +02:00
end
2020-07-10 16:08:40 +02:00
2021-05-29 16:15:30 +02:00
if not minetest.is_creative_enabled ( player : get_player_name ( ) ) then
local idef = itemstack : get_definition ( )
itemstack : add_wear ( 65535 / durability ) -- 65 uses
2024-05-22 20:55:07 +02:00
tt.reload_itemstack_description ( itemstack ) -- update tooltip
2021-05-29 16:15:30 +02:00
if itemstack : get_count ( ) == 0 and idef.sound and idef.sound . breaks then
minetest.sound_play ( idef.sound . breaks , { pos = player : get_pos ( ) , gain = 0.5 } , true )
end
2019-07-31 04:22:28 +02:00
end
end
2021-05-29 16:15:30 +02:00
--Check if object is on land.
local epos = ent.object : get_pos ( )
epos.y = math.floor ( epos.y )
local node = minetest.get_node ( epos )
local def = minetest.registered_nodes [ node.name ]
if def.walkable then
if not minetest.is_creative_enabled ( player : get_player_name ( ) ) then
local idef = itemstack : get_definition ( )
itemstack : add_wear ( ( 65535 / durability ) * 2 ) -- if so and not creative then wear double like in MC.
2024-05-22 20:55:07 +02:00
tt.reload_itemstack_description ( itemstack ) -- update tooltip
2021-05-29 16:15:30 +02:00
if itemstack : get_count ( ) == 0 and idef.sound and idef.sound . breaks then
minetest.sound_play ( idef.sound . breaks , { pos = player : get_pos ( ) , gain = 0.5 } , true )
end
2019-07-31 04:22:28 +02:00
end
end
2021-05-29 16:15:30 +02:00
--Destroy bobber.
ent.object : remove ( )
2023-06-19 13:49:58 +02:00
minetest.sound_play ( " reel " , { object = player , gain = 0.1 , max_hear_distance = 16 } , true )
2021-05-29 16:15:30 +02:00
return itemstack
2019-07-31 04:22:28 +02:00
end
end
end
end
2021-05-29 16:15:30 +02:00
--Check for flying bobber.
for n = 1 , # objs do
ent = objs [ n ] : get_luaentity ( )
if ent then
if ent._thrower and ent.objtype == " fishing " then
if player : get_player_name ( ) == ent._thrower then
noent = false
break
end
2019-07-31 04:22:28 +02:00
end
end
end
2021-05-29 16:15:30 +02:00
--If no bobber or flying_bobber exists then throw bobber.
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
2019-07-31 04:22:28 +02:00
end
-- Movement function of bobber
local bobber_on_step = function ( self , dtime )
self.timer = self.timer + dtime
local epos = self.object : get_pos ( )
epos.y = math.floor ( epos.y )
local node = minetest.get_node ( epos )
local def = minetest.registered_nodes [ node.name ]
2020-07-05 03:28:02 +02:00
2019-11-19 01:19:47 +01:00
--If we have no player, remove self.
if self.player == nil or self.player == " " then
2019-07-31 04:22:28 +02:00
self.object : remove ( )
2019-11-19 01:19:47 +01:00
return
end
local player = minetest.get_player_by_name ( self.player )
if not player then
self.object : remove ( )
return
2019-07-31 04:22:28 +02:00
end
2020-11-09 18:59:08 +01:00
local wield = player : get_wielded_item ( )
2019-07-31 04:22:28 +02:00
--Check if player is nearby
2021-05-29 16:12:33 +02:00
if self.player and player then
2019-07-31 04:22:28 +02:00
--Destroy bobber if item not wielded.
2020-11-02 17:38:51 +01:00
if ( ( not wield ) or ( minetest.get_item_group ( wield : get_name ( ) , " fishing_rod " ) <= 0 ) ) then
2019-07-31 04:22:28 +02:00
self.object : remove ( )
2019-11-19 01:19:47 +01:00
return
2019-07-31 04:22:28 +02:00
end
2020-07-05 03:28:02 +02:00
2019-07-31 04:22:28 +02:00
--Destroy bobber if player is too far away.
local objpos = self.object : get_pos ( )
2019-11-19 01:19:47 +01:00
local playerpos = player : get_pos ( )
2019-07-31 04:22:28 +02:00
if ( ( ( playerpos.y - objpos.y ) >= 33 ) or ( ( playerpos.y - objpos.y ) <= - 33 ) ) then
self.object : remove ( )
2019-11-19 01:19:47 +01:00
return
2019-07-31 04:22:28 +02:00
elseif ( ( ( playerpos.x - objpos.x ) >= 33 ) or ( ( playerpos.x - objpos.x ) <= - 33 ) ) then
self.object : remove ( )
2019-11-19 01:19:47 +01:00
return
2019-07-31 04:22:28 +02:00
elseif ( ( ( playerpos.z - objpos.z ) >= 33 ) or ( ( playerpos.z - objpos.z ) <= - 33 ) ) then
self.object : remove ( )
2019-11-19 01:19:47 +01:00
return
2019-07-31 04:22:28 +02:00
elseif ( ( ( ( playerpos.z + playerpos.x ) - ( objpos.z + objpos.x ) ) >= 33 ) or ( ( playerpos.z + playerpos.x ) - ( objpos.z + objpos.x ) ) <= - 33 ) then
self.object : remove ( )
2019-11-19 01:19:47 +01:00
return
2019-07-31 04:22:28 +02:00
elseif ( ( ( ( playerpos.y + playerpos.x ) - ( objpos.y + objpos.x ) ) >= 33 ) or ( ( playerpos.y + playerpos.x ) - ( objpos.y + objpos.x ) ) <= - 33 ) then
self.object : remove ( )
2019-11-19 01:19:47 +01:00
return
2019-07-31 04:22:28 +02:00
elseif ( ( ( ( playerpos.z + playerpos.y ) - ( objpos.z + objpos.y ) ) >= 33 ) or ( ( playerpos.z + playerpos.y ) - ( objpos.z + objpos.y ) ) <= - 33 ) then
self.object : remove ( )
2019-11-19 01:19:47 +01:00
return
2019-07-31 04:22:28 +02:00
end
2020-07-05 03:28:02 +02:00
2019-07-31 04:22:28 +02:00
end
2019-09-10 15:12:36 +02:00
-- If in water, then bob.
if def.liquidtype == " source " and minetest.get_item_group ( def.name , " water " ) ~= 0 then
2019-07-31 04:22:28 +02:00
if self._oldy == nil then
self.object : set_pos ( { x = self.object : get_pos ( ) . x , y = math.floor ( self.object : get_pos ( ) . y ) + .5 , z = self.object : get_pos ( ) . z } )
self._oldy = self.object : get_pos ( ) . y
2023-06-19 13:49:58 +02:00
minetest.sound_play ( " watersplash " , { pos = epos , gain = 0.25 } , true )
2019-07-31 04:22:28 +02:00
end
-- reset to original position after dive.
if self.object : get_pos ( ) . y > self._oldy then
self.object : set_pos ( { x = self.object : get_pos ( ) . x , y = self._oldy , z = self.object : get_pos ( ) . z } )
self.object : set_velocity ( { x = 0 , y = 0 , z = 0 } )
self.object : set_acceleration ( { x = 0 , y = 0 , z = 0 } )
end
if self._dive then
for i = 1 , 2 do
2019-09-10 15:16:49 +02:00
-- Spray bubbles when there's a fish.
2019-07-31 04:22:28 +02:00
minetest.add_particle ( {
pos = { x = epos [ " x " ] + math.random ( - 1 , 1 ) * math.random ( ) / 2 , y = epos [ " y " ] + 0.1 , z = epos [ " z " ] + math.random ( - 1 , 1 ) * math.random ( ) / 2 } ,
velocity = { x = 0 , y = 4 , z = 0 } ,
acceleration = { x = 0 , y =- 5 , z = 0 } ,
2020-11-09 18:59:08 +01:00
expirationtime = math.random ( ) * 0.5 ,
size = math.random ( ) ,
2019-07-31 04:22:28 +02:00
collisiondetection = true ,
vertical = false ,
texture = " mcl_particles_bubble.png " ,
} )
end
2020-11-09 18:59:08 +01:00
if self._time < self._waittime then
self._time = self._time + dtime
2019-07-31 04:22:28 +02:00
else
2020-11-09 18:59:08 +01:00
self._waittime = 0
self._time = 0
2019-07-31 04:22:28 +02:00
self._dive = false
end
2020-11-09 18:59:08 +01:00
else if not self._waittime or self._waittime <= 0 then
2019-09-10 15:16:49 +02:00
-- wait for random number of ticks.
2020-11-09 18:59:08 +01:00
local lure_enchantment = wield and mcl_enchanting.get_enchantment ( wield , " lure " ) or 0
2020-12-20 16:32:04 +01:00
local reduced = lure_enchantment * 5
2021-01-04 20:23:14 +01:00
self._waittime = math.random ( math.max ( 0 , 5 - reduced ) , 30 - reduced )
2019-07-31 04:22:28 +02:00
else
2020-11-09 18:59:08 +01:00
if self._time < self._waittime then
self._time = self._time + dtime
2019-07-31 04:22:28 +02:00
else
2020-11-09 18:59:08 +01:00
-- wait time is over time to dive.
2023-06-19 13:49:58 +02:00
minetest.sound_play ( " bloop " , { pos = epos , gain = 0.4 } , true )
2019-07-31 04:22:28 +02:00
self._dive = true
self.object : set_velocity ( { x = 0 , y =- 2 , z = 0 } )
self.object : set_acceleration ( { x = 0 , y = 5 , z = 0 } )
2020-11-09 18:59:08 +01:00
self._waittime = 0.8
self._time = 0
2019-07-31 04:22:28 +02:00
end
end
end
2020-07-05 03:28:02 +02:00
end
2019-07-31 04:22:28 +02:00
2019-09-10 15:10:12 +02:00
-- TODO: Destroy when hitting a solid node
2019-07-31 04:22:28 +02:00
--if self._lastpos.x~=nil then
-- if (def and def.walkable) or not def then
--self.object:remove()
-- return
-- end
--end
--self._lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Node will be added at last pos outside the node
end
bobber_ENTITY.on_step = bobber_on_step
minetest.register_entity ( " mcl_fishing:bobber_entity " , bobber_ENTITY )
2021-03-26 22:31:15 +01:00
local flying_bobber_ENTITY = {
physical = false ,
timer = 0 ,
textures = { " mcl_fishing_bobber.png " } , --FIXME: Replace with correct texture.
visual_size = { x = 0.5 , y = 0.5 } ,
collisionbox = { 0 , 0 , 0 , 0 , 0 , 0 } ,
pointable = false ,
2021-04-02 14:28:43 +02:00
get_staticdata = mcl_throwing.get_staticdata ,
on_activate = mcl_throwing.on_activate ,
2021-03-26 22:31:15 +01:00
_lastpos = { } ,
_thrower = nil ,
objtype = " fishing " ,
}
-- Movement function of flying bobber
2021-05-25 12:52:25 +02:00
local function flying_bobber_on_step ( self , dtime )
2021-03-26 22:31:15 +01:00
self.timer = self.timer + dtime
local pos = self.object : get_pos ( )
local node = minetest.get_node ( pos )
local def = minetest.registered_nodes [ node.name ]
--local player = minetest.get_player_by_name(self._thrower)
-- Destroy when hitting a solid node
if self._lastpos . x ~= nil then
if ( def and ( def.walkable or def.liquidtype == " flowing " or def.liquidtype == " source " ) ) or not def then
2021-05-25 12:52:25 +02:00
local ent = minetest.add_entity ( self._lastpos , " mcl_fishing:bobber_entity " ) : get_luaentity ( )
ent.player = self._thrower
ent.child = true
2021-03-26 22:31:15 +01:00
self.object : remove ( )
return
end
end
self._lastpos = { x = pos.x , y = pos.y , z = pos.z } -- Set lastpos-->Node will be added at last pos outside the node
end
flying_bobber_ENTITY.on_step = flying_bobber_on_step
minetest.register_entity ( " mcl_fishing:flying_bobber_entity " , flying_bobber_ENTITY )
mcl_throwing.register_throwable_object ( " mcl_fishing:flying_bobber " , " mcl_fishing:flying_bobber_entity " , 5 )
2021-05-29 16:15:30 +02:00
-- If player leaves area, remove bobber.
minetest.register_on_leaveplayer ( function ( player )
2019-07-31 04:22:28 +02:00
local objs = minetest.get_objects_inside_radius ( player : get_pos ( ) , 250 )
2021-05-29 16:15:30 +02:00
local ent = nil
local noent = true
2019-07-31 04:22:28 +02:00
for n = 1 , # objs do
2021-05-29 16:15:30 +02:00
ent = objs [ n ] : get_luaentity ( )
2019-07-31 04:22:28 +02:00
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
2021-05-29 16:15:30 +02:00
end )
2020-07-05 03:28:02 +02:00
2021-05-22 23:49:03 +02:00
-- If player dies, remove bobber.
2021-05-29 16:15:30 +02:00
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 )
2019-07-31 04:22:28 +02:00
2017-02-17 22:27:33 +01:00
-- Fishing Rod
minetest.register_tool ( " mcl_fishing:fishing_rod " , {
2019-03-08 00:00:09 +01:00
description = S ( " Fishing Rod " ) ,
2020-03-12 01:35:11 +01:00
_tt_help = S ( " Catches fish in water " ) ,
2019-03-08 00:00:09 +01:00
_doc_items_longdesc = S ( " Fishing rods can be used to catch fish. " ) ,
2019-07-31 04:22:28 +02:00
_doc_items_usagehelp = S ( " Rightclick to launch the bobber. When it sinks right-click again to reel in an item. Who knows what you're going to catch? " ) ,
2020-11-25 12:47:27 +01:00
groups = { tool = 1 , fishing_rod = 1 , enchantability = 1 } ,
2017-02-17 22:27:33 +01:00
inventory_image = " mcl_fishing_fishing_rod.png " ,
2022-06-17 23:15:46 +02:00
wield_image = " mcl_fishing_fishing_rod.png^[transformFY^[transformR90 " ,
2020-04-08 04:07:16 +02:00
wield_scale = { x = 1.5 , y = 1.5 , z = 1 } ,
2017-02-17 22:27:33 +01:00
stack_max = 1 ,
2019-07-31 04:22:28 +02:00
on_place = fish ,
on_secondary_use = fish ,
2017-02-19 20:23:33 +01:00
sound = { breaks = " default_tool_breaks " } ,
2020-12-21 15:12:24 +01:00
_mcl_uses = 65 ,
2021-02-18 09:28:12 +01:00
_mcl_toollike_wield = true ,
2017-02-01 15:20:28 +01:00
} )
minetest.register_craft ( {
output = " mcl_fishing:fishing_rod " ,
recipe = {
2021-05-29 16:12:33 +02:00
{ " " , " " , " mcl_core:stick " } ,
{ " " , " mcl_core:stick " , " mcl_mobitems:string " } ,
{ " mcl_core:stick " , " " , " mcl_mobitems:string " } ,
2017-02-01 15:20:28 +01:00
}
} )
minetest.register_craft ( {
output = " mcl_fishing:fishing_rod " ,
recipe = {
2021-05-29 16:12:33 +02:00
{ " mcl_core:stick " , " " , " " } ,
{ " mcl_mobitems:string " , " mcl_core:stick " , " " } ,
{ " mcl_mobitems:string " , " " , " mcl_core:stick " } ,
2017-02-01 15:20:28 +01:00
}
} )
minetest.register_craft ( {
type = " fuel " ,
2020-11-01 17:24:57 +01:00
recipe = " group:fishing_rod " ,
2017-02-01 15:20:28 +01:00
burntime = 15 ,
} )
-- Fish
minetest.register_craftitem ( " mcl_fishing:fish_raw " , {
2019-03-08 00:00:09 +01:00
description = S ( " Raw Fish " ) ,
_doc_items_longdesc = S ( " Raw fish is obtained by fishing and is a food item which can be eaten safely. Cooking it improves its nutritional value. " ) ,
2017-02-01 15:20:28 +01:00
inventory_image = " mcl_fishing_fish_raw.png " ,
2017-02-16 17:45:33 +01:00
on_place = minetest.item_eat ( 2 ) ,
on_secondary_use = minetest.item_eat ( 2 ) ,
2017-02-01 15:20:28 +01:00
stack_max = 64 ,
2023-05-30 20:44:15 +02:00
groups = { food = 2 , eatable = 2 , smoker_cookable = 1 , campfire_cookable = 1 } ,
2017-05-20 17:45:04 +02:00
_mcl_saturation = 0.4 ,
2017-02-01 15:20:28 +01:00
} )
minetest.register_craftitem ( " mcl_fishing:fish_cooked " , {
2019-03-08 00:00:09 +01:00
description = S ( " Cooked Fish " ) ,
_doc_items_longdesc = S ( " Mmh, fish! This is a healthy food item. " ) ,
2017-02-01 15:20:28 +01:00
inventory_image = " mcl_fishing_fish_cooked.png " ,
2017-02-16 17:45:33 +01:00
on_place = minetest.item_eat ( 5 ) ,
on_secondary_use = minetest.item_eat ( 5 ) ,
2017-02-01 15:20:28 +01:00
stack_max = 64 ,
groups = { food = 2 , eatable = 5 } ,
2017-05-21 03:26:51 +02:00
_mcl_saturation = 6 ,
2017-02-01 15:20:28 +01:00
} )
minetest.register_craft ( {
type = " cooking " ,
output = " mcl_fishing:fish_cooked " ,
recipe = " mcl_fishing:fish_raw " ,
cooktime = 10 ,
} )
2017-02-01 15:29:43 +01:00
-- Salmon
minetest.register_craftitem ( " mcl_fishing:salmon_raw " , {
2019-03-08 00:00:09 +01:00
description = S ( " Raw Salmon " ) ,
_doc_items_longdesc = S ( " Raw salmon is obtained by fishing and is a food item which can be eaten safely. Cooking it improves its nutritional value. " ) ,
2017-02-01 15:29:43 +01:00
inventory_image = " mcl_fishing_salmon_raw.png " ,
2017-02-16 17:45:33 +01:00
on_place = minetest.item_eat ( 2 ) ,
on_secondary_use = minetest.item_eat ( 2 ) ,
2017-02-01 15:29:43 +01:00
stack_max = 64 ,
2023-05-30 20:44:15 +02:00
groups = { food = 2 , eatable = 2 , smoker_cookable = 1 , campfire_cookable = 1 } ,
2017-05-20 17:45:04 +02:00
_mcl_saturation = 0.4 ,
2017-02-01 15:29:43 +01:00
} )
minetest.register_craftitem ( " mcl_fishing:salmon_cooked " , {
2019-03-08 00:00:09 +01:00
description = S ( " Cooked Salmon " ) ,
_doc_items_longdesc = S ( " This is a healthy food item which can be eaten. " ) ,
2017-02-01 15:29:43 +01:00
inventory_image = " mcl_fishing_salmon_cooked.png " ,
2017-02-16 17:45:33 +01:00
on_place = minetest.item_eat ( 6 ) ,
on_secondary_use = minetest.item_eat ( 6 ) ,
2017-02-01 15:29:43 +01:00
stack_max = 64 ,
groups = { food = 2 , eatable = 6 } ,
2017-05-20 17:45:04 +02:00
_mcl_saturation = 9.6 ,
2017-02-01 15:29:43 +01:00
} )
minetest.register_craft ( {
type = " cooking " ,
output = " mcl_fishing:salmon_cooked " ,
recipe = " mcl_fishing:salmon_raw " ,
cooktime = 10 ,
} )
-- Clownfish
minetest.register_craftitem ( " mcl_fishing:clownfish_raw " , {
2019-03-08 00:00:09 +01:00
description = S ( " Clownfish " ) ,
_doc_items_longdesc = S ( " Clownfish may be obtained by fishing (and luck) and is a food item which can be eaten safely. " ) ,
2017-02-01 15:29:43 +01:00
inventory_image = " mcl_fishing_clownfish_raw.png " ,
2017-02-16 17:45:33 +01:00
on_place = minetest.item_eat ( 1 ) ,
on_secondary_use = minetest.item_eat ( 1 ) ,
2017-02-01 15:29:43 +01:00
stack_max = 64 ,
groups = { food = 2 , eatable = 1 } ,
2017-05-20 17:45:04 +02:00
_mcl_saturation = 0.2 ,
2017-02-01 15:29:43 +01:00
} )
2020-08-01 14:36:22 +02:00
2017-02-01 15:29:43 +01:00
minetest.register_craftitem ( " mcl_fishing:pufferfish_raw " , {
2019-03-08 00:00:09 +01:00
description = S ( " Pufferfish " ) ,
2021-03-26 22:50:37 +01:00
_tt_help = minetest.colorize ( mcl_colors.YELLOW , S ( " Very poisonous " ) ) ,
2019-03-08 00:00:09 +01:00
_doc_items_longdesc = S ( " Pufferfish are a common species of fish and can be obtained by fishing. They can technically be eaten, but they are very bad for humans. Eating a pufferfish only restores 1 hunger point and will poison you very badly (which drains your health non-fatally) and causes serious food poisoning (which increases your hunger). " ) ,
2017-02-01 15:29:43 +01:00
inventory_image = " mcl_fishing_pufferfish_raw.png " ,
2017-02-16 17:45:33 +01:00
on_place = minetest.item_eat ( 1 ) ,
on_secondary_use = minetest.item_eat ( 1 ) ,
2017-02-01 15:29:43 +01:00
stack_max = 64 ,
2020-07-05 03:28:02 +02:00
groups = { food = 2 , eatable = 1 , brewitem = 1 } ,
2020-08-01 14:36:22 +02:00
-- _mcl_saturation = 0.2,
2017-02-01 15:29:43 +01:00
} )
2020-08-01 14:36:22 +02:00
minetest.register_on_item_eat ( function ( hp_change , replace_with_item , itemstack , user , pointed_thing )
if itemstack : get_name ( ) == " mcl_fishing:pufferfish_raw " then
2024-04-27 04:28:21 +02:00
mcl_potions.give_effect_by_level ( " poison " , user , 3 , 60 )
mcl_potions.give_effect_by_level ( " nausea " , user , 2 , 20 )
2020-08-01 14:36:22 +02:00
end
end )