--- a/net/minecraft/world/entity/animal/EntitySheep.java +++ b/net/minecraft/world/entity/animal/EntitySheep.java @@ -63,6 +63,12 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.LootTables; +// CraftBukkit start +import net.minecraft.world.item.Item; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.SheepRegrowWoolEvent; +// CraftBukkit end + public class EntitySheep extends EntityAnimal implements IShearable { private static final int EAT_ANIMATION_TICKS = 40; @@ -250,6 +256,11 @@ if (itemstack.is(Items.SHEARS)) { if (!this.level().isClientSide && this.readyForShearing()) { + // CraftBukkit start + if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { + return EnumInteractionResult.PASS; + } + // CraftBukkit end this.shear(SoundCategory.PLAYERS); this.gameEvent(GameEvent.SHEAR, entityhuman); itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand)); @@ -269,7 +280,9 @@ int i = 1 + this.random.nextInt(3); for (int j = 0; j < i; ++j) { + this.forceDrops = true; // CraftBukkit EntityItem entityitem = this.spawnAtLocation((IMaterial) EntitySheep.ITEM_BY_DYE.get(this.getColor()), 1); + this.forceDrops = false; // CraftBukkit if (entityitem != null) { entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); @@ -362,6 +375,12 @@ @Override public void ate() { + // CraftBukkit start + SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity()); + this.level().getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) return; + // CraftBukkit end super.ate(); this.setSheared(false); if (this.isBaby()) { @@ -381,7 +400,7 @@ EnumColor enumcolor = ((EntitySheep) entityanimal).getColor(); EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor(); CraftingInput craftinginput = makeCraftInput(enumcolor, enumcolor1); - Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> { + Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, this.level().registryAccess()); }).map(ItemStack::getItem);