// 
// 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 Tint
{
    public static final int NULLABLE_BIT_FIELD_SIZE = 0;
    public static final int FIXED_BLOCK_SIZE = 24;
    public static final int VARIABLE_FIELD_COUNT = 0;
    public static final int VARIABLE_BLOCK_START = 24;
    public static final int MAX_SIZE = 24;
    public int top;
    public int bottom;
    public int front;
    public int back;
    public int left;
    public int right;
    
    public Tint() {
    }
    
    public Tint(final int top, final int bottom, final int front, final int back, final int left, final int right) {
        this.top = top;
        this.bottom = bottom;
        this.front = front;
        this.back = back;
        this.left = left;
        this.right = right;
    }
    
    public Tint(@Nonnull final Tint other) {
        this.top = other.top;
        this.bottom = other.bottom;
        this.front = other.front;
        this.back = other.back;
        this.left = other.left;
        this.right = other.right;
    }
    
    @Nonnull
    public static Tint deserialize(@Nonnull final ByteBuf buf, final int offset) {
        final Tint obj = new Tint();
        obj.top = buf.getIntLE(offset + 0);
        obj.bottom = buf.getIntLE(offset + 4);
        obj.front = buf.getIntLE(offset + 8);
        obj.back = buf.getIntLE(offset + 12);
        obj.left = buf.getIntLE(offset + 16);
        obj.right = buf.getIntLE(offset + 20);
        return obj;
    }
    
    public static int computeBytesConsumed(@Nonnull final ByteBuf buf, final int offset) {
        return 24;
    }
    
    public void serialize(@Nonnull final ByteBuf buf) {
        buf.writeIntLE(this.top);
        buf.writeIntLE(this.bottom);
        buf.writeIntLE(this.front);
        buf.writeIntLE(this.back);
        buf.writeIntLE(this.left);
        buf.writeIntLE(this.right);
    }
    
    public int computeSize() {
        return 24;
    }
    
    public static ValidationResult validateStructure(@Nonnull final ByteBuf buffer, final int offset) {
        if (buffer.readableBytes() - offset < 24) {
            return ValidationResult.error("Buffer too small: expected at least 24 bytes");
        }
        return ValidationResult.OK;
    }
    
    public Tint clone() {
        final Tint copy = new Tint();
        copy.top = this.top;
        copy.bottom = this.bottom;
        copy.front = this.front;
        copy.back = this.back;
        copy.left = this.left;
        copy.right = this.right;
        return copy;
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof final Tint other) {
            return this.top == other.top && this.bottom == other.bottom && this.front == other.front && this.back == other.back && this.left == other.left && this.right == other.right;
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.top, this.bottom, this.front, this.back, this.left, this.right);
    }
}
