parent
da96de0037
commit
0d52bd8e19
@ -141,6 +141,13 @@ object ServerConfig {
|
|||||||
specBuilder.comment("Tweaking of android players").push("androidPlayer")
|
specBuilder.comment("Tweaking of android players").push("androidPlayer")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val REGENERATE_ENERGY: Boolean by specBuilder
|
||||||
|
.comment("If (technically) hunger is above threshold, it turns into energy")
|
||||||
|
.comment("This setting controls whenever to regenerate small amount of energy while eating as Android")
|
||||||
|
.comment("And also whenever to regenerate energy while in peaceful")
|
||||||
|
.comment("If this is disabled, any (technically) excess hunger will be nullified, unless playing on peaceful difficulty.")
|
||||||
|
.define("regenerateEnergy", true)
|
||||||
|
|
||||||
val ANDROID_ENERGY_PER_HUNGER_POINT by specBuilder.defineImpreciseFraction("energyPerHunger", ImpreciseFraction(1000), ImpreciseFraction.ZERO)
|
val ANDROID_ENERGY_PER_HUNGER_POINT by specBuilder.defineImpreciseFraction("energyPerHunger", ImpreciseFraction(1000), ImpreciseFraction.ZERO)
|
||||||
val ANDROID_MAX_ENERGY by specBuilder.comment("Internal battery of every android has this much storage").defineImpreciseFraction("capacity", ImpreciseFraction(80_000), ImpreciseFraction.ZERO)
|
val ANDROID_MAX_ENERGY by specBuilder.comment("Internal battery of every android has this much storage").defineImpreciseFraction("capacity", ImpreciseFraction(80_000), ImpreciseFraction.ZERO)
|
||||||
val NIGHT_VISION_POWER_DRAW by specBuilder.defineImpreciseFraction("nightVisionPowerDraw", ImpreciseFraction(8), ImpreciseFraction.ZERO)
|
val NIGHT_VISION_POWER_DRAW by specBuilder.defineImpreciseFraction("nightVisionPowerDraw", ImpreciseFraction(8), ImpreciseFraction.ZERO)
|
||||||
|
@ -11,6 +11,7 @@ import net.minecraft.network.chat.Component
|
|||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
import net.minecraft.tags.TagKey
|
import net.minecraft.tags.TagKey
|
||||||
|
import net.minecraft.world.Difficulty
|
||||||
import net.minecraft.world.effect.MobEffect
|
import net.minecraft.world.effect.MobEffect
|
||||||
import net.minecraft.world.entity.Entity
|
import net.minecraft.world.entity.Entity
|
||||||
import net.minecraft.world.entity.MobSpawnType
|
import net.minecraft.world.entity.MobSpawnType
|
||||||
@ -631,10 +632,14 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
|
|
||||||
// "block" quick regeneration
|
// "block" quick regeneration
|
||||||
// also cause power to generate while in peaceful
|
// also cause power to generate while in peaceful
|
||||||
|
if (ServerConfig.REGENERATE_ENERGY) {
|
||||||
while (stats.foodLevel > 18 && androidEnergy.receiveEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) {
|
while (stats.foodLevel > 18 && androidEnergy.receiveEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) {
|
||||||
androidEnergy.receiveEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)
|
androidEnergy.receiveEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)
|
||||||
stats.foodLevel = stats.foodLevel - 1
|
stats.foodLevel = stats.foodLevel - 1
|
||||||
}
|
}
|
||||||
|
} else if (ply.level.server?.worldData?.difficulty != Difficulty.PEACEFUL) {
|
||||||
|
stats.foodLevel = stats.foodLevel.coerceAtMost(18)
|
||||||
|
}
|
||||||
|
|
||||||
val foodLevel = stats.foodLevel.toFloat()
|
val foodLevel = stats.foodLevel.toFloat()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user