Commit 52da2c23 authored by KingRainbow44's avatar KingRainbow44
Browse files

Add & implement `EntityMoveEvent`

parent 47f33533
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;
}
}
...@@ -13,8 +13,11 @@ import emu.grasscutter.net.packet.PacketHandler; ...@@ -13,8 +13,11 @@ import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo; import emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo;
import emu.grasscutter.net.proto.MotionStateOuterClass.MotionState; import emu.grasscutter.net.proto.MotionStateOuterClass.MotionState;
import emu.grasscutter.net.proto.PlayerDieTypeOuterClass; 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.game.GameSession;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
import emu.grasscutter.utils.Position;
@Opcodes(PacketOpcodes.CombatInvocationsNotify) @Opcodes(PacketOpcodes.CombatInvocationsNotify)
public class HandlerCombatInvocationsNotify extends PacketHandler { public class HandlerCombatInvocationsNotify extends PacketHandler {
...@@ -41,11 +44,18 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { ...@@ -41,11 +44,18 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
if (entity != null) { if (entity != null) {
// Move player // Move player
MotionInfo motionInfo = moveInfo.getMotionInfo(); 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.getPosition().set(motionInfo.getPos());
entity.getRotation().set(motionInfo.getRot()); entity.getRotation().set(motionInfo.getRot());
entity.setLastMoveSceneTimeMs(moveInfo.getSceneTime()); entity.setLastMoveSceneTimeMs(moveInfo.getSceneTime());
entity.setLastMoveReliableSeq(moveInfo.getReliableSeq()); entity.setLastMoveReliableSeq(moveInfo.getReliableSeq());
MotionState motionState = motionInfo.getState();
entity.setMotionState(motionState); entity.setMotionState(motionState);
session.getPlayer().getStaminaManager().handleCombatInvocationsNotify(session, moveInfo, entity); session.getPlayer().getStaminaManager().handleCombatInvocationsNotify(session, moveInfo, entity);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment