From 1a58b0c510f36eb24dbb3c2804c621bbaf6279f8 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 16 Apr 2021 13:35:03 +0200 Subject: [PATCH 1/4] fix many codestyle issues --- mods/HELP/doc/doc_identifier/init.lua | 4 ++-- mods/HELP/doc/doc_items/init.lua | 3 +-- mods/HELP/mcl_craftguide/init.lua | 8 +++----- mods/HELP/mcl_doc/init.lua | 4 +--- mods/ITEMS/mcl_tools/init.lua | 2 +- mods/ITEMS/mcl_walls/init.lua | 8 ++++---- mods/ITEMS/screwdriver/init.lua | 1 - mods/ITEMS/xpanes/init.lua | 3 +-- mods/MAPGEN/mcl_biomes/init.lua | 4 ++-- mods/MAPGEN/mcl_villages/foundation.lua | 12 ++++++------ mods/MAPGEN/mcl_villages/init.lua | 4 ++-- mods/MAPGEN/mcl_villages/paths.lua | 14 +++++++------- mods/MAPGEN/mcl_villages/utils.lua | 16 ++++++++-------- 13 files changed, 38 insertions(+), 45 deletions(-) diff --git a/mods/HELP/doc/doc_identifier/init.lua b/mods/HELP/doc/doc_identifier/init.lua index 2e041ae2e..a3a35e2fa 100644 --- a/mods/HELP/doc/doc_identifier/init.lua +++ b/mods/HELP/doc/doc_identifier/init.lua @@ -67,7 +67,7 @@ doc_identifier.identify = function(itemstack, user, pointed_thing) local pos = pointed_thing.under local node = minetest.get_node(pos) if minetest.registered_nodes[node.name] ~= nil then - local nodedef = minetest.registered_nodes[node.name] + --local nodedef = minetest.registered_nodes[node.name] if(node.name == "ignore") then show_message(username, "error_ignore") elseif doc.entry_exists("nodes", node.name) then @@ -198,7 +198,7 @@ minetest.register_craft({ if minetest.get_modpath("mcl_core") ~= nil then minetest.register_craft({ output = "doc_identifier:identifier_solid", - recipe = { { "mcl_core:glass" }, + recipe = { { "mcl_core:glass" }, { "group:stick" } } }) end diff --git a/mods/HELP/doc/doc_items/init.lua b/mods/HELP/doc/doc_items/init.lua index b0be3e12d..ec4da620e 100644 --- a/mods/HELP/doc/doc_items/init.lua +++ b/mods/HELP/doc/doc_items/init.lua @@ -907,7 +907,7 @@ doc.add_category("nodes", { -- Do some cleanup of the probability table if max == 1 or max == nil then -- Sort by rarity - local comp = function(p1, p2) + local comp = function(p1, p2) return p1.rarity < p2.rarity end table.sort(probtables, comp) @@ -1269,7 +1269,6 @@ local function gather_descs() if type(def._doc_items_hidden) == "boolean" then hidden = def._doc_items_hidden end - local custom_image name = scrub_newlines(name) local infotable = { name = name, diff --git a/mods/HELP/mcl_craftguide/init.lua b/mods/HELP/mcl_craftguide/init.lua index 829fc4181..e10513bc3 100644 --- a/mods/HELP/mcl_craftguide/init.lua +++ b/mods/HELP/mcl_craftguide/init.lua @@ -33,7 +33,6 @@ local fmt, find, gmatch, match, sub, split, lower = local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil local pairs, next, unpack = pairs, next, unpack -local vec_add, vec_mul = vector.add, vector.multiply local DEFAULT_SIZE = 10 local MIN_LIMIT, MAX_LIMIT = 10, 12 @@ -1001,7 +1000,7 @@ else end end) - local function on_use(user) + --[[local function on_use(user) local name = user:get_player_name() if next(recipe_filters) then @@ -1011,7 +1010,7 @@ else end show_formspec(name, "mcl_craftguide", make_formspec(name)) - end + end]] end @@ -1098,7 +1097,6 @@ if progressive_mode then local name = player:get_player_name() init_data(name) local meta = player:get_meta() - local name = player:get_player_name() local data = player_data[name] data.inv_items = deserialize(meta:get_string("inv_items")) or {} @@ -1144,7 +1142,7 @@ else end function mcl_craftguide.show(name) - local player = minetest.get_player_by_name(name) + local player = get_player_by_name(name) if next(recipe_filters) then local data = player_data[name] data.items_raw = get_filtered_items(player) diff --git a/mods/HELP/mcl_doc/init.lua b/mods/HELP/mcl_doc/init.lua index 6948aed04..d926550f8 100644 --- a/mods/HELP/mcl_doc/init.lua +++ b/mods/HELP/mcl_doc/init.lua @@ -62,7 +62,6 @@ end) -- nodes which have flower placement rules doc.sub.items.register_factoid("nodes", "groups", function(itemstring, def) - local datastring = "" if def.groups.place_flowerlike == 1 then return S("This plant can only grow on grass blocks and dirt. To survive, it needs to have an unobstructed view to the sky above or be exposed to a light level of 8 or higher.") elseif def.groups.place_flowerlike == 2 then @@ -130,7 +129,7 @@ end) -- Armor doc.sub.items.register_factoid(nil, "use", function(itemstring, def) - local def = minetest.registered_items[itemstring] + --local def = minetest.registered_items[itemstring] local s = "" local head = minetest.get_item_group(itemstring, "armor_head") local torso = minetest.get_item_group(itemstring, "armor_torso") @@ -173,7 +172,6 @@ end) doc.sub.items.register_factoid(nil, "groups", function(itemstring, def) if def._repair_material then local mdef = minetest.registered_items[def._repair_material] - local desc if mdef and mdef.description and mdef.description ~= "" then return S("This item can be repaired at an anvil with: @1.", mdef.description) elseif def._repair_material == "group:wood" then diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 2d804b9bc..fa5352c2c 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -233,7 +233,7 @@ if minetest.get_modpath("mcl_farming") then local wear = mcl_autogroup.get_wear(toolname, "shearsy") itemstack:add_wear(wear) end - minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true) + minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true) local dir = vector.subtract(pointed_thing.under, pointed_thing.above) local param2 = minetest.dir_to_facedir(dir) minetest.swap_node(pointed_thing.under, {name="mcl_farming:pumpkin_face", param2 = param2}) diff --git a/mods/ITEMS/mcl_walls/init.lua b/mods/ITEMS/mcl_walls/init.lua index 36694c6f3..de1b1760f 100644 --- a/mods/ITEMS/mcl_walls/init.lua +++ b/mods/ITEMS/mcl_walls/init.lua @@ -151,7 +151,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory minetest.register_node(nodename.."_"..i, { collision_box = { - type = 'fixed', + type = 'fixed', fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, drawtype = "nodebox", @@ -180,7 +180,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory minetest.register_node(nodename.."_16", { drawtype = "nodebox", collision_box = { - type = 'fixed', + type = 'fixed', fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, tiles = tiles, @@ -206,7 +206,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory minetest.register_node(nodename.."_21", { drawtype = "nodebox", collision_box = { - type = 'fixed', + type = 'fixed', fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, tiles = tiles, @@ -247,7 +247,7 @@ function mcl_walls.register_wall(nodename, description, source, tiles, inventory fixed = pillar }, collision_box = { - type = 'fixed', + type = 'fixed', fixed = {-4/16, -0.5, -4/16, 4/16, 1, 4/16} }, collisionbox = {-0.2, 0, -0.2, 0.2, 1.4, 0.2}, diff --git a/mods/ITEMS/screwdriver/init.lua b/mods/ITEMS/screwdriver/init.lua index e6aedf19c..942bccf38 100644 --- a/mods/ITEMS/screwdriver/init.lua +++ b/mods/ITEMS/screwdriver/init.lua @@ -157,7 +157,6 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses) if should_rotate and new_param2 ~= node.param2 then node.param2 = new_param2 minetest.swap_node(pos, node) - minetest.check_for_falling(pos) if ndef.after_rotate then ndef.after_rotate(vector.new(pos)) diff --git a/mods/ITEMS/xpanes/init.lua b/mods/ITEMS/xpanes/init.lua index e1914a9ff..b7faffb3b 100644 --- a/mods/ITEMS/xpanes/init.lua +++ b/mods/ITEMS/xpanes/init.lua @@ -142,7 +142,7 @@ function xpanes.register_pane(name, def) tiles = {def.textures[3], def.textures[2], def.textures[1]}, use_texture_alpha = def.use_texture_alpha, groups = groups, - drop = "xpanes:" .. name .. "_flat", + drop = drop, sounds = def.sounds, node_box = { type = "connected", @@ -153,7 +153,6 @@ function xpanes.register_pane(name, def) connect_right = {{1/32, -1/2, -1/32, 1/2, 1/2, 1/32}}, }, connects_to = {"group:pane", "group:stone", "group:glass", "group:wood", "group:tree"}, - drop = drop, _mcl_blast_resistance = def._mcl_blast_resistance, _mcl_hardness = def._mcl_hardness, _mcl_silk_touch_drop = def._mcl_silk_touch_drop and {"xpanes:" .. name .. "_flat"}, diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index 5f0510344..f583d87b6 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -3906,7 +3906,7 @@ end -- Decorations in non-Overworld dimensions local function register_dimension_decorations() --[[ NETHER ]] - -- TODO: Nether + -- TODO: Nether --[[ THE END ]] @@ -3973,7 +3973,7 @@ if mg_name ~= "singlenode" then if deco_id_chorus_plant then mcl_mapgen_core.register_generator("chorus_grow", nil, function(minp, maxp, blockseed) local gennotify = minetest.get_mapgen_object("gennotify") - local poslist = {} + --local poslist = {} for _, pos in ipairs(gennotify["decoration#"..deco_id_chorus_plant] or {}) do local realpos = { x = pos.x, y = pos.y + 1, z = pos.z } mcl_end.grow_chorus_plant(realpos) diff --git a/mods/MAPGEN/mcl_villages/foundation.lua b/mods/MAPGEN/mcl_villages/foundation.lua index 038a2f202..71c5cfdda 100644 --- a/mods/MAPGEN/mcl_villages/foundation.lua +++ b/mods/MAPGEN/mcl_villages/foundation.lua @@ -9,15 +9,15 @@ function settlements.ground(pos, pr) -- role model: Wendelsteinkircherl, Brannen while true do cnt = cnt+1 if cnt > 20 then break end - if cnt>pr:next(2,4) then - mat = "mcl_core:stone" + if cnt>pr:next(2,4) then + mat = "mcl_core:stone" end minetest.swap_node(p2, {name=mat}) p2.y = p2.y-1 end end ------------------------------------------------------------------------------- --- function clear space above baseplate +-- function clear space above baseplate ------------------------------------------------------------------------------- function settlements.terraform(settlement_info, pr) local fheight, fwidth, fdepth, schematic_data @@ -30,7 +30,7 @@ function settlements.terraform(settlement_info, pr) break end end - local pos = settlement_info[i]["pos"] + local pos = settlement_info[i]["pos"] if settlement_info[i]["rotat"] == "0" or settlement_info[i]["rotat"] == "180" then fwidth = schematic_data["hwidth"] fdepth = schematic_data["hdepth"] @@ -54,9 +54,9 @@ function settlements.terraform(settlement_info, pr) -- local p = {x=pos.x+xi, y=pos.y+yi, z=pos.z+zi} -- local node = mcl_vars.get_node(p) -- if node and node.name ~= "air" then --- minetest.swap_node(p,{name="air"}) +-- minetest.swap_node(p,{name="air"}) -- end - minetest.swap_node({x=pos.x+xi, y=pos.y+yi, z=pos.z+zi},{name="air"}) + minetest.swap_node({x=pos.x+xi, y=pos.y+yi, z=pos.z+zi},{name="air"}) end end end diff --git a/mods/MAPGEN/mcl_villages/init.lua b/mods/MAPGEN/mcl_villages/init.lua index 19de10b98..ccc3f585d 100644 --- a/mods/MAPGEN/mcl_villages/init.lua +++ b/mods/MAPGEN/mcl_villages/init.lua @@ -46,7 +46,7 @@ if minetest.get_modpath("mobs_mc") ~= nil then 7, --active_object_count 31000, --max_height nil) --day_toggle -end +end --]] -- @@ -85,7 +85,7 @@ if mg_name ~= "singlenode" then if blockseed % 77 ~= 17 then return end -- needed for manual and automated settlement building -- don't build settlements on (too) uneven terrain - local heightmap = minetest.get_mapgen_object("heightmap") + --local heightmap = minetest.get_mapgen_object("heightmap") local height_difference = settlements.evaluate_heightmap() if height_difference > max_height_difference then return end diff --git a/mods/MAPGEN/mcl_villages/paths.lua b/mods/MAPGEN/mcl_villages/paths.lua index 4973171a6..63f2ba146 100644 --- a/mods/MAPGEN/mcl_villages/paths.lua +++ b/mods/MAPGEN/mcl_villages/paths.lua @@ -6,10 +6,10 @@ function settlements.paths(settlement_info) local end_point local distance --for k,v in pairs(settlement_info) do - starting_point = settlement_info[1]["pos"] + starting_point = settlement_info[1]["pos"] for o,p in pairs(settlement_info) do - end_point = settlement_info[o]["pos"] + end_point = settlement_info[o]["pos"] if starting_point ~= end_point then -- loop until end_point is reched (distance == 0) @@ -40,35 +40,35 @@ function settlements.paths(settlement_info) -- evaluate which pos is closer to the end_point if dist_north_p_to_end <= dist_south_p_to_end and dist_north_p_to_end <= dist_west_p_to_end and - dist_north_p_to_end <= dist_east_p_to_end + dist_north_p_to_end <= dist_east_p_to_end then starting_point = north_p distance = dist_north_p_to_end elseif dist_south_p_to_end <= dist_north_p_to_end and dist_south_p_to_end <= dist_west_p_to_end and - dist_south_p_to_end <= dist_east_p_to_end + dist_south_p_to_end <= dist_east_p_to_end then starting_point = south_p distance = dist_south_p_to_end elseif dist_west_p_to_end <= dist_north_p_to_end and dist_west_p_to_end <= dist_south_p_to_end and - dist_west_p_to_end <= dist_east_p_to_end + dist_west_p_to_end <= dist_east_p_to_end then starting_point = west_p distance = dist_west_p_to_end elseif dist_east_p_to_end <= dist_north_p_to_end and dist_east_p_to_end <= dist_south_p_to_end and - dist_east_p_to_end <= dist_west_p_to_end + dist_east_p_to_end <= dist_west_p_to_end then starting_point = east_p distance = dist_east_p_to_end end -- find surface of new starting point local surface_point, surface_mat = settlements.find_surface(starting_point) - -- replace surface node with mcl_core:grass_path + -- replace surface node with mcl_core:grass_path if surface_point then if surface_mat == "mcl_core:sand" or surface_mat == "mcl_core:redsand" then diff --git a/mods/MAPGEN/mcl_villages/utils.lua b/mods/MAPGEN/mcl_villages/utils.lua index d7617541d..993de11c4 100644 --- a/mods/MAPGEN/mcl_villages/utils.lua +++ b/mods/MAPGEN/mcl_villages/utils.lua @@ -126,7 +126,7 @@ function settlements.fill_chest(pos, pr) -- fill chest local inv = minetest.get_inventory( {type="node", pos=pos} ) - local function get_treasures(pr) + local function get_treasures(prand) local loottable = {{ stacks_min = 3, stacks_max = 8, @@ -150,7 +150,7 @@ function settlements.fill_chest(pos, pr) { itemstring = "mobs_mc:diamond_horse_armor", weight = 1 }, } }} - local items = mcl_loot.get_multi_loot(loottable, pr) + local items = mcl_loot.get_multi_loot(loottable, prand) return items end @@ -163,14 +163,14 @@ end ------------------------------------------------------------------------------- function settlements.initialize_furnace(pos) -- find chests within radius - local furnacepos = minetest.find_node_near(pos, + local furnacepos = minetest.find_node_near(pos, 7, --radius {"mcl_furnaces:furnace"}) -- initialize furnacepos (mts furnacepos don't have meta) - if furnacepos + if furnacepos then local meta = minetest.get_meta(furnacepos) - if meta:get_string("infotext") ~= "furnace" + if meta:get_string("infotext") ~= "furnace" then minetest.registered_nodes["mcl_furnaces:furnace"].on_construct(furnacepos) end @@ -181,14 +181,14 @@ end ------------------------------------------------------------------------------- function settlements.initialize_anvil(pos) -- find chests within radius - local anvilpos = minetest.find_node_near(pos, + local anvilpos = minetest.find_node_near(pos, 7, --radius {"mcl_anvils:anvil"}) -- initialize anvilpos (mts anvilpos don't have meta) - if anvilpos + if anvilpos then local meta = minetest.get_meta(anvilpos) - if meta:get_string("infotext") ~= "anvil" + if meta:get_string("infotext") ~= "anvil" then minetest.registered_nodes["mcl_anvils:anvil"].on_construct(anvilpos) end From 457f61a532b9c04061ee1793fdd2370848d69f44 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 16 Apr 2021 11:40:44 +0000 Subject: [PATCH 2/4] Fix #1570 --- mods/ITEMS/mcl_armor/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ITEMS/mcl_armor/init.lua b/mods/ITEMS/mcl_armor/init.lua index bce597b7f..df06ecd04 100644 --- a/mods/ITEMS/mcl_armor/init.lua +++ b/mods/ITEMS/mcl_armor/init.lua @@ -14,6 +14,7 @@ minetest.register_tool("mcl_armor:elytra", { _doc_items_usagehelp = usage, inventory_image = "mcl_armor_inv_elytra.png", groups = {armor_torso=1, mcl_armor_points=0, mcl_armor_uses=10, enchantability=0}, + _repair_material = "mcl_mobitems:leather", sounds = { _mcl_armor_equip = "mcl_armor_equip_leather", _mcl_armor_unequip = "mcl_armor_unequip_leather", From 095f78b78510cf84c42f6aedef9176f0516f5340 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Fri, 16 Apr 2021 18:34:29 +0200 Subject: [PATCH 3/4] Massive mcl_burning performance improvement --- mods/ENTITIES/mcl_mobs/api.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index a4b7e5132..ac96e3334 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -3447,7 +3447,7 @@ end -- main mob function local mob_step = function(self, dtime) - if not self.fire_resistant then + if not self.fire_resistant and self._mcl_burning_burn_time and self._mcl_burning_burn_time > 0 then mcl_burning.tick(self.object, dtime) end @@ -3906,7 +3906,7 @@ minetest.register_entity(name, { --default built in engine collision detection self.object:set_properties({ collide_with_objects = false, - }) + }) return mob_activate(self, staticdata, def, dtime) end, From 01c79c5a18d335e620777bff8e2d1e485c2337bb Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Fri, 16 Apr 2021 18:37:07 +0200 Subject: [PATCH 4/4] Fix mcl_burning.tick not being called at all for mobs --- mods/ENTITIES/mcl_mobs/api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index ac96e3334..9182b11c6 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -3447,7 +3447,7 @@ end -- main mob function local mob_step = function(self, dtime) - if not self.fire_resistant and self._mcl_burning_burn_time and self._mcl_burning_burn_time > 0 then + if not self.fire_resistant and self.mcl_burning_burn_time and self.mcl_burning_burn_time > 0 then mcl_burning.tick(self.object, dtime) end