2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/animal/EntityMushroomCow.java
|
|
|
|
+++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java
|
2021-07-23 08:36:16 +02:00
|
|
|
@@ -42,6 +42,13 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
import net.minecraft.world.level.gameevent.GameEvent;
|
2019-04-23 04:00:00 +02:00
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2018-11-14 04:10:22 +01:00
|
|
|
+// CraftBukkit start
|
2021-07-23 08:36:16 +02:00
|
|
|
+import org.bukkit.Bukkit;
|
2018-11-14 04:10:22 +01:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2021-07-23 08:36:16 +02:00
|
|
|
+import org.bukkit.event.entity.EntityDropItemEvent;
|
2018-11-14 04:10:22 +01:00
|
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
public class EntityMushroomCow extends EntityCow implements IShearable {
|
2018-12-04 23:51:20 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.a(EntityMushroomCow.class, DataWatcherRegistry.STRING);
|
2021-07-23 08:36:16 +02:00
|
|
|
@@ -113,6 +120,11 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
this.playSound(soundeffect, 1.0F, 1.0F);
|
2021-06-11 07:00:00 +02:00
|
|
|
return EnumInteractionResult.a(this.level.isClientSide);
|
|
|
|
} else if (itemstack.a(Items.SHEARS) && this.canShear()) {
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
|
|
|
+ return EnumInteractionResult.PASS;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.shear(SoundCategory.PLAYERS);
|
2021-06-11 07:00:00 +02:00
|
|
|
this.a(GameEvent.SHEAR, (Entity) entityhuman);
|
|
|
|
if (!this.level.isClientSide) {
|
2021-07-23 08:36:16 +02:00
|
|
|
@@ -160,7 +172,7 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
this.level.playSound((EntityHuman) null, (Entity) this, SoundEffects.MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F);
|
|
|
|
if (!this.level.isClientSide()) {
|
|
|
|
((WorldServer) this.level).a(Particles.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
2020-06-25 02:00:00 +02:00
|
|
|
- this.die();
|
|
|
|
+ // this.die(); // CraftBukkit - moved down
|
2021-06-11 07:00:00 +02:00
|
|
|
EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.level);
|
2018-11-14 04:10:22 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot());
|
2021-07-23 08:36:16 +02:00
|
|
|
@@ -176,10 +188,25 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
entitycow.setInvulnerable(this.isInvulnerable());
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.level.addEntity(entitycow);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.level.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
|
2018-11-14 04:10:22 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
for (int i = 0; i < 5; ++i) {
|
2021-07-23 08:36:16 +02:00
|
|
|
- this.level.addEntity(new EntityItem(this.level, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().blockState.getBlock())));
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ EntityItem entityitem = new EntityItem(this.level, this.locX(), this.e(1.0D), this.locZ(), 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.addEntity(entityitem);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|