Posted August 5, 20232 yr package net.choccy.darksteel.item.custom; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; public class DarksteelHornItem extends Item { public DarksteelHornItem(Properties properties) { super(properties); } @Override public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) { if (!level.isClientSide()) { player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, 200, 4)); level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.RAID_HORN, SoundSource.PLAYERS, 1.0F, 1.0F); player.getCooldowns().addCooldown(this, 400); } return super.use(level, player, hand); } } This is the code. The strength and cooldown work, but the sound does not play. Anyone know why?
August 7, 20232 yr Move your level.playsound() outside the if statement, it shouldn't be fired on the serverside.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.