22 lines
777 B
Java
22 lines
777 B
Java
|
package me.hypherionmc.hyperlighting.utils;
|
||
|
|
||
|
import net.minecraft.util.math.Direction;
|
||
|
import net.minecraft.util.shape.VoxelShape;
|
||
|
import net.minecraft.util.shape.VoxelShapes;
|
||
|
|
||
|
public class MathUtils {
|
||
|
|
||
|
public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) {
|
||
|
VoxelShape[] buffer = new VoxelShape[]{ shape, VoxelShapes.empty() };
|
||
|
|
||
|
int times = (to.ordinal() - from.ordinal() + 4) % 4;
|
||
|
for (int i = 0; i < times; i++) {
|
||
|
buffer[0].forEachBox((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = VoxelShapes.union(buffer[1], VoxelShapes.cuboid(1-maxZ, minY, minX, 1-minZ, maxY, maxX)));
|
||
|
buffer[0] = buffer[1];
|
||
|
buffer[1] = VoxelShapes.empty();
|
||
|
}
|
||
|
return buffer[0];
|
||
|
}
|
||
|
|
||
|
}
|