mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:32:53 +08:00
Fix cherry pick issues from drown packets
This commit is contained in:
parent
a0ed13182c
commit
cdb08195ee
@ -1,14 +1,15 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.game.entity.EntityAvatar;
|
||||
import emu.grasscutter.game.entity.EntityMonster;
|
||||
import emu.grasscutter.game.entity.GenshinEntity;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
import emu.grasscutter.game.props.LifeState;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.SceneEntityDrownReqOuterClass.SceneEntityDrownReq;
|
||||
import emu.grasscutter.net.proto.VisionTypeOuterClass;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketSceneEntityDrownRsp;
|
||||
|
||||
@Opcodes(PacketOpcodes.SceneEntityDrownReq)
|
||||
@ -18,24 +19,17 @@ public class HandlerSceneEntityDrownReq extends PacketHandler {
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
SceneEntityDrownReq req = SceneEntityDrownReq.parseFrom(payload);
|
||||
|
||||
|
||||
GenshinEntity entity = session.getPlayer().getScene().getEntityById(req.getEntityId());
|
||||
|
||||
|
||||
PacketLifeStateChangeNotify lifeStateChangeNotify = new PacketLifeStateChangeNotify(entity, entity, LifeState.LIFE_DEAD);
|
||||
PacketSceneEntityDrownRsp drownRsp = new PacketSceneEntityDrownRsp(req.getEntityId());
|
||||
|
||||
|
||||
|
||||
//kill entity + broadcast it
|
||||
|
||||
session.getPlayer().getScene().broadcastPacket(lifeStateChangeNotify);
|
||||
session.getPlayer().getScene().broadcastPacket(drownRsp);
|
||||
if (entity == null || !(entity instanceof EntityMonster || entity instanceof EntityAvatar)) {
|
||||
return;
|
||||
}
|
||||
|
||||
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 0);
|
||||
|
||||
//TODO: make a list somewhere of all entities to remove per tick rather than one by one
|
||||
|
||||
session.getPlayer().getScene().removeEntity(entity, VisionTypeOuterClass.VisionType.VisionDie);
|
||||
|
||||
session.getPlayer().getScene().killEntity(entity, 0);
|
||||
session.getPlayer().getScene().broadcastPacket(new PacketSceneEntityDrownRsp(req.getEntityId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.game.entity.GenshinEntity;
|
||||
import emu.grasscutter.net.packet.GenshinPacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.SceneEntityDrownRspOuterClass.SceneEntityDrownRsp;
|
||||
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
|
||||
|
||||
public class PacketSceneEntityDrownRsp extends GenshinPacket {
|
||||
|
||||
public PacketSceneEntityDrownRsp(int entityId) {
|
||||
super(PacketOpcodes.SceneEntityDrownRsp);
|
||||
|
||||
SceneEntityDrownRsp proto = new SceneEntityDrownRsp().toBuilder().setEntityId(entityId).build();
|
||||
SceneEntityDrownRsp proto = SceneEntityDrownRsp.newBuilder().setEntityId(entityId).build();
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user