diff --git a/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java b/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java new file mode 100644 index 000000000..a1583455d --- /dev/null +++ b/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java @@ -0,0 +1,31 @@ +package emu.grasscutter.server.event.entity; + +import emu.grasscutter.game.entity.GameEntity; +import emu.grasscutter.net.proto.MotionStateOuterClass.MotionState; +import emu.grasscutter.server.event.types.EntityEvent; +import emu.grasscutter.utils.Position; + +public final class EntityMoveEvent extends EntityEvent { + private final Position position, rotation; + private final MotionState motionState; + + public EntityMoveEvent(GameEntity entity, Position position, Position rotation, MotionState motionState) { + super(entity); + + this.position = position; + this.rotation = rotation; + this.motionState = motionState; + } + + public Position getPosition() { + return this.position; + } + + public Position getRotation() { + return this.rotation; + } + + public MotionState getMotionState() { + return this.motionState; + } +} 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 54bdad3b6..6104f4639 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java @@ -13,8 +13,11 @@ import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo; import emu.grasscutter.net.proto.MotionStateOuterClass.MotionState; import emu.grasscutter.net.proto.PlayerDieTypeOuterClass; +import emu.grasscutter.server.event.entity.EntityMoveEvent; +import emu.grasscutter.server.event.game.ReceiveCommandFeedbackEvent; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; +import emu.grasscutter.utils.Position; @Opcodes(PacketOpcodes.CombatInvocationsNotify) public class HandlerCombatInvocationsNotify extends PacketHandler { @@ -41,11 +44,18 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { if (entity != null) { // Move player MotionInfo motionInfo = moveInfo.getMotionInfo(); + MotionState motionState = motionInfo.getState(); + + // Call entity move event. + EntityMoveEvent event = new EntityMoveEvent( + entity, new Position(motionInfo.getPos()), + new Position(motionInfo.getRot()), motionState); + event.call(); + entity.getPosition().set(motionInfo.getPos()); entity.getRotation().set(motionInfo.getRot()); entity.setLastMoveSceneTimeMs(moveInfo.getSceneTime()); entity.setLastMoveReliableSeq(moveInfo.getReliableSeq()); - MotionState motionState = motionInfo.getState(); entity.setMotionState(motionState); session.getPlayer().getStaminaManager().handleCombatInvocationsNotify(session, moveInfo, entity);