2025-03-26 03:05:00 +11:00

60 lines
3.3 KiB
Diff

--- a/net/minecraft/world/entity/animal/EntityMushroomCow.java
+++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java
@@ -49,6 +49,13 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.storage.loot.LootTables;
+// 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 EntityMushroomCow extends AbstractCow implements IShearable {
private static final DataWatcherObject<Integer> DATA_TYPE = DataWatcher.<Integer>defineId(EntityMushroomCow.class, DataWatcherRegistry.INT);
@@ -126,6 +133,11 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
this.gameEvent(GameEvent.SHEAR, entityhuman);
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
@@ -167,11 +179,19 @@
worldserver.sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_MOOSHROOM, itemstack, (worldserver1, itemstack1) -> {
for (int i = 0; i < itemstack1.getCount(); ++i) {
- worldserver1.addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1)));
+ // CraftBukkit start
+ EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1));
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ continue;
+ }
+ worldserver1.addFreshEntity(entityitem);
+ // CraftBukkit end
}
});
- });
+ }, EntityTransformEvent.TransformReason.SHEARED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); // CraftBukkit
}
@Override
@@ -190,7 +210,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
this.setVariant((EntityMushroomCow.Type) nbttagcompound.read("Type", EntityMushroomCow.Type.CODEC).orElse(EntityMushroomCow.Type.DEFAULT));
- this.stewEffects = (SuspiciousStewEffects) nbttagcompound.read("stew_effects", SuspiciousStewEffects.CODEC).orElse((Object) null);
+ this.stewEffects = (SuspiciousStewEffects) nbttagcompound.read("stew_effects", SuspiciousStewEffects.CODEC).orElse(null); // CraftBukkit - decompile error
}
private Optional<SuspiciousStewEffects> getEffectsFromItemStack(ItemStack itemstack) {