2024-10-23 02:15:00 +11:00

60 lines
3.1 KiB
Diff

--- a/net/minecraft/world/entity/animal/EntitySheep.java
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
@@ -57,6 +57,12 @@
import net.minecraft.world.level.gameevent.GameEvent;
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;
@@ -167,6 +173,11 @@
WorldServer worldserver = (WorldServer) world;
if (this.readyForShearing()) {
+ // 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));
@@ -185,7 +196,9 @@
worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SHEEP_SHEAR, soundcategory, 1.0F, 1.0F);
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SHEEP, itemstack, (worldserver1, itemstack1) -> {
for (int i = 0; i < itemstack1.getCount(); ++i) {
+ this.forceDrops = true; // CraftBukkit
EntityItem entityitem = this.spawnAtLocation(worldserver1, itemstack1.copyWithCount(1), 1.0F);
+ 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)));
@@ -280,6 +293,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()) {
@@ -299,7 +318,7 @@
EnumColor enumcolor = entitysheep.getColor();
EnumColor enumcolor1 = entitysheep1.getColor();
CraftingInput craftinginput = makeCraftInput(enumcolor, enumcolor1);
- Optional optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> {
+ Optional<Item> optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> { // CraftBukkit - decompile error
return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, worldserver.registryAccess());
}).map(ItemStack::getItem);