2017-02-18 00:27:33 +03:00
local go_fishing = function ( itemstack , user , pointed_thing )
if pointed_thing and pointed_thing.under then
2017-03-02 18:09:13 +03:00
-- Use pointed node's on_rightclick function first, if present
2017-02-18 00:27:33 +03:00
local node = minetest.get_node ( pointed_thing.under )
2017-03-02 18:09:13 +03:00
if user and not user : 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 , user , itemstack ) or itemstack
end
end
2017-02-18 00:27:33 +03:00
if string.find ( node.name , " mcl_core:water " ) then
local itemname
local itemcount = 1
local itemwear = 0
local r = math.random ( 1 , 100 )
if r <= 85 then
-- Fish
r = math.random ( 1 , 100 )
if r <= 60 then
itemname = " mcl_fishing:fish_raw "
elseif r <= 85 then
itemname = " mcl_fishing:salmon_raw "
elseif r <= 87 then
itemname = " mcl_fishing:clownfish_raw "
2017-02-01 17:20:28 +03:00
else
2017-02-18 00:27:33 +03:00
itemname = " mcl_fishing:pufferfish_raw "
2017-02-01 17:20:28 +03:00
end
2017-02-18 00:27:33 +03:00
elseif r <= 95 then
-- Junk
r = math.random ( 1 , 83 )
if r <= 10 then
itemname = " mcl_core:bowl "
elseif r <= 12 then
itemname = " mcl_fishing:fishing_rod "
itemwear = math.random ( 6554 , 65535 ) -- 10%-100% damaged
elseif r <= 22 then
itemname = " mcl_mobitems:leather "
elseif r <= 32 then
itemname = " 3d_armor:boots_leather "
itemwear = math.random ( 6554 , 65535 ) -- 10%-100% damaged
elseif r <= 42 then
itemname = " mcl_mobitems:rotten_flesh "
elseif r <= 47 then
itemname = " mcl_core:stick "
elseif r <= 52 then
itemname = " mcl_mobitems:string "
elseif r <= 62 then
2017-03-11 23:26:45 +03:00
itemname = " mcl_potions:potion_water "
2017-02-18 00:27:33 +03:00
elseif r <= 72 then
itemname = " mcl_mobitems:bone "
elseif r <= 73 then
itemname = " mcl_dye:black "
itemcount = 10
else
-- TODO: Tripwire hook
itemname = " mcl_mobitems:string "
2017-02-01 17:20:28 +03:00
end
2017-02-18 00:27:33 +03:00
else
-- Treasure
r = math.random ( 1 , 6 )
if r == 1 then
2017-03-11 23:26:45 +03:00
-- TODO: Enchanted bow
2017-02-18 00:27:33 +03:00
itemname = " mcl_throwing:bow "
itemwear = math.random ( 49144 , 65535 ) -- 75%-100% damaged
elseif r == 2 then
-- TODO: Enchanted book
itemname = " mcl_books:book "
elseif r == 3 then
2017-03-11 23:26:45 +03:00
-- TODO: Enchanted fishing rod
2017-02-18 00:27:33 +03:00
itemname = " mcl_fishing:fishing_rod "
itemwear = math.random ( 49144 , 65535 ) -- 75%-100% damaged
elseif r == 4 then
itemname = " mobs:nametag "
elseif r == 5 then
itemname = " mcl_mobitems:saddle "
elseif r == 6 then
itemname = " mcl_flowers:waterlily "
2017-02-01 17:33:25 +03:00
end
2017-02-01 17:20:28 +03:00
end
2017-02-18 00:27:33 +03:00
local inv = user : get_inventory ( )
local item = { name = itemname , count = itemcount , wear = itemwear , metadata = " " }
if inv : room_for_item ( " main " , item ) then
inv : add_item ( " main " , item )
end
2017-02-18 00:39:56 +03:00
if not minetest.setting_getbool ( " creative_mode " ) then
2017-02-19 22:23:33 +03:00
local idef = itemstack : get_definition ( )
2017-02-18 00:39:56 +03:00
itemstack : add_wear ( 65535 / 65 ) -- 65 uses
2017-02-19 22:23:33 +03:00
if itemstack : get_count ( ) == 0 and idef.sound and idef.sound . breaks then
minetest.sound_play ( idef.sound . breaks , { pos = pointed_thing.above , gain = 0.5 } )
end
2017-02-18 00:27:33 +03:00
end
return itemstack
2017-02-01 17:20:28 +03:00
end
2017-02-18 00:27:33 +03:00
end
return nil
end
-- Fishing Rod
minetest.register_tool ( " mcl_fishing:fishing_rod " , {
description = " Fishing Rod " ,
2017-03-12 04:09:11 +03:00
_doc_items_longdesc = " Fishing rods can be used to catch fish. " ,
_doc_items_usagehelp = " Rightclick a water source to try to go fishing. Who knows what you're going to catch? " ,
2017-02-18 00:27:33 +03:00
groups = { tool = 1 } ,
inventory_image = " mcl_fishing_fishing_rod.png " ,
stack_max = 1 ,
liquids_pointable = true ,
on_place = go_fishing ,
2017-02-19 22:23:33 +03:00
sound = { breaks = " default_tool_breaks " } ,
2017-02-01 17:20:28 +03:00
} )
minetest.register_craft ( {
output = " mcl_fishing:fishing_rod " ,
recipe = {
{ ' ' , ' ' , ' mcl_core:stick ' } ,
2017-02-01 19:59:15 +03:00
{ ' ' , ' mcl_core:stick ' , ' mcl_mobitems:string ' } ,
{ ' mcl_core:stick ' , ' ' , ' mcl_mobitems:string ' } ,
2017-02-01 17:20:28 +03:00
}
} )
minetest.register_craft ( {
output = " mcl_fishing:fishing_rod " ,
recipe = {
{ ' mcl_core:stick ' , ' ' , ' ' } ,
2017-02-01 19:59:15 +03:00
{ ' mcl_mobitems:string ' , ' mcl_core:stick ' , ' ' } ,
{ ' mcl_mobitems:string ' , ' ' , ' mcl_core:stick ' } ,
2017-02-01 17:20:28 +03:00
}
} )
minetest.register_craft ( {
type = " fuel " ,
recipe = " mcl_fishing:fishing_rod " ,
burntime = 15 ,
} )
-- Fish
minetest.register_craftitem ( " mcl_fishing:fish_raw " , {
description = " Raw Fish " ,
2017-03-18 19:18:12 +03:00
_doc_items_longdesc = " This is a raw food item which can be eaten for 2 hunger points. But cooking it is better. " ,
2017-02-01 17:20:28 +03:00
inventory_image = " mcl_fishing_fish_raw.png " ,
2017-02-16 19:45:33 +03:00
on_place = minetest.item_eat ( 2 ) ,
on_secondary_use = minetest.item_eat ( 2 ) ,
2017-02-01 17:20:28 +03:00
stack_max = 64 ,
groups = { food = 2 , eatable = 2 } ,
} )
minetest.register_craftitem ( " mcl_fishing:fish_cooked " , {
description = " Cooked Fish " ,
2017-03-18 19:18:12 +03:00
_doc_items_longdesc = " Mmh, fish! This food item can be eaten for 5 hunger points. " ,
2017-02-01 17:20:28 +03:00
inventory_image = " mcl_fishing_fish_cooked.png " ,
2017-02-16 19:45:33 +03:00
on_place = minetest.item_eat ( 5 ) ,
on_secondary_use = minetest.item_eat ( 5 ) ,
2017-02-01 17:20:28 +03:00
stack_max = 64 ,
groups = { food = 2 , eatable = 5 } ,
} )
minetest.register_craft ( {
type = " cooking " ,
output = " mcl_fishing:fish_cooked " ,
recipe = " mcl_fishing:fish_raw " ,
cooktime = 10 ,
} )
2017-02-01 17:29:43 +03:00
-- Salmon
minetest.register_craftitem ( " mcl_fishing:salmon_raw " , {
description = " Raw Salmon " ,
2017-03-18 19:18:12 +03:00
_doc_items_longdesc = " This is a raw food item which can be eaten for 2 hunger points. But cooking it is better. " ,
2017-02-01 17:29:43 +03:00
inventory_image = " mcl_fishing_salmon_raw.png " ,
2017-02-16 19:45:33 +03:00
on_place = minetest.item_eat ( 2 ) ,
on_secondary_use = minetest.item_eat ( 2 ) ,
2017-02-01 17:29:43 +03:00
stack_max = 64 ,
groups = { food = 2 , eatable = 2 } ,
} )
minetest.register_craftitem ( " mcl_fishing:salmon_cooked " , {
description = " Cooked Salmon " ,
2017-03-18 19:18:12 +03:00
_doc_items_longdesc = " This is a food item which can be eaten for 6 hunger points. " ,
2017-02-01 17:29:43 +03:00
inventory_image = " mcl_fishing_salmon_cooked.png " ,
2017-02-16 19:45:33 +03:00
on_place = minetest.item_eat ( 6 ) ,
on_secondary_use = minetest.item_eat ( 6 ) ,
2017-02-01 17:29:43 +03:00
stack_max = 64 ,
groups = { food = 2 , eatable = 6 } ,
} )
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 " , {
description = " Clownfish " ,
2017-03-18 19:18:12 +03:00
_doc_items_longdesc = " This is a food item which can be eaten for 1 hunger point. " ,
2017-02-01 17:29:43 +03:00
inventory_image = " mcl_fishing_clownfish_raw.png " ,
2017-02-16 19:45:33 +03:00
on_place = minetest.item_eat ( 1 ) ,
on_secondary_use = minetest.item_eat ( 1 ) ,
2017-02-01 17:29:43 +03:00
stack_max = 64 ,
groups = { food = 2 , eatable = 1 } ,
} )
-- Pufferfish
2017-02-28 06:53:52 +03:00
-- TODO: Add status effect
2017-02-01 17:29:43 +03:00
minetest.register_craftitem ( " mcl_fishing:pufferfish_raw " , {
description = " Pufferfish " ,
2017-03-18 19:18:12 +03:00
_doc_items_longdesc = " Pufferfish are a common species of fish, but they are dangerous to eat. Eating a pufferfish restores 1 hunger point, but it makes you very sick (which drains your health non-fatally). " ,
2017-02-01 17:29:43 +03:00
inventory_image = " mcl_fishing_pufferfish_raw.png " ,
2017-02-16 19:45:33 +03:00
on_place = minetest.item_eat ( 1 ) ,
on_secondary_use = minetest.item_eat ( 1 ) ,
2017-02-01 17:29:43 +03:00
stack_max = 64 ,
groups = { food = 2 , eatable = 1 } ,
} )