Skip to content

Commit af94018

Browse files
committed
add comment for the sake of future maintenance
1 parent 2a3d5b4 commit af94018

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/main/java/com/robertx22/mine_and_slash/vanilla_mc/packets/QuickUsePotionPacket.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void saveToData(FriendlyByteBuf friendlyByteBuf) {
3737
public void onReceived(ExilePacketContext exilePacketContext) {
3838
if (exilePacketContext.getPlayer() instanceof ServerPlayer player) {
3939
List<ItemStack> potionItems = new ArrayList<>();
40+
//get all kinds of SlashPotionItem in player's inventory.
4041
for (Slot slot : player.inventoryMenu.slots) {
4142
if (slot.getItem().getItem() instanceof SlashPotionItem) {
4243
potionItems.add(slot.getItem());
@@ -49,8 +50,10 @@ public void onReceived(ExilePacketContext exilePacketContext) {
4950
.collect(Collectors.groupingBy(x -> x.getRight().getType()))
5051
.values()
5152
.stream()
53+
//pick the greatest one
5254
.map(v -> {
5355
if (v.size() > 1) {
56+
//sort the list to find the greatest one
5457
List<Pair<ItemStack, SlashPotionItem>> sorted = v.stream()
5558
.sorted(((p1, p2) -> -Float.compare(p1.getRight().getType().getHealPercent(p1.getKey()), p2.getRight().getType().getHealPercent(p2.getKey()))))
5659
.toList();
@@ -60,6 +63,7 @@ public void onReceived(ExilePacketContext exilePacketContext) {
6063
}
6164

6265
})
66+
//try drink
6367
.forEach(x -> x.getRight().handlePotionRestore(player, x.getLeft()));
6468
}
6569
}

0 commit comments

Comments
 (0)