2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/animal/EntitySheep.java
|
|
|
|
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -63,6 +63,14 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
import net.minecraft.world.level.gameevent.GameEvent;
|
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.inventory.InventoryCraftResult;
|
|
|
|
+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;
|
2015-02-26 23:41:06 +01:00
|
|
|
+import org.bukkit.inventory.InventoryView;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// 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;
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -243,6 +251,11 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
if (itemstack.is(Items.SHEARS)) {
|
|
|
|
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);
|
2021-11-21 23:00:00 +01:00
|
|
|
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -264,7 +277,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)));
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -357,6 +372,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());
|
2021-06-11 13:33:49 +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()) {
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -376,7 +397,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
|
|
|
|
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
|
2021-11-21 23:00:00 +01:00
|
|
|
InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1);
|
|
|
|
- Optional optional = this.level.getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> {
|
|
|
|
+ Optional<Item> optional = this.level.getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // CraftBukkit - decompile error
|
2023-03-14 17:30:00 +01:00
|
|
|
return recipecrafting.assemble(inventorycrafting, this.level.registryAccess());
|
2019-04-23 04:00:00 +02:00
|
|
|
}).map(ItemStack::getItem);
|
|
|
|
|
2022-12-07 17:00:00 +01:00
|
|
|
@@ -399,10 +420,18 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
public boolean stillValid(EntityHuman entityhuman) {
|
2019-04-23 04:00:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ @Override
|
|
|
|
+ public InventoryView getBukkitView() {
|
|
|
|
+ return null; // TODO: O.O
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}, 2, 1);
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
inventorycrafting.setItem(0, new ItemStack(ItemDye.byColor(enumcolor)));
|
|
|
|
inventorycrafting.setItem(1, new ItemStack(ItemDye.byColor(enumcolor1)));
|
2019-04-23 04:00:00 +02:00
|
|
|
+ inventorycrafting.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
|
|
|
|
return inventorycrafting;
|
|
|
|
}
|
2018-07-15 02:00:00 +02:00
|
|
|
|