diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt index f1f9723d9..ef2f24fc4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt @@ -18,14 +18,17 @@ import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger import kotlin.math.roundToInt class NanobotsArmorFeature(android: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.NANOBOTS_ARMOR, android) { - var strength: Int = 0 - set(value) { field = value.coerceIn(0 .. 3) } + var strength by synchronizer.int( + setter = setter@{ + value, access, _ -> access.write(value.coerceIn(0 .. 3)) + } + ) var speed: Int = 0 set(value) { field = value.coerceIn(0 .. 3) } private var ticksPassed = 0 - private var layers = 0 + var layers by synchronizer.int() override fun tickServer() { if (layers < strength + 1 && android.androidEnergy.extractEnergyInnerExact(ENERGY_PER_LAYER, true).isPositive) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index ff845b2b8..a5385e547 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -19,6 +19,7 @@ import net.minecraftforge.client.gui.overlay.ForgeGui import net.minecraftforge.client.gui.overlay.GuiOverlayManager import ru.dbotthepony.mc.otm.ClientConfig import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -27,6 +28,7 @@ import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.formatPower import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.registry.AndroidFeatures import java.util.* import kotlin.math.ceil @@ -38,15 +40,16 @@ object MatteryGUI { val CHARGE_HUNGER = BARS.subElement(y = 18f, height = 9f) val CHARGE_HUNGER_BG = BARS.subElement(y = 27f, height = 9f) - private val BARS_HP = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "player_bars_health"), 81f, 54f) + private val BARS_HP = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars_health.png"), 81f, 63f) val HEALTH = BARS_HP.subElement(height = 9f) val HEALTH_BG = BARS_HP.subElement(y = 9f, height = 9f) + val HEALTH_BG_NANOBOTS = BARS_HP.subElement(y = 18f, height = 9f) - val HEALTH_POISON = BARS_HP.subElement(y = 18f, height = 9f) - val HEALTH_WITHER = BARS_HP.subElement(y = 27f, height = 9f) - val HEALTH_ABSORB = BARS_HP.subElement(y = 36f, height = 9f) - val HEALTH_FROZEN = BARS_HP.subElement(y = 45f, height = 9f) + val HEALTH_POISON = BARS_HP.subElement(y = 27f, height = 9f) + val HEALTH_WITHER = BARS_HP.subElement(y = 36f, height = 9f) + val HEALTH_ABSORB = BARS_HP.subElement(y = 45f, height = 9f) + val HEALTH_FROZEN = BARS_HP.subElement(y = 54f, height = 9f) private var originalBedButtonX = -1 private var originalBedButtonY = -1 @@ -310,8 +313,8 @@ object MatteryGUI { if (!gui.shouldDrawSurvivalElements()) return - val level: Float = (ply.health / ply.maxHealth).coerceIn(0.0f, 1.0f) - val levelAbsorb: Float = (ply.absorptionAmount / ply.maxHealth).coerceIn(0.0f, 1.0f) + val level: Float = (ply.health / ply.maxHealth).coerceIn(0.0f .. 1.0f) + val levelAbsorb: Float = (ply.absorptionAmount / ply.maxHealth).coerceIn(0.0f .. 1.0f) gui.setupOverlayRenderState(true, false) RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f) @@ -323,6 +326,14 @@ object MatteryGUI { gui.leftHeight += 10 HEALTH_BG.render(event.poseStack, left.toFloat(), top.toFloat()) + + if (mattery.hasFeature(AndroidFeatures.NANOBOTS_ARMOR)) { + val featArmor = mattery.getFeature(AndroidFeatures.NANOBOTS_ARMOR) as NanobotsArmorFeature + val levelArmor: Float = (featArmor.layers.toFloat() / (featArmor.strength + 1).toFloat()).coerceIn(0.0f .. 1.0f) + + HEALTH_BG_NANOBOTS.renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(levelArmor * 81f)) + } + getSpriteForPlayer(ply).renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(level * 80f - 0.5f)) if (levelAbsorb > 0) { HEALTH_ABSORB.renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f)) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars_health.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars_health.png index abf4b1d3a..912697873 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars_health.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars_health.png differ