Skip to content

Commit

Permalink
Update IslandManager.java (#867)
Browse files Browse the repository at this point in the history
- changed from ``getOrCreate`` to ``resolveOrCreate``
- simplified nbt check via ``resolveOrDefault``
  • Loading branch information
sh0inx authored Jun 14, 2024
1 parent 1c2a74c commit 1799f00
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ public ItemStack getIslandCrystal(int amount) {
));

NBT.modify(itemStack, readWriteItemNBT -> {
readWriteItemNBT.getOrCreateCompound("iridiumskyblock").setInteger("islandCrystals", amount);
readWriteItemNBT.resolveOrCreateCompound("iridiumskyblock").setInteger("islandCrystals", amount);
});

return itemStack;
Expand All @@ -726,10 +726,7 @@ public int getIslandCrystals(ItemStack itemStack) {
if (itemStack == null || itemStack.getType() == Material.AIR) return 0;

return NBT.get(itemStack, readableItemNBT -> {
if(readableItemNBT.getCompound("iridiumskyblock").hasTag("islandCrystals")) {
return readableItemNBT.getCompound("iridiumskyblock").getInteger("islandCrystals");
}
return 0;
return readableItemNBT.resolveOrDefault("iridiumskyblock.islandCrystals", 0);
});
}

Expand Down

0 comments on commit 1799f00

Please sign in to comment.