From cad23bd851d0def08fc56bc7cbec395fe60fa108 Mon Sep 17 00:00:00 2001 From: kay27 Date: Tue, 16 Mar 2021 14:05:38 +0400 Subject: [PATCH 01/16] Prevent accessing uninitialized mcl_weather from mcl_burning --- mods/ENTITIES/mcl_burning/api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index a217d294d..1a3365d14 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -34,7 +34,7 @@ function mcl_burning.is_burning(obj) end function mcl_burning.is_affected_by_rain(obj) - return mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos()) + return mcl_weather and mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos()) end function mcl_burning.get_collisionbox(obj, smaller) From 71bb18cd767a867252792d0f1c15b3b52197681e Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 16 Mar 2021 11:07:17 +0100 Subject: [PATCH 02/16] walkover optimisation part1 --- mods/CORE/walkover/init.lua | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/mods/CORE/walkover/init.lua b/mods/CORE/walkover/init.lua index 6bbd505d2..a4f657706 100644 --- a/mods/CORE/walkover/init.lua +++ b/mods/CORE/walkover/init.lua @@ -1,4 +1,9 @@ -- register extra flavours of a base nodedef + +local get_connected_players = minetest.get_connected_players +local get_node = minetest.get_node +local vector_add = vector.add + walkover = {} walkover.registered_globals = {} @@ -6,24 +11,37 @@ function walkover.register_global(func) table.insert(walkover.registered_globals, func) end +local on_walk = {} +local registered_globals = {} + +minetest.register_on_mods_loaded(function() + for name,def in pairs(minetest.registered_nodes) do + if def.on_walk_over then + on_walk[name] = def.on_walk_over + end + end + for _,func in ipairs(walkover.registered_globals) do --cache registered globals + table.insert(registered_globals, value) + end +end) + local timer = 0 minetest.register_globalstep(function(dtime) timer = timer + dtime; if timer >= 0.3 then - for _,player in pairs(minetest.get_connected_players()) do + for _,player in ipairs(get_connected_players()) do local pp = player:get_pos() pp.y = math.ceil(pp.y) - local loc = vector.add(pp, {x=0,y=-1,z=0}) + local loc = vector_add(pp, {x=0,y=-1,z=0}) if loc ~= nil then - local nodeiamon = minetest.get_node(loc) + local nodeiamon = get_node(loc) if nodeiamon ~= nil then - local def = minetest.registered_nodes[nodeiamon.name] - if def ~= nil and def.on_walk_over ~= nil then - def.on_walk_over(loc, nodeiamon, player) + if on_walk[nodeiamon.name] then + on_walk[nodeiamon.name](loc, nodeiamon, player) end - for _, func in ipairs(walkover.registered_globals) do + for _,func in ipairs(registered_globals) do func(loc, nodeiamon, player) end end From 2da8be9f78c3923297360d22e9b7307cb43d530f Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 16 Mar 2021 11:22:13 +0100 Subject: [PATCH 03/16] optimise walkover part2 --- mods/CORE/walkover/init.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/CORE/walkover/init.lua b/mods/CORE/walkover/init.lua index a4f657706..4ef164303 100644 --- a/mods/CORE/walkover/init.lua +++ b/mods/CORE/walkover/init.lua @@ -3,6 +3,7 @@ local get_connected_players = minetest.get_connected_players local get_node = minetest.get_node local vector_add = vector.add +local ceil = math.ceil walkover = {} walkover.registered_globals = {} @@ -31,7 +32,7 @@ minetest.register_globalstep(function(dtime) if timer >= 0.3 then for _,player in ipairs(get_connected_players()) do local pp = player:get_pos() - pp.y = math.ceil(pp.y) + pp.y = ceil(pp.y) local loc = vector_add(pp, {x=0,y=-1,z=0}) if loc ~= nil then @@ -41,8 +42,8 @@ minetest.register_globalstep(function(dtime) if on_walk[nodeiamon.name] then on_walk[nodeiamon.name](loc, nodeiamon, player) end - for _,func in ipairs(registered_globals) do - func(loc, nodeiamon, player) + for i = 1, #registered_globals do + registered_globals[i](loc, nodeiamon, player) end end end From f06a56d7c4a23d41b83cd4e34b79e1f00ed82a94 Mon Sep 17 00:00:00 2001 From: Code-Sploit Date: Tue, 16 Mar 2021 12:54:33 +0000 Subject: [PATCH 04/16] Set max_stack of Lava, Water and Emtpy buckets to 1 --- mods/ITEMS/mcl_buckets/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 9e830fd73..986dea5a4 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -65,7 +65,7 @@ function mcl_buckets.register_liquid(def) _doc_items_usagehelp = def.usagehelp, _tt_help = def.tt_help, inventory_image = def.inventory_image, - stack_max = 16, + stack_max = 1, groups = def.groups, on_place = function(itemstack, user, pointed_thing) -- Must be pointing to node @@ -177,7 +177,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { liquids_pointable = true, inventory_image = "bucket.png", - stack_max = 16, + stack_max = 1, on_place = function(itemstack, user, pointed_thing) -- Must be pointing to node if pointed_thing.type ~= "node" then From 834dfcf9afdcb158960a29816d8b3f3b2f506521 Mon Sep 17 00:00:00 2001 From: Code-Sploit Date: Tue, 16 Mar 2021 13:05:19 +0000 Subject: [PATCH 05/16] Change Max Empty bucket stack back to 16 but keep Lava and Water max_stack. Reason: Wrong research --- mods/ITEMS/mcl_buckets/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 986dea5a4..523b10ef9 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -177,7 +177,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { liquids_pointable = true, inventory_image = "bucket.png", - stack_max = 1, + stack_max = 16, on_place = function(itemstack, user, pointed_thing) -- Must be pointing to node if pointed_thing.type ~= "node" then From f35f80d79a8942aa39fb3b68504c6808fe8d2161 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 16 Mar 2021 17:31:29 +0100 Subject: [PATCH 06/16] fix walkover --- mods/CORE/walkover/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/CORE/walkover/init.lua b/mods/CORE/walkover/init.lua index 4ef164303..f5507efbf 100644 --- a/mods/CORE/walkover/init.lua +++ b/mods/CORE/walkover/init.lua @@ -30,7 +30,7 @@ local timer = 0 minetest.register_globalstep(function(dtime) timer = timer + dtime; if timer >= 0.3 then - for _,player in ipairs(get_connected_players()) do + for _,player in pairs(get_connected_players()) do local pp = player:get_pos() pp.y = ceil(pp.y) local loc = vector_add(pp, {x=0,y=-1,z=0}) From 5d17a6b699613e2c0972a6df2011decbb6181109 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 16 Mar 2021 17:35:46 +0100 Subject: [PATCH 07/16] fix SO MANY pairs/ipairs --- mods/ENTITIES/mcl_burning/init.lua | 2 +- mods/ENTITIES/mcl_item_entity/init.lua | 4 ++-- mods/ENTITIES/mcl_mobs/api.lua | 6 +++--- mods/ENTITIES/mobs_mc/2_throwing.lua | 2 +- mods/ENVIRONMENT/mcl_weather/nether_dust.lua | 2 +- mods/HUD/mcl_hbarmor/init.lua | 2 +- mods/ITEMS/mcl_beds/functions.lua | 5 ++--- mods/ITEMS/mcl_bows/bow.lua | 2 +- mods/ITEMS/mcl_cauldrons/init.lua | 2 +- mods/ITEMS/mcl_clock/init.lua | 5 ++--- mods/ITEMS/mcl_compass/init.lua | 5 ++--- mods/ITEMS/mcl_doors/api_doors.lua | 2 +- 12 files changed, 18 insertions(+), 21 deletions(-) diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index 61ed12837..672036c78 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -22,7 +22,7 @@ minetest.register_entity("mcl_burning:fire", { }) minetest.register_globalstep(function(dtime) - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(minetest.get_connected_players()) do mcl_burning.tick(player, dtime) end end) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index e5863abbc..e73e29da6 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -54,14 +54,14 @@ local disable_physics = function(object, luaentity, ignore_check, reset_movement end minetest.register_globalstep(function(dtime) - for _,player in ipairs(minetest.get_connected_players()) do + for _,player in pairs(minetest.get_connected_players()) do if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then local pos = player:get_pos() local inv = player:get_inventory() local checkpos = {x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z} --magnet and collection - for _,object in ipairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.xp_radius_magnet)) do + for _,object in pairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.xp_radius_magnet)) do if not object:is_player() and vector.distance(checkpos, object:get_pos()) < item_drop_settings.radius_magnet and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and object:get_luaentity()._magnet_timer and (object:get_luaentity()._insta_collect or (object:get_luaentity().age > item_drop_settings.age)) then object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime local collected = false diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 0c8953079..e8ff728d4 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -226,7 +226,7 @@ local collision = function(self) local z = 0 local width = -self.collisionbox[1] + self.collisionbox[4] + 0.5 - for _,object in ipairs(minetest.get_objects_inside_radius(pos, width)) do + for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do if object:is_player() or (object:get_luaentity()._cmi_is_mob == true and object ~= self.object) then @@ -4576,9 +4576,9 @@ local timer = 0 minetest.register_globalstep(function(dtime) timer = timer + dtime if timer < 1 then return end - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(minetest.get_connected_players()) do local pos = player:get_pos() - for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 47)) do + for _, obj in pairs(minetest.get_objects_inside_radius(pos, 47)) do local lua = obj:get_luaentity() if lua and lua._cmi_is_mob then lua.lifetimer = math.max(20, lua.lifetimer) diff --git a/mods/ENTITIES/mobs_mc/2_throwing.lua b/mods/ENTITIES/mobs_mc/2_throwing.lua index fd55fa32c..23ae86d80 100644 --- a/mods/ENTITIES/mobs_mc/2_throwing.lua +++ b/mods/ENTITIES/mobs_mc/2_throwing.lua @@ -122,7 +122,7 @@ local arrows = { } local throwing_shoot_arrow = function(itemstack, player) - for _,arrow in ipairs(arrows) do + for _,arrow in pairs(arrows) do if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then if not minetest.is_creative_enabled(player:get_player_name()) then player:get_inventory():remove_item("main", arrow[1]) diff --git a/mods/ENVIRONMENT/mcl_weather/nether_dust.lua b/mods/ENVIRONMENT/mcl_weather/nether_dust.lua index 735676454..16cdc9487 100644 --- a/mods/ENVIRONMENT/mcl_weather/nether_dust.lua +++ b/mods/ENVIRONMENT/mcl_weather/nether_dust.lua @@ -27,7 +27,7 @@ minetest.register_globalstep(function(dtime) if timer < 0.7 then return end timer = 0 - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(minetest.get_connected_players()) do if not mcl_worlds.has_dust(player:get_pos()) then return false end diff --git a/mods/HUD/mcl_hbarmor/init.lua b/mods/HUD/mcl_hbarmor/init.lua index 57978359c..4434f5dad 100644 --- a/mods/HUD/mcl_hbarmor/init.lua +++ b/mods/HUD/mcl_hbarmor/init.lua @@ -118,7 +118,7 @@ minetest.register_globalstep(function(dtime) if main_timer > mcl_hbarmor.tick or timer > 4 then if minetest.settings:get_bool("enable_damage") then if main_timer > mcl_hbarmor.tick then main_timer = 0 end - for _,player in ipairs(minetest.get_connected_players()) do + for _,player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() if mcl_hbarmor.player_active[name] == true then local ret = mcl_hbarmor.get_armor(player) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 33c38c6cb..86f6a6852 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -36,7 +36,7 @@ local function check_in_beds(players) players = minetest.get_connected_players() end - for n, player in ipairs(players) do + for n, player in pairs(players) do local name = player:get_player_name() if not in_bed[name] then return false @@ -102,8 +102,7 @@ local function lay_down(player, pos, bed_pos, state, skip) -- No sleeping if monsters nearby. -- The exceptions above apply. -- Zombie pigmen only prevent sleep while they are hostle. - local objs = minetest.get_objects_inside_radius(bed_pos, 8) - for _, obj in ipairs(objs) do + for _, obj in pairs(minetest.get_objects_inside_radius(bed_pos, 8)) do if obj ~= nil and not obj:is_player() then local ent = obj:get_luaentity() local mobname = ent.name diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index 4ea2066b0..87820071d 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -341,7 +341,7 @@ controls.register_on_hold(function(player, key, time) end) minetest.register_globalstep(function(dtime) - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() local wielditem = player:get_wielded_item() local wieldindex = player:get_wield_index() diff --git a/mods/ITEMS/mcl_cauldrons/init.lua b/mods/ITEMS/mcl_cauldrons/init.lua index 5c8d93160..f4356d27b 100644 --- a/mods/ITEMS/mcl_cauldrons/init.lua +++ b/mods/ITEMS/mcl_cauldrons/init.lua @@ -131,7 +131,7 @@ minetest.register_abm({ interval = 0.5, chance = 1, action = function(pos, node) - for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 0.4)) do + for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.4)) do if mcl_burning.is_burning(obj) then mcl_burning.extinguish(obj) local new_group = minetest.get_item_group(node.name, "cauldron_filled") - 1 diff --git a/mods/ITEMS/mcl_clock/init.lua b/mods/ITEMS/mcl_clock/init.lua index 0532bf5f7..d53d75076 100644 --- a/mods/ITEMS/mcl_clock/init.lua +++ b/mods/ITEMS/mcl_clock/init.lua @@ -94,9 +94,8 @@ minetest.register_globalstep(function(dtime) watch.old_time = now - local players = minetest.get_connected_players() - for p, player in ipairs(players) do - for s, stack in ipairs(player:get_inventory():get_list("main")) do + for p, player in pairs(minetest.get_connected_players()) do + for s, stack in pairs(player:get_inventory():get_list("main")) do local dim = mcl_worlds.pos_to_dimension(player:get_pos()) local frame -- Clocks do not work in certain zones diff --git a/mods/ITEMS/mcl_compass/init.lua b/mods/ITEMS/mcl_compass/init.lua index b0cf5627e..f19bfe6a6 100644 --- a/mods/ITEMS/mcl_compass/init.lua +++ b/mods/ITEMS/mcl_compass/init.lua @@ -14,15 +14,14 @@ local random_frame = math.random(0, compass_frames-1) minetest.register_globalstep(function(dtime) random_timer = random_timer + dtime - local players = minetest.get_connected_players() if random_timer >= random_timer_trigger then random_frame = (random_frame + math.random(-1, 1)) % compass_frames random_timer = 0 end - for i,player in ipairs(players) do + for i,player in pairs(minetest.get_connected_players()) do local function has_compass(player) - for _,stack in ipairs(player:get_inventory():get_list("main")) do + for _,stack in pairs(player:get_inventory():get_list("main")) do if minetest.get_item_group(stack:get_name(), "compass") ~= 0 then return true end diff --git a/mods/ITEMS/mcl_doors/api_doors.lua b/mods/ITEMS/mcl_doors/api_doors.lua index 716fb22ec..f3dd0f469 100644 --- a/mods/ITEMS/mcl_doors/api_doors.lua +++ b/mods/ITEMS/mcl_doors/api_doors.lua @@ -4,7 +4,7 @@ local S = minetest.get_translator("mcl_doors") local function on_place_node(place_to, newnode, placer, oldnode, itemstack, pointed_thing) -- Run script hook - for _, callback in ipairs(minetest.registered_on_placenodes) do + for _, callback in pairs(minetest.registered_on_placenodes) do -- Deep-copy pos, node and pointed_thing because callback can modify them local place_to_copy = {x = place_to.x, y = place_to.y, z = place_to.z} local newnode_copy = From 8f30e223e2d45c4ead2237196c13446d6b9cb1e3 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 16 Mar 2021 17:39:06 +0100 Subject: [PATCH 08/16] I hate reverting something xD --- mods/ITEMS/REDSTONE/mesecons/actionqueue.lua | 2 +- mods/ITEMS/REDSTONE/mesecons/init.lua | 4 ++-- mods/ITEMS/mcl_core/functions.lua | 2 +- mods/ITEMS/mcl_enchanting/init.lua | 4 ++-- mods/ITEMS/mcl_end/chorus_plant.lua | 2 +- mods/ITEMS/mcl_hoppers/init.lua | 2 +- mods/ITEMS/mcl_mobspawners/init.lua | 2 +- mods/ITEMS/mcl_portals/portal_end.lua | 2 +- mods/ITEMS/mcl_portals/portal_nether.lua | 4 ++-- mods/ITEMS/mcl_potions/functions.lua | 2 +- mods/MAPGEN/tsm_railcorridors/init.lua | 2 +- mods/PLAYER/mcl_hunger/init.lua | 2 +- mods/PLAYER/mcl_player/init.lua | 2 +- mods/PLAYER/mcl_playerinfo/init.lua | 2 +- mods/PLAYER/mcl_playerplus/init.lua | 4 ++-- mods/PLAYER/wieldview/init.lua | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua b/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua index f3479ce59..eabe73d1a 100644 --- a/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua +++ b/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua @@ -22,7 +22,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior local toremove = nil -- Otherwise, add the action to the queue if overwritecheck then -- check if old action has to be overwritten / removed: - for i, ac in ipairs(mesecon.queue.actions) do + for i, ac in pairs(mesecon.queue.actions) do if(vector.equals(pos, ac.pos) and mesecon.cmpAny(overwritecheck, ac.owcheck)) then toremove = i diff --git a/mods/ITEMS/REDSTONE/mesecons/init.lua b/mods/ITEMS/REDSTONE/mesecons/init.lua index 93d299f06..18965287e 100644 --- a/mods/ITEMS/REDSTONE/mesecons/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons/init.lua @@ -75,10 +75,10 @@ mesecon.queue:add_function("receptor_on", function (pos, rules) rules = rules or mesecon.rules.default -- Call turnon on all linking positions - for _, rule in ipairs(mesecon.flattenrules(rules)) do + for _, rule in pairs(mesecon.flattenrules(rules)) do local np = vector.add(pos, rule) local rulenames = mesecon.rules_link_rule_all(pos, rule) - for _, rulename in ipairs(rulenames) do + for _, rulename in pairs(rulenames) do mesecon.turnon(np, rulename) end end diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 3d47336f3..0c25de94f 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -1378,7 +1378,7 @@ minetest.register_abm({ if not do_preserve then -- Drop stuff other than the node itself local itemstacks = minetest.get_node_drops(n0.name) - for _, itemname in ipairs(itemstacks) do + for _, itemname in pairs(itemstacks) do local p_drop = { x = p0.x - 0.5 + math.random(), y = p0.y - 0.5 + math.random(), diff --git a/mods/ITEMS/mcl_enchanting/init.lua b/mods/ITEMS/mcl_enchanting/init.lua index a53350a70..4918e3776 100644 --- a/mods/ITEMS/mcl_enchanting/init.lua +++ b/mods/ITEMS/mcl_enchanting/init.lua @@ -191,7 +191,7 @@ minetest.register_entity("mcl_enchanting:book", { local old_player_near = self._player_near local player_near = false local player - for _, obj in ipairs(minetest.get_objects_inside_radius(vector.subtract(self.object:get_pos(), mcl_enchanting.book_offset), 2.5)) do + for _, obj in pairs(minetest.get_objects_inside_radius(vector.subtract(self.object:get_pos(), mcl_enchanting.book_offset), 2.5)) do if obj:is_player() then player_near = true player = obj @@ -308,7 +308,7 @@ minetest.register_abm({ nodenames = "mcl_enchanting:table", action = function(pos) local playernames = {} - for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 15)) do + for _, obj in pairs(minetest.get_objects_inside_radius(pos, 15)) do if obj:is_player() then table.insert(playernames, obj:get_player_name()) end diff --git a/mods/ITEMS/mcl_end/chorus_plant.lua b/mods/ITEMS/mcl_end/chorus_plant.lua index 1363debf7..9622e618f 100644 --- a/mods/ITEMS/mcl_end/chorus_plant.lua +++ b/mods/ITEMS/mcl_end/chorus_plant.lua @@ -419,7 +419,7 @@ mcl_end.grow_chorus_plant_step = function(pos, node) end end - for _, f in ipairs(new_flowers) do + for _, f in pairs(new_flowers) do if age >= MAX_FLOWER_AGE then local nn = minetest.get_node(f).name if nn ~= "mcl_end:chorus_flower" and nn ~= "mcl_end:chorus_flower_dead" then diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index 52cb60874..3ff549e4f 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -349,7 +349,7 @@ minetest.register_abm({ local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - for _,object in ipairs(minetest.get_objects_inside_radius(pos, 2)) do + for _,object in pairs(minetest.get_objects_inside_radius(pos, 2)) do if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then -- Item must get sucked in when the item just TOUCHES the block above the hopper diff --git a/mods/ITEMS/mcl_mobspawners/init.lua b/mods/ITEMS/mcl_mobspawners/init.lua index f12c893d9..d95395642 100644 --- a/mods/ITEMS/mcl_mobspawners/init.lua +++ b/mods/ITEMS/mcl_mobspawners/init.lua @@ -17,7 +17,7 @@ local function get_mob_textures(mob) end local function find_doll(pos) - for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do + for _,obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do if not obj:is_player() then if obj ~= nil and obj:get_luaentity().name == "mcl_mobspawners:doll" then return obj diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index 045993530..0bc0ce57e 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -224,7 +224,7 @@ function mcl_portals.end_teleport(obj, pos) end function mcl_portals.end_portal_teleport(pos, node) - for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do + for _,obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do local lua_entity = obj:get_luaentity() --maikerumine added for objects to travel if obj:is_player() or lua_entity then local objpos = obj:get_pos() diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 32a24e092..ff9df2b4d 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -798,7 +798,7 @@ minetest.register_abm({ end end distance = vector.subtract(pos, distance) - for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 15)) do + for _, obj in pairs(minetest.get_objects_inside_radius(pos, 15)) do if obj:is_player() then minetest.add_particlespawner({ amount = node_particles_allowed_level + 1, @@ -818,7 +818,7 @@ minetest.register_abm({ }) end end - for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do --maikerumine added for objects to travel + for _, obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do --maikerumine added for objects to travel local lua_entity = obj:get_luaentity() --maikerumine added for objects to travel if (obj:is_player() or lua_entity) and prevent_portal_chatter(obj) then teleport(obj, pos) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index cd4939c2f..996637aa7 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -539,7 +539,7 @@ end) minetest.register_on_shutdown(function() -- save player effects on server shutdown - for _,player in ipairs(minetest.get_connected_players()) do + for _,player in pairs(minetest.get_connected_players()) do mcl_potions._save_player_effects(player) end diff --git a/mods/MAPGEN/tsm_railcorridors/init.lua b/mods/MAPGEN/tsm_railcorridors/init.lua index 982edcd0d..893f3d739 100644 --- a/mods/MAPGEN/tsm_railcorridors/init.lua +++ b/mods/MAPGEN/tsm_railcorridors/init.lua @@ -393,7 +393,7 @@ local function RecheckCartHack(params) local pos = params[1] local cart_id = params[2] -- Find cart - for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do + for _, obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do if obj ~= nil and obj:get_luaentity().name == cart_id then -- Cart found! We can now safely call the callback func. -- (calling it earlier has the danger of failing) diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index 01d74a80d..5ae45591c 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -142,7 +142,7 @@ minetest.register_globalstep(function(dtime) timer = timer + dtime if main_timer > mcl_hunger.HUD_TICK or timer > 0.5 then if main_timer > mcl_hunger.HUD_TICK then main_timer = 0 end - for _,player in ipairs(minetest.get_connected_players()) do + for _,player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() local h = tonumber(mcl_hunger.get_hunger(player)) diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index 449b062c5..9e6790ea0 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -148,7 +148,7 @@ local player_attached = mcl_player.player_attached -- Check each player and apply animations minetest.register_globalstep(function(dtime) - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() local model_name = player_model[name] local model = model_name and models[model_name] diff --git a/mods/PLAYER/mcl_playerinfo/init.lua b/mods/PLAYER/mcl_playerinfo/init.lua index 4c1454d95..5086f3195 100644 --- a/mods/PLAYER/mcl_playerinfo/init.lua +++ b/mods/PLAYER/mcl_playerinfo/init.lua @@ -52,7 +52,7 @@ minetest.register_globalstep(function(dtime) time = 0 -- check players - for _,player in ipairs(minetest.get_connected_players()) do + for _,player in pairs(minetest.get_connected_players()) do -- who am I? local name = player:get_player_name() diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index ab8487396..e376c0f0a 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -41,7 +41,7 @@ minetest.register_globalstep(function(dtime) -- Update jump status immediately since we need this info in real time. -- WARNING: This section is HACKY as hell since it is all just based on heuristics. - for _,player in ipairs(get_connected_players()) do + for _,player in pairs(get_connected_players()) do local controls = player:get_player_control() name = player:get_player_name() @@ -173,7 +173,7 @@ minetest.register_globalstep(function(dtime) time = 0 -- check players - for _,player in ipairs(get_connected_players()) do + for _,player in pairs(get_connected_players()) do -- who am I? local name = player:get_player_name() diff --git a/mods/PLAYER/wieldview/init.lua b/mods/PLAYER/wieldview/init.lua index 4514ca5e6..dea44b2a2 100644 --- a/mods/PLAYER/wieldview/init.lua +++ b/mods/PLAYER/wieldview/init.lua @@ -78,7 +78,7 @@ minetest.register_on_joinplayer(function(player) end) minetest.register_globalstep(function() - for _,player in ipairs(minetest.get_connected_players()) do + for _,player in pairs(minetest.get_connected_players()) do wieldview:update_wielded_item(player) end end) From 6645c4cb304ad655c56f97b835424f6a5d89dd21 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 16 Mar 2021 17:43:32 +0100 Subject: [PATCH 09/16] Really --- mods/ENTITIES/mcl_boats/init.lua | 4 ++-- mods/ENTITIES/mcl_burning/api.lua | 2 +- mods/ENTITIES/mcl_item_entity/init.lua | 2 +- mods/ENVIRONMENT/mcl_weather/rain.lua | 8 +++++--- mods/ENVIRONMENT/mcl_weather/skycolor.lua | 2 +- mods/ENVIRONMENT/mcl_weather/snow.lua | 6 ++++-- mods/ENVIRONMENT/mcl_weather/thunder.lua | 4 +++- mods/ITEMS/mcl_chests/init.lua | 2 +- mods/ITEMS/mcl_compass/init.lua | 2 +- 9 files changed, 19 insertions(+), 13 deletions(-) diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 168e76b70..c181a193b 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -223,7 +223,7 @@ function boat.on_step(self, dtime, moveresult) self._regen_timer = regen_timer if moveresult and moveresult.collides then - for _, collision in ipairs(moveresult.collisions) do + for _, collision in pairs(moveresult.collisions) do local pos = collision.node_pos if collision.type == "node" and minetest.get_item_group(minetest.get_node(pos).name, "dig_by_boat") > 0 then minetest.dig_node(pos) @@ -305,7 +305,7 @@ function boat.on_step(self, dtime, moveresult) self._animation = 0 end - for _, obj in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 1.3)) do + for _, obj in pairs(minetest.get_objects_inside_radius(self.object:get_pos(), 1.3)) do local entity = obj:get_luaentity() if entity and entity._cmi_is_mob then attach_object(self, obj) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index 1a3365d14..723b29a8b 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -267,7 +267,7 @@ function mcl_burning.fire_entity_step(self, dtime) if not parent or not mcl_burning.is_burning(parent) then do_remove = true else - for _, other in ipairs(minetest.get_objects_inside_radius(obj:get_pos(), 0)) do + for _, other in pairs(minetest.get_objects_inside_radius(obj:get_pos(), 0)) do local luaentity = obj:get_luaentity() if luaentity and luaentity.name == "mcl_burning:fire" and not luaentity.doing_step and not luaentity.removed then do_remove = true diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index e73e29da6..7546bd01c 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -785,7 +785,7 @@ minetest.register_entity(":__builtin:item", { if self.physical_state then local own_stack = ItemStack(self.object:get_luaentity().itemstring) -- Merge with close entities of the same item - for _, object in ipairs(minetest.get_objects_inside_radius(p, 0.8)) do + for _, object in pairs(minetest.get_objects_inside_radius(p, 0.8)) do local obj = object:get_luaentity() if obj and obj.name == "__builtin:item" and obj.physical_state == false then diff --git a/mods/ENVIRONMENT/mcl_weather/rain.lua b/mods/ENVIRONMENT/mcl_weather/rain.lua index 0afbb5539..d8425784a 100644 --- a/mods/ENVIRONMENT/mcl_weather/rain.lua +++ b/mods/ENVIRONMENT/mcl_weather/rain.lua @@ -1,6 +1,8 @@ local PARTICLES_COUNT_RAIN = 30 local PARTICLES_COUNT_THUNDER = 45 +local get_connected_players = minetest.get_connected_players + mcl_weather.rain = { -- max rain particles created at time particles_count = PARTICLES_COUNT_RAIN, @@ -36,7 +38,7 @@ mcl_weather.rain.set_sky_box = function() {r=85, g=86, b=98}, {r=0, g=0, b=0}}) mcl_weather.skycolor.active = true - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(get_connected_players()) do player:set_clouds({color="#5D5D5FE8"}) end end @@ -154,7 +156,7 @@ mcl_weather.rain.clear = function() mcl_weather.rain.init_done = false mcl_weather.rain.set_particles_mode("rain") mcl_weather.skycolor.remove_layer("weather-pack-rain-sky") - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(get_connected_players()) do mcl_weather.rain.remove_sound(player) mcl_weather.rain.remove_player(player) end @@ -176,7 +178,7 @@ mcl_weather.rain.make_weather = function() mcl_weather.rain.init_done = true end - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(get_connected_players()) do if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then mcl_weather.rain.remove_sound(player) return false diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index 6cc94b5c1..061634fcb 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -43,7 +43,7 @@ mcl_weather.skycolor = { -- Remove layer from colors table remove_layer = function(layer_name) - for k, name in ipairs(mcl_weather.skycolor.layer_names) do + for k, name in pairs(mcl_weather.skycolor.layer_names) do if name == layer_name then table.remove(mcl_weather.skycolor.layer_names, k) mcl_weather.skycolor.force_update = true diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index afe23c150..3a0c539e3 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -1,3 +1,5 @@ +local get_connected_players = minetest.get_connected_players + mcl_weather.snow = {} mcl_weather.snow.particles_count = 15 @@ -37,7 +39,7 @@ mcl_weather.snow.set_sky_box = function() {r=85, g=86, b=86}, {r=0, g=0, b=0}}) mcl_weather.skycolor.active = true - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(get_connected_players()) do player:set_clouds({color="#ADADADE8"}) end mcl_weather.skycolor.active = true @@ -71,7 +73,7 @@ minetest.register_globalstep(function(dtime) mcl_weather.snow.init_done = true end - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(get_connected_players()) do if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then return false end diff --git a/mods/ENVIRONMENT/mcl_weather/thunder.lua b/mods/ENVIRONMENT/mcl_weather/thunder.lua index 7da3308db..ece673170 100644 --- a/mods/ENVIRONMENT/mcl_weather/thunder.lua +++ b/mods/ENVIRONMENT/mcl_weather/thunder.lua @@ -1,3 +1,5 @@ +local get_connected_players = minetest.get_connected_players + -- turn off lightning mod 'auto mode' lightning.auto = false @@ -25,7 +27,7 @@ minetest.register_globalstep(function(dtime) {r=40, g=40, b=40}, {r=0, g=0, b=0}}) mcl_weather.skycolor.active = true - for _, player in ipairs(minetest.get_connected_players()) do + for _, player in pairs(get_connected_players()) do player:set_clouds({color="#3D3D3FE8"}) end mcl_weather.thunder.init_done = true diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index 852a47fec..42e39f520 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -118,7 +118,7 @@ local function get_entity_pos(pos, dir, double) end local function find_entity(pos) - for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 0)) do + for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0)) do local luaentity = obj:get_luaentity() if luaentity and luaentity.name == "mcl_chests:chest" then return luaentity diff --git a/mods/ITEMS/mcl_compass/init.lua b/mods/ITEMS/mcl_compass/init.lua index f19bfe6a6..f15459303 100644 --- a/mods/ITEMS/mcl_compass/init.lua +++ b/mods/ITEMS/mcl_compass/init.lua @@ -52,7 +52,7 @@ minetest.register_globalstep(function(dtime) compass_image = math.floor((angle_relative/11.25) + 0.5) % compass_frames end - for j,stack in ipairs(player:get_inventory():get_list("main")) do + for j,stack in pairs(player:get_inventory():get_list("main")) do if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then local itemname = "mcl_compass:"..compass_image From 33c589369f6079e1547e02d8aa7665b3be653cd1 Mon Sep 17 00:00:00 2001 From: epCode Date: Tue, 16 Mar 2021 15:22:36 -0700 Subject: [PATCH 10/16] Make arrows stick into players. --- mods/ITEMS/mcl_bows/arrow.lua | 92 +++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index efa465ddf..2ad92d936 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -15,6 +15,26 @@ local dir_to_pitch = function(dir) return -math.atan2(-dir.y, xz) end +local random_arrow_positions = function(positions, placement) + local min = 0 + local max = 0 + if positions == 'x' then + min = -4 + max = 4 + elseif positions == 'y' then + min = 0 + max = 10 + end + if placement == 'front' and positions == 'z' then + min = 3 + max = 3 + elseif placement == 'back' and positions == 'z' then + min = -3 + max = -3 + end + return math.random(max, min) +end + local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") local mod_button = minetest.get_modpath("mesecons_button") @@ -101,6 +121,14 @@ ARROW_ENTITY.on_step = function(self, dtime) dpos = vector.round(dpos) local node = minetest.get_node(dpos) + if self.object:get_attach() ~= nil and self.object:get_attach(parent):get_hp() < 1 then + self.object:remove() + end + + if self.object:get_attach() and not self.object:get_attach(parent) then + self.object:remove() + end + if self._stuck then self._stucktimer = self._stucktimer + dtime self._stuckrechecktimer = self._stuckrechecktimer + dtime @@ -146,7 +174,7 @@ ARROW_ENTITY.on_step = function(self, dtime) -- Check for object "collision". Done every tick (hopefully this is not too stressing) else - if self._damage >= 9 then + if self._damage >= 9 and self._in_player == false then minetest.add_particlespawner({ amount = 1, time = .001, @@ -230,19 +258,60 @@ ARROW_ENTITY.on_step = function(self, dtime) if obj:is_player() and rawget(_G, "armor") and armor.last_damage_types then armor.last_damage_types[obj:get_player_name()] = "projectile" end - damage_particles(self.object:get_pos(), self._is_critical) + if self._in_player == false then + damage_particles(self.object:get_pos(), self._is_critical) + end if mcl_burning.is_burning(self.object) then mcl_burning.set_on_fire(obj, 5) end - obj:punch(self.object, 1.0, { - full_punch_interval=1.0, - damage_groups={fleshy=self._damage}, - }, self.object:get_velocity()) + if self._in_player == false then + obj:punch(self.object, 1.0, { + full_punch_interval=1.0, + damage_groups={fleshy=self._damage}, + }, self.object:get_velocity()) + if obj:is_player() then + local placement = '' + self._placement = math.random(1, 2) + if self._placement == 1 then + placement = 'front' + else + placement = 'back' + end + self._in_player = true + if self._placement == 2 then + self._rotation_station = 90 + else + self._rotation_station = -90 + end + self._y_position = random_arrow_positions('y', placement) + self._x_position = random_arrow_positions('x', placement) + if self._y_position > 6 and self._x_position < 2 and self._x_position > -2 then + self._attach_parent = 'Head' + self._y_position = self._y_position - 6 + elseif self._x_position > 2 then + self._attach_parent = 'Arm_Right' + self._y_position = self._y_position - 3 + self._x_position = self._x_position - 2 + elseif self._x_position < -2 then + self._attach_parent = 'Arm_Left' + self._y_position = self._y_position - 3 + self._x_position = self._x_position + 2 + else + self._attach_parent = 'Body' + end + self._z_rotation = math.random(30, -30) + self._y_rotation = math.random(30, -30) + self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions('z', placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation}) + minetest.after(60, function() + self.object:remove() + end) + end + end end if is_player then - if self._shooter and self._shooter:is_player() then + if self._shooter and self._shooter:is_player() and self._in_player == false then -- “Ding” sound for hitting another player minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter:get_player_name()}, true) end @@ -259,10 +328,14 @@ ARROW_ENTITY.on_step = function(self, dtime) end end end - minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true) + if self._in_player == false then + minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true) + end end mcl_burning.extinguish(self.object) - self.object:remove() + if not obj:is_player() then + self.object:remove() + end return end end @@ -389,6 +462,7 @@ ARROW_ENTITY.get_staticdata = function(self) end ARROW_ENTITY.on_activate = function(self, staticdata, dtime_s) + self._in_player = false local data = minetest.deserialize(staticdata) if data then self._stuck = data.stuck From 08054312316cc8b3429dda9919ce51e3f780f427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Tue, 16 Mar 2021 23:48:11 +0100 Subject: [PATCH 11/16] Fix #1293 --- mods/ENTITIES/mcl_mobs/api.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index e8ff728d4..7d93f2bad 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1047,8 +1047,10 @@ local do_env_damage = function(self) end end + local sunlight = minetest.get_natural_light(pos, self.time_of_day) + -- bright light harms mob - if self.light_damage ~= 0 and (minetest.get_node_light(pos) or 0) > 12 then + if self.light_damage ~= 0 and (sunlight or 0) > 12 then if deal_light_damage(self, pos, self.light_damage) then return true end @@ -1057,7 +1059,7 @@ local do_env_damage = function(self) if mod_worlds then _, dim = mcl_worlds.y_to_layer(pos.y) end - if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (minetest.get_node_light(pos) or 0) >= minetest.LIGHT_MAX and dim == "overworld" then + if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then if self.ignited_by_sunlight then mcl_burning.set_on_fire(self.object, 10) else From 86f2d639f9dba733d5241a1c3649dbd251dfed5c Mon Sep 17 00:00:00 2001 From: epCode Date: Tue, 16 Mar 2021 16:01:47 -0700 Subject: [PATCH 12/16] Make arrows remove after a longer period --- mods/ITEMS/mcl_bows/arrow.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 2ad92d936..5f2713fd0 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -302,7 +302,7 @@ ARROW_ENTITY.on_step = function(self, dtime) self._z_rotation = math.random(30, -30) self._y_rotation = math.random(30, -30) self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions('z', placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation}) - minetest.after(60, function() + minetest.after(150, function() self.object:remove() end) end From b82da0559008297a9668f28cd2c72726af666f22 Mon Sep 17 00:00:00 2001 From: epCode Date: Tue, 16 Mar 2021 19:18:07 -0700 Subject: [PATCH 13/16] Fix #1277 --- mods/ITEMS/mcl_armor/armor.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_armor/armor.lua b/mods/ITEMS/mcl_armor/armor.lua index a879f7240..ec06f19ee 100644 --- a/mods/ITEMS/mcl_armor/armor.lua +++ b/mods/ITEMS/mcl_armor/armor.lua @@ -149,8 +149,8 @@ armor.set_player_armor = function(self, player) if level then local texture = def.texture or item:gsub("%:", "_") local enchanted_addition = (mcl_enchanting.is_enchanted(item) and mcl_enchanting.overlay or "") - table.insert(textures, "("..texture..".png"..enchanted_addition..")") - preview = "(player.png^[opacity:0^"..texture.."_preview.png"..enchanted_addition..")"..(preview and "^"..preview or "") + table.insert(textures, texture..".png"..enchanted_addition) + preview = "player.png^[opacity:0^"..texture.."_preview.png"..enchanted_addition..""..(preview and "^"..preview or "") armor_level = armor_level + level items = items + 1 mcl_armor_points = mcl_armor_points + (def.groups["mcl_armor_points"] or 0) From 6c49c4669726c7b43b27c1948c1fd44931ac5a57 Mon Sep 17 00:00:00 2001 From: ZeDique la Ruleta Date: Tue, 16 Mar 2021 23:10:34 -0400 Subject: [PATCH 14/16] Chests now open 90 degrees, regardless - Removed 'block' check with chests, they will always open 90 degrees regardless of what's behind them --- mods/ITEMS/mcl_chests/init.lua | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index 42e39f520..fb8c59f28 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -11,10 +11,8 @@ local entity_animations = { }, chest = { speed = 25, - open = {x = 0, y = 10}, - open_partly = {x = 0, y = 7}, - close = {x = 10, y = 20}, - close_partly = {x = 13, y = 20}, + open = {x = 0, y = 7}, + close = {x = 13, y = 20}, } } @@ -34,15 +32,14 @@ minetest.register_entity("mcl_chests:chest", { self.object:set_animation(anim, anim_table.speed, 0, false) end, - open = function(self, playername, partly) + open = function(self, playername) self.players[playername] = true if not self.is_open then - self:set_animation(partly and "open_partly" or "open") + self:set_animation("open") minetest.sound_play(self.sound_prefix .. "_open", { pos = self.node_pos, }) self.is_open = true - self.opened_partly = partly end end, @@ -53,12 +50,11 @@ minetest.register_entity("mcl_chests:chest", { for _ in pairs(playerlist) do return end - self:set_animation(self.opened_partly and "close_partly" or "close") + self:set_animation("close") minetest.sound_play(self.sound_prefix .. "_close", { pos = self.node_pos, }) self.is_open = false - self.opened_partly = false end end, @@ -179,8 +175,7 @@ local player_chest_open = function(player, pos, node_name, textures, param2, dou open_chests[name] = {pos = pos, node_name = node_name, textures = textures, param2 = param2, double = double, sound = sound, mesh = mesh, shulker = shulker} if animate_chests then local dir = minetest.facedir_to_dir(param2) - local blocked = not shulker and (back_is_blocked(pos, dir) or double and back_is_blocked(mcl_util.get_double_container_neighbor_pos(pos, param2, node_name:sub(-4)), dir)) - find_or_create_entity(pos, node_name, textures, param2, double, sound, mesh, shulker and "shulker" or "chest", dir):open(name, blocked) + find_or_create_entity(pos, node_name, textures, param2, double, sound, mesh, shulker and "shulker" or "chest", dir):open(name) end end From 7441f0269b199bde790606f45734949537eb9a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Wed, 17 Mar 2021 09:09:13 +0100 Subject: [PATCH 15/16] Use get_node_light for sunlight in 5.3 Avoids servers running 5.3 crashing. --- mods/ENTITIES/mcl_mobs/api.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 7d93f2bad..3b929a119 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1047,7 +1047,10 @@ local do_env_damage = function(self) end end - local sunlight = minetest.get_natural_light(pos, self.time_of_day) + -- Use get_node_light for Minetest version 5.3 where get_natural_light + -- does not exist yet. + local get_light = minetest.get_natural_light or minetest.get_node_light + local sunlight = get_light(pos, self.time_of_day) -- bright light harms mob if self.light_damage ~= 0 and (sunlight or 0) > 12 then From ae18ca7602183a15f02cd6aa2f516be114d1f1b5 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 17 Mar 2021 10:48:59 +0100 Subject: [PATCH 16/16] fix wrong value in walkover --- mods/CORE/walkover/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/CORE/walkover/init.lua b/mods/CORE/walkover/init.lua index f5507efbf..220157c8b 100644 --- a/mods/CORE/walkover/init.lua +++ b/mods/CORE/walkover/init.lua @@ -22,7 +22,7 @@ minetest.register_on_mods_loaded(function() end end for _,func in ipairs(walkover.registered_globals) do --cache registered globals - table.insert(registered_globals, value) + table.insert(registered_globals, func) end end)