Don't tick hunger, breath and swimming if spectator
This commit is contained in:
parent
313a14f8d9
commit
6f9c9edac1
@ -625,17 +625,18 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
if (ply.airSupply < ply.maxAirSupply)
|
if (!ply.isSpectator && ply.airSupply < ply.maxAirSupply)
|
||||||
ply.airSupply = ply.maxAirSupply
|
ply.airSupply = ply.maxAirSupply
|
||||||
|
|
||||||
// TODO: Maybe passive drain?
|
// TODO: Maybe passive drain?
|
||||||
// extractEnergyInner(BigDecimal.valueOf(new Random().nextDouble()), false);
|
// extractEnergyInner(BigDecimal.valueOf(new Random().nextDouble()), false);
|
||||||
if (ply.isSwimming && !hasFeature(AndroidFeatures.AIR_BAGS)) {
|
if (!ply.isSpectator && ply.isSwimming && !hasFeature(AndroidFeatures.AIR_BAGS)) {
|
||||||
ply.isSwimming = false
|
ply.isSwimming = false
|
||||||
}
|
}
|
||||||
|
|
||||||
androidEnergy.tick()
|
androidEnergy.tick()
|
||||||
|
|
||||||
|
if (!ply.isSpectator) {
|
||||||
val stats = ply.foodData
|
val stats = ply.foodData
|
||||||
|
|
||||||
while (stats.foodLevel < 18 && androidEnergy.extractEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) {
|
while (stats.foodLevel < 18 && androidEnergy.extractEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) {
|
||||||
@ -661,6 +662,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
val extracted = androidEnergy.extractEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false)
|
val extracted = androidEnergy.extractEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false)
|
||||||
stats.setExhaustion(stats.exhaustionLevel - (extracted / ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f)
|
stats.setExhaustion(stats.exhaustionLevel - (extracted / ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (feature in featureMap.values) {
|
for (feature in featureMap.values) {
|
||||||
feature.tickServer()
|
feature.tickServer()
|
||||||
|
@ -21,6 +21,9 @@ fun onMovementInputUpdate(event: MovementInputUpdateEvent) {
|
|||||||
val ply = event.entity
|
val ply = event.entity
|
||||||
val input = event.input
|
val input = event.input
|
||||||
|
|
||||||
|
if (ply.isCreative || ply.isSpectator)
|
||||||
|
return
|
||||||
|
|
||||||
val cap = ply.matteryPlayer ?: return
|
val cap = ply.matteryPlayer ?: return
|
||||||
|
|
||||||
if (cap.isAndroid) {
|
if (cap.isAndroid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user