diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java | 18 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/ob/GliderHandler.java | 10 |
2 files changed, 15 insertions, 13 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java index 2fb7344a28..4b579e84d2 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java @@ -12,7 +12,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; - +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.Utils; public class PlayerUtils { @@ -103,15 +103,25 @@ public class PlayerUtils { @SideOnly(Side.SERVER) public static ItemStack getItemStackInPlayersHand(final EntityPlayer player){ ItemStack heldItem = null; - try{heldItem = player.getHeldItem(); - }catch(final NullPointerException e){ + try{ + heldItem = player.getHeldItem(); + } + catch(final NullPointerException e){ e.printStackTrace(); return null; } if (heldItem != null){ return heldItem; } - return null; + else { + if (Utils.isClient()) { + heldItem = player.getItemInUse(); + } + else { + heldItem = player.getCurrentEquippedItem(); + } + } + return heldItem; } @SideOnly(Side.CLIENT) diff --git a/src/Java/gtPlusPlus/xmod/ob/GliderHandler.java b/src/Java/gtPlusPlus/xmod/ob/GliderHandler.java index 7a53572aae..a190511b02 100644 --- a/src/Java/gtPlusPlus/xmod/ob/GliderHandler.java +++ b/src/Java/gtPlusPlus/xmod/ob/GliderHandler.java @@ -35,15 +35,7 @@ public class GliderHandler { return; } - ItemStack aItem = event.entityPlayer.getItemInUse(); - if (!ItemUtils.checkForInvalidItems(aItem)) { - Logger.WARNING("[OpenBlocks] Item in use was invalid, trying currentlyEquipped."); - aItem = event.entityPlayer.getCurrentEquippedItem(); - } - if (!ItemUtils.checkForInvalidItems(aItem)) { - Logger.WARNING("[OpenBlocks] Item in use was invalid, trying heldItem."); - aItem = event.entityPlayer.getHeldItem(); - } + ItemStack aItem = PlayerUtils.getItemStackInPlayersHand(event.entityPlayer); if (ItemUtils.checkForInvalidItems(aItem)) { Class aItemGliderClass = ReflectionUtils.getClass("openblocks.common.item.ItemHangGlider"); if (aItemGliderClass.isInstance(aItem.getItem())) { |