diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/player/PlayerUtils.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java index 9c43b39f92..543fd65b71 100644 --- a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java +++ b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java @@ -101,7 +101,10 @@ public class PlayerUtils { public static ItemStack getItemStackInPlayersHand(final EntityPlayer player){ ItemStack heldItem = null; try{heldItem = player.getHeldItem(); - }catch(final NullPointerException e){return null;} + }catch(final NullPointerException e){ + e.printStackTrace(); + return null; + } if (heldItem != null){ return heldItem; } @@ -109,7 +112,7 @@ public class PlayerUtils { } @SideOnly(Side.CLIENT) - public static Item getItemInPlayersHand(){ + public static Item getItemInPlayersHandClient(){ final Minecraft mc = Minecraft.getMinecraft(); Item heldItem = null; @@ -123,6 +126,18 @@ public class PlayerUtils { return null; } + public static Item getItemInPlayersHand(EntityPlayer player){ + Item heldItem = null; + try{heldItem = player.getHeldItem().getItem(); + }catch(final NullPointerException e){return null;} + + if (heldItem != null){ + return heldItem; + } + + return null; + } + public final static EntityPlayer getPlayerEntityByName(String aPlayerName){ EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); if (player != null){ |