Add a middle chunk position to the chunk pos interface
This commit is contained in:
parent
cf2f0a165b
commit
4eee51709c
5 changed files with 36 additions and 16 deletions
|
@ -1,23 +1,42 @@
|
|||
package dev.zontreck.libzontreck.vectors;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class ChunkPos {
|
||||
public boolean isSubArea;
|
||||
public Points subclaim;
|
||||
|
||||
public Points points;
|
||||
public Vector2 centerPoints;
|
||||
|
||||
public ChunkPos(Vector3 point1, Vector3 point2)
|
||||
{
|
||||
isSubArea=true;
|
||||
subclaim = new Points(point1, point2);
|
||||
points = new Points(point1, point2);
|
||||
}
|
||||
|
||||
public ChunkPos(CompoundTag tag)
|
||||
{
|
||||
isSubArea = tag.getBoolean("subarea");
|
||||
points = new Points(tag.getCompound("points"));
|
||||
centerPoints = new Vector2(tag.getCompound("center"));
|
||||
}
|
||||
|
||||
public boolean isWithin(Vector3 point)
|
||||
{
|
||||
return point.inside(subclaim.Point1, subclaim.Point2);
|
||||
return point.inside(points.Min, points.Max);
|
||||
}
|
||||
|
||||
public static ChunkPos getChunkPos(WorldPosition pos)
|
||||
{
|
||||
return pos.getChunkPos();
|
||||
}
|
||||
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.putBoolean("subarea", isSubArea);
|
||||
tag.put("points", points.serialize());
|
||||
tag.put("center", centerPoints.serialize());
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue