Compare commits
12 Commits
858167c386
...
342f9ef3a4
Author | SHA1 | Date |
---|---|---|
|
342f9ef3a4 | |
|
e6fe5f66d3 | |
|
ca54d2a42b | |
|
cec3abed20 | |
|
d6f4e7157d | |
|
aa399a6ef9 | |
|
23ab8bddbd | |
|
decb1c384c | |
|
9130b43ef8 | |
|
22f52abc6c | |
|
d7a5b88fb4 | |
|
aa867c3fa0 |
|
@ -1,3 +1,5 @@
|
|||
mobs
|
||||
config
|
||||
lucky_block?
|
||||
intllib?
|
||||
test?
|
||||
|
|
141
init.lua
141
init.lua
|
@ -15,9 +15,27 @@ local shoes = {
|
|||
["mobs:horseshoe_steel"] = {7, 4, 2, "mobs_horseshoe_steelo.png"},
|
||||
["mobs:horseshoe_bronze"] = {7, 4, 4, "mobs_horseshoe_bronzeo.png"},
|
||||
["mobs:horseshoe_mese"] = {9, 5, 8, "mobs_horseshoe_meseo.png"},
|
||||
["mobs:horseshoe_diamond"] = {10, 6, 6, "mobs_horseshoe_diamondo.png"}
|
||||
["mobs:horseshoe_diamond"] = {10, 6, 6, "mobs_horseshoe_diamondo.png"},
|
||||
["mobs:horseshoe_crystal"] = {11, 6, 9, "mobs_horseshoe_crystalo.png"}
|
||||
}
|
||||
|
||||
local mod_config = config.settings_model('mob_horse', {
|
||||
horse = {
|
||||
spawn = {
|
||||
enabled = config.types.boolean(true),
|
||||
on = config.types.list({"default:dirt_with_grass", "ethereal:dry_dirt"}),
|
||||
near = config.types.list({ "air" }),
|
||||
interval = config.types.int(60, { min=1 }),
|
||||
chance = config.types.int(16000, { min=1 }),
|
||||
min_light = config.types.int(14, { min=0 }),
|
||||
max_light = config.types.int(15, { min=0 }),
|
||||
min_height = config.types.int(10, { min=-31000, max=31000 }),
|
||||
max_height = config.types.int(31000, { min=-31000, max=31000 }),
|
||||
active_object_count = config.types.int(1, { min=1 }),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
-- rideable horse
|
||||
mobs:register_mob("mob_horse:horse", {
|
||||
type = "animal",
|
||||
|
@ -29,7 +47,12 @@ mobs:register_mob("mob_horse:horse", {
|
|||
speed_normal = 15,
|
||||
speed_run = 30,
|
||||
stand_start = 25,
|
||||
stand_end = 75,
|
||||
stand_end = 50, -- 75
|
||||
stand2_start = 25,
|
||||
stand2_end = 25,
|
||||
stand3_start = 55,
|
||||
stand3_end = 75,
|
||||
stand3_loop = false,
|
||||
walk_start = 75,
|
||||
walk_end = 100,
|
||||
run_start = 75,
|
||||
|
@ -71,6 +94,7 @@ mobs:register_mob("mob_horse:horse", {
|
|||
self.terrain_type = 3
|
||||
self.driver_attach_at = {x = 0, y = y_off, z = -2}
|
||||
self.driver_eye_offset = {x = 0, y = 3, z = 0}
|
||||
self.driver_scale = {x = 0.8, y = 0.8} -- shrink driver to fit model
|
||||
end
|
||||
|
||||
-- if driver present allow control of horse
|
||||
|
@ -86,22 +110,20 @@ mobs:register_mob("mob_horse:horse", {
|
|||
|
||||
on_die = function(self, pos)
|
||||
|
||||
-- drop saddle when horse is killed while riding
|
||||
-- also detach from horse properly
|
||||
-- detach player from horse properly
|
||||
if self.driver then
|
||||
|
||||
minetest.add_item(pos, "mobs:saddle")
|
||||
|
||||
mobs.detach(self.driver, {x = 1, y = 0, z = 1})
|
||||
end
|
||||
|
||||
self.saddle = nil
|
||||
-- drop saddle if found
|
||||
if self.saddle then
|
||||
minetest.add_item(pos, "mobs:saddle")
|
||||
end
|
||||
|
||||
-- drop any horseshoes added
|
||||
if self.shoed then
|
||||
minetest.add_item(pos, self.shoed)
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
do_punch = function(self, hitter)
|
||||
|
@ -143,29 +165,27 @@ mobs:register_mob("mob_horse:horse", {
|
|||
|
||||
mobs.detach(clicker, {x = 1, y = 0, z = 1})
|
||||
|
||||
-- add saddle back to inventory
|
||||
if inv:room_for_item("main", "mobs:saddle") then
|
||||
inv:add_item("main", "mobs:saddle")
|
||||
else
|
||||
minetest.add_item(clicker:get_pos(), "mobs:saddle")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
self.saddle = nil
|
||||
|
||||
-- attach player to horse
|
||||
elseif (not self.driver and not self.child
|
||||
and clicker:get_wielded_item():get_name() == "mobs:saddle")
|
||||
or self.saddle then
|
||||
|
||||
self.object:set_properties({stepheight = 1.1})
|
||||
mobs.attach(self, clicker)
|
||||
|
||||
-- take saddle from inventory
|
||||
if not self.saddle then
|
||||
inv:remove_item("main", "mobs:saddle")
|
||||
end
|
||||
-- attach saddle to horse
|
||||
if not self.driver
|
||||
and not self.child
|
||||
and clicker:get_wielded_item():get_name() == "mobs:saddle"
|
||||
and not self.saddle then
|
||||
|
||||
self.saddle = true
|
||||
self.order = "stand"
|
||||
self.object:set_properties({stepheight = 1.1})
|
||||
|
||||
-- take saddle from inventory
|
||||
inv:remove_item("main", "mobs:saddle")
|
||||
|
||||
self.texture_mods = self.texture_mods .. "^mobs_saddle_overlay.png"
|
||||
|
||||
self.object:set_texture_mod(self.texture_mods)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- apply horseshoes
|
||||
|
@ -190,6 +210,12 @@ mobs:register_mob("mob_horse:horse", {
|
|||
-- apply horseshoe overlay to current horse texture
|
||||
if overlay then
|
||||
self.texture_mods = "^" .. overlay
|
||||
|
||||
if self.saddle then
|
||||
self.texture_mods = self.texture_mods
|
||||
.. "^mobs_saddle_overlay.png"
|
||||
end
|
||||
|
||||
self.object:set_texture_mod(self.texture_mods)
|
||||
end
|
||||
|
||||
|
@ -209,20 +235,30 @@ mobs:register_mob("mob_horse:horse", {
|
|||
end
|
||||
|
||||
-- used to capture horse with magic lasso
|
||||
mobs:capture_mob(self, clicker, 0, 0, 80, false, nil)
|
||||
end,
|
||||
if mobs:capture_mob(self, clicker, nil, nil, 100, false, nil) then return end
|
||||
|
||||
-- ride horse if saddled
|
||||
if self.saddle and self.owner == player_name then
|
||||
mobs.attach(self, clicker)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
mobs:spawn({
|
||||
name = "mob_horse:horse",
|
||||
nodes = {"default:dirt_with_grass", "ethereal:dry_dirt"},
|
||||
min_light = 14,
|
||||
interval = 60,
|
||||
chance = 16000,
|
||||
min_height = 10,
|
||||
max_height = 31000,
|
||||
day_toggle = true,
|
||||
})
|
||||
if mod_config.horse.spawn.enabled then
|
||||
mobs:spawn_specific(
|
||||
"mob_horse:horse",
|
||||
mod_config.horse.spawn.on,
|
||||
mod_config.horse.spawn.near,
|
||||
mod_config.horse.spawn.min_light,
|
||||
mod_config.horse.spawn.max_light,
|
||||
mod_config.horse.spawn.interval,
|
||||
mod_config.horse.spawn.chance,
|
||||
mod_config.horse.spawn.active_object_count,
|
||||
mod_config.horse.spawn.min_height,
|
||||
mod_config.horse.spawn.max_height,
|
||||
true
|
||||
)
|
||||
end
|
||||
|
||||
mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1)
|
||||
|
||||
|
@ -287,6 +323,25 @@ minetest.register_craft({
|
|||
}
|
||||
})
|
||||
|
||||
-- crystal horseshoes
|
||||
if minetest.get_modpath("ethereal") then
|
||||
|
||||
minetest.register_craftitem(":mobs:horseshoe_crystal", {
|
||||
description = S("Crystal HorseShoes (use on horse to apply)"),
|
||||
inventory_image = "mobs_horseshoe_crystal.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mobs:horseshoe_crystal",
|
||||
recipe = {
|
||||
{"", "ethereal:crystal_block", ""},
|
||||
{"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"},
|
||||
{"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
-- lucky blocks
|
||||
if minetest.get_modpath("lucky_block") then
|
||||
|
||||
|
@ -295,6 +350,10 @@ lucky_block:add_blocks({
|
|||
{"dro", {"mobs:horseshoe_bronze"}},
|
||||
{"dro", {"mobs:horseshoe_mese"}},
|
||||
{"dro", {"mobs:horseshoe_diamond"}},
|
||||
{"dro", {"mobs:horseshoe_crystal"}}
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
||||
dofile(MP .. "/test.lua")
|
|
@ -0,0 +1,3 @@
|
|||
Code: MIT
|
||||
Textures: CC-BY-SA 3.0 by Mjollna
|
||||
Model: MIT by KrupnovPavel
|
|
@ -1,4 +1,5 @@
|
|||
# MOB Horse
|
||||
Forked from https://notabug.org/TenPlus1/mob_horse
|
||||
|
||||
### Spawning
|
||||
There are three different horse textures (white, brown, black) which will spawn on green grassy areas and dry dirt areas in Ethereal mapgen.
|
||||
|
@ -7,12 +8,16 @@ There are three different horse textures (white, brown, black) which will spawn
|
|||
### Taming
|
||||
Horses can be tamed with 10x wheat, apple, barley, oats of corn which then allows the player to pick up the horse using a lasso and ride by right-clicking with a saddle.
|
||||
|
||||
---
|
||||
### Saddle
|
||||
Right clicking a horse with a saddle equips it and the horse will be ordered to stand still until you wish to ride.
|
||||
|
||||
---
|
||||
### Horseshoes
|
||||
Horseshoes can be crafted using steel, bronze, mese and diamond (4x ingots - 2 down either side with 1x block top middle) and placed on a horse by right clicking with the item. These can make horses run faster or jump higher while riding depending on tier.
|
||||
Horseshoes can be crafted using steel, bronze, mese, diamond and crystal (4x ingots - 2 down either side with 1x block top middle) and placed on a horse by right clicking with the item. These can make horses run faster or jump higher while riding depending on tier.
|
||||
|
||||
---
|
||||
### Dead Horse
|
||||
When riding a horse monsters will generally attack the horse first to get to player riding it, when horse dies the player is dismounted and it will drop any shoes or saddles in use as well as some horse meat.
|
||||
|
||||
#### Lucky Blocks: 4
|
||||
#### Lucky Blocks: 5
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
# Enable or disable the natural spawning of the horse mob
|
||||
mob_horse.horse.spawn.enabled (Enable horse spawning) bool true
|
||||
|
||||
# List of nodenames that the horse mob can spawn on top of
|
||||
mob_horse.horse.spawn.on (Nodes the horse will spawn on) string default:dirt_with_grass, ethereal:dry_dirt
|
||||
|
||||
# List of nodenames that the horse mob can spawn beside
|
||||
mob_horse.horse.spawn.near (Nodes the horse will spawn near) string air
|
||||
|
||||
# Interval in seconds that specifies when the horse mob will try to spawn
|
||||
mob_horse.horse.spawn.interval (Time between horse spawning) int 60 1
|
||||
|
||||
# Inverted chance for an horse to spawn on a given node
|
||||
mob_horse.horse.spawn.chance (Rarity of horse spawning) int 16000 1
|
||||
|
||||
# The minimum light level the horse mob can spawn at
|
||||
mob_horse.horse.spawn.min_light (Min. light level for horse spawning) int 14 0
|
||||
|
||||
# The maximum light level the horse mob can spawn at
|
||||
mob_horse.horse.spawn.max_light (Max. light level for horse spawning) int 15 0
|
||||
|
||||
# The minimum height the horse mob can spawn at
|
||||
mob_horse.horse.spawn.min_height (Min. world height for horse spawning) int 10 -31000 31000
|
||||
|
||||
# The maximum height the horse mob can spawn at
|
||||
mob_horse.horse.spawn.max_height (Max. world height for horse spawning) int 31000 -31000 31000
|
||||
|
||||
# Number of horse mobs to spawn at one time inside map area
|
||||
mob_horse.horse.spawn.active_object_count (Number of horses in the same place) int 1 1
|
|
@ -0,0 +1,27 @@
|
|||
if not minetest.global_exists('test') then return end
|
||||
if test.active then return end
|
||||
|
||||
local describe = test.describe
|
||||
local it = test.it
|
||||
local stub = test.stub
|
||||
local assert_equal = test.assert.equal
|
||||
|
||||
describe("Horse Mob", function ()
|
||||
describe("Horse", function ()
|
||||
local original_spawn_specific = mobs.spawn_specific
|
||||
local stub_spawn_specific = stub()
|
||||
test.before_all(function ()
|
||||
mobs.spawn_specific = stub_spawn_specific.call
|
||||
end)
|
||||
test.after_all(function ()
|
||||
mobs.spawn_specific = original_spawn_specific
|
||||
end)
|
||||
it("calls the main mob spawn registration function with the same values as before config was added", function ()
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
|
||||
-- The original call before config was added, testing for consistency with config defaults
|
||||
stub_spawn_specific.called_with(mobs, "mob_horse:horse", { "default:dirt_with_grass", "ethereal:dry_dirt" }, { "air" }, 14, 15, 60, 16000, 1, 10, 31000, true)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
test.execute(true)
|
Binary file not shown.
After Width: | Height: | Size: 153 B |
Binary file not shown.
After Width: | Height: | Size: 106 B |
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Loading…
Reference in New Issue