Add velocity to mob drops
This commit is contained in:
parent
2b33600a42
commit
ba7dec1fdc
@ -145,6 +145,18 @@ rp_mobs.is_alive = function(mob)
|
||||
end
|
||||
end
|
||||
|
||||
rp_mobs.spawn_mob_drop = function(pos, item)
|
||||
local obj = minetest.add_item(pos, item)
|
||||
if obj then
|
||||
obj:set_velocity({
|
||||
x = math.random(-1, 1),
|
||||
y = 5,
|
||||
z = math.random(-1, 1)
|
||||
})
|
||||
end
|
||||
return obj
|
||||
end
|
||||
|
||||
rp_mobs.drop_death_items = function(self, pos)
|
||||
if not pos then
|
||||
pos = self.object:get_pos()
|
||||
@ -155,12 +167,12 @@ rp_mobs.drop_death_items = function(self, pos)
|
||||
end
|
||||
if not self._child and mobdef.drops then
|
||||
for d=1, #mobdef.drops do
|
||||
minetest.add_item(pos, mobdef.drops[d])
|
||||
rp_mobs.spawn_mob_drop(pos, mobdef.drops[d])
|
||||
end
|
||||
end
|
||||
if self._child and mobdef.child_drops then
|
||||
for d=1, #mobdef.child_drops do
|
||||
minetest.add_item(pos, mobdef.child_drops[d])
|
||||
rp_mobs.spawn_mob_drop(pos, mobdef.child_drops[d])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -163,15 +163,8 @@ rp_mobs.register_mob("rp_mobs_mobs:sheep", {
|
||||
self._custom_state.shorn = true
|
||||
local pos = self.object:get_pos()
|
||||
pos.y = pos.y + 0.5
|
||||
local obj = minetest.add_item(pos, ItemStack("mobs:wool"))
|
||||
local obj = rp_mobs.spawn_mob_drop(pos, ItemStack("mobs:wool"))
|
||||
minetest.sound_play({name = "default_shears_cut", gain = 0.5}, {pos = clicker:get_pos(), max_hear_distance = 8}, true)
|
||||
if obj then
|
||||
obj:set_velocity({
|
||||
x = math.random(-1,1),
|
||||
y = 5,
|
||||
z = math.random(-1,1)
|
||||
})
|
||||
end
|
||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
||||
local def = item:get_definition()
|
||||
local cuts = minetest.get_item_group(itemname, "sheep_cuts")
|
||||
|
Loading…
x
Reference in New Issue
Block a user