Bugfix
This commit is contained in:
@@ -16,17 +16,20 @@ public record ItemPriceRecord(int buyPrice, int sellPrice, ItemStack stack) {
|
||||
nbt.putInt("SellPrice", this.sellPrice);
|
||||
|
||||
// Serialize the ItemStack to NBT and add it to the compound
|
||||
NbtElement stackNbt = stack.encode(wrapperLookup);
|
||||
nbt.put("ItemStack", stackNbt); // Adds the ItemStack's NBT data to the main NBT compound
|
||||
if (stack != null && !stack.isEmpty()) {
|
||||
NbtElement stackNbt = stack.encode(wrapperLookup);
|
||||
nbt.put("ItemStack", stackNbt); // Adds the ItemStack's NBT data to the main NBT compound
|
||||
return nbt;
|
||||
}
|
||||
return null;
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public static ItemPriceRecord fromNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
int buyPrice = nbt.getInt("BuyPrice");
|
||||
int sellPrice = nbt.getInt("SellPrice");
|
||||
|
||||
if(sellPrice > buyPrice && buyPrice != 0) {
|
||||
if (sellPrice > buyPrice && buyPrice != 0) {
|
||||
buyPrice = sellPrice;
|
||||
}
|
||||
// Deserialize the ItemStack from the NBT
|
||||
|
@@ -116,7 +116,10 @@ public class PriceStorage {
|
||||
for (ItemStack stack : prices.keySet()) {
|
||||
ItemPriceRecord itemPriceRecord = prices.get(stack);
|
||||
if (!stack.isEmpty()) {
|
||||
nbtList.add(itemPriceRecord.toNbt(wrapperLookup));
|
||||
NbtCompound compound = itemPriceRecord.toNbt(wrapperLookup);
|
||||
if (compound != null) {
|
||||
nbtList.add(compound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user