mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 16:36:58 -04:00
inventory: fix wrong setting new item on click
This commit is contained in:
parent
e2a91512be
commit
c6e9d69044
@ -45,12 +45,12 @@ class SimpleContainerAction(
|
||||
floatingItem.lock()
|
||||
val target = container.slots[slot]
|
||||
try {
|
||||
if (count == ContainerCounts.ALL) {
|
||||
floatingItem.item._count = 0
|
||||
} else {
|
||||
floatingItem.item._count-- // don't use decrease, item + container is already locked
|
||||
}
|
||||
if (slot == null) {
|
||||
if (count == ContainerCounts.ALL) {
|
||||
floatingItem.item._count = 0
|
||||
} else {
|
||||
floatingItem.item._count-- // don't use decrease, item + container is already locked
|
||||
}
|
||||
return connection.sendPacket(ContainerClickC2SP(containerId, container.serverRevision, null, 0, count.ordinal, container.createAction(this), mapOf(), null))
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class SimpleContainerAction(
|
||||
}
|
||||
// swap
|
||||
container.floatingItem = target
|
||||
container.slots[slot] = floatingItem
|
||||
container._set(slot, floatingItem)
|
||||
connection.sendPacket(ContainerClickC2SP(containerId, container.serverRevision, slot, 0, count.ordinal, container.createAction(this), mapOf(slot to target), target))
|
||||
} finally {
|
||||
floatingItem.commit()
|
||||
|
@ -113,7 +113,7 @@ open class Container(
|
||||
revision++
|
||||
}
|
||||
|
||||
private fun _set(slotId: Int, itemStack: ItemStack?): Boolean {
|
||||
fun _set(slotId: Int, itemStack: ItemStack?): Boolean {
|
||||
val previous = slots[slotId]
|
||||
if (itemStack == null) {
|
||||
if (previous == null) {
|
||||
|
@ -67,8 +67,8 @@ class ItemElement(
|
||||
}
|
||||
|
||||
override fun onMouseEnter(position: Vec2i, absolute: Vec2i): Boolean {
|
||||
renderWindow.window.cursorShape = CursorShapes.HAND
|
||||
val stack = stack ?: return true
|
||||
renderWindow.window.cursorShape = CursorShapes.HAND
|
||||
popper = ItemInfoPopper(guiRenderer, absolute, stack).apply { show() }
|
||||
hovered = true
|
||||
cacheUpToDate = false
|
||||
@ -132,14 +132,10 @@ class ItemElement(
|
||||
return true
|
||||
}
|
||||
val container = itemsElement.container
|
||||
val controlDown = guiRenderer.isKeyDown(ModifierKeys.CONTROL)
|
||||
val shiftDown = guiRenderer.isKeyDown(ModifierKeys.SHIFT)
|
||||
// ToDo
|
||||
when (key) {
|
||||
KeyCodes.KEY_Q -> {
|
||||
container.invokeAction(DropContainerAction(slotId, controlDown))
|
||||
}
|
||||
if (key != KeyCodes.KEY_Q) { // ToDo: Make it configurable
|
||||
return true
|
||||
}
|
||||
container.invokeAction(DropContainerAction(slotId, guiRenderer.isKeyDown(ModifierKeys.CONTROL)))
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user