package net.minecraft.world.item; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Saddleable; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.gameevent.GameEvent; public class SaddleItem extends Item { public SaddleItem(Item.Properties properties) { super(properties); } @Override public InteractionResult interactLivingEntity(ItemStack stack, Player player, LivingEntity interactionTarget, InteractionHand usedHand) { if (interactionTarget instanceof Saddleable saddleable && interactionTarget.isAlive() && !saddleable.isSaddled() && saddleable.isSaddleable()) { if (!player.level().isClientSide) { saddleable.equipSaddle(stack.split(1), SoundSource.NEUTRAL); interactionTarget.level().gameEvent(interactionTarget, GameEvent.EQUIP, interactionTarget.position()); } return InteractionResult.SUCCESS; } else { return InteractionResult.PASS; } } }