Browse Source

optimized regen client sync

lakebane
FatBoy-DOTC 14 hours ago
parent
commit
29736f9c8f
  1. 4
      src/engine/objects/PlayerCharacter.java

4
src/engine/objects/PlayerCharacter.java

@ -5469,6 +5469,8 @@ public class PlayerCharacter extends AbstractCharacter { @@ -5469,6 +5469,8 @@ public class PlayerCharacter extends AbstractCharacter {
}
public void doRegen(){
if(!this.timestamps.contains("SyncClient"))
this.timestamps.put("SyncClient",System.currentTimeMillis());
if (this.updateLock.writeLock().tryLock()) {
try {
if(!this.isAlive() || !this.enteredWorld || !this.isActive) {
@ -5480,6 +5482,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -5480,6 +5482,7 @@ public class PlayerCharacter extends AbstractCharacter {
boolean updateMana = this.regenerateMana();
boolean updateStamina = this.regenerateStamina();
boolean consumeStamina = this.consumeStamina();
if(this.timestamps.get("SyncClient") + 5000L > System.currentTimeMillis())
if(updateHealth || updateMana || updateStamina || consumeStamina)
this.syncClient();
} catch (Exception e) {
@ -5488,7 +5491,6 @@ public class PlayerCharacter extends AbstractCharacter { @@ -5488,7 +5491,6 @@ public class PlayerCharacter extends AbstractCharacter {
this.updateLock.writeLock().unlock();
}
}
//ChatManager.chatSystemInfo(this,"HEALTH: " + this.health.get() + " MANA: " + this.mana.get() + " STAM: " + this.stamina.get());
}
public boolean regenerateHealth(){

Loading…
Cancel
Save