Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-21 05:50:05 +01:00
74 Zeilen
2.9 KiB
Diff
74 Zeilen
2.9 KiB
Diff
--- a/net/minecraft/server/EntitySheep.java
|
|
+++ b/net/minecraft/server/EntitySheep.java
|
|
@@ -5,6 +5,12 @@
|
|
import java.util.Random;
|
|
import javax.annotation.Nullable;
|
|
|
|
+// 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> bx = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
|
|
@@ -12,6 +18,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[]> bz = Maps.newEnumMap(EnumColor.class);
|
|
private int bB;
|
|
@@ -26,6 +39,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() {
|
|
@@ -126,11 +140,22 @@
|
|
public boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable 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);
|
|
|
|
for (int j = 0; j < i; ++j) {
|
|
+ this.forceDrops = true; // CraftBukkit
|
|
EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor().getColorIndex()), 1.0F);
|
|
+ this.forceDrops = false; // CraftBukkit
|
|
|
|
entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
|
|
entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
|
|
@@ -217,6 +242,12 @@
|
|
}
|
|
|
|
public void A() {
|
|
+ // 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);
|