This repository has been archived on 2024-10-31. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
LibZontreck/src/main/java/dev/zontreck/libzontreck/vectors/ChunkPos.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;
}
}