Add More Creeper API

This commit is contained in:
BillyGalbreath 2018-08-24 11:50:26 -05:00
parent f6b20dccfc
commit bfd8b7bcef
2 changed files with 43 additions and 0 deletions

View file

@ -22,6 +22,15 @@
public Creeper(EntityType<? extends Creeper> type, Level world) {
super(type, world);
@@ -125,7 +133,7 @@
}
if (nbt.getBoolean("ignited")) {
- this.ignite();
+ this.entityData.set(Creeper.DATA_IS_IGNITED, true); // Paper - set directly to avoid firing event
}
}
@@ -214,9 +222,20 @@
@Override
public void thunderHit(ServerLevel world, LightningBolt lightning) {
@ -99,3 +108,25 @@
}
}
@@ -284,9 +315,20 @@
}
public void ignite() {
- this.entityData.set(Creeper.DATA_IS_IGNITED, true);
+ // Paper start - CreeperIgniteEvent
+ setIgnited(true);
}
+ public void setIgnited(boolean ignited) {
+ if (isIgnited() != ignited) {
+ com.destroystokyo.paper.event.entity.CreeperIgniteEvent event = new com.destroystokyo.paper.event.entity.CreeperIgniteEvent((org.bukkit.entity.Creeper) getBukkitEntity(), ignited);
+ if (event.callEvent()) {
+ this.entityData.set(Creeper.DATA_IS_IGNITED, event.isIgnited());
+ }
+ }
+ // Paper end - CreeperIgniteEvent
+ }
+
public boolean canDropMobsSkull() {
return this.isPowered() && this.droppedSkulls < 1;
}

View file

@ -101,4 +101,16 @@ public class CraftCreeper extends CraftMonster implements Creeper {
public String toString() {
return "CraftCreeper";
}
// Paper start
@Override
public void setIgnited(boolean ignited) {
getHandle().setIgnited(ignited);
}
@Override
public boolean isIgnited() {
return getHandle().isIgnited();
}
// Paper end
}