diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Bucketable.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Bucketable.java.patch | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Bucketable.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Bucketable.java.patch new file mode 100644 index 0000000000..407c4e5da4 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Bucketable.java.patch @@ -0,0 +1,155 @@ +--- a/net/minecraft/world/entity/animal/Bucketable.java ++++ b/net/minecraft/world/entity/animal/Bucketable.java +@@ -3,9 +3,10 @@ + import java.util.Optional; + import net.minecraft.advancements.CriteriaTriggers; + import net.minecraft.nbt.CompoundTag; ++import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; + import net.minecraft.server.level.ServerPlayer; + import net.minecraft.sounds.SoundEvent; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.Mob; +@@ -14,6 +15,10 @@ + import net.minecraft.world.item.ItemUtils; + import net.minecraft.world.item.Items; + import net.minecraft.world.level.Level; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.player.PlayerBucketEntityEvent; ++// CraftBukkit end + + public interface Bucketable { + +@@ -31,84 +36,96 @@ + + /** @deprecated */ + @Deprecated +- static void saveDefaultDataToBucketTag(Mob mob, ItemStack itemstack) { +- CompoundTag compoundtag = itemstack.getOrCreateTag(); ++ static void saveDefaultDataToBucketTag(Mob mob, ItemStack bucket) { ++ CompoundTag nbttagcompound = bucket.getOrCreateTag(); + + if (mob.hasCustomName()) { +- itemstack.setHoverName(mob.getCustomName()); ++ bucket.setHoverName(mob.getCustomName()); + } + + if (mob.isNoAi()) { +- compoundtag.putBoolean("NoAI", mob.isNoAi()); ++ nbttagcompound.putBoolean("NoAI", mob.isNoAi()); + } + + if (mob.isSilent()) { +- compoundtag.putBoolean("Silent", mob.isSilent()); ++ nbttagcompound.putBoolean("Silent", mob.isSilent()); + } + + if (mob.isNoGravity()) { +- compoundtag.putBoolean("NoGravity", mob.isNoGravity()); ++ nbttagcompound.putBoolean("NoGravity", mob.isNoGravity()); + } + + if (mob.hasGlowingTag()) { +- compoundtag.putBoolean("Glowing", mob.hasGlowingTag()); ++ nbttagcompound.putBoolean("Glowing", mob.hasGlowingTag()); + } + + if (mob.isInvulnerable()) { +- compoundtag.putBoolean("Invulnerable", mob.isInvulnerable()); ++ nbttagcompound.putBoolean("Invulnerable", mob.isInvulnerable()); + } + +- compoundtag.putFloat("Health", mob.getHealth()); ++ nbttagcompound.putFloat("Health", mob.getHealth()); + } + + /** @deprecated */ + @Deprecated +- static void loadDefaultDataFromBucketTag(Mob mob, CompoundTag compoundtag) { +- if (compoundtag.contains("NoAI")) { +- mob.setNoAi(compoundtag.getBoolean("NoAI")); ++ static void loadDefaultDataFromBucketTag(Mob mob, CompoundTag tag) { ++ if (tag.contains("NoAI")) { ++ mob.setNoAi(tag.getBoolean("NoAI")); + } + +- if (compoundtag.contains("Silent")) { +- mob.setSilent(compoundtag.getBoolean("Silent")); ++ if (tag.contains("Silent")) { ++ mob.setSilent(tag.getBoolean("Silent")); + } + +- if (compoundtag.contains("NoGravity")) { +- mob.setNoGravity(compoundtag.getBoolean("NoGravity")); ++ if (tag.contains("NoGravity")) { ++ mob.setNoGravity(tag.getBoolean("NoGravity")); + } + +- if (compoundtag.contains("Glowing")) { +- mob.setGlowingTag(compoundtag.getBoolean("Glowing")); ++ if (tag.contains("Glowing")) { ++ mob.setGlowingTag(tag.getBoolean("Glowing")); + } + +- if (compoundtag.contains("Invulnerable")) { +- mob.setInvulnerable(compoundtag.getBoolean("Invulnerable")); ++ if (tag.contains("Invulnerable")) { ++ mob.setInvulnerable(tag.getBoolean("Invulnerable")); + } + +- if (compoundtag.contains("Health", 99)) { +- mob.setHealth(compoundtag.getFloat("Health")); ++ if (tag.contains("Health", 99)) { ++ mob.setHealth(tag.getFloat("Health")); + } + + } + +- static <T extends LivingEntity & Bucketable> Optional<InteractionResult> bucketMobPickup(Player player, InteractionHand interactionhand, T t0) { +- ItemStack itemstack = player.getItemInHand(interactionhand); ++ static <T extends LivingEntity & Bucketable> Optional<InteractionResult> bucketMobPickup(Player player, EnumHand hand, T entity) { ++ ItemStack itemstack = player.getItemInHand(hand); + +- if (itemstack.getItem() == Items.WATER_BUCKET && t0.isAlive()) { +- t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); +- ItemStack itemstack1 = ((Bucketable) t0).getBucketItemStack(); ++ if (itemstack.getItem() == Items.WATER_BUCKET && entity.isAlive()) { ++ // CraftBukkit start ++ // t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); // CraftBukkit - moved down ++ ItemStack itemstack1 = ((Bucketable) entity).getBucketItemStack(); + +- ((Bucketable) t0).saveToBucketTag(itemstack1); ++ ((Bucketable) entity).saveToBucketTag(itemstack1); ++ ++ PlayerBucketEntityEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(entity, player, itemstack, itemstack1, hand); ++ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket()); ++ if (playerBucketFishEvent.isCancelled()) { ++ ((ServerPlayer) player).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket ++ ((ServerPlayer) player).connection.send(new ClientboundAddEntityPacket(entity)); // We need to play out these packets as the client assumes the fish is gone ++ entity.getEntityData().refresh((ServerPlayer) player); // Need to send data such as the display name to client ++ return Optional.of(InteractionResult.FAIL); ++ } ++ entity.playSound(((Bucketable) entity).getPickupSound(), 1.0F, 1.0F); ++ // CraftBukkit end + ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, player, itemstack1, false); + +- player.setItemInHand(interactionhand, itemstack2); +- Level level = t0.level(); ++ player.setItemInHand(hand, itemstack2); ++ Level world = entity.level(); + +- if (!level.isClientSide) { ++ if (!world.isClientSide) { + CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer) player, itemstack1); + } + +- t0.discard(); +- return Optional.of(InteractionResult.sidedSuccess(level.isClientSide)); ++ entity.discard(); ++ return Optional.of(InteractionResult.sidedSuccess(world.isClientSide)); + } else { + return Optional.empty(); + } |