2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntitySheep.java
|
|
|
|
+++ b/net/minecraft/server/EntitySheep.java
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -8,10 +8,16 @@
|
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;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2020-05-02 09:48:37 +02:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.entity.SheepRegrowWoolEvent;
|
2015-02-26 23:41:06 +01:00
|
|
|
+import org.bukkit.inventory.InventoryView;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
public class EntitySheep extends EntityAnimal implements IShearable {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
private static final DataWatcherObject<Byte> bv = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
|
|
|
|
- private static final Map<EnumColor, IMaterial> bw = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> {
|
|
|
|
+ private static final Map<EnumColor, IMaterial> bw = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error
|
2018-07-15 02:00:00 +02:00
|
|
|
enummap.put(EnumColor.WHITE, Blocks.WHITE_WOOL);
|
|
|
|
enummap.put(EnumColor.ORANGE, Blocks.ORANGE_WOOL);
|
|
|
|
enummap.put(EnumColor.MAGENTA, Blocks.MAGENTA_WOOL);
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -138,6 +144,11 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
if (itemstack.getItem() == Items.SHEARS) {
|
|
|
|
if (!this.world.isClientSide && this.canShear()) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
|
|
|
+ return EnumInteractionResult.PASS;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.shear(SoundCategory.PLAYERS);
|
2019-04-23 04:00:00 +02:00
|
|
|
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
2020-06-25 02:00:00 +02:00
|
|
|
entityhuman1.broadcastItemBreak(enumhand);
|
|
|
|
@@ -158,7 +169,9 @@
|
|
|
|
int i = 1 + this.random.nextInt(3);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
for (int j = 0; j < i; ++j) {
|
|
|
|
+ this.forceDrops = true; // CraftBukkit
|
|
|
|
EntityItem entityitem = this.a((IMaterial) EntitySheep.bw.get(this.getColor()), 1);
|
|
|
|
+ this.forceDrops = false; // CraftBukkit
|
2016-03-08 07:58:52 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
if (entityitem != null) {
|
|
|
|
entityitem.setMot(entityitem.getMot().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F)));
|
|
|
|
@@ -248,6 +261,12 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
|
|
|
public void blockEaten() {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // 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;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
this.setSheared(false);
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.isBaby()) {
|
|
|
|
this.setAge(60);
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -266,7 +285,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
|
|
|
|
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
|
|
|
|
InventoryCrafting inventorycrafting = a(enumcolor, enumcolor1);
|
|
|
|
- Optional optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> {
|
|
|
|
+ Optional<Item> optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> { // Eclipse fail
|
|
|
|
return recipecrafting.a(inventorycrafting);
|
|
|
|
}).map(ItemStack::getItem);
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -284,10 +303,18 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
public boolean canUse(EntityHuman entityhuman) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ @Override
|
|
|
|
+ public InventoryView getBukkitView() {
|
|
|
|
+ return null; // TODO: O.O
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}, 2, 1);
|
|
|
|
|
|
|
|
inventorycrafting.setItem(0, new ItemStack(ItemDye.a(enumcolor)));
|
|
|
|
inventorycrafting.setItem(1, new ItemStack(ItemDye.a(enumcolor1)));
|
|
|
|
+ inventorycrafting.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
|
|
|
|
return inventorycrafting;
|
|
|
|
}
|
2018-07-15 02:00:00 +02:00
|
|
|
|