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

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

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

public class MountNPC implements Packet
{
    public static final int PACKET_ID = 293;
    public static final boolean IS_COMPRESSED = false;
    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 anchorX;
    public float anchorY;
    public float anchorZ;
    public int entityId;
    
    @Override
    public int getId() {
        return 293;
    }
    
    public MountNPC() {
    }
    
    public MountNPC(final float anchorX, final float anchorY, final float anchorZ, final int entityId) {
        this.anchorX = anchorX;
        this.anchorY = anchorY;
        this.anchorZ = anchorZ;
        this.entityId = entityId;
    }
    
    public MountNPC(@Nonnull final MountNPC other) {
        this.anchorX = other.anchorX;
        this.anchorY = other.anchorY;
        this.anchorZ = other.anchorZ;
        this.entityId = other.entityId;
    }
    
    @Nonnull
    public static MountNPC deserialize(@Nonnull final ByteBuf buf, final int offset) {
        final MountNPC obj = new MountNPC();
        obj.anchorX = buf.getFloatLE(offset + 0);
        obj.anchorY = buf.getFloatLE(offset + 4);
        obj.anchorZ = buf.getFloatLE(offset + 8);
        obj.entityId = buf.getIntLE(offset + 12);
        return obj;
    }
    
    public static int computeBytesConsumed(@Nonnull final ByteBuf buf, final int offset) {
        return 16;
    }
    
    @Override
    public void serialize(@Nonnull final ByteBuf buf) {
        buf.writeFloatLE(this.anchorX);
        buf.writeFloatLE(this.anchorY);
        buf.writeFloatLE(this.anchorZ);
        buf.writeIntLE(this.entityId);
    }
    
    @Override
    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 MountNPC clone() {
        final MountNPC copy = new MountNPC();
        copy.anchorX = this.anchorX;
        copy.anchorY = this.anchorY;
        copy.anchorZ = this.anchorZ;
        copy.entityId = this.entityId;
        return copy;
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof final MountNPC other) {
            return this.anchorX == other.anchorX && this.anchorY == other.anchorY && this.anchorZ == other.anchorZ && this.entityId == other.entityId;
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.anchorX, this.anchorY, this.anchorZ, this.entityId);
    }
}
