Add missed files

This commit is contained in:
2022-05-12 00:20:18 +02:00
parent 16c24ce795
commit a49903cc69
40 changed files with 728 additions and 367 deletions

View File

@@ -1,21 +1,37 @@
package me.hypherionmc.hyperlighting.utils;
package me.hypherionmc.craterlib.util;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
public class MathUtils {
public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) {
VoxelShape[] buffer = new VoxelShape[]{ shape, VoxelShapes.empty() };
VoxelShape[] buffer = new VoxelShape[]{ shape, Shapes.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].forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = Shapes.or(buffer[1], Shapes.box(1-maxZ, minY, minX, 1-minZ, maxY, maxX)));
buffer[0] = buffer[1];
buffer[1] = VoxelShapes.empty();
buffer[1] = Shapes.empty();
}
return buffer[0];
}
public static void writeBlockPosToNBT(BlockPos pos, CompoundTag tag) {
tag.putInt("block_x", pos.getX());
tag.putInt("block_y", pos.getY());
tag.putInt("block_z", pos.getZ());
}
public static BlockPos readBlockPosFromNBT(CompoundTag tag) {
int x, y, z;
x = tag.getInt("block_x");
y = tag.getInt("block_y");
z = tag.getInt("block_z");
return new BlockPos(x, y, z);
}
}