--- a/net/minecraft/world/entity/animal/EntitySheep.java +++ b/net/minecraft/world/entity/animal/EntitySheep.java @@ -66,6 +66,14 @@ import net.minecraft.world.level.storage.loot.LootTables; import org.joml.Vector3f; +// CraftBukkit start +import net.minecraft.world.inventory.InventoryCraftResult; +import net.minecraft.world.item.Item; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.SheepRegrowWoolEvent; +import org.bukkit.inventory.InventoryView; +// CraftBukkit end + public class EntitySheep extends EntityAnimal implements IShearable { private static final int EAT_ANIMATION_TICKS = 40; @@ -246,6 +254,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, (entityhuman1) -> { @@ -267,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))); @@ -360,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()) { @@ -379,7 +400,7 @@ EnumColor enumcolor = ((EntitySheep) entityanimal).getColor(); EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor(); InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1); - Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> { + Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error return ((RecipeCrafting) recipeholder.value()).assemble(inventorycrafting, this.level().registryAccess()); }).map(ItemStack::getItem); @@ -402,10 +423,18 @@ public boolean stillValid(EntityHuman entityhuman) { return false; } + + // CraftBukkit start + @Override + public InventoryView getBukkitView() { + return null; // TODO: O.O + } + // CraftBukkit end }, 2, 1); transientcraftingcontainer.setItem(0, new ItemStack(ItemDye.byColor(enumcolor))); transientcraftingcontainer.setItem(1, new ItemStack(ItemDye.byColor(enumcolor1))); + transientcraftingcontainer.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event return transientcraftingcontainer; }