42 lines
1 KiB
Java
42 lines
1 KiB
Java
package dev.zontreck.libzontreck.vectors;
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
|
|
public class ChunkPos {
|
|
public Points points;
|
|
public Vector2f centerPoints;
|
|
public String dim;
|
|
|
|
public ChunkPos(Vector3d point1, Vector3d point2, ServerLevel lvl)
|
|
{
|
|
points = new Points(point1, point2, lvl);
|
|
dim = WorldPosition.getDim(lvl);
|
|
}
|
|
|
|
public ChunkPos(CompoundTag tag)
|
|
{
|
|
points = new Points(tag.getCompound("points"));
|
|
centerPoints = Vector2f.deserialize(tag.getCompound("center"));
|
|
}
|
|
|
|
public boolean isWithin(Vector3d point)
|
|
{
|
|
return point.Inside(points.Min, points.Max);
|
|
}
|
|
|
|
public static ChunkPos getChunkPos(WorldPosition pos)
|
|
{
|
|
return pos.getChunkPos();
|
|
}
|
|
|
|
public CompoundTag serialize()
|
|
{
|
|
CompoundTag tag = new CompoundTag();
|
|
tag.put("points", points.serialize());
|
|
tag.put("center", centerPoints.serialize());
|
|
tag.putString("dim", dim);
|
|
|
|
return tag;
|
|
}
|
|
}
|