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
|
@ -5,5 +5,5 @@ org.gradle.daemon=false
|
|||
|
||||
mc_version=1.19.2
|
||||
forge_version=43.2.3
|
||||
myversion=1.0.4.2
|
||||
myversion=1.0.4.3
|
||||
parchment_version=2022.11.27
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,19 +3,19 @@ package dev.zontreck.libzontreck.vectors;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class Points {
|
||||
public Vector3 Point1 = Vector3.ZERO;
|
||||
public Vector3 Point2 = Vector3.ZERO;
|
||||
public Vector3 Min = Vector3.ZERO;
|
||||
public Vector3 Max = Vector3.ZERO;
|
||||
|
||||
|
||||
public Points(Vector3 min, Vector3 max)
|
||||
{
|
||||
if(min.less(max))
|
||||
{
|
||||
Point1=min;
|
||||
Point2=max;
|
||||
Min=min;
|
||||
Max=max;
|
||||
}else{
|
||||
Point1=max;
|
||||
Point2=min;
|
||||
Min=max;
|
||||
Max=min;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,14 +25,14 @@ public class Points {
|
|||
|
||||
public CompoundTag serialize(){
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("min", Point1.serialize());
|
||||
tag.put("max", Point2.serialize());
|
||||
tag.put("min", Min.serialize());
|
||||
tag.put("max", Max.serialize());
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void deserialize(CompoundTag tag)
|
||||
{
|
||||
Point1 = new Vector3(tag.getCompound("min"));
|
||||
Point2 = new Vector3(tag.getCompound("max"));
|
||||
Min = new Vector3(tag.getCompound("min"));
|
||||
Max = new Vector3(tag.getCompound("max"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ public class WorldPosition
|
|||
net.minecraft.world.level.ChunkPos mcChunk = getActualDimension().getChunkAt(Position.asBlockPos()).getPos();
|
||||
ChunkPos pos = new ChunkPos(new Vector3(mcChunk.getMinBlockX(),-70,mcChunk.getMinBlockZ()), new Vector3(mcChunk.getMaxBlockX(), 400, mcChunk.getMaxBlockZ()));
|
||||
pos.isSubArea=false;
|
||||
pos.centerPoints = new Vector2(mcChunk.getMiddleBlockX(), mcChunk.getMiddleBlockZ());
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ modId="libzontreck" #mandatory
|
|||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
||||
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||
version="1.0.4.2" #mandatory
|
||||
version="1.0.4.3" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="LibZontreck" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||
|
|
Reference in a new issue