Skip to content
Permalink
Browse files
Merge pull request #546 from Pieter12345/master
Fix NPE in entity_spec for Enderman
  • Loading branch information
PseudoKnight committed Jan 22, 2020
2 parents 475ae05 + a6b0edb commit 298ed5c028386f9ef22755a3093e904e69db1ab3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
@@ -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
@@ -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);
@@ -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;

0 comments on commit 298ed5c

Please sign in to comment.