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

51 Zeilen
2.3 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityMushroomCow.java
+++ b/net/minecraft/server/EntityMushroomCow.java
2020-06-25 02:00:00 +02:00
@@ -4,6 +4,10 @@
2019-06-21 12:00:00 +02:00
import java.util.Random;
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;
+// CraftBukkit end
2020-06-25 02:00:00 +02:00
public class EntityMushroomCow extends EntityCow implements IShearable {
2020-06-25 02:00:00 +02:00
@@ -75,6 +79,11 @@
this.playSound(soundeffect, 1.0F, 1.0F);
return EnumInteractionResult.a(this.world.isClientSide);
} else if (itemstack.getItem() == Items.SHEARS && this.canShear()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
if (!this.world.isClientSide) {
itemstack.damage(1, entityhuman, (entityhuman1) -> {
@@ -121,7 +130,7 @@
this.world.playSound((EntityHuman) null, (Entity) this, SoundEffects.ENTITY_MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F);
if (!this.world.s_()) {
((WorldServer) this.world).a(Particles.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
- this.die();
+ // this.die(); // CraftBukkit - moved down
EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.world);
2020-06-25 02:00:00 +02:00
entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch);
@@ -137,7 +146,14 @@
}
2019-04-23 04:00:00 +02:00
2020-06-25 02:00:00 +02:00
entitycow.setInvulnerable(this.isInvulnerable());
- this.world.addEntity(entitycow);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
+ return;
+ }
+ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
2019-04-23 04:00:00 +02:00
+
2020-06-25 02:00:00 +02:00
+ this.die(); // CraftBukkit - from above
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
for (int 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())));