OpenWindow.java
package com.hypixel.hytale.protocol.packets.window;
import com.hypixel.hytale.protocol.ExtraResources;
import com.hypixel.hytale.protocol.InventorySection;
import com.hypixel.hytale.protocol.Packet;
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.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class OpenWindow implements Packet {
public static final int PACKET_ID = 200;
public static final boolean IS_COMPRESSED = true;
public static final int NULLABLE_BIT_FIELD_SIZE = 1;
public static ;
;
;
;
id;
WindowType windowType;
String windowData;
InventorySection inventory;
ExtraResources extraResources;
{
;
}
{
.windowType = WindowType.Container;
}
{
.windowType = WindowType.Container;
.id = id;
.windowType = windowType;
.windowData = windowData;
.inventory = inventory;
.extraResources = extraResources;
}
{
.windowType = WindowType.Container;
.id = other.id;
.windowType = other.windowType;
.windowData = other.windowData;
.inventory = other.inventory;
.extraResources = other.extraResources;
}
OpenWindow {
();
buf.getByte(offset);
obj.id = buf.getIntLE(offset + );
obj.windowType = WindowType.fromValue(buf.getByte(offset + ));
((nullBits & ) != ) {
offset + + buf.getIntLE(offset + );
VarInt.peek(buf, varPos0);
(windowDataLen < ) {
ProtocolException.negativeLength(, windowDataLen);
}
(windowDataLen > ) {
ProtocolException.stringTooLong(, windowDataLen, );
}
obj.windowData = PacketIO.readVarString(buf, varPos0, PacketIO.UTF8);
}
((nullBits & ) != ) {
offset + + buf.getIntLE(offset + );
obj.inventory = InventorySection.deserialize(buf, varPos1);
}
((nullBits & ) != ) {
offset + + buf.getIntLE(offset + );
obj.extraResources = ExtraResources.deserialize(buf, varPos2);
}
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;
pos1 += InventorySection.computeBytesConsumed(buf, pos1);
(pos1 - offset > maxEnd) {
maxEnd = pos1 - offset;
}
}
((nullBits & ) != ) {
buf.getIntLE(offset + );
offset + + fieldOffset2;
pos2 += ExtraResources.computeBytesConsumed(buf, pos2);
(pos2 - offset > maxEnd) {
maxEnd = pos2 - offset;
}
}
maxEnd;
}
{
buf.writerIndex();
;
(.windowData != ) {
nullBits = ()(nullBits | );
}
(.inventory != ) {
nullBits = ()(nullBits | );
}
(.extraResources != ) {
nullBits = ()(nullBits | );
}
buf.writeByte(nullBits);
buf.writeIntLE(.id);
buf.writeByte(.windowType.getValue());
buf.writerIndex();
buf.writeIntLE();
buf.writerIndex();
buf.writeIntLE();
buf.writerIndex();
buf.writeIntLE();
buf.writerIndex();
(.windowData != ) {
buf.setIntLE(windowDataOffsetSlot, buf.writerIndex() - varBlockStart);
PacketIO.writeVarString(buf, .windowData, );
} {
buf.setIntLE(windowDataOffsetSlot, -);
}
(.inventory != ) {
buf.setIntLE(inventoryOffsetSlot, buf.writerIndex() - varBlockStart);
.inventory.serialize(buf);
} {
buf.setIntLE(inventoryOffsetSlot, -);
}
(.extraResources != ) {
buf.setIntLE(extraResourcesOffsetSlot, buf.writerIndex() - varBlockStart);
.extraResources.serialize(buf);
} {
buf.setIntLE(extraResourcesOffsetSlot, -);
}
}
{
;
(.windowData != ) {
size += PacketIO.stringSize(.windowData);
}
(.inventory != ) {
size += .inventory.computeSize();
}
(.extraResources != ) {
size += .extraResources.computeSize();
}
size;
}
ValidationResult {
(buffer.readableBytes() - offset < ) {
ValidationResult.error();
} {
buffer.getByte(offset);
((nullBits & ) != ) {
buffer.getIntLE(offset + );
(windowDataOffset < ) {
ValidationResult.error();
}
offset + + windowDataOffset;
(pos >= buffer.writerIndex()) {
ValidationResult.error();
}
VarInt.peek(buffer, pos);
(windowDataLen < ) {
ValidationResult.error();
}
(windowDataLen > ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
pos += windowDataLen;
(pos > buffer.writerIndex()) {
ValidationResult.error();
}
}
((nullBits & ) != ) {
buffer.getIntLE(offset + );
(inventoryOffset < ) {
ValidationResult.error();
}
offset + + inventoryOffset;
(pos >= buffer.writerIndex()) {
ValidationResult.error();
}
InventorySection.validateStructure(buffer, pos);
(!inventoryResult.isValid()) {
ValidationResult.error( + inventoryResult.error());
}
pos += InventorySection.computeBytesConsumed(buffer, pos);
}
((nullBits & ) != ) {
buffer.getIntLE(offset + );
(extraResourcesOffset < ) {
ValidationResult.error();
}
offset + + extraResourcesOffset;
(pos >= buffer.writerIndex()) {
ValidationResult.error();
}
ExtraResources.validateStructure(buffer, pos);
(!extraResourcesResult.isValid()) {
ValidationResult.error( + extraResourcesResult.error());
}
pos += ExtraResources.computeBytesConsumed(buffer, pos);
}
ValidationResult.OK;
}
}
OpenWindow {
();
copy.id = .id;
copy.windowType = .windowType;
copy.windowData = .windowData;
copy.inventory = .inventory != ? .inventory.clone() : ;
copy.extraResources = .extraResources != ? .extraResources.clone() : ;
copy;
}
{
( == obj) {
;
} (!(obj OpenWindow)) {
;
} {
(OpenWindow)obj;
.id == other.id && Objects.equals(.windowType, other.windowType) && Objects.equals(.windowData, other.windowData) && Objects.equals(.inventory, other.inventory) && Objects.equals(.extraResources, other.extraResources);
}
}
{
Objects.hash( []{.id, .windowType, .windowData, .inventory, .extraResources});
}
}