fix: Solar Isotoma Elevator doesn't work in multiplayer mode (#1848)

This commit is contained in:
hamusuke 2022-10-12 20:44:25 +09:00 committed by GitHub
parent ef55e5515c
commit ec3cdc040f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -4,7 +4,6 @@ import emu.grasscutter.game.entity.platform.EntityPlatform;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PacketHeadOuterClass;
import emu.grasscutter.net.proto.UpdateAbilityCreatedMovingPlatformNotifyOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketPlatformStartRouteNotify;
@ -14,7 +13,6 @@ import emu.grasscutter.server.packet.send.PacketPlatformStopRouteNotify;
public class HandlerUpdateAbilityCreatedMovingPlatformNotify extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var sequence = PacketHeadOuterClass.PacketHead.parseFrom(header).getClientSequenceId();
var notify = UpdateAbilityCreatedMovingPlatformNotifyOuterClass.UpdateAbilityCreatedMovingPlatformNotify.parseFrom(payload);
var entity = session.getPlayer().getScene().getEntityById(notify.getEntityId());
@ -22,9 +20,11 @@ public class HandlerUpdateAbilityCreatedMovingPlatformNotify extends PacketHandl
return;
}
var scene = ((EntityPlatform) entity).getOwner().getScene();
switch (notify.getOpType()) {
case OP_TYPE_ACTIVATE -> session.send(new PacketPlatformStartRouteNotify(sequence, (EntityPlatform) entity, session.getPlayer().getScene()));
case OP_TYPE_DEACTIVATE -> session.send(new PacketPlatformStopRouteNotify(sequence, (EntityPlatform) entity, session.getPlayer().getScene()));
case OP_TYPE_ACTIVATE -> scene.broadcastPacket(new PacketPlatformStartRouteNotify((EntityPlatform) entity, scene));
case OP_TYPE_DEACTIVATE -> scene.broadcastPacket(new PacketPlatformStopRouteNotify((EntityPlatform) entity, scene));
}
}
}

View File

@ -7,8 +7,8 @@ import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlatformStartRouteNotifyOuterClass;
public class PacketPlatformStartRouteNotify extends BasePacket {
public PacketPlatformStartRouteNotify(int clientSequence, EntityPlatform entity, Scene scene) {
super(PacketOpcodes.PlatformStartRouteNotify, clientSequence);
public PacketPlatformStartRouteNotify(EntityPlatform entity, Scene scene) {
super(PacketOpcodes.PlatformStartRouteNotify);
var notify = PlatformStartRouteNotifyOuterClass.PlatformStartRouteNotify.newBuilder()
.setEntityId(entity.getId())

View File

@ -7,8 +7,8 @@ import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlatformStopRouteNotifyOuterClass;
public class PacketPlatformStopRouteNotify extends BasePacket {
public PacketPlatformStopRouteNotify(int clientSequence, EntityPlatform entity, Scene scene) {
super(PacketOpcodes.PlatformStopRouteNotify, clientSequence);
public PacketPlatformStopRouteNotify(EntityPlatform entity, Scene scene) {
super(PacketOpcodes.PlatformStopRouteNotify);
var notify = PlatformStopRouteNotifyOuterClass.PlatformStopRouteNotify.newBuilder()
.setPlatform(entity.onStopRoute())