Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.
If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!
Now, what are you waiting for? Join the community now!
vb
set {_x} to chunk x of {_chunk}
set {_z} to chunk z of {_chunk}
set {_w} to {_chunk}.getWorld()
add {_w}.getChunkAt({_x} + 1, {_z}) to {_chunks::*}
add {_w}.getChunkAt({_x} - 1, {_z}) to {_chunks::*}
add {_w}.getChunkAt({_x}, {_z} + 1) to {_chunks::*}
add {_w}.getChunkAt({_x}, {_z} - 1) to {_chunks::*}
vb
if size of getAllChunks({_nbt}) > 0:
loop getAllChunks({_nbt}):
add chunksNextToChunk(loop-value) to {_x::*}
{_x::*} does not contain player's chunk:
send "{@error} The chunk must be next to an already claimed chunk!"
stop
else:
loop chunksNextToChunk(chunk of player):
set {_id} to string tag "nation;id" of nbt of loop-value
{_id} ? "" != ""
add loop-value to {_claimedNeighbors::*}
size of {_claimedNeighbors::*} = 2 or 3:
if getDiagonalChunks(chunk of player) does not contain {_claimedNeighbors::*}:
broadcast "{@error} Case 2"
stop
else:
size of {_claimedNeighbors::*} = 4:
add getDiagonalChunks(chunk of player) to {_totalNeighbors::*}
add chunksNextToChunk(chunk of player) to {_totalNeighbors::*}
loop {_totalNeighbors::*}:
set {_id} to string tag "nation;id" of nbt of loop-value
{_id} ? "" != ""
add loop-value to {_claimedTotal::*}
if size of {_claimedTotal::*} < 7:
broadcast "{@error} Case 4"
stop
vb
set {_1} to {_chunk}.getWorld().getChunkAt({_chunk}.getX() + 1, {_z})
set {_2} to {_chunk}.getWorld().getChunkAt({_chunk}.getX(), {_z} + 1)
applescript
function canClaim(new-chunk: chunk, claimed-chunks: chunks) :: boolean:
# avoid contains
loop {_claimed-chunks::*}:
set {_chunks::%loop-value%} to loop-value
set {_offset::1} to vector(0,0,16)
set {_offset::2} to vector(-16,0,0)
set {_offset::3} to vector(0,0,-16)
set {_offset::4} to vector(16,0,0)
# get number of neighbors
set {_loc} to location of block at 0, 0, 0 of {_new-chunk}
loop {_offset::*}:
set {_prospective} to {_loc} ~ loop-value
if {_chunks::%chunk at {_prospective}%} is set:
set {_neighbors::%loop-value%} to loop-value
# if we have no neighbors, we can't claim
if size of {_neighbors::*} is 0:
return false
# if we have 1 neighbor, we can claim
if size of {_neighbors::*} is 1:
return true
# if we have 4 neighbors, we can claim if 3/4 diagonals are claimed
if size of {_neighbors::*} is 4:
loop {_offset::*}:
add 1 to {_i}
set {_prospective} to {_loc} ~ loop-value
set {_prospective} to {_prospective} ~ {_offset::%mod({_i}, 4) + 1%}
if {_chunks::%chunk at {_prospective}%} is set:
add 1 to {_diagonals}
if {_diagonals} >= 3:
return true
return false
# if we have 2 neighbors, we can claim if they're adjacent and the diagonal is claimed
if size of {_neighbors::*} is 2:
set {_v1} to first element of {_neighbors::*}
set {_v2} to last element of {_neighbors::*}
set {_diag} to {_v1} ++ {_v2}
# not adjacent
if vector length of {_diag} < 1:
return false
# diagonal claimed?
set {_diag} to {_loc} ~ {_diag}
if {_chunks::%chunk at {_diag}%} is set:
return true
return false
# if we have 3 neighbors, we can claim if both diagonals are claimed
if size of {_neighbors::*} is 3:
set {_sum} to vector(0,0,0)
loop {_neighbors::*}:
set {_sum} to {_sum} ++ loop-value
delete {_neighbors::%{_sum}%}
loop {_neighbors::*}:
if {_chunks::%chunk at ({_loc} ~ {_sum} ~ loop-value)%} is not set:
return false
return true
return false