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