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