diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Bucketable.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Bucketable.java.patch | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Bucketable.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Bucketable.java.patch new file mode 100644 index 0000000000..45d0710924 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Bucketable.java.patch @@ -0,0 +1,128 @@ +--- 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,8 +15,13 @@ + 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 { ++ + boolean fromBucket(); + + void setFromBucket(boolean fromBucket); +@@ -28,36 +34,39 @@ + + SoundEvent getPickupSound(); + ++ /** @deprecated */ + @Deprecated + static void saveDefaultDataToBucketTag(Mob mob, ItemStack bucket) { +- CompoundTag tag = bucket.getOrCreateTag(); ++ CompoundTag nbttagcompound = bucket.getOrCreateTag(); ++ + if (mob.hasCustomName()) { + bucket.setHoverName(mob.getCustomName()); + } + + if (mob.isNoAi()) { +- tag.putBoolean("NoAI", mob.isNoAi()); ++ nbttagcompound.putBoolean("NoAI", mob.isNoAi()); + } + + if (mob.isSilent()) { +- tag.putBoolean("Silent", mob.isSilent()); ++ nbttagcompound.putBoolean("Silent", mob.isSilent()); + } + + if (mob.isNoGravity()) { +- tag.putBoolean("NoGravity", mob.isNoGravity()); ++ nbttagcompound.putBoolean("NoGravity", mob.isNoGravity()); + } + + if (mob.hasGlowingTag()) { +- tag.putBoolean("Glowing", mob.hasGlowingTag()); ++ nbttagcompound.putBoolean("Glowing", mob.hasGlowingTag()); + } + + if (mob.isInvulnerable()) { +- tag.putBoolean("Invulnerable", mob.isInvulnerable()); ++ nbttagcompound.putBoolean("Invulnerable", mob.isInvulnerable()); + } + +- tag.putFloat("Health", mob.getHealth()); ++ nbttagcompound.putFloat("Health", mob.getHealth()); + } + ++ /** @deprecated */ + @Deprecated + static void loadDefaultDataFromBucketTag(Mob mob, CompoundTag tag) { + if (tag.contains("NoAI")) { +@@ -83,23 +92,40 @@ + if (tag.contains("Health", 99)) { + mob.setHealth(tag.getFloat("Health")); + } ++ + } + +- static <T extends LivingEntity & Bucketable> Optional<InteractionResult> bucketMobPickup(Player player, InteractionHand hand, T entity) { +- ItemStack itemInHand = player.getItemInHand(hand); +- if (itemInHand.getItem() == Items.WATER_BUCKET && entity.isAlive()) { +- entity.playSound(entity.getPickupSound(), 1.0F, 1.0F); +- ItemStack bucketItemStack = entity.getBucketItemStack(); +- entity.saveToBucketTag(bucketItemStack); +- ItemStack itemStack = ItemUtils.createFilledResult(itemInHand, player, bucketItemStack, false); +- player.setItemInHand(hand, itemStack); +- Level level = entity.level(); +- if (!level.isClientSide) { +- CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, bucketItemStack); ++ 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 && entity.isAlive()) { ++ // CraftBukkit start ++ // t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); // CraftBukkit - moved down ++ ItemStack itemstack1 = ((Bucketable) entity).getBucketItemStack(); ++ ++ ((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(hand, itemstack2); ++ Level world = entity.level(); ++ ++ if (!world.isClientSide) { ++ CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer) player, itemstack1); ++ } ++ + entity.discard(); +- return Optional.of(InteractionResult.sidedSuccess(level.isClientSide)); ++ return Optional.of(InteractionResult.sidedSuccess(world.isClientSide)); + } else { + return Optional.empty(); + } |