From a3d459f020024bb8b86af33bafc26b58dad0ad6c Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 25 Oct 2022 00:31:26 +0200 Subject: [PATCH 01/14] Refactor `mcl_init` - use new vectors - make code less confuse - type annotations --- mods/CORE/mcl_init/init.lua | 126 ++++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 56 deletions(-) diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua index 6773949b7..5f19044bb 100644 --- a/mods/CORE/mcl_init/init.lua +++ b/mods/CORE/mcl_init/init.lua @@ -3,26 +3,26 @@ mcl_vars = {} mcl_vars.redstone_tick = 0.1 ---- GUI / inventory menu settings +-- GUI / inventory menu settings mcl_vars.gui_slots = "listcolors[#9990;#FFF7;#FFF0;#000;#FFF]" + -- nonbg is added as formspec prepend in mcl_formspec_prepend -mcl_vars.gui_nonbg = mcl_vars.gui_slots .. - "style_type[image_button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]".. - "style_type[button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]".. - "style_type[field;textcolor=#323232]".. - "style_type[label;textcolor=#323232]".. - "style_type[textarea;textcolor=#323232]".. - "style_type[checkbox;textcolor=#323232]" +mcl_vars.gui_nonbg = table.concat({ + mcl_vars.gui_slots, + "style_type[image_button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]", + "style_type[button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]", + "style_type[field;textcolor=#323232]", + "style_type[label;textcolor=#323232]", + "style_type[textarea;textcolor=#323232]", + "style_type[checkbox;textcolor=#323232]", +}) -- Background stuff must be manually added by mods (no formspec prepend) mcl_vars.gui_bg_color = "bgcolor[#00000000]" mcl_vars.gui_bg_img = "background9[1,1;1,1;mcl_base_textures_background9.png;true;7]" --- Legacy -mcl_vars.inventory_header = "" - -- Tool wield size -mcl_vars.tool_wield_scale = { x = 1.8, y = 1.8, z = 1 } +mcl_vars.tool_wield_scale = vector.new(1.8, 1.8, 1) -- Mapgen variables local mg_name = minetest.get_mapgen_setting("mg_name") @@ -35,55 +35,69 @@ mcl_vars.chunksize = math.max(1, tonumber(minetest.get_mapgen_setting("chunksize mcl_vars.MAP_BLOCKSIZE = math.max(1, minetest.MAP_BLOCKSIZE or 16) mcl_vars.mapgen_limit = math.max(1, tonumber(minetest.get_mapgen_setting("mapgen_limit")) or 31000) mcl_vars.MAX_MAP_GENERATION_LIMIT = math.max(1, minetest.MAX_MAP_GENERATION_LIMIT or 31000) + local central_chunk_offset = -math.floor(mcl_vars.chunksize / 2) + mcl_vars.central_chunk_offset_in_nodes = central_chunk_offset * mcl_vars.MAP_BLOCKSIZE mcl_vars.chunk_size_in_nodes = mcl_vars.chunksize * mcl_vars.MAP_BLOCKSIZE + local central_chunk_min_pos = central_chunk_offset * mcl_vars.MAP_BLOCKSIZE local central_chunk_max_pos = central_chunk_min_pos + mcl_vars.chunk_size_in_nodes - 1 local ccfmin = central_chunk_min_pos - mcl_vars.MAP_BLOCKSIZE -- Fullminp/fullmaxp of central chunk, in nodes local ccfmax = central_chunk_max_pos + mcl_vars.MAP_BLOCKSIZE -local mapgen_limit_b = math.floor(math.min(mcl_vars.mapgen_limit, mcl_vars.MAX_MAP_GENERATION_LIMIT) / mcl_vars.MAP_BLOCKSIZE) +local mapgen_limit_b = math.floor(math.min(mcl_vars.mapgen_limit, mcl_vars.MAX_MAP_GENERATION_LIMIT) / + mcl_vars.MAP_BLOCKSIZE) local mapgen_limit_min = -mapgen_limit_b * mcl_vars.MAP_BLOCKSIZE local mapgen_limit_max = (mapgen_limit_b + 1) * mcl_vars.MAP_BLOCKSIZE - 1 local numcmin = math.max(math.floor((ccfmin - mapgen_limit_min) / mcl_vars.chunk_size_in_nodes), 0) -- Number of complete chunks from central chunk local numcmax = math.max(math.floor((mapgen_limit_max - ccfmax) / mcl_vars.chunk_size_in_nodes), 0) -- fullminp/fullmaxp to effective mapgen limits. + mcl_vars.mapgen_edge_min = central_chunk_min_pos - numcmin * mcl_vars.chunk_size_in_nodes mcl_vars.mapgen_edge_max = central_chunk_max_pos + numcmax * mcl_vars.chunk_size_in_nodes +---@param x integer +---@return integer local function coordinate_to_block(x) return math.floor(x / mcl_vars.MAP_BLOCKSIZE) end +---@param x integer +---@return integer local function coordinate_to_chunk(x) return math.floor((coordinate_to_block(x) - central_chunk_offset) / mcl_vars.chunksize) end +---@param pos Vector +---@return Vector function mcl_vars.pos_to_block(pos) - return { - x = coordinate_to_block(pos.x), - y = coordinate_to_block(pos.y), - z = coordinate_to_block(pos.z) - } + return vector.new( + coordinate_to_block(pos.x), + coordinate_to_block(pos.y), + coordinate_to_block(pos.z) + ) end +---@param pos Vector +---@return Vector function mcl_vars.pos_to_chunk(pos) - return { - x = coordinate_to_chunk(pos.x), - y = coordinate_to_chunk(pos.y), - z = coordinate_to_chunk(pos.z) - } + return vector.new( + coordinate_to_chunk(pos.x), + coordinate_to_chunk(pos.y), + coordinate_to_chunk(pos.z) + ) end local k_positive = math.ceil(mcl_vars.MAX_MAP_GENERATION_LIMIT / mcl_vars.chunk_size_in_nodes) local k_positive_z = k_positive * 2 local k_positive_y = k_positive_z * k_positive_z +---@param pos Vector +---@return integer function mcl_vars.get_chunk_number(pos) -- unsigned int local c = mcl_vars.pos_to_chunk(pos) - return - (c.y + k_positive) * k_positive_y + + return (c.y + k_positive) * k_positive_y + (c.z + k_positive) * k_positive_z + - c.x + k_positive + c.x + k_positive end if not superflat and not singlenode then @@ -117,11 +131,8 @@ elseif singlenode then mcl_vars.mg_bedrock_is_rough = false else -- Classic superflat - local ground = minetest.get_mapgen_setting("mgflat_ground_level") - ground = tonumber(ground) - if not ground then - ground = 8 - end + local ground = tonumber(minetest.get_mapgen_setting("mgflat_ground_level")) or 8 + mcl_vars.mg_overworld_min = ground - 3 mcl_vars.mg_overworld_max_official = mcl_vars.mg_overworld_min + minecraft_height_limit mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min @@ -180,14 +191,16 @@ minetest.craftitemdef_default.stack_max = 64 math.randomseed(os.time()) local chunks = {} -- intervals of chunks generated + +---@param pos Vector function mcl_vars.add_chunk(pos) local n = mcl_vars.get_chunk_number(pos) -- unsigned int local prev for i, d in pairs(chunks) do if n <= d[2] then -- we've found it if (n == d[2]) or (n >= d[1]) then return end -- already here - if n == d[1]-1 then -- right before: - if prev and (prev[2] == n-1) then + if n == d[1] - 1 then -- right before: + if prev and (prev[2] == n - 1) then prev[2] = d[2] table.remove(chunks, i) return @@ -195,17 +208,20 @@ function mcl_vars.add_chunk(pos) d[1] = n return end - if prev and (prev[2] == n-1) then --join to previous + if prev and (prev[2] == n - 1) then --join to previous prev[2] = n return end - table.insert(chunks, i, {n, n}) -- insert new interval before i + table.insert(chunks, i, { n, n }) -- insert new interval before i return end prev = d end - chunks[#chunks+1] = {n, n} + chunks[#chunks + 1] = { n, n } end + +---@param pos Vector +---@return boolean function mcl_vars.is_generated(pos) local n = mcl_vars.get_chunk_number(pos) -- unsigned int for i, d in pairs(chunks) do @@ -216,47 +232,45 @@ function mcl_vars.is_generated(pos) return false end --- "Trivial" (actually NOT) function to just read the node and some stuff to not just return "ignore", like mt 5.4 does. --- p: Position, if it's wrong, {name="error"} node will return. --- force: optional (default: false) - Do the maximum to still read the node within us_timeout. --- us_timeout: optional (default: 244 = 0.000244 s = 1/80/80/80), set it at least to 3000000 to let mapgen to finish its job. --- --- returns node definition, eg. {name="air"}. Unfortunately still can return {name="ignore"}. -function mcl_vars.get_node(p, force, us_timeout) +---"Trivial" (actually NOT) function to just read the node and some stuff to not just return "ignore", like mt 5.4 does. +---@param pos Vector Position, if it's wrong, `{name="error"}` node will return. +---@param force boolean Optional (default: `false`), Do the maximum to still read the node within us_timeout. +---@param us_timeout number Optional (default: `244 = 0.000244 s = 1/80/80/80`), set it at least to `3000000` to let mapgen to finish its job +---@return node # Node definition, eg. `{name="air"}`. Unfortunately still can return `{name="ignore"}`. +function mcl_vars.get_node(pos, force, us_timeout) -- check initial circumstances - if not p or not p.x or not p.y or not p.z then return {name="error"} end + if not pos or not pos.x or not pos.y or not pos.z then return { name = "error" } end -- try common way - local node = minetest.get_node(p) + local node = minetest.get_node(pos) if node.name ~= "ignore" then return node end - -- copy table to get sure it won't changed by other threads - local pos = {x=p.x,y=p.y,z=p.z} + -- copy vector to get sure it won't changed by other threads + local pos_copy = vector.copy(pos) -- try LVM - minetest.get_voxel_manip():read_from_map(pos, pos) - node = minetest.get_node(pos) + minetest.get_voxel_manip():read_from_map(pos_copy, pos_copy) + node = minetest.get_node(pos_copy) if node.name ~= "ignore" or not force then return node end -- all ways failed - need to emerge (or forceload if generated) - local us_timeout = us_timeout or 244 - if mcl_vars.is_generated(pos) then + if mcl_vars.is_generated(pos_copy) then minetest.chat_send_all("IMPOSSIBLE! Please report this to MCL2 issue tracker!") - minetest.forceload_block(pos) + minetest.forceload_block(pos_copy) else - minetest.emerge_area(pos, pos) + minetest.emerge_area(pos_copy, pos_copy) end local t = minetest.get_us_time() - node = minetest.get_node(pos) + node = minetest.get_node(pos_copy) - while (not node or node.name == "ignore") and (minetest.get_us_time() - t < us_timeout) do - node = minetest.get_node(pos) + while (not node or node.name == "ignore") and (minetest.get_us_time() - t < (us_timeout or 244)) do + node = minetest.get_node(pos_copy) end return node From bacec2c7e6024098ec6385377e27f3c63433ec80 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 25 Oct 2022 00:32:35 +0200 Subject: [PATCH 02/14] Make 2 last params of `mcl_vars.get_node` optional --- mods/CORE/mcl_init/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua index 5f19044bb..9b74ad502 100644 --- a/mods/CORE/mcl_init/init.lua +++ b/mods/CORE/mcl_init/init.lua @@ -234,9 +234,10 @@ end ---"Trivial" (actually NOT) function to just read the node and some stuff to not just return "ignore", like mt 5.4 does. ---@param pos Vector Position, if it's wrong, `{name="error"}` node will return. ----@param force boolean Optional (default: `false`), Do the maximum to still read the node within us_timeout. ----@param us_timeout number Optional (default: `244 = 0.000244 s = 1/80/80/80`), set it at least to `3000000` to let mapgen to finish its job +---@param force? boolean Optional (default: `false`), Do the maximum to still read the node within us_timeout. +---@param us_timeout? number Optional (default: `244 = 0.000244 s = 1/80/80/80`), set it at least to `3000000` to let mapgen to finish its job ---@return node # Node definition, eg. `{name="air"}`. Unfortunately still can return `{name="ignore"}`. +---@nodiscard function mcl_vars.get_node(pos, force, us_timeout) -- check initial circumstances if not pos or not pos.x or not pos.y or not pos.z then return { name = "error" } end From 4acee8e64e9418ca576284f3244d43da19d7c5a6 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 11 Nov 2022 00:41:59 +0100 Subject: [PATCH 03/14] Fixes to `mcl_meshhand` - fix actual crash when placing hand in world (undefined function) - remove node fields redundant with default values - remove support for `use_texture_alpha_string_modes` - type annotation - more explicit functions --- mods/PLAYER/mcl_meshhand/init.lua | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mods/PLAYER/mcl_meshhand/init.lua b/mods/PLAYER/mcl_meshhand/init.lua index 0d4bf091d..1cc31f601 100644 --- a/mods/PLAYER/mcl_meshhand/init.lua +++ b/mods/PLAYER/mcl_meshhand/init.lua @@ -1,22 +1,20 @@ local mcl_skins_enabled = minetest.global_exists("mcl_skins") --- This is a fake node that should never be placed in the world +---This is a fake node that should never be placed in the world +---@type node_definition local node_def = { - description = "", - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or false, - visual_scale = 1, - wield_scale = {x=1,y=1,z=1}, + use_texture_alpha = "opaque", paramtype = "light", drawtype = "mesh", node_placement_prediction = "", on_construct = function(pos) - local name = get_node(pos).name + local name = minetest.get_node(pos).name local message = "[mcl_meshhand] Trying to construct " .. name .. " at " .. minetest.pos_to_string(pos) minetest.log("error", message) minetest.remove_node(pos) end, drop = "", - on_drop = function() return "" end, + on_drop = function(_, _, _) return ItemStack() end, groups = { dig_immediate = 3, not_in_creative_inventory = 1 }, range = minetest.registered_items[""].range } @@ -29,20 +27,20 @@ if mcl_skins_enabled then local female = table.copy(node_def) female._mcl_hand_id = skin.id female.mesh = "mcl_meshhand_female.b3d" - female.tiles = {skin.texture} + female.tiles = { skin.texture } minetest.register_node("mcl_meshhand:" .. skin.id, female) else local male = table.copy(node_def) male._mcl_hand_id = skin.id male.mesh = "mcl_meshhand.b3d" - male.tiles = {skin.texture} + male.tiles = { skin.texture } minetest.register_node("mcl_meshhand:" .. skin.id, male) end end else node_def._mcl_hand_id = "hand" node_def.mesh = "mcl_meshhand.b3d" - node_def.tiles = {"character.png"} + node_def.tiles = { "character.png" } minetest.register_node("mcl_meshhand:hand", node_def) end @@ -54,6 +52,6 @@ if mcl_skins_enabled then end) else minetest.register_on_joinplayer(function(player) - player:get_inventory():set_stack("hand", 1, "mcl_meshhand:hand") + player:get_inventory():set_stack("hand", 1, ItemStack("mcl_meshhand:hand")) end) end From 3bb86fd43685d9f0c41443f948dfe9f948348af9 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 11 Nov 2022 00:12:03 +0100 Subject: [PATCH 04/14] Fix warnings + add type annotations - fix wrong usage of `mcl_enchanting.get_enchantments` - use new vectors everywhere - simplify code - make code lines less long --- mods/ENTITIES/mcl_item_entity/init.lua | 207 +++++++++++++------------ 1 file changed, 111 insertions(+), 96 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 0152caec9..a54e087f9 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -7,25 +7,19 @@ local pool = {} local tick = false -local LOGGING_ON = minetest.settings:get_bool("mcl_logging_item_entities",false) -local function mcl_log (message) +local LOGGING_ON = minetest.settings:get_bool("mcl_logging_item_entities", false) +local function mcl_log(message) if LOGGING_ON then - mcl_util.mcl_log (message, "[Item Entities]", true) + mcl_util.mcl_log(message, "[Item Entities]", true) end end - - minetest.register_on_joinplayer(function(player) - local name - name = player:get_player_name() - pool[name] = 0 + pool[player:get_player_name()] = 0 end) minetest.register_on_leaveplayer(function(player) - local name - name = player:get_player_name() - pool[name] = nil + pool[player:get_player_name()] = nil end) @@ -46,7 +40,7 @@ item_drop_settings.random_item_velocity = true --this sets random item velocity item_drop_settings.drop_single_item = false --if true, the drop control drops 1 item instead of the entire stack, and sneak+drop drops the stack -- drop_single_item is disabled by default because it is annoying to throw away items from the intentory screen -item_drop_settings.magnet_time = 0.75 -- how many seconds an item follows the player before giving up +item_drop_settings.magnet_time = 0.75 -- how many seconds an item follows the player before giving up local function get_gravity() return tonumber(minetest.settings:get("movement_gravity")) or 9.81 @@ -57,9 +51,12 @@ local registered_pickup_achievement = {} --TODO: remove limitation of 1 award per itemname function mcl_item_entity.register_pickup_achievement(itemname, award) if not has_awards then - minetest.log("warning", "[mcl_item_entity] Trying to register pickup achievement ["..award.."] for ["..itemname.."] while awards missing") + minetest.log("warning", + "[mcl_item_entity] Trying to register pickup achievement [" .. award .. "] for [" .. + itemname .. "] while awards missing") elseif registered_pickup_achievement[itemname] then - minetest.log("error", "[mcl_item_entity] Trying to register already existing pickup achievement ["..award.."] for ["..itemname.."]") + minetest.log("error", + "[mcl_item_entity] Trying to register already existing pickup achievement [" .. award .. "] for [" .. itemname .. "]") else registered_pickup_achievement[itemname] = award end @@ -74,11 +71,13 @@ mcl_item_entity.register_pickup_achievement("mcl_nether:ancient_debris", "mcl:hi mcl_item_entity.register_pickup_achievement("mcl_end:dragon_egg", "mcl:PickUpDragonEgg") mcl_item_entity.register_pickup_achievement("mcl_armor:elytra", "mcl:skysTheLimit") +---@param object ObjectRef +---@param player ObjectRef local function check_pickup_achievements(object, player) if has_awards then local itemname = ItemStack(object:get_luaentity().itemstring):get_name() local playername = player:get_player_name() - for name,award in pairs(registered_pickup_achievement) do + for name, award in pairs(registered_pickup_achievement) do if itemname == name or minetest.get_item_group(itemname, name) ~= 0 then awards.unlock(playername, award) end @@ -86,16 +85,23 @@ local function check_pickup_achievements(object, player) end end +---@param object ObjectRef +---@param luaentity Luaentity +---@param ignore_check? boolean local function enable_physics(object, luaentity, ignore_check) if luaentity.physical_state == false or ignore_check == true then luaentity.physical_state = true object:set_properties({ physical = true }) - object:set_acceleration({x=0,y=-get_gravity(),z=0}) + object:set_acceleration(vector.new(0, -get_gravity(), 0)) end end +---@param object ObjectRef +---@param luaentity Luaentity +---@param ignore_check? boolean +---@param reset_movement? boolean local function disable_physics(object, luaentity, ignore_check, reset_movement) if luaentity.physical_state == true or ignore_check == true then luaentity.physical_state = false @@ -103,17 +109,16 @@ local function disable_physics(object, luaentity, ignore_check, reset_movement) physical = false }) if reset_movement ~= false then - object:set_velocity({x=0,y=0,z=0}) - object:set_acceleration({x=0,y=0,z=0}) + object:set_velocity(vector.zero()) + object:set_acceleration(vector.zero()) end end end - -minetest.register_globalstep(function(dtime) +minetest.register_globalstep(function(_) tick = not tick - for _,player in pairs(minetest.get_connected_players()) do + for _, player in pairs(minetest.get_connected_players()) do if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then local name = player:get_player_name() @@ -125,7 +130,7 @@ minetest.register_globalstep(function(dtime) pos = pos, gain = 0.3, max_hear_distance = 16, - pitch = math.random(70,110)/100 + pitch = math.random(70, 110) / 100 }) if pool[name] > 6 then pool[name] = 6 @@ -135,15 +140,18 @@ minetest.register_globalstep(function(dtime) end - local inv = player:get_inventory() - local checkpos = {x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z} + local checkpos = vector.offset(pos, 0, item_drop_settings.player_collect_height, 0) --magnet and collection - for _,object in pairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.xp_radius_magnet)) do - if not object:is_player() and vector.distance(checkpos, object:get_pos()) < item_drop_settings.radius_magnet and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and object:get_luaentity()._magnet_timer and (object:get_luaentity()._insta_collect or (object:get_luaentity().age > item_drop_settings.age)) then + for _, object in pairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.xp_radius_magnet)) do + if not object:is_player() and vector.distance(checkpos, object:get_pos()) < item_drop_settings.radius_magnet and + object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and object:get_luaentity()._magnet_timer + and (object:get_luaentity()._insta_collect or (object:get_luaentity().age > item_drop_settings.age)) then - if object:get_luaentity()._magnet_timer >= 0 and object:get_luaentity()._magnet_timer < item_drop_settings.magnet_time and inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then + if object:get_luaentity()._magnet_timer >= 0 and + object:get_luaentity()._magnet_timer < item_drop_settings.magnet_time and inv and + inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then -- Collection if not object:get_luaentity()._removed then @@ -158,8 +166,8 @@ minetest.register_globalstep(function(dtime) object:get_luaentity().target = checkpos object:get_luaentity()._removed = true - object:set_velocity({x=0,y=0,z=0}) - object:set_acceleration({x=0,y=0,z=0}) + object:set_velocity(vector.zero()) + object:set_acceleration(vector.zero()) object:move_to(checkpos) @@ -179,7 +187,6 @@ minetest.register_globalstep(function(dtime) local entity = object:get_luaentity() entity.collector = player:get_player_name() entity.collected = true - end end @@ -194,6 +201,11 @@ end) local tmp_id = 0 +---@param drop string|drop_definition +---@param toolname string +---@param param2 integer +---@param paramtype2 paramtype2 +---@return string[] local function get_drops(drop, toolname, param2, paramtype2) tmp_id = tmp_id + 1 local tmp_node_name = "mcl_item_entity:" .. tmp_id @@ -202,7 +214,7 @@ local function get_drops(drop, toolname, param2, paramtype2) drop = drop, paramtype2 = paramtype2 } - local drops = minetest.get_node_drops({name = tmp_node_name, param2 = param2}, toolname) + local drops = minetest.get_node_drops({ name = tmp_node_name, param2 = param2 }, toolname) minetest.registered_nodes[tmp_node_name] = nil return drops end @@ -265,7 +277,7 @@ function minetest.handle_node_drops(pos, drops, digger) * table: Drop every itemstring in this table when dug by shears _mcl_silk_touch_drop ]] - local enchantments = tool and mcl_enchanting.get_enchantments(tool, "silk_touch") + local enchantments = tool and mcl_enchanting.get_enchantments(tool) local silk_touch_drop = false local nodedef = minetest.registered_nodes[dug_node.name] @@ -294,7 +306,8 @@ function minetest.handle_node_drops(pos, drops, digger) local max_count = fortune_drop.max_count + fortune_level * (fortune_drop.factor or 1) local chance = fortune_drop.chance or fortune_drop.get_chance and fortune_drop.get_chance(fortune_level) if not chance or math.random() < chance then - drops = discrete_uniform_distribution(fortune_drop.multiply and drops or fortune_drop.items, min_count, max_count, fortune_drop.cap) + drops = discrete_uniform_distribution(fortune_drop.multiply and drops or fortune_drop.items, min_count, max_count, + fortune_drop.cap) elseif fortune_drop.override then drops = {} end @@ -306,13 +319,13 @@ function minetest.handle_node_drops(pos, drops, digger) end if digger and mcl_experience.throw_xp and not silk_touch_drop then - local experience_amount = minetest.get_item_group(dug_node.name,"xp") + local experience_amount = minetest.get_item_group(dug_node.name, "xp") if experience_amount > 0 then mcl_experience.throw_xp(pos, experience_amount) end end - for _,item in ipairs(drops) do + for _, item in ipairs(drops) do local count if type(item) == "string" then count = ItemStack(item):get_count() @@ -321,7 +334,7 @@ function minetest.handle_node_drops(pos, drops, digger) end local drop_item = ItemStack(item) drop_item:set_count(1) - for i=1,count do + for i = 1, count do local dpos = table.copy(pos) -- Apply offset for plantlike_rooted nodes because of their special shape if nodedef and nodedef.drawtype == "plantlike_rooted" and nodedef.walkable then @@ -348,7 +361,7 @@ end function minetest.item_drop(itemstack, dropper, pos) if dropper and dropper:is_player() then local v = dropper:get_look_dir() - local p = {x=pos.x, y=pos.y+1.2, z=pos.z} + local p = vector.offset(pos, 0, 1.2, 0) local cs = itemstack:get_count() if dropper:get_player_control().sneak then cs = 1 @@ -356,9 +369,9 @@ function minetest.item_drop(itemstack, dropper, pos) local item = itemstack:take_item(cs) local obj = minetest.add_item(p, item) if obj then - v.x = v.x*4 - v.y = v.y*4 + 2 - v.z = v.z*4 + v.x = v.x * 4 + v.y = v.y * 4 + 2 + v.z = v.z * 4 obj:set_velocity(v) -- Force collection delay obj:get_luaentity()._insta_collect = false @@ -376,16 +389,16 @@ end local function cxcz(o, cw, one, zero) if cw < 0 then - table.insert(o, { [one]=1, y=0, [zero]=0 }) - table.insert(o, { [one]=-1, y=0, [zero]=0 }) + table.insert(o, { [one] = 1, y = 0, [zero] = 0 }) + table.insert(o, { [one] = -1, y = 0, [zero] = 0 }) else - table.insert(o, { [one]=-1, y=0, [zero]=0 }) - table.insert(o, { [one]=1, y=0, [zero]=0 }) + table.insert(o, { [one] = -1, y = 0, [zero] = 0 }) + table.insert(o, { [one] = 1, y = 0, [zero] = 0 }) end return o end -local function hopper_take_item (self, pos) +local function hopper_take_item(self, pos) --mcl_log("self.itemstring: ".. self.itemstring) --mcl_log("self.itemstring: ".. minetest.pos_to_string(pos)) @@ -394,17 +407,17 @@ local function hopper_take_item (self, pos) if objs and self.itemstring then --mcl_log("there is an itemstring. Number of objs: ".. #objs) - for k,v in pairs(objs) do + for k, v in pairs(objs) do local ent = v:get_luaentity() -- Don't forget actual hoppers if ent and ent.name == "mcl_minecarts:hopper_minecart" then local taken_items = false - mcl_log("ent.name: ".. tostring(ent.name)) - mcl_log("ent pos: ".. tostring(ent.object:get_pos())) + mcl_log("ent.name: " .. tostring(ent.name)) + mcl_log("ent pos: " .. tostring(ent.object:get_pos())) - local inv = mcl_entity_invs.load_inv(ent,5) + local inv = mcl_entity_invs.load_inv(ent, 5) if not inv then mcl_log("No inv") @@ -428,7 +441,7 @@ local function hopper_take_item (self, pos) local items_remaining = current_itemstack:get_count() -- This will take part of a floating item stack if no slot can hold the full amount - for i = 1, ent._inv_size,1 do + for i = 1, ent._inv_size, 1 do local stack = inv:get_stack("main", i) mcl_log("i: " .. tostring(i)) @@ -500,13 +513,13 @@ minetest.register_entity(":__builtin:item", { hp_max = 1, physical = true, collide_with_objects = false, - collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3}, + collisionbox = { -0.3, -0.3, -0.3, 0.3, 0.3, 0.3 }, pointable = false, visual = "wielditem", - visual_size = {x = 0.4, y = 0.4}, - textures = {""}, - spritediv = {x = 1, y = 1}, - initial_sprite_basepos = {x = 0, y = 0}, + visual_size = { x = 0.4, y = 0.4 }, + textures = { "" }, + spritediv = { x = 1, y = 1 }, + initial_sprite_basepos = { x = 0, y = 0 }, is_visible = false, infotext = "", }, @@ -544,11 +557,11 @@ minetest.register_entity(":__builtin:item", { if vel and vel.x == 0 and vel.z == 0 and self.random_velocity > 0 then local v = self.random_velocity local x = math.random(5, 10) / 10 * v - if math.random(0,10) < 5 then x = -x end + if math.random(0, 10) < 5 then x = -x end local z = math.random(5, 10) / 10 * v - if math.random(0,10) < 5 then z = -z end - local y = math.random(2,4) - self.object:set_velocity({x=x, y=y, z=z}) + if math.random(0, 10) < 5 then z = -z end + local y = math.random(2, 4) + self.object:set_velocity(vector.new(x, y, z)) end self.random_velocity = 0 end, @@ -576,7 +589,7 @@ minetest.register_entity(":__builtin:item", { local max_count = stack:get_stack_max() if count > max_count then count = max_count - self.itemstring = stack:get_name().." "..max_count + self.itemstring = stack:get_name() .. " " .. max_count end local itemtable = stack:to_table() local itemname = nil @@ -597,9 +610,9 @@ minetest.register_entity(":__builtin:item", { local prop = { is_visible = true, visual = "wielditem", - textures = {itemname}, - visual_size = {x = s, y = s}, - collisionbox = {-c, -c, -c, c, c, c}, + textures = { itemname }, + visual_size = { x = s, y = s }, + collisionbox = { -c, -c, -c, c, c, c }, automatic_rotate = math.pi * 0.5, infotext = description, glow = glow, @@ -695,9 +708,9 @@ minetest.register_entity(":__builtin:item", { self._forcestart = nil self._forcetimer = 0 - self.object:set_armor_groups({immortal = 1}) - -- self.object:set_velocity({x = 0, y = 2, z = 0}) - self.object:set_acceleration({x = 0, y = -get_gravity(), z = 0}) + self.object:set_armor_groups({ immortal = 1 }) + -- self.object:set_velocity(vector.new(0, 2, 0)) + self.object:set_acceleration(vector.new(0, -get_gravity(), 0)) self:set_item(self.itemstring) end, @@ -710,9 +723,9 @@ minetest.register_entity(":__builtin:item", { local stack = ItemStack(entity.itemstring) local name = stack:get_name() if own_stack:get_name() ~= name or - own_stack:get_meta() ~= stack:get_meta() or - own_stack:get_wear() ~= stack:get_wear() or - own_stack:get_free_space() == 0 then + own_stack:get_meta() ~= stack:get_meta() or + own_stack:get_wear() ~= stack:get_wear() or + own_stack:get_free_space() == 0 then -- Can not merge different or full stack return false end @@ -745,8 +758,8 @@ minetest.register_entity(":__builtin:item", { self.object:set_properties({ physical = false }) - self.object:set_velocity({x=0,y=0,z=0}) - self.object:set_acceleration({x=0,y=0,z=0}) + self.object:set_velocity(vector.zero()) + self.object:set_acceleration(vector.zero()) return end self.age = self.age + dtime @@ -761,21 +774,22 @@ minetest.register_entity(":__builtin:item", { -- Delete corrupted item entities. The itemstring MUST be non-empty on its first step, -- otherwise there might have some data corruption. if self.itemstring == "" then - minetest.log("warning", "Item entity with empty itemstring found at "..minetest.pos_to_string(self.object:get_pos()).. "! Deleting it now.") + minetest.log("warning", + "Item entity with empty itemstring found at " .. minetest.pos_to_string(self.object:get_pos()) .. + "! Deleting it now.") self._removed = true self.object:remove() return end local p = self.object:get_pos() - -- If hopper has taken item, it has gone, and no operations should be conducted on this item if hopper_take_item(self, p) then return end - local node = minetest.get_node_or_nil(p) - local in_unloaded = (node == nil) + local node = minetest.get_node(p) + local in_unloaded = node.name == "ignore" if in_unloaded then -- Don't infinetly fall into unloaded map @@ -785,27 +799,27 @@ minetest.register_entity(":__builtin:item", { if self.is_clock then self.object:set_properties({ - textures = {"mcl_clock:clock_" .. (mcl_worlds.clock_works(p) and mcl_clock.old_time or mcl_clock.random_frame)} + textures = { "mcl_clock:clock_" .. (mcl_worlds.clock_works(p) and mcl_clock.old_time or mcl_clock.random_frame) } }) end local nn = node.name local is_in_water = (minetest.get_item_group(nn, "liquid") ~= 0) - local nn_above = minetest.get_node({x=p.x, y=p.y+0.1, z=p.z}).name + local nn_above = minetest.get_node(vector.offset(p, 0, 0.1, 0)).name -- make sure it's more or less stationary and is at water level local sleep_threshold = 0.3 local is_floating = false local is_stationary = math.abs(self.object:get_velocity().x) < sleep_threshold - and math.abs(self.object:get_velocity().y) < sleep_threshold - and math.abs(self.object:get_velocity().z) < sleep_threshold + and math.abs(self.object:get_velocity().y) < sleep_threshold + and math.abs(self.object:get_velocity().z) < sleep_threshold if is_in_water and is_stationary then is_floating = (is_in_water and (minetest.get_item_group(nn_above, "liquid") == 0)) end if is_floating and self.physical_state == true then - self.object:set_velocity({x = 0, y = 0, z = 0}) - self.object:set_acceleration({x = 0, y = 0, z = 0}) + self.object:set_velocity(vector.zero()) + self.object:set_acceleration(vector.zero()) disable_physics(self.object, self) end -- If no collector was found for a long enough time, declare the magnet as disabled @@ -825,7 +839,7 @@ minetest.register_entity(":__builtin:item", { --Wait 2 seconds to allow mob drops to be cooked, & picked up instead of instantly destroyed. if self.age > 2 and minetest.get_item_group(self.itemstring, "fire_immune") == 0 then if dg ~= 2 then - minetest.sound_play("builtin_item_lava", {pos = self.object:get_pos(), gain = 0.5}) + minetest.sound_play("builtin_item_lava", { pos = self.object:get_pos(), gain = 0.5 }) end self._removed = true self.object:remove() @@ -865,7 +879,7 @@ minetest.register_entity(":__builtin:item", { end -- Check which one of the 4 sides is free - for o=1, #order do + for o = 1, #order do local nn = minetest.get_node(vector.add(p, order[o])).name local def = minetest.registered_nodes[nn] if def and def.walkable == false and nn ~= "ignore" then @@ -875,7 +889,7 @@ minetest.register_entity(":__builtin:item", { end -- If none of the 4 sides is free, shoot upwards if shootdir == nil then - shootdir = { x=0, y=1, z=0 } + shootdir = vector.new(0, 1, 0) local nn = minetest.get_node(vector.add(p, shootdir)).name if nn == "ignore" then -- Do not push into ignore @@ -885,7 +899,7 @@ minetest.register_entity(":__builtin:item", { -- Set new item moving speed accordingly local newv = vector.multiply(shootdir, 3) - self.object:set_acceleration({x = 0, y = 0, z = 0}) + self.object:set_acceleration(vector.zero()) self.object:set_velocity(newv) disable_physics(self.object, self, false, false) @@ -907,10 +921,10 @@ minetest.register_entity(":__builtin:item", { if self._forcetimer > 0 then local cbox = self.object:get_properties().collisionbox local ok = false - if self._force.x > 0 and (p.x > (self._forcestart.x + 0.5 + (cbox[4] - cbox[1])/2)) then ok = true - elseif self._force.x < 0 and (p.x < (self._forcestart.x + 0.5 - (cbox[4] - cbox[1])/2)) then ok = true - elseif self._force.z > 0 and (p.z > (self._forcestart.z + 0.5 + (cbox[6] - cbox[3])/2)) then ok = true - elseif self._force.z < 0 and (p.z < (self._forcestart.z + 0.5 - (cbox[6] - cbox[3])/2)) then ok = true end + if self._force.x > 0 and (p.x > (self._forcestart.x + 0.5 + (cbox[4] - cbox[1]) / 2)) then ok = true + elseif self._force.x < 0 and (p.x < (self._forcestart.x + 0.5 - (cbox[4] - cbox[1]) / 2)) then ok = true + elseif self._force.z > 0 and (p.z > (self._forcestart.z + 0.5 + (cbox[6] - cbox[3]) / 2)) then ok = true + elseif self._force.z < 0 and (p.z < (self._forcestart.z + 0.5 - (cbox[6] - cbox[3]) / 2)) then ok = true end -- Item was successfully forced out. No more pushing if ok then self._forcetimer = -1 @@ -941,7 +955,7 @@ minetest.register_entity(":__builtin:item", { -- Set new item moving speed into the direciton of the liquid local newv = vector.multiply(vec, f) -- Swap to acceleration instead of a static speed to better mimic MC mechanics. - self.object:set_acceleration({x = newv.x, y = -0.22, z = newv.z}) + self.object:set_acceleration(vector.new(newv.x, -0.22, newv.z)) self.physical_state = true self._flowing = true @@ -954,9 +968,10 @@ minetest.register_entity(":__builtin:item", { local cur_vec = self.object:get_velocity() -- apply some acceleration in the opposite direction so it doesn't slide forever local vec = { - x = 0 -cur_vec.x*0.9, - y = 3 -cur_vec.y*0.9, - z = 0 -cur_vec.z*0.9} + x = 0 - cur_vec.x * 0.9, + y = 3 - cur_vec.y * 0.9, + z = 0 - cur_vec.z * 0.9 + } self.object:set_acceleration(vec) -- slow down the item in water local vel = self.object:get_velocity() @@ -980,20 +995,20 @@ minetest.register_entity(":__builtin:item", { end -- If node is not registered or node is walkably solid and resting on nodebox - local nn = minetest.get_node({x=p.x, y=p.y-0.5, z=p.z}).name + local nn = minetest.get_node(vector.offset(p, 0, -0.5, 0)).name local def = minetest.registered_nodes[nn] local v = self.object:get_velocity() local is_on_floor = def and (def.walkable and not def.groups.slippery and v.y == 0) if not minetest.registered_nodes[nn] - or is_floating or is_on_floor then + or is_floating or is_on_floor then local own_stack = ItemStack(self.object:get_luaentity().itemstring) -- Merge with close entities of the same item for _, object in pairs(minetest.get_objects_inside_radius(p, 0.8)) do local obj = object:get_luaentity() if obj and obj.name == "__builtin:item" - and obj.physical_state == false then + and obj.physical_state == false then if self:try_merge_with(own_stack, object, obj) then return end From 96e83e866c7152526cbbda22ee1035a4258a86e4 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 11 Nov 2022 00:15:28 +0100 Subject: [PATCH 05/14] Make `mcl_item_entity` API public --- mods/ENTITIES/mcl_item_entity/init.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index a54e087f9..60cfe9dd9 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -22,10 +22,9 @@ minetest.register_on_leaveplayer(function(player) pool[player:get_player_name()] = nil end) - local has_awards = minetest.get_modpath("awards") -local mcl_item_entity = {} +mcl_item_entity = {} --basic settings local item_drop_settings = {} --settings table @@ -46,19 +45,23 @@ local function get_gravity() return tonumber(minetest.settings:get("movement_gravity")) or 9.81 end -local registered_pickup_achievement = {} +mcl_item_entity.registered_pickup_achievement = {} ---TODO: remove limitation of 1 award per itemname +---Register an achievement that will be unlocked on pickup. +--- +---TODO: remove limitation of 1 award per itemname +---@param itemname string +---@param award string function mcl_item_entity.register_pickup_achievement(itemname, award) if not has_awards then minetest.log("warning", "[mcl_item_entity] Trying to register pickup achievement [" .. award .. "] for [" .. itemname .. "] while awards missing") - elseif registered_pickup_achievement[itemname] then + elseif mcl_item_entity.registered_pickup_achievement[itemname] then minetest.log("error", "[mcl_item_entity] Trying to register already existing pickup achievement [" .. award .. "] for [" .. itemname .. "]") else - registered_pickup_achievement[itemname] = award + mcl_item_entity.registered_pickup_achievement[itemname] = award end end @@ -77,7 +80,7 @@ local function check_pickup_achievements(object, player) if has_awards then local itemname = ItemStack(object:get_luaentity().itemstring):get_name() local playername = player:get_player_name() - for name, award in pairs(registered_pickup_achievement) do + for name, award in pairs(mcl_item_entity.registered_pickup_achievement) do if itemname == name or minetest.get_item_group(itemname, name) ~= 0 then awards.unlock(playername, award) end From 89821a8329681acdbd271a73996654a2c50495d8 Mon Sep 17 00:00:00 2001 From: kabou Date: Sat, 31 Dec 2022 10:41:39 +0100 Subject: [PATCH 06/14] Rename cocoa pod placement function. * Rename cocoa pod placement function to match the `on_place` call in the cocoa pods item definition. * Make the function local, there are no callers outside of mcl_cocoas. --- mods/ITEMS/mcl_cocoas/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_cocoas/init.lua b/mods/ITEMS/mcl_cocoas/init.lua index 7c22927f8..59d902d12 100644 --- a/mods/ITEMS/mcl_cocoas/init.lua +++ b/mods/ITEMS/mcl_cocoas/init.lua @@ -3,7 +3,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) mcl_cocoas = {} -- Place cocoa -function mcl_cocoas.place(itemstack, placer, pt, plantname) +local function cocoa_place(itemstack, placer, pt, plantname) -- check if pointing at a node if not pt or pt.type ~= "node" then return From 2a37d38f6cb09a97e2de24bff4c7220422cb81bb Mon Sep 17 00:00:00 2001 From: kabou Date: Sat, 31 Dec 2022 11:18:04 +0100 Subject: [PATCH 07/14] Reformat cocoa pod node definition groups. --- mods/ITEMS/mcl_cocoas/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_cocoas/init.lua b/mods/ITEMS/mcl_cocoas/init.lua index 59d902d12..0792972be 100644 --- a/mods/ITEMS/mcl_cocoas/init.lua +++ b/mods/ITEMS/mcl_cocoas/init.lua @@ -90,7 +90,11 @@ local crop_def = { }, }, groups = { - handy=1,axey=1, cocoa=1, not_in_creative_inventory=1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1, attached_node_facedir=1, + handy = 1, axey = 1, + dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1, + attached_node_facedir=1, + not_in_creative_inventory=1, + cocoa=1 }, sounds = mcl_sounds.node_sound_wood_defaults(), on_rotate = false, From 50d8e95c168a4a8410f657fae9457fc597e0ae7d Mon Sep 17 00:00:00 2001 From: test1 Date: Sat, 31 Dec 2022 13:16:52 +0000 Subject: [PATCH 08/14] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d9ca077d..f69647efe 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ The following features are incomplete: * Some monsters and animals * Redstone-related things -* Special minecarts +* Some special minecarts (hopper and chest minecarts work) * A couple of non-trivial blocks and items Bonus features (not found in Minecraft): From 3026808a7194a5dd166d01e41ccd29068879e979 Mon Sep 17 00:00:00 2001 From: iliekprogrammar Date: Sat, 31 Dec 2022 17:31:57 +0800 Subject: [PATCH 09/14] Add templates for issues and pull requests --- .gitea/issue_template/bug.md | 36 +++++++++++++++++++ .gitea/issue_template/feature_request.md | 26 ++++++++++++++ .../issue_template/missing_feature_request.md | 25 +++++++++++++ .gitea/pull_request_template.md | 20 +++++++++++ 4 files changed, 107 insertions(+) create mode 100644 .gitea/issue_template/bug.md create mode 100644 .gitea/issue_template/feature_request.md create mode 100644 .gitea/issue_template/missing_feature_request.md create mode 100644 .gitea/pull_request_template.md diff --git a/.gitea/issue_template/bug.md b/.gitea/issue_template/bug.md new file mode 100644 index 000000000..9dd0454fc --- /dev/null +++ b/.gitea/issue_template/bug.md @@ -0,0 +1,36 @@ +--- + +name: "Bug report" +about: "File a bug report" +labels: + +- unconfirmed +- bug + +--- + + + + +MineClone2 version: + +# What happened? +Report about the bug! Please send large log snippets as an attachement file. + +# What should happen: +Tell us what should happen! + +# Steps to reproduce +Tell us how we can reproduce the bug! diff --git a/.gitea/issue_template/feature_request.md b/.gitea/issue_template/feature_request.md new file mode 100644 index 000000000..fdd6e3dae --- /dev/null +++ b/.gitea/issue_template/feature_request.md @@ -0,0 +1,26 @@ +--- + +name: "Feature request" +about: "File a feature request not in Minecraft" +labels: + +- "non-Minecraft feature" +- "needs discussion" + +--- + + + +# Feature +Tell us about your requested feature not in Minecraft! + +# Why +Tell us why should we implement it! diff --git a/.gitea/issue_template/missing_feature_request.md b/.gitea/issue_template/missing_feature_request.md new file mode 100644 index 000000000..55386a888 --- /dev/null +++ b/.gitea/issue_template/missing_feature_request.md @@ -0,0 +1,25 @@ +--- + +name: "Missing Feature request" +about: "File a missing feature request in Minecraft but not in MineClone2" +labels: + +- "missing feature" + +--- + + + +# Missing Feature +Tell us about the requested missing feature in Minecraft but not in MineClone2! + +# Why +Tell us why should we implement it! diff --git a/.gitea/pull_request_template.md b/.gitea/pull_request_template.md new file mode 100644 index 000000000..ebc848f17 --- /dev/null +++ b/.gitea/pull_request_template.md @@ -0,0 +1,20 @@ +--- + +name: "Pull request" +about: "Submit a pull request" +labels: + +--- + + + +Tell us about your pull request! Reference related issues, if necessary + +# Testing +Tell us how to test your changes! From 98dac6dcd79a2935ca7e67d40940292588cedc04 Mon Sep 17 00:00:00 2001 From: iliekprogrammar Date: Sat, 31 Dec 2022 18:13:19 +0800 Subject: [PATCH 10/14] Add "Testing/Review needed" tag to pull request templates --- .gitea/pull_request_template.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitea/pull_request_template.md b/.gitea/pull_request_template.md index ebc848f17..c4967ef22 100644 --- a/.gitea/pull_request_template.md +++ b/.gitea/pull_request_template.md @@ -4,6 +4,8 @@ name: "Pull request" about: "Submit a pull request" labels: +- "Testing/Review needed" + --- MineClone2 version: -# What happened? +### What happened? Report about the bug! Please send large log snippets as an attachement file. -# What should happen: +### What should happen: Tell us what should happen! -# Steps to reproduce +### Steps to reproduce Tell us how we can reproduce the bug! diff --git a/.gitea/issue_template/feature_request.md b/.gitea/issue_template/feature_request.md index fdd6e3dae..58a7437ab 100644 --- a/.gitea/issue_template/feature_request.md +++ b/.gitea/issue_template/feature_request.md @@ -19,8 +19,8 @@ By submitting this issue, you agree to follow our Code of Conduct: https://git.minetest.land/MineClone2/MineClone2/src/branch/master/CODE_OF_CONDUCT.md --> -# Feature +### Feature Tell us about your requested feature not in Minecraft! -# Why +### Why Tell us why should we implement it! diff --git a/.gitea/issue_template/missing_feature_request.md b/.gitea/issue_template/missing_feature_request.md index 55386a888..cb0bf786a 100644 --- a/.gitea/issue_template/missing_feature_request.md +++ b/.gitea/issue_template/missing_feature_request.md @@ -18,8 +18,8 @@ By submitting this issue, you agree to follow our Code of Conduct: https://git.minetest.land/MineClone2/MineClone2/src/branch/master/CODE_OF_CONDUCT.md --> -# Missing Feature -Tell us about the requested missing feature in Minecraft but not in MineClone2! +### Current feature in Minecraft +Tell us about the feature currently in Minecraft! -# Why -Tell us why should we implement it! +### Current feature in MineClone2 +Tell us about the feature currently in MineClone2! diff --git a/.gitea/pull_request_template.md b/.gitea/pull_request_template.md index ebc848f17..ec7207ee4 100644 --- a/.gitea/pull_request_template.md +++ b/.gitea/pull_request_template.md @@ -16,5 +16,5 @@ https://git.minetest.land/MineClone2/MineClone2/src/branch/master/CODE_OF_CONDUC Tell us about your pull request! Reference related issues, if necessary -# Testing +### Testing Tell us how to test your changes! From 6430fcf10308e0667640ba3801d4c3837497da14 Mon Sep 17 00:00:00 2001 From: iliekprogrammar Date: Sun, 1 Jan 2023 13:37:34 +0800 Subject: [PATCH 13/14] Clarify *missing feature request* template --- .gitea/issue_template/missing_feature_request.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/issue_template/missing_feature_request.md b/.gitea/issue_template/missing_feature_request.md index cb0bf786a..b3e275c9b 100644 --- a/.gitea/issue_template/missing_feature_request.md +++ b/.gitea/issue_template/missing_feature_request.md @@ -19,7 +19,7 @@ https://git.minetest.land/MineClone2/MineClone2/src/branch/master/CODE_OF_CONDUC --> ### Current feature in Minecraft -Tell us about the feature currently in Minecraft! +Tell us about the feature currently in Minecraft! What is it like on Minecraft? ### Current feature in MineClone2 -Tell us about the feature currently in MineClone2! +Tell us about the feature currently in MineClone2! What is different? From df6d1c026af55ed68627597656541882e771aff8 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Mon, 2 Jan 2023 21:48:58 +0000 Subject: [PATCH 14/14] Fix crash for sky colour if cannot find biome --- mods/ENVIRONMENT/mcl_weather/skycolor.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index d8e89baf1..3163b0a9d 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -136,9 +136,16 @@ mcl_weather.skycolor = { local biomesky local biomefog if mg_name ~= "v6" and mg_name ~= "singlenode" then - local biome = minetest.get_biome_name(minetest.get_biome_data(player:get_pos()).biome) - biomesky = minetest.registered_biomes[biome]._mcl_skycolor - biomefog = minetest.registered_biomes[biome]._mcl_fogcolor + local biome_index = minetest.get_biome_data(player:get_pos()).biome + local biome_name = minetest.get_biome_name(biome_index) + local biome = minetest.registered_biomes[biome_name] + if biome then + --minetest.log("action", string.format("Biome found for number: %s in biome: %s", tostring(biome_index), biome_name)) + biomesky = biome._mcl_skycolor + biomefog = biome._mcl_fogcolor + else + --minetest.log("action", string.format("No biome for number: %s in biome: %s", tostring(biome_index), biome_name)) + end end if (mcl_weather.state == "none") then -- Clear weather