mirror of
https://github.com/array-in-a-matrix/brainwine.git
synced 2025-04-02 11:11:58 -04:00
Fixed crash caused by out-of-bounds linked block positions
This commit is contained in:
parent
c8deef0e9e
commit
0aa063d285
1 changed files with 10 additions and 4 deletions
|
@ -395,11 +395,17 @@ public class Zone {
|
|||
for(List<Integer> position : positions) {
|
||||
int pX = position.get(0);
|
||||
int pY = position.get(1);
|
||||
int pIndex = pY * width + pX;
|
||||
int pOffset = 0;
|
||||
|
||||
// Make sure that the linked block is in bounds
|
||||
if(pIndex >= 0 && pIndex < blocks.length) {
|
||||
// Create an offset in case the block is bigger than 1x1
|
||||
Item linkedItem = blocks[pIndex].getFrontItem();
|
||||
linkedItem = replacedItems.getOrDefault(linkedItem, linkedItem);
|
||||
pOffset = -(linkedItem.getBlockWidth() - 1);
|
||||
}
|
||||
|
||||
// Create an offset in case the block is bigger than 1x1
|
||||
Item linkedItem = blocks[pY * width + pX].getFrontItem();
|
||||
linkedItem = replacedItems.getOrDefault(linkedItem, linkedItem);
|
||||
int pOffset = -(linkedItem.getBlockWidth() - 1);
|
||||
position.set(0, (mirrored ? width - 1 - pX + pOffset : pX) + x);
|
||||
position.set(1, position.get(1) + y);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue