From e2690e8f576b87a689ba61f07baa7e0e178316af Mon Sep 17 00:00:00 2001 From: Treer Date: Sun, 21 Aug 2022 20:22:57 +1000 Subject: [PATCH] Use Minetest_game fences API if it's available Fixes #56, and adds netherbrick rails (for consistency with MTG) if the fences API is found. Using the MTG fence system adds interop between different fence types, and support for the "Tall fences and walls" option. I've left the nether's register_craft() call unchanged, it overrides the recipe that default.register_fence() registers, granting 6 fences per crafting instead of MTG's 4. --- locale/nether.fr.tr | 1 + locale/template.txt | 1 + nodes.lua | 69 ++++++++++++++++++++++++++++++++------------- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/locale/nether.fr.tr b/locale/nether.fr.tr index 24488ed..12ce386 100644 --- a/locale/nether.fr.tr +++ b/locale/nether.fr.tr @@ -66,6 +66,7 @@ Lava crust is strong enough to walk on, but still hot enough to inflict burns.= Nether Basalt= Nether Brick=Brique du Nether Nether Brick Fence=Barrière en briques du Nether +Nether Brick Fence Rail=Clôture en briques du Nether Nether Slab=Dalle du Nether Nether Stair=Escalier du Nether Netherrack=Roche du Nether diff --git a/locale/template.txt b/locale/template.txt index 701eef3..fa3d032 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -65,6 +65,7 @@ Lava crust is strong enough to walk on, but still hot enough to inflict burns.= Nether Basalt= Nether Brick= Nether Brick Fence= +Nether Brick Fence Rail= Nether Slab= Nether Stair= Netherrack= diff --git a/nodes.lua b/nodes.lua index b5cda2d..190eefe 100644 --- a/nodes.lua +++ b/nodes.lua @@ -249,26 +249,6 @@ minetest.register_node("nether:brick_cracked", { sounds = default.node_sound_stone_defaults(), }) -local fence_texture = - "default_fence_overlay.png^nether_brick.png^default_fence_overlay.png^[makealpha:255,126,126" - -minetest.register_node("nether:fence_nether_brick", { - description = S("Nether Brick Fence"), - drawtype = "fencelike", - tiles = {"nether_brick.png"}, - inventory_image = fence_texture, - wield_image = fence_texture, - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - selection_box = { - type = "fixed", - fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, - }, - groups = {cracky = 2, level = 2}, - sounds = default.node_sound_stone_defaults(), -}) - minetest.register_node("nether:brick_deep", { description = S("Deep Nether Brick"), tiles = {{ @@ -281,6 +261,55 @@ minetest.register_node("nether:brick_deep", { sounds = default.node_sound_stone_defaults() }) +-- Register fence and rails + +local fence_texture = + "default_fence_overlay.png^nether_brick.png^default_fence_overlay.png^[makealpha:255,126,126" + +if minetest.get_modpath("default") and minetest.global_exists("default") and default.register_fence ~= nil then + -- The Minetest_Game fences API is available, + -- using it adds interop between different fences, and the "Tall fences and walls" option. + default.register_fence("nether:fence_nether_brick", { + description = S("Nether Brick Fence"), + texture = "nether_brick.png", + inventory_image = fence_texture, + wield_image = fence_texture, + material = "nether:brick", + groups = {cracky = 2, level = 2}, + sounds = default.node_sound_stone_defaults() + }) + + default.register_fence_rail("nether:fence_rail_nether_brick", { + description = S("Nether Brick Fence Rail"), + texture = "nether_brick.png", + inventory_image = "default_fence_rail_overlay.png^nether_brick.png^" .. + "default_fence_rail_overlay.png^[makealpha:255,126,126", + wield_image = "default_fence_rail_overlay.png^nether_brick.png^" .. + "default_fence_rail_overlay.png^[makealpha:255,126,126", + material = "nether:brick", + groups = {cracky = 2, level = 2}, + sounds = default.node_sound_stone_defaults() + }) +else + -- Original nether fence code, preserved to avoid deeper coupling with MTG + minetest.register_node("nether:fence_nether_brick", { + description = S("Nether Brick Fence"), + drawtype = "fencelike", + tiles = {"nether_brick.png"}, + inventory_image = fence_texture, + wield_image = fence_texture, + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, + groups = {cracky = 2, level = 2}, + sounds = default.node_sound_stone_defaults(), + }) +end + -- Register stair and slab -- Nether bricks can be made into stairs, slabs, inner stairs, and outer stairs