Skip to content

Commit c42a525

Browse files
mbartlett21paramat
authored andcommittedSep 16, 2019
Add option for non-jumpable fences and walls
Add an option, default disabled, to extend the collision boxes upwards.
1 parent 1f7ea89 commit c42a525

File tree

5 files changed

+68
-35
lines changed

5 files changed

+68
-35
lines changed
 

‎minetest.conf.example

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ default:torch 99,default:cobble 99
6060
# Default value is true.
6161
#enable_bed_night_skip = true
6262

63+
# If enabled, fences and walls cannot be jumped over.
64+
#enable_fence_tall = false
65+
6366
# Whether the engine's spawn search, which does not check for a suitable
6467
# starting biome, is used.
6568
# Default value is false.

‎mods/default/functions.lua

+40-25
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ end
273273
--
274274
-- Fence registration helper
275275
--
276+
local fence_collision_extra = minetest.settings:get_bool("enable_fence_tall") and 3/8 or 0
276277

277278
function default.register_fence(name, def)
278279
minetest.register_craft({
@@ -291,17 +292,27 @@ function default.register_fence(name, def)
291292
drawtype = "nodebox",
292293
node_box = {
293294
type = "connected",
294-
fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}},
295+
fixed = {-1/8, -1/2, -1/8, 1/8, 1/2, 1/8},
295296
-- connect_top =
296297
-- connect_bottom =
297-
connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
298-
{-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
299-
connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
300-
{-1/2,-5/16,-1/16,-1/8,-3/16,1/16}},
301-
connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
302-
{-1/16,-5/16,1/8,1/16,-3/16,1/2}},
303-
connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
304-
{1/8,-5/16,-1/16,1/2,-3/16,1/16}},
298+
connect_front = {{-1/16, 3/16, -1/2, 1/16, 5/16, -1/8 },
299+
{-1/16, -5/16, -1/2, 1/16, -3/16, -1/8 }},
300+
connect_left = {{-1/2, 3/16, -1/16, -1/8, 5/16, 1/16},
301+
{-1/2, -5/16, -1/16, -1/8, -3/16, 1/16}},
302+
connect_back = {{-1/16, 3/16, 1/8, 1/16, 5/16, 1/2 },
303+
{-1/16, -5/16, 1/8, 1/16, -3/16, 1/2 }},
304+
connect_right = {{ 1/8, 3/16, -1/16, 1/2, 5/16, 1/16},
305+
{ 1/8, -5/16, -1/16, 1/2, -3/16, 1/16}}
306+
},
307+
collision_box = {
308+
type = "connected",
309+
fixed = {-1/8, -1/2, -1/8, 1/8, 1/2 + fence_collision_extra, 1/8},
310+
-- connect_top =
311+
-- connect_bottom =
312+
connect_front = {-1/8, -1/2, -1/2, 1/8, 1/2 + fence_collision_extra, -1/8},
313+
connect_left = {-1/2, -1/2, -1/8, -1/8, 1/2 + fence_collision_extra, 1/8},
314+
connect_back = {-1/8, -1/2, 1/8, 1/8, 1/2 + fence_collision_extra, 1/2},
315+
connect_right = { 1/8, -1/2, -1/8, 1/2, 1/2 + fence_collision_extra, 1/8}
305316
},
306317
connects_to = {"group:fence", "group:wood", "group:tree", "group:wall"},
307318
inventory_image = fence_texture,
@@ -349,24 +360,28 @@ function default.register_fence_rail(name, def)
349360
drawtype = "nodebox",
350361
node_box = {
351362
type = "connected",
352-
fixed = {
353-
{-1/16, 3/16, -1/16, 1/16, 5/16, 1/16},
354-
{-1/16, -3/16, -1/16, 1/16, -5/16, 1/16}
355-
},
363+
fixed = {{-1/16, 3/16, -1/16, 1/16, 5/16, 1/16},
364+
{-1/16, -3/16, -1/16, 1/16, -5/16, 1/16}},
365+
-- connect_top =
366+
-- connect_bottom =
367+
connect_front = {{-1/16, 3/16, -1/2, 1/16, 5/16, -1/16},
368+
{-1/16, -5/16, -1/2, 1/16, -3/16, -1/16}},
369+
connect_left = {{-1/2, 3/16, -1/16, -1/16, 5/16, 1/16},
370+
{-1/2, -5/16, -1/16, -1/16, -3/16, 1/16}},
371+
connect_back = {{-1/16, 3/16, 1/16, 1/16, 5/16, 1/2 },
372+
{-1/16, -5/16, 1/16, 1/16, -3/16, 1/2 }},
373+
connect_right = {{ 1/16, 3/16, -1/16, 1/2, 5/16, 1/16},
374+
{ 1/16, -5/16, -1/16, 1/2, -3/16, 1/16}}
375+
},
376+
collision_box = {
377+
type = "connected",
378+
fixed = {-1/8, -1/2, -1/8, 1/8, 1/2 + fence_collision_extra, 1/8},
356379
-- connect_top =
357380
-- connect_bottom =
358-
connect_front = {
359-
{-1/16, 3/16, -1/2, 1/16, 5/16, -1/16},
360-
{-1/16, -5/16, -1/2, 1/16, -3/16, -1/16}},
361-
connect_left = {
362-
{-1/2, 3/16, -1/16, -1/16, 5/16, 1/16},
363-
{-1/2, -5/16, -1/16, -1/16, -3/16, 1/16}},
364-
connect_back = {
365-
{-1/16, 3/16, 1/16, 1/16, 5/16, 1/2},
366-
{-1/16, -5/16, 1/16, 1/16, -3/16, 1/2}},
367-
connect_right = {
368-
{1/16, 3/16, -1/16, 1/2, 5/16, 1/16},
369-
{1/16, -5/16, -1/16, 1/2, -3/16, 1/16}},
381+
connect_front = {-1/8, -1/2, -1/2, 1/8, 1/2 + fence_collision_extra, -1/8},
382+
connect_left = {-1/2, -1/2, -1/8, -1/8, 1/2 + fence_collision_extra, 1/8},
383+
connect_back = {-1/8, -1/2, 1/8, 1/8, 1/2 + fence_collision_extra, 1/2},
384+
connect_right = { 1/8, -1/2, -1/8, 1/2, 1/2 + fence_collision_extra, 1/8}
370385
},
371386
connects_to = {"group:fence", "group:wall"},
372387
inventory_image = fence_rail_texture,

‎mods/doors/init.lua

+5-4
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ minetest.register_craft({
725725

726726

727727
----fence gate----
728+
local fence_collision_extra = minetest.settings:get_bool("enable_fence_tall") and 3/8 or 0
728729

729730
function doors.register_fencegate(name, def)
730731
local fence = {
@@ -748,7 +749,7 @@ function doors.register_fencegate(name, def)
748749
end,
749750
selection_box = {
750751
type = "fixed",
751-
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
752+
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}
752753
},
753754
}
754755

@@ -774,7 +775,7 @@ function doors.register_fencegate(name, def)
774775
fence_closed.sound = "doors_fencegate_open"
775776
fence_closed.collision_box = {
776777
type = "fixed",
777-
fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
778+
fixed = {-1/2, -1/2, -1/8, 1/2, 1/2 + fence_collision_extra, 1/8}
778779
}
779780

780781
local fence_open = table.copy(fence)
@@ -784,8 +785,8 @@ function doors.register_fencegate(name, def)
784785
fence_open.groups.not_in_creative_inventory = 1
785786
fence_open.collision_box = {
786787
type = "fixed",
787-
fixed = {{-1/2, -1/2, -1/4, -3/8, 1/2, 1/4},
788-
{-1/2, -3/8, -1/2, -3/8, 3/8, 0}},
788+
fixed = {{-1/2, -1/2, -1/8, -3/8, 1/2 + fence_collision_extra, 1/8},
789+
{-1/2, -3/8, -1/2, -3/8, 3/8, 0 }}
789790
}
790791

791792
minetest.register_node(":" .. name .. "_closed", fence_closed)

‎mods/walls/init.lua

+17-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
walls = {}
44

5+
local fence_collision_extra = minetest.settings:get_bool("enable_fence_tall") and 3/8 or 0
6+
57
-- Load support for MT game translation.
68
local S = minetest.get_translator("walls")
79

8-
910
walls.register = function(wall_name, wall_desc, wall_texture_table, wall_mat, wall_sounds)
1011
--make wall_texture_table paramenter backwards compatible for mods passing single texture
1112
if type(wall_texture_table) ~= "table" then
@@ -17,12 +18,22 @@ walls.register = function(wall_name, wall_desc, wall_texture_table, wall_mat, wa
1718
drawtype = "nodebox",
1819
node_box = {
1920
type = "connected",
20-
fixed = {{-1/4, -1/2, -1/4, 1/4, 1/2, 1/4}},
21+
fixed = {-1/4, -1/2, -1/4, 1/4, 1/2, 1/4},
22+
-- connect_bottom =
23+
connect_front = {-3/16, -1/2, -1/2, 3/16, 3/8, -1/4},
24+
connect_left = {-1/2, -1/2, -3/16, -1/4, 3/8, 3/16},
25+
connect_back = {-3/16, -1/2, 1/4, 3/16, 3/8, 1/2},
26+
connect_right = { 1/4, -1/2, -3/16, 1/2, 3/8, 3/16},
27+
},
28+
collision_box = {
29+
type = "connected",
30+
fixed = {-1/4, -1/2, -1/4, 1/4, 1/2 + fence_collision_extra, 1/4},
31+
-- connect_top =
2132
-- connect_bottom =
22-
connect_front = {{-3/16, -1/2, -1/2, 3/16, 3/8, -1/4}},
23-
connect_left = {{-1/2, -1/2, -3/16, -1/4, 3/8, 3/16}},
24-
connect_back = {{-3/16, -1/2, 1/4, 3/16, 3/8, 1/2}},
25-
connect_right = {{ 1/4, -1/2, -3/16, 1/2, 3/8, 3/16}},
33+
connect_front = {-1/4,-1/2,-1/2,1/4,1/2 + fence_collision_extra,-1/4},
34+
connect_left = {-1/2,-1/2,-1/4,-1/4,1/2 + fence_collision_extra,1/4},
35+
connect_back = {-1/4,-1/2,1/4,1/4,1/2 + fence_collision_extra,1/2},
36+
connect_right = {1/4,-1/2,-1/4,1/2,1/2 + fence_collision_extra,1/4},
2637
},
2738
connects_to = { "group:wall", "group:stone", "group:fence" },
2839
paramtype = "light",

‎settingtypes.txt

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ enable_bed_respawn (Respawn at bed) bool true
3232
# in beds.
3333
enable_bed_night_skip (Skip night when sleeping) bool true
3434

35+
# If enabled, fences and walls cannot be jumped over.
36+
enable_fence_tall (Tall fences and walls) bool false
37+
3538
# When TNT explodes, it destroys nearby nodes and damages nearby players.
3639
# This setting is disabled by default on servers.
3740
enable_tnt (TNT) bool true

0 commit comments

Comments
 (0)
Please sign in to comment.