Skip to content

Commit

Permalink
fix blockPos from Int Array Nbt
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Dec 10, 2024
1 parent dc5c533 commit 37a2510
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/main/java/fi/dy/masa/malilib/util/nbt/NbtBlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ public static Pair<List<BeehiveBlockEntity.BeeData>, BlockPos> getBeesDataFromNb
List<BeehiveBlockEntity.BeeData> bees = new ArrayList<>();
BlockPos flower = BlockPos.ORIGIN;

if (nbt.contains(NbtKeys.FLOWER))
if (nbt.contains(NbtKeys.BEES))
{
flower = NbtUtils.readBlockPosFromIntArray(nbt, NbtKeys.FLOWER);
BeehiveBlockEntity.BeeData.LIST_CODEC.parse(NbtOps.INSTANCE, nbt.get(NbtKeys.BEES)).resultOrPartial().ifPresent(bees::addAll);
}
if (nbt.contains(NbtKeys.BEES, Constants.NBT.TAG_LIST))
if (nbt.contains(NbtKeys.FLOWER, Constants.NBT.TAG_INT_ARRAY))
{
BeehiveBlockEntity.BeeData.LIST_CODEC.parse(NbtOps.INSTANCE, nbt.get(NbtKeys.BEES)).resultOrPartial().ifPresent(bees::addAll);
flower = NbtUtils.readBlockPosFromIntArray(nbt, NbtKeys.FLOWER);
}

return Pair.of(bees, flower);
Expand Down Expand Up @@ -309,4 +309,14 @@ public static Reference2IntOpenHashMap<RegistryKey<Recipe<?>>> getRecipesUsedFro

return list;
}

public static int getOutputSignalFromNbt(@Nonnull NbtCompound nbt)
{
if (nbt.contains(NbtKeys.OUTPUT_SIGNAL, Constants.NBT.TAG_INT))
{
return nbt.getInt(NbtKeys.OUTPUT_SIGNAL);
}

return 0;
}
}
1 change: 1 addition & 0 deletions src/main/java/fi/dy/masa/malilib/util/nbt/NbtKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class NbtKeys
public static final String SECONDARY_EFFECT = "secondary_effect";
public static final String FLOWER = "flower_pos";
public static final String BEES = "bees";
public static final String OUTPUT_SIGNAL = "OutputSignal";
public static final String VIBRATION = "last_vibration_frequency";
public static final String LISTENER = "listener";
public static final String EXIT = "exit_portal";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fi/dy/masa/malilib/util/nbt/NbtUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static BlockPos readBlockPosFromArrayTag(@Nonnull NbtCompound tag, String
{
if (NbtWrap.containsIntArray(tag, tagName))
{
int[] pos = NbtWrap.getIntArray(tag, NbtKeys.POS);
int[] pos = NbtWrap.getIntArray(tag, tagName);

if (pos.length == 3)
{
Expand Down

0 comments on commit 37a2510

Please sign in to comment.