forked from MineClone5/MineClone5
Implement basics of head movement and fix walking mobs flying away after floating
This commit is contained in:
parent
bac191293b
commit
df364eed28
|
@ -165,6 +165,7 @@ dofile(api_path .. "death_logic.lua")
|
||||||
dofile(api_path .. "mob_effects.lua")
|
dofile(api_path .. "mob_effects.lua")
|
||||||
dofile(api_path .. "projectile_handling.lua")
|
dofile(api_path .. "projectile_handling.lua")
|
||||||
dofile(api_path .. "breeding.lua")
|
dofile(api_path .. "breeding.lua")
|
||||||
|
dofile(api_path .. "head_logic.lua")
|
||||||
|
|
||||||
|
|
||||||
mobs.spawning_mobs = {}
|
mobs.spawning_mobs = {}
|
||||||
|
@ -362,9 +363,14 @@ function mobs:register_mob(name, def)
|
||||||
ignores_cobwebs = def.ignores_cobwebs,
|
ignores_cobwebs = def.ignores_cobwebs,
|
||||||
breath = def.breath_max or 6,
|
breath = def.breath_max or 6,
|
||||||
|
|
||||||
--random_sound_timer = 0,
|
|
||||||
random_sound_timer_min = 3,
|
random_sound_timer_min = 3,
|
||||||
random_sound_timer_max = 10,
|
random_sound_timer_max = 10,
|
||||||
|
|
||||||
|
|
||||||
|
--head code variables
|
||||||
|
has_head = def.has_head or false,
|
||||||
|
head_bone = def.head_bone,
|
||||||
|
|
||||||
--end j4i stuff
|
--end j4i stuff
|
||||||
|
|
||||||
-- MCL2 extensions
|
-- MCL2 extensions
|
||||||
|
|
|
@ -371,6 +371,8 @@ local land_state_execution = function(self,dtime)
|
||||||
|
|
||||||
if float_now then
|
if float_now then
|
||||||
mobs.float(self)
|
mobs.float(self)
|
||||||
|
elseif self.object:get_acceleration().y == 0 then
|
||||||
|
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -817,6 +819,17 @@ mobs.mob_step = function(self, dtime)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--DEBUG TIME!
|
||||||
|
|
||||||
|
mobs.do_head_logic(self)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--if true then--DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
|
||||||
|
-- return
|
||||||
|
--end
|
||||||
|
|
||||||
--despawn mechanism
|
--despawn mechanism
|
||||||
--don't despawned tamed or bred mobs
|
--don't despawned tamed or bred mobs
|
||||||
if not self.tamed and not self.bred then
|
if not self.tamed and not self.bred then
|
||||||
|
@ -1101,13 +1114,19 @@ mobs.mob_step = function(self, dtime)
|
||||||
|
|
||||||
mobs.stick_in_cobweb(self)
|
mobs.stick_in_cobweb(self)
|
||||||
|
|
||||||
|
self.was_stuck_in_cobweb = true
|
||||||
|
|
||||||
else
|
else
|
||||||
|
--do not override other functions
|
||||||
|
if self.was_stuck_in_cobweb == true then
|
||||||
--return the mob back to normal
|
--return the mob back to normal
|
||||||
|
self.was_stuck_in_cobweb = nil
|
||||||
if self.object:get_acceleration().y == 0 and not self.swim and not self.fly then
|
if self.object:get_acceleration().y == 0 and not self.swim and not self.fly then
|
||||||
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.old_velocity = self.object:get_velocity()
|
self.old_velocity = self.object:get_velocity()
|
||||||
self.old_pos = self.object:get_pos()
|
self.old_pos = self.object:get_pos()
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
mobs.do_head_logic = function(self)
|
||||||
|
local yaw = self.object:get_yaw()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue