From 1e17989ef28696fe69ab16467a1db8ef9488bad3 Mon Sep 17 00:00:00 2001 From: Doloment Date: Tue, 6 Apr 2021 21:17:02 +0700 Subject: [PATCH 01/38] Prevent opening an ender chest while block above it --- mods/ITEMS/mcl_chests/init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index 1f3f518a49..ac12261718 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -1027,11 +1027,14 @@ minetest.register_node("mcl_chests:ender_chest_small", { sounds = mcl_sounds.node_sound_stone_defaults(), drop = "mcl_core:obsidian 8", on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", formspec_ender_chest) create_entity(pos, "mcl_chests:ender_chest_small", {"mcl_chests_ender.png"}, minetest.get_node(pos).param2, false, "mcl_chests_enderchest", "mcl_chests_chest", "chest") end, on_rightclick = function(pos, node, clicker) + if minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name].groups.opaque == 1 then + -- won't open if there is no space from the top + return false + end + minetest.show_formspec(clicker:get_player_name(), "mcl_chests:ender_chest_"..clicker:get_player_name(), formspec_ender_chest) player_chest_open(clicker, pos, "mcl_chests:ender_chest_small", {"mcl_chests_ender.png"}, node.param2, false, "mcl_chests_enderchest", "mcl_chests_chest") end, on_receive_fields = function(pos, formname, fields, sender) From 54f81b774059cff39d085a602add534b4cf83e90 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Apr 2021 14:19:11 +0200 Subject: [PATCH 02/38] add basic .luacheckrc file --- .luacheckrc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .luacheckrc diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000000..55ad4cd5ea --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,35 @@ +read_globals = { + "DIR_DELIM", + "minetest", "core", + "dump", "dump2", + "vector", + "VoxelManip", "VoxelArea", + "PseudoRandom", "PcgRandom", + "ItemStack", + "Settings", + "unpack", + + table = { + fields = { + "copy", + "indexof", + "insert_all", + "key_value_swap", + } + }, + + string = { + fields = { + "split", + "trim", + } + }, + + math = { + fields = { + "hypot", + "sign", + "factorial" + } + }, +} \ No newline at end of file From d865d95639b2965ad1908036041382e848fe3753 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Apr 2021 14:26:12 +0200 Subject: [PATCH 03/38] update config --- .luacheckrc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index 55ad4cd5ea..01d71d6dfd 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,6 +1,13 @@ +unused_args = false +allow_defined_top = true +max_line_length = 125 + +globals = { + "minetest", "core", +} + read_globals = { "DIR_DELIM", - "minetest", "core", "dump", "dump2", "vector", "VoxelManip", "VoxelArea", From b1f7294578ae2126f2acfdfda21d3d67db3da54d Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Apr 2021 22:22:23 +0200 Subject: [PATCH 04/38] create python script --- tools/create_luacheck.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tools/create_luacheck.py diff --git a/tools/create_luacheck.py b/tools/create_luacheck.py new file mode 100644 index 0000000000..e69de29bb2 From b4977781924ea48eab3f5c9c93678ea03ec0ea0c Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Apr 2021 22:22:39 +0200 Subject: [PATCH 05/38] delete unused file --- mods/PLAYER/mcl_skins/intllib.lua | 45 ------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 mods/PLAYER/mcl_skins/intllib.lua diff --git a/mods/PLAYER/mcl_skins/intllib.lua b/mods/PLAYER/mcl_skins/intllib.lua deleted file mode 100644 index 6669d72023..0000000000 --- a/mods/PLAYER/mcl_skins/intllib.lua +++ /dev/null @@ -1,45 +0,0 @@ - --- Fallback functions for when `intllib` is not installed. --- Code released under Unlicense . - --- Get the latest version of this file at: --- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua - -local function format(str, ...) - local args = { ... } - local function repl(escape, open, num, close) - if escape == "" then - local replacement = tostring(args[tonumber(num)]) - if open == "" then - replacement = replacement..close - end - return replacement - else - return "@"..open..num..close - end - end - return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl)) -end - -local gettext, ngettext -if minetest.get_modpath("intllib") then - if intllib.make_gettext_pair then - -- New method using gettext. - gettext, ngettext = intllib.make_gettext_pair() - else - -- Old method using text files. - gettext = intllib.Getter() - end -end - --- Fill in missing functions. - -gettext = gettext or function(msgid, ...) - return format(msgid, ...) -end - -ngettext = ngettext or function(msgid, msgid_plural, n, ...) - return format(n==1 and msgid or msgid_plural, ...) -end - -return gettext, ngettext From a602f64ea535f4040596ca409b68ff38478495da Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Apr 2021 23:41:34 +0200 Subject: [PATCH 06/38] fix many warnings --- mods/ITEMS/mcl_farming/soil.lua | 2 +- mods/ITEMS/mcl_farming/wheat.lua | 25 +++++++++++----- mods/ITEMS/mcl_fences/init.lua | 2 +- mods/ITEMS/mcl_fire/fire_charge.lua | 2 +- mods/ITEMS/mcl_fire/flint_and_steel.lua | 2 +- mods/ITEMS/mcl_fishing/init.lua | 10 +------ mods/ITEMS/mcl_flowers/init.lua | 5 +--- mods/ITEMS/mcl_furnaces/init.lua | 10 +++++-- mods/ITEMS/mcl_heads/init.lua | 6 ++-- mods/ITEMS/mcl_hoppers/init.lua | 7 ++--- mods/ITEMS/mcl_monster_eggs/init.lua | 6 ++-- mods/ITEMS/mcl_mushrooms/small.lua | 1 - mods/ITEMS/mcl_ocean/corals.lua | 1 - mods/ITEMS/mcl_ocean/kelp.lua | 33 +++++++++------------- mods/ITEMS/mcl_throwing/init.lua | 6 ++-- mods/ITEMS/mcl_tnt/init.lua | 2 -- mods/MISC/mcl_commands/init.lua | 4 --- mods/MISC/mcl_commands/setblock.lua | 2 +- mods/MISC/mcl_commands/sound.lua | 9 ++---- mods/MISC/mcl_temp_helper_recipes/init.lua | 7 ++++- mods/PLAYER/mcl_death_drop/init.lua | 2 +- mods/PLAYER/mcl_hunger/api.lua | 5 ++-- mods/PLAYER/mcl_hunger/hunger.lua | 10 +++---- mods/PLAYER/mcl_hunger/init.lua | 4 +-- mods/PLAYER/mcl_meshhand/init.lua | 1 - mods/PLAYER/mcl_player/init.lua | 9 ++++-- mods/PLAYER/mcl_playerplus/init.lua | 22 ++++----------- mods/PLAYER/mcl_skins/init.lua | 1 - mods/PLAYER/mcl_sprint/init.lua | 13 +++++++-- mods/PLAYER/wieldview/init.lua | 11 ++++---- 30 files changed, 102 insertions(+), 118 deletions(-) diff --git a/mods/ITEMS/mcl_farming/soil.lua b/mods/ITEMS/mcl_farming/soil.lua index 0c0e3b8324..f7a7bbbfb8 100644 --- a/mods/ITEMS/mcl_farming/soil.lua +++ b/mods/ITEMS/mcl_farming/soil.lua @@ -99,7 +99,7 @@ minetest.register_abm({ -- No decay near unloaded areas since these might include water. if not check_surroundings(pos, "ignore") then if wet <= 0 then - local n_def = minetest.registered_nodes[node.name] or nil + --local n_def = minetest.registered_nodes[node.name] or nil local nn = minetest.get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z}) if not nn or not nn.name then return diff --git a/mods/ITEMS/mcl_farming/wheat.lua b/mods/ITEMS/mcl_farming/wheat.lua index e3ee79ead2..d986e5be33 100644 --- a/mods/ITEMS/mcl_farming/wheat.lua +++ b/mods/ITEMS/mcl_farming/wheat.lua @@ -5,7 +5,10 @@ minetest.register_craftitem("mcl_farming:wheat_seeds", { description = S("Wheat Seeds"), _tt_help = S("Grows on farmland"), _doc_items_longdesc = S("Grows into a wheat plant. Chickens like wheat seeds."), - _doc_items_usagehelp = S("Place the wheat seeds on farmland (which can be created with a hoe) to plant a wheat plant. They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it wheat seeds."), + _doc_items_usagehelp = S([[ + Place the wheat seeds on farmland (which can be created with a hoe) to plant a wheat plant. + They grow in sunlight and grow faster on hydrated farmland. Rightclick an animal to feed it wheat seeds. + ]]), groups = { craftitem=1 }, inventory_image = "mcl_farming_wheat_seeds.png", on_place = function(itemstack, placer, pointed_thing) @@ -28,7 +31,10 @@ for i=1,7 do if i == 1 then create = true name = S("Premature Wheat Plant") - longdesc = S("Premature wheat plants grow on farmland under sunlight in 8 stages. On hydrated farmland, they grow faster. They can be harvested at any time but will only yield a profit when mature.") + longdesc = S([[ + Premature wheat plants grow on farmland under sunlight in 8 stages. + On hydrated farmland, they grow faster. They can be harvested at any time but will only yield a profit when mature. + ]]) else create = false end @@ -54,7 +60,8 @@ for i=1,7 do {-0.5, -0.5, -0.5, 0.5, sel_heights[i], 0.5} }, }, - groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, + groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, + dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, }) @@ -62,7 +69,10 @@ end minetest.register_node("mcl_farming:wheat", { description = S("Mature Wheat Plant"), - _doc_items_longdesc = S("Mature wheat plants are ready to be harvested for wheat and wheat seeds. They won't grow any further."), + _doc_items_longdesc = S([[ + Mature wheat plants are ready to be harvested for wheat and wheat seeds. + They won't grow any further. + ]]), sunlight_propagates = true, paramtype = "light", paramtype2 = "meshoptions", @@ -81,7 +91,8 @@ minetest.register_node("mcl_farming:wheat", { { items = {'mcl_farming:wheat_item'} } } }, - groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, + groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1, attached_node=1, + dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1}, sounds = mcl_sounds.node_sound_leaves_defaults(), _mcl_blast_resistance = 0, }) @@ -144,9 +155,9 @@ minetest.register_node("mcl_farming:hay_block", { is_ground_content = false, stack_max = 64, paramtype2 = "facedir", - is_ground_content = false, on_place = mcl_util.rotate_axis, - groups = {handy=1, hoey=1, flammable=2, fire_encouragement=60, fire_flammability=20, building_block=1, fall_damage_add_percent=-80}, + groups = {handy=1, hoey=1, flammable=2, fire_encouragement=60, + fire_flammability=20, building_block=1, fall_damage_add_percent=-80}, sounds = mcl_sounds.node_sound_leaves_defaults(), on_rotate = on_rotate, _mcl_blast_resistance = 0.5, diff --git a/mods/ITEMS/mcl_fences/init.lua b/mods/ITEMS/mcl_fences/init.lua index 650854f881..e607822152 100644 --- a/mods/ITEMS/mcl_fences/init.lua +++ b/mods/ITEMS/mcl_fences/init.lua @@ -76,7 +76,7 @@ mcl_fences.register_fence_gate = function(id, fence_gate_name, texture, groups, local meta2 local state2 = 0 - local function update_gate(pos, node) + local function update_gate(pos, node) minetest.set_node(pos, node) end diff --git a/mods/ITEMS/mcl_fire/fire_charge.lua b/mods/ITEMS/mcl_fire/fire_charge.lua index f4d2da3218..69e5367906 100644 --- a/mods/ITEMS/mcl_fire/fire_charge.lua +++ b/mods/ITEMS/mcl_fire/fire_charge.lua @@ -6,7 +6,7 @@ local add_entity = minetest.add_entity -- Fire Charge minetest.register_craftitem("mcl_fire:fire_charge", { description = S("Fire Charge"), - _tt_help = S("Dispenser projectile").."\n"..S("Starts fires and ignites blocks"), + _tt_help = S("Dispenser projectile").."\n"..S("Starts fires and ignites blocks"), _doc_items_longdesc = S("Fire charges are primarily projectiles which can be launched from dispensers, they will fly in a straight line and burst into a fire on impact. Alternatively, they can be used to ignite fires directly."), _doc_items_usagehelp = S("Put the fire charge into a dispenser and supply it with redstone power to launch it. To ignite a fire directly, simply place the fire charge on the ground, which uses it up."), inventory_image = "mcl_fire_fire_charge.png", diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index b0e711e0a4..5aa02aec10 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -5,7 +5,7 @@ local add_node = minetest.add_node -- Flint and Steel minetest.register_tool("mcl_fire:flint_and_steel", { description = S("Flint and Steel"), - _tt_help = S("Starts fires and ignites blocks"), + _tt_help = S("Starts fires and ignites blocks"), _doc_items_longdesc = S("Flint and steel is a tool to start fires and ignite blocks."), _doc_items_usagehelp = S("Rightclick the surface of a block to attempt to light a fire in front of it or ignite the block. A few blocks have an unique reaction when ignited."), inventory_image = "mcl_fire_flint_and_steel.png", diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index 2bd0ed5155..e5381f9bdb 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -1,11 +1,6 @@ --Fishing Rod, Bobber, and Flying Bobber mechanics and Bobber artwork by Rootyjr. local S = minetest.get_translator("mcl_fishing") -local mod_throwing = minetest.get_modpath("mcl_throwing") - -local entity_mapping = { - ["mcl_fishing:bobber"] = "mcl_fishing:bobber_entity", -} local bobber_ENTITY={ physical = false, @@ -61,7 +56,6 @@ local fish = function(itemstack, player, pointed_thing) local itemname local items local itemcount = 1 - local itemwear = 0 local pr = PseudoRandom(os.time() * math.random(1, 100)) local r = pr:next(1, 100) local fish_values = {85, 84.8, 84.7, 84.5} @@ -173,7 +167,7 @@ local fish = function(itemstack, player, pointed_thing) if noent == true then local playerpos = player:get_pos() local dir = player:get_look_dir() - local obj = mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name()) + mcl_throwing.throw("mcl_fishing:flying_bobber", {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, 15, player:get_player_name()) end end @@ -344,10 +338,8 @@ mcl_throwing.register_throwable_object("mcl_fishing:flying_bobber", "mcl_fishing -- If player leaves area, remove bobber. minetest.register_on_leaveplayer(function(player) local objs = minetest.get_objects_inside_radius(player:get_pos(), 250) - local num = 0 local ent = nil local noent = true - for n = 1, #objs do ent = objs[n]:get_luaentity() if ent then diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index a155ebd0b9..7a2501f25a 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -180,7 +180,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im if not inv_img then inv_img = top_img end - local usagehelp, noncreative, create_entry, paramtype2, palette + local noncreative, create_entry, paramtype2, palette if is_flower == nil then is_flower = true end @@ -475,9 +475,6 @@ local fix_doubleplants = minetest.settings:get_bool("fix_doubleplants", true) if mod_mcimport and mg_name == "singlenode" and fix_doubleplants == true then local flowernames = { "peony", "rose_bush", "lilac", "sunflower", "double_fern", "double_grass" } - for c=1, 6 do - local flowername = flowernames[c] - end minetest.register_lbm({ label = "Add double plant tops.", diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index 1d1ecc0319..02a104bc53 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -384,7 +384,6 @@ local function furnace_node_timer(pos, elapsed) -- Update formspec and node -- local formspec = inactive_formspec - local item_state local item_percent = 0 if cookable then item_percent = math.floor(src_time / cooked.time * 100) @@ -414,7 +413,7 @@ local function furnace_node_timer(pos, elapsed) meta:set_float("fuel_time", fuel_time) meta:set_float("src_time", src_time) if srclist then - meta:set_string("src_item", srclist[1]:get_name()) + meta:set_string("src_item", src_item) else meta:set_string("src_item", "") end @@ -441,7 +440,12 @@ minetest.register_node("mcl_furnaces:furnace", { _tt_help = S("Uses fuel to smelt or cook items"), _doc_items_longdesc = S("Furnaces cook or smelt several items, using a furnace fuel, into something else."), _doc_items_usagehelp = - S("Use the furnace to open the furnace menu. Place a furnace fuel in the lower slot and the source material in the upper slot. The furnace will slowly use its fuel to smelt the item. The result will be placed into the output slot at the right side.").."\n".. + S([[ + Use the furnace to open the furnace menu. + Place a furnace fuel in the lower slot and the source material in the upper slot. + The furnace will slowly use its fuel to smelt the item. + The result will be placed into the output slot at the right side. + ]]).."\n".. S("Use the recipe book to see what you can smelt, what you can use as fuel and how long it will burn."), _doc_items_hidden = false, tiles = { diff --git a/mods/ITEMS/mcl_heads/init.lua b/mods/ITEMS/mcl_heads/init.lua index 2000c70702..e7340242d8 100644 --- a/mods/ITEMS/mcl_heads/init.lua +++ b/mods/ITEMS/mcl_heads/init.lua @@ -90,7 +90,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) local wdir = minetest.dir_to_wallmounted(diff) local itemstring = itemstack:get_name() - local fakestack = ItemStack(itemstack) + --local fakestack = ItemStack(itemstack) local idef = fakestack:get_definition() local retval if wdir == 0 or wdir == 1 then @@ -101,9 +101,7 @@ local function addhead(name, texture, desc, longdesc, rangemob, rangefactor) if not retval then return itemstack end - - local success - itemstack, success = minetest.item_place(fakestack, placer, pointed_thing, wdir) + itemstack,_ = minetest.item_place(fakestack, placer, pointed_thing, wdir) itemstack:set_name(itemstring) return itemstack end, diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index e9b3f75e0c..e9f6ddf923 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -152,7 +152,7 @@ def_hopper_enabled.on_place = function(itemstack, placer, pointed_thing) local z = upos.z - apos.z local fake_itemstack = ItemStack(itemstack) - local newnode, param2 + local param2 if x == -1 then fake_itemstack:set_name("mcl_hoppers:hopper_side") param2 = 0 @@ -166,7 +166,7 @@ def_hopper_enabled.on_place = function(itemstack, placer, pointed_thing) fake_itemstack:set_name("mcl_hoppers:hopper_side") param2 = 1 end - local itemstack, success = minetest.item_place_node(fake_itemstack, placer, pointed_thing, param2) + local itemstack,_ = minetest.item_place_node(fake_itemstack, placer, pointed_thing, param2) itemstack:set_name("mcl_hoppers:hopper") return itemstack end @@ -411,7 +411,6 @@ minetest.register_abm({ -- Move an item from the hopper into container below local downnode = minetest.get_node(downpos) if not minetest.registered_nodes[downnode.name] then return end - g = minetest.registered_nodes[downnode.name].groups.container mcl_util.move_item_container(pos, downpos) end, }) @@ -462,7 +461,7 @@ minetest.register_abm({ -- Put fuel into fuel slot local sinv = minetest.get_inventory({type="node", pos = pos}) local dinv = minetest.get_inventory({type="node", pos = front}) - local slot_id, stack = mcl_util.get_eligible_transfer_item_slot(sinv, "main", dinv, "fuel", is_transferrable_fuel) + local slot_id,_ = mcl_util.get_eligible_transfer_item_slot(sinv, "main", dinv, "fuel", is_transferrable_fuel) if slot_id then mcl_util.move_item_container(pos, front, nil, slot_id, "fuel") end diff --git a/mods/ITEMS/mcl_monster_eggs/init.lua b/mods/ITEMS/mcl_monster_eggs/init.lua index 55875159e5..dd986d127f 100644 --- a/mods/ITEMS/mcl_monster_eggs/init.lua +++ b/mods/ITEMS/mcl_monster_eggs/init.lua @@ -20,11 +20,13 @@ local register_block = function(subname, description, tiles, is_ground_content) is_ground_content = is_ground_content, groups = {dig_immediate = 3, spawns_silverfish = 1, deco_block = 1}, drop = '', - is_ground_content = false, sounds = mcl_sounds.node_sound_stone_defaults(), after_dig_node = spawn_silverfish, _tt_help = S("Hides a silverfish"), - _doc_items_longdesc = S("An infested block is a block from which a silverfish will pop out when it is broken. It looks identical to its normal counterpart."), + _doc_items_longdesc = S([[ + An infested block is a block from which a silverfish will pop out when it is broken. + It looks identical to its normal counterpart. + ]]), _mcl_hardness = 0, _mcl_blast_resistance = 0.5, }) diff --git a/mods/ITEMS/mcl_mushrooms/small.lua b/mods/ITEMS/mcl_mushrooms/small.lua index 8105386f4b..52c64928f1 100644 --- a/mods/ITEMS/mcl_mushrooms/small.lua +++ b/mods/ITEMS/mcl_mushrooms/small.lua @@ -4,7 +4,6 @@ local on_place = mcl_util.generate_on_place_plant_function(function(place_pos, p local soil_node = minetest.get_node_or_nil({x=place_pos.x, y=place_pos.y-1, z=place_pos.z}) if not soil_node then return false end local snn = soil_node.name -- soil node name - local sd = minetest.registered_nodes[snn] -- soil definition -- Placement rules: -- * Always allowed on podzol or mycelimu diff --git a/mods/ITEMS/mcl_ocean/corals.lua b/mods/ITEMS/mcl_ocean/corals.lua index f3de5968eb..376b8a22fa 100644 --- a/mods/ITEMS/mcl_ocean/corals.lua +++ b/mods/ITEMS/mcl_ocean/corals.lua @@ -265,7 +265,6 @@ minetest.register_abm({ if minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "mcl_core:water_source" then -- Find dead form (it's the same as the node's drop) local def = minetest.registered_nodes[node.name] - local dead if def then node.name = def.drop else diff --git a/mods/ITEMS/mcl_ocean/kelp.lua b/mods/ITEMS/mcl_ocean/kelp.lua index 9670943da6..326b08a811 100644 --- a/mods/ITEMS/mcl_ocean/kelp.lua +++ b/mods/ITEMS/mcl_ocean/kelp.lua @@ -37,14 +37,9 @@ local mt_record_protection_violation = minetest.record_protection_violation local mt_is_creative_enabled = minetest.is_creative_enabled local mt_sound_play = minetest.sound_play -local math_min = math.min -local math_max = math.max -local math_ceil = math.ceil -local math_floor = math.floor -local math_random = math.random -local string_format = string.format -local table_copy = table.copy -local table_insert = table.insert +local math = math +local string = string +local table = table -- DEBUG: functions -- local log = minetest.log @@ -122,7 +117,7 @@ function kelp.is_downward_flowing(pos, node, pos_above, node_above, __is_above__ -- Function params: (pos[, node]) or (node, pos_above) or (node, node_above) local node = node or mt_get_node(pos) - local result = (math_floor(node.param2 / 8) % 2) == 1 + local result = (math.floor(node.param2 / 8) % 2) == 1 if not (result or __is_above__) then -- If not, also check node above. -- (this is needed due a weird quirk in the definition of "downwards flowing" @@ -182,14 +177,14 @@ end -- Roll whether to grow kelp or not. function kelp.roll_growth(numerator, denominator) -- Optional params: numerator, denominator - return math_random(denominator or kelp.ROLL_GROWTH_DENOMINATOR) <= (numerator or kelp.ROLL_GROWTH_NUMERATOR) + return math.random(denominator or kelp.ROLL_GROWTH_DENOMINATOR) <= (numerator or kelp.ROLL_GROWTH_NUMERATOR) end -- Roll initial age for kelp. function kelp.roll_init_age(min, max) -- Optional params - return math_random(min or kelp.MIN_AGE, (max or kelp.MAX_AGE)-1) + return math.random(min or kelp.MIN_AGE, (max or kelp.MAX_AGE)-1) end @@ -197,7 +192,7 @@ end -- For the special case where the max param2 is reached, interpret that as the -- 16th kelp stem. function kelp.get_height(param2) - return math_floor(param2 / 16) + math_floor(param2 % 16 / 8) + return math.floor(param2 / 16) + math.floor(param2 % 16 / 8) end @@ -232,7 +227,7 @@ end -- Obtain next param2. function kelp.next_param2(param2) -- param2 max value is 255, so adding to 256 causes overflow. - return math_min(param2+16 - param2 % 16, 255); + return math.min(param2+16 - param2 % 16, 255); end @@ -242,8 +237,8 @@ function kelp.store_meta() for _ in pairs(kelp.age_queue_pos) do count = count + 1 end - -- chatlog(string_format("Storing age metadata: %d in queue", #kelp.age_queue)) - -- chatlog(string_format("Storing age metadata: %d valid in queue", count)) + -- chatlog(string.format("Storing age metadata: %d in queue", #kelp.age_queue)) + -- chatlog(string.format("Storing age metadata: %d valid in queue", count)) for i=1,#kelp.age_queue do local pos_hash = kelp.age_queue[i] local pos = kelp.age_queue_pos[pos_hash] @@ -265,7 +260,7 @@ function kelp.store_age(age, pos, pos_hash) kelp.age_pool[pos_hash] = age if not kelp.age_queue_pos[pos_hash] then - table_insert(kelp.age_queue, pos_hash) + table.insert(kelp.age_queue, pos_hash) kelp.age_queue_pos[pos_hash] = pos return true, pos_hash end @@ -713,7 +708,7 @@ function kelp.register_kelp_surface(surface, surface_deftemplate, surface_docs) doc.add_entry_alias("nodes", surface_docs.entry_id_orig, "nodes", surfacename) end - local sounds = table_copy(def.sounds) + local sounds = table.copy(def.sounds) sounds.dig = kelp.leaf_sounds.dig sounds.dug = kelp.leaf_sounds.dug sounds.place = kelp.leaf_sounds.place @@ -732,9 +727,9 @@ end -- Kelp surfaces nodes --------------------------------------------------------- -- Dirt must be registered first, for the docs -kelp.register_kelp_surface(kelp.surfaces[1], table_copy(kelp.surface_deftemplate), kelp.surface_docs) +kelp.register_kelp_surface(kelp.surfaces[1], table.copy(kelp.surface_deftemplate), kelp.surface_docs) for i=2, #kelp.surfaces do - kelp.register_kelp_surface(kelp.surfaces[i], table_copy(kelp.surface_deftemplate), kelp.surface_docs) + kelp.register_kelp_surface(kelp.surfaces[i], table.copy(kelp.surface_deftemplate), kelp.surface_docs) end -- Kelp item ------------------------------------------------------------------- diff --git a/mods/ITEMS/mcl_throwing/init.lua b/mods/ITEMS/mcl_throwing/init.lua index 09a34c12f5..2d57744d0e 100644 --- a/mods/ITEMS/mcl_throwing/init.lua +++ b/mods/ITEMS/mcl_throwing/init.lua @@ -1,10 +1,8 @@ mcl_throwing = {} -local S = minetest.get_translator("mcl_throwing") -local mod_death_messages = minetest.get_modpath("mcl_death_messages") local modpath = minetest.get_modpath(minetest.get_current_modname()) --- +-- -- Snowballs and other throwable items -- @@ -42,7 +40,7 @@ function mcl_throwing.get_player_throw_function(entity_name, velocity) local func = function(item, player, pointed_thing) local playerpos = player:get_pos() local dir = player:get_look_dir() - local obj = mcl_throwing.throw(item, {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, velocity, player:get_player_name()) + mcl_throwing.throw(item, {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, velocity, player:get_player_name()) if not minetest.is_creative_enabled(player:get_player_name()) then item:take_item() end diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 8001e5cf01..19bd04a18a 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -1,8 +1,6 @@ local S = minetest.get_translator("mcl_tnt") local tnt_griefing = minetest.settings:get_bool("mcl_tnt_griefing", true) -local mod_death_messages = minetest.get_modpath("mcl_death_messages") - local function spawn_tnt(pos, entname) minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,}, true) local tnt = minetest.add_entity(pos, entname) diff --git a/mods/MISC/mcl_commands/init.lua b/mods/MISC/mcl_commands/init.lua index 7a9fe4868b..a287c29269 100644 --- a/mods/MISC/mcl_commands/init.lua +++ b/mods/MISC/mcl_commands/init.lua @@ -1,7 +1,3 @@ -local S = minetest.get_translator("mcl_commands") - -local mod_death_messages = minetest.get_modpath("mcl_death_messages") - local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/kill.lua") diff --git a/mods/MISC/mcl_commands/setblock.lua b/mods/MISC/mcl_commands/setblock.lua index 30d68b74fa..dc834e1e8a 100644 --- a/mods/MISC/mcl_commands/setblock.lua +++ b/mods/MISC/mcl_commands/setblock.lua @@ -6,7 +6,7 @@ minetest.register_chatcommand("setblock", { privs = {give=true, interact=true}, func = function(name, param) local p = {} - local nodestring = nil + local nodestring p.x, p.y, p.z, nodestring = param:match("^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) +(.+)$") p.x, p.y, p.z = tonumber(p.x), tonumber(p.y), tonumber(p.z) if p.x and p.y and p.z and nodestring then diff --git a/mods/MISC/mcl_commands/sound.lua b/mods/MISC/mcl_commands/sound.lua index 934abb80eb..06225271d6 100644 --- a/mods/MISC/mcl_commands/sound.lua +++ b/mods/MISC/mcl_commands/sound.lua @@ -4,39 +4,34 @@ minetest.register_chatcommand("playsound",{ params = S(" "), --TODO:add source description = S("Play a sound. Arguments: : name of the sound. : Target."), privs = {server = true}, - func = function(name, params) + func = function(name, rawparams) local P = {} local i = 0 - for str in string.gmatch(params, "([^ ]+)") do + for str in string.gmatch(rawparams, "([^ ]+)") do i = i + 1 P[i] = str end - local params = {} if P[1] == tostring(P[1]) then params.name = P[1] else return false, S("Sound name is invalid!") --TODO: add mc chat message end - if P[2] == tostring(P[2]) and minetest.player_exists(P[2]) then params.target = P[2] else return false, S("Target is invalid!!") end - -- if P[3] then -- params.pos = nil --TODO:position -- else -- params.pos = nil -- end - -- if P[4] == tonumber(P[4]) then -- params.gain = P[4] -- else -- params.gain = 1.0 -- end - -- if P[5] == tonumber(P[5]) then -- params.pitch = P[5] -- else diff --git a/mods/MISC/mcl_temp_helper_recipes/init.lua b/mods/MISC/mcl_temp_helper_recipes/init.lua index d1262cb2c2..ff9f541f36 100644 --- a/mods/MISC/mcl_temp_helper_recipes/init.lua +++ b/mods/MISC/mcl_temp_helper_recipes/init.lua @@ -27,7 +27,12 @@ minetest.register_craft({ minetest.register_craft({ type = "shapeless", output = "mcl_ocean:prismarine_crystals", - recipe = { "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_ocean:prismarine_shard", "mcl_core:gold_ingot" }, + recipe = { + "mcl_ocean:prismarine_shard", + "mcl_ocean:prismarine_shard", + "mcl_ocean:prismarine_shard", + "mcl_core:gold_ingot", + }, }) minetest.register_craft({ diff --git a/mods/PLAYER/mcl_death_drop/init.lua b/mods/PLAYER/mcl_death_drop/init.lua index 7c54334a95..90a2b0fbd1 100644 --- a/mods/PLAYER/mcl_death_drop/init.lua +++ b/mods/PLAYER/mcl_death_drop/init.lua @@ -20,7 +20,7 @@ minetest.register_on_dieplayer(function(player) local playerinv = player:get_inventory() local pos = player:get_pos() -- No item drop if in deep void - local void, void_deadly = mcl_worlds.is_in_void(pos) + local _, void_deadly = mcl_worlds.is_in_void(pos) for l=1,#mcl_death_drop.registered_dropped_lists do local inv = mcl_death_drop.registered_dropped_lists[l].inv diff --git a/mods/PLAYER/mcl_hunger/api.lua b/mods/PLAYER/mcl_hunger/api.lua index 55153b9bf4..4fea9b04e4 100644 --- a/mods/PLAYER/mcl_hunger/api.lua +++ b/mods/PLAYER/mcl_hunger/api.lua @@ -86,7 +86,8 @@ if mcl_hunger.active then function mcl_hunger.saturate(playername, increase, update_hudbar) local player = minetest.get_player_by_name(playername) - local ok = mcl_hunger.set_saturation(player, math.min(mcl_hunger.get_saturation(player) + increase, mcl_hunger.get_hunger(player))) + local ok = mcl_hunger.set_saturation(player, + math.min(mcl_hunger.get_saturation(player) + increase, mcl_hunger.get_hunger(player))) if update_hudbar ~= false then mcl_hunger.update_saturation_hud(player, mcl_hunger.get_saturation(player), mcl_hunger.get_hunger(player)) end @@ -105,7 +106,7 @@ if mcl_hunger.active then -- otherwise the following poison/exhaust fields are ignored food[name].poison = poison -- poison damage per tick for poisonous food food[name].exhaust = exhaust -- exhaustion per tick for poisonous food - food[name].poisonchance = poisonchance -- chance percentage that this item poisons the player (default: 100% if poisoning is enabled) + food[name].poisonchance = poisonchance -- chance percentage that this item poisons the player (default: 100%) food[name].sound = sound -- special sound that is played when eating end diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index 393bdc9a92..30ad10ac2e 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -2,7 +2,6 @@ local S = minetest.get_translator("mcl_hunger") local mod_death_messages = minetest.get_modpath("mcl_death_messages") -- wrapper for minetest.item_eat (this way we make sure other mods can't break this one) -local org_eat = minetest.do_item_eat minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing) if not user or user:is_player() == false then @@ -38,7 +37,8 @@ minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, p -- FIXME: In singleplayer, there's a cheat to circumvent this, simply by pausing the game between eats. -- This is because os.time() obviously does not care about the pause. A fix needs a different timer mechanism. if no_eat_delay or (mcl_hunger.last_eat[name] < 0) or (os.difftime(os.time(), mcl_hunger.last_eat[name]) >= 2) then - local can_eat_when_full = creative or (mcl_hunger.active == false) or minetest.get_item_group(itemstack:get_name(), "can_eat_when_full") == 1 + local can_eat_when_full = creative or (mcl_hunger.active == false) + or minetest.get_item_group(itemstack:get_name(), "can_eat_when_full") == 1 -- Don't allow eating when player has full hunger bar (some exceptional items apply) if can_eat_when_full or (mcl_hunger.get_hunger(user) < 20) then itemstack = mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing) @@ -67,7 +67,8 @@ function mcl_hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_t def.saturation = hp_change def.replace = replace_with_item end - local func = mcl_hunger.item_eat(def.saturation, def.replace, def.poisontime, def.poison, def.exhaust, def.poisonchance, def.sound) + local func = mcl_hunger.item_eat(def.saturation, def.replace, def.poisontime, + def.poison, def.exhaust, def.poisonchance, def.sound) return func(itemstack, user, pointed_thing) end @@ -90,7 +91,6 @@ local function poisonp(tick, time, time_left, damage, exhaustion, name) if not player then return end - local name = player:get_player_name() -- Abort if food poisonings have been stopped if mcl_hunger.poison_hunger[name] == 0 then return @@ -131,7 +131,7 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso itemstack:take_item() end local name = user:get_player_name() - local hp = user:get_hp() + --local hp = user:get_hp() local pos = user:get_pos() -- player height diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index b640dfdc9b..c65206599b 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -65,9 +65,7 @@ end -- Count number of poisonings a player has at once mcl_hunger.poison_hunger = {} -- food poisoning, increasing hunger --- HUD item ids -local hunger_hud = {} - +-- HUD local function init_hud(player) hb.init_hudbar(player, "hunger", mcl_hunger.get_hunger(player)) if mcl_hunger.debug then diff --git a/mods/PLAYER/mcl_meshhand/init.lua b/mods/PLAYER/mcl_meshhand/init.lua index cdd5da946d..80bf36b7d2 100644 --- a/mods/PLAYER/mcl_meshhand/init.lua +++ b/mods/PLAYER/mcl_meshhand/init.lua @@ -63,7 +63,6 @@ end if has_mcl_skins == true then --change the player's hand to their skin mcl_skins.register_on_set_skin(function(player, skin) - local name = player:get_player_name() local meta = mcl_skins.meta[skin] if meta.gender == "female" then player:get_inventory():set_stack("hand", 1, "mcl_meshhand:"..skin.."_female") diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index 210e2d19f0..9df852502e 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -9,7 +9,7 @@ local animation_blend = 0 local function get_mouse_button(player) local controls = player:get_player_control() local get_wielded_item_name = player:get_wielded_item():get_name() - if controls.RMB and not string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") or controls.LMB then + if controls.RMB and not string.find(get_wielded_item_name, "mcl_bows:bow") or controls.LMB then return true else return false @@ -110,7 +110,7 @@ function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname) local name = player:get_player_name() local model = player_model[name] local anim = models[model].animations[player_anim[name]] - return "model[" .. x .. "," .. y .. ";" .. w .. "," .. h .. ";" .. fsname .. ";" .. model .. ";" .. table.concat(player_textures[name], ",") .. ";0," .. 180 .. ";false;false;" .. anim.x .. "," .. anim.y .. "]" + return "model["..x..","..y..";"..w..","..h..";"..fsname..";"..model..";"..table.concat(player_textures[name], ",")..";0,".. 180 ..";false;false;"..anim.x..","..anim.y.."]" end function mcl_player.player_set_animation(player, anim_name, speed) @@ -179,7 +179,10 @@ minetest.register_globalstep(function(dtime) -- Apply animations based on what the player is doing if player:get_hp() == 0 then player_set_animation(player, "die") - elseif walking and velocity.x > 0.35 or walking and velocity.x < -0.35 or walking and velocity.z > 0.35 or walking and velocity.z < -0.35 then + elseif walking and velocity.x > 0.35 + or walking and velocity.x < -0.35 + or walking and velocity.z > 0.35 + or walking and velocity.z < -0.35 then if player_sneak[name] ~= controls.sneak then player_anim[name] = nil player_sneak[name] = controls.sneak diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index f4dceb9b4a..5cca23d320 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -29,7 +29,7 @@ local look_pitch = 0 local player_collision = function(player) local pos = player:get_pos() - local vel = player:get_velocity() + --local vel = player:get_velocity() local x = 0 local z = 0 local width = .75 @@ -58,18 +58,8 @@ local function degrees(rad) return rad * 180.0 / math.pi end -local pi = math.pi -local atann = math.atan -local atan = function(x) - if not x or x ~= x then - return 0 - else - return atann(x) - end -end - local dir_to_pitch = function(dir) - local dir2 = vector.normalize(dir) + --local dir2 = vector.normalize(dir) local xz = math.abs(dir.x) + math.abs(dir.z) return -math.atan2(-dir.y, xz) end @@ -121,7 +111,7 @@ function limit_vel_yaw(player_vel_yaw, yaw) return player_vel_yaw end -local pitch, name, node_stand, node_stand_below, node_head, node_feet, pos +local node_stand, node_stand_below, node_head, node_feet minetest.register_on_punchplayer(function(player, hitter, damage) @@ -178,7 +168,7 @@ minetest.register_globalstep(function(dtime) local control = player:get_player_control() local name = player:get_player_name() - local meta = player:get_meta() + --local meta = player:get_meta() local parent = player:get_attach() local wielded = player:get_wielded_item() local player_velocity = player:get_velocity() or player:get_player_velocity() @@ -217,7 +207,7 @@ minetest.register_globalstep(function(dtime) elytra[player] = true elseif key=="RMB" then if wielded:get_name() == "mcl_tools:rocket" then - local item = wielded:take_item() + wielded:take_item() player:set_wielded_item(wielded) end end @@ -314,7 +304,7 @@ minetest.register_globalstep(function(dtime) if control.jump and mcl_playerplus_internal[name].jump_cooldown <= 0 then - pos = player:get_pos() + --pos = player:get_pos() node_stand = mcl_playerinfo[name].node_stand node_stand_below = mcl_playerinfo[name].node_stand_below diff --git a/mods/PLAYER/mcl_skins/init.lua b/mods/PLAYER/mcl_skins/init.lua index 5956aab7c3..297817fac0 100644 --- a/mods/PLAYER/mcl_skins/init.lua +++ b/mods/PLAYER/mcl_skins/init.lua @@ -198,7 +198,6 @@ minetest.register_chatcommand("setskin", { end end - local skin local ok = mcl_skins.set_player_skin(player, skin_id) if not ok then return false, S("Invalid skin number! Valid numbers: 0 to @1", mcl_skins.skin_count) diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 9dc678000c..12d0394e50 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -53,7 +53,10 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player local controls = player:get_player_control() if players[playerName] then players[playerName].sprinting = sprinting - if sprinting == true or controls.RMB and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then + if sprinting == true + or controls.RMB + and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") + and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then if sprinting == true then players[playerName].fov = math.min(players[playerName].fov + 0.05, 1.2) players[playerName].fade_time = .15 @@ -65,7 +68,10 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player if sprinting == true then playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) end - elseif sprinting == false and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then + elseif sprinting == false + and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0" + and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1" + and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then players[playerName].fov = math.max(players[playerName].fov - 0.05, 1.0) player:set_fov(players[playerName].fov, true, 0.15) if sprinting == false then @@ -186,7 +192,8 @@ minetest.register_globalstep(function(dtime) if players[playerName]["shouldSprint"] == true then --Stopped local sprinting -- Prevent sprinting if hungry or sleeping - if (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then + if (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) + or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then sprinting = false cancelClientSprinting(playerName) else diff --git a/mods/PLAYER/wieldview/init.lua b/mods/PLAYER/wieldview/init.lua index 7a349f2f37..91b2cd7215 100644 --- a/mods/PLAYER/wieldview/init.lua +++ b/mods/PLAYER/wieldview/init.lua @@ -1,4 +1,3 @@ -local time = 0 local update_time = tonumber(minetest.settings:get("wieldview_update_time")) if not update_time then update_time = 2 @@ -69,14 +68,14 @@ end minetest.register_on_joinplayer(function(player) local name = player:get_player_name() wieldview.wielded_item[name] = "" - minetest.after(0, function(player) + minetest.after(0, function(target) -- if the player left :is_player() will return nil - if not player:is_player() then + if not target:is_player() then return end - wieldview:update_wielded_item(player) - 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)) + wieldview:update_wielded_item(target) + local itementity = minetest.add_entity(target:get_pos(), "wieldview:wieldnode") + itementity:set_attach(target, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 0, 45)) itementity:get_luaentity().wielder = name end, player) end) From 60e74fc41d36383db8ea1062c1e970fca704e3c6 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Apr 2021 23:44:29 +0200 Subject: [PATCH 07/38] fix excedent lines --- mods/ITEMS/mcl_fishing/init.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index e5381f9bdb..76526ee72d 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -37,8 +37,7 @@ local fish = function(itemstack, player, pointed_thing) local num = 0 local ent = nil local noent = true - - + local durability = 65 local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") if unbreaking > 0 then From 1df916bd7b363c0dfabf53d8ce4c2009d6ced805 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 16 Apr 2021 11:03:31 +0200 Subject: [PATCH 08/38] fix warning --- mods/ITEMS/mcl_torches/api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_torches/api.lua b/mods/ITEMS/mcl_torches/api.lua index 83320435f6..3044888054 100644 --- a/mods/ITEMS/mcl_torches/api.lua +++ b/mods/ITEMS/mcl_torches/api.lua @@ -257,7 +257,7 @@ minetest.register_lbm({ nodenames = {"group:torch_particles"}, run_at_every_load = true, action = function(pos, node) - local torch_group = minetest.get_node_group(node.name, "torch") + local torch_group = minetest.get_item_group(node.name, "torch") if torch_group == 1 then spawn_flames_floor(pos) elseif torch_group == 2 then From 3dd490ed6b463c44543c9d01263450f6fab1ec50 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 16 Apr 2021 12:59:00 +0200 Subject: [PATCH 09/38] remove lengh limitation --- .luacheckrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index 01d71d6dfd..ce5049d378 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,6 +1,6 @@ unused_args = false allow_defined_top = true -max_line_length = 125 +max_line_length = false globals = { "minetest", "core", From 1a58b0c510f36eb24dbb3c2804c621bbaf6279f8 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 16 Apr 2021 13:35:03 +0200 Subject: [PATCH 10/38] 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 2e041ae2e2..a3a35e2fab 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 b0be3e12dd..ec4da620ec 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 829fc41817..e10513bc3d 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 6948aed04f..d926550f8d 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 2d804b9bc7..fa5352c2cc 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 36694c6f38..de1b1760f5 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 e6aedf19c5..942bccf38b 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 e1914a9ff2..b7faffb3bb 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 5f0510344b..f583d87b6f 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 038a2f2020..71c5cfdda4 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 19de10b98f..ccc3f585dd 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 4973171a62..63f2ba1468 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 d7617541dc..993de11c42 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 11/38] 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 bce597b7f1..df06ecd04d 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 12/38] 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 a4b7e51326..ac96e33343 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 13/38] 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 ac96e33343..9182b11c63 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 From 10f81dbf0cfdcf60a9a86888e6ba1ae37e15d752 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Fri, 16 Apr 2021 18:41:10 +0200 Subject: [PATCH 14/38] Change max mcl_bossbars default to 5 (Minecraft value) --- settingtypes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settingtypes.txt b/settingtypes.txt index bfda9b3ba8..c5968a4c09 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -98,7 +98,7 @@ animated_chests (Animated chests) bool true 3d_player_preview (3D Player preview) bool true # The maximum number of boss bars to simultaniously display on the screen -max_bossbars (Maximum Boss bars) int 4 +max_bossbars (Maximum Boss bars) int 5 [Experimental] # Whether ice is translucent. If disabled, ice is fully opaque. From bd3c08d367fc454aecf9ddd6954d0a81cf2a9514 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Fri, 16 Apr 2021 19:50:56 +0200 Subject: [PATCH 15/38] Improve mcl_burning player performance --- mods/ENTITIES/mcl_burning/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index 672036c78b..6f1b0ef0d3 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -15,7 +15,7 @@ minetest.register_entity("mcl_burning:fire", { pointable = false, glow = -1, }, - + animation_frame = 0, animation_timer = 0, on_step = mcl_burning.fire_entity_step, @@ -23,7 +23,9 @@ minetest.register_entity("mcl_burning:fire", { minetest.register_globalstep(function(dtime) for _, player in pairs(minetest.get_connected_players()) do - mcl_burning.tick(player, dtime) + if player:get_meta():get_float("mcl_burning:burn_time") > 0 then + mcl_burning.tick(player, dtime) + end end end) From 5f076d372a74c98d0991d070c12d4d31c71319e2 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 17 Apr 2021 07:42:49 +0200 Subject: [PATCH 16/38] fix many codestyle errors --- .luacheckrc | 3 +- mods/MAPGEN/mcl_villages/buildings.lua | 58 +++++++++++++------------- mods/MAPGEN/mcl_villages/const.lua | 20 ++++----- mods/MAPGEN/tsm_railcorridors/init.lua | 4 +- mods/MISC/findbiome/init.lua | 4 +- mods/PLAYER/mcl_playerplus/init.lua | 4 -- mods/PLAYER/mcl_spawn/init.lua | 6 +-- 7 files changed, 47 insertions(+), 52 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index ce5049d378..f36a4a37b2 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,6 +1,7 @@ unused_args = false allow_defined_top = true max_line_length = false +redefined = false globals = { "minetest", "core", @@ -11,7 +12,7 @@ read_globals = { "dump", "dump2", "vector", "VoxelManip", "VoxelArea", - "PseudoRandom", "PcgRandom", + "PseudoRandom", "PcgRandom", "PerlinNoise", "ItemStack", "Settings", "unpack", diff --git a/mods/MAPGEN/mcl_villages/buildings.lua b/mods/MAPGEN/mcl_villages/buildings.lua index e43db6d987..e917638dbc 100644 --- a/mods/MAPGEN/mcl_villages/buildings.lua +++ b/mods/MAPGEN/mcl_villages/buildings.lua @@ -12,19 +12,19 @@ function settlements.build_schematic(vm, data, va, pos, building, replace_wall, -- pick random material local material = wallmaterial[math.random(1,#wallmaterial)] -- schematic conversion to lua - local schem_lua = minetest.serialize_schematic(building, - "lua", + local schem_lua = minetest.serialize_schematic(building, + "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)" -- replace material if replace_wall == "y" then schem_lua = schem_lua:gsub("mcl_core:cobble", material) end - schem_lua = schem_lua:gsub("mcl_core:dirt_with_grass", + schem_lua = schem_lua:gsub("mcl_core:dirt_with_grass", platform_material) -- Disable special junglewood for now. -- special material for spawning npcs - -- schem_lua = schem_lua:gsub("mcl_core:junglewood", + -- schem_lua = schem_lua:gsub("mcl_core:junglewood", -- "settlements:junglewood") -- @@ -37,25 +37,25 @@ function settlements.build_schematic(vm, data, va, pos, building, replace_wall, local possible_rotations = {"0", "90", "180", "270"} local rotation = possible_rotations[ math.random( #possible_rotations ) ] settlements.foundation( - pos, - width, - depth, - height, + pos, + width, + depth, + height, rotation) vm:set_data(data) -- place schematic minetest.place_schematic_on_vmanip( - vm, - pos, - schematic, - rotation, - nil, + vm, + pos, + schematic, + rotation, + nil, true) vm:write_to_map(true) end]] ------------------------------------------------------------------------------- --- initialize settlement_info +-- initialize settlement_info ------------------------------------------------------------------------------- function settlements.initialize_settlement_info(pr) local count_buildings = {} @@ -81,8 +81,8 @@ function settlements.create_site_plan(maxp, minp, pr) local possible_rotations = {"0", "90", "180", "270"} -- find center of chunk local center = { - x=math.floor((minp.x+maxp.x)/2), - y=maxp.y, + x=math.floor((minp.x+maxp.x)/2), + y=maxp.y, z=math.floor((minp.z+maxp.z)/2) } -- find center_surface of chunk @@ -105,8 +105,8 @@ function settlements.create_site_plan(maxp, minp, pr) -- add to settlement info table local index = 1 settlement_info[index] = { - pos = center_surface, - name = building_all_info["name"], + pos = center_surface, + name = building_all_info["name"], hsize = building_all_info["hsize"], rotat = rotation, surface_mat = surface_material @@ -149,8 +149,8 @@ function settlements.create_site_plan(maxp, minp, pr) rotation = possible_rotations[ pr:next(1, #possible_rotations ) ] number_built = number_built + 1 settlement_info[index] = { - pos = pos_surface, - name = building_all_info["name"], + pos = pos_surface, + name = building_all_info["name"], hsize = building_all_info["hsize"], rotat = rotation, surface_mat = surface_material @@ -215,10 +215,10 @@ function settlements.place_schematics(settlement_info, pr) end end - local pos = settlement_info[i]["pos"] - local rotation = settlement_info[i]["rotat"] + local pos = settlement_info[i]["pos"] + local rotation = settlement_info[i]["rotat"] -- get building node material for better integration to surrounding - local platform_material = settlement_info[i]["surface_mat"] + local platform_material = settlement_info[i]["surface_mat"] --platform_material_name = minetest.get_name_from_content_id(platform_material) -- pick random material --local material = wallmaterial[pr:next(1,#wallmaterial)] @@ -226,8 +226,8 @@ function settlements.place_schematics(settlement_info, pr) local building = building_all_info["mts"] local replace_wall = building_all_info["rplc"] -- schematic conversion to lua - local schem_lua = minetest.serialize_schematic(building, - "lua", + local schem_lua = minetest.serialize_schematic(building, + "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)" schem_lua = schem_lua:gsub("mcl_core:stonebrickcarved", "mcl_villages:stonebrickcarved") -- replace material @@ -269,10 +269,10 @@ function settlements.place_schematics(settlement_info, pr) -- build foundation for the building an make room above -- place schematic mcl_structures.place_schematic( - pos, - schematic, - rotation, - nil, + pos, + schematic, + rotation, + nil, true, nil, init_nodes, diff --git a/mods/MAPGEN/mcl_villages/const.lua b/mods/MAPGEN/mcl_villages/const.lua index 4e2b39136b..6621dbf3a3 100644 --- a/mods/MAPGEN/mcl_villages/const.lua +++ b/mods/MAPGEN/mcl_villages/const.lua @@ -8,15 +8,15 @@ end --[[ Manually set in 'buildings.lua' -- material to replace cobblestone with wallmaterial = { - "mcl_core:junglewood", - "mcl_core:sprucewood", - "mcl_core:wood", - "mcl_core:birchwood", - "mcl_core:acaciawood", - "mcl_core:stonebrick", - "mcl_core:cobble", - "mcl_core:sandstonecarved", - "mcl_core:sandstone", + "mcl_core:junglewood", + "mcl_core:sprucewood", + "mcl_core:wood", + "mcl_core:birchwood", + "mcl_core:acaciawood", + "mcl_core:stonebrick", + "mcl_core:cobble", + "mcl_core:sandstonecarved", + "mcl_core:sandstone", "mcl_core:sandstonesmooth2" } --]] @@ -78,4 +78,4 @@ max_height_difference = 56 -- -- half_map_chunk_size = 40 -quarter_map_chunk_size = 20 +--quarter_map_chunk_size = 20 diff --git a/mods/MAPGEN/tsm_railcorridors/init.lua b/mods/MAPGEN/tsm_railcorridors/init.lua index 893f3d7396..2414cc9626 100644 --- a/mods/MAPGEN/tsm_railcorridors/init.lua +++ b/mods/MAPGEN/tsm_railcorridors/init.lua @@ -823,7 +823,7 @@ local function create_corridor_line(waypoint, axis, sign, length, wood, post, da local s = sign local ud = false -- Up or down local udn = false -- Up or down is next - local udp = false -- Up or down was previous + local udp -- Up or down was previous local up = false -- true if going up local upp = false -- true if was going up previously for i=1,length do @@ -911,7 +911,7 @@ local function create_corridor_line(waypoint, axis, sign, length, wood, post, da a="z" elseif a=="z" then a="x" - end; + end; s = pr:next(1, 2) == 1 end end diff --git a/mods/MISC/findbiome/init.lua b/mods/MISC/findbiome/init.lua index ce7fd97990..5f55da493d 100644 --- a/mods/MISC/findbiome/init.lua +++ b/mods/MISC/findbiome/init.lua @@ -119,7 +119,7 @@ local function find_biome(pos, biomes) local edge_dist = 0 local dir_step = 0 local dir_ind = 1 - local success = false + local success local spawn_pos local biome_ids @@ -166,7 +166,7 @@ local function find_biome(pos, biomes) spawn_pos = {x = spos.x, y = spos.y, z = spos.z} end if spawn_pos then - local adjusted_pos, outside = adjust_pos_to_biome_limits(spawn_pos, biome_id) + local _,outside = adjust_pos_to_biome_limits(spawn_pos, biome_id) if is_in_world(spawn_pos) and not outside then return true end diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 5cca23d320..8dad7b2c5b 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -22,7 +22,6 @@ local math = math -- Internal player state local mcl_playerplus_internal = {} -local def = {} local time = 0 local look_pitch = 0 @@ -376,9 +375,6 @@ minetest.register_globalstep(function(dtime) return end - -- set defaults - def.speed = 1 - -- Standing on soul sand? If so, walk slower (unless player wears Soul Speed boots) if node_stand == "mcl_nether:soul_sand" then -- TODO: Tweak walk speed diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index fe88cf3de6..441db28b7c 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -500,10 +500,8 @@ function mcl_spawn.shadow_worker() if success then local wsp_node = minetest.get_node(wsp) - if wsp_node and wsp_node.name == "ignore" then - -- special case - respawn area unloaded from memory - it's okay, skip for now - - elseif ((not good_for_respawn(wsp)) or ((no_trees_area_counter >= 0) and not can_find_tree(wsp))) then + if not (wsp_node and wsp_node.name == "ignore") + and ((not good_for_respawn(wsp)) or ((no_trees_area_counter >= 0) and not can_find_tree(wsp))) then success = false minetest.log("action", "[mcl_spawn] World spawn position isn't safe anymore: "..minetest.pos_to_string(wsp)) mcl_spawn.search() From 22a2fdbf5fca5bee14ac5ee23fa325610853ab37 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 17 Apr 2021 07:46:24 +0200 Subject: [PATCH 17/38] fix more codestyle --- mods/MAPGEN/mcl_structures/init.lua | 13 ++++++------- mods/MAPGEN/mcl_villages/buildings.lua | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index b7afd18bbe..e3f6b48298 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -110,7 +110,8 @@ mcl_structures.generate_igloo = function(pos, rotation, pr) if r == 1 then -- Select basement depth local dim = mcl_worlds.pos_to_dimension(pos) - local buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10) + --local buffer = pos.y - (mcl_vars.mg_lava_overworld_max + 10) + local buffer if dim == "nether" then buffer = pos.y - (mcl_vars.mg_lava_nether_max + 10) elseif dim == "end" then @@ -219,7 +220,7 @@ local function igloo_placement_callback(p1, p2, size, orientation, pr) else return end - local size = {x=9,y=5,z=7} + --local size = {x=9,y=5,z=7} local lootitems = mcl_loot.get_multi_loot({ { stacks_min = 1, @@ -335,7 +336,7 @@ local function shrine_placement_callback(p1, p2, size, rotation, pr) -- Find and setup spawner with silverfish local spawners = minetest.find_nodes_in_area(p1, p2, "mcl_mobspawners:spawner") for s=1, #spawners do - local meta = minetest.get_meta(spawners[s]) + --local meta = minetest.get_meta(spawners[s]) mcl_mobspawners.setup_spawner(spawners[s], "mobs_mc:silverfish") end @@ -411,7 +412,7 @@ end mcl_structures.generate_end_portal_shrine = function(pos, rotation, pr) local offset = {x=6, y=4, z=6} - local size = {x=13, y=8, z=13} + --local size = {x=13, y=8, z=13} local newpos = { x = pos.x - offset.x, y = pos.y, z = pos.z - offset.z } local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_portal_room_simple.mts" @@ -471,8 +472,6 @@ local function temple_placement_callback(p1, p2, size, rotation, pr) { itemstring = "mcl_mobitems:string", weight = 10, amount_min = 1, amount_max = 8 }, } }}, pr) - - local meta = minetest.get_meta(chests[c]) init_node_construct(chests[c]) local meta = minetest.get_meta(chests[c]) local inv = meta:get_inventory() @@ -498,7 +497,7 @@ mcl_structures.generate_desert_temple = function(pos, rotation, pr) -- No Generating for the temple ... Why using it ? No Change local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_temple.mts" local newpos = {x=pos.x,y=pos.y-12,z=pos.z} - local size = {x=22, y=24, z=22} + --local size = {x=22, y=24, z=22} if newpos == nil then return end diff --git a/mods/MAPGEN/mcl_villages/buildings.lua b/mods/MAPGEN/mcl_villages/buildings.lua index e917638dbc..9d8e7580fe 100644 --- a/mods/MAPGEN/mcl_villages/buildings.lua +++ b/mods/MAPGEN/mcl_villages/buildings.lua @@ -84,7 +84,7 @@ function settlements.create_site_plan(maxp, minp, pr) x=math.floor((minp.x+maxp.x)/2), y=maxp.y, z=math.floor((minp.z+maxp.z)/2) - } + } -- find center_surface of chunk local center_surface , surface_material = settlements.find_surface(center, true) local chunks = {} From 02f393998ff6893f958f9a9e5034f74ff35c9bad Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 17 Apr 2021 09:26:37 +0200 Subject: [PATCH 18/38] fix many warnings (644 remaining) --- .luacheckrc | 2 +- mods/ITEMS/mcl_potions/init.lua | 13 ++++--------- mods/ITEMS/mcl_potions/potions.lua | 4 ++-- mods/ITEMS/mcl_potions/splash.lua | 4 ++-- mods/ITEMS/mcl_potions/tipped_arrow.lua | 7 +++---- mods/ITEMS/mcl_signs/init.lua | 6 +++--- mods/ITEMS/mcl_stairs/api.lua | 6 ++++-- mods/ITEMS/mcl_throwing/register.lua | 2 +- mods/ITEMS/mcl_torches/api.lua | 2 +- mods/MAPGEN/mcl_dungeons/init.lua | 12 +++++------- mods/MAPGEN/mcl_mapgen_core/init.lua | 24 ++++++++++++------------ 11 files changed, 38 insertions(+), 44 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index f36a4a37b2..556b2e8f0f 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -12,7 +12,7 @@ read_globals = { "dump", "dump2", "vector", "VoxelManip", "VoxelArea", - "PseudoRandom", "PcgRandom", "PerlinNoise", + "PseudoRandom", "PcgRandom", "PerlinNoise", "PerlinNoiseMap", "ItemStack", "Settings", "unpack", diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index 65bb0d4de5..6cfa0dc509 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -25,11 +25,9 @@ dofile(modpath .. "/lingering.lua") dofile(modpath .. "/tipped_arrow.lua") dofile(modpath .. "/potions.lua") -local brewhelp = S("Try different combinations to create potions.") - minetest.register_craftitem("mcl_potions:fermented_spider_eye", { description = S("Fermented Spider Eye"), - _doc_items_longdesc = brewhelp, + _doc_items_longdesc = S("Try different combinations to create potions."), wield_image = "mcl_potions_spider_eye_fermented.png", inventory_image = "mcl_potions_spider_eye_fermented.png", groups = { brewitem = 1, }, @@ -65,14 +63,12 @@ minetest.register_craftitem("mcl_potions:glass_bottle", { -- Try to fill glass bottle with water local get_water = false - local from_liquid_source = false + --local from_liquid_source = false local river_water = false - if not def then - -- Unknown node: no-op - elseif def.groups and def.groups.water and def.liquidtype == "source" then + if def and def.groups and def.groups.water and def.liquidtype == "source" then -- Water source get_water = true - from_liquid_source = true + --from_liquid_source = true river_water = node.name == "mclx_core:river_water_source" -- Or reduce water level of cauldron by 1 elseif string.sub(node.name, 1, 14) == "mcl_cauldrons:" then @@ -440,7 +436,6 @@ function mcl_potions.get_alchemy(ingr, pot) if brew_table[ingr] ~= nil then return brew_table[ingr] end - end if mod_table[ingr] ~= nil then diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index 4a82348e55..2d76a217b0 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -1,5 +1,5 @@ local S = minetest.get_translator("mcl_potions") -local brewhelp = S("Try different combinations to create potions.") +--local brewhelp = S("Try different combinations to create potions.") local potion_image = function(colorstring, opacity) if not opacity then @@ -98,7 +98,7 @@ local function register_potion(def) end elseif def.name == "healing" or def.name == "harming" then _tt = S("@1 HP", effect) - else + else _tt = tt or time_string(dur) or S("No effect") end return _tt diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index bea07b8cf4..f986134d67 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -123,6 +123,6 @@ function mcl_potions.register_splash(name, descr, color, def) }) end -local function time_string(dur) +--[[local function time_string(dur) return math.floor(dur/60)..string.format(":%02d",math.floor(dur % 60)) -end +end]] diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index 860019e8ad..abeae81063 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -4,12 +4,12 @@ local ARROW_TIMEOUT = 60 -- Time after which stuck arrow is rechecked for being stuck local STUCK_RECHECK_TIME = 5 -local GRAVITY = 9.81 +--local GRAVITY = 9.81 local YAW_OFFSET = -math.pi/2 local dir_to_pitch = function(dir) - local dir2 = vector.normalize(dir) + --local dir2 = vector.normalize(dir) local xz = math.abs(dir.x) + math.abs(dir.z) return -math.atan2(-dir.y, xz) end @@ -197,7 +197,6 @@ function mcl_potions.register_arrow(name, desc, color, def) glow = 1, }) end - -- We just check for any hurtable objects nearby. -- The radius of 3 is fairly liberal, but anything lower than than will cause -- arrow to hilariously go through mobs often. @@ -360,7 +359,7 @@ function mcl_potions.register_arrow(name, desc, color, def) if not v then v = 0 end - local old_v = self._viscosity + --local old_v = self._viscosity self._viscosity = v local vpenalty = math.max(0.1, 0.98 - 0.1 * v) if math.abs(vel.x) > 0.001 then diff --git a/mods/ITEMS/mcl_signs/init.lua b/mods/ITEMS/mcl_signs/init.lua index e053c6e822..be9db2feec 100644 --- a/mods/ITEMS/mcl_signs/init.lua +++ b/mods/ITEMS/mcl_signs/init.lua @@ -93,7 +93,7 @@ local generate_line = function(s, ypos) local chars = 0 local printed_char_width = CHAR_WIDTH + 1 while chars < LINE_LENGTH and i <= #s do - local file = nil + local file -- Get and render character if charmap[s:sub(i, i)] ~= nil then file = charmap[s:sub(i, i)] @@ -185,7 +185,7 @@ local function get_wall_signtext_info(param2, nodename) end end -local sign_groups = {handy=1,axey=1, flammable=1, deco_block=1, material_wood=1, attached_node=1, dig_by_piston=1, flammable=-1} +local sign_groups = {handy=1,axey=1, deco_block=1, material_wood=1, attached_node=1, dig_by_piston=1, flammable=-1} local destruct_sign = function(pos) local objects = minetest.get_objects_inside_radius(pos, 0.5) @@ -322,7 +322,7 @@ minetest.register_node("mcl_signs:wall_sign", { local wdir = minetest.dir_to_wallmounted(dir) - local placer_pos = placer:get_pos() + --local placer_pos = placer:get_pos() local fdir = minetest.dir_to_facedir(dir) diff --git a/mods/ITEMS/mcl_stairs/api.lua b/mods/ITEMS/mcl_stairs/api.lua index aecf108361..cca54226fa 100644 --- a/mods/ITEMS/mcl_stairs/api.lua +++ b/mods/ITEMS/mcl_stairs/api.lua @@ -20,7 +20,7 @@ local function place_slab_normal(itemstack, placer, pointed_thing) local p0 = pointed_thing.under local p1 = pointed_thing.above - local placer_pos = placer:get_pos() + --local placer_pos = placer:get_pos() local fpos = get_fpos(placer, pointed_thing) @@ -179,7 +179,7 @@ end -- Slab facedir to placement 6d matching table -local slab_trans_dir = {[0] = 8, 0, 2, 1, 3, 4} +--local slab_trans_dir = {[0] = 8, 0, 2, 1, 3, 4} -- Register slabs. -- Node will be called mcl_stairs:slab_ @@ -268,6 +268,7 @@ function mcl_stairs.register_slab(subname, recipeitem, groups, images, descripti end end, _mcl_hardness = hardness, + _mcl_blast_resistance = blast_resistance, _mcl_other_slab_half = upper_slab, on_rotate = function(pos, node, user, mode, param2) -- Flip slab @@ -331,6 +332,7 @@ function mcl_stairs.register_slab(subname, recipeitem, groups, images, descripti sounds = sounds, drop = lower_slab .. " 2", _mcl_hardness = hardness, + _mcl_blast_resistance = blast_resistance, }) if recipeitem then diff --git a/mods/ITEMS/mcl_throwing/register.lua b/mods/ITEMS/mcl_throwing/register.lua index 3d8cc94cfa..c2af9717fa 100644 --- a/mods/ITEMS/mcl_throwing/register.lua +++ b/mods/ITEMS/mcl_throwing/register.lua @@ -224,7 +224,7 @@ local pearl_on_step = function(self, dtime) lv, ld = math.abs(vc.x), "x" end if math.abs(vc.z) > lv then - lv, ld = math.abs(vc.z), "z" + ld = "z" --math.abs(vc.z) end if ld ~= "x" then vc.x = 0 end if ld ~= "y" then vc.y = 0 end diff --git a/mods/ITEMS/mcl_torches/api.lua b/mods/ITEMS/mcl_torches/api.lua index 3044888054..c98bda3d99 100644 --- a/mods/ITEMS/mcl_torches/api.lua +++ b/mods/ITEMS/mcl_torches/api.lua @@ -30,7 +30,7 @@ local spawn_flames_floor = function(pos) end local spawn_flames_wall = function(pos) - local minrelpos, maxrelpos + --local minrelpos, maxrelpos local node = minetest.get_node(pos) local dir = minetest.wallmounted_to_dir(node.param2) diff --git a/mods/MAPGEN/mcl_dungeons/init.lua b/mods/MAPGEN/mcl_dungeons/init.lua index 928faaa11a..58e23b12e4 100644 --- a/mods/MAPGEN/mcl_dungeons/init.lua +++ b/mods/MAPGEN/mcl_dungeons/init.lua @@ -49,12 +49,12 @@ local dungeonsizes = { { x=7, y=4, z=7}, } -local dirs = { +--[[local dirs = { { x= 1, y=0, z= 0 }, { x= 0, y=0, z= 1 }, { x=-1, y=0, z= 0 }, { x= 0, y=0, z=-1 }, -} +}]] local surround_vectors = { { x=-1, y=0, z=0 }, @@ -66,7 +66,7 @@ local surround_vectors = { local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param) if calls_remaining >= 1 then return end - local p1, p2, dim, pr = param.p1, param.p2, param.dim, param.pr + local p1, _, dim, pr = param.p1, param.p2, param.dim, param.pr local x, y, z = p1.x, p1.y, p1.z local check = not (param.dontcheck or false) @@ -404,8 +404,7 @@ local function dungeons_nodes(minp, maxp, blockseed) local p1 = {x=x,y=y,z=z} local p2 = {x = x+dim.x+1, y = y+dim.y+1, z = z+dim.z+1} minetest.log("verbose","[mcl_dungeons] size=" ..minetest.pos_to_string(dim) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2)) - local param = {p1=p1, p2=p2, dim=dim, pr=pr} - emerge_area(p1, p2, ecb_spawn_dungeon, param) + emerge_area(p1, p2, ecb_spawn_dungeon, {p1=p1, p2=p2, dim=dim, pr=pr}) end end @@ -414,8 +413,7 @@ function mcl_dungeons.spawn_dungeon(p1, _, pr) local dim = dungeonsizes[pr:next(1, #dungeonsizes)] local p2 = {x = p1.x+dim.x+1, y = p1.y+dim.y+1, z = p1.z+dim.z+1} minetest.log("verbose","[mcl_dungeons] size=" ..minetest.pos_to_string(dim) .. ", emerge from "..minetest.pos_to_string(p1) .. " to " .. minetest.pos_to_string(p2)) - local param = {p1=p1, p2=p2, dim=dim, pr=pr, dontcheck=true} - emerge_area(p1, p2, ecb_spawn_dungeon, param) + emerge_area(p1, p2, ecb_spawn_dungeon, {p1=p1, p2=p2, dim=dim, pr=pr, dontcheck=true}) end mcl_mapgen_core.register_generator("dungeons", nil, dungeons_nodes, 999999) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 1ee861e4a2..90b2725067 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -65,21 +65,21 @@ local c_dirt = minetest.get_content_id("mcl_core:dirt") local c_dirt_with_grass = minetest.get_content_id("mcl_core:dirt_with_grass") local c_dirt_with_grass_snow = minetest.get_content_id("mcl_core:dirt_with_grass_snow") local c_sand = minetest.get_content_id("mcl_core:sand") -local c_sandstone = minetest.get_content_id("mcl_core:sandstone") +--local c_sandstone = minetest.get_content_id("mcl_core:sandstone") local c_void = minetest.get_content_id("mcl_core:void") local c_lava = minetest.get_content_id("mcl_core:lava_source") local c_water = minetest.get_content_id("mcl_core:water_source") local c_soul_sand = minetest.get_content_id("mcl_nether:soul_sand") local c_netherrack = minetest.get_content_id("mcl_nether:netherrack") local c_nether_lava = minetest.get_content_id("mcl_nether:nether_lava_source") -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 c_realm_barrier = minetest.get_content_id("mcl_core:realm_barrier") local c_top_snow = minetest.get_content_id("mcl_core:snow") local c_snow_block = minetest.get_content_id("mcl_core:snowblock") local c_clay = minetest.get_content_id("mcl_core:clay") local c_leaves = minetest.get_content_id("mcl_core:leaves") local c_jungleleaves = minetest.get_content_id("mcl_core:jungleleaves") -local c_jungletree = minetest.get_content_id("mcl_core:jungletree") +--local c_jungletree = minetest.get_content_id("mcl_core:jungletree") local c_cocoa_1 = minetest.get_content_id("mcl_cocoas:cocoa_1") local c_cocoa_2 = minetest.get_content_id("mcl_cocoas:cocoa_2") local c_cocoa_3 = minetest.get_content_id("mcl_cocoas:cocoa_3") @@ -1169,13 +1169,13 @@ end -- minp and maxp (from an on_generated callback) and returns the real world coordinates -- as X, Z. -- Inverse function of xz_to_biomemap -local biomemap_to_xz = function(index, minp, maxp) +--[[local biomemap_to_xz = function(index, minp, maxp) local xwidth = maxp.x - minp.x + 1 local zwidth = maxp.z - minp.z + 1 local x = ((index-1) % xwidth) + minp.x local z = ((index-1) / zwidth) + minp.z return x, z -end +end]] -- Takes x and z coordinates and minp and maxp of a generated chunk -- (in on_generated callback) and returns a biomemap index) @@ -1897,7 +1897,7 @@ function mcl_mapgen_core.unregister_generator(id) local rec = registered_generators[id] registered_generators[id] = nil if rec.vf then lvm = lvm - 1 end - if rev.nf then nodes = nodes - 1 end + if rec.nf then nodes = nodes - 1 end if rec.needs_param2 then param2 = param2 - 1 end if rec.needs_level0 then level0 = level0 - 1 end end @@ -1979,7 +1979,7 @@ end -- Below the bedrock, generate air/void local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) - local biomemap, ymin, ymax + local biomemap --ymin, ymax local lvm_used = false local pr = PseudoRandom(blockseed) @@ -2077,7 +2077,7 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local n = nodes[n] local p_pos = area:index(n.x, n.y, n.z) local p_pos_above = area:index(n.x, n.y+1, n.z) - local p_pos_below = area:index(n.x, n.y-1, n.z) + --local p_pos_below = area:index(n.x, n.y-1, n.z) local b_pos = aream:index(n.x, 0, n.z) local bn = minetest.get_biome_name(biomemap[b_pos]) if bn then @@ -2126,7 +2126,7 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) -- * Remove stone, sand, dirt in v6 so our End map generator works in v6. -- * Generate spawn platform (End portal destination) elseif minp.y <= mcl_vars.mg_end_max and maxp.y >= mcl_vars.mg_end_min then - local nodes, n + local nodes if mg_name == "v6" then nodes = minetest.find_nodes_in_area(emin, emax, {"mcl_core:water_source", "mcl_core:stone", "mcl_core:sand", "mcl_core:dirt"}) else @@ -2134,7 +2134,7 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) end if #nodes > 0 then lvm_used = true - for _, n in pairs(nodes) do + for _,n in pairs(nodes) do data[area:index(n.x, n.y, n.z)] = c_air end end @@ -2144,8 +2144,8 @@ local function basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) minp.x <= mcl_vars.mg_end_platform_pos.x and maxp.x >= mcl_vars.mg_end_platform_pos.z and minp.z <= mcl_vars.mg_end_platform_pos.z and maxp.z >= mcl_vars.mg_end_platform_pos.z then - local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} - local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} + --local pos1 = {x = math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), y = math.max(minp.y, mcl_vars.mg_end_platform_pos.y), z = math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2)} + --local pos2 = {x = math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2), y = math.min(maxp.y, mcl_vars.mg_end_platform_pos.y+2), z = math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2)} for x=math.max(minp.x, mcl_vars.mg_end_platform_pos.x-2), math.min(maxp.x, mcl_vars.mg_end_platform_pos.x+2) do for z=math.max(minp.z, mcl_vars.mg_end_platform_pos.z-2), math.min(maxp.z, mcl_vars.mg_end_platform_pos.z+2) do From 06699c2cc4b62a0bde7c4d8c1bd09e48c6c85323 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sat, 17 Apr 2021 11:55:50 +0000 Subject: [PATCH 19/38] Fix that an ax wears out if you right-click another block --- mods/ITEMS/mcl_tools/init.lua | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index fa5352c2cc..3aebafb7bc 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -352,7 +352,14 @@ minetest.register_tool("mcl_tools:shovel_diamond", { }) -- Axes - +local make_stripped_trunk_add_wear = function(itemstack, placer) + if not minetest.is_creative_enabled(placer:get_player_name()) then + -- Add wear (as if digging a axey node) + local toolname = itemstack:get_name() + local wear = mcl_autogroup.get_wear(toolname, "axey") + itemstack:add_wear(wear) + end +end local make_stripped_trunk = function(itemstack, placer, pointed_thing) if pointed_thing.type == "node" then local pos = minetest.get_pointed_thing_position(pointed_thing) @@ -367,36 +374,42 @@ local make_stripped_trunk = function(itemstack, placer, pointed_thing) minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) return itemstack end - if not minetest.is_creative_enabled(placer:get_player_name()) then - -- Add wear (as if digging a axey node) - local toolname = itemstack:get_name() - local wear = mcl_autogroup.get_wear(toolname, "axey") - itemstack:add_wear(wear) - end if node_name == "mcl_core:tree" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:darktree" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:acaciatree" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:birchtree" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:sprucetree" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:jungletree" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:tree_bark" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak_bark"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:darktree_bark" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak_bark"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:acaciatree_bark" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia_bark"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:birchtree_bark" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch_bark"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:sprucetree_bark" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce_bark"}) + make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:jungletree_bark" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle_bark"}) + make_stripped_trunk_add_wear(itemstack, placer) end end return itemstack From 5c928575f87980c20a0403033acae373d3ef7857 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 17 Apr 2021 18:15:45 +0200 Subject: [PATCH 20/38] Fix #1572, server crash during login --- mods/PLAYER/mcl_playerplus/init.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 8dad7b2c5b..b14d348243 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -183,10 +183,11 @@ minetest.register_globalstep(function(dtime) player_vel_yaw = limit_vel_yaw(player_vel_yaw, yaw) player_vel_yaws[name] = player_vel_yaw - if minetest.get_node_or_nil({x=player:get_pos().x, y=player:get_pos().y - 0.5, z=player:get_pos().z}) then - node_stand_return = minetest.get_node_or_nil({x=player:get_pos().x, y=player:get_pos().y - 0.1, z=player:get_pos().z}).name - else - minetest.log("action", "somehow player got of loaded areas") + local pos = player:get_pos() + local node = minetest.get_node_or_nil({x = pos.x, y = pos.y - 0.5, z = pos.z}) + + if node then + node_stand_return = node.name end local chestplate = player:get_inventory():get_stack("armor", 3) From f8b54db3929206b4c826533aad035f1c71cc7b89 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 17 Apr 2021 18:55:56 +0200 Subject: [PATCH 21/38] Fix controls.register_on_press being called for every player in a globalstep --- mods/PLAYER/mcl_playerplus/init.lua | 51 +++++++++++++---------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index b14d348243..65c585f522 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -199,22 +199,7 @@ minetest.register_globalstep(function(dtime) end end - - controls.register_on_press(function(player, key) - if key~="jump" and key~="RMB" then return end - if key=="jump" then - if player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" and player_velocity.y < -6 and elytra[player] ~= true then - elytra[player] = true - elseif key=="RMB" then - if wielded:get_name() == "mcl_tools:rocket" then - wielded:take_item() - player:set_wielded_item(wielded) - end - end - end - end) - - if elytra[player] == true and node_stand_return ~= "air" or elytra[player] == true and player:get_inventory():get_stack("armor", 3):get_name() ~= "mcl_armor:elytra" or player:get_attach() ~= nil then + if elytra[player] == true and ~= nil then elytra[player] = false end --[[ @@ -224,21 +209,29 @@ minetest.register_globalstep(function(dtime) elytra[player] = false end]] - if elytra[player] == true then - mcl_player.player_set_animation(player, "fly") - playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1) - if player_velocity.y < -1.5 then - player:add_velocity({x=0, y=0.17, z=0}) - end - if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then - local dir = minetest.yaw_to_dir(player:get_look_horizontal()) - if degrees(player:get_look_vertical()) * -.01 < .1 then - look_pitch = degrees(player:get_look_vertical()) * -.01 - else - look_pitch = .1 + local wearing_elytra = player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" + + if elytra[player] then + if node_stand_return ~= "air" or not wearing_elytra or player:get_attach() then + elytra[player] = false + else + mcl_player.player_set_animation(player, "fly") + playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1) + if player_velocity.y < -1.5 then + player:add_velocity({x=0, y=0.17, z=0}) + end + if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then + local dir = minetest.yaw_to_dir(player:get_look_horizontal()) + if degrees(player:get_look_vertical()) * -.01 < .1 then + look_pitch = degrees(player:get_look_vertical()) * -.01 + else + look_pitch = .1 + end + player:add_velocity({x=dir.x, y=look_pitch, z=dir.z}) end - player:add_velocity({x=dir.x, y=look_pitch, z=dir.z}) end + elseif wearing_elytra and player_velocity.y < -6 and controls.jump then + elytra[player] = true else playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra") end From 205572cc693cde98fc7f3bed890d61f449627ee5 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 17 Apr 2021 19:34:23 +0200 Subject: [PATCH 22/38] Fix elytra code style --- mods/ITEMS/mcl_fireworks/register.lua | 85 +++++++-------------------- mods/PLAYER/mcl_playerplus/init.lua | 83 +++++++++++--------------- 2 files changed, 57 insertions(+), 111 deletions(-) diff --git a/mods/ITEMS/mcl_fireworks/register.lua b/mods/ITEMS/mcl_fireworks/register.lua index cce36042ab..08f07c5cbe 100644 --- a/mods/ITEMS/mcl_fireworks/register.lua +++ b/mods/ITEMS/mcl_fireworks/register.lua @@ -1,69 +1,28 @@ local S = minetest.get_translator("mcl_fireworks") -player_rocketing = {} +local player_rocketing = {} -local help = S("Flight Duration:") +local tt_help = S("Flight Duration:") local description = S("Firework Rocket") -local rocket_sound = function() - minetest.sound_play("mcl_fireworks_rocket") + +local function register_rocket(n, duration, force) + minetest.register_craftitem("mcl_fireworks:rocket_" .. n, { + description = description, + _tt_help = tt_help .. " " .. duration, + inventory_image = "mcl_fireworks_rocket.png", + stack_max = 64, + on_use = function(itemstack, user, pointed_thing) + local elytra = mcl_playerplus.elytra[user] + if elytra.active and elytra.rocketing <= 0 then + elytra.rocketing = duration + itemstack:take_item() + minetest.sound_play("mcl_fireworks_rocket", {pos = user:get_pos()}) + end + return itemstack + end, + }) end -minetest.register_craftitem("mcl_fireworks:rocket_1", { - description = description, - _tt_help = help.." 1", - inventory_image = "mcl_fireworks_rocket.png", - stack_max = 64, - on_use = function(itemstack, user, pointed_thing) - local torso = user:get_inventory():get_stack("armor", 3) - if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then - player_rocketing[user] = true - minetest.after(2.2, function() - player_rocketing[user] = false - end) - itemstack:take_item() - --user:add_player_velocity(vector.multiply(user:get_look_dir(), 20)) - rocket_sound() - end - return itemstack - end, -}) - -minetest.register_craftitem("mcl_fireworks:rocket_2", { - description = description, - _tt_help = help.." 2", - inventory_image = "mcl_fireworks_rocket.png", - stack_max = 64, - on_use = function(itemstack, user, pointed_thing) - local torso = user:get_inventory():get_stack("armor", 3) - if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then - player_rocketing[user] = true - minetest.after(4.5, function() - player_rocketing[user] = false - end) - itemstack:take_item() - --user:add_player_velocity(vector.multiply(user:get_look_dir(), 20)) - rocket_sound() - end - return itemstack - end, -}) - -minetest.register_craftitem("mcl_fireworks:rocket_3", { - description = description, - _tt_help = help.." 3", - inventory_image = "mcl_fireworks_rocket.png", - stack_max = 64, - on_use = function(itemstack, user, pointed_thing) - local torso = user:get_inventory():get_stack("armor", 3) - if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then - player_rocketing[user] = true - minetest.after(6, function() - player_rocketing[user] = false - end) - itemstack:take_item() - --user:add_player_velocity(vector.multiply(user:get_look_dir(), 20)) - rocket_sound() - end - return itemstack - end, -}) +register_rocket(1, 2.2, 10) +register_rocket(2, 4.5, 20) +register_rocket(3, 6, 30) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 65c585f522..38844a1e12 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -1,8 +1,9 @@ local S = minetest.get_translator("mcl_playerplus") -elytra = {} +mcl_playerplus = { + elytra = {}, +} -local node_stand_return = ":air" local get_connected_players = minetest.get_connected_players local dir_to_yaw = minetest.dir_to_yaw local get_item_group = minetest.get_item_group @@ -183,56 +184,40 @@ minetest.register_globalstep(function(dtime) player_vel_yaw = limit_vel_yaw(player_vel_yaw, yaw) player_vel_yaws[name] = player_vel_yaw - local pos = player:get_pos() - local node = minetest.get_node_or_nil({x = pos.x, y = pos.y - 0.5, z = pos.z}) + local fly_pos = player:get_pos() + local fly_node = minetest.get_node({x = fly_pos.x, y = fly_pos.y - 0.5, z = fly_pos.z}).name + local elytra = mcl_playerplus.elytra[player] - if node then - node_stand_return = node.name - end + elytra.active = player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" + and not player:get_attach() + and (elytra.active or control.jump and player_velocity.y < -6) + and (fly_node == "air" or fly_node == "ignore") - local chestplate = player:get_inventory():get_stack("armor", 3) - - if player_rocketing[player] and player_rocketing[player] == true and chestplate:get_name() == "mcl_armor:elytra" then - if math.abs(player_velocity.x) + math.abs(player_velocity.y) + math.abs(player_velocity.z) < 40 then - player:add_player_velocity(vector.multiply(player:get_look_dir(), 4)) - elytra[player] = true + if elytra.active then + mcl_player.player_set_animation(player, "fly") + if player_velocity.y < -1.5 then + player:add_velocity({x=0, y=0.17, z=0}) end - end - - if elytra[player] == true and ~= nil then - elytra[player] = false - end ---[[ - if player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" and player_velocity.y < -6 and elytra[player] ~= true and is_sprinting(name) then - elytra[player] = true - elseif elytra[player] == true and node_stand_return ~= "air" or elytra[player] == true and player:get_inventory():get_stack("armor", 3):get_name() ~= "mcl_armor:elytra" or player:get_attach() ~= nil then - elytra[player] = false - end]] - - local wearing_elytra = player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" - - if elytra[player] then - if node_stand_return ~= "air" or not wearing_elytra or player:get_attach() then - elytra[player] = false - else - mcl_player.player_set_animation(player, "fly") - playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1) - if player_velocity.y < -1.5 then - player:add_velocity({x=0, y=0.17, z=0}) + if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then + local dir = minetest.yaw_to_dir(player:get_look_horizontal()) + if degrees(player:get_look_vertical()) * -.01 < .1 then + look_pitch = degrees(player:get_look_vertical()) * -.01 + else + look_pitch = .1 end - if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then - local dir = minetest.yaw_to_dir(player:get_look_horizontal()) - if degrees(player:get_look_vertical()) * -.01 < .1 then - look_pitch = degrees(player:get_look_vertical()) * -.01 - else - look_pitch = .1 - end - player:add_velocity({x=dir.x, y=look_pitch, z=dir.z}) + player:add_velocity({x=dir.x, y=look_pitch, z=dir.z}) + end + playerphysics.add_physics_factor(player, "gravity", "mcl_playerplus:elytra", 0.1) + + if elytra.rocketing > 0 then + elytra.rocketing = elytra.rocketing - dtime + if vector.length(player_velocity) < 40 then + local add_velocity = player.add_velocity or player.add_player_velocity + add_velocity(player, vector.multiply(player:get_look_dir(), 4)) end end - elseif wearing_elytra and player_velocity.y < -6 and controls.jump then - elytra[player] = true else + elytra.rocketing = 0 playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra") end @@ -254,12 +239,12 @@ minetest.register_globalstep(function(dtime) player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(0,0,0)) end - if elytra[player] == true then - -- set head pitch and yaw when swimming + if elytra.active then + -- set head pitch and yaw when flying player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) -- sets eye height, and nametag color accordingly player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) - -- control body bone when swimming + -- control body bone when flying player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0)) elseif parent then local parent_yaw = degrees(parent:get_yaw()) @@ -523,6 +508,7 @@ minetest.register_on_joinplayer(function(player) swimDistance = 0, jump_cooldown = -1, -- Cooldown timer for jumping, we need this to prevent the jump exhaustion to increase rapidly } + mcl_playerplus.elytra[player] = {active = false, rocketing = 0} end) -- clear when player leaves @@ -530,4 +516,5 @@ minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() mcl_playerplus_internal[name] = nil + mcl_playerplus.elytra[player] = nil end) From 48a2e4212a78c9ce01a6feb3fcefe77088603cfb Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 17 Apr 2021 20:55:08 +0200 Subject: [PATCH 23/38] Fix namtags being invisible --- mods/PLAYER/mcl_playerplus/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 38844a1e12..360f4fe5de 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -243,12 +243,12 @@ minetest.register_globalstep(function(dtime) -- set head pitch and yaw when flying player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) -- sets eye height, and nametag color accordingly - player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) + player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) -- control body bone when flying player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0)) elseif parent then local parent_yaw = degrees(parent:get_yaw()) - player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) + player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0)) elseif control.sneak then @@ -262,12 +262,12 @@ minetest.register_globalstep(function(dtime) -- set head pitch and yaw when swimming player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) -- sets eye height, and nametag color accordingly - player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,0.8,0.312}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) + player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,0.8,0.312}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) -- control body bone when swimming player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0)) else -- sets eye height, and nametag color accordingly - player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) + player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0)) From baebe3c2d2b80122ff4c413711213d7c3d19b5c9 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 17 Apr 2021 20:55:08 +0200 Subject: [PATCH 24/38] Fix namtags being invisible --- mods/PLAYER/mcl_playerplus/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 38844a1e12..360f4fe5de 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -243,12 +243,12 @@ minetest.register_globalstep(function(dtime) -- set head pitch and yaw when flying player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) -- sets eye height, and nametag color accordingly - player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) + player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) -- control body bone when flying player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0)) elseif parent then local parent_yaw = degrees(parent:get_yaw()) - player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) + player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0)) elseif control.sneak then @@ -262,12 +262,12 @@ minetest.register_globalstep(function(dtime) -- set head pitch and yaw when swimming player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0)) -- sets eye height, and nametag color accordingly - player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,0.8,0.312}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) + player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,0.8,0.312}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) -- control body bone when swimming player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0)) else -- sets eye height, and nametag color accordingly - player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) + player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0)) player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0)) From bcd058feb1c1cd4bd24086a99838d3aa8cce8526 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 17 Apr 2021 21:00:32 +0200 Subject: [PATCH 25/38] Fix get_light crash --- mods/ENTITIES/mcl_mobs/api.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 9182b11c63..1b5715b2aa 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1029,6 +1029,14 @@ local node_ok = function(pos, fallback) return minetest.registered_nodes[fallback] end +local function get_light(pos) + if math.abs(pos.x) < 31000 and math.abs(pos.y) < 31000 and math.abs(pos.z) < 31000 then + local lightfunc = minetest.get_natural_light or minetest.get_node_light + return lightfunc(pos) + else + return 0 + end +end -- environmental damage (water, lava, fire, light etc.) local do_env_damage = function(self) @@ -1074,7 +1082,6 @@ local do_env_damage = function(self) -- 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 From a7e102426a49bf1c60381621e65cdaa9e87bb6d5 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 17 Apr 2021 21:01:09 +0200 Subject: [PATCH 26/38] Add time_of_day to get_light crash fix --- 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 1b5715b2aa..8aed37288f 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1029,10 +1029,10 @@ local node_ok = function(pos, fallback) return minetest.registered_nodes[fallback] end -local function get_light(pos) +local function get_light(pos, tod) if math.abs(pos.x) < 31000 and math.abs(pos.y) < 31000 and math.abs(pos.z) < 31000 then local lightfunc = minetest.get_natural_light or minetest.get_node_light - return lightfunc(pos) + return lightfunc(pos, tod) else return 0 end From 11b66e83a26fa22ceb580d33ddfc5285faaa5dd3 Mon Sep 17 00:00:00 2001 From: kay27 Date: Sun, 18 Apr 2021 04:28:14 +0400 Subject: [PATCH 27/38] [mcl_portals] Better NP search, no more teleports on the roof, fix https://git.minetest.land/MineClone2/MineClone2/issues/1560 --- mods/ITEMS/mcl_portals/portal_nether.lua | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 1d9fe2efbe..a121f719c5 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -27,9 +27,8 @@ local DELAY = 3 -- seconds before teleporting in Nether portal in Survival mo local DISTANCE_MAX = 128 local PORTAL = "mcl_portals:portal" 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 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_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max, 2048) +local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_min - H_MIN -- Alpha and particles local node_particles_allowed = minetest.settings:get("mcl_node_particles") or "none" @@ -78,6 +77,8 @@ local pos_to_string = minetest.pos_to_string local is_area_protected = minetest.is_area_protected local get_us_time = minetest.get_us_time +local dimension_to_teleport = { nether = "overworld", overworld = "nether" } + local limits = { nether = { pmin = {x=LIM_MIN, y = N_Y_MIN, z = LIM_MIN}, @@ -181,10 +182,10 @@ local function get_target(p) x, o1 = ping_pong(x, TRAVEL_X, LIM_MIN, LIM_MAX) z, o2 = ping_pong(z, TRAVEL_Z, LIM_MIN, LIM_MAX) y = floor(y * TRAVEL_Y + (o1+o2) / 16 * LIM_MAX) - y = min(max(y + mcl_vars.mg_overworld_min, mcl_vars.mg_overworld_min), mcl_vars.mg_overworld_max) + y = min(max(y + O_Y_MIN, O_Y_MIN), O_Y_MAX) elseif d=="overworld" then x, y, z = floor(x / TRAVEL_X + 0.5), floor(y / TRAVEL_Y + 0.5), floor(z / TRAVEL_Z + 0.5) - y = min(max(y + mcl_vars.mg_nether_min, mcl_vars.mg_nether_min), mcl_vars.mg_nether_max) + y = min(max(y + N_Y_MIN, N_Y_MIN), N_Y_MAX) end return {x=x, y=y, z=z}, d end @@ -457,8 +458,8 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param) local nodes = find_nodes_in_area_under_air(pos1, pos2, {"group:building_block"}) if nodes then local nc = #nodes + log("action", "[mcl_portals] Area for destination Nether portal emerged! Found " .. tostring(nc) .. " nodes under the air around "..pos_to_string(pos)) if nc > 0 then - log("action", "[mcl_portals] Area for destination Nether portal emerged! Found " .. tostring(nc) .. " nodes under the air around "..pos_to_string(pos)) for i=1,nc do local node = nodes[i] local node1 = {x=node.x, y=node.y+1, z=node.z } @@ -474,7 +475,7 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param) return end if not distance or (distance0 < distance) or (distance0 < distance-1 and node.y > lava and pos0.y < lava) then - log("action", "[mcl_portals] found distance "..tostring(distance0).." at pos "..pos_to_string(node)) + log("verbose", "[mcl_portals] found distance "..tostring(distance0).." at pos "..pos_to_string(node)) distance = distance0 pos0 = {x=node1.x, y=node1.y, z=node1.z} end @@ -626,7 +627,7 @@ end -- Pos can be any of the inner part. -- The frame MUST be filled only with air or any fire, which will be replaced with Nether portal blocks. -- If no Nether portal can be lit, nothing happens. --- Returns number of portals created (0, 1 or 2) +-- Returns true if portal created function mcl_portals.light_nether_portal(pos) -- Only allow to make portals in Overworld and Nether local dim = mcl_worlds.pos_to_dimension(pos) @@ -636,11 +637,6 @@ function mcl_portals.light_nether_portal(pos) local orientation = random(0, 1) for orientation_iteration = 1, 2 do if check_and_light_shape(pos, orientation) then - minetest.after(0.2, function(pos) -- generate target map chunk - 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) - minetest.emerge_area(pos1, pos2) - end, vector.new(pos)) return true end orientation = 1 - orientation @@ -672,6 +668,7 @@ local function teleport_no_delay(obj, pos) if exit then finalize_teleport(obj, exit) else + dim = dimension_to_teleport[dim] -- need to create arrival portal create_portal(target, limits[dim].pmin, limits[dim].pmax, name, obj) end From dd69dcfd9f5fe5c8e481e275536f130853fc9e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Sat, 17 Apr 2021 23:03:57 +0200 Subject: [PATCH 28/38] Fix efficiency and unbreaking not working together This commit fixes an issue were tools enchanted with both efficiency and unbreaking would loose the effect of one of the enchantments in some conditions. --- mods/ITEMS/mcl_enchanting/enchantments.lua | 6 +++--- mods/ITEMS/mcl_enchanting/engine.lua | 1 + mods/ITEMS/mcl_enchanting/groupcaps.lua | 12 ++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index ca936c3192..df6105d52d 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -771,11 +771,11 @@ mcl_enchanting.enchantments.unbreaking = { curse = false, on_enchant = function(itemstack, level) local tool_capabilities = itemstack:get_tool_capabilities() - for group, capability in pairs(tool_capabilities.groupcaps) do - capability.uses = capability.uses * (1 + level) - end tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level) itemstack:get_meta():set_tool_capabilities(tool_capabilities) + + -- Unbreaking for groupcaps is handled in this function. + mcl_enchanting.update_groupcaps(itemstack) end, requires_tool = true, treasure = false, diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index ea69d1868b..30e4a9a863 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -17,6 +17,7 @@ function mcl_enchanting.unload_enchantments(itemstack) local meta = itemstack:get_meta() if meta:get_string("name") == "" then meta:set_string("description", "") + meta:set_string("groupcaps_hash", "") end end diff --git a/mods/ITEMS/mcl_enchanting/groupcaps.lua b/mods/ITEMS/mcl_enchanting/groupcaps.lua index 3750295477..1a4f8fd141 100644 --- a/mods/ITEMS/mcl_enchanting/groupcaps.lua +++ b/mods/ITEMS/mcl_enchanting/groupcaps.lua @@ -50,13 +50,21 @@ function mcl_enchanting.update_groupcaps(itemstack) end local name = itemstack:get_name() - local level = mcl_enchanting.get_enchantment(itemstack, "efficiency") - local groupcaps = get_efficiency_groupcaps(name, level) + local efficiency = mcl_enchanting.get_enchantment(itemstack, "efficiency") + local groupcaps = get_efficiency_groupcaps(name, efficiency) local hash = itemstack:get_meta():get_string("groupcaps_hash") if not hash or hash ~= groupcaps.hash then local tool_capabilities = itemstack:get_tool_capabilities() tool_capabilities.groupcaps = groupcaps.values + + -- Increase the number of uses depending on the unbreaking level + -- of the tool. + local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") + for group, capability in pairs(tool_capabilities.groupcaps) do + capability.uses = capability.uses * (1 + unbreaking) + end + itemstack:get_meta():set_tool_capabilities(tool_capabilities) itemstack:get_meta():set_string("groupcaps_hash", groupcaps.hash) end From 573b1dc44b4376bca3fe4bf4d3ed18f24210723b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Sat, 17 Apr 2021 23:40:19 +0200 Subject: [PATCH 29/38] Do not include unnecessary tool_capabilities This commit makes enchanted tools which have no use for tool_capabilities to not include it in their metadata. It does this by not including tool_capabilities in the metadata of an enchanted tool if at least one of two cases is true: (1) The tool is not enchanted with unbreaking or efficiency (2) The tool does not have tool_capabilities defined in its definition The first case covers situations like having a pickaxe only being enchanted with silk_touch. The second case covers situations like a piece of armor being enchanted with unbreaking. --- mods/ITEMS/mcl_enchanting/enchantments.lua | 5 +++++ mods/ITEMS/mcl_enchanting/engine.lua | 2 +- mods/ITEMS/mcl_enchanting/groupcaps.lua | 10 +++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index df6105d52d..fa3bc3ed5f 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -770,6 +770,11 @@ mcl_enchanting.enchantments.unbreaking = { description = S("Increases item durability."), curse = false, on_enchant = function(itemstack, level) + local name = itemstack:get_name() + if not minetest.registered_tools[name].tool_capabilities then + return + end + local tool_capabilities = itemstack:get_tool_capabilities() tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level) itemstack:get_meta():set_tool_capabilities(tool_capabilities) diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index 30e4a9a863..037134e4c3 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -12,7 +12,7 @@ end function mcl_enchanting.unload_enchantments(itemstack) local itemdef = itemstack:get_definition() if itemdef.tool_capabilities then - itemstack:get_meta():set_tool_capabilities(itemdef.tool_capabilities) + itemstack:get_meta():set_tool_capabilities(nil) end local meta = itemstack:get_meta() if meta:get_string("name") == "" then diff --git a/mods/ITEMS/mcl_enchanting/groupcaps.lua b/mods/ITEMS/mcl_enchanting/groupcaps.lua index 1a4f8fd141..0bc1b8e245 100644 --- a/mods/ITEMS/mcl_enchanting/groupcaps.lua +++ b/mods/ITEMS/mcl_enchanting/groupcaps.lua @@ -45,12 +45,17 @@ end -- To make it more efficient it will first check a hash value to determine if -- the tool needs to be updated. function mcl_enchanting.update_groupcaps(itemstack) - if not itemstack:get_meta():get("tool_capabilities") then + local name = itemstack:get_name() + if not minetest.registered_tools[name].tool_capabilities then return end - local name = itemstack:get_name() local efficiency = mcl_enchanting.get_enchantment(itemstack, "efficiency") + local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") + if unbreaking == 0 and efficiency == 0 then + return + end + local groupcaps = get_efficiency_groupcaps(name, efficiency) local hash = itemstack:get_meta():get_string("groupcaps_hash") @@ -60,7 +65,6 @@ function mcl_enchanting.update_groupcaps(itemstack) -- Increase the number of uses depending on the unbreaking level -- of the tool. - local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") for group, capability in pairs(tool_capabilities.groupcaps) do capability.uses = capability.uses * (1 + unbreaking) end From 956dab78ceb49aaed98f12b6b88acc3efac81957 Mon Sep 17 00:00:00 2001 From: Doloment Date: Sun, 18 Apr 2021 09:50:02 +0000 Subject: [PATCH 30/38] Added LBM --- mods/ITEMS/mcl_chests/init.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index ac12261718..05a6d18181 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -1409,3 +1409,13 @@ minetest.register_lbm({ meta:set_string("formspec", formspec_shulker_box) end, }) + +minetest.register_lbm({ + label = "Upgrade old ender chest formspec", + name = "mcl_chests:replace_old_ender_form", + nodenames = {"mcl_chests:ender_chest_small"}, + run_at_every_load = false, + action = function(pos, node) + minetest.get_meta(pos):set_string("formspec", "") + end, +}) From 5d9c3cd85bc5f5cd2650f5e982a9ae0626f4d385 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 18 Apr 2021 14:41:44 +0200 Subject: [PATCH 31/38] Fix #1572 --- mods/PLAYER/mcl_playerplus/init.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 360f4fe5de..f7c4305095 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -150,13 +150,6 @@ minetest.register_globalstep(function(dtime) for _,player in pairs(get_connected_players()) do - local c_x, c_y = unpack(player_collision(player)) - - if player:get_velocity().x + player:get_velocity().y < .5 and c_x + c_y > 0 then - --minetest.chat_send_player(player:get_player_name(), "pushed at " .. c_x + c_y .. " parsecs.") - player:add_velocity({x=c_x, y=0, z=c_y}) - end - --[[ _ _ _ __ _ _ __ (_)_ __ ___ __ _| |_(_) ___ _ __ ___ @@ -173,6 +166,14 @@ minetest.register_globalstep(function(dtime) local wielded = player:get_wielded_item() local player_velocity = player:get_velocity() or player:get_player_velocity() + local c_x, c_y = unpack(player_collision(player)) + + if player_velocity.x + player_velocity.y < .5 and c_x + c_y > 0 then + local add_velocity = player.add_player_velocity or player.add_velocity + add_velocity(player, {x = c_x, y = 0, z = c_y}) + player_velocity = player:get_velocity() or player:get_player_velocity() + end + -- control head bone local pitch = - degrees(player:get_look_vertical()) local yaw = degrees(player:get_look_horizontal()) From 9bc2f2d8669b63225de22114d17ad9ced8aefe19 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Apr 2021 17:18:27 +0000 Subject: [PATCH 32/38] Fix lying trunks that stand upright again after debarking --- mods/ITEMS/mcl_tools/init.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 3aebafb7bc..cdc981b2a1 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -375,22 +375,22 @@ local make_stripped_trunk = function(itemstack, placer, pointed_thing) return itemstack end if node_name == "mcl_core:tree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:darktree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:acaciatree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:birchtree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:sprucetree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:jungletree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:tree_bark" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak_bark"}) From 3668b2dee68daf57aa81b5a30941ee48ef5673b9 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Apr 2021 18:02:37 +0000 Subject: [PATCH 33/38] Summarize all debarked types of wood --- mods/ITEMS/mcl_core/nodes_trees.lua | 204 +++++++--------------------- 1 file changed, 46 insertions(+), 158 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index 4af3eef34c..d2c5443d32 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -48,165 +48,46 @@ local register_tree_trunk = function(subname, description_trunk, description_bar }) end --- Register stripped trunk -minetest.register_node("mcl_core:stripped_oak", { - description = "Stripped Oak Log", - _doc_items_longdesc = "Stripped Oak Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_acacia", { - description = "Stripped Acacia Log", - _doc_items_longdesc = "Stripped Acacia Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_dark_oak", { - description = "Stripped Dark Oak Log", - _doc_items_longdesc = "Stripped Dark Oak Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_birch", { - description = "Stripped Birch Log", - _doc_items_longdesc = "Stripped Birch Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_spruce", { - description = "Stripped Spruce Log", - _doc_items_longdesc = "Stripped Spruce Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_jungle", { - description = "Stripped Jungle Log", - _doc_items_longdesc = "Stripped Jungle Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - - --- Register stripped bark -minetest.register_node("mcl_core:stripped_oak_bark", { - description = "Stripped Oak Bark", - _doc_items_longdesc = "Stripped Oak Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_acacia_bark", { - description = "Stripped Acacia Bark", - _doc_items_longdesc = "Stripped Acacia Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_acacia_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_dark_oak_bark", { - description = "Stripped Dark Oak Bark", - _doc_items_longdesc = "Stripped Dark Oak Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_dark_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_birch_bark", { - description = "Stripped Birch Bark", - _doc_items_longdesc = "Stripped Birch Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_birch_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_spruce_bark", { - description = "Stripped Spruce Bark", - _doc_items_longdesc = "Stripped Spruce Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_spruce_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_jungle_bark", { - description = "Stripped Jungle Bark", - _doc_items_longdesc = "Stripped Jungles Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_jungle_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) +-- Register stripped trunk and stripped wood +local register_stripped_trunk = function(subname, description_stripped_trunk, description_stripped_bark, longdesc, tile_stripped_inner, tile_stripped_bark) + minetest.register_node("mcl_core:"..subname, { + description = description_stripped_trunk, + _doc_items_longdesc = longdesc, + _doc_items_hidden = false, + tiles = {tile_stripped_inner, tile_stripped_inner, tile_stripped_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + stack_max = 64, + groups = {handy=1,axey=1, tree=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, + }) + minetest.register_node("mcl_core:"..subname.."_bark", { + description = description_stripped_bark, + _doc_items_longdesc = S("This is a decorative block."), + tiles = {tile_stripped_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + stack_max = 64, + groups = {handy=1,axey=1, bark=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + is_ground_content = false, + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, + }) + + minetest.register_craft({ + output = "mcl_core:"..subname.."_bark 3", + recipe = { + { "mcl_core:"..subname, "mcl_core:"..subname }, + { "mcl_core:"..subname, "mcl_core:"..subname }, + } + }) +end local register_wooden_planks = function(subname, description, tiles) minetest.register_node("mcl_core:"..subname, { @@ -340,6 +221,13 @@ register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The tru register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png") register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png") +register_stripped_trunk("stripped_oak", S("Stripped Oak Log"), S("Stripped Oak Wood"), S("The stripped trunk of an oak tree."), "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png") +register_stripped_trunk("stripped_acacia", S("Stripped Acacia Log"), S("Stripped Acacia Wood"), S("The stripped trunk of an acacia tree."), "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png") +register_stripped_trunk("stripped_dark_oak", S("Stripped Dark Oak Log"), S("Stripped Dark Oak Wood"), S("The stripped trunk of an dark oak tree."), "mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_side.png") +register_stripped_trunk("stripped_birch", S("Stripped Birch Log"), S("Stripped Birch Wood"), S("The stripped trunk of an birch tree."), "mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_side.png") +register_stripped_trunk("stripped_spruce", S("Stripped Spruce Log"), S("Stripped Spruce Wood"), S("The stripped trunk of an spruce tree."), "mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_side.png") +register_stripped_trunk("stripped_jungle", S("Stripped Jungle Log"), S("Stripped Jungle Wood"), S("The stripped trunk of an jungle tree."),"mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_side.png") + register_wooden_planks("wood", S("Oak Wood Planks"), {"default_wood.png"}) register_wooden_planks("darkwood", S("Dark Oak Wood Planks"), {"mcl_core_planks_big_oak.png"}) register_wooden_planks("junglewood", S("Jungle Wood Planks"), {"default_junglewood.png"}) From 49f6ccaa4adf1cd36bbc56f93968d26fedc5ba6e Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Apr 2021 18:02:41 +0000 Subject: [PATCH 34/38] Remove old crafting recipes --- mods/ITEMS/mcl_core/crafting.lua | 50 -------------------------------- 1 file changed, 50 deletions(-) diff --git a/mods/ITEMS/mcl_core/crafting.lua b/mods/ITEMS/mcl_core/crafting.lua index 7a2b6a5c8a..a0ad38a777 100644 --- a/mods/ITEMS/mcl_core/crafting.lua +++ b/mods/ITEMS/mcl_core/crafting.lua @@ -46,56 +46,6 @@ minetest.register_craft({ } }) --- Stripped Bark -minetest.register_craft({ - output = "mcl_core:stripped_oak_bark 3", - recipe = { - { "mcl_core:stripped_oak", "mcl_core:stripped_oak" }, - { "mcl_core:stripped_oak", "mcl_core:stripped_oak" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_acacia_bark 3", - recipe = { - { "mcl_core:stripped_acacia", "mcl_core:stripped_acacia" }, - { "mcl_core:stripped_acacia", "mcl_core:stripped_acacia" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_dark_oak_bark 3", - recipe = { - { "mcl_core:stripped_dark_oak", "mcl_core:stripped_dark_oak" }, - { "mcl_core:stripped_dark_oak", "mcl_core:stripped_dark_oak" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_birch_bark 3", - recipe = { - { "mcl_core:stripped_birch", "mcl_core:stripped_birch" }, - { "mcl_core:stripped_birch", "mcl_core:stripped_birch" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_spruce_bark 3", - recipe = { - { "mcl_core:stripped_spruce", "mcl_core:stripped_spruce" }, - { "mcl_core:stripped_spruce", "mcl_core:stripped_spruce" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_jungle_bark 3", - recipe = { - { "mcl_core:stripped_jungle", "mcl_core:stripped_jungle" }, - { "mcl_core:stripped_jungle", "mcl_core:stripped_jungle" }, - } -}) - - minetest.register_craft({ type = 'shapeless', output = 'mcl_core:mossycobble', From aa533edda230403ca1a7daf9a097927fc2c2ac5b Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Apr 2021 18:28:39 +0000 Subject: [PATCH 35/38] Simplify debarking --- mods/ITEMS/mcl_tools/init.lua | 88 ++++++++++++++--------------------- 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index cdc981b2a1..bb9a4873c9 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -360,59 +360,43 @@ local make_stripped_trunk_add_wear = function(itemstack, placer) itemstack:add_wear(wear) end end + +local stripped_table = { + {"mcl_core:tree", "mcl_core:stripped_oak"}, + {"mcl_core:darktree", "mcl_core:stripped_dark_oak"}, + {"mcl_core:acaciatree", "mcl_core:stripped_acacia"}, + {"mcl_core:birchtree", "mcl_core:stripped_birch"}, + {"mcl_core:sprucetree", "mcl_core:stripped_spruce"}, + {"mcl_core:jungletree", "mcl_core:stripped_jungle"}, + {"mcl_core:tree_bark", "mcl_core:stripped_oak_bark"}, + {"mcl_core:darktree_bark", "mcl_core:stripped_dark_oak_bark"}, + {"mcl_core:acaciatree_bark", "mcl_core:stripped_acacia_bark"}, + {"mcl_core:birchtree_bark", "mcl_core:stripped_birch_bark"}, + {"mcl_core:sprucetree_bark", "mcl_core:stripped_spruce_bark"}, + {"mcl_core:jungletree_bark", "mcl_core:stripped_jungle_bark"}, +} + local make_stripped_trunk = function(itemstack, placer, pointed_thing) - if pointed_thing.type == "node" then - local pos = minetest.get_pointed_thing_position(pointed_thing) - local node = minetest.get_node(pos) - local node_name = node.name - 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 - if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) - return itemstack - end - if node_name == "mcl_core:tree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:darktree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:acaciatree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:birchtree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:sprucetree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:jungletree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:tree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:darktree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:acaciatree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:birchtree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:sprucetree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:jungletree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - end - end - return itemstack + if pointed_thing.type ~= "node" then return end + + local node = minetest.get_node(pointed_thing.under) + local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] + + if not placer:get_player_control().sneak and noddef.on_rightclick then + return minetest.item_place(itemstack, placer, pointed_thing) + end + if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then + minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) + return itemstack + end + + for _, st in pairs(stripped_table) do + if noddef.name == st[1] then + minetest.swap_node(pointed_thing.under, {name=st[2], param2=node.param2}) + make_stripped_trunk_add_wear(itemstack, placer) + end + end + return itemstack end minetest.register_tool("mcl_tools:axe_wood", { From 44a25de12fdd3743db6f84b05d0fa591d8578596 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 18 Apr 2021 23:18:18 -0400 Subject: [PATCH 36/38] Fix crashing with unknown slot description when enchanting --- mods/ITEMS/mcl_enchanting/engine.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index 037134e4c3..f3bfea12b0 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -502,7 +502,7 @@ function mcl_enchanting.show_enchanting_formspec(player) local hover_ending = (can_enchant and "_hovered" or "_off") formspec = formspec .. "container[3.2," .. y .. "]" - .. (slot and "tooltip[button_" .. i .. ";" .. C(mcl_colors.GRAY) .. F(slot.description) .. " " .. C(mcl_colors.WHITE) .. " . . . ?\n\n" .. (enough_levels and C(enough_lapis and mcl_colors.GRAY or mcl_colors.RED) .. F(S("@1 Lapis Lazuli", i)) .. "\n" .. C(mcl_colors.GRAY) .. F(S("@1 Enchantment Levels", i)) or C(mcl_colors.RED) .. F(S("Level requirement: @1", slot.level_requirement))) .. "]" or "") + .. (slot and "tooltip[button_" .. i .. ";" .. C(mcl_colors.GRAY) .. ((slot.description and F(slot.description)) or "") .. " " .. C(mcl_colors.WHITE) .. " . . . ?\n\n" .. (enough_levels and C(enough_lapis and mcl_colors.GRAY or mcl_colors.RED) .. F(S("@1 Lapis Lazuli", i)) .. "\n" .. C(mcl_colors.GRAY) .. F(S("@1 Enchantment Levels", i)) or C(mcl_colors.RED) .. F(S("Level requirement: @1", slot.level_requirement))) .. "]" or "") .. "style[button_" .. i .. ";bgimg=mcl_enchanting_button" .. ending .. ".png;bgimg_hovered=mcl_enchanting_button" .. hover_ending .. ".png;bgimg_pressed=mcl_enchanting_button" .. hover_ending .. ".png]" .. "button[0,0;7.5,1.3;button_" .. i .. ";]" .. (slot and "image[0,0;1.3,1.3;mcl_enchanting_number_" .. i .. ending .. ".png]" or "") From c03717139b6dfb0f86fd9f0506b545befae7f89d Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Sun, 18 Apr 2021 23:23:07 -0400 Subject: [PATCH 37/38] Add mod.conf to mcl_fireworks --- mods/ITEMS/mcl_fireworks/mod.conf | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 mods/ITEMS/mcl_fireworks/mod.conf diff --git a/mods/ITEMS/mcl_fireworks/mod.conf b/mods/ITEMS/mcl_fireworks/mod.conf new file mode 100644 index 0000000000..cf9e34e91a --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/mod.conf @@ -0,0 +1,2 @@ +name = mcl_fireworks +description = Adds fun fireworks to the game which players can use. \ No newline at end of file From 0c5ca70187fb4f168f2da5ea76ef2c40e61ebeff Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 19 Apr 2021 07:35:53 +0000 Subject: [PATCH 38/38] remove wrong config --- mods/ITEMS/mcl_fireworks/config.txt | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 mods/ITEMS/mcl_fireworks/config.txt diff --git a/mods/ITEMS/mcl_fireworks/config.txt b/mods/ITEMS/mcl_fireworks/config.txt deleted file mode 100644 index 5a12a1f527..0000000000 --- a/mods/ITEMS/mcl_fireworks/config.txt +++ /dev/null @@ -1,2 +0,0 @@ -name = mcl_firework -author = NO11, j45