Implement material crafting

This commit is contained in:
Melledy
2025-10-30 19:33:07 -07:00
parent 489b88ea4a
commit 00b77e80e1
5 changed files with 95 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.proto.ItemProduct.ItemProductReq;
import emu.nebula.net.HandlerId;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.item_product_req)
public class HandlerItemProductReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Parse request
var req = ItemProductReq.parseFrom(message);
// Produce item
var changes = session.getPlayer().getInventory().produce(req.getId(), req.getNum());
if (changes == null) {
return this.encodeMsg(NetMsgId.item_product_failed_ack);
}
// Send response
return this.encodeMsg(NetMsgId.item_product_succeed_ack, changes.toProto());
}
}