Commits

Nathan (antiPerson) authored and md_5 committed 20fc5bea2c5
Add list of entities to EntityTransformEvent & move die calls
No tags

nms-patches/EntityMushroomCow.patch

Modified
6 6
7 7 +// CraftBukkit start
8 8 +import org.bukkit.craftbukkit.event.CraftEventFactory;
9 9 +import org.bukkit.event.entity.EntityTransformEvent;
10 10 +import org.bukkit.event.player.PlayerShearEntityEvent;
11 11 +// CraftBukkit end
12 12 +
13 13 public class EntityMushroomCow extends EntityCow {
14 14
15 15 public EntityMushroomCow(World world) {
16 -@@ -23,6 +29,14 @@
16 +@@ -23,9 +29,17 @@
17 17
18 18 return true;
19 19 } else if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
20 20 + // CraftBukkit start
21 21 + PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
22 22 + this.world.getServer().getPluginManager().callEvent(event);
23 23 +
24 24 + if (event.isCancelled()) {
25 25 + return false;
26 26 + }
27 27 + // CraftBukkit end
28 28 this.world.addParticle(Particles.u, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
29 29 if (!this.world.isClientSide) {
30 - this.die();
31 -@@ -35,7 +49,12 @@
30 +- this.die();
31 ++ // this.die(); // CraftBukkit - moved down
32 + EntityCow entitycow = new EntityCow(this.world);
33 +
34 + entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
35 +@@ -35,7 +49,14 @@
32 36 entitycow.setCustomName(this.getCustomName());
33 37 }
34 38
35 39 - this.world.addEntity(entitycow);
36 40 + // CraftBukkit start
37 41 + if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
38 42 + return false;
39 43 + }
40 44 + this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
45 ++
46 ++ this.die(); // CraftBukkit - from above
41 47 + // CraftBukkit end
42 48
43 49 for (int i = 0; i < 5; ++i) {
44 50 this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM)));

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut