Fix stacks of same type in different inventories not grouping
This commit is contained in:
parent
6fae09d410
commit
19c035495c
|
@ -1,5 +1,6 @@
|
|||
package net.shadowfacts.phycon.network.block.terminal
|
||||
|
||||
import alexiil.mc.lib.attributes.item.ItemStackCollections
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.shadowfacts.phycon.api.packet.Packet
|
||||
import net.shadowfacts.phycon.init.PhyBlockEntities
|
||||
|
@ -12,7 +13,7 @@ import net.shadowfacts.phycon.network.packet.RequestReadAllPacket
|
|||
*/
|
||||
class TerminalBlockEntity: DeviceBlockEntity(PhyBlockEntities.TERMINAL) {
|
||||
|
||||
private var cachedItems = mutableMapOf<ItemStack, Int>()
|
||||
private var cachedItems = ItemStackCollections.intMap()
|
||||
|
||||
override fun handlePacket(packet: Packet) {
|
||||
when (packet) {
|
||||
|
@ -22,7 +23,7 @@ class TerminalBlockEntity: DeviceBlockEntity(PhyBlockEntities.TERMINAL) {
|
|||
|
||||
fun handleReadAll(packet: ReadAllPacket) {
|
||||
packet.items.forEach { (stack, amount) ->
|
||||
cachedItems.merge(stack, amount) { a, b -> a + b }
|
||||
cachedItems.mergeInt(stack, amount) { a, b -> a + b }
|
||||
}
|
||||
println("new cached items: $cachedItems")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue