mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 13:02:57 +08:00
feature(serenitea pot): Implementation of the entry function
It's being perfected, so don't worry. (probably)
This commit is contained in:
parent
83f8bec947
commit
19ee983c08
@ -0,0 +1,57 @@
|
|||||||
|
package emu.grasscutter.server.packet.recv;
|
||||||
|
|
||||||
|
import emu.grasscutter.Grasscutter;
|
||||||
|
import emu.grasscutter.data.GameData;
|
||||||
|
import emu.grasscutter.data.def.GadgetData;
|
||||||
|
import emu.grasscutter.game.entity.EntityVehicle;
|
||||||
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
|
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.*;
|
||||||
|
import emu.grasscutter.server.game.GameSession;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketWidgetCoolDownNotify;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketWidgetDoBagRsp;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketWidgetGadgetDataNotify;
|
||||||
|
import emu.grasscutter.utils.Position;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Opcodes(PacketOpcodes.WidgetDoBagReq)
|
||||||
|
public class HandlerWidgetDoBagReq extends PacketHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
|
WidgetDoBagReqOuterClass.WidgetDoBagReq req = WidgetDoBagReqOuterClass.WidgetDoBagReq.parseFrom(payload);
|
||||||
|
switch (req.getMaterialId()) {
|
||||||
|
case 220026 -> {
|
||||||
|
GadgetData gadgetData = GameData.getGadgetDataMap().get(70500025);
|
||||||
|
Position pos = new Position(req.getWidgetCreatorInfo().getLocationInfo().getPos());
|
||||||
|
Position rot = new Position(req.getWidgetCreatorInfo().getLocationInfo().getRot());
|
||||||
|
GameEntity entity = new EntityVehicle(
|
||||||
|
session.getPlayer().getScene(),
|
||||||
|
session.getPlayer(),
|
||||||
|
gadgetData.getId(),
|
||||||
|
0,
|
||||||
|
pos,
|
||||||
|
rot
|
||||||
|
);
|
||||||
|
|
||||||
|
session.getPlayer().getScene().addEntity(entity);
|
||||||
|
|
||||||
|
session.send(new PacketWidgetGadgetDataNotify(70500025, List.of(entity.getId()))); // ???
|
||||||
|
session.send(new PacketWidgetCoolDownNotify(15, System.currentTimeMillis() + 5000L, true));
|
||||||
|
session.send(new PacketWidgetCoolDownNotify(15, System.currentTimeMillis() + 5000L, true));
|
||||||
|
// Send twice, and I don't know why, Ask mhy
|
||||||
|
session.send(new PacketWidgetDoBagRsp());
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
session.send(new PacketWidgetDoBagRsp());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.WidgetCoolDownDataOuterClass;
|
||||||
|
import emu.grasscutter.net.proto.WidgetCoolDownNotifyOuterClass;
|
||||||
|
|
||||||
|
public class PacketWidgetCoolDownNotify extends BasePacket {
|
||||||
|
|
||||||
|
public PacketWidgetCoolDownNotify(int id, long coolDownTime, boolean isSuccess) {
|
||||||
|
super(PacketOpcodes.WidgetCoolDownNotify);
|
||||||
|
|
||||||
|
WidgetCoolDownNotifyOuterClass.WidgetCoolDownNotify proto = WidgetCoolDownNotifyOuterClass.WidgetCoolDownNotify.newBuilder()
|
||||||
|
.addGroupCoolDownDataList(
|
||||||
|
WidgetCoolDownDataOuterClass.WidgetCoolDownData.newBuilder()
|
||||||
|
.setId(id)
|
||||||
|
.setCoolDownTime(coolDownTime)
|
||||||
|
.setIsSuccess(isSuccess)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.WidgetDoBagRspOuterClass;
|
||||||
|
|
||||||
|
public class PacketWidgetDoBagRsp extends BasePacket {
|
||||||
|
|
||||||
|
public PacketWidgetDoBagRsp(int materialId) {
|
||||||
|
super(PacketOpcodes.WidgetDoBagRsp);
|
||||||
|
|
||||||
|
WidgetDoBagRspOuterClass.WidgetDoBagRsp proto = WidgetDoBagRspOuterClass.WidgetDoBagRsp.newBuilder()
|
||||||
|
.setMaterialId(materialId)
|
||||||
|
.setRetcode(0)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketWidgetDoBagRsp() {
|
||||||
|
super(PacketOpcodes.WidgetDoBagRsp);
|
||||||
|
|
||||||
|
WidgetDoBagRspOuterClass.WidgetDoBagRsp proto = WidgetDoBagRspOuterClass.WidgetDoBagRsp.newBuilder()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.WidgetGadgetDataNotifyOuterClass;
|
||||||
|
import emu.grasscutter.net.proto.WidgetGadgetDataOuterClass;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PacketWidgetGadgetDataNotify extends BasePacket {
|
||||||
|
public PacketWidgetGadgetDataNotify(int gadgetId, List<Integer> gadgetEntityIdList) throws IOException {
|
||||||
|
super(PacketOpcodes.WidgetGadgetDataNotify);
|
||||||
|
|
||||||
|
WidgetGadgetDataNotifyOuterClass.WidgetGadgetDataNotify proto = WidgetGadgetDataNotifyOuterClass.WidgetGadgetDataNotify.newBuilder()
|
||||||
|
.setWidgetGadgetData(
|
||||||
|
WidgetGadgetDataOuterClass.WidgetGadgetData.newBuilder()
|
||||||
|
.setGadgetId(gadgetId)
|
||||||
|
.addAllGadgetEntityIdList(gadgetEntityIdList)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user