Skip to content
Browse files
Fix NPE in entity_spec for Enderman
Fix calling entity_spec on an Enderman that is not carrying a block resulting in a NullPointerException.
  • Loading branch information
Pieter12345 committed Jan 21, 2020
1 parent 475ae05 commit a6b0edbb4e7995652193b84fc3df7134c258f6ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
@@ -18,7 +18,8 @@ public BukkitMCEnderman(Entity ent) {

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

@@ -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
MCEnderman enderman = (MCEnderman) entity;
MCBlockData carried = enderman.getCarriedMaterial();
specArray.set(entity_spec.KEY_ENDERMAN_CARRIED, new CString(carried.getMaterial().getName(), t), t);
(carried == null ? CNull.NULL : new CString(carried.getMaterial().getName(), t)), t);
MCEvokerFangs fangs = (MCEvokerFangs) entity;

0 comments on commit a6b0edb

Please sign in to comment.