Skip to content

Commit

Permalink
Fix encoding of item values
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jul 12, 2024
1 parent 2caa54f commit e42e3b8
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Tag serialize(ValueDeseralizationContext valueDeseralizationContext, Valu
CompoundTag tag = new CompoundTag();
ItemStack itemStack = value.getRawValue();
if(!itemStack.isEmpty()) {
tag.putInt("Count", itemStack.getCount());
tag.putInt("count", itemStack.getCount());
return itemStack.save(valueDeseralizationContext.holderLookupProvider(), tag);
}
return tag;
Expand All @@ -78,10 +78,10 @@ public ValueItemStack deserialize(ValueDeseralizationContext valueDeseralization
CompoundTag tag = (CompoundTag) value;
// Forge returns air for tags with negative count,
// so we set it to 1 for deserialization and fix it afterwards.
int realCount = tag.getInt("Count");
int realCount = tag.getInt("count");
// Consider the tag immutable, to avoid changes elsewhere
tag = tag.copy();
tag.putByte("Count", (byte)1);
tag.putInt("count", 1);
ItemStack itemStack = ItemStack.parseOptional(valueDeseralizationContext.holderLookupProvider(), tag);
if (!itemStack.isEmpty()) {
itemStack.setCount(realCount);
Expand Down

0 comments on commit e42e3b8

Please sign in to comment.