ItemCategory.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 java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ItemCategory {
public static final int NULLABLE_BIT_FIELD_SIZE = 1;
public static final int FIXED_BLOCK_SIZE = 6;
public static final int VARIABLE_FIELD_COUNT = 4;
public static final int VARIABLE_BLOCK_START = 22;
public ;
String id;
String name;
String icon;
order;
ItemGridInfoDisplayMode infoDisplayMode;
ItemCategory[] children;
{
.infoDisplayMode = ItemGridInfoDisplayMode.Tooltip;
}
{
.infoDisplayMode = ItemGridInfoDisplayMode.Tooltip;
.id = id;
.name = name;
.icon = icon;
.order = order;
.infoDisplayMode = infoDisplayMode;
.children = children;
}
{
.infoDisplayMode = ItemGridInfoDisplayMode.Tooltip;
.id = other.id;
.name = other.name;
.icon = other.icon;
.order = other.order;
.infoDisplayMode = other.infoDisplayMode;
.children = other.children;
}
ItemCategory {
();
buf.getByte(offset);
obj.order = buf.getIntLE(offset + );
obj.infoDisplayMode = ItemGridInfoDisplayMode.fromValue(buf.getByte(offset + ));
((nullBits & ) != ) {
offset + + buf.getIntLE(offset + );
VarInt.peek(buf, varPos0);
(idLen < ) {
ProtocolException.negativeLength(, idLen);
}
(idLen > ) {
ProtocolException.stringTooLong(, idLen, );
}
obj.id = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8);
}
((nullBits & ) != ) {
offset + + buf.getIntLE(offset + );
VarInt.peek(buf, varPos1);
(nameLen < ) {
ProtocolException.negativeLength(, nameLen);
}
(nameLen > ) {
ProtocolException.stringTooLong(, nameLen, );
}
obj.name = PacketIO.readVarString(buf, varPos1, PacketIO.UTF8);
}
((nullBits & ) != ) {
offset + + buf.getIntLE(offset + );
VarInt.peek(buf, varPos2);
(iconLen < ) {
ProtocolException.negativeLength(, iconLen);
}
(iconLen > ) {
ProtocolException.stringTooLong(, iconLen, );
}
obj.icon = PacketIO.readVarString(buf, varPos2, PacketIO.UTF8);
}
((nullBits & ) != ) {
offset + + buf.getIntLE(offset + );
VarInt.peek(buf, varPos3);
(childrenCount < ) {
ProtocolException.negativeLength(, childrenCount);
}
(childrenCount > ) {
ProtocolException.arrayTooLong(, childrenCount, );
}
VarInt.length(buf, varPos3);
(()(varPos3 + varIntLen) + ()childrenCount * > ()buf.readableBytes()) {
ProtocolException.bufferTooSmall(, varPos3 + varIntLen + childrenCount * , buf.readableBytes());
}
obj.children = [childrenCount];
varPos3 + varIntLen;
( ; i < childrenCount; ++i) {
obj.children[i] = deserialize(buf, elemPos);
elemPos += computeBytesConsumed(buf, elemPos);
}
}
obj;
}
{
buf.getByte(offset);
;
((nullBits & ) != ) {
buf.getIntLE(offset + );
offset + + fieldOffset0;
VarInt.peek(buf, pos0);
pos0 += VarInt.length(buf, pos0) + sl;
(pos0 - offset > maxEnd) {
maxEnd = pos0 - offset;
}
}
((nullBits & ) != ) {
buf.getIntLE(offset + );
offset + + fieldOffset1;
VarInt.peek(buf, pos1);
pos1 += VarInt.length(buf, pos1) + sl;
(pos1 - offset > maxEnd) {
maxEnd = pos1 - offset;
}
}
((nullBits & ) != ) {
buf.getIntLE(offset + );
offset + + fieldOffset2;
VarInt.peek(buf, pos2);
pos2 += VarInt.length(buf, pos2) + sl;
(pos2 - offset > maxEnd) {
maxEnd = pos2 - offset;
}
}
((nullBits & ) != ) {
buf.getIntLE(offset + );
offset + + fieldOffset3;
VarInt.peek(buf, pos3);
pos3 += VarInt.length(buf, pos3);
( ; i < arrLen; ++i) {
pos3 += computeBytesConsumed(buf, pos3);
}
(pos3 - offset > maxEnd) {
maxEnd = pos3 - offset;
}
}
maxEnd;
}
{
buf.writerIndex();
;
(.id != ) {
nullBits = ()(nullBits | );
}
(.name != ) {
nullBits = ()(nullBits | );
}
(.icon != ) {
nullBits = ()(nullBits | );
}
(.children != ) {
nullBits = ()(nullBits | );
}
buf.writeByte(nullBits);
buf.writeIntLE(.order);
buf.writeByte(.infoDisplayMode.getValue());
buf.writerIndex();
buf.writeIntLE();
buf.writerIndex();
buf.writeIntLE();
buf.writerIndex();
buf.writeIntLE();
buf.writerIndex();
buf.writeIntLE();
buf.writerIndex();
(.id != ) {
buf.setIntLE(idOffsetSlot, buf.writerIndex() - varBlockStart);
PacketIO.writeVarString(buf, .id, );
} {
buf.setIntLE(idOffsetSlot, -);
}
(.name != ) {
buf.setIntLE(nameOffsetSlot, buf.writerIndex() - varBlockStart);
PacketIO.writeVarString(buf, .name, );
} {
buf.setIntLE(nameOffsetSlot, -);
}
(.icon != ) {
buf.setIntLE(iconOffsetSlot, buf.writerIndex() - varBlockStart);
PacketIO.writeVarString(buf, .icon, );
} {
buf.setIntLE(iconOffsetSlot, -);
}
(.children != ) {
buf.setIntLE(childrenOffsetSlot, buf.writerIndex() - varBlockStart);
(.children.length > ) {
ProtocolException.arrayTooLong(, .children.length, );
}
VarInt.write(buf, .children.length);
(ItemCategory item : .children) {
item.serialize(buf);
}
} {
buf.setIntLE(childrenOffsetSlot, -);
}
}
{
;
(.id != ) {
size += PacketIO.stringSize(.id);
}
(.name != ) {
size += PacketIO.stringSize(.name);
}
(.icon != ) {
size += PacketIO.stringSize(.icon);
}
(.children != ) {
;
(ItemCategory elem : .children) {
childrenSize += elem.computeSize();
}
size += VarInt.size(.children.length) + childrenSize;
}
size;
}
ValidationResult {
(buffer.readableBytes() - offset < ) {
ValidationResult.error();
} {
buffer.getByte(offset);
((nullBits & ) != ) {
buffer.getIntLE(offset + );
(idOffset < ) {
ValidationResult.error();
}
offset + + idOffset;
(pos >= buffer.writerIndex()) {
ValidationResult.error();
}
VarInt.peek(buffer, pos);
(idLen < ) {
ValidationResult.error();
}
(idLen > ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
pos += idLen;
(pos > buffer.writerIndex()) {
ValidationResult.error();
}
}
((nullBits & ) != ) {
buffer.getIntLE(offset + );
(nameOffset < ) {
ValidationResult.error();
}
offset + + nameOffset;
(pos >= buffer.writerIndex()) {
ValidationResult.error();
}
VarInt.peek(buffer, pos);
(nameLen < ) {
ValidationResult.error();
}
(nameLen > ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
pos += nameLen;
(pos > buffer.writerIndex()) {
ValidationResult.error();
}
}
((nullBits & ) != ) {
buffer.getIntLE(offset + );
(iconOffset < ) {
ValidationResult.error();
}
offset + + iconOffset;
(pos >= buffer.writerIndex()) {
ValidationResult.error();
}
VarInt.peek(buffer, pos);
(iconLen < ) {
ValidationResult.error();
}
(iconLen > ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
pos += iconLen;
(pos > buffer.writerIndex()) {
ValidationResult.error();
}
}
((nullBits & ) != ) {
buffer.getIntLE(offset + );
(childrenOffset < ) {
ValidationResult.error();
}
offset + + childrenOffset;
(pos >= buffer.writerIndex()) {
ValidationResult.error();
}
VarInt.peek(buffer, pos);
(childrenCount < ) {
ValidationResult.error();
}
(childrenCount > ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
( ; i < childrenCount; ++i) {
validateStructure(buffer, pos);
(!structResult.isValid()) {
ValidationResult.error( + i + + structResult.error());
}
pos += computeBytesConsumed(buffer, pos);
}
}
ValidationResult.OK;
}
}
ItemCategory {
();
copy.id = .id;
copy.name = .name;
copy.icon = .icon;
copy.order = .order;
copy.infoDisplayMode = .infoDisplayMode;
copy.children = .children != ? (ItemCategory[])Arrays.stream(.children).map((e) -> e.clone()).toArray((x$) -> [x$]) : ;
copy;
}
{
( == obj) {
;
} (!(obj ItemCategory)) {
;
} {
(ItemCategory)obj;
Objects.equals(.id, other.id) && Objects.equals(.name, other.name) && Objects.equals(.icon, other.icon) && .order == other.order && Objects.equals(.infoDisplayMode, other.infoDisplayMode) && Arrays.equals(.children, other.children);
}
}
{
;
result = * result + Objects.hashCode(.id);
result = * result + Objects.hashCode(.name);
result = * result + Objects.hashCode(.icon);
result = * result + Integer.hashCode(.order);
result = * result + Objects.hashCode(.infoDisplayMode);
result = * result + Arrays.hashCode(.children);
result;
}
}