smoother ability cooldown display (rubberbanding due to late sync)
This commit is contained in:
parent
f13f9481ea
commit
8dcf484362
@ -1,8 +1,10 @@
|
|||||||
package ru.dbotthepony.mc.otm.android
|
package ru.dbotthepony.mc.otm.android
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiGraphics
|
import net.minecraft.client.gui.GuiGraphics
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel
|
||||||
import net.minecraft.nbt.CompoundTag
|
import net.minecraft.nbt.CompoundTag
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||||
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||||
|
|
||||||
@ -31,6 +33,11 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma
|
|||||||
|
|
||||||
val cooldownPercent: Float get() {
|
val cooldownPercent: Float get() {
|
||||||
if (maxCooldown <= 0) return 0.0f
|
if (maxCooldown <= 0) return 0.0f
|
||||||
|
|
||||||
|
if (ply.level() is ClientLevel) {
|
||||||
|
return ((cooldown.toFloat() - minecraft.partialTick) / maxCooldown.toFloat()).coerceIn(0.0f, 1.0f)
|
||||||
|
}
|
||||||
|
|
||||||
return (cooldown.toFloat() / maxCooldown.toFloat()).coerceIn(0.0f, 1.0f)
|
return (cooldown.toFloat() / maxCooldown.toFloat()).coerceIn(0.0f, 1.0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user