mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
Fix item using when not able to use; hud: fix vehicle health not disappearing
This commit is contained in:
parent
397cfd916c
commit
ca85ca017f
@ -25,9 +25,6 @@ import de.bixilon.minosoft.util.KUtil.decide
|
||||
import de.bixilon.minosoft.util.KUtil.toBoolean
|
||||
import de.bixilon.minosoft.util.KUtil.toFloat
|
||||
import de.bixilon.minosoft.util.KUtil.toInt
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.asCompound
|
||||
|
||||
open class FoodItem(
|
||||
@ -61,7 +58,6 @@ open class FoodItem(
|
||||
}
|
||||
|
||||
override fun finishUsing(connection: PlayConnection, itemStack: ItemStack) {
|
||||
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Finished eating: $timeToEat" }
|
||||
if (connection.player.gamemode != Gamemodes.CREATIVE) {
|
||||
itemStack.count--
|
||||
}
|
||||
|
@ -45,6 +45,9 @@ class HotbarVehicleHealthElement(hudRenderer: HUDRenderer) : AbstractHotbarHealt
|
||||
override var totalMaxHealth = 0.0f
|
||||
|
||||
override fun forceRender(offset: Vec2i, z: Int, consumer: GUIVertexConsumer, options: GUIVertexOptions?): Int {
|
||||
if (!shown) {
|
||||
return 0
|
||||
}
|
||||
if (text) {
|
||||
return super.forceRender(offset, z, consumer, options)
|
||||
}
|
||||
@ -77,6 +80,8 @@ class HotbarVehicleHealthElement(hudRenderer: HUDRenderer) : AbstractHotbarHealt
|
||||
val riddenEntity = hudRenderer.connection.player.vehicle
|
||||
if (riddenEntity == null || riddenEntity !is LivingEntity) {
|
||||
if (this.shown) {
|
||||
totalHealth = 0.0f
|
||||
totalMaxHealth = 0.0f
|
||||
this.shown = false
|
||||
return true
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ class InteractInteractionHandler(
|
||||
|
||||
val interactingItem = interactingItem
|
||||
val item = interactingItem?.item
|
||||
if (item is UsableItem) {
|
||||
if (item is UsableItem && connection.player.isUsingItem) {
|
||||
interactingTicksLeft--
|
||||
if (interactingTicksLeft < 0) {
|
||||
item.finishUsing(connection, interactingItem)
|
||||
|
Loading…
x
Reference in New Issue
Block a user