OpenWindowPacket
This commit is contained in:
@@ -55,6 +55,7 @@ public enum State {
|
||||
),
|
||||
// client bound
|
||||
Map.of(
|
||||
OpenWindowPacket.class, 0x13,
|
||||
PingPacket.class, 0x1F,
|
||||
ChunkDataPacket.class, 0x20,
|
||||
JoinGamePacket.class, 0x23,
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package mc.protocol.packets.server;
|
||||
|
||||
import lombok.Data;
|
||||
import mc.protocol.io.NetByteBuf;
|
||||
import mc.protocol.model.text.Text;
|
||||
import mc.protocol.packets.ServerSidePacket;
|
||||
import mc.protocol.serializer.TextSerializer;
|
||||
|
||||
/**
|
||||
* Open Window packet.
|
||||
*
|
||||
* <p>Структура пакета</p>
|
||||
* <pre>
|
||||
* | FIELD | TYPE | NOTES |
|
||||
* |-----------------|---------------|--------------------------------------------------------------|
|
||||
* | Window ID | Unsigned Byte | Уникальный ID окна |
|
||||
* | Window Type | String (32) | Тип окна. [1] |
|
||||
* | Window Title | Text | Заголовок окна |
|
||||
* | Number Of Slots | Unsigned Byte | Количество слотов в окне (без учета слотов инвенторя игрока) |
|
||||
* | | | Всегда 0 для окон без хранения (например Anvil) |
|
||||
*
|
||||
* [1] - <a href="https://wiki.vg/index.php?title=Inventory&oldid=14093">Inventory</a>
|
||||
* </pre>
|
||||
*
|
||||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Open_Window">Open Window</a>
|
||||
* @see <a href="https://wiki.vg/index.php?title=Inventory&oldid=14093">Inventory</a>
|
||||
*/
|
||||
@Data
|
||||
public class OpenWindowPacket implements ServerSidePacket {
|
||||
|
||||
private int windowId;
|
||||
private String windowType;
|
||||
private Text windowTitle;
|
||||
private int numberOfSlots;
|
||||
|
||||
@Override
|
||||
public void writeSelf(NetByteBuf netByteBuf) {
|
||||
netByteBuf.writeUnsignedByte(this.windowId);
|
||||
netByteBuf.writeString(this.windowType);
|
||||
netByteBuf.writeString(TextSerializer.toJsonObject(this.windowTitle).toString());
|
||||
netByteBuf.writeUnsignedByte(this.numberOfSlots);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import mc.protocol.api.ConnectionContext;
|
||||
import mc.protocol.model.Location;
|
||||
import mc.protocol.model.Look;
|
||||
import mc.protocol.model.ServerInfo;
|
||||
import mc.protocol.model.text.Text;
|
||||
import mc.protocol.packets.PingPacket;
|
||||
import mc.protocol.packets.client.HandshakePacket;
|
||||
import mc.protocol.packets.client.LoginStartPacket;
|
||||
@@ -122,6 +123,16 @@ public class PacketHandler {
|
||||
context.send(pingPacket);
|
||||
|
||||
context.flushSending();
|
||||
|
||||
// -- Эксперименты -- //
|
||||
|
||||
var openWindowPacket = new OpenWindowPacket();
|
||||
openWindowPacket.setWindowId(random.nextInt());
|
||||
openWindowPacket.setWindowType("minecraft:chest");
|
||||
openWindowPacket.setWindowTitle(Text.of("Some Title"));
|
||||
openWindowPacket.setNumberOfSlots(9);
|
||||
|
||||
context.sendNow(openWindowPacket);
|
||||
}
|
||||
|
||||
private static String faviconToBase64(Path iconPath) {
|
||||
|
||||
Reference in New Issue
Block a user