mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
rendering, items: fix edit state not cleared and gui wrongly updated
This commit is contained in:
parent
f00b612f8b
commit
c1d61c1330
@ -87,6 +87,7 @@ abstract class Container(
|
|||||||
}
|
}
|
||||||
stack.holder?.container = null
|
stack.holder?.container = null
|
||||||
iterator.remove()
|
iterator.remove()
|
||||||
|
onRemove(slot, stack)
|
||||||
edit?.addChange()
|
edit?.addChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +195,7 @@ abstract class Container(
|
|||||||
|
|
||||||
val id = id ?: return
|
val id = id ?: return
|
||||||
|
|
||||||
if (id != PlayerInventory.CONTAINER_ID || this is ClientContainer) {
|
if (id != PlayerInventory.CONTAINER_ID && this !is ClientContainer) {
|
||||||
connection.player.containers -= id
|
connection.player.containers -= id
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,6 +228,7 @@ abstract class Container(
|
|||||||
fun commit() {
|
fun commit() {
|
||||||
val edit = this.edit ?: throw IllegalStateException("Not in bulk edit mode!")
|
val edit = this.edit ?: throw IllegalStateException("Not in bulk edit mode!")
|
||||||
validate()
|
validate()
|
||||||
|
this.edit = null
|
||||||
lock.unlock()
|
lock.unlock()
|
||||||
for (slot in edit.slots) {
|
for (slot in edit.slots) {
|
||||||
slot.revision++
|
slot.revision++
|
||||||
|
@ -31,6 +31,7 @@ class DropContainerAction(
|
|||||||
if (container.getSlotType(this.slot)?.canRemove(container, slot, item) != true) {
|
if (container.getSlotType(this.slot)?.canRemove(container, slot, item) != true) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
container.lock()
|
||||||
previousStack = item.copy()
|
previousStack = item.copy()
|
||||||
if (stack) {
|
if (stack) {
|
||||||
item.item.count = 0
|
item.item.count = 0
|
||||||
@ -42,6 +43,7 @@ class DropContainerAction(
|
|||||||
connection.sendPacket(ContainerClickC2SP(containerId, container.serverRevision, slot, 4, if (stack) 1 else 0, actionId, slotsOf(slot to item), null))
|
connection.sendPacket(ContainerClickC2SP(containerId, container.serverRevision, slot, 4, if (stack) 1 else 0, actionId, slotsOf(slot to item), null))
|
||||||
|
|
||||||
// TODO (1.18.2): use creative inventory packet
|
// TODO (1.18.2): use creative inventory packet
|
||||||
|
container.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun revert(connection: PlayConnection, containerId: Int, container: Container) {
|
override fun revert(connection: PlayConnection, containerId: Int, container: Container) {
|
||||||
|
@ -233,6 +233,7 @@ class ItemStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val edit = edit ?: throw IllegalStateException("Not in edit mode!")
|
val edit = edit ?: throw IllegalStateException("Not in edit mode!")
|
||||||
|
this.edit = null
|
||||||
lock.unlock()
|
lock.unlock()
|
||||||
if (edit.changes > 0) {
|
if (edit.changes > 0) {
|
||||||
revision++
|
revision++
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -15,7 +15,6 @@ package de.bixilon.minosoft.gui.rendering.gui.elements.items
|
|||||||
|
|
||||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||||
import de.bixilon.kutil.observer.map.MapObserver.Companion.observeMap
|
|
||||||
import de.bixilon.minosoft.data.container.Container
|
import de.bixilon.minosoft.data.container.Container
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasSlot
|
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasSlot
|
||||||
@ -70,7 +69,7 @@ class ContainerItemsElement(
|
|||||||
}
|
}
|
||||||
this._size = size
|
this._size = size
|
||||||
|
|
||||||
container::slots.observeMap(this) { update = true; }
|
container::revision.observe(this) { update = true; }
|
||||||
container::floatingItem.observe(this) {
|
container::floatingItem.observe(this) {
|
||||||
this.floatingItem?.close()
|
this.floatingItem?.close()
|
||||||
this.floatingItem = null
|
this.floatingItem = null
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -14,8 +14,6 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.input.interaction
|
package de.bixilon.minosoft.gui.rendering.input.interaction
|
||||||
|
|
||||||
import de.bixilon.kutil.rate.RateLimiter
|
import de.bixilon.kutil.rate.RateLimiter
|
||||||
import de.bixilon.kutil.time.TimeUtil
|
|
||||||
import de.bixilon.kutil.time.TimeUtil.millis
|
|
||||||
import de.bixilon.minosoft.config.key.KeyActions
|
import de.bixilon.minosoft.config.key.KeyActions
|
||||||
import de.bixilon.minosoft.config.key.KeyBinding
|
import de.bixilon.minosoft.config.key.KeyBinding
|
||||||
import de.bixilon.minosoft.config.key.KeyCodes
|
import de.bixilon.minosoft.config.key.KeyCodes
|
||||||
@ -43,7 +41,6 @@ class DropInteractionManager(
|
|||||||
|
|
||||||
|
|
||||||
fun dropItem(stack: Boolean) {
|
fun dropItem(stack: Boolean) {
|
||||||
val time = millis()
|
|
||||||
val type = if (stack) {
|
val type = if (stack) {
|
||||||
connection.player.inventory.getHotbarSlot()?.item?.count = 0
|
connection.player.inventory.getHotbarSlot()?.item?.count = 0
|
||||||
PlayerActionC2SP.Actions.DROP_ITEM_STACK
|
PlayerActionC2SP.Actions.DROP_ITEM_STACK
|
||||||
|
Loading…
x
Reference in New Issue
Block a user