Skip to content

Commit a56162a

Browse files
authored
Merge branch 'master' into prospector-fix
2 parents 3976984 + f8948ad commit a56162a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

technic/machines/other/anchor.lua

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@ local S = technic.getter
22

33
local desc = S("Administrative World Anchor")
44

5-
local function floor_to_nearest(n)
6-
return math.floor(n / core.MAP_BLOCKSIZE)
5+
local function pos_to_mapblock(pos)
6+
return vector.floor(vector.divide(pos, core.MAP_BLOCKSIZE))
77
end
88

99
local function compute_forceload_positions(pos, meta)
1010
local radius = meta:get_int("radius")
11-
local minpos = vector.offset(pos, -radius, -radius, -radius)
12-
local maxpos = vector.offset(pos, radius, radius, radius)
13-
local minbpos = vector.apply(minpos, floor_to_nearest)
14-
local maxbpos = vector.apply(maxpos, floor_to_nearest)
11+
local minblock = pos_to_mapblock(vector.subtract(pos, radius))
12+
local maxblock = pos_to_mapblock(vector.add(pos, radius))
1513
local flposes = {}
16-
for x = minbpos.x, maxbpos.x, 16 do
17-
for y = minbpos.y, maxbpos.y, 16 do
18-
for z = minbpos.z, maxbpos.z, 16 do
19-
table.insert(flposes, vector.new(x, y, z))
14+
for x = minblock.x, maxblock.x do
15+
for y = minblock.y, maxblock.y do
16+
for z = minblock.z, maxblock.z do
17+
table.insert(flposes, vector.multiply(vector.new(x, y, z), core.MAP_BLOCKSIZE))
2018
end
2119
end
2220
end

0 commit comments

Comments
 (0)