SPIGOT-4339: Add EntityTransformEvent
Thanks klugemonkey for some contributions in https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/351/overview By: nathat890 <nathat890@outlook.com>
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
--- a/net/minecraft/server/EntityMushroomCow.java
|
||||
+++ b/net/minecraft/server/EntityMushroomCow.java
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.minecraft.server;
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
+import org.bukkit.event.player.PlayerShearEntityEvent; // CraftBukkit
|
||||
|
||||
+// 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 {
|
||||
|
||||
@@ -23,6 +24,14 @@
|
||||
public EntityMushroomCow(World world) {
|
||||
@@ -23,6 +29,14 @@
|
||||
|
||||
return true;
|
||||
} else if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
|
||||
@@ -23,3 +28,15 @@
|
||||
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,6 +49,11 @@
|
||||
entitycow.setCustomName(this.getCustomName());
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.world.addEntity(entitycow);
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user