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

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

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 BuilderToolSelectionUpdate implements Packet
{
    public static final int PACKET_ID = 409;
    public static final boolean IS_COMPRESSED = false;
    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 xMin;
    public int yMin;
    public int zMin;
    public int xMax;
    public int yMax;
    public int zMax;
    
    @Override
    public int getId() {
        return 409;
    }
    
    public BuilderToolSelectionUpdate() {
    }
    
    public BuilderToolSelectionUpdate(final int xMin, final int yMin, final int zMin, final int xMax, final int yMax, final int zMax) {
        this.xMin = xMin;
        this.yMin = yMin;
        this.zMin = zMin;
        this.xMax = xMax;
        this.yMax = yMax;
        this.zMax = zMax;
    }
    
    public BuilderToolSelectionUpdate(@Nonnull final BuilderToolSelectionUpdate other) {
        this.xMin = other.xMin;
        this.yMin = other.yMin;
        this.zMin = other.zMin;
        this.xMax = other.xMax;
        this.yMax = other.yMax;
        this.zMax = other.zMax;
    }
    
    @Nonnull
    public static BuilderToolSelectionUpdate deserialize(@Nonnull final ByteBuf buf, final int offset) {
        final BuilderToolSelectionUpdate obj = new BuilderToolSelectionUpdate();
        obj.xMin = buf.getIntLE(offset + 0);
        obj.yMin = buf.getIntLE(offset + 4);
        obj.zMin = buf.getIntLE(offset + 8);
        obj.xMax = buf.getIntLE(offset + 12);
        obj.yMax = buf.getIntLE(offset + 16);
        obj.zMax = buf.getIntLE(offset + 20);
        return obj;
    }
    
    public static int computeBytesConsumed(@Nonnull final ByteBuf buf, final int offset) {
        return 24;
    }
    
    @Override
    public void serialize(@Nonnull final ByteBuf buf) {
        buf.writeIntLE(this.xMin);
        buf.writeIntLE(this.yMin);
        buf.writeIntLE(this.zMin);
        buf.writeIntLE(this.xMax);
        buf.writeIntLE(this.yMax);
        buf.writeIntLE(this.zMax);
    }
    
    @Override
    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 BuilderToolSelectionUpdate clone() {
        final BuilderToolSelectionUpdate copy = new BuilderToolSelectionUpdate();
        copy.xMin = this.xMin;
        copy.yMin = this.yMin;
        copy.zMin = this.zMin;
        copy.xMax = this.xMax;
        copy.yMax = this.yMax;
        copy.zMax = this.zMax;
        return copy;
    }
    
    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof final BuilderToolSelectionUpdate other) {
            return this.xMin == other.xMin && this.yMin == other.yMin && this.zMin == other.zMin && this.xMax == other.xMax && this.yMax == other.yMax && this.zMax == other.zMax;
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.xMin, this.yMin, this.zMin, this.xMax, this.yMax, this.zMax);
    }
}
