Cache ItemStack display name
This commit is contained in:
parent
3951f7cbd4
commit
54f64b5342
@ -16,6 +16,7 @@ function ItemStack:fromDetail(inv, detail, slot)
|
||||
obj.count = detail.count
|
||||
obj.maxCount = detail.maxCount
|
||||
obj.enchantments = detail.enchantments
|
||||
obj.displayName = detail.displayName
|
||||
end
|
||||
|
||||
setmetatable(obj, self)
|
||||
@ -33,7 +34,8 @@ function ItemStack:clone(withSlot)
|
||||
maxDamage = self.maxDamage,
|
||||
count = self.count,
|
||||
maxCount = self.maxCount,
|
||||
enchantments = self.enchantments
|
||||
enchantments = self.enchantments,
|
||||
displayName = self.displayName
|
||||
}
|
||||
|
||||
setmetatable(obj, self)
|
||||
@ -55,6 +57,7 @@ function ItemStack:toSerializable()
|
||||
ser.maxDamage = self.maxDamage
|
||||
ser.count = self.count
|
||||
ser.enchantments = self.enchantments
|
||||
ser.displayName = self.displayName
|
||||
end
|
||||
|
||||
return ser
|
||||
@ -129,6 +132,7 @@ function ItemStack:_modify(countDelta, stack)
|
||||
self.count = nil
|
||||
self.maxCount = nil
|
||||
self.enchantments = nil
|
||||
self.displayName = nil
|
||||
else
|
||||
-- If stack is empty, copy stack data from source
|
||||
if self:isEmpty() then
|
||||
@ -138,6 +142,7 @@ function ItemStack:_modify(countDelta, stack)
|
||||
self.maxDamage = stack.maxDamage
|
||||
self.maxCount = stack.maxCount
|
||||
self.enchantments = stack.enchantments
|
||||
self.displayName = stack.displayName
|
||||
end
|
||||
|
||||
self.count = newCount
|
||||
@ -206,6 +211,7 @@ function ItemStack:canTransfer(stack)
|
||||
return self.name == stack.name and
|
||||
self.damage == stack.damage and
|
||||
self.maxDamage == stack.maxDamage and
|
||||
self.displayName == stack.displayName and
|
||||
objEquals(self.enchantments, stack.enchantments)
|
||||
end
|
||||
|
||||
@ -234,7 +240,8 @@ function ItemStack:matches(query)
|
||||
queryField(query.count, self.count) and
|
||||
queryField(query.maxDamage, self.maxDamage) and
|
||||
queryField(query.enchantments, self.enchantments) and
|
||||
queryField(query.maxCount, self.maxCount)
|
||||
queryField(query.maxCount, self.maxCount) and
|
||||
queryField(query.displayName, self.displayName)
|
||||
end
|
||||
|
||||
return ItemStack
|
Loading…
x
Reference in New Issue
Block a user