2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/animal/EntityMushroomCow.java
|
|
|
|
+++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -43,6 +43,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-11-21 23:00:00 +01:00
|
|
|
private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING);
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -116,6 +123,11 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
this.playSound(soundeffect, 1.0F, 1.0F);
|
2021-11-21 23:00:00 +01:00
|
|
|
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
|
|
|
|
} else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
|
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);
|
2022-06-07 18:00:00 +02:00
|
|
|
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
2021-06-11 07:00:00 +02:00
|
|
|
if (!this.level.isClientSide) {
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -163,7 +175,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()) {
|
2021-11-21 23:00:00 +01:00
|
|
|
((WorldServer) this.level).sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
|
|
|
- this.discard();
|
|
|
|
+ // this.discard(); // CraftBukkit - moved down
|
|
|
|
EntityCow entitycow = (EntityCow) EntityTypes.COW.create(this.level);
|
2018-11-14 04:10:22 +01:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -179,10 +191,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-11-21 23:00:00 +01:00
|
|
|
- this.level.addFreshEntity(entitycow);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2021-11-21 23:00:00 +01:00
|
|
|
+ this.level.addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
|
2019-04-23 04:00:00 +02:00
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
+ this.discard(); // CraftBukkit - from above
|
2020-06-25 02:00:00 +02:00
|
|
|
+ // 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-11-21 23:00:00 +01:00
|
|
|
- this.level.addFreshEntity(new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getMushroomType().blockState.getBlock())));
|
2021-07-23 08:36:16 +02:00
|
|
|
+ // CraftBukkit start
|
2021-11-21 23:00:00 +01:00
|
|
|
+ EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getMushroomType().blockState.getBlock()));
|
2021-07-23 08:36:16 +02:00
|
|
|
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
|
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
2021-11-21 23:00:00 +01:00
|
|
|
+ this.level.addFreshEntity(entityitem);
|
2021-07-23 08:36:16 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|