Convert fences to NDT_CONNECTED.
authorAuke Kok <sofar@foo-projects.org>
Tue, 15 Dec 2015 05:49:20 +0000 (21:49 -0800)
committerparamat <mat.gregory@virginmedia.com>
Sun, 13 Mar 2016 04:10:51 +0000 (04:10 +0000)
This changes the drawtype of fences to NDT_CONNECTED nodebox drawtype.

These nodes are drawn by the client with the needed connections on
the fly as the scene is drawn. There is no logic needed by mods to
modify the nodes.

These fences connect to (1) other fences, (2) planks and (3) tree
trunks, but nothing else. They do not connect to stone, dirt, wool,
etc. This is done by the "connects_to" parameter, which takes groups
and node names.

Due to the way textures are wrapped, we can make these nodes look a
lot better by giving them a special tile.

This change requires minetest/minetest#3503.

mods/default/functions.lua
mods/default/nodes.lua
mods/default/textures/default_fence_acacia_wood.png [new file with mode: 0644]
mods/default/textures/default_fence_aspen_wood.png [new file with mode: 0644]
mods/default/textures/default_fence_junglewood.png [new file with mode: 0644]
mods/default/textures/default_fence_pine_wood.png [new file with mode: 0644]
mods/default/textures/default_fence_wood.png [new file with mode: 0644]

index 29506c40b8d5ad6aae4c87d278ccdc33e1e78cb2..a85009bf248d010981940fdd153032afd67494cc 100644 (file)
@@ -213,16 +213,27 @@ function default.register_fence(name, def)
        -- Allow almost everything to be overridden
        local default_fields = {
                paramtype = "light",
-               drawtype = "fencelike",
+               drawtype = "nodebox",
+               node_box = {
+                       type = "connected",
+                       fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}},
+                       -- connect_top =
+                       -- connect_bottom =
+                       connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
+                               {-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
+                       connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
+                               {-1/2,-5/16,-1/16,-1/8,-3/16,1/16}},
+                       connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
+                               {-1/16,-5/16,1/8,1/16,-3/16,1/2}},
+                       connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
+                               {1/8,-5/16,-1/16,1/2,-3/16,1/16}},
+               },
+               connects_to = {"group:fence", "group:wood", "group:tree"},
                inventory_image = fence_texture,
                wield_image = fence_texture,
-               tiles = { def.texture },
+               tiles = {def.texture},
                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 = {},
        }
        for k, v in pairs(default_fields) do
index 6ebf1a6a4a2d09c943a11562b8888671100e0990..7b03383d6150d7e1d8ea4c34a158f865058cdbc9 100644 (file)
@@ -1713,7 +1713,7 @@ minetest.register_node("default:ladder_steel", {
 
 default.register_fence("default:fence_wood", {
        description = "Wooden Fence",
-       texture = "default_wood.png",
+       texture = "default_fence_wood.png",
        material = "default:wood",
        groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
        sounds = default.node_sound_wood_defaults()
@@ -1721,7 +1721,7 @@ default.register_fence("default:fence_wood", {
 
 default.register_fence("default:fence_acacia_wood", {
        description = "Acacia Fence",
-       texture = "default_acacia_wood.png",
+       texture = "default_fence_acacia_wood.png",
        material = "default:acacia_wood",
        groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
        sounds = default.node_sound_wood_defaults()
@@ -1729,7 +1729,7 @@ default.register_fence("default:fence_acacia_wood", {
 
 default.register_fence("default:fence_junglewood", {
        description = "Junglewood Fence",
-       texture = "default_junglewood.png",
+       texture = "default_fence_junglewood.png",
        material = "default:junglewood",
        groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
        sounds = default.node_sound_wood_defaults()
@@ -1737,7 +1737,7 @@ default.register_fence("default:fence_junglewood", {
 
 default.register_fence("default:fence_pine_wood", {
        description = "Pine Fence",
-       texture = "default_pine_wood.png",
+       texture = "default_fence_pine_wood.png",
        material = "default:pine_wood",
        groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
        sounds = default.node_sound_wood_defaults()
@@ -1745,7 +1745,7 @@ default.register_fence("default:fence_pine_wood", {
 
 default.register_fence("default:fence_aspen_wood", {
        description = "Aspen Fence",
-       texture = "default_aspen_wood.png",
+       texture = "default_fence_aspen_wood.png",
        material = "default:aspen_wood",
        groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
        sounds = default.node_sound_wood_defaults()
diff --git a/mods/default/textures/default_fence_acacia_wood.png b/mods/default/textures/default_fence_acacia_wood.png
new file mode 100644 (file)
index 0000000..3b973f3
Binary files /dev/null and b/mods/default/textures/default_fence_acacia_wood.png differ
diff --git a/mods/default/textures/default_fence_aspen_wood.png b/mods/default/textures/default_fence_aspen_wood.png
new file mode 100644 (file)
index 0000000..7fb624d
Binary files /dev/null and b/mods/default/textures/default_fence_aspen_wood.png differ
diff --git a/mods/default/textures/default_fence_junglewood.png b/mods/default/textures/default_fence_junglewood.png
new file mode 100644 (file)
index 0000000..c390941
Binary files /dev/null and b/mods/default/textures/default_fence_junglewood.png differ
diff --git a/mods/default/textures/default_fence_pine_wood.png b/mods/default/textures/default_fence_pine_wood.png
new file mode 100644 (file)
index 0000000..74609d9
Binary files /dev/null and b/mods/default/textures/default_fence_pine_wood.png differ
diff --git a/mods/default/textures/default_fence_wood.png b/mods/default/textures/default_fence_wood.png
new file mode 100644 (file)
index 0000000..1e76430
Binary files /dev/null and b/mods/default/textures/default_fence_wood.png differ