Add colored Sheep
Sheep spawn randomly with white, grey, brown or black wool
This commit is contained in:
parent
ac569c49a9
commit
4096344c6f
@ -1,12 +1,13 @@
|
|||||||
Sheep for Creatures MOB-Engine
|
Sheep for Creatures MOB-Engine
|
||||||
==============================
|
==============================
|
||||||
Copyright (c) 2015 BlockMen <blockmen2015@gmail.com>
|
Copyright (c) 2015-2016 BlockMen <blockmen2015@gmail.com>
|
||||||
|
|
||||||
Version: 2.0 Beta
|
Version: 2.1
|
||||||
|
|
||||||
|
|
||||||
Adds sheep to Minetest (requires Creatures MOB-Engine).
|
Adds sheep to Minetest (requires Creatures MOB-Engine).
|
||||||
Sheep spawn only at day-time and are friendly and remain around 5 minutes in the world.
|
Sheep spawn only at day-time and are friendly and remain around 5 minutes in the world.
|
||||||
|
There are four different wool colors: white, grey, brown and black.
|
||||||
You can tame them by feading them with wheat. If there is grass they eat the grass
|
You can tame them by feading them with wheat. If there is grass they eat the grass
|
||||||
and regrow wool that way. They will follow you if you have Wheat in your hand.
|
and regrow wool that way. They will follow you if you have Wheat in your hand.
|
||||||
Sheep have 8 HP and drop 1-2 wool when punched or 1-3 wool when using shears.
|
Sheep have 8 HP and drop 1-2 wool when punched or 1-3 wool when using shears.
|
||||||
@ -20,11 +21,11 @@ ingot stick
|
|||||||
License:
|
License:
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
Code:
|
Code:
|
||||||
(c) Copyright 2015 BlockMen; modified zlib-License
|
(c) Copyright 2015-2016 BlockMen; modified zlib-License
|
||||||
see "LICENSE.txt" for details.
|
see "LICENSE.txt" for details.
|
||||||
|
|
||||||
Media(textures and meshes/models):
|
Media(textures and meshes/models):
|
||||||
(c) Copyright (2014-2015) BlockMen; CC-BY-SA 3.0
|
(c) Copyright (2014-2016) BlockMen; CC-BY-SA 3.0
|
||||||
|
|
||||||
Sounds:
|
Sounds:
|
||||||
- creatures_sheep.1.ogg, confusion_music(https://freesound.org/people/confusion_music) CC-BY 3.0
|
- creatures_sheep.1.ogg, confusion_music(https://freesound.org/people/confusion_music) CC-BY 3.0
|
||||||
|
299
sheep/init.lua
299
sheep/init.lua
@ -1,5 +1,5 @@
|
|||||||
--= Sheep for Creatures MOB-Engine (cme) =--
|
--= Sheep for Creatures MOB-Engine (cme) =--
|
||||||
-- Copyright (c) 2015 BlockMen <blockmen2015@gmail.com>
|
-- Copyright (c) 2015-2016 BlockMen <blockmen2015@gmail.com>
|
||||||
--
|
--
|
||||||
-- init.lua
|
-- init.lua
|
||||||
--
|
--
|
||||||
@ -34,163 +34,182 @@ core.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
local function shear(self, drop_count, sound)
|
|
||||||
if self.has_wool == true then
|
|
||||||
self.has_wool = false
|
|
||||||
local pos = self.object:getpos()
|
|
||||||
|
|
||||||
if sound then
|
local function setColor(self)
|
||||||
core.sound_play("creatures_shears", {pos = pos, gain = 1, max_hear_distance = 10})
|
if self and self.object then
|
||||||
end
|
local ext = ".png"
|
||||||
self.object:set_properties({textures = {"creatures_sheep.png"}})
|
if self.has_wool ~= true then
|
||||||
creatures.dropItems(pos, {{"wool:white", drop_count}})
|
ext = ".png^(creatures_sheep_shaved.png^[colorize:" .. self.wool_color:gsub("grey", "gray") .. ":50)"
|
||||||
end
|
end
|
||||||
|
self.object:set_properties({textures = {"creatures_sheep.png^creatures_sheep_" .. self.wool_color .. ext}})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function shear(self, drop_count, sound)
|
||||||
|
if self.has_wool == true then
|
||||||
|
self.has_wool = false
|
||||||
|
local pos = self.object:getpos()
|
||||||
|
if sound then
|
||||||
|
core.sound_play("creatures_shears", {pos = pos, gain = 1, max_hear_distance = 10})
|
||||||
|
end
|
||||||
|
|
||||||
|
setColor(self)
|
||||||
|
creatures.dropItems(pos, {{"wool:" .. self.wool_color, drop_count}})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- white, grey, brown, black (see wool colors as reference)
|
||||||
|
local colors = {"white", "grey", "brown", "black"}
|
||||||
|
|
||||||
local def = {
|
local def = {
|
||||||
name = "creatures:sheep",
|
name = "creatures:sheep",
|
||||||
stats = {
|
stats = {
|
||||||
hp = 8,
|
hp = 8,
|
||||||
lifetime = 450, -- 7,5 Minutes
|
lifetime = 450, -- 7,5 Minutes
|
||||||
can_jump = 1,
|
can_jump = 1,
|
||||||
can_swim = true,
|
can_swim = true,
|
||||||
can_burn = true,
|
can_burn = true,
|
||||||
can_panic = true,
|
can_panic = true,
|
||||||
has_falldamage = true,
|
has_falldamage = true,
|
||||||
has_kockback = true,
|
has_kockback = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
model = {
|
model = {
|
||||||
mesh = "creatures_sheep.b3d",
|
mesh = "creatures_sheep.b3d",
|
||||||
textures = {"creatures_sheep.png^creatures_sheep_white.png"},
|
textures = {"creatures_sheep.png^creatures_sheep_white.png"},
|
||||||
collisionbox = {-0.5, -0.01, -0.55, 0.5, 1.1, 0.55},
|
collisionbox = {-0.5, -0.01, -0.55, 0.5, 1.1, 0.55},
|
||||||
rotation = -90.0,
|
rotation = -90.0,
|
||||||
animations = {
|
animations = {
|
||||||
idle = {start = 1, stop = 60, speed = 15},
|
idle = {start = 1, stop = 60, speed = 15},
|
||||||
walk = {start = 81, stop = 101, speed = 18},
|
walk = {start = 81, stop = 101, speed = 18},
|
||||||
walk_long = {start = 81, stop = 101, speed = 18},
|
walk_long = {start = 81, stop = 101, speed = 18},
|
||||||
eat = {start = 107, stop = 170, speed = 12, loop = false},
|
eat = {start = 107, stop = 170, speed = 12, loop = false},
|
||||||
follow = {start = 81, stop = 101, speed = 15},
|
follow = {start = 81, stop = 101, speed = 15},
|
||||||
death = {start = 171, stop = 191, speed = 32, loop = false, duration = 2.52},
|
death = {start = 171, stop = 191, speed = 32, loop = false, duration = 2.52},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
sounds = {
|
sounds = {
|
||||||
on_damage = {name = "creatures_sheep", gain = 1.0, distance = 10},
|
on_damage = {name = "creatures_sheep", gain = 1.0, distance = 10},
|
||||||
on_death = {name = "creatures_sheep", gain = 1.0, distance = 10},
|
on_death = {name = "creatures_sheep", gain = 1.0, distance = 10},
|
||||||
swim = {name = "creatures_splash", gain = 1.0, distance = 10,},
|
swim = {name = "creatures_splash", gain = 1.0, distance = 10,},
|
||||||
random = {
|
random = {
|
||||||
idle = {name = "creatures_sheep", gain = 0.6, distance = 10, time_min = 23},
|
idle = {name = "creatures_sheep", gain = 0.6, distance = 10, time_min = 23},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
modes = {
|
modes = {
|
||||||
idle = {chance = 0.5, duration = 10, update_yaw = 8},
|
idle = {chance = 0.5, duration = 10, update_yaw = 8},
|
||||||
walk = {chance = 0.14, duration = 4.5, moving_speed = 1.3},
|
walk = {chance = 0.14, duration = 4.5, moving_speed = 1.3},
|
||||||
walk_long = {chance = 0.11, duration = 8, moving_speed = 1.3, update_yaw = 5},
|
walk_long = {chance = 0.11, duration = 8, moving_speed = 1.3, update_yaw = 5},
|
||||||
-- special modes
|
-- special modes
|
||||||
follow = {chance = 0, duration = 20, radius = 4, timer = 5, moving_speed = 1, items = {"farming:wheat"}},
|
follow = {chance = 0, duration = 20, radius = 4, timer = 5, moving_speed = 1, items = {"farming:wheat"}},
|
||||||
eat = {chance = 0.25,
|
eat = { chance = 0.25,
|
||||||
duration = 4,
|
duration = 4,
|
||||||
nodes = {
|
nodes = {
|
||||||
"default:grass_1", "default:grass_2", "default:grass_3",
|
"default:grass_1", "default:grass_2", "default:grass_3",
|
||||||
"default:grass_4", "default:grass_5", "default:dirt_with_grass"
|
"default:grass_4", "default:grass_5", "default:dirt_with_grass"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
drops = function(self)
|
drops = function(self)
|
||||||
local items = {{"creatures:flesh"}}
|
local items = {{"creatures:flesh"}}
|
||||||
if self.has_wool then
|
if self.has_wool then
|
||||||
table.insert(items, {"wool:white", {min = 1, max = 2}})
|
table.insert(items, {"wool:" .. self.wool_color, {min = 1, max = 2}})
|
||||||
end
|
end
|
||||||
creatures.dropItems(self.object:getpos(), items)
|
creatures.dropItems(self.object:getpos(), items)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
spawning = {
|
spawning = {
|
||||||
abm_nodes = {
|
abm_nodes = {
|
||||||
spawn_on = {"default:dirt_with_grass"},
|
spawn_on = {"default:dirt_with_grass"},
|
||||||
},
|
},
|
||||||
abm_interval = 55,
|
abm_interval = 55,
|
||||||
abm_chance = 7800,
|
abm_chance = 7800,
|
||||||
max_number = 1,
|
max_number = 1,
|
||||||
number = {min = 1, max = 3},
|
number = {min = 1, max = 3},
|
||||||
time_range = {min = 5100, max = 18300},
|
time_range = {min = 5100, max = 18300},
|
||||||
light = {min = 10, max = 15},
|
light = {min = 10, max = 15},
|
||||||
height_limit = {min = 0, max = 25},
|
height_limit = {min = 0, max = 25},
|
||||||
|
|
||||||
spawn_egg = {
|
spawn_egg = {
|
||||||
description = "Sheep Spawn-Egg",
|
description = "Sheep Spawn-Egg",
|
||||||
texture = "creatures_egg_sheep.png",
|
texture = "creatures_egg_sheep.png",
|
||||||
},
|
},
|
||||||
|
|
||||||
spawner = {
|
spawner = {
|
||||||
description = "Sheep Spawner",
|
description = "Sheep Spawner",
|
||||||
range = 8,
|
range = 8,
|
||||||
player_range = 20,
|
player_range = 20,
|
||||||
number = 6,
|
number = 6,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
on_punch = function(self, puncher)
|
on_punch = function(self, puncher)
|
||||||
shear(self)
|
shear(self)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get_staticdata = function(self)
|
get_staticdata = function(self)
|
||||||
return {
|
return {
|
||||||
has_wool = self.has_wool
|
has_wool = self.has_wool,
|
||||||
}
|
wool_color = self.wool_color,
|
||||||
end,
|
}
|
||||||
|
end,
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
if self.has_wool == false then
|
if self.has_wool == nil then
|
||||||
self.object:set_properties({textures = {"creatures_sheep.png"}})
|
self.has_wool = true
|
||||||
end
|
end
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
if not self.wool_color then
|
||||||
local item = clicker:get_wielded_item()
|
self.wool_color = colors[math.random(1, #colors)]
|
||||||
if item then
|
end
|
||||||
local name = item:get_name()
|
-- update fur
|
||||||
if name == "farming:wheat" then
|
setColor(self)
|
||||||
self.target = clicker
|
end,
|
||||||
self.mode = "follow"
|
|
||||||
self.modetimer = 0
|
|
||||||
|
|
||||||
if not self.tamed then
|
on_rightclick = function(self, clicker)
|
||||||
self.fed_cnt = (self.fed_cnt or 0) + 1
|
local item = clicker:get_wielded_item()
|
||||||
end
|
if item then
|
||||||
-- play eat sound?
|
local name = item:get_name()
|
||||||
item:take_item()
|
if name == "farming:wheat" then
|
||||||
elseif name == "creatures:shears" and self.has_wool then
|
self.target = clicker
|
||||||
shear(self, math.random(2, 3), true)
|
self.mode = "follow"
|
||||||
item:add_wear(65535/100)
|
self.modetimer = 0
|
||||||
end
|
|
||||||
if not core.setting_getbool("creative_mode") then
|
|
||||||
clicker:set_wielded_item(item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
if not self.tamed then
|
||||||
end,
|
self.fed_cnt = (self.fed_cnt or 0) + 1
|
||||||
|
end
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
-- play eat sound?
|
||||||
if self.has_wool == nil then
|
item:take_item()
|
||||||
self.has_wool = true
|
elseif name == "creatures:shears" and self.has_wool then
|
||||||
end
|
shear(self, math.random(2, 3), true)
|
||||||
if self.mode == "eat" and self.eat_node then
|
item:add_wear(65535/100)
|
||||||
self.regrow_wool = true
|
end
|
||||||
end
|
if not core.setting_getbool("creative_mode") then
|
||||||
if self.last_mode == "eat" and (self.modetimer and self.modetimer == 0) and self.regrow_wool then
|
clicker:set_wielded_item(item)
|
||||||
self.has_wool = true
|
end
|
||||||
self.regrow_wool = nil
|
end
|
||||||
self.object:set_properties({textures = {"creatures_sheep.png^creatures_sheep_white.png"}})
|
return true
|
||||||
end
|
end,
|
||||||
if self.fed_cnt and self.fed_cnt > 4 then
|
|
||||||
self.tamed = true
|
on_step = function(self, dtime)
|
||||||
self.fed_cnt = nil
|
if self.mode == "eat" and self.eat_node then
|
||||||
end
|
self.regrow_wool = true
|
||||||
end
|
end
|
||||||
|
if self.last_mode == "eat" and (self.modetimer and self.modetimer == 0) and self.regrow_wool then
|
||||||
|
self.has_wool = true
|
||||||
|
self.regrow_wool = nil
|
||||||
|
setColor(self)
|
||||||
|
end
|
||||||
|
if self.fed_cnt and self.fed_cnt > 4 then
|
||||||
|
self.tamed = true
|
||||||
|
self.fed_cnt = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
creatures.register_mob(def)
|
creatures.register_mob(def)
|
||||||
|
BIN
sheep/textures/creatures_sheep_black.png
Normal file
BIN
sheep/textures/creatures_sheep_black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
sheep/textures/creatures_sheep_brown.png
Normal file
BIN
sheep/textures/creatures_sheep_brown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
sheep/textures/creatures_sheep_grey.png
Normal file
BIN
sheep/textures/creatures_sheep_grey.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 5.5 KiB |
Loading…
x
Reference in New Issue
Block a user