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()
|
floatingItem.lock()
|
||||||
val target = container.slots[slot]
|
val target = container.slots[slot]
|
||||||
try {
|
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 (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))
|
return connection.sendPacket(ContainerClickC2SP(containerId, container.serverRevision, null, 0, count.ordinal, container.createAction(this), mapOf(), null))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ class SimpleContainerAction(
|
|||||||
}
|
}
|
||||||
// swap
|
// swap
|
||||||
container.floatingItem = target
|
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))
|
connection.sendPacket(ContainerClickC2SP(containerId, container.serverRevision, slot, 0, count.ordinal, container.createAction(this), mapOf(slot to target), target))
|
||||||
} finally {
|
} finally {
|
||||||
floatingItem.commit()
|
floatingItem.commit()
|
||||||
|
@ -113,7 +113,7 @@ open class Container(
|
|||||||
revision++
|
revision++
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun _set(slotId: Int, itemStack: ItemStack?): Boolean {
|
fun _set(slotId: Int, itemStack: ItemStack?): Boolean {
|
||||||
val previous = slots[slotId]
|
val previous = slots[slotId]
|
||||||
if (itemStack == null) {
|
if (itemStack == null) {
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
|
@ -67,8 +67,8 @@ class ItemElement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onMouseEnter(position: Vec2i, absolute: Vec2i): Boolean {
|
override fun onMouseEnter(position: Vec2i, absolute: Vec2i): Boolean {
|
||||||
renderWindow.window.cursorShape = CursorShapes.HAND
|
|
||||||
val stack = stack ?: return true
|
val stack = stack ?: return true
|
||||||
|
renderWindow.window.cursorShape = CursorShapes.HAND
|
||||||
popper = ItemInfoPopper(guiRenderer, absolute, stack).apply { show() }
|
popper = ItemInfoPopper(guiRenderer, absolute, stack).apply { show() }
|
||||||
hovered = true
|
hovered = true
|
||||||
cacheUpToDate = false
|
cacheUpToDate = false
|
||||||
@ -132,14 +132,10 @@ class ItemElement(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
val container = itemsElement.container
|
val container = itemsElement.container
|
||||||
val controlDown = guiRenderer.isKeyDown(ModifierKeys.CONTROL)
|
if (key != KeyCodes.KEY_Q) { // ToDo: Make it configurable
|
||||||
val shiftDown = guiRenderer.isKeyDown(ModifierKeys.SHIFT)
|
return true
|
||||||
// ToDo
|
|
||||||
when (key) {
|
|
||||||
KeyCodes.KEY_Q -> {
|
|
||||||
container.invokeAction(DropContainerAction(slotId, controlDown))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
container.invokeAction(DropContainerAction(slotId, guiRenderer.isKeyDown(ModifierKeys.CONTROL)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user