mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-10 20:59:54 +01:00
50 lines
2.3 KiB
Diff
50 lines
2.3 KiB
Diff
--- a/net/minecraft/server/EntityMushroomCow.java
|
|
+++ b/net/minecraft/server/EntityMushroomCow.java
|
|
@@ -3,6 +3,11 @@
|
|
import java.util.Random;
|
|
import java.util.UUID;
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
+// 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 {
|
|
|
|
@@ -81,9 +86,17 @@
|
|
int i;
|
|
|
|
if (itemstack.getItem() == Items.SHEARS && !this.isBaby()) {
|
|
+ // 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.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 0.0D, 0.0D, 0.0D);
|
|
if (!this.world.isClientSide) {
|
|
- this.die();
|
|
+ // this.die(); // CraftBukkit - moved down
|
|
EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.world);
|
|
|
|
entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch);
|
|
@@ -99,7 +112,14 @@
|
|
}
|
|
|
|
entitycow.setInvulnerable(this.isInvulnerable());
|
|
- 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);
|
|
+
|
|
+ this.die(); // CraftBukkit - from above
|
|
+ // CraftBukkit end
|
|
|
|
for (i = 0; i < 5; ++i) {
|
|
this.world.addEntity(new EntityItem(this.world, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().d.getBlock())));
|