UpdateInteractions.java
package com.hypixel.hytale.protocol.packets.assets;
import com.hypixel.hytale.protocol.Interaction;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.protocol.UpdateType;
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.HashMap;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class UpdateInteractions implements Packet {
public static final int PACKET_ID = 66;
public static final boolean IS_COMPRESSED = true;
public static final int NULLABLE_BIT_FIELD_SIZE = 1;
public ;
;
;
;
UpdateType type;
maxId;
Map<Integer, Interaction> interactions;
{
;
}
{
.type = UpdateType.Init;
}
{
.type = UpdateType.Init;
.type = type;
.maxId = maxId;
.interactions = interactions;
}
{
.type = UpdateType.Init;
.type = other.type;
.maxId = other.maxId;
.interactions = other.interactions;
}
UpdateInteractions {
();
buf.getByte(offset);
obj.type = UpdateType.fromValue(buf.getByte(offset + ));
obj.maxId = buf.getIntLE(offset + );
offset + ;
((nullBits & ) != ) {
VarInt.peek(buf, pos);
(interactionsCount < ) {
ProtocolException.negativeLength(, interactionsCount);
}
(interactionsCount > ) {
ProtocolException.dictionaryTooLarge(, interactionsCount, );
}
pos += VarInt.size(interactionsCount);
obj.interactions = (interactionsCount);
( ; i < interactionsCount; ++i) {
buf.getIntLE(pos);
pos += ;
Interaction.deserialize(buf, pos);
pos += Interaction.computeBytesConsumed(buf, pos);
(obj.interactions.put(key, val) != ) {
ProtocolException.duplicateKey(, key);
}
}
}
obj;
}
{
buf.getByte(offset);
offset + ;
((nullBits & ) != ) {
VarInt.peek(buf, pos);
pos += VarInt.length(buf, pos);
( ; i < dictLen; ++i) {
pos += ;
pos += Interaction.computeBytesConsumed(buf, pos);
}
}
pos - offset;
}
{
;
(.interactions != ) {
nullBits = ()(nullBits | );
}
buf.writeByte(nullBits);
buf.writeByte(.type.getValue());
buf.writeIntLE(.maxId);
(.interactions != ) {
(.interactions.size() > ) {
ProtocolException.dictionaryTooLarge(, .interactions.size(), );
}
VarInt.write(buf, .interactions.size());
(Map.Entry<Integer, Interaction> e : .interactions.entrySet()) {
buf.writeIntLE((Integer)e.getKey());
((Interaction)e.getValue()).serializeWithTypeId(buf);
}
}
}
{
;
(.interactions != ) {
;
(Map.Entry<Integer, Interaction> kvp : .interactions.entrySet()) {
interactionsSize += + ((Interaction)kvp.getValue()).computeSizeWithTypeId();
}
size += VarInt.size(.interactions.size()) + interactionsSize;
}
size;
}
ValidationResult {
(buffer.readableBytes() - offset < ) {
ValidationResult.error();
} {
buffer.getByte(offset);
offset + ;
((nullBits & ) != ) {
VarInt.peek(buffer, pos);
(interactionsCount < ) {
ValidationResult.error();
}
(interactionsCount > ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
( ; i < interactionsCount; ++i) {
pos += ;
(pos > buffer.writerIndex()) {
ValidationResult.error();
}
pos += Interaction.computeBytesConsumed(buffer, pos);
}
}
ValidationResult.OK;
}
}
UpdateInteractions {
();
copy.type = .type;
copy.maxId = .maxId;
copy.interactions = .interactions != ? (.interactions) : ;
copy;
}
{
( == obj) {
;
} (!(obj UpdateInteractions)) {
;
} {
(UpdateInteractions)obj;
Objects.equals(.type, other.type) && .maxId == other.maxId && Objects.equals(.interactions, other.interactions);
}
}
{
Objects.hash( []{.type, .maxId, .interactions});
}
}