Make underwater travel challenge account for displacement, and not distance
This commit is contained in:
parent
ebafdbc925
commit
a72f2aabb2
@ -459,7 +459,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
var ticksIExist = 0
|
var ticksIExist = 0
|
||||||
private set
|
private set
|
||||||
|
|
||||||
private var lastOutsideLiquid = Vec3(0.0, 0.0, 0.0)
|
private var lastLiquidPosition = Vec3(0.0, 0.0, 0.0)
|
||||||
|
private var liquidDistanceTravelled = 0.0
|
||||||
private var wasInLiquid = false
|
private var wasInLiquid = false
|
||||||
private var lastDimension = ResourceLocation("overworld")
|
private var lastDimension = ResourceLocation("overworld")
|
||||||
|
|
||||||
@ -591,8 +592,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
savetables.int(::nextDischargeHurt)
|
savetables.int(::nextDischargeHurt)
|
||||||
savetables.int(::nextHealTick)
|
savetables.int(::nextHealTick)
|
||||||
|
|
||||||
savetables.vector(::lastOutsideLiquid)
|
savetables.vector(::lastLiquidPosition)
|
||||||
savetables.codec(::lastDimension, ResourceLocation.CODEC)
|
savetables.codec(::lastDimension, ResourceLocation.CODEC)
|
||||||
|
savetables.double(::liquidDistanceTravelled)
|
||||||
|
|
||||||
savetables.stateful(::exopackSlotModifier, "exoSuitSlotCountModifiers")
|
savetables.stateful(::exopackSlotModifier, "exoSuitSlotCountModifiers")
|
||||||
savetables.stateful(::exopackContainer, "exoSuitContainer")
|
savetables.stateful(::exopackContainer, "exoSuitContainer")
|
||||||
@ -664,7 +666,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
androidEnergy.batteryLevel = AndroidConfig.ANDROID_MAX_ENERGY
|
androidEnergy.batteryLevel = AndroidConfig.ANDROID_MAX_ENERGY
|
||||||
androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY
|
androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY
|
||||||
|
|
||||||
lastOutsideLiquid = ply.position()
|
lastLiquidPosition = ply.position()
|
||||||
wasInLiquid = false
|
wasInLiquid = false
|
||||||
|
|
||||||
if (ply is ServerPlayer) {
|
if (ply is ServerPlayer) {
|
||||||
@ -719,7 +721,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY
|
androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY
|
||||||
dropBattery()
|
dropBattery()
|
||||||
|
|
||||||
lastOutsideLiquid = ply.position()
|
lastLiquidPosition = ply.position()
|
||||||
wasInLiquid = false
|
wasInLiquid = false
|
||||||
|
|
||||||
if (ply is ServerPlayer) {
|
if (ply is ServerPlayer) {
|
||||||
@ -1193,31 +1195,38 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
|||||||
if (ply.airSupply < ply.maxAirSupply)
|
if (ply.airSupply < ply.maxAirSupply)
|
||||||
ply.airSupply = ply.maxAirSupply
|
ply.airSupply = ply.maxAirSupply
|
||||||
|
|
||||||
if (ply.isSwimming && !hasFeature(AndroidFeatures.AIR_BAGS))
|
if (ply.isSwimming && !hasFeature(AndroidFeatures.AIR_BAGS) && !ply.isCreative)
|
||||||
ply.isSwimming = false
|
ply.isSwimming = false
|
||||||
|
|
||||||
if (ply is ServerPlayer) {
|
if (ply is ServerPlayer) {
|
||||||
if (ply.level().dimension().location() != lastDimension) {
|
if (ply.level().dimension().location() != lastDimension) {
|
||||||
lastDimension = ply.level().dimension().location()
|
lastDimension = ply.level().dimension().location()
|
||||||
wasInLiquid = false
|
wasInLiquid = false
|
||||||
lastOutsideLiquid = ply.position
|
lastLiquidPosition = ply.position
|
||||||
|
liquidDistanceTravelled = 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ply.isUnderWater && !ply.isCreative) {
|
if (ply.isUnderWater) {
|
||||||
if (!wasInLiquid) {
|
if (!wasInLiquid) {
|
||||||
wasInLiquid = true
|
wasInLiquid = true
|
||||||
lastOutsideLiquid = ply.position
|
liquidDistanceTravelled = 0.0
|
||||||
|
lastLiquidPosition = ply.position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
liquidDistanceTravelled += (ply.position - lastLiquidPosition).length()
|
||||||
} else {
|
} else {
|
||||||
if (wasInLiquid) {
|
if (wasInLiquid) {
|
||||||
wasInLiquid = false
|
wasInLiquid = false
|
||||||
|
|
||||||
if (!hasFeature(AndroidFeatures.AIR_BAGS))
|
if (!hasFeature(AndroidFeatures.AIR_BAGS)) {
|
||||||
AndroidTravelUnderwater.trigger(ply, (lastOutsideLiquid - ply.position).length())
|
AndroidTravelUnderwater.trigger(ply, liquidDistanceTravelled)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastOutsideLiquid = ply.position
|
liquidDistanceTravelled = 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastLiquidPosition = ply.position
|
||||||
}
|
}
|
||||||
|
|
||||||
val stats = ply.foodData
|
val stats = ply.foodData
|
||||||
|
Loading…
Reference in New Issue
Block a user