2021-03-14 22:55:16 +03:00
|
|
|
--[[
|
2016-06-09 17:08:34 +03:00
|
|
|
|
2022-09-30 19:26:44 +03:00
|
|
|
This fishing routine is inspired by the great work Rootyjr did for MineClone2
|
2016-06-09 17:08:34 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
]]--
|
2014-11-09 22:17:41 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- fish and where they can be caught
|
2014-11-09 22:17:41 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
local fish_items = {
|
|
|
|
"ethereal:fish_bluefin",
|
|
|
|
"ethereal:fish_blueram",
|
|
|
|
"ethereal:fish_catfish",
|
2021-03-20 13:44:13 +03:00
|
|
|
"ethereal:fish_plaice",
|
|
|
|
"ethereal:fish_salmon",
|
2021-03-15 18:12:18 +03:00
|
|
|
{"ethereal:fish_clownfish", "savanna"},
|
2024-01-22 11:24:22 +03:00
|
|
|
{"ethereal:fish_pike", "grassland_ocean"},
|
2024-09-26 11:02:13 +03:00
|
|
|
{"ethereal:fish_flathead", "rainforest"},
|
2021-03-15 18:12:18 +03:00
|
|
|
{"ethereal:fish_pufferfish", "desert_ocean"},
|
2024-09-26 11:02:13 +03:00
|
|
|
{"ethereal:fish_cichlid", "rainforest_ocean"},
|
2024-08-29 13:39:32 +03:00
|
|
|
{"ethereal:fish_coy", "bamboo"},
|
|
|
|
{"ethereal:fish_tilapia", "bamboo"},
|
|
|
|
{"ethereal:fish_trevally", "bamboo"},
|
2021-03-20 13:44:13 +03:00
|
|
|
{"ethereal:fish_angler", "ocean"},
|
|
|
|
{"ethereal:fish_jellyfish", "ocean"},
|
|
|
|
{"ethereal:fish_seahorse", "ocean"},
|
2024-09-26 11:02:13 +03:00
|
|
|
{"ethereal:fish_seahorse_green", "rainforest_ocean"},
|
2023-04-11 10:58:01 +03:00
|
|
|
{"ethereal:fish_seahorse_pink", "mushroom_ocean"},
|
2024-01-27 10:56:20 +03:00
|
|
|
{"ethereal:fish_seahorse_blue", "coniferous_forest_ocean"},
|
2023-04-11 10:58:01 +03:00
|
|
|
{"ethereal:fish_seahorse_yellow", "desert_ocean"},
|
2023-04-25 12:47:55 +03:00
|
|
|
{"ethereal:fish_parrot", "desert"},
|
2024-09-26 11:02:13 +03:00
|
|
|
{"ethereal:fish_piranha", "rainforest"},
|
|
|
|
{"ethereal:fish_tuna", "rainforest"},
|
2023-04-21 14:36:33 +03:00
|
|
|
{"ethereal:fish_trout", "ocean"},
|
|
|
|
{"ethereal:fish_cod", "ocean"},
|
|
|
|
{"ethereal:fish_flounder", "ocean"},
|
|
|
|
{"ethereal:fish_redsnapper", "ocean"},
|
|
|
|
{"ethereal:fish_squid", "ocean"},
|
|
|
|
{"ethereal:fish_shrimp", "ocean"},
|
2024-01-22 11:24:22 +03:00
|
|
|
{"ethereal:fish_carp", "swamp"},
|
|
|
|
{"ethereal:fish_tetra", "grayness_ocean"},
|
2024-01-28 20:20:52 +03:00
|
|
|
{"ethereal:fish_mackerel", "glacier"}
|
2021-03-14 22:55:16 +03:00
|
|
|
}
|
2024-08-29 13:39:32 +03:00
|
|
|
-- grassland_ocean, desert_ocean, bamboo_ocean, mesa_ocean, coniferous_forest_ocean,
|
2023-04-11 10:58:01 +03:00
|
|
|
-- taiga_ocean, frost_ocean, deciduous_forest_ocean, grayness_ocean, grassytwo_ocean,
|
2024-09-26 11:02:13 +03:00
|
|
|
-- prairie_ocean, jumble_ocean, rainforest_ocean, grove_ocean, mushroom_ocean,
|
2023-04-11 10:58:01 +03:00
|
|
|
-- sandstone_desert_ocean, plains_ocean, savanna_ocean, fiery_ocean, swamp_ocean,
|
|
|
|
-- glacier_ocean, tundra_ocean
|
2015-07-04 14:22:39 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- translation and mod checks
|
|
|
|
|
|
|
|
local S = minetest.get_translator("ethereal")
|
2023-04-12 15:50:50 +03:00
|
|
|
local mod_bonemeal = minetest.get_modpath("bonemeal")
|
|
|
|
local mod_armor = minetest.get_modpath("3d_armor")
|
|
|
|
local mod_mobs = minetest.get_modpath("mobs")
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- junk items to be found
|
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
local junk_items = {
|
|
|
|
"ethereal:bowl",
|
|
|
|
"default:stick",
|
|
|
|
"farming:string",
|
2021-03-15 11:57:05 +03:00
|
|
|
"default:papyrus",
|
2021-03-15 17:49:16 +03:00
|
|
|
"dye:black",
|
2023-04-12 15:50:50 +03:00
|
|
|
"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"
|
2021-03-14 22:55:16 +03:00
|
|
|
}
|
2014-11-09 22:17:41 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- bonus items to be found
|
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
local bonus_items = {
|
2023-04-12 15:50:50 +03:00
|
|
|
mod_mobs and "mobs:nametag" or "fireflies:bug_net",
|
|
|
|
mod_mobs and "mobs:net" or "default:sapling",
|
|
|
|
"fireflies:firefly_bottle",
|
|
|
|
mod_mobs and "mobs:saddle" or "farming:cotton_wild",
|
2021-03-15 17:49:16 +03:00
|
|
|
"default:book",
|
2023-04-12 15:50:50 +03:00
|
|
|
{"ethereal:firethorn", "glacier"},
|
2021-03-15 17:49:16 +03:00
|
|
|
{"ethereal:crystal_spike", "frost"},
|
2023-04-12 15:50:50 +03:00
|
|
|
{"ethereal:banana_bunch", "grove"},
|
|
|
|
"tnt:tnt_stick",
|
|
|
|
"bucket:bucket_empty",
|
|
|
|
"default:sword_steel 12000",
|
|
|
|
"ethereal:fishing_rod 9000"
|
2021-03-14 22:55:16 +03:00
|
|
|
}
|
2014-11-09 22:17:41 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- helpers
|
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
local default_item = "default:dirt"
|
|
|
|
local random = math.random -- yup we use this a lot
|
2019-03-18 11:50:38 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- global add item function
|
2022-09-30 19:26:44 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
ethereal.add_item = function(fish, junk, bonus)
|
2019-03-18 11:50:38 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
if fish and fish ~= "" then table.insert(fish_items, fish) end
|
2019-03-18 11:50:38 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
if junk and junk ~= "" then table.insert(junk_items, junk) end
|
2019-03-18 11:50:38 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
if bonus and bonus ~= "" then table.insert(bonus_items, bonus) end
|
2019-03-18 11:50:38 +03:00
|
|
|
end
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- bubble particle effect
|
2019-03-18 11:50:38 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
local function effect(pos)
|
2022-05-24 12:49:12 +03:00
|
|
|
|
|
|
|
minetest.add_particle({
|
|
|
|
pos = {
|
|
|
|
x = pos.x + random() - 0.5,
|
|
|
|
y = pos.y + 0.1,
|
|
|
|
z = pos.z + random() - 0.5
|
|
|
|
},
|
|
|
|
velocity = {x = 0, y = 4, z = 0},
|
|
|
|
acceleration = {x = 0, y = -5, z = 0},
|
|
|
|
expirationtime = random() * 0.5,
|
|
|
|
size = random(),
|
|
|
|
collisiondetection = false,
|
|
|
|
vertical = false,
|
|
|
|
texture = "bubble.png"
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
-- fishing bob entity
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
minetest.register_entity("ethereal:bob_entity", {
|
2014-11-09 22:17:41 +03:00
|
|
|
|
2023-12-18 11:04:58 +03:00
|
|
|
initial_properties = {
|
|
|
|
textures = {"ethereal_fishing_bob.png"},
|
|
|
|
visual_size = {x = 0.5, y = 0.5},
|
|
|
|
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
|
|
|
|
physical = false,
|
|
|
|
pointable = false,
|
|
|
|
static_save = false
|
|
|
|
},
|
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
timer = 0,
|
2021-03-14 22:55:16 +03:00
|
|
|
|
|
|
|
on_step = function(self, dtime)
|
|
|
|
|
|
|
|
local pos = self.object:get_pos()
|
2022-05-23 10:04:35 +03:00
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
local def = minetest.registered_nodes[node.name]
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
-- casting rod into water
|
|
|
|
if not self.cast then
|
|
|
|
|
2022-05-23 10:04:35 +03:00
|
|
|
-- remove if we hit something hard
|
|
|
|
if (def and def.walkable) or node.name == "ignore" then
|
2021-03-15 11:57:05 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
self.object:remove() ; --print("-- hit block")
|
2021-03-15 11:57:05 +03:00
|
|
|
|
2022-05-23 10:04:35 +03:00
|
|
|
return
|
|
|
|
end
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
-- while bob is in water
|
2022-05-23 10:04:35 +03:00
|
|
|
if def and def.liquidtype == "source"
|
|
|
|
and minetest.get_item_group(node.name, "water") > 0 then
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2022-05-23 10:04:35 +03:00
|
|
|
-- incase of lag find water level
|
|
|
|
local free_fall, blocker = minetest.line_of_sight(
|
2024-08-16 13:05:33 +03:00
|
|
|
{x = pos.x, y = pos.y + 2, z = pos.z},
|
|
|
|
{x = pos.x, y = pos.y , z = pos.z})
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2022-05-23 10:04:35 +03:00
|
|
|
-- do we have worms for bait, if so take one
|
|
|
|
local player = self.fisher and minetest.get_player_by_name(self.fisher)
|
|
|
|
local inv = player and player:get_inventory()
|
|
|
|
local bait = 0
|
2021-03-15 11:57:05 +03:00
|
|
|
|
2023-05-29 13:57:19 +03:00
|
|
|
if inv and inv:contains_item("main", "caverealms:glow_bait") then
|
|
|
|
inv:remove_item("main", "caverealms:glow_bait")
|
|
|
|
bait = 40
|
|
|
|
elseif inv and inv:contains_item("main", "ethereal:worm") then
|
2022-05-23 10:04:35 +03:00
|
|
|
inv:remove_item("main", "ethereal:worm")
|
|
|
|
bait = 20
|
|
|
|
end
|
2021-07-18 11:52:19 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
-- re-position fishing bob and set to cast
|
|
|
|
pos = {x = pos.x, y = blocker.y + 0.45, z = pos.z}
|
|
|
|
|
|
|
|
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
|
|
|
self.object:set_velocity({x = 0, y = 0, z = 0})
|
|
|
|
self.object:set_pos(pos)
|
|
|
|
self.bait = bait
|
|
|
|
self.cast = true
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
-- splash
|
|
|
|
effect(pos) ; effect(pos) ; effect(pos) ; effect(pos)
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
minetest.sound_play("default_water_footstep",
|
|
|
|
{pos = pos, gain = 0.1}, true)
|
2021-03-14 22:55:16 +03:00
|
|
|
end
|
2014-11-09 22:17:41 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
else -- already cast and waiting for fish
|
2021-03-14 22:55:16 +03:00
|
|
|
|
|
|
|
-- we need a name
|
2021-03-15 11:57:05 +03:00
|
|
|
if self.fisher == nil or self.fisher == "" then
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
self.object:remove() ; --print("-- no name")
|
2021-03-14 22:55:16 +03:00
|
|
|
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-03-15 11:57:05 +03:00
|
|
|
local player = minetest.get_player_by_name(self.fisher)
|
2021-03-14 22:55:16 +03:00
|
|
|
|
|
|
|
-- we need an actual person
|
|
|
|
if not player then
|
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
self.object:remove() ; --print("-- no player")
|
2021-03-14 22:55:16 +03:00
|
|
|
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local wield = player:get_wielded_item()
|
|
|
|
|
|
|
|
-- we also need a rod to fish with
|
2021-03-15 11:57:05 +03:00
|
|
|
if not wield or wield:get_name() ~= "ethereal:fishing_rod" then
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
self.object:remove() ; --print("-- no rod")
|
2015-07-04 14:22:39 +03:00
|
|
|
|
2016-01-21 17:59:28 +03:00
|
|
|
return
|
|
|
|
end
|
2018-11-29 14:09:41 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
-- remove bob if player is too far away
|
|
|
|
local pla_pos = player:get_pos()
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
if (pla_pos.y - pos.y) > 15 or (pla_pos.y - pos.y) < -15
|
|
|
|
or (pla_pos.x - pos.x) > 15 or (pla_pos.x - pos.x) < -15
|
|
|
|
or (pla_pos.z - pos.z) > 15 or (pla_pos.z - pos.z) < -15 then
|
2015-07-04 14:22:39 +03:00
|
|
|
|
2022-05-23 10:04:35 +03:00
|
|
|
self.object:remove() ; --print("-- out of range")
|
2021-03-14 22:55:16 +03:00
|
|
|
|
|
|
|
return
|
|
|
|
end
|
2015-12-23 13:13:09 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
-- when in water, bob.
|
|
|
|
if def and def.liquidtype == "source"
|
|
|
|
and minetest.get_item_group(def.name, "water") ~= 0 then
|
2015-12-23 13:13:09 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
self.old_y = self.old_y or pos.y
|
2016-01-21 17:59:28 +03:00
|
|
|
|
2021-03-15 11:57:05 +03:00
|
|
|
-- choose random time to wait (minus bait time for worm)
|
2021-03-14 22:55:16 +03:00
|
|
|
if not self.patience or self.patience <= 0 then
|
2021-03-15 11:57:05 +03:00
|
|
|
|
|
|
|
self.patience = random(10, (45 - self.bait))
|
|
|
|
self.bait = 0
|
2021-03-14 22:55:16 +03:00
|
|
|
end
|
2018-11-29 14:09:41 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
-- add particles if bobber bobbing
|
|
|
|
if self.bob then
|
2018-11-29 14:09:41 +03:00
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
effect(pos)
|
2018-11-29 14:09:41 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
-- handle timer
|
|
|
|
if self.timer < self.patience then
|
|
|
|
self.timer = self.timer + dtime
|
|
|
|
else
|
|
|
|
self.patience = 0
|
|
|
|
self.timer = 0
|
|
|
|
self.bob = false
|
|
|
|
end
|
2015-07-04 14:22:39 +03:00
|
|
|
else
|
2021-03-14 22:55:16 +03:00
|
|
|
-- handle timer
|
|
|
|
if self.timer < self.patience then
|
|
|
|
self.timer = self.timer + dtime
|
|
|
|
else
|
|
|
|
-- waiting over, bob that bobber and play splash sound
|
|
|
|
self.bob = true
|
2023-12-18 11:04:58 +03:00
|
|
|
self.patience = 1.4 -- timeframe to catch fish after bob
|
2021-03-14 22:55:16 +03:00
|
|
|
self.timer = 0
|
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
self.object:set_velocity({x = 0, y = -1, z = 0})
|
|
|
|
self.object:set_acceleration({x = 0, y = 3, z = 0})
|
2021-03-14 22:55:16 +03:00
|
|
|
|
|
|
|
minetest.sound_play("default_water_footstep", {
|
|
|
|
pos = pos, gain = 0.1}, true)
|
|
|
|
end
|
|
|
|
end
|
2022-05-23 10:04:35 +03:00
|
|
|
else
|
2022-05-24 12:49:12 +03:00
|
|
|
-- reset to original position after dive.
|
|
|
|
if self.old_y and pos.y > self.old_y then
|
|
|
|
|
|
|
|
self.object:set_velocity({x = 0, y = 0, z = 0})
|
|
|
|
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
|
|
|
self.object:set_pos({x = pos.x, y = self.old_y, z = pos.z})
|
|
|
|
--print("-- reset bob y pos")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- remove if not in water and not bobbing
|
|
|
|
if not self.bob then
|
|
|
|
self.object:remove() ; --print("-- not in water")
|
|
|
|
end
|
2021-03-14 22:55:16 +03:00
|
|
|
end
|
2022-05-24 12:49:12 +03:00
|
|
|
|
|
|
|
end -- if not self.cast
|
|
|
|
|
|
|
|
end -- on_step
|
2021-03-14 22:55:16 +03:00
|
|
|
})
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- narrow item list depending on biome
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2021-03-15 17:49:16 +03:00
|
|
|
local find_item = function(list, pos)
|
|
|
|
|
|
|
|
local item
|
|
|
|
local items = {}
|
|
|
|
local data= minetest.get_biome_data(pos)
|
|
|
|
local biome = data and minetest.get_biome_name(data.biome) or ""
|
|
|
|
|
2024-01-28 20:20:52 +03:00
|
|
|
--print("--biome", biome)
|
|
|
|
|
2021-03-15 17:49:16 +03:00
|
|
|
for n = 1, #list do
|
|
|
|
|
|
|
|
item = list[n]
|
|
|
|
|
|
|
|
if type(item) == "string" then
|
|
|
|
|
|
|
|
table.insert(items, item)
|
|
|
|
|
|
|
|
elseif type(item) == "table" then
|
|
|
|
|
2021-03-15 18:58:34 +03:00
|
|
|
if item[2] == "" or biome:find(item[2]) then
|
2021-03-15 17:49:16 +03:00
|
|
|
table.insert(items, item[1])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--print("==biome: " .. biome, dump(items))
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
if #items > 0 then return items[random(#items)] end
|
2021-03-15 17:49:16 +03:00
|
|
|
|
|
|
|
return ""
|
|
|
|
end
|
|
|
|
|
2021-03-15 16:06:21 +03:00
|
|
|
-- fishing rod function that throws pre bob, places bob and catches fish when it moves
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2021-03-15 16:06:21 +03:00
|
|
|
local use_rod = function(itemstack, player, pointed_thing)
|
|
|
|
|
|
|
|
local pos = player:get_pos()
|
2022-05-24 12:49:12 +03:00
|
|
|
local objs = minetest.get_objects_inside_radius(pos, 15)
|
2021-03-15 16:06:21 +03:00
|
|
|
local found = true
|
|
|
|
local ent
|
|
|
|
|
|
|
|
-- loop through entities and look for bobs
|
|
|
|
for n = 1, #objs do
|
|
|
|
|
|
|
|
ent = objs[n]:get_luaentity()
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
if ent and ent.fisher and ent.name == "ethereal:bob_entity"
|
2021-03-15 16:06:21 +03:00
|
|
|
and player:get_player_name() == ent.fisher then
|
|
|
|
|
|
|
|
found = false
|
|
|
|
|
|
|
|
if ent.bob == true then
|
|
|
|
|
|
|
|
local item
|
|
|
|
local r = random(100)
|
2023-12-18 11:04:58 +03:00
|
|
|
local rodpos = ent.object:get_pos() or pos
|
2021-03-15 16:06:21 +03:00
|
|
|
|
2024-01-26 11:38:47 +03:00
|
|
|
-- lower position to be in water
|
|
|
|
rodpos.y = rodpos.y - 1
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- chance between catching fish, bonuns item or junk
|
2021-03-15 16:06:21 +03:00
|
|
|
if r < 86 then
|
|
|
|
|
2023-12-18 11:33:39 +03:00
|
|
|
item = find_item(fish_items, rodpos)
|
2021-03-15 16:06:21 +03:00
|
|
|
|
|
|
|
elseif r > 85 and r < 96 then
|
|
|
|
|
2023-12-18 11:33:39 +03:00
|
|
|
item = find_item(junk_items, rodpos)
|
2021-03-15 16:06:21 +03:00
|
|
|
|
|
|
|
else
|
|
|
|
|
2023-12-18 11:33:39 +03:00
|
|
|
item = find_item(bonus_items, rodpos)
|
2021-03-15 16:06:21 +03:00
|
|
|
end
|
|
|
|
|
2023-04-12 15:50:50 +03:00
|
|
|
-- split into name and number (wear level or number of items)
|
|
|
|
local item_name = item:split(" ")[1]
|
|
|
|
local item_wear = item:split(" ")[2]
|
|
|
|
|
2021-03-15 16:06:21 +03:00
|
|
|
-- make sure item exists, if not replace with default item
|
2023-04-12 15:50:50 +03:00
|
|
|
if not minetest.registered_items[item_name] then
|
2021-03-15 16:06:21 +03:00
|
|
|
item = default_item
|
|
|
|
end
|
|
|
|
|
|
|
|
--print ("---caught", item, r)
|
|
|
|
|
2023-04-12 15:50:50 +03:00
|
|
|
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
|
2021-03-15 16:06:21 +03:00
|
|
|
|
|
|
|
local inv = player:get_inventory()
|
|
|
|
|
|
|
|
if inv:room_for_item("main", item) then
|
|
|
|
inv:add_item("main", item)
|
|
|
|
else
|
|
|
|
minetest.add_item(pos, item)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ent.object:remove()
|
|
|
|
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- loop through entities and look for bobs
|
|
|
|
for n = 1, #objs do
|
|
|
|
|
|
|
|
ent = objs[n]:get_luaentity()
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
if ent and ent.fisher and ent.name == "ethereal:bob_entity"
|
2021-03-15 16:06:21 +03:00
|
|
|
and player:get_player_name() == ent.fisher then
|
|
|
|
|
|
|
|
found = false
|
|
|
|
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if found == true then
|
|
|
|
|
|
|
|
local playerpos = player:get_pos()
|
|
|
|
local dir = player:get_look_dir()
|
|
|
|
local pos = {x = playerpos.x, y = playerpos.y + 1.5, z = playerpos.z}
|
|
|
|
|
2021-03-18 20:30:21 +03:00
|
|
|
minetest.sound_play("ethereal_casting_rod",
|
2024-08-16 13:05:33 +03:00
|
|
|
{pos = pos, gain = 1.0, max_hear_distance = 10}, true)
|
2021-03-15 16:06:21 +03:00
|
|
|
|
|
|
|
-- place actual bob
|
2022-05-24 12:49:12 +03:00
|
|
|
local obj = minetest.add_entity(pos, "ethereal:bob_entity")
|
2021-03-15 16:06:21 +03:00
|
|
|
|
|
|
|
obj:set_velocity({x = dir.x * 8, y = dir.y * 8, z = dir.z * 8})
|
|
|
|
obj:set_acceleration({x = dir.x * -3, y = -9.8, z = dir.z * -3})
|
|
|
|
obj:get_luaentity().fisher = player and player:get_player_name()
|
|
|
|
end
|
2023-04-12 15:50:50 +03:00
|
|
|
|
|
|
|
-- Add wear to fishing rod (65 uses)
|
2023-07-06 09:47:07 +03:00
|
|
|
itemstack:add_wear(65535 / 65)
|
2023-04-12 15:50:50 +03:00
|
|
|
|
2023-07-06 09:47:07 +03:00
|
|
|
return itemstack
|
2021-03-15 16:06:21 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
-- scan area for bobs that belong to player and remove
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
local remove_bob = function(player)
|
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
local objs = minetest.get_objects_inside_radius(player:get_pos(), 15)
|
2021-03-15 11:57:05 +03:00
|
|
|
local name = player:get_player_name()
|
2021-03-14 22:55:16 +03:00
|
|
|
local ent
|
|
|
|
|
|
|
|
for n = 1, #objs do
|
|
|
|
|
|
|
|
ent = objs[n]:get_luaentity()
|
|
|
|
|
2022-05-24 12:49:12 +03:00
|
|
|
if ent and ent.name == "ethereal:bob_entity" then
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2021-03-15 11:57:05 +03:00
|
|
|
-- only remove players own bob
|
|
|
|
if ent.fisher and ent.fisher == name then
|
2021-03-14 22:55:16 +03:00
|
|
|
ent.object:remove()
|
2015-07-04 14:22:39 +03:00
|
|
|
end
|
|
|
|
end
|
2021-03-14 22:55:16 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- remove bob if player signs off
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
minetest.register_on_leaveplayer(function(player)
|
|
|
|
remove_bob(player)
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- remove bob if player dies
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
minetest.register_on_dieplayer(function(player)
|
|
|
|
remove_bob(player)
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- fishing rod
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
minetest.register_tool("ethereal:fishing_rod", {
|
|
|
|
description = S("Fishing Rod (USE to cast and again when the time is right)"),
|
2021-03-15 11:57:05 +03:00
|
|
|
groups = {tool = 1},
|
2021-03-14 22:55:16 +03:00
|
|
|
inventory_image = "ethereal_fishing_rod.png",
|
|
|
|
wield_image = "ethereal_fishing_rod.png^[transformFX",
|
|
|
|
wield_scale = {x = 1.5, y = 1.5, z = 1},
|
|
|
|
stack_max = 1,
|
|
|
|
on_use = use_rod,
|
2021-07-18 11:52:19 +03:00
|
|
|
sound = {breaks = "default_tool_breaks"}
|
2014-11-09 22:17:41 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2021-03-14 22:55:16 +03:00
|
|
|
output = "ethereal:fishing_rod",
|
|
|
|
recipe = {
|
|
|
|
{"","","group:stick"},
|
|
|
|
{"","group:stick","farming:string"},
|
2021-07-18 11:52:19 +03:00
|
|
|
{"group:stick","","farming:string"}
|
2021-03-14 22:55:16 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "fuel",
|
2021-03-15 16:06:21 +03:00
|
|
|
recipe = "ethereal:fishing_rod",
|
2021-07-18 11:52:19 +03:00
|
|
|
burntime = 15
|
2021-03-14 22:55:16 +03:00
|
|
|
})
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- table of fish and edibility
|
2021-03-14 22:55:16 +03:00
|
|
|
|
|
|
|
local fish = {
|
|
|
|
{"Blue Fin", "bluefin", 2},
|
2023-04-21 14:36:33 +03:00
|
|
|
{"Blue Ram Chichlid", "blueram", 2},
|
|
|
|
{"Common Carp", "carp", 2},
|
|
|
|
{"Cod", "cod", 2},
|
|
|
|
{"Redtail Catfish", "catfish", 2},
|
2021-03-14 22:55:16 +03:00
|
|
|
{"Clownfish", "clownfish", 2},
|
2023-04-21 14:36:33 +03:00
|
|
|
{"Northern Pike", "pike", 2},
|
|
|
|
{"Dusky Flathead", "flathead", 2},
|
2021-03-14 22:55:16 +03:00
|
|
|
{"Plaice", "plaice", 2},
|
2023-04-21 14:36:33 +03:00
|
|
|
{"Tiger Pufferfish", "pufferfish", -2},
|
2021-03-15 16:48:34 +03:00
|
|
|
{"Coy", "coy", 2},
|
2023-04-21 14:36:33 +03:00
|
|
|
{"European Flounder", "flounder", 2},
|
|
|
|
{"Atlantic Salmon", "salmon", 2},
|
|
|
|
{"Iceblue Zebra Cichlid", "cichlid", 2},
|
2021-03-20 13:44:13 +03:00
|
|
|
{"Angler", "angler", 2},
|
2023-04-21 14:36:33 +03:00
|
|
|
{"Moon Jellyfish", "jellyfish", 0},
|
|
|
|
{"Pacific Mackerel", "mackerel", 2},
|
2021-03-20 13:44:13 +03:00
|
|
|
{"Piranha", "piranha", 2},
|
2023-04-21 14:36:33 +03:00
|
|
|
{"Rainbow Trout", "trout", 2},
|
|
|
|
{"Red Snapper", "redsnapper", 2},
|
2023-04-11 10:58:01 +03:00
|
|
|
{"Red Seahorse", "seahorse", 0},
|
|
|
|
{"Green Seahorse", "seahorse_green", 0},
|
|
|
|
{"Pink Seahorse", "seahorse_pink", 0},
|
|
|
|
{"Blue Seahorse", "seahorse_blue", 0},
|
|
|
|
{"Yellow Seahorse", "seahorse_yellow", 0},
|
2023-04-21 14:36:33 +03:00
|
|
|
{"Yellowfin Tuna", "tuna", 2},
|
|
|
|
{"Humboldt Squid", "squid", 0},
|
2023-04-22 17:31:18 +03:00
|
|
|
{"White Shrimp", "shrimp", 0},
|
|
|
|
{"Neon Tetra", "tetra", 1},
|
2023-04-25 12:47:55 +03:00
|
|
|
{"Tilapia", "tilapia", 2},
|
|
|
|
{"Golden Trevally", "trevally", 2},
|
|
|
|
{"Stoplight Parrotfish", "parrot", 2}
|
2021-03-14 22:55:16 +03:00
|
|
|
}
|
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
-- register above fish
|
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
for n = 1, #fish do
|
|
|
|
|
2021-03-20 13:44:13 +03:00
|
|
|
local usage
|
2024-07-26 18:54:52 +03:00
|
|
|
local groups = nil
|
2021-03-20 13:44:13 +03:00
|
|
|
|
|
|
|
if fish[n][3] > 0 then
|
|
|
|
usage = minetest.item_eat(fish[n][3])
|
2024-07-26 18:54:52 +03:00
|
|
|
groups = {food_fish_raw = 1, ethereal_fish = 1}
|
2021-03-20 13:44:13 +03:00
|
|
|
end
|
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
minetest.register_craftitem("ethereal:fish_" .. fish[n][2], {
|
2024-07-26 18:54:52 +03:00
|
|
|
description = S(fish[n][1]),
|
2021-03-14 22:55:16 +03:00
|
|
|
inventory_image = "ethereal_fish_" .. fish[n][2] .. ".png",
|
2021-03-20 13:44:13 +03:00
|
|
|
on_use = usage,
|
|
|
|
groups = groups
|
2021-03-14 22:55:16 +03:00
|
|
|
})
|
2024-07-26 18:54:52 +03:00
|
|
|
|
|
|
|
if groups then
|
|
|
|
ethereal.add_eatable("ethereal:fish_" .. fish[n][2], fish[n][3])
|
|
|
|
end
|
2021-03-14 22:55:16 +03:00
|
|
|
end
|
|
|
|
|
2023-04-22 17:31:18 +03:00
|
|
|
-- Make Neon Tetra glow slightly
|
2021-03-14 22:55:16 +03:00
|
|
|
|
2024-08-16 13:05:33 +03:00
|
|
|
minetest.override_item("ethereal:fish_tetra", {light_source = 3})
|
2021-03-14 22:55:16 +03:00
|
|
|
|
|
|
|
-- Worm
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2021-03-14 22:55:16 +03:00
|
|
|
minetest.register_craftitem("ethereal:worm", {
|
|
|
|
description = S("Worm"),
|
2021-04-02 23:06:43 +03:00
|
|
|
inventory_image = "ethereal_worm.png",
|
|
|
|
wield_image = "ethereal_worm.png"
|
2021-03-14 22:55:16 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "ethereal:worm",
|
|
|
|
recipe = {
|
2022-09-30 19:26:44 +03:00
|
|
|
{"default:dirt", "default:dirt"}
|
2021-03-14 22:55:16 +03:00
|
|
|
}
|
2015-11-23 23:43:48 +03:00
|
|
|
})
|
2021-03-15 16:06:21 +03:00
|
|
|
|
|
|
|
-- compatibility
|
2024-08-16 13:05:33 +03:00
|
|
|
|
2021-04-06 11:18:03 +03:00
|
|
|
minetest.register_alias("ethereal:fish_raw", "ethereal:fish_cichlid")
|
2021-03-15 16:06:21 +03:00
|
|
|
minetest.register_alias("ethereal:fishing_rod_baited", "ethereal:fishing_rod")
|
2021-04-06 11:18:03 +03:00
|
|
|
minetest.register_alias("ethereal:fish_chichlid", "ethereal:fish_cichlid")
|