Skip to content

Commit

Permalink
feat(utils): methods for operating vec3 nbt
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Aug 11, 2022
1 parent 559ac77 commit 6f74675
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/auioc/mcmod/arnicalib/utils/game/NbtUtils.java
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.nbt.DoubleTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;

public class NbtUtils {

Expand Down Expand Up @@ -46,4 +47,18 @@ public static AABB getAABB(CompoundTag nbt, String key) {
return readAABB(getDoubleListTag(nbt, key));
}


public static ListTag writeVec3(Vec3 vec) {
return writeDoubleArray(vec.x, vec.y, vec.z);
}

public static Vec3 readVec3(ListTag nbt) {
double[] p = readDoubleArray(nbt);
return new Vec3(p[0], p[1], p[2]);
}

public static Vec3 getVec3(CompoundTag nbt, String key) {
return readVec3(getDoubleListTag(nbt, key));
}

}

0 comments on commit 6f74675

Please sign in to comment.