diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketNBTQueryResponse.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketNBTQueryResponse.java new file mode 100644 index 000000000..e2b12b682 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketNBTQueryResponse.java @@ -0,0 +1,56 @@ +/* + * 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.clientbound.play; + +import de.bixilon.minosoft.logging.Log; +import de.bixilon.minosoft.nbt.tag.CompoundTag; +import de.bixilon.minosoft.protocol.packets.ClientboundPacket; +import de.bixilon.minosoft.protocol.protocol.InPacketBuffer; +import de.bixilon.minosoft.protocol.protocol.PacketHandler; + +public class PacketNBTQueryResponse implements ClientboundPacket { + int transactionId; + CompoundTag tag; + + + @Override + public boolean read(InPacketBuffer buffer) { + switch (buffer.getVersion()) { + case VERSION_1_13_2: + transactionId = buffer.readVarInt(); + tag = buffer.readNBT(); + return true; + } + + return false; + } + + @Override + public void log() { + Log.protocol(String.format("Received nbt response (transactionId=%d, nbt=%s)", transactionId, tag.toString())); + } + + @Override + public void handle(PacketHandler h) { + h.handle(this); + } + + public int getTransactionId() { + return transactionId; + } + + public CompoundTag getTag() { + return tag; + } +} 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 89521df4d..0ab5c8e57 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java @@ -575,4 +575,6 @@ public class PacketHandler { public void handle(PacketAdvancements pkg) { } + public void handle(PacketNBTQueryResponse pkg) { + } } 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 83d6ac5e5..17c2feb3d 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java @@ -27,6 +27,9 @@ import java.util.Map; public abstract class Protocol implements ProtocolInterface { static final HashMap> packetClassMapping = new HashMap<>(); + static { + initPacketClassMapping(); + } public final HashMap serverboundPacketMapping; public final HashMap clientboundPacketMapping; @@ -54,10 +57,6 @@ public abstract class Protocol implements ProtocolInterface { } public static Class getPacketByPacket(Packets.Clientbound p) { - if (packetClassMapping.size() == 0) { - // init - initPacketClassMapping(); - } return packetClassMapping.get(p); } @@ -146,6 +145,7 @@ public abstract class Protocol implements ProtocolInterface { packetClassMapping.put(Packets.Clientbound.PLAY_UNLOCK_RECIPES, PacketUnlockRecipes.class); packetClassMapping.put(Packets.Clientbound.PLAY_SELECT_ADVANCEMENT_TAB, PacketSelectAdvancementTab.class); packetClassMapping.put(Packets.Clientbound.PLAY_ADVANCEMENTS, PacketAdvancements.class); + packetClassMapping.put(Packets.Clientbound.PLAY_NBT_QUERY_RESPONSE, PacketNBTQueryResponse.class); } public static ProtocolVersion getLowestVersionSupported() {