mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-26 22:22:51 +00:00
Add & implement EntityMoveEvent
This commit is contained in:
parent
13c2037899
commit
a5620e4632
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user