Added all missing server packets

This commit is contained in:
themode 2021-01-05 13:44:14 +01:00
parent 388caefa34
commit 261d734740
3 changed files with 55 additions and 13 deletions

View File

@ -0,0 +1,29 @@
package net.minestom.server.network.packet.server.play;
import net.minestom.server.network.packet.server.ServerPacket;
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
import net.minestom.server.utils.binary.BinaryWriter;
import org.jetbrains.annotations.NotNull;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
public class NbtQueryResponsePacket implements ServerPacket {
public int transactionId;
public NBTCompound nbtCompound;
@Override
public void write(@NotNull BinaryWriter writer) {
writer.writeVarInt(transactionId);
if (nbtCompound != null) {
writer.writeNBT("", nbtCompound);
} else {
// TAG_End
writer.writeByte((byte) 0x00);
}
}
@Override
public int getId() {
return ServerPacketIdentifier.NBT_QUERY_RESPONSE;
}
}

View File

@ -0,0 +1,26 @@
package net.minestom.server.network.packet.server.play;
import net.minestom.server.network.packet.server.ServerPacket;
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
import net.minestom.server.utils.binary.BinaryWriter;
import org.jetbrains.annotations.NotNull;
public class SelectAdvancementTabPacket implements ServerPacket {
public String identifier;
@Override
public void write(@NotNull BinaryWriter writer) {
final boolean hasId = identifier != null;
writer.writeBoolean(hasId);
if (hasId) {
writer.writeSizedString(identifier);
}
}
@Override
public int getId() {
return ServerPacketIdentifier.SELECT_ADVANCEMENT_TAB;
}
}

View File

@ -163,19 +163,6 @@ public class BinaryWriter extends OutputStream {
writeBytes(bytes);
}
/**
* Writes a string to the buffer.
* <p>
* The size is a short type.
*
* @param string the string to write
*/
public void writeShortSizedString(@NotNull String string) {
final byte[] bytes = string.getBytes(StandardCharsets.UTF_8);
writeShort((short) bytes.length);
writeBytes(bytes);
}
/**
* Writes a var-int array to the buffer.
* <p>