Paper/paper-server/nms-patches/net/minecraft/world/entity/animal/EntityCow.patch
CraftBukkit/Spigot b3a8254758 Update to Minecraft 1.17
By: md_5 <git@md-5.net>
2021-06-11 15:00:00 +10:00

33 lines
1.5 KiB
Diff

--- a/net/minecraft/world/entity/animal/EntityCow.java
+++ b/net/minecraft/world/entity/animal/EntityCow.java
@@ -30,6 +30,11 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+// CraftBukkit end
+
public class EntityCow extends EntityAnimal {
public EntityCow(EntityTypes<? extends EntityCow> entitytypes, World world) {
@@ -82,8 +87,16 @@
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.a(Items.BUCKET) && !this.isBaby()) {
+ // CraftBukkit start - Got milk?
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET);
+
+ if (event.isCancelled()) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
+
entityhuman.playSound(SoundEffects.COW_MILK, 1.0F, 1.0F);
- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, Items.MILK_BUCKET.createItemStack());
+ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
entityhuman.a(enumhand, itemstack1);
return EnumInteractionResult.a(this.level.isClientSide);