0
0
Fork 0

Merge remote-tracking branch 'origin/master' into mineclone5

This commit is contained in:
kay27 2021-04-07 17:19:41 +04:00
commit 99563ab93a
59 changed files with 983 additions and 139 deletions

View File

@ -410,7 +410,7 @@ function mcl_util.get_color(colorstr)
local mc_color = mcl_colors[colorstr:upper()] local mc_color = mcl_colors[colorstr:upper()]
if mc_color then if mc_color then
colorstr = mc_color colorstr = mc_color
elseif #colorstr ~= 7 or colorstr:sub(1, 1) ~= "#"then elseif #colorstr ~= 7 or colorstr:sub(1, 1) ~= "#" then
return return
end end
local hex = tonumber(colorstr:sub(2, 7), 16) local hex = tonumber(colorstr:sub(2, 7), 16)

View File

@ -3418,6 +3418,7 @@ local mob_activate = function(self, staticdata, def, dtime)
self.timer = 0 self.timer = 0
self.blinktimer = 0 self.blinktimer = 0
self.blinkstatus = false self.blinkstatus = false
self.collide_with_objects = false
-- check existing nametag -- check existing nametag
if not self.nametag then if not self.nametag then
@ -3526,14 +3527,6 @@ local mob_step = function(self, dtime)
-- end rotation -- end rotation
-- knockback timer
if self.pause_timer > 0 then
self.pause_timer = self.pause_timer - dtime
return
end
-- run custom function (defined in mob lua file) -- run custom function (defined in mob lua file)
if self.do_custom then if self.do_custom then
@ -3543,6 +3536,14 @@ local mob_step = function(self, dtime)
end end
end end
-- knockback timer
if self.pause_timer > 0 then
self.pause_timer = self.pause_timer - dtime
return
end
-- attack timer -- attack timer
self.timer = self.timer + dtime self.timer = self.timer + dtime
@ -3561,7 +3562,7 @@ local mob_step = function(self, dtime)
end end
-- mob plays random sound at times -- mob plays random sound at times
if random(1, 100) == 1 then if random(1, 70) == 1 then
mob_sound(self, "random", true) mob_sound(self, "random", true)
end end
@ -3924,7 +3925,35 @@ end
end -- END mobs:register_mob function end -- END mobs:register_mob function
--BEGIN SPAWNING ALGORITHM
-- count how many mobs of one type are inside an area -- count how many mobs of one type are inside an area
--[[
local count_mobs = function(pos, mobtype) local count_mobs = function(pos, mobtype)
local num = 0 local num = 0
@ -3968,7 +3997,7 @@ local count_mobs = function(pos, mobtype)
return num return num
end end
]]--
-- global functions -- global functions
@ -3978,8 +4007,48 @@ function mobs:spawn_abm_check(pos, node, name)
end end
function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, --[[
interval, chance, aoc, min_height, max_height, day_toggle, on_spawn) Custom elements changed:
name:
the mobs name
dimension:
"overworld"
"nether"
"end"
types of spawning:
"air"
"water"
"ground"
"lava"
what is aoc???
WARNING: BIOME INTEGRATION NEEDED -> How to get biome through lua??
]]--
--this is where all of the spawning information is kept
local spawn_dictionary = {
["overworld"] = {},
["nether"] = {},
["end"] = {}
}
function mobs:spawn_specific(
name,
dimension,
type_of_spawning,
min_light,
max_light,
interval,
chance,
aoc,
min_height,
max_height,
day_toggle,
on_spawn)
-- Do mobs spawn at all? -- Do mobs spawn at all?
if not mobs_spawn then if not mobs_spawn then
@ -4001,7 +4070,6 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
minetest.log("action", minetest.log("action",
string.format("[mobs] Chance setting for %s changed to %s (total: %s)", name, chance, aoc)) string.format("[mobs] Chance setting for %s changed to %s (total: %s)", name, chance, aoc))
end end
local spawn_action local spawn_action
@ -4166,6 +4234,24 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
spawn_action(pos, node, active_object_count, active_object_count_wider, name) spawn_action(pos, node, active_object_count, active_object_count_wider, name)
end end
--load information into the spawn dictionary
local key = #spawn_dictionary[dimension] + 1
spawn_dictionary[dimension][key] = {}
spawn_dictionary[dimension][key]["name"] = name
spawn_dictionary[dimension][key]["type"] = type_of_spawning
spawn_dictionary[dimension][key]["min_light"] = min_light
spawn_dictionary[dimension][key]["max_light"] = max_light
spawn_dictionary[dimension][key]["interval"] = interval
spawn_dictionary[dimension][key]["chance"] = chance
spawn_dictionary[dimension][key]["aoc"] = aoc
spawn_dictionary[dimension][key]["min_height"] = min_height
spawn_dictionary[dimension][key]["max_height"] = max_height
spawn_dictionary[dimension][key]["day_toggle"] = day_toggle
spawn_dictionary[dimension][key]["on_spawn"] = spawn_abm_action
--[[
minetest.register_abm({ minetest.register_abm({
label = name .. " spawning", label = name .. " spawning",
nodenames = nodes, nodenames = nodes,
@ -4175,18 +4261,24 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
catch_up = false, catch_up = false,
action = spawn_abm_action, action = spawn_abm_action,
}) })
]]--
end end
-- compatibility with older mob registration -- compatibility with older mob registration
-- we're going to forget about this for now -j4i
--[[
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, day_toggle) function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, day_toggle)
mobs:spawn_specific(name, nodes, {"air"}, min_light, max_light, 30, mobs:spawn_specific(name, nodes, {"air"}, min_light, max_light, 30,
chance, active_object_count, -31000, max_height, day_toggle) chance, active_object_count, -31000, max_height, day_toggle)
end end
]]--
--I'm not sure what this does but disabling it doesn't cause a crash -j4i
-- MarkBu's spawn function -- MarkBu's spawn function
--[[
function mobs:spawn(def) function mobs:spawn(def)
local name = def.name local name = def.name
@ -4205,6 +4297,160 @@ function mobs:spawn(def)
mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval, mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval,
chance, active_object_count, min_height, max_height, day_toggle, on_spawn) chance, active_object_count, min_height, max_height, day_toggle, on_spawn)
end end
]]--
local axis
--inner and outer part of square donut radius
local inner = 1
local outer = 70
local int = {-1,1}
local position_calculation = function(pos)
pos = vector.floor(pos)
--this is used to determine the axis buffer from the player
axis = math.random(0,1)
--cast towards the direction
if axis == 0 then --x
pos.x = pos.x + math.random(inner,outer)*int[math.random(1,2)]
pos.z = pos.z + math.random(-outer,outer)
else --z
pos.z = pos.z + math.random(inner,outer)*int[math.random(1,2)]
pos.x = pos.x + math.random(-outer,outer)
end
return(pos)
end
--[[
local decypher_limits_dictionary = {
["overworld"] = {mcl_vars.mg_overworld_min,mcl_vars.mg_overworld_max},
["nether"] = {mcl_vars.mg_nether_min, mcl_vars.mg_nether_max},
["end"] = {mcl_vars.mg_end_min, mcl_vars.mg_end_max}
}
]]--
local function decypher_limits(posy)
--local min_max_table = decypher_limits_dictionary[dimension]
--return min_max_table[1],min_max_table[2]
posy = math.floor(posy)
return posy - 32, posy + 32
end
--todo mob limiting
--MAIN LOOP
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 15 then
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
for i = 1,math.random(5) do
local player_pos = player:get_pos()
local _,dimension = mcl_worlds.y_to_layer(player_pos.y)
local min,max = decypher_limits(player_pos.y)
local goal_pos = position_calculation(player_pos)
local mob_def = spawn_dictionary[dimension][math.random(1,#spawn_dictionary[dimension])]
if not mob_def then --to catch a crazy error if it ever happens
minetest.log("error", "WARNING!! mob spawning attempted to index a NIL mob!")
goto continue
end
if mob_def.type == "ground" then
local spawning_position_list = minetest.find_nodes_in_area_under_air(vector.new(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), {"group:solid"})
if #spawning_position_list <= 0 then
goto continue
end
local spawning_position = spawning_position_list[math.random(1,#spawning_position_list)]
spawning_position.y = spawning_position.y + 1
local gotten_light = minetest.get_node_light(spawning_position)
if gotten_light and gotten_light >= mob_def.min_light and gotten_light <= mob_def.max_light then
minetest.add_entity(spawning_position, mob_def.name)
end
elseif mob_def.type == "air" then
local spawning_position_list = minetest.find_nodes_in_area(vector.new(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), {"air"})
if #spawning_position_list <= 0 then
goto continue
end
local spawning_position = spawning_position_list[math.random(1,#spawning_position_list)]
local gotten_light = minetest.get_node_light(spawning_position)
if gotten_light and gotten_light >= mob_def.min_light and gotten_light <= mob_def.max_light then
minetest.add_entity(spawning_position, mob_def.name)
end
elseif mob_def.type == "water" then
local spawning_position_list = minetest.find_nodes_in_area(vector.new(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), {"group:water"})
if #spawning_position_list <= 0 then
goto continue
end
local spawning_position = spawning_position_list[math.random(1,#spawning_position_list)]
local gotten_light = minetest.get_node_light(spawning_position)
if gotten_light and gotten_light >= mob_def.min_light and gotten_light <= mob_def.max_light then
minetest.add_entity(spawning_position, mob_def.name)
end
--elseif mob_def.type == "lava" then
--implement later
end
--local spawn minetest.find_nodes_in_area_under_air(vector.new(pos.x,pos.y-find_node_height,pos.z), vector.new(pos.x,pos.y+find_node_height,pos.z), {"group:solid"})
::continue:: --this is a safety catch
end
end
end
end)
--END SPAWNING ALGORITHM
-- register arrow for shoot attack -- register arrow for shoot attack
@ -4632,6 +4878,7 @@ function mobs:alias_mob(old_name, new_name)
end end
--[[
local timer = 0 local timer = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
timer = timer + dtime timer = timer + dtime
@ -4648,3 +4895,4 @@ minetest.register_globalstep(function(dtime)
end end
timer = 0 timer = 0
end) end)
]]--

View File

@ -168,16 +168,20 @@ function mobs.detach(player, offset)
mcl_player.player_set_animation(player, "stand" , 30) mcl_player.player_set_animation(player, "stand" , 30)
local pos = player:get_pos() --local pos = player:get_pos()
pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z} --pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z}
player:add_velocity(vector.new(math.random(-6,6),math.random(5,8),math.random(-6,6))) --throw the rider off
--[[
minetest.after(0.1, function(name, pos) minetest.after(0.1, function(name, pos)
local player = minetest.get_player_by_name(name) local player = minetest.get_player_by_name(name)
if player then if player then
player:set_pos(pos) player:set_pos(pos)
end end
end, player:get_player_name(), pos) end, player:get_player_name(), pos)
]]--
end end

View File

@ -1,5 +1,5 @@
--################### --###################
--################### AGENT --################### AGENT - seemingly unused
--################### --###################
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator("mobs_mc")

View File

@ -64,7 +64,7 @@ else
end end
-- Spawn on solid blocks at or below Sea level and the selected light level -- Spawn on solid blocks at or below Sea level and the selected light level
mobs:spawn_specific("mobs_mc:bat", mobs_mc.spawn.solid, {"air"}, 0, maxlight, 20, 5000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.water-1) mobs:spawn_specific("mobs_mc:bat", "overworld", "air", 0, maxlight, 20, 5000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.water-1)
-- spawn eggs -- spawn eggs

View File

@ -1,6 +1,6 @@
-- daufinsyd -- daufinsyd
-- My work is under the LGPL terms -- My work is under the LGPL terms
-- Model and mobs_blaze.png see https://github.com/22i/minecraft-voxel-blender-models -- Model and mobs_blaze.png see https://github.com/22i/minecraft-voxel-blender-models -hi 22i ~jordan4ibanez
-- blaze.lua partial copy of mobs_mc/ghast.lua -- blaze.lua partial copy of mobs_mc/ghast.lua
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator("mobs_mc")
@ -128,7 +128,7 @@ mobs:register_mob("mobs_mc:blaze", {
end, end,
}) })
mobs:spawn_specific("mobs_mc:blaze", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 5000, 3, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) mobs:spawn_specific("mobs_mc:blaze", "nether", "ground", 0, minetest.LIGHT_MAX+1, 30, 5000, 3, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max)
-- Blaze fireball -- Blaze fireball
mobs:register_arrow("mobs_mc:blaze_fireball", { mobs:register_arrow("mobs_mc:blaze_fireball", {

View File

@ -100,7 +100,7 @@ mobs:register_mob("mobs_mc:chicken", {
}) })
--spawn --spawn
mobs:spawn_specific("mobs_mc:chicken", mobs_mc.spawn.grassland, {"air"}, 9, minetest.LIGHT_MAX+1, 30, 17000, 3, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:chicken", "overworld", "ground", 9, minetest.LIGHT_MAX+1, 30, 17000, 3, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:chicken", S("Chicken"), "mobs_mc_spawn_icon_chicken.png", 0) mobs:register_egg("mobs_mc:chicken", S("Chicken"), "mobs_mc_spawn_icon_chicken.png", 0)

View File

@ -145,8 +145,9 @@ mobs:register_mob("mobs_mc:mooshroom", mooshroom_def)
-- Spawning -- Spawning
mobs:spawn_specific("mobs_mc:cow", mobs_mc.spawn.grassland, {"air"}, 9, minetest.LIGHT_MAX+1, 30, 17000, 10, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:cow", "overworld", "ground", 9, minetest.LIGHT_MAX+1, 30, 17000, 10, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
mobs:spawn_specific("mobs_mc:mooshroom", mobs_mc.spawn.mushroom_island, {"air"}, 9, minetest.LIGHT_MAX+1, 30, 17000, 5, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) --WARNING: THIS NEEDS A BIOME INTEGRATION
mobs:spawn_specific("mobs_mc:mooshroom", "overworld", "ground", 9, minetest.LIGHT_MAX+1, 30, 17000, 5, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- spawn egg -- spawn egg
mobs:register_egg("mobs_mc:cow", S("Cow"), "mobs_mc_spawn_icon_cow.png", 0) mobs:register_egg("mobs_mc:cow", S("Cow"), "mobs_mc_spawn_icon_cow.png", 0)

View File

@ -39,6 +39,8 @@ mobs:register_mob("mobs_mc:creeper", {
runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" }, runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" },
attack_type = "explode", attack_type = "explode",
--hssssssssssss
explosion_strength = 3, explosion_strength = 3,
explosion_radius = 3.5, explosion_radius = 3.5,
explosion_damage_radius = 3.5, explosion_damage_radius = 3.5,
@ -76,7 +78,6 @@ mobs:register_mob("mobs_mc:creeper", {
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
if self._forced_explosion_countdown_timer <= 0 then if self._forced_explosion_countdown_timer <= 0 then
mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength)
self.object:remove()
end end
end end
end, end,
@ -139,6 +140,9 @@ mobs:register_mob("mobs_mc:creeper_charged", {
pathfinding = 1, pathfinding = 1,
visual = "mesh", visual = "mesh",
mesh = "mobs_mc_creeper.b3d", mesh = "mobs_mc_creeper.b3d",
--BOOM
textures = { textures = {
{"mobs_mc_creeper.png", {"mobs_mc_creeper.png",
"mobs_mc_creeper_charge.png"}, "mobs_mc_creeper_charge.png"},
@ -195,7 +199,6 @@ mobs:register_mob("mobs_mc:creeper_charged", {
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
if self._forced_explosion_countdown_timer <= 0 then if self._forced_explosion_countdown_timer <= 0 then
mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength) mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength)
self.object:remove()
end end
end end
end, end,
@ -250,7 +253,7 @@ mobs:register_mob("mobs_mc:creeper_charged", {
glow = 3, glow = 3,
}) })
mobs:spawn_specific("mobs_mc:creeper", mobs_mc.spawn.solid, {"air"}, 0, 7, 20, 16500, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:creeper", "overworld", "ground", 0, 7, 20, 16500, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:creeper", S("Creeper"), "mobs_mc_spawn_icon_creeper.png", 0) mobs:register_egg("mobs_mc:creeper", S("Creeper"), "mobs_mc_spawn_icon_creeper.png", 0)

View File

@ -50,8 +50,8 @@ mobs:register_mob("mobs_mc:enderdragon", {
arrow = "mobs_mc:dragon_fireball", arrow = "mobs_mc:dragon_fireball",
shoot_interval = 0.5, shoot_interval = 0.5,
shoot_offset = -1.0, shoot_offset = -1.0,
xp_min = 12000, xp_min = 500,
xp_max = 12000, xp_max = 500,
animation = { animation = {
fly_speed = 8, stand_speed = 8, fly_speed = 8, stand_speed = 8,
stand_start = 0, stand_end = 20, stand_start = 0, stand_end = 20,
@ -59,15 +59,31 @@ mobs:register_mob("mobs_mc:enderdragon", {
run_start = 0, run_end = 20, run_start = 0, run_end = 20,
}, },
ignores_nametag = true, ignores_nametag = true,
on_die = function(self, own_pos) do_custom = function(self)
if self._egg_spawn_pos then mcl_bossbars.update_boss(self, "Ender Dragon", "light_purple")
local pos = minetest.string_to_pos(self._egg_spawn_pos) if self._portal_pos then
--if minetest.get_node(pos).buildable_to then -- migrate old format
minetest.set_node(pos, {name = mobs_mc.items.dragon_egg}) if type(self._portal_pos) == "string" then
return self._portal_pos = minetest.string_to_pos(self._portal_pos)
--end end
local portal_center = vector.add(self._portal_pos, vector.new(3, 11, 3))
local pos = self.object:get_pos()
if vector.distance(pos, portal_center) > 50 then
self.object:set_pos(self._last_good_pos or portal_center)
else
self._last_good_pos = pos
end
end
end,
on_die = function(self, pos)
if self._portal_pos then
mcl_portals.spawn_gateway_portal()
mcl_structures.call_struct(self._portal_pos, "end_exit_portal_open")
if self._initial then
mcl_experience.throw_experience(pos, 11500) -- 500 + 11500 = 12000
minetest.set_node(vector.add(self._portal_pos, vector.new(3, 5, 3)), {name = mobs_mc.items.dragon_egg})
end
end end
minetest.add_item(own_pos, mobs_mc.items.dragon_egg)
end, end,
fire_resistant = true, fire_resistant = true,
}) })

View File

@ -295,7 +295,8 @@ mobs:register_mob("mobs_mc:enderman", {
-- ARROW / DAYTIME PEOPLE AVOIDANCE BEHAVIOUR HERE. -- ARROW / DAYTIME PEOPLE AVOIDANCE BEHAVIOUR HERE.
-- Check for arrows and people nearby. -- Check for arrows and people nearby.
local enderpos = self.object:get_pos() local enderpos = self.object:get_pos()
local objs = minetest.get_objects_inside_radius(enderpos, 4) enderpos.y = enderpos.y + 1.5
local objs = minetest.get_objects_inside_radius(enderpos, 2)
for n = 1, #objs do for n = 1, #objs do
local obj = objs[n] local obj = objs[n]
if obj then if obj then
@ -307,7 +308,7 @@ mobs:register_mob("mobs_mc:enderman", {
else else
local lua = obj:get_luaentity() local lua = obj:get_luaentity()
if lua then if lua then
if lua.name == "mcl_bows:arrow_entity" then if lua.name == "mcl_bows:arrow_entity" or lua.name == "mcl_throwing:snowball_entity" then
self:teleport(nil) self:teleport(nil)
end end
end end
@ -328,36 +329,46 @@ mobs:register_mob("mobs_mc:enderman", {
--end --end
end end
-- Check to see if people are near by enough to look at us. -- Check to see if people are near by enough to look at us.
local objs = minetest.get_objects_inside_radius(enderpos, 64) for _,obj in pairs(minetest.get_connected_players()) do
local obj
for n = 1, #objs do --check if they are within radius
obj = objs[n]
if obj then
if minetest.is_player(obj) then
-- Check if they are looking at us.
local player_pos = obj:get_pos() local player_pos = obj:get_pos()
if player_pos then -- prevent crashing in 1 in a million scenario
local ender_distance = vector.distance(enderpos, player_pos)
if ender_distance <= 64 then
-- Check if they are looking at us.
local look_dir_not_normalized = obj:get_look_dir() local look_dir_not_normalized = obj:get_look_dir()
local look_dir = vector.normalize(look_dir_not_normalized) local look_dir = vector.normalize(look_dir_not_normalized)
local look_pos = vector.new({x = look_dir.x+player_pos.x, y = look_dir.y+player_pos.y + 1.5, z = look_dir.z+player_pos.z}) -- Arbitrary value (1.5) is head level according to player info mod. local player_eye_height = obj:get_properties().eye_height
-- Cast up to 64 to see if player is looking at enderman.
for n = 1,64,.25 do --skip player if they have no data - log it
local node = minetest.get_node(look_pos) if not player_eye_height then
if node.name ~= "air" then minetest.log("error", "Enderman at location: ".. dump(enderpos).." has indexed a null player!")
break goto continue
end end
if look_pos.x-1<enderpos.x and look_pos.x+1>enderpos.x and look_pos.y-2.89<enderpos.y and look_pos.y-2>enderpos.y and look_pos.z-1<enderpos.z and look_pos.z+1>enderpos.z then
--calculate very quickly the exact location the player is looking
--within the distance between the two "heads" (player and enderman)
local look_pos = vector.new(player_pos.x, player_pos.y + player_eye_height, player_pos.z)
local look_pos_base = look_pos
local ender_eye_pos = vector.new(enderpos.x, enderpos.y + 2.75, enderpos.z)
local eye_distance_from_player = vector.distance(ender_eye_pos, look_pos)
look_pos = vector.add(look_pos, vector.multiply(look_dir, eye_distance_from_player))
--if looking in general head position, turn hostile
if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then
self.provoked = "staring" self.provoked = "staring"
self.attack = minetest.get_player_by_name(obj:get_player_name()) self.attack = minetest.get_player_by_name(obj:get_player_name())
break break
else else -- I'm not sure what this part does, but I don't want to break anything - jordan4ibanez
if self.provoked == "staring" then if self.provoked == "staring" then
self.provoked = "broke_contact" self.provoked = "broke_contact"
end end
end end
look_pos.x = look_pos.x + (.25 * look_dir.x)
look_pos.y = look_pos.y + (.25 * look_dir.y) ::continue:: -- this is a sweep over statement, this can be used to continue even when errors occurred
look_pos.z = look_pos.z + (.25 * look_dir.z)
end
end end
end end
end end
@ -551,11 +562,11 @@ mobs:register_mob("mobs_mc:enderman", {
-- End spawn -- End spawn
mobs:spawn_specific("mobs_mc:enderman", mobs_mc.spawn.solid, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 3000, 12, mobs_mc.spawn_height.end_min, mobs_mc.spawn_height.end_max) mobs:spawn_specific("mobs_mc:enderman", "end", "ground", 0, minetest.LIGHT_MAX+1, 30, 3000, 12, mobs_mc.spawn_height.end_min, mobs_mc.spawn_height.end_max)
-- Overworld spawn -- Overworld spawn
mobs:spawn_specific("mobs_mc:enderman", mobs_mc.spawn.solid, {"air"}, 0, 7, 30, 19000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:enderman", "overworld", "ground", 0, 7, 30, 19000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- Nether spawn (rare) -- Nether spawn (rare)
mobs:spawn_specific("mobs_mc:enderman", mobs_mc.spawn.solid, {"air"}, 0, 7, 30, 27500, 4, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) mobs:spawn_specific("mobs_mc:enderman", "nether", "ground", 0, 7, 30, 27500, 4, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:enderman", S("Enderman"), "mobs_mc_spawn_icon_enderman.png", 0) mobs:register_egg("mobs_mc:enderman", S("Enderman"), "mobs_mc_spawn_icon_enderman.png", 0)

View File

@ -75,7 +75,7 @@ mobs:register_mob("mobs_mc:ghast", {
}) })
mobs:spawn_specific("mobs_mc:ghast", mobs_mc.spawn.nether, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 18000, 2, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) mobs:spawn_specific("mobs_mc:ghast", "nether", "air", 0, minetest.LIGHT_MAX+1, 30, 18000, 2, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max)
-- fireball (projectile) -- fireball (projectile)
mobs:register_arrow("mobs_mc:fireball", { mobs:register_arrow("mobs_mc:fireball", {

View File

@ -106,7 +106,7 @@ mobs:register_mob("mobs_mc:guardian_elder", {
view_range = 16, view_range = 16,
}) })
-- Spawning disabled due to size issues -- Spawning disabled due to size issues <- what do you mean? -j4i
-- TODO: Re-enable spawning -- TODO: Re-enable spawning
-- mobs:spawn_specific("mobs_mc:guardian_elder", mobs_mc.spawn.water, mobs_mc.spawn_water, 0, minetest.LIGHT_MAX+1, 30, 40000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.water-18) -- mobs:spawn_specific("mobs_mc:guardian_elder", mobs_mc.spawn.water, mobs_mc.spawn_water, 0, minetest.LIGHT_MAX+1, 30, 40000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.water-18)

View File

@ -231,7 +231,6 @@ local horse = {
temper_increase = 5 temper_increase = 5
elseif (iname == mobs_mc.items.golden_apple) then elseif (iname == mobs_mc.items.golden_apple) then
temper_increase = 10 temper_increase = 10
-- Trying to ride -- Trying to ride
elseif not self.driver then elseif not self.driver then
self.object:set_properties({stepheight = 1.1}) self.object:set_properties({stepheight = 1.1})
@ -511,8 +510,8 @@ mobs:register_mob("mobs_mc:mule", mule)
--=========================== --===========================
--Spawn Function --Spawn Function
mobs:spawn_specific("mobs_mc:horse", mobs_mc.spawn.grassland_savanna, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15000, 4, mobs_mc.spawn_height.water+3, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:horse", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 15000, 4, mobs_mc.spawn_height.water+3, mobs_mc.spawn_height.overworld_max)
mobs:spawn_specific("mobs_mc:donkey", mobs_mc.spawn.grassland_savanna, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15000, 4, mobs_mc.spawn_height.water+3, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:donkey", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 15000, 4, mobs_mc.spawn_height.water+3, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:horse", S("Horse"), "mobs_mc_spawn_icon_horse.png", 0) mobs:register_egg("mobs_mc:horse", S("Horse"), "mobs_mc_spawn_icon_horse.png", 0)

View File

@ -217,7 +217,7 @@ mobs:register_mob("mobs_mc:llama", {
}) })
--spawn --spawn
mobs:spawn_specific("mobs_mc:llama", mobs_mc.spawn.savanna, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15000, 5, mobs_mc.spawn_height.water+15, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:llama", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 15000, 5, mobs_mc.spawn_height.water+15, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:llama", S("Llama"), "mobs_mc_spawn_icon_llama.png", 0) mobs:register_egg("mobs_mc:llama", S("Llama"), "mobs_mc_spawn_icon_llama.png", 0)

View File

@ -152,6 +152,9 @@ mobs:register_mob("mobs_mc:cat", cat)
local base_spawn_chance = 5000 local base_spawn_chance = 5000
-- Spawn ocelot -- Spawn ocelot
--they get the same as the llama because I'm trying to rework so much of this code right now -j4i
mobs:spawn_specific("mobs_mc:ocelot", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 15000, 5, mobs_mc.spawn_height.water+15, mobs_mc.spawn_height.overworld_max)
--[[
mobs:spawn({ mobs:spawn({
name = "mobs_mc:ocelot", name = "mobs_mc:ocelot",
nodes = mobs_mc.spawn.jungle, nodes = mobs_mc.spawn.jungle,
@ -163,8 +166,8 @@ mobs:spawn({
min_height = mobs_mc.spawn_height.water+1, -- Right above ocean level min_height = mobs_mc.spawn_height.water+1, -- Right above ocean level
max_height = mobs_mc.spawn_height.overworld_max, max_height = mobs_mc.spawn_height.overworld_max,
on_spawn = function(self, pos) on_spawn = function(self, pos)
--[[ Note: Minecraft has a 1/3 spawn failure rate. Note: Minecraft has a 1/3 spawn failure rate.
In this mod it is emulated by reducing the spawn rate accordingly (see above). ]] In this mod it is emulated by reducing the spawn rate accordingly (see above).
-- 1/7 chance to spawn 2 ocelot kittens -- 1/7 chance to spawn 2 ocelot kittens
if pr:next(1,7) == 1 then if pr:next(1,7) == 1 then
@ -207,6 +210,7 @@ mobs:spawn({
end end
end, end,
}) })
]]--
-- spawn eggs -- spawn eggs
-- FIXME: The spawn icon shows a cat texture, not an ocelot texture -- FIXME: The spawn icon shows a cat texture, not an ocelot texture

View File

@ -90,8 +90,8 @@ mobs:register_mob("mobs_mc:parrot", {
}) })
-- Parrots spawn rarely in jungles. TODO: Also check for jungle *biome* -- Parrots spawn rarely in jungles. TODO: Also check for jungle *biome* <- I'll get to this eventually -j4i
mobs:spawn_specific("mobs_mc:parrot", {"mcl_core:jungletree", "mcl_core:jungleleaves"}, {"air"}, 0, minetest.LIGHT_MAX+1, 7, 30000, 1, mobs_mc.spawn_height.water+7, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:parrot","overworld", "air", 0, minetest.LIGHT_MAX+1, 7, 30000, 1, mobs_mc.spawn_height.water+7, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:parrot", S("Parrot"), "mobs_mc_spawn_icon_parrot.png", 0) mobs:register_egg("mobs_mc:parrot", S("Parrot"), "mobs_mc_spawn_icon_parrot.png", 0)

View File

@ -182,7 +182,7 @@ mobs:register_mob("mobs_mc:pig", {
end, end,
}) })
mobs:spawn_specific("mobs_mc:pig", mobs_mc.spawn.grassland, {"air"}, 9, minetest.LIGHT_MAX+1, 30, 15000, 8, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:pig", "overworld", "ground", 9, minetest.LIGHT_MAX+1, 30, 15000, 8, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:pig", S("Pig"), "mobs_mc_spawn_icon_pig.png", 0) mobs:register_egg("mobs_mc:pig", S("Pig"), "mobs_mc_spawn_icon_pig.png", 0)

View File

@ -67,7 +67,7 @@ mobs:register_mob("mobs_mc:polar_bear", {
}) })
mobs:spawn_specific("mobs_mc:polar_bear", mobs_mc.spawn.snow, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 7000, 3, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:polar_bear", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 7000, 3, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- spawn egg -- spawn egg
mobs:register_egg("mobs_mc:polar_bear", S("Polar Bear"), "mobs_mc_spawn_icon_polarbear.png", 0) mobs:register_egg("mobs_mc:polar_bear", S("Polar Bear"), "mobs_mc_spawn_icon_polarbear.png", 0)

View File

@ -107,8 +107,11 @@ end
mobs:register_mob("mobs_mc:killer_bunny", killer_bunny) mobs:register_mob("mobs_mc:killer_bunny", killer_bunny)
-- Mob spawning rules. -- Mob spawning rules.
-- Different skins depending on spawn location -- Different skins depending on spawn location <- we'll get to this when the spawning algorithm is fleshed out
mobs:spawn_specific("mobs_mc:rabbit", "overworld", "ground", 9, minetest.LIGHT_MAX+1, 30, 15000, 8, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
--[[
local spawn = { local spawn = {
name = "mobs_mc:rabbit", name = "mobs_mc:rabbit",
neighbors = {"air"}, neighbors = {"air"},
@ -165,6 +168,7 @@ spawn_grass.on_spawn = function(self, pos)
self.object:set_properties({textures = self.base_texture}) self.object:set_properties({textures = self.base_texture})
end end
mobs:spawn(spawn_grass) mobs:spawn(spawn_grass)
]]--
-- Spawn egg -- Spawn egg
mobs:register_egg("mobs_mc:rabbit", S("Rabbit"), "mobs_mc_spawn_icon_rabbit.png", 0) mobs:register_egg("mobs_mc:rabbit", S("Rabbit"), "mobs_mc_spawn_icon_rabbit.png", 0)

View File

@ -303,7 +303,7 @@ mobs:register_mob("mobs_mc:sheep", {
end end
end, end,
}) })
mobs:spawn_specific("mobs_mc:sheep", mobs_mc.spawn.grassland, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15000, 3, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:sheep", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 15000, 3, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:sheep", S("Sheep"), "mobs_mc_spawn_icon_sheep.png", 0) mobs:register_egg("mobs_mc:sheep", S("Sheep"), "mobs_mc_spawn_icon_sheep.png", 0)

View File

@ -81,4 +81,4 @@ mobs:register_arrow("mobs_mc:shulkerbullet", {
mobs:register_egg("mobs_mc:shulker", S("Shulker"), "mobs_mc_spawn_icon_shulker.png", 0) mobs:register_egg("mobs_mc:shulker", S("Shulker"), "mobs_mc_spawn_icon_shulker.png", 0)
mobs:spawn_specific("mobs_mc:shulker", mobs_mc.spawn.end_city, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 5000, 2, mobs_mc.spawn_height.end_min, mobs_mc.spawn_height.end_max) mobs:spawn_specific("mobs_mc:shulker", "end", "ground", 0, minetest.LIGHT_MAX+1, 30, 5000, 2, mobs_mc.spawn_height.end_min, mobs_mc.spawn_height.end_max)

View File

@ -139,13 +139,13 @@ table.insert(stray.drops, {
mobs:register_mob("mobs_mc:stray", stray) mobs:register_mob("mobs_mc:stray", stray)
-- Overworld spawn -- Overworld spawn
mobs:spawn_specific("mobs_mc:skeleton", mobs_mc.spawn.solid, {"air"}, 0, 7, 20, 17000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:skeleton", "overworld", "ground", 0, 7, 20, 17000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- Nether spawn -- Nether spawn
mobs:spawn_specific("mobs_mc:skeleton", mobs_mc.spawn.nether_fortress, {"air"}, 0, 7, 30, 10000, 3, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) mobs:spawn_specific("mobs_mc:skeleton", "nether", "ground", 0, 7, 30, 10000, 3, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max)
-- Stray spawn -- Stray spawn
-- TODO: Spawn directly under the sky -- TODO: Spawn directly under the sky
mobs:spawn_specific("mobs_mc:stray", mobs_mc.spawn.snow, {"air"}, 0, 7, 20, 19000, 2, mobs_mc.spawn_height.water, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:stray", "overworld", "ground", 0, 7, 20, 19000, 2, mobs_mc.spawn_height.water, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs

View File

@ -94,7 +94,7 @@ mobs:register_mob("mobs_mc:witherskeleton", {
}) })
--spawn --spawn
mobs:spawn_specific("mobs_mc:witherskeleton", mobs_mc.spawn.nether_fortress, {"air"}, 0, 7, 30, 5000, 5, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) mobs:spawn_specific("mobs_mc:witherskeleton", "nether", "ground", 0, 7, 30, 5000, 5, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:witherskeleton", S("Wither Skeleton"), "mobs_mc_spawn_icon_witherskeleton.png", 0) mobs:register_egg("mobs_mc:witherskeleton", S("Wither Skeleton"), "mobs_mc_spawn_icon_witherskeleton.png", 0)

View File

@ -157,9 +157,9 @@ mobs:register_mob("mobs_mc:slime_tiny", slime_tiny)
local smin = mobs_mc.spawn_height.overworld_min local smin = mobs_mc.spawn_height.overworld_min
local smax = mobs_mc.spawn_height.water - 23 local smax = mobs_mc.spawn_height.water - 23
mobs:spawn_specific("mobs_mc:slime_tiny", mobs_mc.spawn.solid, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 12000, 4, smin, smax) mobs:spawn_specific("mobs_mc:slime_tiny", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 12000, 4, smin, smax)
mobs:spawn_specific("mobs_mc:slime_small", mobs_mc.spawn.solid, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 8500, 4, smin, smax) mobs:spawn_specific("mobs_mc:slime_small", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 8500, 4, smin, smax)
mobs:spawn_specific("mobs_mc:slime_big", mobs_mc.spawn.solid, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 10000, 4, smin, smax) mobs:spawn_specific("mobs_mc:slime_big", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 10000, 4, smin, smax)
-- Magma cube -- Magma cube
local magma_cube_big = { local magma_cube_big = {
@ -272,13 +272,13 @@ mobs:register_mob("mobs_mc:magma_cube_tiny", magma_cube_tiny)
local mmin = mobs_mc.spawn_height.nether_min local mmin = mobs_mc.spawn_height.nether_min
local mmax = mobs_mc.spawn_height.nether_max local mmax = mobs_mc.spawn_height.nether_max
mobs:spawn_specific("mobs_mc:magma_cube_tiny", mobs_mc.spawn.nether, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15000, 4, mmin, mmax) mobs:spawn_specific("mobs_mc:magma_cube_tiny", "nether", "ground", 0, minetest.LIGHT_MAX+1, 30, 15000, 4, mmin, mmax)
mobs:spawn_specific("mobs_mc:magma_cube_small", mobs_mc.spawn.nether, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15500, 4, mmin, mmax) mobs:spawn_specific("mobs_mc:magma_cube_small", "nether", "ground", 0, minetest.LIGHT_MAX+1, 30, 15500, 4, mmin, mmax)
mobs:spawn_specific("mobs_mc:magma_cube_big", mobs_mc.spawn.nether, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 16000, 4, mmin, mmax) mobs:spawn_specific("mobs_mc:magma_cube_big", "nether", "ground", 0, minetest.LIGHT_MAX+1, 30, 16000, 4, mmin, mmax)
mobs:spawn_specific("mobs_mc:magma_cube_tiny", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11000, 4, mmin, mmax) --mobs:spawn_specific("mobs_mc:magma_cube_tiny", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11000, 4, mmin, mmax)
mobs:spawn_specific("mobs_mc:magma_cube_small", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11100, 4, mmin, mmax) --mobs:spawn_specific("mobs_mc:magma_cube_small", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11100, 4, mmin, mmax)
mobs:spawn_specific("mobs_mc:magma_cube_big", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11200, 4, mmin, mmax) --mobs:spawn_specific("mobs_mc:magma_cube_big", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11200, 4, mmin, mmax)
-- spawn eggs -- spawn eggs

View File

@ -87,7 +87,7 @@ cave_spider.sounds.base_pitch = 1.25
mobs:register_mob("mobs_mc:cave_spider", cave_spider) mobs:register_mob("mobs_mc:cave_spider", cave_spider)
mobs:spawn_specific("mobs_mc:spider", mobs_mc.spawn.solid, {"air"}, 0, 7, 30, 17000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:spider", "overworld", "ground", 0, 7, 30, 17000, 2, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:spider", S("Spider"), "mobs_mc_spawn_icon_spider.png", 0) mobs:register_egg("mobs_mc:spider", S("Spider"), "mobs_mc_spawn_icon_spider.png", 0)

View File

@ -62,7 +62,7 @@ mobs:register_mob("mobs_mc:squid", {
local water = mobs_mc.spawn_height.water local water = mobs_mc.spawn_height.water
--name, nodes, neighbours, minlight, maxlight, interval, chance, active_object_count, min_height, max_height --name, nodes, neighbours, minlight, maxlight, interval, chance, active_object_count, min_height, max_height
mobs:spawn_specific("mobs_mc:squid", mobs_mc.spawn.water, {mobs_mc.items.water_source}, 0, minetest.LIGHT_MAX+1, 30, 5500, 3, water-16, water) mobs:spawn_specific("mobs_mc:squid", "overworld", "water", 0, minetest.LIGHT_MAX+1, 30, 5500, 3, water-16, water)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:squid", S("Squid"), "mobs_mc_spawn_icon_squid.png", 0) mobs:register_egg("mobs_mc:squid", S("Squid"), "mobs_mc_spawn_icon_squid.png", 0)

View File

@ -1074,7 +1074,7 @@ mobs:register_mob("mobs_mc:villager", {
mobs:spawn_specific("mobs_mc:villager", mobs_mc.spawn.village, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 20, 4, mobs_mc.spawn_height.water+1, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:villager", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 20, 4, mobs_mc.spawn_height.water+1, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:villager", S("Villager"), "mobs_mc_spawn_icon_villager.png", 0) mobs:register_egg("mobs_mc:villager", S("Villager"), "mobs_mc_spawn_icon_villager.png", 0)

View File

@ -146,8 +146,8 @@ mobs:register_mob("mobs_mc:villager_zombie", {
harmed_by_heal = true, harmed_by_heal = true,
}) })
mobs:spawn_specific("mobs_mc:villager_zombie", mobs_mc.spawn.village, {"air"}, 0, 7, 30, 4090, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:villager_zombie", "overworld", "ground", 0, 7, 30, 4090, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
mobs:spawn_specific("mobs_mc:villager_zombie", mobs_mc.spawn.solid, {"air"}, 0, 7, 30, 60000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:villager_zombie", "overworld", "ground", 0, 7, 30, 60000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:villager_zombie", S("Zombie Villager"), "mobs_mc_spawn_icon_zombie_villager.png", 0) mobs:register_egg("mobs_mc:villager_zombie", S("Zombie Villager"), "mobs_mc_spawn_icon_zombie_villager.png", 0)

View File

@ -99,7 +99,7 @@ mobs:register_arrow("mobs_mc:potion_arrow", {
end end
}) })
-- TODO: Spawn when witch works properly -- TODO: Spawn when witch works properly <- eventually -j4i
--mobs:spawn_specific("mobs_mc:witch", mobs_mc.spawn.jungle, {"air"}, 0, minetest.LIGHT_MAX-6, 12, 20000, 2, mobs_mc.spawn_height.water-6, mobs_mc.spawn_height.overworld_max) --mobs:spawn_specific("mobs_mc:witch", mobs_mc.spawn.jungle, {"air"}, 0, minetest.LIGHT_MAX-6, 12, 20000, 2, mobs_mc.spawn_height.water-6, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs

View File

@ -73,6 +73,7 @@ mobs:register_mob("mobs_mc:wither", {
self.object:set_properties({textures={self.base_texture}}) self.object:set_properties({textures={self.base_texture}})
self.armor = {undead = 80, fleshy = 80} self.armor = {undead = 80, fleshy = 80}
end end
mcl_bossbars.update_boss(self, "Wither", "dark_purple")
end, end,
on_spawn = function(self) on_spawn = function(self)
minetest.sound_play("mobs_mc_wither_spawn", {object=self.object, gain=1.0, max_hear_distance=64}) minetest.sound_play("mobs_mc_wither_spawn", {object=self.object, gain=1.0, max_hear_distance=64})

View File

@ -232,6 +232,6 @@ end
mobs:register_mob("mobs_mc:dog", dog) mobs:register_mob("mobs_mc:dog", dog)
-- Spawn -- Spawn
mobs:spawn_specific("mobs_mc:wolf", mobs_mc.spawn.wolf, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 9000, 7, mobs_mc.spawn_height.water+3, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:wolf", "overworld", "ground", 0, minetest.LIGHT_MAX+1, 30, 9000, 7, mobs_mc.spawn_height.water+3, mobs_mc.spawn_height.overworld_max)
mobs:register_egg("mobs_mc:wolf", S("Wolf"), "mobs_mc_spawn_icon_wolf.png", 0) mobs:register_egg("mobs_mc:wolf", S("Wolf"), "mobs_mc_spawn_icon_wolf.png", 0)

View File

@ -135,11 +135,11 @@ mobs:register_mob("mobs_mc:baby_husk", baby_husk)
-- Spawning -- Spawning
mobs:spawn_specific("mobs_mc:zombie", mobs_mc.spawn.solid, {"air"}, 0, 7, 30, 6000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:zombie", "overworld", "ground", 0, 7, 30, 6000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- Baby zombie is 20 times less likely than regular zombies -- Baby zombie is 20 times less likely than regular zombies
mobs:spawn_specific("mobs_mc:baby_zombie", mobs_mc.spawn.solid, {"air"}, 0, 7, 30, 60000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:baby_zombie", "overworld", "ground", 0, 7, 30, 60000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
mobs:spawn_specific("mobs_mc:husk", mobs_mc.spawn.desert, {"air"}, 0, 7, 30, 6500, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:husk", "overworld", "ground", 0, 7, 30, 6500, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
mobs:spawn_specific("mobs_mc:baby_husk", mobs_mc.spawn.desert, {"air"}, 0, 7, 30, 65000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) mobs:spawn_specific("mobs_mc:baby_husk", "overworld", "ground", 0, 7, 30, 65000, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- Spawn eggs -- Spawn eggs
mobs:register_egg("mobs_mc:husk", S("Husk"), "mobs_mc_spawn_icon_husk.png", 0) mobs:register_egg("mobs_mc:husk", S("Husk"), "mobs_mc_spawn_icon_husk.png", 0)

View File

@ -111,12 +111,12 @@ baby_pigman.child = 1
mobs:register_mob("mobs_mc:baby_pigman", baby_pigman) mobs:register_mob("mobs_mc:baby_pigman", baby_pigman)
-- Regular spawning in the Nether -- Regular spawning in the Nether
mobs:spawn_specific("mobs_mc:pigman", mobs_mc.spawn.solid, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) mobs:spawn_specific("mobs_mc:pigman", "nether", "ground", 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max)
-- Baby zombie is 20 times less likely than regular zombies -- Baby zombie is 20 times less likely than regular zombies
mobs:spawn_specific("mobs_mc:baby_pigman", mobs_mc.spawn.solid, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 100000, 4, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max) mobs:spawn_specific("mobs_mc:baby_pigman", "nether", "ground", 0, minetest.LIGHT_MAX+1, 30, 100000, 4, mobs_mc.spawn_height.nether_min, mobs_mc.spawn_height.nether_max)
-- Spawning in Nether portals in the Overworld -- Spawning in Nether portals in the Overworld
mobs:spawn_specific("mobs_mc:pigman", mobs_mc.spawn.nether_portal, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 500, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max) --mobs:spawn_specific("mobs_mc:pigman", mobs_mc.spawn.nether_portal, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 500, 4, mobs_mc.spawn_height.overworld_min, mobs_mc.spawn_height.overworld_max)
-- spawn eggs -- spawn eggs
mobs:register_egg("mobs_mc:pigman", S("Zombie Pigman"), "mobs_mc_spawn_icon_zombie_pigman.png", 0) mobs:register_egg("mobs_mc:pigman", S("Zombie Pigman"), "mobs_mc_spawn_icon_zombie_pigman.png", 0)

View File

@ -0,0 +1,124 @@
mcl_bossbars = {
bars = {},
huds = {},
colors = {"light_purple", "blue", "red", "green", "yellow", "dark_purple", "white"},
}
function mcl_bossbars.recalculate_colors()
local sorted = {}
local colors = mcl_bossbars.colors
local color_count = #colors
local frame_count = color_count * 2
for i, color in ipairs(colors) do
local idx = i * 2 - 1
local image = "mcl_bossbars.png"
.. "^[transformR270"
.. "^[verticalframe:" .. frame_count .. ":" .. (idx - 1)
.. "^(mcl_bossbars_empty.png"
.. "^[lowpart:%d:mcl_bossbars.png"
.. "^[transformR270"
.. "^[verticalframe:" .. frame_count .. ":" .. idx .. ")"
local _, hex = mcl_util.get_color(color)
sorted[color] = {
image = image,
hex = hex,
}
end
mcl_bossbars.colors_sorted = sorted
end
function mcl_bossbars.update_bar(player, text, color, percentage)
local cdef = mcl_bossbars.colors_sorted[color]
table.insert(mcl_bossbars.bars[player:get_player_name()], {color = cdef.hex, text = text, image = string.format(cdef.image, percentage)})
end
function mcl_bossbars.update_boss(luaentity, name, color)
local object = luaentity.object
local text = luaentity.nametag
if not text or text == "" then
text = name
end
local percentage = math.floor(luaentity.health / luaentity.hp_max * 100)
for _, obj in pairs(minetest.get_objects_inside_radius(object:get_pos(), 128)) do
if obj:is_player() then
mcl_bossbars.update_bar(obj, text, color, percentage)
end
end
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
mcl_bossbars.huds[name] = {}
mcl_bossbars.bars[name] = {}
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
mcl_bossbars.huds[name] = nil
mcl_bossbars.bars[name] = nil
end)
minetest.register_globalstep(function()
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local bars = mcl_bossbars.bars[name]
local huds = mcl_bossbars.huds[name]
local huds_new = {}
local i = 0
while #huds > 0 or #bars > 0 do
local bar = table.remove(bars, 1)
local hud = table.remove(huds, 1)
if bar and not hud then
hud = {
color = bar.color,
image = bar.image,
text = bar.text,
text_id = player:hud_add({
hud_elem_type = "text",
text = bar.text,
number = bar.color,
position = {x = 0.5, y = 0},
alignment = {x = 0, y = 1},
offset = {x = 0, y = i * 40},
}),
image_id = player:hud_add({
hud_elem_type = "image",
text = bar.image,
position = {x = 0.5, y = 0},
alignment = {x = 0, y = 1},
offset = {x = 0, y = i * 40 + 25},
scale = {x = 3, y = 3},
}),
}
elseif hud and not bar then
player:hud_remove(hud.text_id)
player:hud_remove(hud.image_id)
hud = nil
else
if bar.text ~= hud.text then
player:hud_change(hud.text_id, "text", bar.text)
hud.text = bar.text
end
if bar.color ~= hud.color then
player:hud_change(hud.text_id, "number", bar.color)
hud.color = bar.color
end
if bar.image ~= hud.image then
player:hud_change(hud.image_id, "text", bar.image)
hud.image = bar.image
end
end
table.insert(huds_new, hud)
i = i + 1
end
mcl_bossbars.huds[name] = huds_new
end
end)
mcl_bossbars.recalculate_colors()

View File

@ -0,0 +1,4 @@
name = mcl_bossbars
author = Fleckenstein
description = Show enderdragon & wither boss bars. Also allows custom bars.
depends = mcl_util, mcl_colors

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1,209 @@
mcl_credits = {
players = {},
}
mcl_credits.description = "A faithful Open Source clone of Minecraft"
-- Sub-lists are sorted by number of commits, but the list should not be rearranged (-> new contributors are just added at the end of the list)
mcl_credits.people = {
{"Creator of MineClone", 0x0A9400, {
"davedevils",
}},
{"Creator of MineClone2", 0xFBF837, {
"Wuzzy",
}},
{"Maintainers", 0xFF51D5, {
"Fleckenstein",
"kay27",
"oilboi",
}},
{"Developers", 0xF84355, {
"bzoss",
"AFCMS",
"epCode",
"ryvnf",
"iliekprogrammar",
"MysticTempest",
"Rootyjr",
"Nicu",
"aligator",
}},
{"Contributors", 0x52FF00, {
"Code-Sploit",
"Laurent Rocher",
"HimbeerserverDE",
"TechDudie",
"Alexander Minges",
"ArTee3",
"ZeDique la Ruleta",
"pitchum",
"wuniversales",
"Bu-Gee",
"David McMackins II",
"Nicholas Niro",
"Wouters Dorian",
"Blue Blancmange",
"Jared Moody",
"Li0n",
"Midgard",
"NO11",
"Saku Laesvuori",
"Yukitty",
"ZedekThePD",
"aldum",
"dBeans",
"nickolas360",
"yutyo",
"ztianyang",
}},
{"MineClone5", 0xA60014, {
"kay27",
"Debiankaios",
"epCode",
"NO11",
"j45",
}},
{"3D Models", 0x0019FF, {
"22i",
"tobyplowy",
"epCode",
}},
{"Textures", 0xFF9705, {
"XSSheep",
"Wuzzy",
"kingoscargames",
"leorockway",
"xMrVizzy",
"yutyo"
}},
{"Translations", 0x00FF60, {
"Wuzzy",
"Rocher Laurent",
"wuniversales",
"kay27",
"pitchum",
}},
}
local function add_hud_element(def, huds, y)
def.alignment = {x = 0, y = 0}
def.position = {x = 0.5, y = 0}
def.offset = {x = 0, y = y}
def.z_index = 1001
local id = huds.player:hud_add(def)
table.insert(huds.ids, id)
huds.moving[id] = y
return id
end
function mcl_credits.show(player)
local name = player:get_player_name()
if mcl_credits.players[name] then
return
end
local huds = {
new = true, -- workaround for MT < 5.5 (sending hud_add and hud_remove in the same tick)
player = player,
moving = {},
ids = {
player:hud_add({
hud_elem_type = "image",
text = "menu_bg.png",
position = {x = 0, y = 0},
alignment = {x = 1, y = 1},
scale = {x = -100, y = -100},
z_index = 1000,
}),
player:hud_add({
hud_elem_type = "text",
text = "Sneak to skip",
position = {x = 1, y = 1},
alignment = {x = -1, y = -1},
offset = {x = -5, y = -5},
z_index = 1001,
number = 0xFFFFFF,
})
},
}
add_hud_element({
hud_elem_type = "image",
text = "mineclone2_logo.png",
scale = {x = 1, y = 1},
}, huds, 300, 0)
add_hud_element({
hud_elem_type = "text",
text = mcl_credits.description,
number = 0x757575,
scale = {x = 5, y = 5},
}, huds, 350, 0)
local y = 450
for _, group in ipairs(mcl_credits.people) do
add_hud_element({
hud_elem_type = "text",
text = group[1],
number = group[2],
scale = {x = 3, y = 3},
}, huds, y, 0)
y = y + 25
for _, name in ipairs(group[3]) do
y = y + 25
add_hud_element({
hud_elem_type = "text",
text = name,
number = 0xFFFFFF,
scale = {x = 1, y = 1},
}, huds, y, 0)
end
y = y + 200
end
huds.icon = add_hud_element({
hud_elem_type = "image",
text = "mineclone2_icon.png",
scale = {x = 1, y = 1},
}, huds, y)
mcl_credits.players[name] = huds
end
function mcl_credits.hide(player)
local name = player:get_player_name()
local huds = mcl_credits.players[name]
if huds then
for _, id in pairs(huds.ids) do
player:hud_remove(id)
end
end
mcl_credits.players[name] = nil
end
minetest.register_on_leaveplayer(function(player)
mcl_credits.players[player:get_player_name()] = nil
end)
minetest.register_globalstep(function(dtime)
for _, huds in pairs(mcl_credits.players) do
local player = huds.player
if not huds.new and player:get_player_control().sneak then
mcl_credits.hide(player)
else
local moving = {}
local any
for id, y in pairs(huds.moving) do
y = y - 1
if y > -100 then
if id == huds.icon then
y = math.max(400, y)
else
any = true
end
player:hud_change(id, "offset", {x = 0, y = y})
moving[id] = y
end
end
if not any then
mcl_credits.hide(player)
end
huds.moving = moving
end
huds.new = false
end
end)

View File

@ -0,0 +1,3 @@
name = mcl_credits
author = Fleckenstein
description = Show a HUD containing the credits

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 B

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 965 B

View File

@ -169,7 +169,16 @@ minetest.register_node("mcl_end:dragon_egg", {
sounds = mcl_sounds.node_sound_stone_defaults(), sounds = mcl_sounds.node_sound_stone_defaults(),
_mcl_blast_resistance = 9, _mcl_blast_resistance = 9,
_mcl_hardness = 3, _mcl_hardness = 3,
-- TODO: Make dragon egg teleport on punching on_punch = function(pos, node)
local max_dist = vector.new(15, 7, 15)
local positions = minetest.find_nodes_in_area(vector.subtract(pos, max_dist), vector.add(pos, max_dist), "air", false)
if #positions > 0 then
local tpos = positions[math.random(#positions)]
minetest.remove_node(pos)
minetest.set_node(tpos, node)
minetest.check_for_falling(tpos)
end
end,
}) })

View File

@ -58,8 +58,9 @@ local function spawn_crystal(pos)
for _, crystal in pairs(crystals) do for _, crystal in pairs(crystals) do
crystal_explode(crystal) crystal_explode(crystal)
end end
local dragon = minetest.add_entity(vector.add(portal_center, {x = 0, y = 10, z = 0}), "mobs_mc:enderdragon") local portal_pos = vector.add(portal_center, vector.new(-3, -1, -3))
dragon:get_luaentity()._egg_spawn_pos = minetest.pos_to_string(vector.add(portal_center, {x = 0, y = 4, z = 0})) mcl_structures.call_struct(portal_pos, "end_exit_portal")
minetest.add_entity(vector.add(portal_pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon"):get_luaentity()._portal_pos = portal_pos
end end
minetest.register_entity("mcl_end:crystal", { minetest.register_entity("mcl_end:crystal", {

View File

@ -1,6 +1,8 @@
-- Load files -- Load files
mcl_portals = {} mcl_portals = {
storage = minetest.get_mod_storage(),
}
-- Nether portal: -- Nether portal:
-- Obsidian frame, activated by flint and steel -- Obsidian frame, activated by flint and steel
@ -10,3 +12,5 @@ dofile(minetest.get_modpath("mcl_portals").."/portal_nether.lua")
-- Red nether brick block frame, activated by an eye of ender -- Red nether brick block frame, activated by an eye of ender
dofile(minetest.get_modpath("mcl_portals").."/portal_end.lua") dofile(minetest.get_modpath("mcl_portals").."/portal_end.lua")
dofile(minetest.get_modpath("mcl_portals").."/portal_gateway.lua")

View File

@ -211,6 +211,9 @@ function mcl_portals.end_teleport(obj, pos)
-- Look towards the main End island -- Look towards the main End island
if dim ~= "end" then if dim ~= "end" then
obj:set_look_horizontal(math.pi/2) obj:set_look_horizontal(math.pi/2)
-- Show credits
else
mcl_credits.show(obj)
end end
mcl_worlds.dimension_change(obj, mcl_worlds.pos_to_dimension(target)) mcl_worlds.dimension_change(obj, mcl_worlds.pos_to_dimension(target))
minetest.sound_play("mcl_portals_teleport", {pos=target, gain=0.5, max_hear_distance = 16}, true) minetest.sound_play("mcl_portals_teleport", {pos=target, gain=0.5, max_hear_distance = 16}, true)

View File

@ -0,0 +1,113 @@
local S = minetest.get_translator("mcl_portals")
local storage = mcl_portals.storage
local gateway_positions = {
{x = 96, y = -26925, z = 0},
{x = 91, y = -26925, z = 29},
{x = 77, y = -26925, z = 56},
{x = 56, y = -26925, z = 77},
{x = 29, y = -26925, z = 91},
{x = 0, y = -26925, z = 96},
{x = -29, y = -26925, z = 91},
{x = -56, y = -26925, z = 77},
{x = -77, y = -26925, z = 56},
{x = -91, y = -26925, z = 29},
{x = -96, y = -26925, z = 0},
{x = -91, y = -26925, z = -29},
{x = -77, y = -26925, z = -56},
{x = -56, y = -26925, z = -77},
{x = -29, y = -26925, z = -91},
{x = 0, y = -26925, z = -96},
{x = 29, y = -26925, z = -91},
{x = 56, y = -26925, z = -77},
{x = 77, y = -26925, z = -56},
{x = 91, y = -26925, z = -29},
}
local function spawn_gateway_portal(pos, dest_str)
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts"
return mcl_structures.place_schematic(vector.add(pos, vector.new(-1, -2, -1)), path, "0", nil, true, nil, dest_str and function()
minetest.get_meta(pos):set_string("mcl_portals:gateway_destination", dest_str)
end)
end
function mcl_portals.spawn_gateway_portal()
local id = storage:get_int("gateway_last_id") + 1
local pos = gateway_positions[id]
if not pos then return end
storage:set_int("gateway_last_id", id)
spawn_gateway_portal(pos)
end
local gateway_def = table.copy(minetest.registered_nodes["mcl_portals:portal_end"])
gateway_def.description = S("End Gateway Portal")
gateway_def._tt_help = S("Used to construct end gateway portals")
gateway_def._doc_items_longdesc = S("An End gateway portal teleports creatures and objects to the outer End (and back!).")
gateway_def._doc_items_usagehelp = S("Throw an ender pearl into the portal to teleport. Entering an Gateway portal near the Overworld teleports you to the outer End. At this destination another gateway portal will be constructed, which you can use to get back.")
gateway_def.after_destruct = nil
gateway_def.drawtype = "normal"
gateway_def.node_box = nil
gateway_def.walkable = true
gateway_def.tiles[3] = nil
minetest.register_node("mcl_portals:portal_gateway", gateway_def)
local function find_destination_pos(minp, maxp)
for y = maxp.y, minp.y, -1 do
for x = maxp.x, minp.x, -1 do
for z = maxp.z, minp.z, -1 do
local pos = vector.new(x, y, z)
local nn = minetest.get_node(pos).name
if nn ~= "ignore" and nn ~= "mcl_portals:portal_gateway" and nn ~= "mcl_core:bedrock" then
local def = minetest.registered_nodes[nn]
if def and def.walkable then
return vector.add(pos, vector.new(0, 1.5, 0))
end
end
end
end
end
end
local preparing = {}
local function teleport(pos, obj)
local meta = minetest.get_meta(pos)
local dest_portal
local dest_str = meta:get_string("mcl_portals:gateway_destination")
local pos_str = minetest.pos_to_string(pos)
if dest_str == "" then
dest_portal = vector.multiply(vector.direction(vector.new(0, pos.y, 0), pos), math.random(768, 1024))
dest_portal.y = -26970
spawn_gateway_portal(dest_portal, pos_str)
meta:set_string("mcl_portals:gateway_destination", minetest.pos_to_string(dest_portal))
else
dest_portal = minetest.string_to_pos(dest_str)
end
local minp = vector.subtract(dest_portal, vector.new(5, 40, 5))
local maxp = vector.add(dest_portal, vector.new(5, 10, 5))
preparing[pos_str] = true
minetest.emerge_area(minp, maxp, function(blockpos, action, calls_remaining, param)
if calls_remaining < 1 then
if obj and obj:is_player() or obj:get_luaentity() then
obj:set_pos(find_destination_pos(minp, maxp) or vector.add(dest_portal, vector.new(0, 3.5, 0)))
end
preparing[pos_str] = false
end
end)
end
minetest.register_abm({
label = "End gateway portal teleportation",
nodenames = {"mcl_portals:portal_gateway"},
interval = 0.1,
chance = 1,
action = function(pos)
if preparing[minetest.pos_to_string(pos)] then return end
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do
if obj:get_hp() > 0 then
teleport(pos, obj)
return
end
end
end,
})

View File

@ -1,5 +1,7 @@
local S = minetest.get_translator("mcl_portals") local S = minetest.get_translator("mcl_portals")
local SCAN_2_MAP_CHUNKS = true -- slower but helps to find more suitable places
-- Localize functions for better performance -- Localize functions for better performance
local abs = math.abs local abs = math.abs
local ceil = math.ceil local ceil = math.ceil
@ -26,7 +28,7 @@ local DISTANCE_MAX = 128
local PORTAL = "mcl_portals:portal" local PORTAL = "mcl_portals:portal"
local OBSIDIAN = "mcl_core:obsidian" local OBSIDIAN = "mcl_core:obsidian"
local O_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max_official, 2048) local O_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max_official, 2048)
local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_max local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_max - H_MIN
local O_DY, N_DY = O_Y_MAX - O_Y_MIN + 1, N_Y_MAX - N_Y_MIN + 1 local O_DY, N_DY = O_Y_MAX - O_Y_MIN + 1, N_Y_MAX - N_Y_MIN + 1
-- Alpha and particles -- Alpha and particles
@ -47,7 +49,7 @@ local chatter = {}
local queue = {} local queue = {}
local chunks = {} local chunks = {}
local storage = minetest.get_mod_storage() local storage = mcl_portals.storage
local exits = {} local exits = {}
local keys = minetest.deserialize(storage:get_string("nether_exits_keys") or "return {}") or {} local keys = minetest.deserialize(storage:get_string("nether_exits_keys") or "return {}") or {}
for _, key in pairs(keys) do for _, key in pairs(keys) do
@ -486,6 +488,14 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
create_portal_2(pos0, name, obj) create_portal_2(pos0, name, obj)
return return
end end
if param.next_chunk_1 and param.next_chunk_2 and param.next_pos then
local pos1, pos2, pos = param.next_chunk_1, param.next_chunk_2, param.next_pos
log("action", "[mcl_portals] Making additional search in chunk below, because current one doesn't contain any air space for portal, target pos "..pos_to_string(pos))
minetest.emerge_area(pos1, pos2, ecb_scan_area_2, {pos = pos, pos1 = pos1, pos2 = pos2, name=name, obj=obj})
return
end
log("action", "[mcl_portals] found no space, reverting to target pos "..pos_to_string(pos).." - creating a portal") log("action", "[mcl_portals] found no space, reverting to target pos "..pos_to_string(pos).." - creating a portal")
if pos.y < lava then if pos.y < lava then
pos.y = lava + 1 pos.y = lava + 1
@ -507,18 +517,35 @@ local function create_portal(pos, limit1, limit2, name, obj)
-- we need to emerge the area here, but currently (mt5.4/mcl20.71) map generation is slow -- we need to emerge the area here, but currently (mt5.4/mcl20.71) map generation is slow
-- so we'll emerge single chunk only: 5x5x5 blocks, 80x80x80 nodes maximum -- so we'll emerge single chunk only: 5x5x5 blocks, 80x80x80 nodes maximum
-- and maybe one more chunk from below if (SCAN_2_MAP_CHUNKS = true)
local pos1 = add(mul(mcl_vars.pos_to_chunk(pos), mcl_vars.chunk_size_in_nodes), mcl_vars.central_chunk_offset_in_nodes) local pos1 = add(mul(mcl_vars.pos_to_chunk(pos), mcl_vars.chunk_size_in_nodes), mcl_vars.central_chunk_offset_in_nodes)
local pos2 = add(pos1, mcl_vars.chunk_size_in_nodes - 1) local pos2 = add(pos1, mcl_vars.chunk_size_in_nodes - 1)
if not SCAN_2_MAP_CHUNKS then
if limit1 and limit1.x and limit1.y and limit1.z then if limit1 and limit1.x and limit1.y and limit1.z then
pos1 = {x = max(min(limit1.x, pos.x), pos1.x), y = max(min(limit1.y, pos.y), pos1.y), z = max(min(limit1.z, pos.z), pos1.z)} pos1 = {x = max(min(limit1.x, pos.x), pos1.x), y = max(min(limit1.y, pos.y), pos1.y), z = max(min(limit1.z, pos.z), pos1.z)}
end end
if limit2 and limit2.x and limit2.y and limit2.z then if limit2 and limit2.x and limit2.y and limit2.z then
pos2 = {x = min(max(limit2.x, pos.x), pos2.x), y = min(max(limit2.y, pos.y), pos2.y), z = min(max(limit2.z, pos.z), pos2.z)} pos2 = {x = min(max(limit2.x, pos.x), pos2.x), y = min(max(limit2.y, pos.y), pos2.y), z = min(max(limit2.z, pos.z), pos2.z)}
end end
minetest.emerge_area(pos1, pos2, ecb_scan_area_2, {pos = vector.new(pos), pos1 = pos1, pos2 = pos2, name=name, obj=obj}) minetest.emerge_area(pos1, pos2, ecb_scan_area_2, {pos = vector.new(pos), pos1 = pos1, pos2 = pos2, name=name, obj=obj})
return
end
-- Basically the copy of code above, with minor additions to continue the search in single additional chunk below:
local next_chunk_1 = {x = pos1.x, y = pos1.y - mcl_vars.chunk_size_in_nodes, z = pos1.z}
local next_chunk_2 = add(next_chunk_1, mcl_vars.chunk_size_in_nodes - 1)
local next_pos = {x = pos.x, y=next_chunk_2.y, z = pos.z}
if limit1 and limit1.x and limit1.y and limit1.z then
pos1 = {x = max(min(limit1.x, pos.x), pos1.x), y = max(min(limit1.y, pos.y), pos1.y), z = max(min(limit1.z, pos.z), pos1.z)}
next_chunk_1 = {x = max(min(limit1.x, next_pos.x), next_chunk_1.x), y = max(min(limit1.y, next_pos.y), next_chunk_1.y), z = max(min(limit1.z, next_pos.z), next_chunk_1.z)}
end
if limit2 and limit2.x and limit2.y and limit2.z then
pos2 = {x = min(max(limit2.x, pos.x), pos2.x), y = min(max(limit2.y, pos.y), pos2.y), z = min(max(limit2.z, pos.z), pos2.z)}
next_chunk_2 = {x = min(max(limit2.x, next_pos.x), next_chunk_2.x), y = min(max(limit2.y, next_pos.y), next_chunk_2.y), z = min(max(limit2.z, next_pos.z), next_chunk_2.z)}
end
minetest.emerge_area(pos1, pos2, ecb_scan_area_2, {pos = vector.new(pos), pos1 = pos1, pos2 = pos2, name=name, obj=obj, next_chunk_1 = next_chunk_1, next_chunk_2 = next_chunk_2, next_pos = next_pos})
end end
local function available_for_nether_portal(p) local function available_for_nether_portal(p)

View File

@ -94,6 +94,35 @@ minetest.register_node("mcl_sponges:sponge", {
_mcl_hardness = 0.6, _mcl_hardness = 0.6,
}) })
function place_wet_sponge(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node(pointed_thing.under)
if placer and not placer:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
local name = placer:get_player_name()
if minetest.is_protected(pointed_thing.above, name) then
return itemstack
end
if mcl_worlds.pos_to_dimension(pointed_thing.above) == "nether" then
minetest.item_place_node(ItemStack("mcl_sponges:sponge"), placer, pointed_thing)
if not minetest.is_creative_enabled(name) then
itemstack:take_item()
end
return itemstack
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
minetest.register_node("mcl_sponges:sponge_wet", { minetest.register_node("mcl_sponges:sponge_wet", {
description = S("Waterlogged Sponge"), description = S("Waterlogged Sponge"),
_tt_help = S("Can be dried in furnace"), _tt_help = S("Can be dried in furnace"),
@ -108,6 +137,7 @@ minetest.register_node("mcl_sponges:sponge_wet", {
stack_max = 64, stack_max = 64,
sounds = mcl_sounds.node_sound_dirt_defaults(), sounds = mcl_sounds.node_sound_dirt_defaults(),
groups = {handy=1, hoey=1, building_block=1}, groups = {handy=1, hoey=1, building_block=1},
on_place = place_wet_sponge,
_mcl_blast_resistance = 0.6, _mcl_blast_resistance = 0.6,
_mcl_hardness = 0.6, _mcl_hardness = 0.6,
}) })
@ -127,6 +157,7 @@ if minetest.get_modpath("mclx_core") then
stack_max = 64, stack_max = 64,
sounds = mcl_sounds.node_sound_dirt_defaults(), sounds = mcl_sounds.node_sound_dirt_defaults(),
groups = {handy=1, building_block=1}, groups = {handy=1, building_block=1},
on_place = place_wet_sponge,
_mcl_blast_resistance = 0.6, _mcl_blast_resistance = 0.6,
_mcl_hardness = 0.6, _mcl_hardness = 0.6,
}) })

View File

@ -1484,6 +1484,7 @@ local function register_dimension_biomes()
node_stone = "mcl_nether:netherrack", node_stone = "mcl_nether:netherrack",
node_water = "air", node_water = "air",
node_river_water = "air", node_river_water = "air",
node_cave_liquid = "air",
y_min = mcl_vars.mg_nether_min, y_min = mcl_vars.mg_nether_min,
-- FIXME: For some reason the Nether stops generating early if this constant is not added. -- FIXME: For some reason the Nether stops generating early if this constant is not added.
-- Figure out why. -- Figure out why.
@ -1501,6 +1502,7 @@ local function register_dimension_biomes()
node_filler = "air", node_filler = "air",
node_water = "air", node_water = "air",
node_river_water = "air", node_river_water = "air",
node_cave_liquid = "air",
-- FIXME: For some reason the End stops generating early if this constant is not added. -- FIXME: For some reason the End stops generating early if this constant is not added.
-- Figure out why. -- Figure out why.
y_min = mcl_vars.mg_end_min, y_min = mcl_vars.mg_end_min,

View File

@ -8,12 +8,10 @@ local noisemap = PerlinNoiseMap({
}, {x = 151, y = 30, z = 151}):get_3d_map({x = 0, y = 0, z = 0}) }, {x = 151, y = 30, z = 151}):get_3d_map({x = 0, y = 0, z = 0})
local c_end_stone = minetest.get_content_id("mcl_end:end_stone") local c_end_stone = minetest.get_content_id("mcl_end:end_stone")
local x_offset = mcl_vars.mg_end_platform_pos.x - 27
local y_offset = -2 local y_offset = -2
minetest.register_on_generated(function(minp, maxp) minetest.register_on_generated(function(minp, maxp)
if maxp.y < (-27025 + y_offset) or minp.y > (-27000 + y_offset + 4) or maxp.x < (-75 + x_offset) or minp.x > (75 + x_offset) or maxp.z < -75 or minp.z > 75 then if maxp.y < (-27025 + y_offset) or minp.y > (-27000 + y_offset + 4) or maxp.x < -75 or minp.x > 75 or maxp.z < -75 or minp.z > 75 then
return return
end end
@ -21,10 +19,10 @@ minetest.register_on_generated(function(minp, maxp)
local data = vm:get_data() local data = vm:get_data()
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax}) local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
for idx in area:iter(math.max(minp.x, -75 + x_offset), math.max(minp.y, -27025 + y_offset + 4), math.max(minp.z, -75), math.min(maxp.x, 75 + x_offset), math.min(maxp.y, -27000 + y_offset), math.min(maxp.z, 75)) do for idx in area:iter(math.max(minp.x, -75), math.max(minp.y, -27025 + y_offset + 4), math.max(minp.z, -75), math.min(maxp.x, 75), math.min(maxp.y, -27000 + y_offset), math.min(maxp.z, 75)) do
local pos = area:position(idx) local pos = area:position(idx)
local y = 27025 + pos.y - y_offset local y = 27025 + pos.y - y_offset
if noisemap[pos.x + 75 - x_offset + 1][y + 1][pos.z + 75 + 1] > (math.abs(1 - y / 25) ^ 2 + math.abs((pos.x - x_offset) / 75) ^ 2 + math.abs(pos.z / 75) ^ 2) then if noisemap[pos.x + 75 + 1][y + 1][pos.z + 75 + 1] > (math.abs(1 - y / 25) ^ 2 + math.abs(pos.x / 75) ^ 2 + math.abs(pos.z / 75) ^ 2) then
data[idx] = c_end_stone data[idx] = c_end_stone
end end
end end

View File

@ -54,12 +54,8 @@ local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superfl
local WITCH_HUT_HEIGHT = 3 -- Exact Y level to spawn witch huts at. This height refers to the height of the floor local WITCH_HUT_HEIGHT = 3 -- Exact Y level to spawn witch huts at. This height refers to the height of the floor
-- End exit portal position. This is temporary. -- End exit portal position
-- TODO: Remove the exit portal generation when the ender dragon has been implemented. local END_EXIT_PORTAL_POS = vector.new(-3, -27003, -3)
local END_EXIT_PORTAL_POS = table.copy(mcl_vars.mg_end_platform_pos)
END_EXIT_PORTAL_POS.x = END_EXIT_PORTAL_POS.x - 30
END_EXIT_PORTAL_POS.z = END_EXIT_PORTAL_POS.z - 3
END_EXIT_PORTAL_POS.y = END_EXIT_PORTAL_POS.y - 3
-- Content IDs -- Content IDs
local c_bedrock = minetest.get_content_id("mcl_core:bedrock") local c_bedrock = minetest.get_content_id("mcl_core:bedrock")
@ -1251,6 +1247,13 @@ local function generate_clay(minp, maxp, blockseed, voxelmanip_data, voxelmanip_
return lvm_used return lvm_used
end end
local function generate_end_exit_portal(pos)
local dragon_entity = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon"):get_luaentity()
dragon_entity._initial = true
dragon_entity._portal_pos = pos
mcl_structures.call_struct(pos, "end_exit_portal")
end
-- TODO: Try to use more efficient structure generating code -- TODO: Try to use more efficient structure generating code
local function generate_structures(minp, maxp, blockseed, biomemap) local function generate_structures(minp, maxp, blockseed, biomemap)
local chunk_has_desert_well = false local chunk_has_desert_well = false
@ -1490,11 +1493,11 @@ local function generate_structures(minp, maxp, blockseed, biomemap)
for y=maxp.y, minp.y, -1 do for y=maxp.y, minp.y, -1 do
local p = {x=END_EXIT_PORTAL_POS.x, y=y, z=END_EXIT_PORTAL_POS.z} local p = {x=END_EXIT_PORTAL_POS.x, y=y, z=END_EXIT_PORTAL_POS.z}
if minetest.get_node(p).name == "mcl_end:end_stone" then if minetest.get_node(p).name == "mcl_end:end_stone" then
mcl_structures.call_struct(p, "end_exit_portal") generate_end_exit_portal(p)
return return
end end
end end
mcl_structures.call_struct(END_EXIT_PORTAL_POS, "end_exit_portal") generate_end_exit_portal(END_EXIT_PORTAL_POS)
end end
end end

View File

@ -11,10 +11,10 @@ local function ecb_place(blockpos, action, calls_remaining, param)
if calls_remaining >= 1 then return end if calls_remaining >= 1 then return end
minetest.place_schematic(param.pos, param.schematic, param.rotation, param.replacements, param.force_placement, param.flags) minetest.place_schematic(param.pos, param.schematic, param.rotation, param.replacements, param.force_placement, param.flags)
if param.after_placement_callback and param.p1 and param.p2 then if param.after_placement_callback and param.p1 and param.p2 then
param.after_placement_callback(param.p1, param.p2, param.size, param.rotation, param.pr) param.after_placement_callback(param.p1, param.p2, param.size, param.rotation, param.pr, param.callback_param)
end end
end end
mcl_structures.place_schematic = function(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr) mcl_structures.place_schematic = function(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr, callback_param)
local s = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return(schematic)")() local s = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return(schematic)")()
if s and s.size then if s and s.size then
local x, z = s.size.x, s.size.z local x, z = s.size.x, s.size.z
@ -32,7 +32,7 @@ mcl_structures.place_schematic = function(pos, schematic, rotation, replacements
local p1 = {x=pos.x , y=pos.y , z=pos.z } local p1 = {x=pos.x , y=pos.y , z=pos.z }
local p2 = {x=pos.x+x-1, y=pos.y+s.size.y-1, z=pos.z+z-1} local p2 = {x=pos.x+x-1, y=pos.y+s.size.y-1, z=pos.z+z-1}
minetest.log("verbose","[mcl_structures] size=" ..minetest.pos_to_string(s.size) .. ", rotation=" .. tostring(rotation) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2)) minetest.log("verbose","[mcl_structures] size=" ..minetest.pos_to_string(s.size) .. ", rotation=" .. tostring(rotation) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2))
local param = {pos=vector.new(pos), schematic=s, rotation=rotation, replacements=replacements, force_placement=force_placement, flags=flags, p1=p1, p2=p2, after_placement_callback = after_placement_callback, size=vector.new(s.size), pr=pr} local param = {pos=vector.new(pos), schematic=s, rotation=rotation, replacements=replacements, force_placement=force_placement, flags=flags, p1=p1, p2=p2, after_placement_callback = after_placement_callback, size=vector.new(s.size), pr=pr, callback_param=callback_param}
minetest.emerge_area(p1, p2, ecb_place, param) minetest.emerge_area(p1, p2, ecb_place, param)
end end
end end
@ -87,6 +87,10 @@ mcl_structures.call_struct = function(pos, struct_style, rotation, pr)
return mcl_structures.generate_fossil(pos, rotation, pr) return mcl_structures.generate_fossil(pos, rotation, pr)
elseif struct_style == "end_exit_portal" then elseif struct_style == "end_exit_portal" then
return mcl_structures.generate_end_exit_portal(pos, rotation) return mcl_structures.generate_end_exit_portal(pos, rotation)
elseif struct_style == "end_exit_portal_open" then
return mcl_structures.generate_end_exit_portal_open(pos, rotation)
elseif struct_style == "end_gateway_portal" then
return mcl_structures.generate_end_gateway_portal(pos, rotation)
elseif struct_style == "end_portal_shrine" then elseif struct_style == "end_portal_shrine" then
return mcl_structures.generate_end_portal_shrine(pos, rotation, pr) return mcl_structures.generate_end_portal_shrine(pos, rotation, pr)
end end
@ -313,8 +317,17 @@ mcl_structures.generate_fossil = function(pos, rotation, pr)
end end
mcl_structures.generate_end_exit_portal = function(pos, rot) mcl_structures.generate_end_exit_portal = function(pos, rot)
minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon")
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts" local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts"
return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true)
end
mcl_structures.generate_end_exit_portal_open = function(pos, rot)
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts"
return mcl_structures.place_schematic(pos, path, rot or "0", nil, true)
end
mcl_structures.generate_end_gateway_portal = function(pos, rot)
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts"
return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) return mcl_structures.place_schematic(pos, path, rot or "0", nil, true)
end end
@ -535,7 +548,7 @@ end
-- Debug command -- Debug command
minetest.register_chatcommand("spawnstruct", { minetest.register_chatcommand("spawnstruct", {
params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_portal_shrine | nether_portal | dungeon", params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_exit_portal_open | end_gateway_portal | end_portal_shrine | nether_portal | dungeon",
description = S("Generate a pre-defined structure near your position."), description = S("Generate a pre-defined structure near your position."),
privs = {debug = true}, privs = {debug = true},
func = function(name, param) func = function(name, param)
@ -567,6 +580,10 @@ minetest.register_chatcommand("spawnstruct", {
mcl_structures.generate_ice_spike_large(pos, rot, pr) mcl_structures.generate_ice_spike_large(pos, rot, pr)
elseif param == "end_exit_portal" then elseif param == "end_exit_portal" then
mcl_structures.generate_end_exit_portal(pos, rot, pr) mcl_structures.generate_end_exit_portal(pos, rot, pr)
elseif param == "end_exit_portal_open" then
mcl_structures.generate_end_exit_portal_open(pos, rot, pr)
elseif param == "end_gateway_portal" then
mcl_structures.generate_end_gateway_portal(pos, rot, pr)
elseif param == "end_portal_shrine" then elseif param == "end_portal_shrine" then
mcl_structures.generate_end_portal_shrine(pos, rot, pr) mcl_structures.generate_end_portal_shrine(pos, rot, pr)
elseif param == "dungeon" and mcl_dungeons and mcl_dungeons.spawn_dungeon then elseif param == "dungeon" and mcl_dungeons and mcl_dungeons.spawn_dungeon then

View File

@ -70,6 +70,10 @@ minetest.register_on_joinplayer(function(player)
local name = player:get_player_name() local name = player:get_player_name()
wieldview.wielded_item[name] = "" wieldview.wielded_item[name] = ""
minetest.after(0, function(player) minetest.after(0, function(player)
-- if the player left :is_player() will return nil
if not player:is_player() then
return
end
wieldview:update_wielded_item(player) wieldview:update_wielded_item(player)
local itementity = minetest.add_entity(player:get_pos(), "wieldview:wieldnode") local itementity = minetest.add_entity(player:get_pos(), "wieldview:wieldnode")
itementity:set_attach(player, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 0, 45)) itementity:set_attach(player, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 0, 45))
@ -114,7 +118,8 @@ minetest.register_entity("wieldview:wieldnode", {
-- wield item as cubic -- wield item as cubic
if armor.textures[self.wielder].wielditem == "blank.png" then if armor.textures[self.wielder].wielditem == "blank.png" then
self.object:set_properties({textures = {itemstring}}) self.object:set_properties({textures = {itemstring}})
else -- wield item as flat -- wield item as flat
else
self.object:set_properties({textures = {""}}) self.object:set_properties({textures = {""}})
end end