Make the constants static and use buffer.writeShort instead of doing it manually

This commit is contained in:
Sollace 2023-03-23 21:04:43 +00:00
parent 42d45b3a9e
commit 4ab3ce224d

View file

@ -16,10 +16,9 @@ import java.util.UUID;
import java.util.function.Supplier; import java.util.function.Supplier;
public class MsgPonyData implements IPonyData { public class MsgPonyData implements IPonyData {
private static final short API_IDENTIFIER = (short) 0xABCD;
private final short API_IDENTIFIER = (short) 0xABCD;
// API version - increment this number before any time any data is added/removed/moved in the data stream // API version - increment this number before any time any data is added/removed/moved in the data stream
private final byte API_VERSION = 2; private static final byte API_VERSION = 2;
private final Race race; private final Race race;
private final TailLength tailLength; private final TailLength tailLength;
@ -87,8 +86,7 @@ public class MsgPonyData implements IPonyData {
} }
public PacketByteBuf toBuffer(PacketByteBuf buffer) { public PacketByteBuf toBuffer(PacketByteBuf buffer) {
buffer.writeByte((API_IDENTIFIER & 0xFF00) >> 8); buffer.writeShort(API_IDENTIFIER);
buffer.writeByte(API_IDENTIFIER & 0x00FF);
buffer.writeByte(API_VERSION); buffer.writeByte(API_VERSION);
buffer.writeEnumConstant(race); buffer.writeEnumConstant(race);
buffer.writeEnumConstant(tailLength); buffer.writeEnumConstant(tailLength);