Fix stacks of same type in different inventories not grouping

This commit is contained in:
Shadowfacts 2019-10-26 21:49:52 -04:00
parent 6fae09d410
commit 19c035495c
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 3 additions and 2 deletions

View File

@ -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")
}