forked from minetest-mods/nether
Compare commits
1 Commits
97cf3250e4
...
v2
Author | SHA1 | Date | |
---|---|---|---|
02d062b9c9 |
6
init.lua
6
init.lua
@ -51,8 +51,8 @@ nether.useBiomes = minetest.get_mapgen_setting("mg_name") ~= "v6" and minet
|
||||
|
||||
|
||||
-- Settings
|
||||
nether.DEPTH_CEILING = -25000 -- The y location of the Nether's celing
|
||||
nether.DEPTH_FLOOR = -31000 -- The y location of the Nether's floor
|
||||
nether.DEPTH_CEILING = -5000 -- The y location of the Nether's celing
|
||||
nether.DEPTH_FLOOR = -11000 -- The y location of the Nether's floor
|
||||
nether.FASTTRAVEL_FACTOR = 8 -- 10 could be better value for Minetest, since there's no sprint, but ex-Minecraft players will be mathing for 8
|
||||
nether.PORTAL_BOOK_LOOT_WEIGHTING = 0.9 -- Likelyhood of finding the Book of Portals (guide) in dungeon chests. Set to 0 to disable.
|
||||
nether.NETHER_REALM_ENABLED = true -- Setting to false disables the Nether and Nether portal
|
||||
@ -100,7 +100,7 @@ function nether.debug(message, ...)
|
||||
end
|
||||
end
|
||||
|
||||
local composed_message = string.format(message, unpack(args))
|
||||
local composed_message = "nether: " .. string.format(message, unpack(args))
|
||||
|
||||
if math.floor(DEBUG_FLAGS / 1) % 2 == 1 then print(composed_message) end
|
||||
if math.floor(DEBUG_FLAGS / 2) % 2 == 1 then minetest.chat_send_all(composed_message) end
|
||||
|
@ -503,4 +503,4 @@ end
|
||||
-- if a biome defines the dungeon nodes
|
||||
minetest.set_gen_notify({dungeon = true})
|
||||
|
||||
minetest.register_on_generated(on_generated)
|
||||
minetest.register_on_generated(on_generated)
|
@ -52,6 +52,11 @@ if minetest.get_mod_storage == nil then
|
||||
error(nether.modname .. " does not support Minetest versions earlier than 0.4.16", 0)
|
||||
end
|
||||
|
||||
local S = nether.get_translator
|
||||
nether.portal_destination_not_found_message =
|
||||
S("Mysterious forces prevented you from opening that portal. Please try another location")
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
Positions
|
||||
@ -663,7 +668,6 @@ nether.PortalShape_Platform = {
|
||||
-- Portal implementation functions --
|
||||
-- =============================== --
|
||||
|
||||
local S = nether.get_translator
|
||||
local debugf = nether.debug
|
||||
local ignition_item_name
|
||||
local mod_storage = minetest.get_mod_storage()
|
||||
@ -1367,8 +1371,13 @@ local function ignite_portal(ignition_pos, player_name, ignition_node_name)
|
||||
destination_orientation = orientation
|
||||
end
|
||||
|
||||
if destination_anchorPos == nil then
|
||||
if destination_anchorPos == nil or destination_anchorPos.y == nil then
|
||||
-- destination_anchorPos.y was also checked for nil in case portal_definition.find_surface_anchorPos()
|
||||
-- had used nether.find_surface_target_y() and that had returned nil.
|
||||
debugf("No portal destination available here!")
|
||||
if (player_name or "") ~= "" then
|
||||
minetest.chat_send_player(player_name, nether.portal_destination_not_found_message)
|
||||
end
|
||||
return false
|
||||
else
|
||||
local destination_wormholePos = portal_definition.shape.get_wormholePos_from_anchorPos(destination_anchorPos, destination_orientation)
|
||||
@ -2160,23 +2169,18 @@ function nether.register_portal_ignition_item(item_name, ignition_failure_sound)
|
||||
|
||||
minetest.override_item(item_name, {
|
||||
on_place = function(stack, placer, pt)
|
||||
local node = minetest.get_node(pt.under)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local done = false
|
||||
|
||||
if pt.under and nether.is_frame_node[node.name] then
|
||||
if pt.under and nether.is_frame_node[minetest.get_node(pt.under).name] then
|
||||
done = ignite_portal(pt.under, placer:get_player_name())
|
||||
if done and not minetest.settings:get_bool("creative_mode") then
|
||||
stack:take_item()
|
||||
end
|
||||
elseif def and def.on_rightclick then
|
||||
def.on_rightclick(pt.under, node, placer, stack, pt)
|
||||
end
|
||||
|
||||
if not done and ignition_failure_sound ~= nil then
|
||||
minetest.sound_play(ignition_failure_sound, {pos = pt.under, max_hear_distance = 10})
|
||||
end
|
||||
|
||||
|
||||
return stack
|
||||
end,
|
||||
})
|
||||
@ -2222,7 +2226,7 @@ function nether.volume_is_natural_and_unprotected(minp, maxp, player_name)
|
||||
end
|
||||
|
||||
if minetest.is_area_protected(minp, maxp, player_name or "") then
|
||||
debugf("Volume is protected %s-%s", minp, maxp)
|
||||
debugf("Volume is protected against player '%s', %s-%s", player_name, minp, maxp)
|
||||
return false;
|
||||
end
|
||||
|
||||
@ -2321,7 +2325,12 @@ function nether.find_surface_target_y(target_x, target_z, portal_name, player_na
|
||||
local minp = {x = minp_schem.x, y = 0, z = minp_schem.z}
|
||||
local maxp = {x = maxp_schem.x, y = 0, z = maxp_schem.z}
|
||||
|
||||
for y = start_y, start_y - 256, -16 do
|
||||
-- Starting searchstep at -16 and making it larger by 2 after each step gives a 20-step search range down to -646:
|
||||
-- 0, -16, -34, -54, -76, -100, -126, -154, -184, -216, -250, -286, -324, -364, -406, -450, -496, -544, -594, -646
|
||||
local searchstep = -16;
|
||||
|
||||
local y = start_y
|
||||
while y > start_y - 650 do
|
||||
-- Check volume for non-natural nodes
|
||||
minp.y = minp_schem.y + y
|
||||
maxp.y = maxp_schem.y + y
|
||||
@ -2336,9 +2345,11 @@ function nether.find_surface_target_y(target_x, target_z, portal_name, player_na
|
||||
return y
|
||||
end
|
||||
end
|
||||
y = y + searchstep
|
||||
searchstep = searchstep - 2
|
||||
end
|
||||
|
||||
return start_y - 256 -- Fallback
|
||||
return nil -- Portal ignition failure. Possibly due to a large protected area.
|
||||
end
|
||||
|
||||
|
||||
@ -2370,10 +2381,11 @@ function nether.find_nearest_working_portal(portal_name, anchorPos, distance_lim
|
||||
if portalFound then
|
||||
return portal_info.anchorPos, portal_info.orientation
|
||||
else
|
||||
debugf("Portal wasn't found, removing portal from mod_storage at %s orientation %s", portal_info.anchorPos, portal_info.orientation)
|
||||
debugf("Portal wasn't found, removing portal from mod_storage at %s orientation %s",
|
||||
portal_info.anchorPos, portal_info.orientation)
|
||||
-- The portal at that location must have been destroyed
|
||||
remove_portal_location_info(portal_name, portal_info.anchorPos)
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
@ -65,6 +65,8 @@ Helper functions
|
||||
surface to be reused.
|
||||
* player_name is optional, providing it prevents the exclusion of surface
|
||||
target areas which are protected by the player.
|
||||
* May return nil in extreme circumstances, such as the surface being
|
||||
protected down to a great depth.
|
||||
|
||||
* `nether.find_nearest_working_portal(portal_name, anchorPos, distance_limit, y_factor)`: returns
|
||||
(anchorPos, orientation), or nil if no portal was found within the
|
||||
@ -222,7 +224,8 @@ Used by `nether.register_portal`.
|
||||
-- If the location of an existing portal is returned then include the
|
||||
-- orientation, otherwise the existing portal could be overwritten by
|
||||
-- a new one with the orientation of the surface portal.
|
||||
-- Return nil to prevent the portal from igniting.
|
||||
-- Return nil, or a position with a nil y component, to prevent the
|
||||
-- portal from igniting.
|
||||
-- player_name may be "", e.g. if the portal was ignited by a mesecon,
|
||||
-- and is provided for use with volume_is_natural_and_unprotected() etc.
|
||||
|
||||
@ -239,7 +242,8 @@ Used by `nether.register_portal`.
|
||||
-- If the location of an existing portal is returned then include the
|
||||
-- orientation, otherwise the existing portal could be overwritten by
|
||||
-- a new one with the orientation of the realm portal.
|
||||
-- Return nil to prevent the portal from igniting.
|
||||
-- Return nil, or a position with a nil y component, to prevent the
|
||||
-- portal from igniting.
|
||||
-- player_name may be "", e.g. if the portal was ignited by a mesecon,
|
||||
-- and is provided for use with volume_is_natural_and_unprotected() etc.
|
||||
|
||||
|
Reference in New Issue
Block a user