1
0
Fork 0

Something secret :P

This commit is contained in:
Lizzy Fleckenstein 2021-03-25 09:24:38 +01:00
parent 43a60e0c57
commit 46c6328432
2 changed files with 72 additions and 3 deletions

View File

@ -283,6 +283,33 @@ local get_velocity = function(self)
return 0 return 0
end 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 -- set and return valid yaw
local set_yaw = function(self, yaw, delay, dtime) 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 yaw = yaw + (math.random() * 2 - 1) * 5 * dtime
end end
self.object:set_yaw(yaw) self.object:set_yaw(yaw)
update_roll(self)
return yaw return yaw
end end
@ -645,9 +673,9 @@ local update_tag = function(self)
nametag = tag, nametag = tag,
}) })
update_roll(self)
end end
-- drop items -- drop items
local item_drop = function(self, cooked, looting_level) 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 yaw = yaw + (math.random() * 2 - 1) * 5 * dtime
end end
self.object:set_yaw(yaw) self.object:set_yaw(yaw)
update_roll(self)
end end
-- end rotation -- end rotation

View File

@ -25,6 +25,19 @@ local colors = {
unicolor_black = { mobs_mc.items.wool_black, "#000000D0" }, 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 if minetest.get_modpath("mcl_wool") ~= nil then
colors["unicolor_light_blue"] = { mobs_mc.items.wool_light_blue, "#5050FFD0" } colors["unicolor_light_blue"] = { mobs_mc.items.wool_light_blue, "#5050FFD0" }
end end
@ -112,7 +125,7 @@ mobs:register_mob("mobs_mc:sheep", {
end, end,
-- Set random color on spawn -- Set random color on spawn
do_custom = function(self) do_custom = function(self, dtime)
if not self.initial_color_set then if not self.initial_color_set then
local r = math.random(0,100000) local r = math.random(0,100000)
local textures local textures
@ -149,6 +162,33 @@ mobs:register_mob("mobs_mc:sheep", {
} }
self.initial_color_set = true self.initial_color_set = true
end 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, end,
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)