diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cow.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cow.java.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cow.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cow.java.patch new file mode 100644 index 0000000000..1dbc9445d4 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cow.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/world/entity/animal/Cow.java ++++ b/net/minecraft/world/entity/animal/Cow.java +@@ -33,6 +33,12 @@ + import net.minecraft.world.level.block.state.BlockState; + import org.joml.Vector3f; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.player.PlayerBucketFillEvent; ++// CraftBukkit end ++ + public class Cow extends Animal { + public Cow(EntityType<? extends Cow> entityType, Level level) { + super(entityType, level); +@@ -80,12 +87,22 @@ + } + + @Override +- public InteractionResult mobInteract(Player player, InteractionHand hand) { +- ItemStack itemInHand = player.getItemInHand(hand); +- if (itemInHand.is(Items.BUCKET) && !this.isBaby()) { ++ public InteractionResult mobInteract(Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ ++ if (itemstack.is(Items.BUCKET) && !this.isBaby()) { ++ // CraftBukkit start - Got milk? ++ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level(), player, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, hand); ++ ++ if (event.isCancelled()) { ++ return InteractionResult.PASS; ++ } ++ // CraftBukkit end ++ + player.playSound(SoundEvents.COW_MILK, 1.0F, 1.0F); +- ItemStack itemStack = ItemUtils.createFilledResult(itemInHand, player, Items.MILK_BUCKET.getDefaultInstance()); +- player.setItemInHand(hand, itemStack); ++ ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, player, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit ++ ++ player.setItemInHand(hand, itemstack1); + return InteractionResult.sidedSuccess(this.level().isClientSide); + } else { + return super.mobInteract(player, hand); |