Paper/nms-patches/EntitySheep.patch
2016-03-01 09:32:45 +11:00

67 lines
2.4 KiB
Diff

--- a/net/minecraft/server/EntitySheep.java
+++ b/net/minecraft/server/EntitySheep.java
@@ -4,6 +4,12 @@
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 static final DataWatcherObject<Byte> bv = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
@@ -11,6 +17,13 @@
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[]> bx = Maps.newEnumMap(EnumColor.class);
private int bz;
@@ -25,6 +38,7 @@
this.setSize(0.9F, 1.3F);
this.container.setItem(0, new ItemStack(Items.DYE));
this.container.setItem(1, new ItemStack(Items.DYE));
+ this.container.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
}
protected void r() {
@@ -123,6 +137,15 @@
public boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
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);
@@ -210,6 +233,12 @@
}
public void B() {
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) return;
+ // CraftBukkit end
this.setSheared(false);
if (this.isBaby()) {
this.setAge(60);