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

77 Zeilen
3.2 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntitySheep.java
+++ b/net/minecraft/server/EntitySheep.java
2018-12-25 22:00:00 +01:00
@@ -8,6 +8,12 @@
2018-07-15 02:00:00 +02:00
import java.util.stream.Collectors;
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 {
2018-07-15 02:00:00 +02:00
private static final DataWatcherObject<Byte> bC = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
2018-12-25 22:00:00 +01:00
@@ -15,8 +21,15 @@
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);
2018-07-15 02:00:00 +02:00
- private static final Map<EnumColor, IMaterial> bE = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> {
+ private static final Map<EnumColor, IMaterial> bE = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error
enummap.put(EnumColor.WHITE, Blocks.WHITE_WOOL);
enummap.put(EnumColor.ORANGE, Blocks.ORANGE_WOOL);
enummap.put(EnumColor.MAGENTA, Blocks.MAGENTA_WOOL);
2018-12-25 22:00:00 +01:00
@@ -141,11 +154,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
2018-07-15 02:00:00 +02:00
EntityItem entityitem = this.a((IMaterial) EntitySheep.bE.get(this.getColor()), 1);
+ this.forceDrops = false; // CraftBukkit
2018-07-15 02:00:00 +02:00
if (entityitem != null) {
entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
2018-12-25 22:00:00 +01:00
@@ -230,6 +254,12 @@
}
2018-07-15 02:00:00 +02:00
public void x() {
+ // 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);
2018-12-25 22:00:00 +01:00
@@ -250,6 +280,7 @@
2018-07-15 02:00:00 +02:00
this.container.setItem(0, new ItemStack(ItemDye.a(enumcolor)));
this.container.setItem(1, new ItemStack(ItemDye.a(enumcolor1)));
+ this.container.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
2018-12-13 01:00:00 +01:00
ItemStack itemstack = entityanimal.world.getCraftingManager().craft(this.container, ((EntitySheep) entityanimal).world);
2018-07-15 02:00:00 +02:00
Item item = itemstack.getItem();
EnumColor enumcolor2;