1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
--- 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<Item> 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;
}
|