craftbukkit/nms-patches/net/minecraft/world/entity/animal/EntitySheep.patch

81 lines
3.7 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/animal/EntitySheep.java
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
2023-09-22 02:40:00 +10:00
@@ -66,6 +66,14 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.level.storage.loot.LootTables;
2023-09-22 02:40:00 +10:00
import org.joml.Vector3f;
+// CraftBukkit start
2021-03-16 09:00:00 +11:00
+import net.minecraft.world.inventory.InventoryCraftResult;
+import net.minecraft.world.item.Item;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.SheepRegrowWoolEvent;
2015-02-26 22:41:06 +00:00
+import org.bukkit.inventory.InventoryView;
+// CraftBukkit end
+
2020-06-25 10:00:00 +10:00
public class EntitySheep extends EntityAnimal implements IShearable {
2021-06-11 15:00:00 +10:00
private static final int EAT_ANIMATION_TICKS = 40;
2023-09-22 02:40:00 +10:00
@@ -246,6 +254,11 @@
2016-11-17 12:41:03 +11:00
2021-11-22 09:00:00 +11:00
if (itemstack.is(Items.SHEARS)) {
2023-06-08 01:30:00 +10:00
if (!this.level().isClientSide && this.readyForShearing()) {
2020-06-25 10:00:00 +10:00
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
2022-06-08 02:00:00 +10:00
this.gameEvent(GameEvent.SHEAR, entityhuman);
2021-11-22 09:00:00 +11:00
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
2023-09-22 02:40:00 +10:00
@@ -267,7 +280,9 @@
2020-06-25 10:00:00 +10:00
int i = 1 + this.random.nextInt(3);
2020-06-25 10:00:00 +10:00
for (int j = 0; j < i; ++j) {
+ this.forceDrops = true; // CraftBukkit
2021-11-22 09:00:00 +11:00
EntityItem entityitem = this.spawnAtLocation((IMaterial) EntitySheep.ITEM_BY_DYE.get(this.getColor()), 1);
2020-06-25 10:00:00 +10:00
+ this.forceDrops = false; // CraftBukkit
2020-06-25 10:00:00 +10:00
if (entityitem != null) {
2021-11-22 09:00:00 +11:00
entityitem.setDeltaMovement(entityitem.getDeltaMovement().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)));
2023-09-22 02:40:00 +10:00
@@ -360,6 +375,12 @@
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public void ate() {
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
2023-06-08 01:30:00 +10:00
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
2016-03-01 08:32:46 +11:00
+ if (event.isCancelled()) return;
+ // CraftBukkit end
2022-06-08 02:00:00 +10:00
super.ate();
2016-03-01 08:32:46 +11:00
this.setSheared(false);
if (this.isBaby()) {
2023-09-22 02:40:00 +10:00
@@ -379,7 +400,7 @@
2019-04-23 12:00:00 +10:00
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
2021-11-22 09:00:00 +11:00
InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1);
2023-09-22 02:40:00 +10:00
- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> {
+ Optional<Item> optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error
return ((RecipeCrafting) recipeholder.value()).assemble(inventorycrafting, this.level().registryAccess());
2019-04-23 12:00:00 +10:00
}).map(ItemStack::getItem);
2023-09-22 02:40:00 +10:00
@@ -402,10 +423,18 @@
2021-11-22 09:00:00 +11:00
public boolean stillValid(EntityHuman entityhuman) {
2019-04-23 12:00:00 +10:00
return false;
}
+
+ // CraftBukkit start
+ @Override
+ public InventoryView getBukkitView() {
+ return null; // TODO: O.O
+ }
+ // CraftBukkit end
}, 2, 1);
2023-06-08 01:30:00 +10:00
transientcraftingcontainer.setItem(0, new ItemStack(ItemDye.byColor(enumcolor)));
transientcraftingcontainer.setItem(1, new ItemStack(ItemDye.byColor(enumcolor1)));
+ transientcraftingcontainer.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
return transientcraftingcontainer;
2019-04-23 12:00:00 +10:00
}
2018-07-15 10:00:00 +10:00