Soften dependencies in mcl_throwing

This commit is contained in:
Wuzzy 2017-07-26 19:35:56 +02:00
parent 11bd39774a
commit a06670b02f
3 changed files with 38 additions and 29 deletions

View File

@ -1,3 +1,6 @@
local mod_mcl_hunger = minetest.get_modpath("mcl_hunger")
local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements")
minetest.register_craftitem("mcl_throwing:arrow", {
description = "Arrow",
_doc_items_longdesc = "Arrows are ammunition for bows and dispensers.",
@ -90,7 +93,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
full_punch_interval=1.0,
damage_groups={fleshy=self._damage},
}, nil)
if is_player then
if mod_mcl_hunger and is_player then
mcl_hunger.exhaust(obj:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
end
@ -100,7 +103,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
-- NOTE: Range has been reduced because mobs unload much earlier than that ... >_>
-- TODO: This achievement should be given for the kill, not just a hit
if self._shooter and self._shooter:is_player() and vector.distance(pos, self._startpos) >= 20 then
if (entity_name == "mobs_mc:skeleton" or entity_name == "mobs_mc:stray" or entity_name == "mobs_mc:witherskeleton") then
if mod_awards and (entity_name == "mobs_mc:skeleton" or entity_name == "mobs_mc:stray" or entity_name == "mobs_mc:witherskeleton") then
awards.unlock(self._shooter:get_player_name(), "mcl:snipeSkeleton")
end
end
@ -127,6 +130,7 @@ end
minetest.register_entity("mcl_throwing:arrow_entity", THROWING_ARROW_ENTITY)
if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then
minetest.register_craft({
output = 'mcl_throwing:arrow 4',
recipe = {
@ -135,3 +139,4 @@ minetest.register_craft({
{'mcl_mobitems:feather'}
}
})
end

View File

@ -1,4 +1,6 @@
mcl_core
mcl_hunger
mcl_achievements
awards?
mcl_achievements?
mcl_hunger?
mcl_core?
mcl_mobitems?
doc?

View File

@ -191,6 +191,7 @@ minetest.register_tool("mcl_throwing:bow_2", {
end,
})
if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then
minetest.register_craft({
output = 'mcl_throwing:bow',
recipe = {
@ -207,6 +208,7 @@ minetest.register_craft({
{'mcl_mobitems:string', 'mcl_core:stick', ''},
}
})
end
minetest.register_craft({
type = "fuel",