Skip to content

Commit

Permalink
Fixed chargers not playing No Ink sound event
Browse files Browse the repository at this point in the history
  • Loading branch information
Cibernet83 committed Feb 7, 2024
1 parent 1b93f3a commit 34faab2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ protected void playChargingSound(Player player) {
@Override
public void weaponUseTick(Level level, LivingEntity entity, ItemStack stack, int timeLeft)
{
if (entity instanceof Player player && level.isClientSide && !player.getCooldowns().isOnCooldown(this))
if(!level.isClientSide)
{
if(timeLeft % 4 == 0 && !enoughInk(entity, this, 0.1f, 0, false))
playNoInkSound(entity, SplatcraftSounds.noInkMain);
}
else if (entity instanceof Player player && !player.getCooldowns().isOnCooldown(this))
{
ChargerWeaponSettings settings = getSettings(stack);
float prevCharge = PlayerCharge.getChargeValue(player, stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,16 @@ public static void sendNoInkMessage(LivingEntity entity, SoundEvent sound)
{
((Player) entity).displayClientMessage(new TranslatableComponent("status.no_ink").withStyle(ChatFormatting.RED), true);
if (sound != null)
{
entity.level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), sound, SoundSource.PLAYERS, 0.8F,
((entity.level.getRandom().nextFloat() - entity.level.getRandom().nextFloat()) * 0.1F + 1.0F) * 0.95F);
}
playNoInkSound(entity, sound);
}
}

public static void playNoInkSound(LivingEntity entity, SoundEvent sound)
{
entity.level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), sound, SoundSource.PLAYERS, 0.8F,
((entity.level.getRandom().nextFloat() - entity.level.getRandom().nextFloat()) * 0.1F + 1.0F) * 0.95F);
}

@Override
public void appendHoverText(@NotNull ItemStack stack, @Nullable Level level, @NotNull List<Component> tooltip, @NotNull TooltipFlag flag)
{
Expand Down

0 comments on commit 34faab2

Please sign in to comment.