fishing rods have 65 uses, add new items to catch, some with item wear

This commit is contained in:
tenplus1 2023-04-12 13:50:50 +01:00
parent 79d9cad7cb
commit 929e202aeb
2 changed files with 42 additions and 8 deletions

View File

@ -28,6 +28,10 @@ You may also use a table that not only adds an item but the biome it can be foun
ethereal.add_item("", "", {"ethereal:crystal_spike", "frost"}) ethereal.add_item("", "", {"ethereal:crystal_spike", "frost"})
.. add special item with wear level:
ethereal.add_item("", "", "default:sword_steel 15000")
Please note that only Ethereal biome names can be used for specific finds, unless mod Please note that only Ethereal biome names can be used for specific finds, unless mod
specifically adds ethereal as an optional dependency. specifically adds ethereal as an optional dependency.

View File

@ -34,22 +34,38 @@ local fish_items = {
-- sandstone_desert_ocean, plains_ocean, savanna_ocean, fiery_ocean, swamp_ocean, -- sandstone_desert_ocean, plains_ocean, savanna_ocean, fiery_ocean, swamp_ocean,
-- glacier_ocean, tundra_ocean -- glacier_ocean, tundra_ocean
local mod_bonemeal = minetest.get_modpath("bonemeal")
local mod_armor = minetest.get_modpath("3d_armor")
local mod_mobs = minetest.get_modpath("mobs")
local junk_items = { local junk_items = {
"ethereal:bowl", "ethereal:bowl",
"default:stick", "default:stick",
"farming:string", "farming:string",
"default:papyrus", "default:papyrus",
"dye:black", "dye:black",
{"ethereal:bamboo", "bamboo"} "flowers:waterlily",
"default:paper",
"flowers:mushroom_red",
"vessels:glass_bottle",
{"ethereal:bamboo", "bamboo"},
mod_bonemeal and "bonemeal:bone" or "default:stick",
mod_armor and "3d_armor:boots_wood 6000" or "default:stick"
} }
local bonus_items = { local bonus_items = {
"mobs:nametag", mod_mobs and "mobs:nametag" or "fireflies:bug_net",
"mobs:saddle", mod_mobs and "mobs:net" or "default:sapling",
"flowers:waterlily", "fireflies:firefly_bottle",
mod_mobs and "mobs:saddle" or "farming:cotton_wild",
"default:book", "default:book",
{"ethereal:firethorn", "glacier"},
{"ethereal:crystal_spike", "frost"}, {"ethereal:crystal_spike", "frost"},
{"ethereal:banana_bunch", "grove"} {"ethereal:banana_bunch", "grove"},
"tnt:tnt_stick",
"bucket:bucket_empty",
"default:sword_steel 12000",
"ethereal:fishing_rod 9000"
} }
local default_item = "default:dirt" local default_item = "default:dirt"
@ -287,7 +303,6 @@ local find_item = function(list, pos)
table.insert(items, item[1]) table.insert(items, item[1])
end end
end end
end end
--print("==biome: " .. biome, dump(items)) --print("==biome: " .. biome, dump(items))
@ -338,14 +353,23 @@ local use_rod = function(itemstack, player, pointed_thing)
item = find_item(bonus_items, pos) item = find_item(bonus_items, pos)
end end
-- split into name and number (wear level or number of items)
local item_name = item:split(" ")[1]
local item_wear = item:split(" ")[2]
-- make sure item exists, if not replace with default item -- make sure item exists, if not replace with default item
if not minetest.registered_items[item] then if not minetest.registered_items[item_name] then
item = default_item item = default_item
end end
--print ("---caught", item, r) --print ("---caught", item, r)
item = ItemStack(item) item = ItemStack(item) -- convert into itemstack
-- if tool then add wear
if item_wear and minetest.registered_tools[item_name] then
item:set_wear(65535 - item_wear)
end
local inv = player:get_inventory() local inv = player:get_inventory()
@ -394,6 +418,12 @@ local use_rod = function(itemstack, player, pointed_thing)
obj:set_acceleration({x = dir.x * -3, y = -9.8, z = dir.z * -3}) obj:set_acceleration({x = dir.x * -3, y = -9.8, z = dir.z * -3})
obj:get_luaentity().fisher = player and player:get_player_name() obj:get_luaentity().fisher = player and player:get_player_name()
end end
-- Add wear to fishing rod (65 uses)
local item = player:get_wielded_item()
item:add_wear(65535 / 65)
player:set_wielded_item(item)
end end