mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 12:37:42 +01:00
Added all missing server packets
This commit is contained in:
parent
388caefa34
commit
261d734740
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -163,19 +163,6 @@ public class BinaryWriter extends OutputStream {
|
|||||||
writeBytes(bytes);
|
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.
|
* Writes a var-int array to the buffer.
|
||||||
* <p>
|
* <p>
|
||||||
|
Loading…
Reference in New Issue
Block a user