aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/animal/MushroomCow.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/animal/MushroomCow.java.patch')
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/animal/MushroomCow.java.patch73
1 files changed, 73 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/animal/MushroomCow.java.patch
new file mode 100644
index 0000000000..25a849b38f
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/animal/MushroomCow.java.patch
@@ -0,0 +1,73 @@
+--- a/net/minecraft/world/entity/animal/MushroomCow.java
++++ b/net/minecraft/world/entity/animal/MushroomCow.java
+@@ -42,6 +42,13 @@
+ import net.minecraft.world.level.block.state.BlockState;
+ import net.minecraft.world.level.gameevent.GameEvent;
+
++// CraftBukkit start
++import org.bukkit.Bukkit;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.event.entity.EntityDropItemEvent;
++import org.bukkit.event.entity.EntityTransformEvent;
++// CraftBukkit end
++
+ public class MushroomCow extends Cow implements Shearable, VariantHolder<MushroomCow.MushroomType> {
+
+ private static final EntityDataAccessor<String> DATA_TYPE = SynchedEntityData.defineId(MushroomCow.class, EntityDataSerializers.STRING);
+@@ -118,6 +121,11 @@
+ this.playSound(soundevent, 1.0F, 1.0F);
+ return InteractionResult.sidedSuccess(this.level().isClientSide);
+ } else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
++ // CraftBukkit start
++ if (!CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand)) {
++ return InteractionResult.PASS;
++ }
++ // CraftBukkit end
+ this.shear(SoundSource.PLAYERS);
+ this.gameEvent(GameEvent.SHEAR, player);
+ if (!this.level().isClientSide) {
+@@ -166,10 +173,10 @@
+
+ if (cow != null) {
+ ((ServerLevel) this.level()).sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
+- this.discard();
+- cow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+- cow.setHealth(this.getHealth());
+- cow.yBodyRot = this.yBodyRot;
++ // this.discard(); // CraftBukkit - moved down
++ entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
++ entitycow.setHealth(this.getHealth());
++ entitycow.yBodyRot = this.yBodyRot;
+ if (this.hasCustomName()) {
+ cow.setCustomName(this.getCustomName());
+ cow.setCustomNameVisible(this.isCustomNameVisible());
+@@ -179,11 +186,26 @@
+ cow.setPersistenceRequired();
+ }
+
+- cow.setInvulnerable(this.isInvulnerable());
+- this.level().addFreshEntity(cow);
++ entitycow.setInvulnerable(this.isInvulnerable());
++ // CraftBukkit start
++ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
++ return;
++ }
++ this.level().addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
+
++ this.discard(); // CraftBukkit - from above
++ // CraftBukkit end
++
+ for (int i = 0; i < 5; ++i) {
+- this.level().addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock())));
++ // CraftBukkit start
++ ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock()));
++ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
++ Bukkit.getPluginManager().callEvent(event);
++ if (event.isCancelled()) {
++ continue;
++ }
++ this.level().addFreshEntity(entityitem);
++ // CraftBukkit end
+ }
+ }
+ }