make fire charges activate target (+ fix possible crash)

This commit is contained in:
AFCMS 2022-02-26 22:38:34 +01:00
parent 096d46152e
commit b51e322304
Signed by untrusted user: AFCMS
GPG Key ID: 8720389A25B652E3
1 changed files with 9 additions and 5 deletions

View File

@ -5,6 +5,8 @@
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator("mobs_mc")
local mod_target = minetest.get_modpath("mcl_target")
--################### --###################
--################### BLAZE --################### BLAZE
--################### --###################
@ -178,17 +180,19 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
-- Node hit, make fire -- Node hit, make fire
hit_node = function(self, pos, node) hit_node = function(self, pos, node)
if node.name == "air" then if node == "air" then
minetest.set_node(pos_above, {name=mobs_mc.items.fire}) minetest.set_node(pos, {name = mobs_mc.items.fire})
else else
local v = self.object:get_velocity() if self._shot_from_dispenser and mod_target and node == "mcl_target:target_off" then
v = vector.normalize(v) mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
end
local v = vector.normalize(self.object:get_velocity())
local crashpos = vector.subtract(pos, v) local crashpos = vector.subtract(pos, v)
local crashnode = minetest.get_node(crashpos) local crashnode = minetest.get_node(crashpos)
-- Set fire if node is air, or a replacable flammable node (e.g. a plant) -- Set fire if node is air, or a replacable flammable node (e.g. a plant)
if crashnode.name == "air" or if crashnode.name == "air" or
(minetest.registered_nodes[crashnode.name].buildable_to and minetest.get_item_group(crashnode.name, "flammable") >= 1) then (minetest.registered_nodes[crashnode.name].buildable_to and minetest.get_item_group(crashnode.name, "flammable") >= 1) then
minetest.set_node(crashpos, {name=mobs_mc.items.fire}) minetest.set_node(crashpos, {name = mobs_mc.items.fire})
end end
end end
end end