I wanted to make a mod to play a violin while right clicking and stop when not, with the code i have until now i can play it. But now i need to use another function so it stops when you don't right click anymore. The function that i encounter most useful was "onUsingTick", but as i understand know its deprecated and i don't find the replacement.
At the same time, i think something to stop the sound in a function like "useOnRelease" or "finishUsingItem" would be more helpful, but that is equally complicated without sound events management as i understand. (sorry if my english is a little broken, i am from Argentina).
@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
if(!level.isClientSide() && hand == InteractionHand.MAIN_HAND) {
level.playSound(null, player.getX(), player.getY(), player.getZ(),
ModSounds.VIOLIN.get(), SoundSource.PLAYERS, 1F, 1.F);
}
return super.use(level, player, hand);
}