Advertisement
jayhillx

onRespawn

Sep 18th, 2021
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. @SubscribeEvent
  2.     public void onRespawn(PlayerRespawnEvent event) {
  3.         PlayerEntity player = event.getPlayer();
  4.  
  5.         player.getCapability(HealthCapability.HEALTH_CAPABILITY).ifPresent(health -> {
  6.             if (player.getMaxHealth() >= 2.0F && player.getMaxHealth() <= 20.0F) {
  7.                 player.setHealth(health.getMaxHealth());
  8.                 player.getAttribute(Attributes.MAX_HEALTH).setBaseValue(health.getMaxHealth());
  9.  
  10.             } if (player.getMaxHealth() >= 22.0F) {
  11.                 player.setGameMode(GameType.SPECTATOR);
  12.             }
  13.         });
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement