Skip to content

Commit d6b0400

Browse files
committed
Merge branch 'bed-compat-ng' of github.com:mt-mods/jumpdrive into bed-compat-ng
2 parents 9ba1e1f + 59ceb74 commit d6b0400

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+719
-8578
lines changed

.github/workflows/integration-test.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/luacheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v1
11+
- uses: actions/checkout@master
1212
- name: apt
1313
run: sudo apt-get install -y luarocks
1414
- name: luacheck install

.github/workflows/test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: buckaroobanzay/mtt@main
12+
with:
13+
modname: jumpdrive
14+
git_dependencies: |
15+
https://github.com/minetest-mods/areas.git

.luacheckrc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
unused_args = false
2-
allow_defined_top = true
3-
4-
ignore = {"512"}
51

62
globals = {
73
"jumpdrive",
@@ -35,5 +31,9 @@ read_globals = {
3531
"ropes",
3632
"sethome",
3733
"drawers",
38-
"player_monoids"
34+
"player_monoids",
35+
"vizlib",
36+
"mcl_sounds",
37+
"mcl_formspec",
38+
"mtt"
3939
}

backbone.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ minetest.register_node("jumpdrive:backbone", {
44
description = "Jumpdrive Backbone",
55

66
tiles = {"jumpdrive_backbone.png"},
7-
groups = {cracky=3,oddly_breakable_by_hand=3},
8-
sounds = default.node_sound_glass_defaults(),
7+
groups = {cracky=3,oddly_breakable_by_hand=3,handy=1,pickaxey=1},
8+
_mcl_blast_resistance = 2,
9+
_mcl_hardness = 0.9,
10+
sounds = jumpdrive.sounds.node_sound_glass_defaults(),
11+
is_ground_content = false,
912
light_source = 13
1013
})

bookmark.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11

2+
local book_item, book_written = ""
3+
4+
if minetest.get_modpath("default") then
5+
book_item = "default:book"
6+
book_written = "default:book_written"
7+
end
8+
9+
if minetest.get_modpath("mcl_books") then
10+
book_item = "mcl_books:book"
11+
book_written = "mcl_books:written_book"
12+
end
213

314
jumpdrive.write_to_book = function(pos, sender)
415
local meta = minetest.get_meta(pos)
516
local inv = meta:get_inventory()
617

7-
if inv:contains_item("main", {name="default:book", count=1}) then
8-
local stack = inv:remove_item("main", {name="default:book", count=1})
18+
if inv:contains_item("main", {name=book_item, count=1}) then
19+
local stack = inv:remove_item("main", {name=book_item, count=1})
920

10-
local new_stack = ItemStack("default:book_written")
21+
local new_stack = ItemStack(book_written)
1122

1223
local data = {}
1324

@@ -63,7 +74,7 @@ jumpdrive.read_from_book = function(pos)
6374
for i = inv_size, 1, -1 do
6475
stack = inv:get_stack("main", i)
6576
stack_name = stack:get_name()
66-
if "default:book_written" == stack_name then
77+
if book_written == stack_name then
6778
-- remove item from inventory
6879
inv:set_stack("main", i, ItemStack())
6980
stack_meta = stack:get_meta()

common.lua

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,72 @@
11

2-
jumpdrive.sanitize_coord = function(coord)
2+
local c_air = minetest.get_content_id("air")
3+
4+
function jumpdrive.clear_area(pos1, pos2)
5+
local manip = minetest.get_voxel_manip()
6+
local e1, e2 = manip:read_from_map(pos1, pos2)
7+
local source_area = VoxelArea:new({MinEdge=e1, MaxEdge=e2})
8+
local source_data = manip:get_data()
9+
10+
11+
for z=pos1.z, pos2.z do
12+
for y=pos1.y, pos2.y do
13+
for x=pos1.x, pos2.x do
14+
15+
local source_index = source_area:index(x, y, z)
16+
source_data[source_index] = c_air
17+
end
18+
end
19+
end
20+
21+
manip:set_data(source_data)
22+
manip:write_to_map()
23+
24+
-- remove metadata
25+
local target_meta_pos_list = minetest.find_nodes_with_meta(pos1, pos2)
26+
for _,target_pos in pairs(target_meta_pos_list) do
27+
local target_meta = minetest.get_meta(target_pos)
28+
target_meta:from_table(nil)
29+
end
30+
end
31+
32+
function jumpdrive.sanitize_coord(coord)
333
return math.max( math.min( coord, 31000 ), -31000 )
434
end
535

636
-- get pos object from pos
7-
jumpdrive.get_meta_pos = function(pos)
37+
function jumpdrive.get_meta_pos(pos)
838
local meta = minetest.get_meta(pos);
939
return {x=meta:get_int("x"), y=meta:get_int("y"), z=meta:get_int("z")}
1040
end
1141

1242
-- set pos object from pos
13-
jumpdrive.set_meta_pos = function(pos, target)
43+
function jumpdrive.set_meta_pos(pos, target)
1444
local meta = minetest.get_meta(pos);
1545
meta:set_int("x", target.x)
1646
meta:set_int("y", target.y)
1747
meta:set_int("z", target.z)
1848
end
1949

2050
-- get offset from meta
21-
jumpdrive.get_radius = function(pos)
51+
function jumpdrive.get_radius(pos)
2252
local meta = minetest.get_meta(pos);
2353
return math.max(math.min(meta:get_int("radius"), jumpdrive.config.max_radius), 1)
2454
end
2555

2656
-- calculates the power requirements for a jump
27-
jumpdrive.calculate_power = function(radius, distance, sourcePos, targetPos)
57+
-- params: radius, distance, sourcePos, targetPos
58+
function jumpdrive.calculate_power(radius, distance)
2859
return 10 * distance * radius
2960
end
3061

3162

3263
-- preflight check, for overriding
33-
jumpdrive.preflight_check = function(source, destination, radius, playername)
64+
-- params: source, destination, radius, playername
65+
function jumpdrive.preflight_check()
3466
return { success=true }
3567
end
3668

37-
jumpdrive.reset_coordinates = function(pos)
69+
function jumpdrive.reset_coordinates(pos)
3870
local meta = minetest.get_meta(pos)
3971

4072
meta:set_int("x", pos.x)

compat/compat.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ end
2121

2222
if has_technic_mod then
2323
dofile(MP.."/compat/anchor.lua")
24+
dofile(MP.."/compat/technic_networks.lua")
2425
end
2526

2627
if has_locator_mod then
@@ -75,7 +76,5 @@ jumpdrive.node_compat = function(name, source_pos, target_pos, source_pos1, sour
7576
end
7677

7778
jumpdrive.commit_node_compat = function()
78-
if has_pipeworks_mod then
79-
jumpdrive.teleporttube_compat_commit()
80-
end
79+
-- Nothing to do here
8180
end

compat/elevator.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
local nodedef = minetest.registered_nodes["elevator:motor"]
33

44
minetest.override_item("elevator:motor", {
5-
on_movenode = function(from_pos, to_pos)
5+
on_movenode = function(_, to_pos)
66
minetest.log("action", "[jumpdrive] Restoring elevator @ " .. to_pos.x .. "/" .. to_pos.y .. "/" .. to_pos.z)
77
nodedef.after_place_node(to_pos, nil, nil)
88
end

compat/technic_networks.lua

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
--
2+
-- Compatibility hacks for technic plus new network system
3+
--
4+
-- More information:
5+
-- https://github.com/mt-mods/technic/issues/100
6+
--
7+
-- See also proposal draft to actually move networks instead of rebuilding:
8+
-- https://github.com/mt-mods/jumpdrive/pull/79
9+
--
10+
11+
-- Check for technic mod version compatibility
12+
if technic.remove_network and technic.pos2network and technic.machines then
13+
14+
local function on_movenode(from_pos, to_pos, info)
15+
-- Destroy network caches at source location, inside jump area
16+
local src_net_id = technic.pos2network(from_pos)
17+
if src_net_id then
18+
technic.remove_network(src_net_id)
19+
end
20+
21+
-- Destroy network caches at target location, outside jump area
22+
local edge = info.edge
23+
for axis, value in pairs(edge) do
24+
if value ~= 0 then
25+
local axis_dir = {x=0,y=0,z=0}
26+
axis_dir[axis] = value
27+
local edge_pos = vector.add(to_pos, axis_dir)
28+
local dst_net_id = technic.pos2network(edge_pos)
29+
if dst_net_id then
30+
technic.remove_network(dst_net_id)
31+
end
32+
end
33+
end
34+
end
35+
36+
-- Collect groups for registered technic cables
37+
local cable_groups = {}
38+
for tier,_ in pairs(technic.machines) do
39+
cable_groups[("technic_%s_cable"):format(tier:lower())] = 1
40+
end
41+
42+
local function is_network_node(_, def)
43+
if not def.groups then return end
44+
for group,_ in pairs(cable_groups) do
45+
if def.groups[group] then return true end
46+
end
47+
return def.groups["technic_machine"]
48+
end
49+
50+
-- Inject on_movenode functionality but only if node does not already implement it
51+
for name, def in pairs(minetest.registered_nodes) do
52+
if not def.on_movenode and is_network_node(name, def) then
53+
minetest.override_item(name, { on_movenode = on_movenode })
54+
end
55+
end
56+
57+
end

0 commit comments

Comments
 (0)