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