2021-06-11 07:00:00 +02:00
--- a/net/minecraft/world/entity/animal/Bucketable.java
+++ b/net/minecraft/world/entity/animal/Bucketable.java
@@ -15,6 +15,14 @@
import net.minecraft.world.item.Items;
import net.minecraft.world.level.World;
+// CraftBukkit start
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
2022-06-07 18:00:00 +02:00
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
2021-06-11 07:00:00 +02:00
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.player.PlayerBucketEntityEvent;
+// CraftBukkit end
+
public interface Bucketable {
2021-11-21 23:00:00 +01:00
boolean fromBucket();
2021-11-24 22:00:00 +01:00
@@ -94,10 +102,22 @@
2021-11-21 23:00:00 +01:00
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
2021-06-11 07:00:00 +02:00
if (itemstack.getItem() == Items.WATER_BUCKET && t0.isAlive()) {
2021-11-21 23:00:00 +01:00
- t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F);
2021-06-11 07:00:00 +02:00
+ // CraftBukkit start
2021-11-21 23:00:00 +01:00
+ // t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); // CraftBukkit - moved down
ItemStack itemstack1 = ((Bucketable) t0).getBucketItemStack();
2021-06-11 07:00:00 +02:00
2021-11-21 23:00:00 +01:00
((Bucketable) t0).saveToBucketTag(itemstack1);
2021-06-11 07:00:00 +02:00
+
2022-10-02 00:07:14 +02:00
+ PlayerBucketEntityEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(t0, entityhuman, itemstack, itemstack1, enumhand);
2021-06-11 07:00:00 +02:00
+ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket());
+ if (playerBucketFishEvent.isCancelled()) {
2021-11-21 23:00:00 +01:00
+ ((EntityPlayer) entityhuman).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket
2022-06-07 18:00:00 +02:00
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSpawnEntity(t0)); // We need to play out these packets as the client assumes the fish is gone
2022-12-07 17:00:00 +01:00
+ t0.getEntityData().refresh((EntityPlayer) entityhuman); // Need to send data such as the display name to client
2021-06-11 07:00:00 +02:00
+ return Optional.of(EnumInteractionResult.FAIL);
+ }
2021-11-21 23:00:00 +01:00
+ t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F);
2021-06-11 07:00:00 +02:00
+ // CraftBukkit end
2021-11-21 23:00:00 +01:00
ItemStack itemstack2 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false);
2021-06-11 07:00:00 +02:00
2021-11-21 23:00:00 +01:00
entityhuman.setItemInHand(enumhand, itemstack2);