Advertisement
Guest User

Untitled

a guest
May 18th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.27 KB | None | 0 0
  1. @SubscribeEvent
  2.     fun attributesHandler(e: LivingEvent.LivingUpdateEvent) {
  3.         if(e.entity is EntityPlayer) {
  4.             val player = e.entity as EntityPlayer
  5.             if(!player.world.isRemote) {
  6.                 if(staminaTimer++ == 5) {
  7.                     when {
  8.                         player.isSprinting -> player.getEntityAttribute(PropertiesRegistry.stamina).baseValue -= TLDConfig.staminaConsume
  9.                         else -> player.getEntityAttribute(PropertiesRegistry.stamina).baseValue += TLDConfig.staminaFill
  10.                     }
  11.                     staminaTimer = 0
  12.                 }
  13.                
  14.                 if(fatigueTimer++ == 5) {
  15.                     when {
  16.                         player.isSprinting -> player.getEntityAttribute(PropertiesRegistry.fatigue).baseValue -= (TLDConfig.fatigueConsumeOnSprint /36)
  17.                         player.motionX != 0.0 && player.motionY != 0.0 -> player.getEntityAttribute(PropertiesRegistry.fatigue).baseValue -= (TLDConfig.fatigueConsumeOnWalk / 36)
  18.                         else -> player.getEntityAttribute(PropertiesRegistry.fatigue).baseValue -= (TLDConfig.fatigueConsumeOnStand / 36)
  19.                     }
  20.                     fatigueTimer = 0
  21.                 }
  22.             }
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement