From ca37b4959fd6f0ce8bd9771fa29ccf7976100354 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 17:36:55 +0700 Subject: [PATCH 1/3] Bring back old behavior where exhaustion is immediately nullified by energy buffer on Androids --- .../mc/otm/player/MatteryFoodData.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt index 1ffbc6b74..b460cd7de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt @@ -69,21 +69,20 @@ class MatteryFoodData(private var player: Player) : FoodData() { private var energyToDrain = Decimal.ZERO private fun tickExhaustion() { - if (exhaustionLevel >= EXHAUSTION_PER_HUNGER_POINT) { + if (player.matteryPlayer.isAndroid && exhaustionLevel > 0f) { + energyToDrain += PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (exhaustionLevel / EXHAUSTION_PER_HUNGER_POINT) + exhaustionLevel = 0f + } else if (exhaustionLevel >= EXHAUSTION_PER_HUNGER_POINT) { var points = (exhaustionLevel / EXHAUSTION_PER_HUNGER_POINT).toInt() exhaustionLevel %= EXHAUSTION_PER_HUNGER_POINT - if (player.matteryPlayer.isAndroid) { - energyToDrain += PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * points - } else { - if (saturationLevel > 0f) { - val satisfied = min(saturationLevel.roundToInt(), points) - points -= satisfied - saturationLevel -= satisfied - } - - foodLevel = max(0, foodLevel - points) + if (saturationLevel > 0f) { + val satisfied = min(saturationLevel.roundToInt(), points) + points -= satisfied + saturationLevel -= satisfied } + + foodLevel = max(0, foodLevel - points) } } From 80ff50b937cf537a422250276102111f8b2efbef Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 17:40:16 +0700 Subject: [PATCH 2/3] Nullify excess hunger when eating as android --- .../kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt index b460cd7de..62b9a8e82 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/player/MatteryFoodData.kt @@ -110,9 +110,13 @@ class MatteryFoodData(private var player: Player) : FoodData() { if (player.matteryPlayer.isAndroid) { if (energyToDrain > Decimal.ZERO) energyToDrain -= player.matteryPlayer.androidEnergy.extractEnergy(energyToDrain, false) - else if (energyToDrain < Decimal.ZERO) + else if (energyToDrain < Decimal.ZERO) { energyToDrain += player.matteryPlayer.androidEnergy.receiveEnergy(-energyToDrain, false) + if (player.matteryPlayer.androidEnergy.missingPower <= Decimal.ZERO) + energyToDrain = Decimal.ZERO + } + if (player.level().difficulty == Difficulty.PEACEFUL && PlayerConfig.REGENERATE_ENERGY_IN_PEACEFUL) player.matteryPlayer.androidEnergy.receiveEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) From 579445fbbe46dfe56c1eccf8e6e5848b08890b65 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Mar 2025 17:44:26 +0700 Subject: [PATCH 3/3] Nerf food for androids further --- .../dbotthepony/mc/otm/config/PlayerConfig.kt | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt index b8be2c4c8..c9f907244 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/PlayerConfig.kt @@ -16,11 +16,11 @@ object PlayerConfig : AbstractConfig("player") { val REGENERATE_ENERGY_EFFICIENCY_FOOD: Double by builder .comment("How much % of food points to convert to energy") - .defineInRange("REGENERATE_ENERGY_EFFICIENCY_FOOD", 0.75, 0.0) + .defineInRange("REGENERATE_ENERGY_EFFICIENCY_FOOD", 0.4, 0.0) val REGENERATE_ENERGY_EFFICIENCY_SATURATION: Double by builder .comment("How much % of food saturation points to convert to energy") - .defineInRange("REGENERATE_ENERGY_EFFICIENCY_SATURATION", 0.4, 0.0) + .defineInRange("REGENERATE_ENERGY_EFFICIENCY_SATURATION", 0.2, 0.0) val REGENERATE_ENERGY_IN_PEACEFUL: Boolean by builder .comment("Regenerate energy while in peaceful") @@ -39,6 +39,28 @@ object PlayerConfig : AbstractConfig("player") { .comment("for android players, since 'hunger' (for compatibility) is managed by mod in such case") .defineInRange("TIME_BETWEEN_NATURAL_REGENERATION", 120, 0, Int.MAX_VALUE) + val ANDROID_ENERGY_PER_HUNGER_POINT by builder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO) + val ANDROID_MAX_ENERGY by builder + .comment("Internal battery of every android has this much storage") + .comment("Keep in mind that already existing players won't get their value changed since it is", "stored inside their savedata") + .defineDecimal("capacity", Decimal(80_000), Decimal.ZERO) + + val NIGHT_VISION_POWER_DRAW by builder.defineDecimal("nightVisionPowerDraw", Decimal(8), Decimal.ZERO) + + val FALL_DAMAGE_REDUCTION_PER_LEVEL_P: Double by builder + .comment("In percent. Level of feature is multiplied by this") + .comment("First, fall damage is reduced by flat resistance, then reduced by percentage resistance (this)") + .defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_P", 0.2, 0.01, 1.0) + + val FALL_DAMAGE_REDUCTION_PER_LEVEL_F: Double by builder + .comment("In flat half of hearts. Level of feature is multiplied by this") + .comment("First, fall damage is reduced by flat resistance (this), then reduced by percentage resistance") + .defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_F", 1.5, 0.0, Float.MAX_VALUE.toDouble()) + + val SWIM_BOOSTERS: Double by builder + .comment("Increase per level") + .defineInRange("SWIM_BOOSTERS", 0.25, 0.0, Float.MAX_VALUE.toDouble()) + init { builder.pop() } @@ -71,27 +93,6 @@ object PlayerConfig : AbstractConfig("player") { } } - val ANDROID_ENERGY_PER_HUNGER_POINT by builder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO) - val ANDROID_MAX_ENERGY by builder - .comment("Internal battery of every android has this much storage") - .comment("Keep in mind that already existing players won't get their value changed since it is", "stored inside their savedata") - .defineDecimal("capacity", Decimal(80_000), Decimal.ZERO) - val NIGHT_VISION_POWER_DRAW by builder.defineDecimal("nightVisionPowerDraw", Decimal(8), Decimal.ZERO) - - val FALL_DAMAGE_REDUCTION_PER_LEVEL_P: Double by builder - .comment("In percent. Level of feature is multiplied by this") - .comment("First, fall damage is reduced by flat resistance, then reduced by percentage resistance (this)") - .defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_P", 0.2, 0.01, 1.0) - - val FALL_DAMAGE_REDUCTION_PER_LEVEL_F: Double by builder - .comment("In flat half of hearts. Level of feature is multiplied by this") - .comment("First, fall damage is reduced by flat resistance (this), then reduced by percentage resistance") - .defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_F", 1.5, 0.0, Float.MAX_VALUE.toDouble()) - - val SWIM_BOOSTERS: Double by builder - .comment("Increase per level") - .defineInRange("SWIM_BOOSTERS", 0.25, 0.0, Float.MAX_VALUE.toDouble()) - object EnderTeleporter { init { builder.comment("Ender Teleporter ability").push("EnderTeleporter")