mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 00:19:32 +01:00
Generalize anvil damage
This commit is contained in:
parent
584ef08266
commit
c71bd9588d
4 changed files with 22 additions and 5 deletions
|
@ -30,6 +30,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
|||
### Groups for interactions
|
||||
|
||||
* `crush_after_fall=1`: For falling nodes. These will crush whatever they hit after falling, not dropping as an item
|
||||
* `falling_node_damage=1`: For falling nodes. Hurts any objects it hits while falling. Damage is based on anvils
|
||||
* `dig_by_water=1`: Blocks with this group will drop when they are near flowing water
|
||||
* `destroy_by_lava_flow=1`: Blocks with this group will be destroyed by flowing lava
|
||||
* `dig_by_piston=1`: Blocks which will drop as an item when pushed by a piston. They also cannot be pulled by sticky pistons
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
local on_anvil_step = function(self, dtime)
|
||||
local on_damage_step = function(self, dtime)
|
||||
-- Cause damage to everything it hits.
|
||||
-- Algorithm based on MC anvils.
|
||||
local pos = self.object:get_pos()
|
||||
if not self._startpos then
|
||||
self._startpos = pos
|
||||
|
@ -28,7 +30,13 @@ local on_anvil_step = function(self, dtime)
|
|||
hp = 0
|
||||
end
|
||||
if v:is_player() then
|
||||
mcl_death_messages.player_damage(v, string.format("%s was smashed by a falling anvil.", v:get_player_name()))
|
||||
local msg
|
||||
if minetest.get_item_group(self.node.name, "anvil") ~= 0 then
|
||||
msg = "%s was smashed by a falling anvil."
|
||||
else
|
||||
msg = "%s was smashed by a falling block."
|
||||
end
|
||||
mcl_death_messages.player_damage(v, string.format(msg, v:get_player_name()))
|
||||
mcl_hunger.exhaust(v:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
||||
end
|
||||
v:set_hp(hp)
|
||||
|
@ -210,8 +218,8 @@ minetest.register_entity(":__builtin:falling_node", {
|
|||
end
|
||||
end
|
||||
|
||||
if minetest.get_item_group(self.node, "anvil") ~= 0 then
|
||||
on_anvil_step(self, dtime)
|
||||
if minetest.get_item_group(self.node.name, "falling_node_damage") ~= 0 then
|
||||
on_damage_step(self, dtime)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
|
|
@ -159,6 +159,14 @@ doc.sub.items.register_factoid("nodes", "gravity", function(itemstring, def)
|
|||
return s
|
||||
end)
|
||||
|
||||
doc.sub.items.register_factoid("nodes", "gravity", function(itemstring, def)
|
||||
local s = ""
|
||||
if minetest.get_item_group(itemstring, "crush_after_fall") == 1 then
|
||||
s = s .. "When this block falls deeper than 1 block, it causes damage to anything it hits. The damage dealt is B×2−2 hit points with B = number of blocks fallen. The damage can never be more than 40 HP."
|
||||
end
|
||||
return s
|
||||
end)
|
||||
|
||||
-- Mining, hardness and all that
|
||||
doc.sub.items.register_factoid("nodes", "mining", function(itemstring, def)
|
||||
local pickaxey = { "Diamond Pickaxe", "Iron Pickaxe", "Stone Pickaxe", "Golden Pickaxe", "Wooden Pickaxe" }
|
||||
|
|
|
@ -234,7 +234,7 @@ local function damage_anvil(pos)
|
|||
end
|
||||
|
||||
local anvildef = {
|
||||
groups = {pickaxey=1, falling_node=1, crush_after_fall=1, deco_block=1, anvil=1},
|
||||
groups = {pickaxey=1, falling_node=1, falling_node_damage=1, crush_after_fall=1, deco_block=1, anvil=1},
|
||||
tiles = {"mcl_anvils_anvil_top_damaged_0.png^[transformR90", "mcl_anvils_anvil_base.png", "mcl_anvils_anvil_side.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
|
|
Loading…
Reference in a new issue