mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
fast container action: fix item duplication
This commit is contained in:
parent
660e41db88
commit
3e86c1f48a
@ -97,13 +97,16 @@ class FastMoveContainerActionTest {
|
|||||||
|
|
||||||
container.invokeAction(FastMoveContainerAction(0))
|
container.invokeAction(FastMoveContainerAction(0))
|
||||||
assertNull(container.floatingItem)
|
assertNull(container.floatingItem)
|
||||||
assertNull(container[0])
|
assertEquals(
|
||||||
assertEquals(container[54], ItemStack(CoalTest0.item, 64))
|
container.slots, slotsOf(
|
||||||
assertEquals(container[55], ItemStack(AppleTestO.item, 61))
|
54 to ItemStack(CoalTest0.item, 64),
|
||||||
assertEquals(container[56], ItemStack(CoalTest0.item, 64))
|
55 to ItemStack(AppleTestO.item, 61),
|
||||||
assertEquals(container[57], ItemStack(CoalTest0.item, 64))
|
56 to ItemStack(CoalTest0.item, 64),
|
||||||
assertEquals(container[58], ItemStack(CoalTest0.item, 64))
|
57 to ItemStack(CoalTest0.item, 64),
|
||||||
assertEquals(container[62], ItemStack(CoalTest0.item, 4))
|
58 to ItemStack(CoalTest0.item, 64),
|
||||||
|
62 to ItemStack(CoalTest0.item, 4),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
connection.assertOnlyPacket(ContainerClickC2SP(9, container.serverRevision, 0, 1, 0, 0, slotsOf(0 to null, 58 to ItemStack(AppleTestO.item, count = 64), 56 to ItemStack(AppleTestO.item, count = 64), 54 to ItemStack(AppleTestO.item, count = 64), 57 to ItemStack(AppleTestO.item, count = 64), 62 to ItemStack(AppleTestO.item, count = 4)), null)) // TODO: respect order of changes
|
connection.assertOnlyPacket(ContainerClickC2SP(9, container.serverRevision, 0, 1, 0, 0, slotsOf(0 to null, 58 to ItemStack(AppleTestO.item, count = 64), 56 to ItemStack(AppleTestO.item, count = 64), 54 to ItemStack(AppleTestO.item, count = 64), 57 to ItemStack(AppleTestO.item, count = 64), 62 to ItemStack(AppleTestO.item, count = 4)), null)) // TODO: respect order of changes
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ class FastMoveContainerAction(
|
|||||||
list += slot
|
list += slot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val maxStack = source.item.item.maxStackSize
|
||||||
val changes: Int2ObjectOpenHashMap<ItemStack> = Int2ObjectOpenHashMap()
|
val changes: Int2ObjectOpenHashMap<ItemStack> = Int2ObjectOpenHashMap()
|
||||||
sections@ for (list in targets) {
|
sections@ for (list in targets) {
|
||||||
for (slot in list.intIterator()) {
|
for (slot in list.intIterator()) {
|
||||||
@ -69,7 +70,7 @@ class FastMoveContainerAction(
|
|||||||
container._set(this.slot, null)
|
container._set(this.slot, null)
|
||||||
break@sections
|
break@sections
|
||||||
}
|
}
|
||||||
val countToPut = source.item._count - (source.item.item.maxStackSize - content.item._count)
|
val countToPut = if (source.item._count + content.item._count > maxStack) maxStack - content.item._count else source.item._count
|
||||||
source.item._count -= countToPut
|
source.item._count -= countToPut
|
||||||
content.item._count += countToPut
|
content.item._count += countToPut
|
||||||
changes[slot] = content
|
changes[slot] = content
|
||||||
|
Loading…
x
Reference in New Issue
Block a user