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

package com.hypixel.hytale.server.worldgen.util;

import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import java.util.Arrays;
import com.hypixel.hytale.math.util.MathUtil;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import javax.annotation.Nonnull;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;

public final class ResolvedBlockArray
{
    public static final ResolvedBlockArray EMPTY;
    public static final Long2ObjectMap<ResolvedBlockArray> RESOLVED_BLOCKS;
    public static final Long2ObjectMap<ResolvedBlockArray> RESOLVED_BLOCKS_WITH_VARIANTS;
    @Nonnull
    private final LongSet entrySet;
    @Nonnull
    private final BlockFluidEntry[] entries;
    
    public ResolvedBlockArray(@Nonnull final BlockFluidEntry[] entries) {
        this.entries = entries;
        this.entrySet = new LongOpenHashSet();
        for (final BlockFluidEntry entry : entries) {
            this.entrySet.add(MathUtil.packLong(entry.blockId(), entry.fluidId()));
        }
    }
    
    @Nonnull
    public BlockFluidEntry[] getEntries() {
        return this.entries;
    }
    
    @Nonnull
    public LongSet getEntrySet() {
        return this.entrySet;
    }
    
    public int size() {
        return this.entries.length;
    }
    
    public boolean contains(final int block, final int fluidId) {
        return this.entrySet.contains(MathUtil.packLong(block, fluidId));
    }
    
    @Override
    public boolean equals(final Object o) {
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        final ResolvedBlockArray that = (ResolvedBlockArray)o;
        return this.entrySet.equals(that.entrySet) && Arrays.deepEquals(this.entries, that.entries);
    }
    
    @Override
    public int hashCode() {
        int result = this.entrySet.hashCode();
        result = 31 * result + Arrays.hashCode(this.entries);
        return result;
    }
    
    @Nonnull
    @Override
    public String toString() {
        return "ResolvedBlockArray{entrySet=" + String.valueOf(this.entrySet) + ", entries=" + Arrays.toString(this.entries);
    }
    
    static {
        EMPTY = new ResolvedBlockArray(BlockFluidEntry.EMPTY_ARRAY);
        RESOLVED_BLOCKS = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<ResolvedBlockArray>());
        RESOLVED_BLOCKS_WITH_VARIANTS = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<ResolvedBlockArray>());
    }
}
