Fix stacksize being shared by different item stacks

This commit is contained in:
nea
2023-05-29 23:33:46 +02:00
parent dd0afac3a8
commit edb723e423

View File

@@ -47,6 +47,10 @@ data class SBItemStack(
object SBItemEntryDefinition : EntryDefinition<SBItemStack> { object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
override fun equals(o1: SBItemStack, o2: SBItemStack, context: ComparisonContext): Boolean { override fun equals(o1: SBItemStack, o2: SBItemStack, context: ComparisonContext): Boolean {
if (!context.isFuzzy) {
if (o1.stackSize != o2.stackSize)
return false
}
return o1.skyblockId == o2.skyblockId return o1.skyblockId == o2.skyblockId
} }
@@ -73,7 +77,7 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
override fun hash(entry: EntryStack<SBItemStack>, value: SBItemStack, context: ComparisonContext): Long { override fun hash(entry: EntryStack<SBItemStack>, value: SBItemStack, context: ComparisonContext): Long {
// Repo items are immutable, and get replaced entirely when loaded from disk // Repo items are immutable, and get replaced entirely when loaded from disk
return value.skyblockId.hashCode() * 31L return value.skyblockId.hashCode() * 31L + if (!context.isExact) value.stackSize else 0
} }
override fun wildcard(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack { override fun wildcard(entry: EntryStack<SBItemStack>?, value: SBItemStack): SBItemStack {