Accumulate how much ticks player exist in world
This commit is contained in:
parent
c47b9c52fe
commit
47e9840365
@ -177,10 +177,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
|
||||
private var invalidateNetworkIn = 10
|
||||
|
||||
var sleepTicks = 0
|
||||
val isEverAndroid: Boolean get() = isAndroid || willBecomeAndroid
|
||||
var lastJumpTicks = 14
|
||||
|
||||
var ticksIExist = 0
|
||||
private set
|
||||
|
||||
var willBecomeAndroid by synchronizer.bool()
|
||||
var isAndroid by synchronizer.bool()
|
||||
|
||||
@ -356,6 +358,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
override fun serializeNBT(): CompoundTag {
|
||||
val tag = CompoundTag()
|
||||
|
||||
tag["ticksIExist"] = ticksIExist
|
||||
|
||||
// iteration
|
||||
tag["iteration"] = iteration
|
||||
tag["shouldSendIteration"] = shouldSendIteration
|
||||
@ -403,6 +407,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
}
|
||||
|
||||
override fun deserializeNBT(tag: CompoundTag) {
|
||||
ticksIExist = tag.getInt("ticksIExist")
|
||||
|
||||
// iterations
|
||||
iteration = tag.getInt("iteration")
|
||||
shouldSendIteration = tag.getBoolean("shouldSendIteration")
|
||||
@ -492,14 +498,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
return
|
||||
}
|
||||
|
||||
if (willBecomeAndroid) {
|
||||
if (ply.isSleeping) {
|
||||
sleepTicks++
|
||||
} else {
|
||||
sleepTicks = 0
|
||||
}
|
||||
}
|
||||
|
||||
if (isAndroid) {
|
||||
for (feature in features.values) {
|
||||
feature.tickClient()
|
||||
@ -512,20 +510,14 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
fun tick() {
|
||||
if (!ply.isAlive) return
|
||||
|
||||
if (willBecomeAndroid) {
|
||||
if (ply.isSleeping) {
|
||||
sleepTicks++
|
||||
ticksIExist++
|
||||
|
||||
if (sleepTicks > SLEEP_TICKS_LIMIT) {
|
||||
if (willBecomeAndroid) {
|
||||
if (ply.isSleeping && ply.sleepTimer > SLEEP_TICKS_LIMIT) {
|
||||
becomeAndroid()
|
||||
shouldPlaySound = true
|
||||
sleepTicks = 0
|
||||
|
||||
(ply as? ServerPlayer)?.displayClientMessage(TranslatableComponent("otm.pill.message_finish").withStyle(ChatFormatting.DARK_RED), false)
|
||||
}
|
||||
} else {
|
||||
sleepTicks = 0
|
||||
}
|
||||
}
|
||||
|
||||
if (isAndroid) {
|
||||
|
@ -59,7 +59,7 @@ object MatteryGUI {
|
||||
return@ifPresentK
|
||||
}
|
||||
|
||||
val dispersion = (10.0 * Math.max(0, it.sleepTicks - 20) / (MatteryPlayerCapability.SLEEP_TICKS_LIMIT - 20)).toInt()
|
||||
val dispersion = (10.0 * Math.max(0, it.ply.sleepTimer - 20) / (MatteryPlayerCapability.SLEEP_TICKS_LIMIT - 20)).toInt()
|
||||
|
||||
screen.leaveBedButton.x =
|
||||
originalBedButtonX - dispersion / 2 + (button_shaker.nextDouble() * dispersion).toInt()
|
||||
|
Loading…
Reference in New Issue
Block a user