Fix item using when not able to use; hud: fix vehicle health not disappearing

This commit is contained in:
Bixilon 2021-11-01 12:33:37 +01:00
parent 397cfd916c
commit ca85ca017f
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 6 additions and 5 deletions

View File

@ -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--
}

View File

@ -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
}

View File

@ -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)