From 787f3fd45e83146beca0a544e8c16d9677ce1a4b Mon Sep 17 00:00:00 2001 From: Melledy <52122272+Melledy@users.noreply.github.com> Date: Wed, 4 May 2022 01:21:34 -0700 Subject: [PATCH] Fix damage number not showing up if it was the killing blow --- src/main/java/emu/grasscutter/game/player/Player.java | 8 ++++++++ .../packet/recv/HandlerCombatInvocationsNotify.java | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index e4c59e38f..50fa517e6 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -29,6 +29,7 @@ import emu.grasscutter.game.world.Scene; import emu.grasscutter.game.world.World; import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry; +import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult; import emu.grasscutter.net.proto.CombatInvokeEntryOuterClass.CombatInvokeEntry; import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType; import emu.grasscutter.net.proto.MpSettingTypeOuterClass.MpSettingType; @@ -54,6 +55,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.time.Instant; import java.util.*; +import java.util.concurrent.LinkedBlockingQueue; @Entity(value = "players", useDiscriminator = false) public class Player { @@ -113,6 +115,7 @@ public class Player { @Transient private long nextSendPlayerLocTime = 0; @Transient private final Int2ObjectMap coopRequests; + @Transient private final Queue attackResults; @Transient private final InvokeHandler combatInvokeHandler; @Transient private final InvokeHandler abilityInvokeHandler; @Transient private final InvokeHandler clientAbilityInitFinishHandler; @@ -143,6 +146,7 @@ public class Player { this.setRegionId(1); this.sceneState = SceneLoadState.NONE; + this.attackResults = new LinkedBlockingQueue<>(); this.coopRequests = new Int2ObjectOpenHashMap<>(); this.combatInvokeHandler = new InvokeHandler(PacketCombatInvocationsNotify.class); this.abilityInvokeHandler = new InvokeHandler(PacketAbilityInvocationsNotify.class); @@ -414,6 +418,10 @@ public class Player { public MpSettingType getMpSetting() { return MpSettingType.MP_SETTING_ENTER_AFTER_APPLY; // TEMP } + + public Queue getAttackResults() { + return this.attackResults; + } public synchronized Int2ObjectMap getCoopRequests() { return coopRequests; diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java index a5a3fd4c3..d62d9fc6f 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java @@ -22,7 +22,7 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { case COMBAT_EVT_BEING_HIT: // Handle damage EvtBeingHitInfo hitInfo = EvtBeingHitInfo.parseFrom(entry.getCombatData()); - session.getPlayer().getScene().handleAttack(hitInfo.getAttackResult()); + session.getPlayer().getAttackResults().add(hitInfo.getAttackResult()); break; case ENTITY_MOVE: // Handle movement @@ -43,9 +43,14 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { session.getPlayer().getCombatInvokeHandler().addEntry(entry.getForwardType(), entry); } + // Handles sending combat invokes to other players/server if (notif.getInvokeListList().size() > 0) { session.getPlayer().getCombatInvokeHandler().update(session.getPlayer()); } + + // Handle attack results last + while (!session.getPlayer().getAttackResults().isEmpty()) { + session.getPlayer().getScene().handleAttack(session.getPlayer().getAttackResults().poll()); + } } - }