From d16b530685d62f6891d8f4d537bf36acf842a077 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sat, 9 Mar 2024 10:29:03 -0800 Subject: [PATCH 1/4] Call old `on_place` when not clicking on portal material (#74) This is needed to work with telemosaic since telemosaic depends on `on_rightclick` being called on beacon node when wielding a mese crystal fragment. --- portal_api.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/portal_api.lua b/portal_api.lua index c67b27d..47e7c4c 100644 --- a/portal_api.lua +++ b/portal_api.lua @@ -2166,22 +2166,20 @@ function nether.unregister_portal(name) end function nether.register_portal_ignition_item(item_name, ignition_failure_sound) - + local old_on_place = minetest.registered_items[item_name].on_place or minetest.item_place minetest.override_item(item_name, { - on_place = function(stack, placer, pt) - local done = false + on_place = function(stack, placer, pt, ...) if pt.under and nether.is_frame_node[minetest.get_node(pt.under).name] then - done = ignite_portal(pt.under, placer:get_player_name()) + local done = ignite_portal(pt.under, placer:get_player_name()) if done and not minetest.settings:get_bool("creative_mode") then stack:take_item() end + if not done and ignition_failure_sound ~= nil then + minetest.sound_play(ignition_failure_sound, {pos = pt.under, max_hear_distance = 10}) + end + return stack end - if not done and ignition_failure_sound ~= nil then - minetest.sound_play(ignition_failure_sound, {pos = pt.under, max_hear_distance = 10}) - end - - - return stack + return old_on_place(stack, placer, pt, ...) end, }) From a6d1f55f0a4983a3616e7ecf5a6b972dd23fae40 Mon Sep 17 00:00:00 2001 From: Diablosxm <132860646+Diablosxm@users.noreply.github.com> Date: Sun, 28 Apr 2024 12:53:46 -0400 Subject: [PATCH 2/4] Technic and Toolranks support (#73) Co-authored-by: Treer --- .luacheckrc | 3 +++ init.lua | 6 ++++-- mod.conf | 2 +- nether-compressor-recipe.lua | 40 ++++++++++++++++++++++++++++++++++++ tools.lua | 32 +++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 nether-compressor-recipe.lua diff --git a/.luacheckrc b/.luacheckrc index 319eba3..6946337 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -27,9 +27,12 @@ read_globals = { "stairsplus", "string.split", table = { fields = { "copy", "getn" } }, + "technic", + "toolranks", "vector", "VoxelArea", "VoxelManip", + "walls", xpanes = { fields = { "register_pane" } }, } diff --git a/init.lua b/init.lua index 2251be9..9f8116e 100644 --- a/init.lua +++ b/init.lua @@ -144,7 +144,9 @@ if nether.NETHER_REALM_ENABLED then end end dofile(nether.path .. "/portal_examples.lua") - +if minetest.get_modpath("technic") then + dofile(nether.path .. "/nether-compressor-recipe.lua") +end -- Portals are ignited by right-clicking with a mese crystal fragment nether.register_portal_ignition_item( @@ -345,4 +347,4 @@ minetest.register_on_dieplayer( ) end end -) \ No newline at end of file +) diff --git a/mod.conf b/mod.conf index 50426d2..978b9b6 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = nether description = Adds a deep underground realm with different mapgen that you can reach with obsidian portals. depends = stairs, default -optional_depends = moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls +optional_depends = toolranks, technic, moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls diff --git a/nether-compressor-recipe.lua b/nether-compressor-recipe.lua new file mode 100644 index 0000000..5babc35 --- /dev/null +++ b/nether-compressor-recipe.lua @@ -0,0 +1,40 @@ +local S = minetest.get_translator("nether") + +technic.register_recipe_type("compressing", { description = S("Compressing") }) + +function register_compressor_recipe(data) + data.time = data.time or 4 + technic.register_recipe("compressing", data) +end + +local recipes = { + {"nether:rack", "nether:brick",}, + {"nether:rack_deep", "nether:brick_deep"}, + {"nether:brick 9", "nether:brick_compressed", 12}, + {"nether:brick_compressed 9", "nether:nether_lump", 12} + +} +-- clear craft recipe +-- But allow brick blocks to be crafted like the other bricks from Minetest Game + +minetest.clear_craft({ + recipe = { + {"nether:brick","nether:brick","nether:brick"}, + {"nether:brick","nether:brick","nether:brick"}, + {"nether:brick","nether:brick","nether:brick"}, + } +}) + +minetest.clear_craft({ + recipe = { + {"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"}, + {"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"}, + {"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"}, + } +}) + +for _, data in pairs(recipes) do + register_compressor_recipe({input = {data[1]}, output = data[2], time = data[3]}) +end + + diff --git a/tools.lua b/tools.lua index 1591e47..740bf83 100644 --- a/tools.lua +++ b/tools.lua @@ -153,6 +153,38 @@ minetest.register_craft({ }) +if minetest.get_modpath("toolranks") then + + local function add_toolranks(name) + local nethertool_after_use = ItemStack(name):get_definition().after_use + toolranks.add_tool(name) + local toolranks_after_use = ItemStack(name):get_definition().after_use + + if nethertool_after_use == nil or nethertool_after_use == toolranks_after_use then + return + end + + minetest.override_item(name, { + after_use = function(itemstack, user, node, digparams) + -- combine nethertool_after_use and toolranks_after_use by allowing + -- nethertool_after_use() to calculate the wear... + local initial_wear = itemstack:get_wear() + itemstack = nethertool_after_use(itemstack, user, node, digparams) + local wear = itemstack:get_wear() - initial_wear + itemstack:set_wear(initial_wear) -- restore/undo the wear + + -- ...and have toolranks_after_use() apply the wear. + digparams.wear = wear + return toolranks_after_use(itemstack, user, node, digparams) + end + }) + end + + add_toolranks("nether:pick_nether") + add_toolranks("nether:shovel_nether") + add_toolranks("nether:axe_nether") + add_toolranks("nether:sword_nether") +end --===========================-- From 01b6f3c56d9a22214b819da7ee8e1e5d25768011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikita=20Wi=C5=9Bniewski?= Date: Tue, 21 May 2024 01:22:39 +0700 Subject: [PATCH 3/4] No wear out in creative and replace add_wear with add_wear_by_uses (#76) --- tools.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools.lua b/tools.lua index 740bf83..9616b8a 100644 --- a/tools.lua +++ b/tools.lua @@ -384,10 +384,11 @@ minetest.register_tool("nether:lightstaff_eternal", { sound = {breaks = "default_tool_breaks"}, stack_max = 1, on_use = function(itemstack, user, pointed_thing) - if lightstaff_on_use(user, "#23F", 0) then -- was "#8088FF" or "#13F" + if lightstaff_on_use(user, "#23F", 0) -- was "#8088FF" or "#13F" + and not minetest.is_creative_enabled(user) then -- The staff of Eternal Light wears out, to limit how much -- a player can alter the nether with it. - itemstack:add_wear(65535 / (nether.lightstaff_uses - 1)) + itemstack:add_wear_by_uses(nether.lightstaff_uses) end return itemstack end From b51b83148315e3a0dc555e2aac974069d321eebe Mon Sep 17 00:00:00 2001 From: Treer Date: Wed, 17 Jul 2024 05:21:15 +1000 Subject: [PATCH 4/4] Remove technic (fix issue #77) (#78) nether added technic support on April 29, and technic added nether support on May 1, resulting in them both optionally depending on each other and becoming incompatible with each other. To resolve this, technic will keep the nether support, the compressor recipe has been moved into technic (https://github.com/minetest-mods/technic/pull/644), and this commit reverts the technic-related parts of a6d1f55f, removing the technic dependency. --- .luacheckrc | 1 - init.lua | 4 +--- mod.conf | 2 +- nether-compressor-recipe.lua | 40 ------------------------------------ 4 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 nether-compressor-recipe.lua diff --git a/.luacheckrc b/.luacheckrc index 6946337..c113881 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -27,7 +27,6 @@ read_globals = { "stairsplus", "string.split", table = { fields = { "copy", "getn" } }, - "technic", "toolranks", "vector", "VoxelArea", diff --git a/init.lua b/init.lua index 9f8116e..78209c9 100644 --- a/init.lua +++ b/init.lua @@ -144,9 +144,7 @@ if nether.NETHER_REALM_ENABLED then end end dofile(nether.path .. "/portal_examples.lua") -if minetest.get_modpath("technic") then - dofile(nether.path .. "/nether-compressor-recipe.lua") -end + -- Portals are ignited by right-clicking with a mese crystal fragment nether.register_portal_ignition_item( diff --git a/mod.conf b/mod.conf index 978b9b6..5eb348a 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = nether description = Adds a deep underground realm with different mapgen that you can reach with obsidian portals. depends = stairs, default -optional_depends = toolranks, technic, moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls +optional_depends = toolranks, moreblocks, mesecons, loot, dungeon_loot, doc_basics, fire, climate_api, ethereal, xpanes, walls diff --git a/nether-compressor-recipe.lua b/nether-compressor-recipe.lua deleted file mode 100644 index 5babc35..0000000 --- a/nether-compressor-recipe.lua +++ /dev/null @@ -1,40 +0,0 @@ -local S = minetest.get_translator("nether") - -technic.register_recipe_type("compressing", { description = S("Compressing") }) - -function register_compressor_recipe(data) - data.time = data.time or 4 - technic.register_recipe("compressing", data) -end - -local recipes = { - {"nether:rack", "nether:brick",}, - {"nether:rack_deep", "nether:brick_deep"}, - {"nether:brick 9", "nether:brick_compressed", 12}, - {"nether:brick_compressed 9", "nether:nether_lump", 12} - -} --- clear craft recipe --- But allow brick blocks to be crafted like the other bricks from Minetest Game - -minetest.clear_craft({ - recipe = { - {"nether:brick","nether:brick","nether:brick"}, - {"nether:brick","nether:brick","nether:brick"}, - {"nether:brick","nether:brick","nether:brick"}, - } -}) - -minetest.clear_craft({ - recipe = { - {"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"}, - {"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"}, - {"nether:brick_compressed","nether:brick_compressed","nether:brick_compressed"}, - } -}) - -for _, data in pairs(recipes) do - register_compressor_recipe({input = {data[1]}, output = data[2], time = data[3]}) -end - -