From 36c2e1334aae48ac21a0005cf53b29b059936783 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 12 Jun 2024 07:18:54 -0500 Subject: [PATCH] Nether portal delay settings --- mods/ITEMS/mcl_portals/mod.conf | 2 +- mods/ITEMS/mcl_portals/portal_nether.lua | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_portals/mod.conf b/mods/ITEMS/mcl_portals/mod.conf index ab03de570..8587a7d07 100644 --- a/mods/ITEMS/mcl_portals/mod.conf +++ b/mods/ITEMS/mcl_portals/mod.conf @@ -1,4 +1,4 @@ name = mcl_portals description = Adds buildable portals to the Nether and End dimensions. -depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn, mcl_credits, mcl_structures +depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn, mcl_credits, mcl_structures, vl_tuning optional_depends = awards, doc diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index d261b4bd3..ddc5e220a 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -85,7 +85,14 @@ local LIM_MIN, LIM_MAX = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max local PLAYER_COOLOFF, MOB_COOLOFF = 3, 14 -- for this many seconds they won't teleported again local TOUCH_CHATTER_TIME = 1 -- prevent multiple teleportation attempts caused by multiple portal touches, for this number of seconds local CHATTER_US = TOUCH_CHATTER_TIME * 1000000 -local DELAY = 3 -- seconds before teleporting in Nether portal in Survival mode (4 minus ABM interval time) + +local nether_portal_creative_delay = vl_tuning.setting("gamerule:playersNetherPortalCreativeDelay", "number", { + default = 0, +}) +local nether_port_survival_delay = vl_tuning.setting("gamerule:playersNetherPortalDefaultDelay", "number", { + default = 4, +}) + -- Speeds up the search by allowing some non-air nodes to be replaced when -- looking for acceptable portal locations. Setting this lower means the -- algorithm will do more searching. Even at 0, there is no risk of finding @@ -1477,12 +1484,16 @@ local function teleport(obj, portal_pos) if cooloff[obj] then return end + local delay = math.max(0, nether_portal_survival_delay[1] - 1) if minetest.is_creative_enabled(name) then - teleport_no_delay(obj, portal_pos) - return + delay = math.max(0, nether_portal_creative_delay[1] - 1) end - minetest.after(DELAY, teleport_no_delay, obj, portal_pos) + if delay == 0 then + teleport_no_delay(obj, portal_pos) + else + minetest.after(delay, teleport_no_delay, obj, portal_pos) + end end minetest.register_abm({