From 04c8a08cc4bb8f1f9a658ce182c548974f7ed7dd Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 30 Jan 2020 23:11:16 +0100 Subject: [PATCH] Ignite tnt minecart by fire charge --- mods/ENTITIES/mcl_minecarts/init.lua | 10 +++++++--- mods/ENTITIES/mcl_mobs/api.lua | 14 +++++++++++--- mods/ENTITIES/mcl_mobs/api.txt | 3 +++ mods/ENTITIES/mobs_mc/blaze.lua | 9 +++++++++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index 17b01ff42..035534815 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -23,12 +23,16 @@ local function detach_driver(self) end end -local function activate_tnt_minecart(self) +local function activate_tnt_minecart(self, timer) if self._boomtimer then return end self.object:set_armor_groups({immortal=1}) - self._boomtimer = tnt.BOOMTIMER + if timer then + self._boomtimer = timer + else + self._boomtimer = tnt.BOOMTIMER + end self.object:set_properties({textures = { "mcl_tnt_blink.png", "mcl_tnt_blink.png", @@ -600,7 +604,7 @@ register_minecart( S("Minecarts can be used for a quick transportion on rails.") .. "\n" .. S("Minecarts only ride on rails and always follow the tracks. At a T-junction with no straight way ahead, they turn left. The speed is affected by the rail type."), S("You can place the minecart on rails. Right-click it to enter it. Punch it to get it moving.") .. "\n" .. - S("To obtain the minecart, punch it while holding down the sneak key.") .. "\n" + S("To obtain the minecart, punch it while holding down the sneak key.") .. "\n" .. S("If it moves over a powered activator rail, you'll get ejected."), "mcl_minecarts_minecart.b3d", {"mcl_minecarts_minecart.png"}, diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index b736bf6fb..b07dd00a2 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -3605,6 +3605,7 @@ function mobs:register_arrow(name, def) hit_player = def.hit_player, hit_node = def.hit_node, hit_mob = def.hit_mob, + hit_object = def.hit_object, drop = def.drop or false, -- drops arrow as registered item when true collisionbox = {0, 0, 0, 0, 0, 0}, -- remove box around arrows timer = 0, @@ -3671,7 +3672,7 @@ function mobs:register_arrow(name, def) end end - if self.hit_player or self.hit_mob then + if self.hit_player or self.hit_mob or self.hit_object then for _,player in pairs(minetest.get_objects_inside_radius(pos, 1.0)) do @@ -3690,11 +3691,18 @@ function mobs:register_arrow(name, def) and entity._cmi_is_mob == true and tostring(player) ~= self.owner_id and entity.name ~= self.object:get_luaentity().name then - self.hit_mob(self, player) - self.object:remove(); + return + end + if entity + and self.hit_object + and (not entity._cmi_is_mob) + and tostring(player) ~= self.owner_id + and entity.name ~= self.object:get_luaentity().name then + self.hit_object(self, player) + self.object:remove(); return end end diff --git a/mods/ENTITIES/mcl_mobs/api.txt b/mods/ENTITIES/mcl_mobs/api.txt index 8a2861e41..3a61c1c83 100644 --- a/mods/ENTITIES/mcl_mobs/api.txt +++ b/mods/ENTITIES/mcl_mobs/api.txt @@ -428,6 +428,9 @@ This function registers a arrow for mobs with the attack type shoot. 'hit_mob' a function that is called when the arrow hits a mob; this function should hurt the mob, the parameters are (self, mob) + 'hit_object' a function that is called when the arrow hits an object + that is neither a player nor a mob. this function should + hurt the object, the parameters are (self, object) 'hit_node' a function that is called when the arrow hits a node, the parameters are (self, pos, node) 'tail' when set to 1 adds a trail or tail to mob arrows diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index 4562fea26..adf5238c9 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -95,6 +95,15 @@ mobs:register_arrow("mobs_mc:blaze_fireball", { }, nil) end, + hit_object = function(self, object) + local lua = object:get_luaentity() + if lua then + if lua.name == "mcl_minecarts:tnt_minecart" then + lua:on_activate_by_rail(2) + end + end + end, + -- Node hit, make fire hit_node = function(self, pos, node) if node.name == "air" then