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.
This commit is contained in:
Treer 2022-08-21 20:22:57 +10:00
parent d3f79e961b
commit e2690e8f57
3 changed files with 51 additions and 20 deletions

View File

@ -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

View File

@ -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=

View File

@ -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