Skip to content

Commit

Permalink
Merge pull request #546 from Pieter12345/master
Browse files Browse the repository at this point in the history
Fix NPE in entity_spec for Enderman
  • Loading branch information
PseudoKnight committed Jan 22, 2020
2 parents 475ae05 + a6b0edb commit 298ed5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Expand Up @@ -18,7 +18,8 @@ public BukkitMCEnderman(Entity ent) {

@Override
public MCBlockData getCarriedMaterial() {
return new BukkitMCBlockData(e.getCarriedBlock());
BlockData data = e.getCarriedBlock();
return (data == null ? null : new BukkitMCBlockData(data));
}

@Override
Expand Down
Expand Up @@ -5,6 +5,10 @@

public interface MCEnderman extends MCLivingEntity {

/**
* Gets the data of the block that the Enderman is carrying.
* @return {@link MCBlockData} containing the carried block, or {@code null} if none.
*/
MCBlockData getCarriedMaterial();

void setCarriedMaterial(MCBlockData held);
Expand Down
Expand Up @@ -1839,7 +1839,8 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
case ENDERMAN:
MCEnderman enderman = (MCEnderman) entity;
MCBlockData carried = enderman.getCarriedMaterial();
specArray.set(entity_spec.KEY_ENDERMAN_CARRIED, new CString(carried.getMaterial().getName(), t), t);
specArray.set(entity_spec.KEY_ENDERMAN_CARRIED,
(carried == null ? CNull.NULL : new CString(carried.getMaterial().getName(), t)), t);
break;
case EVOKER_FANGS:
MCEvokerFangs fangs = (MCEvokerFangs) entity;
Expand Down

0 comments on commit 298ed5c

Please sign in to comment.