diff --git a/gradle.properties b/gradle.properties index d5afba1..1517fe9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,5 +5,5 @@ org.gradle.daemon=false mc_version=1.19.2 forge_version=43.2.3 -myversion=1.0.3.7 +myversion=1.0.4.0 parchment_version=2022.11.27 \ No newline at end of file diff --git a/src/main/java/dev/zontreck/libzontreck/vectors/ChunkPos.java b/src/main/java/dev/zontreck/libzontreck/vectors/ChunkPos.java new file mode 100644 index 0000000..7c1edd1 --- /dev/null +++ b/src/main/java/dev/zontreck/libzontreck/vectors/ChunkPos.java @@ -0,0 +1,24 @@ +package dev.zontreck.libzontreck.vectors; + +public class ChunkPos { + public boolean isSubArea; + public Points subclaim; + + public ChunkPos(Vector2 chunkPos) + { + isSubArea=false; + Vector3 min = new Vector3(chunkPos.x, -70, chunkPos.y); + subclaim = new Points(min, min.add(new Vector3(15, 300, 15))); + } + + public ChunkPos(Vector3 point1, Vector3 point2) + { + isSubArea=true; + subclaim = new Points(point1, point2); + } + + public boolean isWithin(Vector3 point) + { + return point.inside(subclaim.Point1, subclaim.Point2); + } +} diff --git a/src/main/java/dev/zontreck/libzontreck/vectors/NonAbsVector3.java b/src/main/java/dev/zontreck/libzontreck/vectors/NonAbsVector3.java index 6ca3c1a..d484e1b 100644 --- a/src/main/java/dev/zontreck/libzontreck/vectors/NonAbsVector3.java +++ b/src/main/java/dev/zontreck/libzontreck/vectors/NonAbsVector3.java @@ -45,4 +45,19 @@ public class NonAbsVector3 if(x == other.x && y==other.y && z==other.z)return true; else return false; } + + public boolean inside(NonAbsVector3 point1, NonAbsVector3 point2) + { + if(point1.x <= x && point2.x >= x){ + if(point1.y <= y && point2.y >= y) + { + if(point1.z <= z && point2.z >= z) + { + return true; + } + } + } + + return false; + } } diff --git a/src/main/java/dev/zontreck/libzontreck/vectors/Points.java b/src/main/java/dev/zontreck/libzontreck/vectors/Points.java new file mode 100644 index 0000000..e43fd94 --- /dev/null +++ b/src/main/java/dev/zontreck/libzontreck/vectors/Points.java @@ -0,0 +1,38 @@ +package dev.zontreck.libzontreck.vectors; + +import net.minecraft.nbt.CompoundTag; + +public class Points { + public Vector3 Point1 = Vector3.ZERO; + public Vector3 Point2 = Vector3.ZERO; + + + public Points(Vector3 min, Vector3 max) + { + if(min.less(max)) + { + Point1=min; + Point2=max; + }else{ + Point1=max; + Point2=min; + } + } + + public Points(CompoundTag tag){ + deserialize(tag); + } + + public CompoundTag serialize(){ + CompoundTag tag = new CompoundTag(); + tag.put("min", Point1.serialize()); + tag.put("max", Point2.serialize()); + return tag; + } + + public void deserialize(CompoundTag tag) + { + Point1 = new Vector3(tag.getCompound("min")); + Point2 = new Vector3(tag.getCompound("max")); + } +} diff --git a/src/main/java/dev/zontreck/libzontreck/vectors/Vector2.java b/src/main/java/dev/zontreck/libzontreck/vectors/Vector2.java index e75473c..100ae27 100644 --- a/src/main/java/dev/zontreck/libzontreck/vectors/Vector2.java +++ b/src/main/java/dev/zontreck/libzontreck/vectors/Vector2.java @@ -6,6 +6,8 @@ import net.minecraft.world.phys.Vec2; public class Vector2 { + public static final Vector2 ZERO = new Vector2(0, 0); + public float x; public float y; @@ -90,4 +92,29 @@ public class Vector2 if(x == other.x && y==other.y)return true; else return false; } + + public boolean inside(Vector2 point1, Vector2 point2) + { + if(point1.x <= x && point2.x >= x){ + if(point1.y <= y && point2.y >= y) + { + return true; + } + } + + return false; + } + + public boolean greater(Vector2 other) + { + return ((x>other.x) && (y>other.y)); + } + public boolean less(Vector2 other) + { + return ((x>other.x) && (y>other.y)); + } + public boolean equal(Vector2 other) + { + return same(other); + } } diff --git a/src/main/java/dev/zontreck/libzontreck/vectors/Vector3.java b/src/main/java/dev/zontreck/libzontreck/vectors/Vector3.java index 19f21df..68b2481 100644 --- a/src/main/java/dev/zontreck/libzontreck/vectors/Vector3.java +++ b/src/main/java/dev/zontreck/libzontreck/vectors/Vector3.java @@ -10,6 +10,9 @@ import net.minecraft.world.phys.Vec3; public class Vector3 { + public static final Vector3 ZERO = new Vector3(0, 0, 0); + + public double x; public double y; public double z; @@ -244,4 +247,33 @@ public class Vector3 if(x == other.x && y==other.y && z==other.z)return true; else return false; } + + + public boolean inside(Vector3 point1, Vector3 point2) + { + if(point1.x <= x && point2.x >= x){ + if(point1.y <= y && point2.y >= y) + { + if(point1.z <= z && point2.z >= z) + { + return true; + } + } + } + + return false; + } + + public boolean greater(Vector3 other) + { + return ((x>other.x) && (y>other.y) && (z>other.z)); + } + public boolean less(Vector3 other) + { + return ((x