3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 14:50:08 +01:00
Paper/nms-patches/EntitySheep.patch

69 Zeilen
2.4 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntitySheep.java
+++ b/net/minecraft/server/EntitySheep.java
2015-02-26 23:41:06 +01:00
@@ -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;
2015-02-26 23:41:06 +01:00
+import org.bukkit.inventory.InventoryView;
+// CraftBukkit end
+
public class EntitySheep extends EntityAnimal {
2015-02-26 23:41:06 +01:00
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));
2015-02-26 23:41:06 +01:00
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() {
2015-02-26 23:41:06 +01:00
@@ -86,6 +100,15 @@
if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
2015-02-26 23:41:06 +01:00
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
2015-02-26 23:41:06 +01:00
+
this.setSheared(true);
int i = 1 + this.random.nextInt(3);
2015-02-26 23:41:06 +01:00
@@ -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);
}