Guest User

PlayerHandler.class

a guest
Aug 19th, 2015
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. package com.maikyy.endgamepp.util;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
  5. import net.minecraftforge.event.entity.living.LivingFallEvent;
  6. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  7.  
  8. public class PlayerHandler
  9. {
  10.     //Check to see if the player has jumped
  11.     public static boolean isJumping = false;
  12.    
  13.     //Check to see if the player has jumped a second time
  14.     public static boolean isDoubleJumping = false;
  15.    
  16.     //Check to see if the player is able to double jump, will be dependend on items later but for now I just want the mechanics working.
  17.     public static boolean canDoubleJump = true;
  18.    
  19.     //Check if the player is jumping, if so set the isJumping to true
  20.     @SubscribeEvent()
  21.     public void onEvent(LivingJumpEvent event)
  22.     {
  23.         EntityPlayer player = (EntityPlayer) event.entity;
  24.        
  25.         if(event.entity instanceof EntityPlayer)
  26.         {
  27.             isJumping = true;
  28.         }
  29.     }
  30.    
  31.     //Check if the player has landed, if so set the isJumping AND isDoubleJumping to false
  32.     @SubscribeEvent()
  33.     public void onEvent(LivingFallEvent event)
  34.     {
  35.         if(event.entity instanceof EntityPlayer)
  36.         {
  37.             isJumping = false;
  38.             isDoubleJumping = false;
  39.         }
  40.     }  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment