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
|
--- /home/matt/mc-dev-private//net/minecraft/server/EntitySheep.java 2015-02-26 22:40:22.675608138 +0000
+++ src/main/java/net/minecraft/server/EntitySheep.java 2015-02-26 22:40:22.679608138 +0000
@@ -4,12 +4,25 @@
import java.util.Map;
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.event.entity.SheepRegrowWoolEvent;
+import org.bukkit.event.player.PlayerShearEntityEvent;
+import org.bukkit.inventory.InventoryView;
+// CraftBukkit end
+
public class EntitySheep extends EntityAnimal {
private final InventoryCrafting bm = new InventoryCrafting(new Container() {
public boolean a(EntityHuman entityhuman) {
return false;
}
+
+ // CraftBukkit start
+ @Override
+ public InventoryView getBukkitView() {
+ return null; // TODO: O.O
+ }
+ // CraftBukkit end
}, 2, 1);
private static final Map<EnumColor, float[]> bo = Maps.newEnumMap(EnumColor.class);
private int bp;
@@ -34,6 +47,7 @@
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
this.bm.setItem(0, new ItemStack(Items.DYE, 1, 0));
this.bm.setItem(1, new ItemStack(Items.DYE, 1, 0));
+ this.bm.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
}
protected void E() {
@@ -86,6 +100,15 @@
if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
if (!this.world.isClientSide) {
+ // CraftBukkit start
+ PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
+
this.setSheared(true);
int i = 1 + this.random.nextInt(3);
@@ -173,7 +196,14 @@
}
public void v() {
- this.setSheared(false);
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.setSheared(false);
+ }
+ // CraftBukkit end
if (this.isBaby()) {
this.setAge(60);
}
|