better constants
This commit is contained in:
parent
2d1b81dc20
commit
0587223da8
@ -29,32 +29,32 @@ public class PrecomputedData { // TODO add isFullyPassable
|
||||
|
||||
private final int[] data = new int[Block.BLOCK_STATE_IDS.size()];
|
||||
|
||||
private final int completedMask = 1 << 0;
|
||||
private final int canWalkOnMask = 1 << 1;
|
||||
private final int canWalkOnSpecialMask = 1 << 2;
|
||||
private final int canWalkThroughMask = 1 << 3;
|
||||
private final int canWalkThroughSpecialMask = 1 << 4;
|
||||
private static final int COMPLETED_MASK = 1 << 0;
|
||||
private static final int CAN_WALK_ON_MASK = 1 << 1;
|
||||
private static final int CAN_WALK_ON_SPECIAL_MASK = 1 << 2;
|
||||
private static final int CAN_WALK_THROUGH_MASK = 1 << 3;
|
||||
private static final int CAN_WALK_THROUGH_SPECIAL_MASK = 1 << 4;
|
||||
|
||||
private int fillData(int id, IBlockState state) {
|
||||
int blockData = 0;
|
||||
|
||||
Ternary canWalkOnState = MovementHelper.canWalkOnBlockState(state);
|
||||
if (canWalkOnState == YES) {
|
||||
blockData |= canWalkOnMask;
|
||||
blockData |= CAN_WALK_ON_MASK;
|
||||
}
|
||||
if (canWalkOnState == MAYBE) {
|
||||
blockData |= canWalkOnSpecialMask;
|
||||
blockData |= CAN_WALK_ON_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
Ternary canWalkThroughState = MovementHelper.canWalkThroughBlockState(state);
|
||||
if (canWalkThroughState == YES) {
|
||||
blockData |= canWalkThroughMask;
|
||||
blockData |= CAN_WALK_THROUGH_MASK;
|
||||
}
|
||||
if (canWalkOnState == MAYBE) {
|
||||
blockData |= canWalkThroughSpecialMask;
|
||||
blockData |= CAN_WALK_THROUGH_SPECIAL_MASK;
|
||||
}
|
||||
|
||||
blockData |= completedMask;
|
||||
blockData |= COMPLETED_MASK;
|
||||
|
||||
data[id] = blockData; // in theory, this is thread "safe" because every thread should compute the exact same int to write?
|
||||
return blockData;
|
||||
@ -64,14 +64,14 @@ public class PrecomputedData { // TODO add isFullyPassable
|
||||
int id = Block.BLOCK_STATE_IDS.get(state);
|
||||
int blockData = data[id];
|
||||
|
||||
if ((blockData & completedMask) == 0) { // we need to fill in the data
|
||||
if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data
|
||||
blockData = fillData(id, state);
|
||||
}
|
||||
|
||||
if ((blockData & canWalkOnSpecialMask) != 0) {
|
||||
if ((blockData & CAN_WALK_ON_SPECIAL_MASK) != 0) {
|
||||
return MovementHelper.canWalkOnPosition(bsi, x, y, z, state);
|
||||
} else {
|
||||
return (blockData & canWalkOnMask) != 0;
|
||||
return (blockData & CAN_WALK_ON_MASK) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,14 +79,14 @@ public class PrecomputedData { // TODO add isFullyPassable
|
||||
int id = Block.BLOCK_STATE_IDS.get(state);
|
||||
int blockData = data[id];
|
||||
|
||||
if ((blockData & completedMask) == 0) { // we need to fill in the data
|
||||
if ((blockData & COMPLETED_MASK) == 0) { // we need to fill in the data
|
||||
blockData = fillData(id, state);
|
||||
}
|
||||
|
||||
if ((blockData & canWalkThroughSpecialMask) != 0) {
|
||||
if ((blockData & CAN_WALK_THROUGH_SPECIAL_MASK) != 0) {
|
||||
return MovementHelper.canWalkThroughPosition(bsi, x, y, z, state);
|
||||
} else {
|
||||
return (blockData & canWalkThroughMask) != 0;
|
||||
return (blockData & CAN_WALK_THROUGH_MASK) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user