From 0da87980f7a62fd657391e67ecc3eea875f79622 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 14 Mar 2023 18:09:46 +0300 Subject: [PATCH] =?UTF-8?q?DBotThePony=20=E2=80=94=20=D0=A1=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2017:11=20=D0=B0=D1=85=20?= =?UTF-8?q?=D0=B4=D0=B0=20=D1=82=D1=8B=20=D0=BF=D1=80=D0=BE=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=D0=B8=D0=B7=D1=83=D0=B0=D0=BB=D0=BA=D1=83=20?= =?UTF-8?q?=D0=B1=D1=80=D0=BE=D0=BD=D0=B8=20=D0=BD=D0=B0=D0=BD=D0=BE=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B2=20=D1=82=D0=B0=D0=BA=20=D1=82=D1=8B?= =?UTF-8?q?=D0=B6=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BE=D1=81=D0=BA=D1=83=20=D1=85=D0=BF,=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B6=D0=BD=D0=BE=20=D1=82=D1=83=D0=B4=D0=B0=20=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B1=D0=BE=D1=82=D0=BE=D0=B2=20=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BF=D0=B8=D1=82=D1=8C=20:Pogomega:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/feature/NanobotsArmorFeature.kt | 9 ++++--- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 25 +++++++++++++----- .../textures/gui/player_bars_health.png | Bin 292 -> 325 bytes 3 files changed, 24 insertions(+), 10 deletions(-) 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 abf4b1d3a4372b2fe23b8ae3a5aa23d84defd11e..91269787329a435ef2bde45c6ec3bac8b43d86a4 100644 GIT binary patch delta 283 zcmZ3&bd+g=IF~&KGXn#|`t?`zCMqh_TL$=qxc(Ow-YqN)6xGnsVEF%^VgG&xeSHQ8 zhba{j8NnP^u3Wi)|Gt8Pg0{BymG$OV7BMtDeb2b>6Hq-9@16rdO1LD*FZe$OVAxc9 zhXW|hS>O>_%)r36AA}h#Sc6r7f@PjAjv*2C?r*PY3LP-uVL90Q_|EqK|8K~guu)#1 z_4b3B(FQJCQPT`XBTK=Tniqq!ZnmB{)9K;AvpM)3`xb$jb2`38D{cC*v`09q!^h91 zO6<{|1$!UuYHU66rSt33f8RU4=p6a$z&-I~r^k6G8-1{jH(om#H)|ZbTG!e&59kC2 NPggcSmvv4FO#tOqd}{yz delta 220 zcmX@gw1jDbIF}g*GXn!d$AZ>p6BQK%bpw1tT>lFT?-mvYifU+ROpH^km#-As2juaW z1o;L3M*$31?#x&Sl;SM#h%9Dc;5z`qj9J$@Ie~(yo-U3d5$QNp*GOE{F%lJgnc8u==Uc~V zt~8^GFGcrH|8-yY(rJP1vS1ByZ54Ae#AbGNyiwBAIMbS^@iwIgXd{ECtDnm{r-UW| D!TMOH