0
0
Fork 0

Added shepherd functionality

This commit is contained in:
the-real-herowl 2023-12-24 05:48:41 +01:00
parent dd7d56a385
commit a2a4da5aed
11 changed files with 119 additions and 15 deletions

View File

@ -1096,3 +1096,12 @@ function mcl_util.move_player_list(player, src_listname)
vector.offset(player:get_pos(), 0, 1.2, 0), vector.offset(player:get_pos(), 0, 1.2, 0),
player:get_look_dir(), false) player:get_look_dir(), false)
end end
function mcl_util.is_it_christmas()
local date = os.date("*t")
if date.month == 12 and date.day >= 24 or date.month == 1 and date.day <= 7 then
return true
else
return false
end
end

View File

@ -32,6 +32,9 @@ function mob_class:feed_tame(clicker, feed_count, breed, tame, notake)
if not self.follow then if not self.follow then
return false return false
end end
if clicker:get_wielded_item():get_definition()._mcl_not_consumable then
return false
end
-- can eat/tame with item in hand -- can eat/tame with item in hand
if self.nofollow or self:follow_holding(clicker) then if self.nofollow or self:follow_holding(clicker) then
local consume_food = false local consume_food = false

View File

@ -111,7 +111,7 @@ mcl_mobs.register_mob("mobs_mc:sheep", {
run_start = 81, run_end = 121, run_speed = 60, run_start = 81, run_end = 121, run_speed = 60,
eat_start = 121, eat_start = 161, eat_loop = false, eat_start = 121, eat_start = 161, eat_loop = false,
}, },
follow = { "mcl_farming:wheat_item" }, follow = { "mcl_farming:wheat_item", "mcl_shepherd:shepherd_staff" },
view_range = 12, view_range = 12,
-- Eat grass -- Eat grass

View File

@ -120,12 +120,13 @@ mcl_weather.skycolor = {
override_day_night_ratio = function(player, ratio) override_day_night_ratio = function(player, ratio)
local meta = player:get_meta() local meta = player:get_meta()
local has_night_vision = meta:get_int("night_vision") == 1 local has_night_vision = meta:get_int("night_vision") == 1
local is_visited_shepherd = meta:get_int("mcl_shepherd:special") == 1
local arg local arg
-- Apply night vision only for dark sky -- Apply night vision only for dark sky
local is_dark = minetest.get_timeofday() > 0.8 or minetest.get_timeofday() < 0.2 or mcl_weather.state ~= "none" local is_dark = minetest.get_timeofday() > 0.8 or minetest.get_timeofday() < 0.2 or mcl_weather.state ~= "none"
local pos = player:get_pos() local pos = player:get_pos()
local dim = mcl_worlds.pos_to_dimension(pos) local dim = mcl_worlds.pos_to_dimension(pos)
if has_night_vision and is_dark and dim ~= "nether" and dim ~= "end" then if (has_night_vision or is_visited_shepherd) and is_dark and dim ~= "nether" and dim ~= "end" then
if ratio == nil then if ratio == nil then
arg = NIGHT_VISION_RATIO arg = NIGHT_VISION_RATIO
else else

View File

@ -13,17 +13,7 @@ local mod_doc = minetest.get_modpath("doc")
mcl_chests = {} mcl_chests = {}
-- Christmas chest setup -- Christmas chest setup
local it_is_christmas = false local it_is_christmas = mcl_util.is_it_christmas()
local date = os.date("*t")
if (
date.month == 12 and (
date.day == 24 or
date.day == 25 or
date.day == 26
)
) then
it_is_christmas = true
end
local tiles_chest_normal_small = { "mcl_chests_normal.png" } local tiles_chest_normal_small = { "mcl_chests_normal.png" }
local tiles_chest_normal_double = { "mcl_chests_normal_double.png" } local tiles_chest_normal_double = { "mcl_chests_normal_double.png" }

View File

@ -0,0 +1,91 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
minetest.register_tool("mcl_shepherd:shepherd_staff", {
description = S("Shepherd Staff"),
_doc_items_longdesc = S(""),
_doc_items_usagehelp = S(""),
inventory_image = "mcl_tool_shepherd_staff.png",
wield_scale = 1.3*mcl_vars.tool_wield_scale,
stack_max = 1,
groups = { weapon=1, tool=1, staff=1, enchantability=-1 },
tool_capabilities = {
full_punch_interval = 1,
max_drop_level=1,
damage_groups = {fleshy=2},
punch_attack_uses = 45,
},
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_diggroups = {
swordy = { speed = 1, level = 1, uses = 60 },
swordy_cobweb = { speed = 1, level = 1, uses = 60 }
},
_mcl_not_consumable = true,
})
if mcl_util.is_it_christmas() then
minetest.register_globalstep(function(dtime)
local time = minetest.get_timeofday()
if time < 0.005 or time > 0.995 then
for _, player in pairs(minetest.get_connected_players()) do
local meta = player:get_meta()
local sp = meta:get_int("mcl_shepherd:special")
if sp == 0 and player:get_wielded_item():get_definition().groups.staff then
local has_sheep = false
for _, obj in pairs(minetest.get_objects_inside_radius(player:get_pos(), 3)) do
local ent = obj:get_luaentity()
if ent and ent.name == "mobs_mc:sheep" then
has_sheep = true
break
end
end
if has_sheep then
minetest.sound_play(
{name="shepherd-midnight", gain=3, pitch=1.0},
{to_player=player:get_player_name(), gain=1.0, fade=0.0, pitch=1.0},
false
)
meta:set_int("mcl_shepherd:special", 1)
mcl_weather.skycolor.update_sky_color({player})
minetest.after(45, function(name)
local player = minetest.get_player_by_name(name)
if not player then return end
local meta = player:get_meta()
meta:set_int("mcl_shepherd:special", 0)
mcl_weather.skycolor.update_sky_color({player})
end, player:get_player_name())
end
end
end
end
end)
minetest.register_on_joinplayer(function(player)
local meta = player:get_meta()
meta:set_int("mcl_shepherd:special", 0)
end)
end
minetest.register_craft({
output = "mcl_shepherd:shepherd_staff",
recipe = {
{"","","mcl_core:stick"},
{"","mcl_core:stick",""},
{"mcl_core:stick","",""},
}
})
minetest.register_craft({
output = "mcl_shepherd:shepherd_staff",
recipe = {
{"mcl_core:stick", "", ""},
{"", "mcl_core:stick", ""},
{"","","mcl_core:stick"},
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_shepherd:shepherd_staff",
burntime = 15,
})

View File

@ -0,0 +1,4 @@
name = mcl_shepherd
author = Herowl
depends = mcl_core, mobs_mc, mcl_util
optional_depends = doc

Binary file not shown.

View File

@ -38,6 +38,12 @@ local function add_scope(player)
text = "mcl_spyglass_scope.png", text = "mcl_spyglass_scope.png",
}) })
player:hud_set_flags({wielditem = false}) player:hud_set_flags({wielditem = false})
if mcl_util.is_it_christmas() then
local time = minetest.get_timeofday()
if (time < 0.01 or time > 0.99) and player:get_look_vertical() < -1.335 then
player:set_moon({texture = "mcl_moon_special.png"})
end
end
end end
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B