diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketChatMessage.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketChatMessageReceiving.java
similarity index 96%
rename from src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketChatMessage.java
rename to src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketChatMessageReceiving.java
index cc1dccb92..25af6fb5c 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketChatMessage.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketChatMessageReceiving.java
@@ -20,7 +20,7 @@ import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
-public class PacketChatMessage implements ClientboundPacket {
+public class PacketChatMessageReceiving implements ClientboundPacket {
TextComponent c;
TextPosition position;
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketAdvancementTab.java b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketAdvancementTab.java
new file mode 100644
index 000000000..3e9c9159d
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketAdvancementTab.java
@@ -0,0 +1,81 @@
+/*
+ * Codename Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.protocol.packets.serverbound.play;
+
+import de.bixilon.minosoft.logging.Log;
+import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
+import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
+import de.bixilon.minosoft.protocol.protocol.Packets;
+import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
+
+public class PacketAdvancementTab implements ServerboundPacket {
+ final AdvancementTabStatus action;
+ final String tabToOpen;
+
+ public PacketAdvancementTab(AdvancementTabStatus action) {
+ this.action = action;
+ tabToOpen = null;
+ log();
+ }
+
+ public PacketAdvancementTab(AdvancementTabStatus action, String tabToOpen) {
+ this.action = action;
+ this.tabToOpen = tabToOpen;
+ log();
+ }
+
+ @Override
+ public OutPacketBuffer write(ProtocolVersion version) {
+ OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_ADVANCEMENT_TAB));
+ switch (version) {
+ case VERSION_1_12_2:
+ buffer.writeVarInt(action.getId());
+ if (action == AdvancementTabStatus.OPEN_TAB) {
+ buffer.writeString(tabToOpen);
+ }
+ }
+ return buffer;
+ }
+
+ @Override
+ public void log() {
+ Log.protocol(String.format("Sending advancement tab packet (action=%s, tabToOpen=%s)", action.name(), tabToOpen));
+
+ }
+
+ public enum AdvancementTabStatus {
+ OPEN_TAB(0),
+ CLOSE_TAB(1);
+
+ final int id;
+
+
+ AdvancementTabStatus(int id) {
+ this.id = id;
+ }
+
+ public static AdvancementTabStatus byId(int id) {
+ for (AdvancementTabStatus action : values()) {
+ if (action.getId() == id) {
+ return action;
+ }
+ }
+ return null;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketChatMessage.java b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketChatMessageSending.java
similarity index 93%
rename from src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketChatMessage.java
rename to src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketChatMessageSending.java
index 3584b4f87..ff8e50bc9 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketChatMessage.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketChatMessageSending.java
@@ -19,11 +19,11 @@ import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
import de.bixilon.minosoft.protocol.protocol.Packets;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
-public class PacketChatMessage implements ServerboundPacket {
+public class PacketChatMessageSending implements ServerboundPacket {
final String message;
- public PacketChatMessage(String message) {
+ public PacketChatMessageSending(String message) {
this.message = message;
log();
}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketCraftingBookData.java b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketCraftingBookData.java
new file mode 100644
index 000000000..35cdf8628
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketCraftingBookData.java
@@ -0,0 +1,102 @@
+/*
+ * Codename Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.protocol.packets.serverbound.play;
+
+import de.bixilon.minosoft.logging.Log;
+import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
+import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
+import de.bixilon.minosoft.protocol.protocol.Packets;
+import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
+
+public class PacketCraftingBookData implements ServerboundPacket {
+ final BookDataStatus action;
+
+ final int recipeId;
+
+ final boolean craftingBookOpen;
+ final boolean craftingFilter;
+
+ public PacketCraftingBookData(BookDataStatus action, int recipeId) {
+ this.action = action;
+ this.recipeId = recipeId;
+ craftingBookOpen = false;
+ craftingFilter = false;
+ log();
+ }
+
+ public PacketCraftingBookData(BookDataStatus action, boolean craftingBookOpen, boolean craftingFilter) {
+ this.action = action;
+ this.recipeId = 0;
+ this.craftingBookOpen = craftingBookOpen;
+ this.craftingFilter = craftingFilter;
+ log();
+ }
+
+
+ @Override
+ public OutPacketBuffer write(ProtocolVersion version) {
+ OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_RECIPE_BOOK_DATA));
+ switch (version) {
+ case VERSION_1_12_2:
+ buffer.writeVarInt(action.getId());
+ switch (action) {
+ case DISPLAY_RECIPE:
+ buffer.writeVarInt(recipeId);
+ break;
+ case CRAFTING_BOOK_STATUS:
+ buffer.writeBoolean(craftingBookOpen);
+ buffer.writeBoolean(craftingFilter);
+ break;
+ }
+ }
+ return buffer;
+ }
+
+ @Override
+ public void log() {
+ switch (action) {
+ case DISPLAY_RECIPE:
+ Log.protocol(String.format("Sending crafting book status (action=%s, recipeId=%d)", action.name(), recipeId));
+ break;
+ case CRAFTING_BOOK_STATUS:
+ Log.protocol(String.format("Sending crafting book status (action=%s, craftingBookOpen=%s, craftingFilter=%s)", action.name(), craftingBookOpen, craftingFilter));
+ break;
+ }
+ }
+
+ public enum BookDataStatus {
+ DISPLAY_RECIPE(0),
+ CRAFTING_BOOK_STATUS(1);
+
+ final int id;
+
+
+ BookDataStatus(int id) {
+ this.id = id;
+ }
+
+ public static BookDataStatus byId(int id) {
+ for (BookDataStatus action : values()) {
+ if (action.getId() == id) {
+ return action;
+ }
+ }
+ return null;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketCraftingRecipeRequest.java b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketCraftingRecipeRequest.java
new file mode 100644
index 000000000..33b54d76e
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketCraftingRecipeRequest.java
@@ -0,0 +1,50 @@
+/*
+ * Codename Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.protocol.packets.serverbound.play;
+
+import de.bixilon.minosoft.logging.Log;
+import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
+import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
+import de.bixilon.minosoft.protocol.protocol.Packets;
+import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
+
+public class PacketCraftingRecipeRequest implements ServerboundPacket {
+ final byte windowId;
+ final int recipeId;
+
+ public PacketCraftingRecipeRequest(byte windowId, int recipeId) {
+ this.windowId = windowId;
+ this.recipeId = recipeId;
+ log();
+ }
+
+
+ @Override
+ public OutPacketBuffer write(ProtocolVersion version) {
+ OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_CRAFT_RECIPE_REQUEST));
+ switch (version) {
+ case VERSION_1_12_2:
+ buffer.writeByte(windowId);
+ buffer.writeVarInt(recipeId);
+ break;
+ }
+ return buffer;
+ }
+
+ @Override
+ public void log() {
+ Log.protocol(String.format("Sending entity action packet (windowId=%d, recipeId=%d)", windowId, recipeId));
+ }
+
+}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java
index 552b2bacb..265850d63 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java
@@ -181,7 +181,7 @@ public class PacketHandler {
connection.getPlayer().setSpawnLocation(pkg.getSpawnLocation());
}
- public void handle(PacketChatMessage pkg) {
+ public void handle(PacketChatMessageReceiving pkg) {
}
public void handle(PacketDisconnect pkg) {
@@ -574,4 +574,5 @@ public class PacketHandler {
public void handle(PacketAdvancements pkg) {
}
+
}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketSender.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketSender.java
index ea2772ba6..1bfcff999 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketSender.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketSender.java
@@ -31,7 +31,7 @@ public class PacketSender {
}
public void sendChatMessage(String message) {
- connection.sendPacket(new PacketChatMessage(message));
+ connection.sendPacket(new PacketChatMessageSending(message));
}
public void spectateEntity(UUID entityUUID) {
diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java
index 7586d994f..83d6ac5e5 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java
@@ -77,7 +77,7 @@ public abstract class Protocol implements ProtocolInterface {
packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_HEALTH, PacketUpdateHealth.class);
packetClassMapping.put(Packets.Clientbound.PLAY_PLUGIN_MESSAGE, PacketPluginMessageReceiving.class);
packetClassMapping.put(Packets.Clientbound.PLAY_SPAWN_POSITION, PacketSpawnLocation.class);
- packetClassMapping.put(Packets.Clientbound.PLAY_CHAT_MESSAGE, PacketChatMessage.class);
+ packetClassMapping.put(Packets.Clientbound.PLAY_CHAT_MESSAGE, PacketChatMessageReceiving.class);
packetClassMapping.put(Packets.Clientbound.PLAY_DISCONNECT, PacketDisconnect.class);
packetClassMapping.put(Packets.Clientbound.PLAY_HELD_ITEM_CHANGE, PacketHeldItemChangeReceiving.class);
packetClassMapping.put(Packets.Clientbound.PLAY_SET_EXPERIENCE, PacketSetExperience.class);