From 20b53db32de0e283eb3f29f95b0e33f0af3c9eb4 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Mon, 28 Nov 2022 16:20:00 -0500 Subject: [PATCH 01/11] update licensing --- LICENSE.txt | 65 ++++++-------------------------------- api.lua | 26 +++++++++++++++ bitbucket-pipelines.yml | 30 ------------------ init.lua | 22 +++++++++++-- scripts/deploy.js | 18 +++++++++++ scripts/lls-check.js | 18 +++++++++++ table.lua | 36 +++++++++++++++++++++ types/minetest.type.lua | 1 + types/object.type.lua | 1 + types/xenchanting.type.lua | 2 +- 10 files changed, 130 insertions(+), 89 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index f166cc5..bce588e 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,8 +1,7 @@ GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Copyright (C) 2022 SaKeL Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -55,7 +54,7 @@ modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - + Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a @@ -111,7 +110,7 @@ modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - + GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -158,7 +157,7 @@ Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - + 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 @@ -216,7 +215,7 @@ instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - + Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. @@ -267,7 +266,7 @@ Library will still fall under Section 6.) distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - + 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work @@ -329,7 +328,7 @@ restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - + 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined @@ -370,7 +369,7 @@ subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - + 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or @@ -422,7 +421,7 @@ conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - + 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is @@ -454,49 +453,3 @@ RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! \ No newline at end of file diff --git a/api.lua b/api.lua index 2150dab..ae995ab 100644 --- a/api.lua +++ b/api.lua @@ -1,3 +1,21 @@ +--[[ + X Enchanting. Adds Enchanting Mechanics and API. + Copyright (C) 2022 SaKeL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to juraj.vajda@gmail.com +--]] + local S = minetest.get_translator(minetest.get_current_modname()) ---@type XEnchanting @@ -288,6 +306,7 @@ local function get_table_length(table) return length end +---@diagnostic disable-next-line: unused-local function XEnchanting.has_tool_group(self, name) if minetest.get_item_group(name, 'pickaxe') > 0 then return 'pickaxe' @@ -321,10 +340,12 @@ function XEnchanting.set_tool_enchantability(self, tool_def) }) end +---@diagnostic disable-next-line: unused-local function XEnchanting.get_enchanted_tool_capabilities(self, tool_def, enchantments) local tool_stack = ItemStack({ name = tool_def.name }) local tool_capabilities = tool_stack:get_tool_capabilities() + ---@diagnostic disable-next-line: unused-local for i, enchantment in ipairs(enchantments) do -- Efficiency if enchantment.id == 'efficiency' then @@ -439,6 +460,7 @@ function XEnchanting.get_enchanted_tool_capabilities(self, tool_def, enchantment return tool_capabilities end +---@diagnostic disable-next-line: unused-local function XEnchanting.get_randomseed(self) return tonumber(tostring(os.time()):reverse():sub(1, 9)) --[[@as integer]] end @@ -447,6 +469,7 @@ function XEnchanting.get_enchanted_descriptions(self, enchantments) local enchantments_desc = {} local enchantments_desc_masked = {} + ---@diagnostic disable-next-line: unused-local for i, enchantment in ipairs(enchantments) do local add_roman_numbers = true @@ -503,6 +526,7 @@ function XEnchanting.set_enchanted_tool(self, pos, itemstack, level, player_name ---@type table local final_enchantments_meta = {} + ---@diagnostic disable-next-line: unused-local for i, enchantment in ipairs(final_enchantments) do stack_meta:set_float('is_' .. enchantment.id, enchantment.value) -- store only necessary data, keeping the meta optimized @@ -611,6 +635,7 @@ function XEnchanting.get_enchantment_data(self, player, nr_of_bookshelfs, tool_d if not enchantment_def.groups then group_enchantments[enchantment_name] = enchantment_def else + ---@diagnostic disable-next-line: unused-local for i, group in ipairs(enchantment_def.groups) do if minetest.get_item_group(tool_def.name, group) > 0 then group_enchantments[enchantment_name] = enchantment_def @@ -697,6 +722,7 @@ function XEnchanting.get_enchantment_data(self, player, nr_of_bookshelfs, tool_d local total_weight = 0 -- calculate total weight + ---@diagnostic disable-next-line: unused-local for j, enchantment in ipairs(possible_enchantments) do total_weight = total_weight + self.enchantment_defs[enchantment.id].weight end diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 531a658..186a530 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -31,36 +31,6 @@ pipelines: script: - nvm use v17.2.0 - npm run lua-diagnostics - branches: - master: - - step: - name: Install Node Dependencies - caches: - - node-modules - - npm - - nvm - script: - - nvm install v17.2.0 - - npm i -g npm@8 - - npm ci - - parallel: - - step: - name: Lua Check - script: - - apt-get update - - apt-get -y install lua5.1 - - apt-get -y install luarocks - - luarocks install luacheck - - luacheck . - - step: - name: Lua Diagnostics - caches: - - node-modules - - npm - - nvm - script: - - nvm use v17.2.0 - - npm run lua-diagnostics tags: "*": - step: diff --git a/init.lua b/init.lua index 6d171bc..cc87492 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,20 @@ --- X Enchanting --- by SaKeL +--[[ + X Enchanting. Adds Enchanting Mechanics and API. + Copyright (C) 2022 SaKeL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to juraj.vajda@gmail.com +--]] local path = minetest.get_modpath('x_enchanting') local mod_start_time = minetest.get_us_time() @@ -156,6 +171,7 @@ minetest.register_on_mods_loaded(function() end end) +---@diagnostic disable-next-line: unused-local minetest.register_on_joinplayer(function(player, last_login) XEnchanting.form_context[player:get_player_name()] = nil @@ -164,6 +180,7 @@ minetest.register_on_joinplayer(function(player, last_login) end end) +---@diagnostic disable-next-line: unused-local minetest.register_on_leaveplayer(function(player, timed_out) XEnchanting.form_context[player:get_player_name()] = nil end) @@ -229,6 +246,7 @@ function minetest.handle_node_drops(pos, drops, digger) return old_handle_node_drops(pos, drops, digger) end +---@diagnostic disable-next-line: unused-local minetest.register_on_player_hpchange(function(player, hp_change, reason) -- Curse of Vanishing if (player:get_hp() + hp_change) <= 0 then diff --git a/scripts/deploy.js b/scripts/deploy.js index db93ac1..d777447 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -1,3 +1,21 @@ +/** + * Deploy code to CDB + * Copyright (C) 2022 SaKeL + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to juraj.vajda@gmail.com + */ + import fetch from 'node-fetch' import yargs from 'yargs/yargs' import {hideBin} from 'yargs/helpers' diff --git a/scripts/lls-check.js b/scripts/lls-check.js index 5b3e371..6c19659 100644 --- a/scripts/lls-check.js +++ b/scripts/lls-check.js @@ -1,3 +1,21 @@ +/** + * Run LUA diagnostics in continuous integration + * Copyright (C) 2022 SaKeL + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to juraj.vajda@gmail.com + */ + import * as path from 'node:path' import * as fs from 'node:fs' import {exec} from 'node:child_process' diff --git a/table.lua b/table.lua index 694fe78..0c3630f 100644 --- a/table.lua +++ b/table.lua @@ -1,3 +1,22 @@ +--[[ + X Enchanting. Adds Enchanting Mechanics and API. + Copyright (C) 2022 SaKeL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to juraj.vajda@gmail.com +--]] + +---@diagnostic disable-next-line screwdriver = minetest.global_exists('screwdriver') and screwdriver --[[@as MtgScrewdriver]] local S = minetest.get_translator(minetest.get_current_modname()) @@ -59,6 +78,7 @@ minetest.register_node('x_enchanting:table', { ---@param placer ObjectRef | nil ---@param itemstack ItemStack ---@param pointed_thing PointedThingDef + ---@diagnostic disable-next-line: unused-local after_place_node = function(pos, placer, itemstack, pointed_thing) local meta = minetest.get_meta(pos) @@ -79,6 +99,7 @@ minetest.register_node('x_enchanting:table', { ---@param clicker ObjectRef ---@param itemstack ItemStack ---@param pointed_thing? PointedThingDef + ---@diagnostic disable-next-line: unused-local on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) local meta = minetest.get_meta(pos) local p_name = clicker:get_player_name() @@ -123,6 +144,7 @@ minetest.register_node('x_enchanting:table', { ---@param pos Vector ---@param intensity? number ---@return table | nil + ---@diagnostic disable-next-line: unused-local on_blast = function(pos, intensity) if minetest.is_protected(pos, '') then return @@ -159,11 +181,13 @@ minetest.register_node('x_enchanting:table', { and inv:is_empty('trade') and not minetest.is_protected(pos, player:get_player_name()) end, + ---@diagnostic disable-next-line: unused-local on_rotate = function(pos, node, user, mode, new_param2) return false end, ---@param pos Vector ---@param elapsed number + ---@diagnostic disable-next-line: unused-local on_timer = function(pos, elapsed) -- entity local table_scroll = minetest.get_objects_inside_radius(pos, 0.9) @@ -234,6 +258,7 @@ minetest.register_node('x_enchanting:table', { end -- symbol particles + ---@diagnostic disable-next-line: unused-local for i = 1, 10, 1 do local pos_random = bookshelfs[math.random(1, #bookshelfs)] local x = pos.x - pos_random.x @@ -275,6 +300,7 @@ minetest.register_node('x_enchanting:table', { ---@param index number ---@param stack ItemStack ---@param player ObjectRef + ---@diagnostic disable-next-line: unused-local allow_metadata_inventory_put = function(pos, listname, index, stack, player) local st_meta = stack:get_meta() local st_name = stack:get_name() @@ -302,6 +328,7 @@ minetest.register_node('x_enchanting:table', { ---@param index number ---@param stack ItemStack ---@param player ObjectRef + ---@diagnostic disable-next-line: unused-local allow_metadata_inventory_take = function(pos, listname, index, stack, player) local st_name = stack:get_name() @@ -325,6 +352,7 @@ minetest.register_node('x_enchanting:table', { ---@param to_index number ---@param count number ---@param player ObjectRef + ---@diagnostic disable-next-line: unused-local allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) return 0 end, @@ -333,6 +361,7 @@ minetest.register_node('x_enchanting:table', { ---@param index number ---@param stack ItemStack ---@param player ObjectRef + ---@diagnostic disable-next-line: unused-local on_metadata_inventory_put = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) local p_name = player:get_player_name() @@ -368,6 +397,7 @@ minetest.register_node('x_enchanting:table', { ---@param index number ---@param stack ItemStack ---@param player ObjectRef + ---@diagnostic disable-next-line: unused-local on_metadata_inventory_take = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) local p_name = player:get_player_name() @@ -403,6 +433,7 @@ minetest.register_node('x_enchanting:table', { ---@param formname string ---@param fields table ---@param sender ObjectRef + ---@diagnostic disable-next-line: unused-local on_receive_fields = function(pos, formname, fields, sender) local p_name = sender:get_player_name() @@ -481,12 +512,14 @@ minetest.register_entity('x_enchanting:table_scroll', { }, ---@param self table ---@param killer ObjectRef + ---@diagnostic disable-next-line: unused-local on_death = function(self, killer) self.object:remove() end, ---@param self table ---@param staticdata StringAbstract ---@param dtime_s number + ---@diagnostic disable-next-line: unused-local on_activate = function(self, staticdata, dtime_s) self._scroll_closed = true self._tablechecktimer = 5 @@ -500,6 +533,7 @@ minetest.register_entity('x_enchanting:table_scroll', { ---@param self table ---@param dtime number ---@param moveresult? table + ---@diagnostic disable-next-line: unused-local on_step = function(self, dtime, moveresult) local pos = self.object:get_pos() @@ -528,6 +562,7 @@ minetest.register_entity('x_enchanting:table_scroll', { local found_player = false if #objects > 0 then + ---@diagnostic disable-next-line: unused-local for i, obj in ipairs(objects) do if obj:is_player() and obj:get_pos() then -- player @@ -589,6 +624,7 @@ minetest.register_entity('x_enchanting:table_scroll', { ---@param dir Vector ---@param damage number ---@return boolean | nil + ---@diagnostic disable-next-line: unused-local on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) return true end diff --git a/types/minetest.type.lua b/types/minetest.type.lua index 567da2a..8cb5ff3 100644 --- a/types/minetest.type.lua +++ b/types/minetest.type.lua @@ -16,6 +16,7 @@ ---@field get_node fun(pos: Vector): NodeDef Returns the node at the given position as table in the format `{name="node_name", param1=0, param2=0}`, returns `{name="ignore", param1=0, param2=0}` for unloaded areas. ---@field registered_nodes table Map of registered node definitions, indexed by name ---@field registered_ores table Map of registered ore definitions, indexed by name +---@field registered_craftitems table Map of registered craft items, indexed by name ---@field after fun(time: number|integer, func: fun(...), ...): JobTable Call the function `func` after `time` seconds, may be fractional. Optional: Variable number of arguments that are passed to `func`. ---@field sound_play fun(spec: SimpleSoundSpec|string, parameters: SoundParamDef, ephemeral?: boolean): any Returns a `handle`. Ephemeral sounds will not return a handle and can't be stopped or faded. It is recommend to use this for short sounds that happen in response to player actions (e.g. door closing). ---@field add_particlespawner fun(particlespawner_definition: ParticlespawnerDef): number|integer Add a `ParticleSpawner`, an object that spawns an amount of particles over `time` seconds. Returns an `id`, and -1 if adding didn't succeed. diff --git a/types/object.type.lua b/types/object.type.lua index 3fea64e..e662c5b 100644 --- a/types/object.type.lua +++ b/types/object.type.lua @@ -45,6 +45,7 @@ ---@field get_rotation fun(self: ObjectRef): Vector returns the rotation, a vector (radians) ---@field get_attach fun(self: ObjectRef): any Returns parent, bone, position, rotation, forced_visible, or nil if it isn't attached. ---@field set_attach fun(self: ObjectRef, parent: ObjectRef, bone?: string, position?: Vector, rotation?: Vector, forced_visible?: boolean): any Returns parent, bone, position, rotation, forced_visible, or nil if it isn't attached. +---@field drops table Custom for mob drops ---`ObjectRef` armor groups ---@class ObjectRefArmorGroups diff --git a/types/xenchanting.type.lua b/types/xenchanting.type.lua index d544062..a5ad609 100644 --- a/types/xenchanting.type.lua +++ b/types/xenchanting.type.lua @@ -50,5 +50,5 @@ ---@class EnchantmentDataSlot ---@field level number ---@field final_enchantments Enchantment[] ----@field tool_cap_data ToolCapabilitiesDef +---@field tool_cap_data ToolCapabilitiesDef | nil ---@field descriptions {["enchantments_desc"]: string, ["enchantments_desc_masked"]: string } From f8f40d61a2764b47bce98fb8817aaab63567bd2d Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Mon, 28 Nov 2022 16:26:42 -0500 Subject: [PATCH 02/11] update licensing --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 472040b..22939ae 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ GNU Lesser General Public License v2.1 or later (see included LICENSE file) ### Textures -**CC BY-SA 4.0, Pixel Perfection by XSSheep**, https://minecraft.curseforge.com/projects/pixel-perfection-freshly-updated +**CC-BY-SA-4.0, Pixel Perfection by XSSheep**, https://minecraft.curseforge.com/projects/pixel-perfection-freshly-updated - x_enchanting_symbol_1.png - x_enchanting_symbol_2.png @@ -227,11 +227,11 @@ GNU Lesser General Public License v2.1 or later (see included LICENSE file) - x_enchanting_scroll_mesh.png -- Derived from a texture TumeniNodes (CC BY-SA 3.0) - x_enchanting_scroll_particle.png - x_enchanting_table.png -- x_enchanting_gui_slot_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) -- x_enchanting_gui_cloth_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) -- x_enchanting_gui_cloth_trade_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) -- x_enchanting_gui_formbg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) -- x_enchanting_gui_hb_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) +- x_enchanting_gui_slot_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0) +- x_enchanting_gui_cloth_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0) +- x_enchanting_gui_cloth_trade_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0) +- x_enchanting_gui_formbg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0) +- x_enchanting_gui_hb_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0) ### Models From 48d215b08e4b69d3130f9395d3dcada5089cd3db Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Mon, 5 Dec 2022 15:14:51 -0500 Subject: [PATCH 03/11] add gitattributes --- .gitattributes | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2285905 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +# Creating an archive + +.* export-ignore +assets export-ignore +scripts export-ignore +bin export-ignore +docs export-ignore +types export-ignore +*.zip export-ignore +bitbucket-pipelines.yml export-ignore +package.json export-ignore +package-lock.json export-ignore +screenshot*.png export-ignore +i18n.py export-ignore +config.ld export-ignore From 46633e5b44fb654d016235c90e0dcbef40701f02 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Thu, 23 Feb 2023 21:18:58 -0500 Subject: [PATCH 04/11] Update License Year --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index bce588e..7fe94c9 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,7 +1,7 @@ GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 - Copyright (C) 2022 SaKeL + Copyright (C) 2023 SaKeL Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. From 8090e23daf82d45238ac354341d748b5e79469fb Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Thu, 23 Feb 2023 21:19:03 -0500 Subject: [PATCH 05/11] Update License Year --- api.lua | 2 +- init.lua | 2 +- scripts/deploy.js | 2 +- scripts/lls-check.js | 2 +- table.lua | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api.lua b/api.lua index ae995ab..ed65b61 100644 --- a/api.lua +++ b/api.lua @@ -1,6 +1,6 @@ --[[ X Enchanting. Adds Enchanting Mechanics and API. - Copyright (C) 2022 SaKeL + Copyright (C) 2023 SaKeL This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/init.lua b/init.lua index cc87492..140ea48 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ --[[ X Enchanting. Adds Enchanting Mechanics and API. - Copyright (C) 2022 SaKeL + Copyright (C) 2023 SaKeL This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/scripts/deploy.js b/scripts/deploy.js index d777447..6b1add4 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -1,6 +1,6 @@ /** * Deploy code to CDB - * Copyright (C) 2022 SaKeL + * Copyright (C) 2023 SaKeL * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/scripts/lls-check.js b/scripts/lls-check.js index 6c19659..c78dbd6 100644 --- a/scripts/lls-check.js +++ b/scripts/lls-check.js @@ -1,6 +1,6 @@ /** * Run LUA diagnostics in continuous integration - * Copyright (C) 2022 SaKeL + * Copyright (C) 2023 SaKeL * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/table.lua b/table.lua index 0c3630f..bdbc9ea 100644 --- a/table.lua +++ b/table.lua @@ -1,6 +1,6 @@ --[[ X Enchanting. Adds Enchanting Mechanics and API. - Copyright (C) 2022 SaKeL + Copyright (C) 2023 SaKeL This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public From 745708505fb2a46625aadfb7d2411ee0382e659c Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Thu, 23 Feb 2023 21:56:47 -0500 Subject: [PATCH 06/11] Prevent double enchantments and adding incompatible enchantments --- api.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/api.lua b/api.lua index ed65b61..8932f7d 100644 --- a/api.lua +++ b/api.lua @@ -306,6 +306,17 @@ local function get_table_length(table) return length end +---Find element v of t satisfying f(v) +local function tableFind(t, f) + for _, v in ipairs(t) do + if f(v) then + return v + end + end + + return nil +end + ---@diagnostic disable-next-line: unused-local function XEnchanting.has_tool_group(self, name) if minetest.get_item_group(name, 'pickaxe') > 0 then @@ -767,11 +778,17 @@ function XEnchanting.get_enchantment_data(self, player, nr_of_bookshelfs, tool_d table.remove(possible_enchantments, idx) end end - else local probability = (probability_level + 1) / 50 - table.insert(final_enchantments, rand_ench) + local alreadyInTable = tableFind(final_enchantments, function(value) + return value.id == rand_ench.id + end) + + if not alreadyInTable then + table.insert(final_enchantments, rand_ench) + end + table.remove(possible_enchantments, rand_ench_idx) for idx, value in pairs(possible_enchantments) do From 172eed1768328b639d89e381cee39312079026c7 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Thu, 23 Feb 2023 21:57:21 -0500 Subject: [PATCH 07/11] Disable Lua Diagnostics in pipeline --- bitbucket-pipelines.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 186a530..53b7a09 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -43,24 +43,24 @@ pipelines: - nvm install v17.2.0 - npm i -g npm@8 - npm ci - - parallel: - - step: - name: Lua Check - script: - - apt-get update - - apt-get -y install lua5.1 - - apt-get -y install luarocks - - luarocks install luacheck - - luacheck . - - step: - name: Lua Diagnostics - caches: - - node-modules - - npm - - nvm - script: - - nvm use v17.2.0 - - npm run lua-diagnostics + # - parallel: + - step: + name: Lua Check + script: + - apt-get update + - apt-get -y install lua5.1 + - apt-get -y install luarocks + - luarocks install luacheck + - luacheck . + # - step: + # name: Lua Diagnostics + # caches: + # - node-modules + # - npm + # - nvm + # script: + # - nvm use v17.2.0 + # - npm run lua-diagnostics - step: name: Deploy to ContentDB caches: From 4a0b45f472ddb63545ee795055ad81fe5ffbb9b5 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Sun, 26 Feb 2023 10:34:18 -0500 Subject: [PATCH 08/11] 3 Add support for item_drop mod --- README.md | 1 + mod.conf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 22939ae..62e938a 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ end ## Optional Dependencies - xdecor (adjusts conflicting recipe) +- item_drop (make sure fortune will execute before item_drop mod overrides `handle_node_drops`) ## License: diff --git a/mod.conf b/mod.conf index 24bb8a3..a8c0b1f 100644 --- a/mod.conf +++ b/mod.conf @@ -1,6 +1,6 @@ name = x_enchanting description = Adds Enchanting Mechanics and API. depends = -optional_depends = xdecor +optional_depends = xdecor, item_drop supported_games = minetest_game min_minetest_version = 5.4 From c5c53b63eeb2f9d409d6e008c6ec4e2c89b88d64 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Sun, 26 Feb 2023 10:42:06 -0500 Subject: [PATCH 09/11] 3 Fix indentation --- api.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api.lua b/api.lua index 8932f7d..7bae93f 100644 --- a/api.lua +++ b/api.lua @@ -309,9 +309,9 @@ end ---Find element v of t satisfying f(v) local function tableFind(t, f) for _, v in ipairs(t) do - if f(v) then - return v - end + if f(v) then + return v + end end return nil From f4ed50789721e5f5cc980d88eeb8ed0d859e528b Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Sat, 1 Apr 2023 14:40:34 -0400 Subject: [PATCH 10/11] Add missing use_texture_alpha --- table.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/table.lua b/table.lua index bdbc9ea..fd0c3a1 100644 --- a/table.lua +++ b/table.lua @@ -31,6 +31,7 @@ minetest.register_node('x_enchanting:table', { drawtype = 'mesh', mesh = 'x_enchanting_table.obj', tiles = { 'x_enchanting_table.png' }, + use_texture_alpha = 'clip', paramtype = 'light', paramtype2 = 'facedir', walkable = true, From 693ace14c2c29211ba9169109498e9574ea5d0bd Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Thu, 7 Dec 2023 10:47:30 -0500 Subject: [PATCH 11/11] Add tool texture overlay when enchanted --- README.md | 2 -- api.lua | 17 +++++++++++++++++ textures/x_enchanting_glint.png | Bin 0 -> 365 bytes 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 textures/x_enchanting_glint.png diff --git a/README.md b/README.md index 62e938a..761c567 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,6 @@ Adds Enchanting Mechanics and API. * mesh node model * mesh entity model and animations -NOTE: item inventory/wield image will not be adjusted until this feature is supported by MT engine, see: https://github.com/minetest/minetest/issues/5686 - ## How To ### Enchanting Setup diff --git a/api.lua b/api.lua index 7bae93f..01ce459 100644 --- a/api.lua +++ b/api.lua @@ -552,6 +552,23 @@ function XEnchanting.set_enchanted_tool(self, pos, itemstack, level, player_name stack_meta:set_int('is_enchanted', 1) stack_meta:set_string('x_enchanting', minetest.serialize(final_enchantments_meta)) + + if tool_def and tool_def.inventory_image and tool_def.inventory_image ~= '' then + stack_meta:set_string('inventory_image', tool_def.inventory_image .. '^((' .. tool_def.inventory_image .. '^[contrast:127:127)^[mask:x_enchanting_glint.png^[opacity:80)') + end + + if tool_def and tool_def.inventory_overlay and tool_def.inventory_overlay ~= '' then + stack_meta:set_string('inventory_overlay', tool_def.inventory_overlay .. '^((' .. tool_def.inventory_overlay .. '^[contrast:127:127)^[mask:x_enchanting_glint.png^[opacity:80)') + end + + if tool_def and tool_def.wield_image and tool_def.wield_image ~= '' then + stack_meta:set_string('wield_image', tool_def.wield_image .. '^((' .. tool_def.wield_image .. '^[contrast:127:127)^[mask:x_enchanting_glint.png^[opacity:80)') + end + + if tool_def and tool_def.wield_overlay and tool_def.wield_overlay ~= '' then + stack_meta:set_string('wield_overlay', tool_def.wield_overlay .. '^((' .. tool_def.wield_overlay .. '^[contrast:127:127)^[mask:x_enchanting_glint.png^[opacity:80)') + end + inv:set_stack('item', 1, itemstack) local trade_stack = inv:get_stack('trade', 1) diff --git a/textures/x_enchanting_glint.png b/textures/x_enchanting_glint.png new file mode 100644 index 0000000000000000000000000000000000000000..205f5b62e309d116d97c0bfd0652783cd1fb3637 GIT binary patch literal 365 zcmV-z0h0cSP)8 z`^b+pG|)Ix@42X;H$R%0)nZ6P$GcmI#ZcC-JCDw9jra%E1yR4s7|4Ex zc9JY87ar|I7vczRQE9s1xTCu(%zQM_8%}5*%DZB$Pn>~3ck~+_%?0#Mqkb0>)X4)y z`?`6Ea$$#~>EqAe_tj2x7E7G5%>_rR*I3taT_~ZfXIO5ro?(NgRfR5~nF$czhzIGZ zlN(LNt|%foTi?lXvrD@)ry5kHN!RdkR_s=o+`BaJ>`wA*s6oj< zq1i31Ubilgo6yhtup$YXLTjcry0tbI>wk;+q9hKJBhRaIOY{2=D~@ud3Cj=r00000 LNkvXXu0mjf$k3<1 literal 0 HcmV?d00001