forked from VoxeLibre/VoxeLibre
Fix dispenser arrows so they hit players and entities, minetest.register_entity -> vl_projectile.register for mcl_throwing:egg
This commit is contained in:
parent
a2ef6c4dc9
commit
244cf40d11
|
@ -297,7 +297,7 @@ local arrow_entity = {
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
self._allow_punch = self._allow_punch or not self._startpos or pos and vector.distance(self._startpos, pos) > 1.5
|
self._allow_punch = self._allow_punch or not self._owner or not self._startpos or pos and vector.distance(self._startpos, pos) > 1.5
|
||||||
|
|
||||||
if self._stuck then
|
if self._stuck then
|
||||||
return stuck_arrow_on_step(self, dtime)
|
return stuck_arrow_on_step(self, dtime)
|
||||||
|
|
|
@ -35,7 +35,7 @@ local function egg_spawn_chicks(pos)
|
||||||
mcl_mobs.spawn_child(vector.offset(pos, -0.7, 0, 0.7), "mobs_mc:chicken")
|
mcl_mobs.spawn_child(vector.offset(pos, -0.7, 0, 0.7), "mobs_mc:chicken")
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("mcl_throwing:egg_entity",{
|
vl_projectile.register("mcl_throwing:egg_entity",{
|
||||||
physical = false,
|
physical = false,
|
||||||
timer=0,
|
timer=0,
|
||||||
textures = {"mcl_throwing_egg.png"},
|
textures = {"mcl_throwing_egg.png"},
|
||||||
|
|
|
@ -205,13 +205,18 @@ function mod.collides_with_solids(self, dtime, entity_def, projectile_def)
|
||||||
-- Projectile has stopped in one axis, so it probably hit something.
|
-- Projectile has stopped in one axis, so it probably hit something.
|
||||||
-- This detection is a bit clunky, but sadly, MT does not offer a direct collision detection for us. :-(
|
-- This detection is a bit clunky, but sadly, MT does not offer a direct collision detection for us. :-(
|
||||||
local vel = self.object:get_velocity()
|
local vel = self.object:get_velocity()
|
||||||
if math.abs(vel.x) >= 0.0001 and math.abs(vel.z) >= 0.0001 and math.abs(vel.y) >= 0.0001 then
|
if not self._last_velocity then
|
||||||
self._last_pos = pos
|
self._last_velocity = vel
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local delta_v = (vel - self._last_velocity) / vector.length(vel)
|
||||||
|
if math.abs(delta_v.x) <= 0.1 and math.abs(delta_v.z) <= 0.1 and math.abs(delta_v.y) <= 0.2 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self._last_velocity = vel
|
||||||
else
|
else
|
||||||
if node_def and not node_def.walkable and (not collides_with or not mcl_util.match_node_to_filter(node.name, collides_with)) then
|
if node_def and not node_def.walkable and (not collides_with or not mcl_util.match_node_to_filter(node.name, collides_with)) then
|
||||||
self._last_pos = pos
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -364,7 +369,6 @@ function mod.raycast_collides_with_entities(self, dtime, entity_def, projectile_
|
||||||
closest_distance = dist
|
closest_distance = dist
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if closest_object then
|
if closest_object then
|
||||||
|
|
Loading…
Reference in New Issue