Skip to content

Commit

Permalink
Fix trident sounds not working #123
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeltumn committed Jan 28, 2025
1 parent db8abbd commit c5fed85
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public boolean isInWaterOrRain(Player player) {
@Redirect(
method = "releaseUsing",
at =
@At(
value = "INVOKE",
target =
"Lnet/minecraft/world/level/Level;playSound(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FF)V"))
@At(
value = "INVOKE",
target =
"Lnet/minecraft/world/level/Level;playSound(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FF)V"))
public void playSound(
Level instance,
Player ignored,
Expand All @@ -54,9 +54,12 @@ public void playSound(
Level level,
LivingEntity livingEntity,
int i) {
if (!ServerRules.ENABLE_SMOOTHER_CLIENT_TRIDENT.getValue()) return;

var player = Minecraft.getInstance().player;
if (entity != player || player == null) return;
if (!ServerRules.ENABLE_SMOOTHER_CLIENT_TRIDENT.getValue() || entity != player || player == null) {
instance.playSound(ignored, entity, soundEvent, soundSource, volume, pitch);
return;
}

// Play a sound locally to replace the remote sound
instance.playLocalSound(entity, soundEvent, soundSource, volume, pitch);
Expand All @@ -66,9 +69,9 @@ public void playSound(

// Send the server a packet to inform it about the riptide as we may have used coyote time to trigger it!
new ServerboundRiptidePacket(
player.getUsedItemHand() == InteractionHand.MAIN_HAND
? player.getInventory().selected
: Inventory.SLOT_OFFHAND)
player.getUsedItemHand() == InteractionHand.MAIN_HAND
? player.getInventory().selected
: Inventory.SLOT_OFFHAND)
.send();
}
}

0 comments on commit c5fed85

Please sign in to comment.