Skip to content

Commit

Permalink
Fix crash if non-player right-clicks entity
Browse files Browse the repository at this point in the history
  • Loading branch information
copyboy committed Nov 6, 2013
1 parent 78421b0 commit 574ce8d
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ public void onEntityInteract(EntityInteractEvent event) {
// Right clicking the back of an entity that
// has a backpack will open a GUI for that it.

if (event.entity.worldObj.isRemote) return;
if (event.entity.worldObj.isRemote ||
!(event.entity instanceof EntityPlayerMP) ||
!(event.target instanceof EntityLivingBase)) return;

EntityPlayerMP player = (EntityPlayerMP)event.entity;
if (!(event.target instanceof EntityLivingBase)) return;
EntityLivingBase target = (EntityLivingBase)event.target;

if (ItemBackpack.openBackpack(player, target))
player.swingItem();

Expand All @@ -149,7 +150,7 @@ public void onEntityInteract(EntityInteractEvent event) {
@ForgeSubscribe
public void onSpecialSpawn(SpecialSpawn event) {

// When a mob spawns natually, see if it has a chance to spawn with a backpack.
// When a mob spawns naturally, see if it has a chance to spawn with a backpack.

EntityLivingBase entity = event.entityLiving;
double probability = 0.0;
Expand Down

0 comments on commit 574ce8d

Please sign in to comment.