22
33import com .robertx22 .library_of_exile .main .MyPacket ;
44import com .robertx22 .library_of_exile .packets .ExilePacketContext ;
5+ import com .robertx22 .library_of_exile .utils .SoundUtils ;
56import com .robertx22 .mine_and_slash .mmorpg .SlashRef ;
67import com .robertx22 .mine_and_slash .vanilla_mc .items .SlashPotionItem ;
78import net .minecraft .network .FriendlyByteBuf ;
89import net .minecraft .resources .ResourceLocation ;
910import net .minecraft .server .level .ServerPlayer ;
11+ import net .minecraft .sounds .SoundEvents ;
1012import net .minecraft .world .entity .player .Player ;
1113import net .minecraft .world .inventory .Slot ;
1214import net .minecraft .world .item .ItemStack ;
@@ -45,7 +47,7 @@ public void onReceived(ExilePacketContext exilePacketContext) {
4547 }
4648 potionItems .stream ()
4749 //remove all in-cooldown potions
48- .filter (x -> player .getCooldowns ().isOnCooldown (x .getItem ()))
50+ .filter (x -> ! player .getCooldowns ().isOnCooldown (x .getItem ()))
4951 .map (x -> Pair .of (x , ((SlashPotionItem ) x .getItem ())))
5052 .collect (Collectors .groupingBy (x -> x .getRight ().getType ()))
5153 .values ()
@@ -64,7 +66,11 @@ public void onReceived(ExilePacketContext exilePacketContext) {
6466
6567 })
6668 //try drink
67- .forEach (x -> x .getRight ().handlePotionRestore (player , x .getLeft ()));
69+ .map (x -> x .getRight ().handlePotionRestore (player , x .getLeft ()))
70+ .filter (x -> x )
71+ //at least one potion is consumed
72+ .findFirst ()
73+ .ifPresentOrElse (x -> SoundUtils .playSound (player , SoundEvents .VILLAGER_YES ), () -> SoundUtils .playSound (player , SoundEvents .VILLAGER_NO ));
6874 }
6975 }
7076
0 commit comments