2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/animal/EntitySheep.java
|
|
|
|
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
|
2024-06-13 17:05:00 +02:00
|
|
|
@@ -63,6 +63,12 @@
|
2024-04-23 17:15:00 +02:00
|
|
|
import net.minecraft.world.level.storage.loot.LootTable;
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.storage.loot.LootTables;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2021-03-15 23:00:00 +01:00
|
|
|
+import net.minecraft.world.item.Item;
|
2020-05-02 09:48:37 +02:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.entity.SheepRegrowWoolEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
public class EntitySheep extends EntityAnimal implements IShearable {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private static final int EAT_ANIMATION_TICKS = 40;
|
2024-06-13 17:05:00 +02:00
|
|
|
@@ -250,6 +256,11 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
if (itemstack.is(Items.SHEARS)) {
|
2023-06-07 17:30:00 +02:00
|
|
|
if (!this.level().isClientSide && 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);
|
2024-04-23 17:15:00 +02:00
|
|
|
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
|
2024-06-13 17:05:00 +02:00
|
|
|
@@ -269,7 +280,9 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
int i = 1 + this.random.nextInt(3);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
for (int j = 0; j < i; ++j) {
|
|
|
|
+ this.forceDrops = true; // CraftBukkit
|
2021-11-21 23:00:00 +01:00
|
|
|
EntityItem entityitem = this.spawnAtLocation((IMaterial) EntitySheep.ITEM_BY_DYE.get(this.getColor()), 1);
|
2020-06-25 02:00:00 +02:00
|
|
|
+ this.forceDrops = false; // CraftBukkit
|
2016-03-08 07:58:52 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
if (entityitem != null) {
|
2021-11-21 23:00:00 +01:00
|
|
|
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)));
|
2024-06-13 17:05:00 +02:00
|
|
|
@@ -362,6 +375,12 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
public void ate() {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (event.isCancelled()) return;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2022-06-07 18:00:00 +02:00
|
|
|
super.ate();
|
2016-02-29 22:32:46 +01:00
|
|
|
this.setSheared(false);
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.isBaby()) {
|
2024-06-13 17:05:00 +02:00
|
|
|
@@ -381,7 +400,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
|
|
|
|
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
|
2024-06-13 17:05:00 +02:00
|
|
|
CraftingInput craftinginput = makeCraftInput(enumcolor, enumcolor1);
|
|
|
|
- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> {
|
|
|
|
+ Optional<Item> optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error
|
|
|
|
return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, this.level().registryAccess());
|
2019-04-23 04:00:00 +02:00
|
|
|
}).map(ItemStack::getItem);
|
|
|
|
|