Merge branch '1.21' into new-container-api

This commit is contained in:
DBotThePony 2025-03-14 17:47:09 +07:00
commit d57371ca13
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 39 additions and 35 deletions

View File

@ -16,11 +16,11 @@ object PlayerConfig : AbstractConfig("player") {
val REGENERATE_ENERGY_EFFICIENCY_FOOD: Double by builder val REGENERATE_ENERGY_EFFICIENCY_FOOD: Double by builder
.comment("How much % of food points to convert to energy") .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 val REGENERATE_ENERGY_EFFICIENCY_SATURATION: Double by builder
.comment("How much % of food saturation points to convert to energy") .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 val REGENERATE_ENERGY_IN_PEACEFUL: Boolean by builder
.comment("Regenerate energy while in peaceful") .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") .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) .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 { init {
builder.pop() 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 { object EnderTeleporter {
init { init {
builder.comment("Ender Teleporter ability").push("EnderTeleporter") builder.comment("Ender Teleporter ability").push("EnderTeleporter")

View File

@ -69,21 +69,20 @@ class MatteryFoodData(private var player: Player) : FoodData() {
private var energyToDrain = Decimal.ZERO private var energyToDrain = Decimal.ZERO
private fun tickExhaustion() { 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() var points = (exhaustionLevel / EXHAUSTION_PER_HUNGER_POINT).toInt()
exhaustionLevel %= EXHAUSTION_PER_HUNGER_POINT exhaustionLevel %= EXHAUSTION_PER_HUNGER_POINT
if (player.matteryPlayer.isAndroid) { if (saturationLevel > 0f) {
energyToDrain += PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * points val satisfied = min(saturationLevel.roundToInt(), points)
} else { points -= satisfied
if (saturationLevel > 0f) { saturationLevel -= satisfied
val satisfied = min(saturationLevel.roundToInt(), points)
points -= satisfied
saturationLevel -= satisfied
}
foodLevel = max(0, foodLevel - points)
} }
foodLevel = max(0, foodLevel - points)
} }
} }
@ -111,9 +110,13 @@ class MatteryFoodData(private var player: Player) : FoodData() {
if (player.matteryPlayer.isAndroid) { if (player.matteryPlayer.isAndroid) {
if (energyToDrain > Decimal.ZERO) if (energyToDrain > Decimal.ZERO)
energyToDrain -= player.matteryPlayer.androidEnergy.extractEnergy(energyToDrain, false) energyToDrain -= player.matteryPlayer.androidEnergy.extractEnergy(energyToDrain, false)
else if (energyToDrain < Decimal.ZERO) else if (energyToDrain < Decimal.ZERO) {
energyToDrain += player.matteryPlayer.androidEnergy.receiveEnergy(-energyToDrain, false) 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) if (player.level().difficulty == Difficulty.PEACEFUL && PlayerConfig.REGENERATE_ENERGY_IN_PEACEFUL)
player.matteryPlayer.androidEnergy.receiveEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) player.matteryPlayer.androidEnergy.receiveEnergy(PlayerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)