This commit is contained in:
Jesse Boyd
2019-06-29 04:20:48 +10:00
parent f1e98da01f
commit 58c6b6278f
12 changed files with 121 additions and 61 deletions

View File

@ -85,17 +85,27 @@ public class BlockTransformExtent extends ResettableExtent {
private static long combine(Direction... directions) {
return Arrays.stream(directions).mapToLong(dir -> (1L << dir.ordinal())).reduce(0, (a, b) -> a | b);
long mask = 0;
for (Direction dir : directions) {
mask = mask | (1L << dir.ordinal());
}
return mask;
}
private static long[] adapt(Direction... dirs) {
long[] arr = new long[dirs.length];
Arrays.setAll(arr, i -> 1L << dirs[i].ordinal());
for (int i = 0; i < arr.length; i++) {
arr[i] = 1L << dirs[i].ordinal();
}
return arr;
}
private static long[] adapt(Long... dirs) {
return Arrays.stream(dirs).mapToLong(dir -> dir).toArray();
long[] arr = new long[dirs.length];
for (int i = 0; i < arr.length; i++) {
arr[i] = dirs[i];
}
return arr;
}
private static long[] getDirections(AbstractProperty property) {
@ -209,7 +219,9 @@ public class BlockTransformExtent extends ResettableExtent {
}
private static long notIndex(long mask, int... indexes) {
mask |= Arrays.stream(indexes).mapToLong(index -> (1L << (index + values().length))).reduce(0, (a, b) -> a | b);
for (int index : indexes) {
mask = mask | (1L << (index + values().length));
}
return mask;
}
@ -421,8 +433,7 @@ public class BlockTransformExtent extends ResettableExtent {
* @return the same block
*/
public static <B extends BlockStateHolder<B>> B transform(B block, Transform transform) {
checkNotNull(block);
checkNotNull(transform);
// performance critical
BlockState state = block.toImmutableState();
int transformedId = transformState(state, transform);