mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Something secret :P
This commit is contained in:
parent
43a60e0c57
commit
46c6328432
@ -283,6 +283,33 @@ local get_velocity = function(self)
|
||||
return 0
|
||||
end
|
||||
|
||||
local function update_roll(self)
|
||||
local is_Fleckenstein = self.nametag == "Fleckenstein"
|
||||
local was_Fleckenstein = false
|
||||
|
||||
local rot = self.object:get_rotation()
|
||||
rot.z = is_Fleckenstein and pi or 0
|
||||
self.object:set_rotation(rot)
|
||||
|
||||
local cbox = table.copy(self.collisionbox)
|
||||
local acbox = self.object:get_properties().collisionbox
|
||||
|
||||
if math.abs(cbox[2] - acbox[2]) > 0.1 then
|
||||
was_Fleckenstein = true
|
||||
end
|
||||
|
||||
if is_Fleckenstein ~= was_Fleckenstein then
|
||||
local pos = self.object:get_pos()
|
||||
pos.y = pos.y + (acbox[2] + acbox[5])
|
||||
self.object:set_pos(pos)
|
||||
end
|
||||
|
||||
if is_Fleckenstein then
|
||||
cbox[2], cbox[5] = -cbox[5], -cbox[2]
|
||||
end
|
||||
|
||||
self.object:set_properties({collisionbox = cbox})
|
||||
end
|
||||
|
||||
-- set and return valid yaw
|
||||
local set_yaw = function(self, yaw, delay, dtime)
|
||||
@ -298,6 +325,7 @@ local set_yaw = function(self, yaw, delay, dtime)
|
||||
yaw = yaw + (math.random() * 2 - 1) * 5 * dtime
|
||||
end
|
||||
self.object:set_yaw(yaw)
|
||||
update_roll(self)
|
||||
return yaw
|
||||
end
|
||||
|
||||
@ -645,9 +673,9 @@ local update_tag = function(self)
|
||||
nametag = tag,
|
||||
})
|
||||
|
||||
update_roll(self)
|
||||
end
|
||||
|
||||
|
||||
-- drop items
|
||||
local item_drop = function(self, cooked, looting_level)
|
||||
|
||||
@ -3487,6 +3515,7 @@ local mob_step = function(self, dtime)
|
||||
yaw = yaw + (math.random() * 2 - 1) * 5 * dtime
|
||||
end
|
||||
self.object:set_yaw(yaw)
|
||||
update_roll(self)
|
||||
end
|
||||
|
||||
-- end rotation
|
||||
|
@ -25,6 +25,19 @@ local colors = {
|
||||
unicolor_black = { mobs_mc.items.wool_black, "#000000D0" },
|
||||
}
|
||||
|
||||
local rainbow_colors = {
|
||||
"unicolor_light_red",
|
||||
"unicolor_red",
|
||||
"unicolor_orange",
|
||||
"unicolor_yellow",
|
||||
"unicolor_green",
|
||||
"unicolor_dark_green",
|
||||
"unicolor_light_blue",
|
||||
"unicolor_blue",
|
||||
"unicolor_violet",
|
||||
"unicolor_red_violet"
|
||||
}
|
||||
|
||||
if minetest.get_modpath("mcl_wool") ~= nil then
|
||||
colors["unicolor_light_blue"] = { mobs_mc.items.wool_light_blue, "#5050FFD0" }
|
||||
end
|
||||
@ -112,7 +125,7 @@ mobs:register_mob("mobs_mc:sheep", {
|
||||
end,
|
||||
|
||||
-- Set random color on spawn
|
||||
do_custom = function(self)
|
||||
do_custom = function(self, dtime)
|
||||
if not self.initial_color_set then
|
||||
local r = math.random(0,100000)
|
||||
local textures
|
||||
@ -149,6 +162,33 @@ mobs:register_mob("mobs_mc:sheep", {
|
||||
}
|
||||
self.initial_color_set = true
|
||||
end
|
||||
|
||||
local is_kay27 = self.nametag == "kay27"
|
||||
|
||||
if self.color_change_timer then
|
||||
local old_color = self.color
|
||||
if is_kay27 then
|
||||
self.color_change_timer = self.color_change_timer - dtime
|
||||
if self.color_change_timer < 0 then
|
||||
self.color_change_timer = 0.5
|
||||
self.color_index = (self.color_index + 1) % #rainbow_colors
|
||||
self.color = rainbow_colors[self.color_index + 1]
|
||||
end
|
||||
else
|
||||
self.color_change_timer = nil
|
||||
self.color_index = nil
|
||||
self.color = self.initial_color
|
||||
end
|
||||
|
||||
if old_color ~= self.color then
|
||||
self.base_texture = sheep_texture(self.color)
|
||||
self.object:set_properties({textures = self.base_texture})
|
||||
end
|
||||
elseif is_kay27 then
|
||||
self.initial_color = self.color
|
||||
self.color_change_timer = 0
|
||||
self.color_index = -1
|
||||
end
|
||||
end,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
|
Loading…
Reference in New Issue
Block a user