DamageEffects.java
package com.hypixel.hytale.protocol;
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 DamageEffects {
public static final int NULLABLE_BIT_FIELD_SIZE = 1;
public static final int FIXED_BLOCK_SIZE = 5;
public static final int VARIABLE_FIELD_COUNT = 2;
public static final int VARIABLE_BLOCK_START = 13;
public static final int MAX_SIZE ;
ModelParticle[] modelParticles;
WorldParticle[] worldParticles;
soundEventIndex;
{
}
{
.modelParticles = modelParticles;
.worldParticles = worldParticles;
.soundEventIndex = soundEventIndex;
}
{
.modelParticles = other.modelParticles;
.worldParticles = other.worldParticles;
.soundEventIndex = other.soundEventIndex;
}
DamageEffects {
();
buf.getByte(offset);
obj.soundEventIndex = buf.getIntLE(offset + );
((nullBits & ) != ) {
offset + + buf.getIntLE(offset + );
VarInt.peek(buf, varPos0);
(modelParticlesCount < ) {
ProtocolException.negativeLength(, modelParticlesCount);
}
(modelParticlesCount > ) {
ProtocolException.arrayTooLong(, modelParticlesCount, );
}
VarInt.length(buf, varPos0);
(()(varPos0 + varIntLen) + ()modelParticlesCount * > ()buf.readableBytes()) {
ProtocolException.bufferTooSmall(, varPos0 + varIntLen + modelParticlesCount * , buf.readableBytes());
}
obj.modelParticles = [modelParticlesCount];
varPos0 + varIntLen;
( ; i < modelParticlesCount; ++i) {
obj.modelParticles[i] = ModelParticle.deserialize(buf, elemPos);
elemPos += ModelParticle.computeBytesConsumed(buf, elemPos);
}
}
((nullBits & ) != ) {
offset + + buf.getIntLE(offset + );
VarInt.peek(buf, varPos1);
(worldParticlesCount < ) {
ProtocolException.negativeLength(, worldParticlesCount);
}
(worldParticlesCount > ) {
ProtocolException.arrayTooLong(, worldParticlesCount, );
}
VarInt.length(buf, varPos1);
(()(varPos1 + varIntLen) + ()worldParticlesCount * > ()buf.readableBytes()) {
ProtocolException.bufferTooSmall(, varPos1 + varIntLen + worldParticlesCount * , buf.readableBytes());
}
obj.worldParticles = [worldParticlesCount];
varPos1 + varIntLen;
( ; i < worldParticlesCount; ++i) {
obj.worldParticles[i] = WorldParticle.deserialize(buf, elemPos);
elemPos += WorldParticle.computeBytesConsumed(buf, elemPos);
}
}
obj;
}
{
buf.getByte(offset);
;
((nullBits & ) != ) {
buf.getIntLE(offset + );
offset + + fieldOffset0;
VarInt.peek(buf, pos0);
pos0 += VarInt.length(buf, pos0);
( ; i < arrLen; ++i) {
pos0 += ModelParticle.computeBytesConsumed(buf, pos0);
}
(pos0 - offset > maxEnd) {
maxEnd = pos0 - offset;
}
}
((nullBits & ) != ) {
buf.getIntLE(offset + );
offset + + fieldOffset1;
VarInt.peek(buf, pos1);
pos1 += VarInt.length(buf, pos1);
( ; i < arrLen; ++i) {
pos1 += WorldParticle.computeBytesConsumed(buf, pos1);
}
(pos1 - offset > maxEnd) {
maxEnd = pos1 - offset;
}
}
maxEnd;
}
{
buf.writerIndex();
;
(.modelParticles != ) {
nullBits = ()(nullBits | );
}
(.worldParticles != ) {
nullBits = ()(nullBits | );
}
buf.writeByte(nullBits);
buf.writeIntLE(.soundEventIndex);
buf.writerIndex();
buf.writeIntLE();
buf.writerIndex();
buf.writeIntLE();
buf.writerIndex();
(.modelParticles != ) {
buf.setIntLE(modelParticlesOffsetSlot, buf.writerIndex() - varBlockStart);
(.modelParticles.length > ) {
ProtocolException.arrayTooLong(, .modelParticles.length, );
}
VarInt.write(buf, .modelParticles.length);
(ModelParticle item : .modelParticles) {
item.serialize(buf);
}
} {
buf.setIntLE(modelParticlesOffsetSlot, -);
}
(.worldParticles != ) {
buf.setIntLE(worldParticlesOffsetSlot, buf.writerIndex() - varBlockStart);
(.worldParticles.length > ) {
ProtocolException.arrayTooLong(, .worldParticles.length, );
}
VarInt.write(buf, .worldParticles.length);
(WorldParticle item : .worldParticles) {
item.serialize(buf);
}
} {
buf.setIntLE(worldParticlesOffsetSlot, -);
}
}
{
;
(.modelParticles != ) {
;
(ModelParticle elem : .modelParticles) {
modelParticlesSize += elem.computeSize();
}
size += VarInt.size(.modelParticles.length) + modelParticlesSize;
}
(.worldParticles != ) {
;
(WorldParticle elem : .worldParticles) {
worldParticlesSize += elem.computeSize();
}
size += VarInt.size(.worldParticles.length) + worldParticlesSize;
}
size;
}
ValidationResult {
(buffer.readableBytes() - offset < ) {
ValidationResult.error();
} {
buffer.getByte(offset);
((nullBits & ) != ) {
buffer.getIntLE(offset + );
(modelParticlesOffset < ) {
ValidationResult.error();
}
offset + + modelParticlesOffset;
(pos >= buffer.writerIndex()) {
ValidationResult.error();
}
VarInt.peek(buffer, pos);
(modelParticlesCount < ) {
ValidationResult.error();
}
(modelParticlesCount > ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
( ; i < modelParticlesCount; ++i) {
ModelParticle.validateStructure(buffer, pos);
(!structResult.isValid()) {
ValidationResult.error( + i + + structResult.error());
}
pos += ModelParticle.computeBytesConsumed(buffer, pos);
}
}
((nullBits & ) != ) {
buffer.getIntLE(offset + );
(worldParticlesOffset < ) {
ValidationResult.error();
}
offset + + worldParticlesOffset;
(pos >= buffer.writerIndex()) {
ValidationResult.error();
}
VarInt.peek(buffer, pos);
(worldParticlesCount < ) {
ValidationResult.error();
}
(worldParticlesCount > ) {
ValidationResult.error();
}
pos += VarInt.length(buffer, pos);
( ; i < worldParticlesCount; ++i) {
WorldParticle.validateStructure(buffer, pos);
(!structResult.isValid()) {
ValidationResult.error( + i + + structResult.error());
}
pos += WorldParticle.computeBytesConsumed(buffer, pos);
}
}
ValidationResult.OK;
}
}
DamageEffects {
();
copy.modelParticles = .modelParticles != ? (ModelParticle[])Arrays.stream(.modelParticles).map((e) -> e.clone()).toArray((x$) -> [x$]) : ;
copy.worldParticles = .worldParticles != ? (WorldParticle[])Arrays.stream(.worldParticles).map((e) -> e.clone()).toArray((x$) -> [x$]) : ;
copy.soundEventIndex = .soundEventIndex;
copy;
}
{
( == obj) {
;
} (!(obj DamageEffects)) {
;
} {
(DamageEffects)obj;
Arrays.equals(.modelParticles, other.modelParticles) && Arrays.equals(.worldParticles, other.worldParticles) && .soundEventIndex == other.soundEventIndex;
}
}
{
;
result = * result + Arrays.hashCode(.modelParticles);
result = * result + Arrays.hashCode(.worldParticles);
result = * result + Integer.hashCode(.soundEventIndex);
result;
}
}