// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.protocol;

import java.util.Objects;
import com.hypixel.hytale.protocol.io.ValidationResult;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;

public class ParticleCollision
{
    public static final int NULLABLE_BIT_FIELD_SIZE = 0;
    public static final int FIXED_BLOCK_SIZE = 3;
    public static final int VARIABLE_FIELD_COUNT = 0;
    public static final int VARIABLE_BLOCK_START = 3;
    public static final int MAX_SIZE = 3;
    @Nonnull
    public ParticleCollisionBlockType blockType;
    @Nonnull
    public ParticleCollisionAction action;
    @Nonnull
    public ParticleRotationInfluence particleRotationInfluence;
    
    public ParticleCollision() {
        this.blockType = ParticleCollisionBlockType.None;
        this.action = ParticleCollisionAction.Expire;
        this.particleRotationInfluence = ParticleRotationInfluence.None;
    }
    
    public ParticleCollision(@Nonnull final ParticleCollisionBlockType blockType, @Nonnull final ParticleCollisionAction action, @Nonnull final ParticleRotationInfluence particleRotationInfluence) {
        this.blockType = ParticleCollisionBlockType.None;
        this.action = ParticleCollisionAction.Expire;
        this.particleRotationInfluence = ParticleRotationInfluence.None;
        this.blockType = blockType;
        this.action = action;
        this.particleRotationInfluence = particleRotationInfluence;
    }
    
    public ParticleCollision(@Nonnull final ParticleCollision other) {
        this.blockType = ParticleCollisionBlockType.None;
        this.action = ParticleCollisionAction.Expire;
        this.particleRotationInfluence = ParticleRotationInfluence.None;
        this.blockType = other.blockType;
        this.action = other.action;
        this.particleRotationInfluence = other.particleRotationInfluence;
    }
    
    @Nonnull
    public static ParticleCollision deserialize(@Nonnull final ByteBuf buf, final int offset) {
        final ParticleCollision obj = new ParticleCollision();
        obj.blockType = ParticleCollisionBlockType.fromValue(buf.getByte(offset + 0));
        obj.action = ParticleCollisionAction.fromValue(buf.getByte(offset + 1));
        obj.particleRotationInfluence = ParticleRotationInfluence.fromValue(buf.getByte(offset + 2));
        return obj;
    }
    
    public static int computeBytesConsumed(@Nonnull final ByteBuf buf, final int offset) {
        return 3;
    }
    
    public void serialize(@Nonnull final ByteBuf buf) {
        buf.writeByte(this.blockType.getValue());
        buf.writeByte(this.action.getValue());
        buf.writeByte(this.particleRotationInfluence.getValue());
    }
    
    public int computeSize() {
        return 3;
    }
    
    public static ValidationResult validateStructure(@Nonnull final ByteBuf buffer, final int offset) {
        if (buffer.readableBytes() - offset < 3) {
            return ValidationResult.error("Buffer too small: expected at least 3 bytes");
        }
        return ValidationResult.OK;
    }
    
    public ParticleCollision clone() {
        final ParticleCollision copy = new ParticleCollision();
        copy.blockType = this.blockType;
        copy.action = this.action;
        copy.particleRotationInfluence = this.particleRotationInfluence;
        return copy;
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof final ParticleCollision other) {
            return Objects.equals(this.blockType, other.blockType) && Objects.equals(this.action, other.action) && Objects.equals(this.particleRotationInfluence, other.particleRotationInfluence);
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.blockType, this.action, this.particleRotationInfluence);
    }
}
