Hey
Recently started learning modding and ive looked all over but i cant find a specific solution to my problem. I have basic java knowledge (currently studying computer science).
Here is my code:
@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
if(!level.isClientSide() && hand == InteractionHand.MAIN_HAND) {
level.playSound(player, player.getX(), player.getY(), player.getZ(), ModSoundEvents.WILLIAM_STICK_INTERACT.get(), SoundSource.AMBIENT, 1.0f, 1.0f);
player.getCooldowns().addCooldown(this, 20);
}
return super.use(level, player, hand); }
I want my item to play a sound everytime i press mouse button 2. But it doesnt work. The cooldown function also stops working when i havent greyed out the sound part.