Add list of entities to EntityTransformEvent & move die calls

By: nathat890 <nathat890@outlook.com>
This commit is contained in:
CraftBukkit/Spigot
2018-12-05 09:51:20 +11:00
parent b69f1de549
commit e9e6bec4e5
6 changed files with 72 additions and 39 deletions

View File

@@ -28,31 +28,18 @@
}
@Nullable
@@ -149,6 +155,12 @@
if (!this.world.isClientSide && !this.dead) {
EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
+ // CraftBukkit start
+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
entitypigzombie.setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD));
entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
entitypigzombie.setNoAI(this.isNoAI());
@@ -157,7 +169,13 @@
@@ -157,7 +163,13 @@
entitypigzombie.setCustomNameVisible(this.getCustomNameVisible());
}
- this.world.addEntity(entitypigzombie);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitypigzombie, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+ // CraftBukkit - added a reason for spawning this creature
+ this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
+ // CraftBukkit end
this.die();
}
}