mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-25 18:37:35 +01:00
45 lines
1.9 KiB
Diff
45 lines
1.9 KiB
Diff
--- a/net/minecraft/server/EntityMushroomCow.java
|
|
+++ b/net/minecraft/server/EntityMushroomCow.java
|
|
@@ -2,6 +2,12 @@
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
|
+import org.bukkit.event.player.PlayerShearEntityEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class EntityMushroomCow extends EntityCow {
|
|
|
|
public EntityMushroomCow(World world) {
|
|
@@ -23,6 +29,14 @@
|
|
|
|
return true;
|
|
} else if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
|
|
+ // CraftBukkit start
|
|
+ PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (event.isCancelled()) {
|
|
+ return false;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
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) {
|
|
this.die();
|
|
@@ -35,7 +49,12 @@
|
|
entitycow.setCustomName(this.getCustomName());
|
|
}
|
|
|
|
- this.world.addEntity(entitycow);
|
|
+ // CraftBukkit start
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
|
|
+ return false;
|
|
+ }
|
|
+ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
|
|
+ // CraftBukkit end
|
|
|
|
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)));
|