Commit 19ee983c authored by Yazawazi's avatar Yazawazi Committed by Melledy
Browse files

feature(serenitea pot): Implementation of the entry function

It's being perfected, so don't worry. (probably)
parent 83f8bec9
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());
}
}
}
}
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);
}
}
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);
}
}
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);
}
}
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