BlockGroup.java
package com.hypixel.hytale.protocol;
import com.hypixel.hytale.protocol.io.PacketIO;
import com.hypixel.hytale.protocol.io.ProtocolException;
import com.hypixel.hytale.protocol.io.ValidationResult;
import com.hypixel.hytale.protocol.io.VarInt;
import io.netty.buffer.ByteBuf;
import java.util.Arrays;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockGroup {
public static final int NULLABLE_BIT_FIELD_SIZE = 1;
public static final int FIXED_BLOCK_SIZE = 1;
public static final int VARIABLE_FIELD_COUNT = 1;
public static final int VARIABLE_BLOCK_START = 1;
public static final ;
String[] names;
{
}
{
.names = names;
}
{
.names = other.names;
}
BlockGroup {
();
buf.getByte(offset);
offset + ;
((nullBits & ) != ) {
VarInt.peek(buf, pos);
(namesCount < ) {
ProtocolException.negativeLength(, namesCount);
}
(namesCount > ) {
ProtocolException.arrayTooLong(, namesCount, );
}
VarInt.size(namesCount);
(()(pos + namesVarLen) + ()namesCount * > ()buf.readableBytes()) {
ProtocolException.bufferTooSmall(, pos + namesVarLen + namesCount * , buf.readableBytes());
}
pos += namesVarLen;
obj.names = [namesCount];
( ; i < namesCount; ++i) {
VarInt.peek(buf, pos);
(strLen < ) {
ProtocolException.negativeLength( + i + , strLen);
}
(strLen > ) {
ProtocolException.stringTooLong( + i + , strLen, );
}
VarInt.length(buf, pos);
obj.names[i] = PacketIO.readVarString(buf, pos);
pos += strVarLen + strLen;
}
}
obj;
}
{
buf.getByte(offset);
offset + ;
((nullBits & ) != ) {
VarInt.peek(buf, pos);
pos += VarInt.length(buf, pos);
( ; i < arrLen; ++i) {
VarInt.peek(buf, pos);
pos += VarInt.length(buf, pos) + sl;
}
}
pos - offset;
}
{
;
(.names != ) {
nullBits = ()(nullBits | );
}
buf.writeByte(nullBits);
(.names != ) {
(.names.length > ) {
ProtocolException.arrayTooLong(, .names.length, );
}
VarInt.write(buf, .names.length);
(String item : .names) {
PacketIO.writeVarString(buf, item, );
}
}
}
{
;
(.names != ) {
;
(String elem : .names) {
namesSize += PacketIO.stringSize(elem);
}
size += VarInt.size(.names.length) + namesSize;
}
size;
}
ValidationResult {
(buffer.readableBytes() - offset < ) {
ValidationResult.error();
} {
buffer.getByte(offset);
offset + ;
((nullBits & ) != ) {
VarInt.peek(buffer, pos);
(namesCount < ) {
ValidationResult.error();
}
(namesCount > ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
( ; i < namesCount; ++i) {
VarInt.peek(buffer, pos);
(strLen < ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
pos += strLen;
(pos > buffer.writerIndex()) {
ValidationResult.error();
}
}
}
ValidationResult.OK;
}
}
BlockGroup {
();
copy.names = .names != ? (String[])Arrays.copyOf(.names, .names.length) : ;
copy;
}
{
( == obj) {
;
} (obj BlockGroup) {
(BlockGroup)obj;
Arrays.equals(.names, other.names);
} {
;
}
}
{
;
result = * result + Arrays.hashCode(.names);
result;
}
}