3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00
Paper/nms-patches/EntityMushroomCow.patch

59 Zeilen
2.6 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityMushroomCow.java
+++ b/net/minecraft/server/EntityMushroomCow.java
2019-04-23 04:00:00 +02:00
@@ -2,6 +2,11 @@
2016-05-10 13:47:39 +02:00
2019-04-23 04:00:00 +02:00
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
2019-04-23 04:00:00 +02:00
public class EntityMushroomCow extends EntityCow {
2019-04-23 04:00:00 +02:00
@@ -72,9 +77,17 @@
int i;
2019-04-23 04:00:00 +02:00
if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
+ // CraftBukkit start
2019-04-23 04:00:00 +02:00
+ 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
2019-04-23 04:00:00 +02:00
this.world.addParticle(Particles.EXPLOSION, this.locX, this.locY + (double) (this.getHeight() / 2.0F), 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);
@@ -84,7 +97,14 @@
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);
+
+ this.die(); // CraftBukkit - from above
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
for (i = 0; i < 5; ++i) {
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.getHeight(), this.locZ, new ItemStack(this.dV().d.getBlock())));
2019-04-26 06:48:19 +02:00
@@ -156,7 +176,7 @@
return Pair.of(blockflowers.d(), blockflowers.e());
}
- private void a(EntityMushroomCow.Type entitymushroomcow_type) {
+ public void a(EntityMushroomCow.Type entitymushroomcow_type) { // PAIL
this.datawatcher.set(EntityMushroomCow.bz, entitymushroomcow_type.c);
}