Add some missing CreatureSpawnEvent.SpawnReason calls

This commit is contained in:
md_5 2018-11-14 14:17:25 +11:00
parent d2c422f13e
commit c2035aa1d0
3 changed files with 14 additions and 5 deletions

View file

@ -28,15 +28,17 @@
this.world.addParticle(Particles.u, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D); this.world.addParticle(Particles.u, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
if (!this.world.isClientSide) { if (!this.world.isClientSide) {
this.die(); this.die();
@@ -35,6 +49,11 @@ @@ -35,7 +49,12 @@
entitycow.setCustomName(this.getCustomName()); entitycow.setCustomName(this.getCustomName());
} }
- this.world.addEntity(entitycow);
+ // CraftBukkit start + // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { + if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
+ return false; + return false;
+ } + }
+ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
+ // CraftBukkit end + // CraftBukkit end
this.world.addEntity(entitycow);
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM)));

View file

@ -73,15 +73,17 @@
} }
} }
@@ -574,6 +604,11 @@ @@ -574,7 +604,12 @@
entitywitch.setCustomNameVisible(this.getCustomNameVisible()); entitywitch.setCustomNameVisible(this.getCustomNameVisible());
} }
- this.world.addEntity(entitywitch);
+ // CraftBukkit start + // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { + if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
+ return; + return;
+ } + }
+ this.world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
+ // CraftBukkit end + // CraftBukkit end
this.world.addEntity(entitywitch);
this.die(); this.die();
} }
}

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/Village.java --- a/net/minecraft/server/Village.java
+++ b/net/minecraft/server/Village.java +++ b/net/minecraft/server/Village.java
@@ -73,7 +73,7 @@ @@ -73,11 +73,11 @@
BlockPosition blockposition1 = blockposition.a(this.a.random.nextInt(16) - 8, this.a.random.nextInt(6) - 3, this.a.random.nextInt(16) - 8); BlockPosition blockposition1 = blockposition.a(this.a.random.nextInt(16) - 8, this.a.random.nextInt(6) - 3, this.a.random.nextInt(16) - 8);
if (this.a(blockposition1)) { if (this.a(blockposition1)) {
@ -9,3 +9,8 @@
if (entityirongolem != null) { if (entityirongolem != null) {
if (entityirongolem.a((GeneratorAccess) this.a, false) && entityirongolem.a((IWorldReader) this.a)) { if (entityirongolem.a((GeneratorAccess) this.a, false) && entityirongolem.a((IWorldReader) this.a)) {
- this.a.addEntity(entityirongolem);
+ this.a.addEntity(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit
return entityirongolem;
}