3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00
Paper/nms-patches/EntitySheep.patch

74 Zeilen
2.8 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntitySheep.java
+++ b/net/minecraft/server/EntitySheep.java
2016-05-10 13:47:39 +02:00
@@ -5,6 +5,12 @@
import java.util.Random;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// 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 {
2017-05-14 04:00:00 +02:00
private static final DataWatcherObject<Byte> bx = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
2016-05-10 13:47:39 +02:00
@@ -12,6 +18,13 @@
2017-09-18 12:00:00 +02:00
public boolean canUse(EntityHuman entityhuman) {
2015-02-26 23:41:06 +01:00
return false;
}
+
+ // CraftBukkit start
+ @Override
+ public InventoryView getBukkitView() {
+ return null; // TODO: O.O
+ }
+ // CraftBukkit end
}, 2, 1);
2017-05-14 04:00:00 +02:00
private static final Map<EnumColor, float[]> bz = Maps.newEnumMap(EnumColor.class);
private int bB;
@@ -29,6 +42,7 @@
2016-02-29 22:32:46 +01:00
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
}
2016-02-29 22:32:46 +01:00
protected void r() {
2017-05-14 04:00:00 +02:00
@@ -131,11 +145,22 @@
2016-11-17 02:41:03 +01:00
if (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);
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);
2017-05-14 04:00:00 +02:00
@@ -222,6 +247,12 @@
}
2016-06-09 03:43:49 +02:00
public void A() {
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
+
2016-02-29 22:32:46 +01:00
+ if (event.isCancelled()) return;
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
this.setSheared(false);
if (this.isBaby()) {
this.setAge(60);