Skip to content

Commit

Permalink
Update NbtUtils with BlockPos and EntityPos calls
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Dec 11, 2024
1 parent 11465d7 commit 822ac2c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/fi/dy/masa/malilib/util/nbt/NbtUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public static <T> NbtList asListTag(Collection<T> values, Function<T, NbtElement
return list;
}

public static @NotNull NbtCompound createBlockPos(@Nonnull BlockPos pos)
{
return writeBlockPos(pos, new NbtCompound());
}

public static @NotNull NbtCompound createBlockPosTag(@Nonnull BlockPos pos)
{
return writeBlockPos(pos, new NbtCompound());
Expand All @@ -95,6 +100,11 @@ public static <T> NbtList asListTag(Collection<T> values, Function<T, NbtElement
return putVec3i(new NbtCompound(), pos);
}

public static @NotNull NbtCompound createEntityPosition(@Nonnull Vec3d pos)
{
return createEntityPositionToTag(pos);
}

public static @NotNull NbtCompound createEntityPositionToTag(@Nonnull Vec3d pos)
{
return writeVec3dToListTag(pos, new NbtCompound(), NbtKeys.POS);
Expand All @@ -108,6 +118,11 @@ public static <T> NbtList asListTag(Collection<T> values, Function<T, NbtElement
return tag;
}

public static @NotNull NbtCompound writeBlockPosToTag(@Nonnull BlockPos pos, @Nonnull NbtCompound tag)
{
return writeBlockPos(pos, tag);
}

public static @NotNull NbtCompound writeBlockPos(@Nonnull BlockPos pos, @Nonnull NbtCompound tag)
{
NbtWrap.putInt(tag, "x", pos.getX());
Expand Down Expand Up @@ -190,6 +205,11 @@ public static BlockPos readBlockPosFromArrayTag(@Nonnull NbtCompound tag, String
return null;
}

public static @NotNull NbtCompound removeBlockPos(@Nonnull NbtCompound tag)
{
return removeBlockPosFromTag(tag);
}

public static @NotNull NbtCompound removeBlockPosFromTag(@Nonnull NbtCompound tag)
{
NbtWrap.remove(tag, "x");
Expand All @@ -199,6 +219,11 @@ public static BlockPos readBlockPosFromArrayTag(@Nonnull NbtCompound tag, String
return tag;
}

public static @NotNull NbtCompound writeEntityPosition(@Nonnull Vec3d pos, @Nonnull NbtCompound tag)
{
return writeVec3dToListTag(pos, tag, NbtKeys.POS);
}

public static @NotNull NbtCompound writeEntityPositionToTag(@Nonnull Vec3d pos, @Nonnull NbtCompound tag)
{
return writeVec3dToListTag(pos, tag, NbtKeys.POS);
Expand Down

0 comments on commit 822ac2c

Please sign in to comment.