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

package com.hypixel.hytale.protocol.packets.world;

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

public class SetFluidCmd
{
    public static final int NULLABLE_BIT_FIELD_SIZE = 0;
    public static final int FIXED_BLOCK_SIZE = 7;
    public static final int VARIABLE_FIELD_COUNT = 0;
    public static final int VARIABLE_BLOCK_START = 7;
    public static final int MAX_SIZE = 7;
    public short index;
    public int fluidId;
    public byte fluidLevel;
    
    public SetFluidCmd() {
    }
    
    public SetFluidCmd(final short index, final int fluidId, final byte fluidLevel) {
        this.index = index;
        this.fluidId = fluidId;
        this.fluidLevel = fluidLevel;
    }
    
    public SetFluidCmd(@Nonnull final SetFluidCmd other) {
        this.index = other.index;
        this.fluidId = other.fluidId;
        this.fluidLevel = other.fluidLevel;
    }
    
    @Nonnull
    public static SetFluidCmd deserialize(@Nonnull final ByteBuf buf, final int offset) {
        final SetFluidCmd obj = new SetFluidCmd();
        obj.index = buf.getShortLE(offset + 0);
        obj.fluidId = buf.getIntLE(offset + 2);
        obj.fluidLevel = buf.getByte(offset + 6);
        return obj;
    }
    
    public static int computeBytesConsumed(@Nonnull final ByteBuf buf, final int offset) {
        return 7;
    }
    
    public void serialize(@Nonnull final ByteBuf buf) {
        buf.writeShortLE(this.index);
        buf.writeIntLE(this.fluidId);
        buf.writeByte(this.fluidLevel);
    }
    
    public int computeSize() {
        return 7;
    }
    
    public static ValidationResult validateStructure(@Nonnull final ByteBuf buffer, final int offset) {
        if (buffer.readableBytes() - offset < 7) {
            return ValidationResult.error("Buffer too small: expected at least 7 bytes");
        }
        return ValidationResult.OK;
    }
    
    public SetFluidCmd clone() {
        final SetFluidCmd copy = new SetFluidCmd();
        copy.index = this.index;
        copy.fluidId = this.fluidId;
        copy.fluidLevel = this.fluidLevel;
        return copy;
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof final SetFluidCmd other) {
            return this.index == other.index && this.fluidId == other.fluidId && this.fluidLevel == other.fluidLevel;
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.index, this.fluidId, this.fluidLevel);
    }
}
