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

package com.hypixel.hytale.server.core.universe.world.chunk;

import com.hypixel.hytale.component.Store;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.component.ComponentType;
import javax.annotation.Nullable;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.component.Component;

@Deprecated
public class ChunkColumn implements Component<ChunkStore>
{
    public static final BuilderCodec<ChunkColumn> CODEC;
    private final Ref<ChunkStore>[] sections;
    @Nullable
    private Holder<ChunkStore>[] sectionHolders;
    
    public static ComponentType<ChunkStore, ChunkColumn> getComponentType() {
        return LegacyModule.get().getChunkColumnComponentType();
    }
    
    public ChunkColumn() {
        this.sections = new Ref[10];
    }
    
    public ChunkColumn(final Holder<ChunkStore>[] sectionHolders) {
        this.sections = new Ref[10];
        this.sectionHolders = sectionHolders;
    }
    
    @Nullable
    public Ref<ChunkStore> getSection(final int section) {
        if (section < 0 || section >= this.sections.length) {
            return null;
        }
        return this.sections[section];
    }
    
    @Nonnull
    public Ref<ChunkStore>[] getSections() {
        return this.sections;
    }
    
    @Nullable
    public Holder<ChunkStore>[] getSectionHolders() {
        return this.sectionHolders;
    }
    
    @Nullable
    public Holder<ChunkStore>[] takeSectionHolders() {
        final Holder<ChunkStore>[] temp = this.sectionHolders;
        this.sectionHolders = null;
        return temp;
    }
    
    public void putSectionHolders(final Holder<ChunkStore>[] holders) {
        this.sectionHolders = holders;
    }
    
    @Nonnull
    @Override
    public Component<ChunkStore> clone() {
        final ChunkColumn newChunk = new ChunkColumn();
        int length = this.sections.length;
        if (this.sectionHolders != null) {
            length = Math.max(this.sectionHolders.length, this.sections.length);
        }
        final Holder<ChunkStore>[] holders = new Holder[length];
        if (this.sectionHolders != null) {
            for (int i = 0; i < this.sectionHolders.length; ++i) {
                final Holder<ChunkStore> sectionHolder = this.sectionHolders[i];
                if (sectionHolder != null) {
                    holders[i] = sectionHolder.clone();
                }
            }
        }
        for (int i = 0; i < this.sections.length; ++i) {
            final Ref<ChunkStore> section = this.sections[i];
            if (section != null) {
                holders[i] = section.getStore().copyEntity(section);
            }
        }
        newChunk.sectionHolders = holders;
        return newChunk;
    }
    
    @Nonnull
    @Override
    public Component<ChunkStore> cloneSerializable() {
        final ChunkColumn newChunk = new ChunkColumn();
        int length = this.sections.length;
        if (this.sectionHolders != null) {
            length = Math.max(this.sectionHolders.length, this.sections.length);
        }
        final Holder<ChunkStore>[] holders = new Holder[length];
        if (this.sectionHolders != null) {
            for (int i = 0; i < this.sectionHolders.length; ++i) {
                final Holder<ChunkStore> sectionHolder = this.sectionHolders[i];
                if (sectionHolder != null) {
                    holders[i] = sectionHolder.clone();
                }
            }
        }
        for (int i = 0; i < this.sections.length; ++i) {
            final Ref<ChunkStore> section = this.sections[i];
            if (section != null) {
                holders[i] = section.getStore().copySerializableEntity(section);
            }
        }
        newChunk.sectionHolders = holders;
        return newChunk;
    }
    
    static {
        // 
        // This method could not be decompiled.
        // 
        // Original Bytecode:
        // 
        //     2: invokedynamic   BootstrapMethod #0, get:()Ljava/util/function/Supplier;
        //     7: invokestatic    com/hypixel/hytale/codec/builder/BuilderCodec.builder:(Ljava/lang/Class;Ljava/util/function/Supplier;)Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //    10: new             Lcom/hypixel/hytale/codec/KeyedCodec;
        //    13: dup            
        //    14: ldc             "Sections"
        //    16: new             Lcom/hypixel/hytale/codec/codecs/array/ArrayCodec;
        //    19: dup            
        //    20: new             Lcom/hypixel/hytale/codec/store/StoredCodec;
        //    23: dup            
        //    24: getstatic       com/hypixel/hytale/server/core/universe/world/storage/ChunkStore.HOLDER_CODEC_KEY:Lcom/hypixel/hytale/codec/store/CodecKey;
        //    27: invokespecial   com/hypixel/hytale/codec/store/StoredCodec.<init>:(Lcom/hypixel/hytale/codec/store/CodecKey;)V
        //    30: invokedynamic   BootstrapMethod #1, apply:()Ljava/util/function/IntFunction;
        //    35: invokespecial   com/hypixel/hytale/codec/codecs/array/ArrayCodec.<init>:(Lcom/hypixel/hytale/codec/Codec;Ljava/util/function/IntFunction;)V
        //    38: invokespecial   com/hypixel/hytale/codec/KeyedCodec.<init>:(Ljava/lang/String;Lcom/hypixel/hytale/codec/Codec;)V
        //    41: invokedynamic   BootstrapMethod #2, accept:()Ljava/util/function/BiConsumer;
        //    46: invokedynamic   BootstrapMethod #3, apply:()Ljava/util/function/Function;
        //    51: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.append:(Lcom/hypixel/hytale/codec/KeyedCodec;Ljava/util/function/BiConsumer;Ljava/util/function/Function;)Lcom/hypixel/hytale/codec/builder/BuilderField$FieldBuilder;
        //    54: invokevirtual   com/hypixel/hytale/codec/builder/BuilderField$FieldBuilder.add:()Lcom/hypixel/hytale/codec/builder/BuilderCodec$BuilderBase;
        //    57: checkcast       Lcom/hypixel/hytale/codec/builder/BuilderCodec$Builder;
        //    60: invokevirtual   com/hypixel/hytale/codec/builder/BuilderCodec$Builder.build:()Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //    63: putstatic       com/hypixel/hytale/server/core/universe/world/chunk/ChunkColumn.CODEC:Lcom/hypixel/hytale/codec/builder/BuilderCodec;
        //    66: return         
        // 
        // The error that occurred was:
        // 
        // java.lang.UnsupportedOperationException: The requested operation is not supported.
        //     at com.strobel.util.ContractUtils.unsupported(ContractUtils.java:27)
        //     at com.strobel.assembler.metadata.TypeReference.getRawType(TypeReference.java:284)
        //     at com.strobel.assembler.metadata.TypeReference.getRawType(TypeReference.java:279)
        //     at com.strobel.assembler.metadata.TypeReference.makeGenericType(TypeReference.java:154)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:225)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:25)
        //     at com.strobel.assembler.metadata.ParameterizedType.accept(ParameterizedType.java:103)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visit(TypeSubstitutionVisitor.java:40)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:211)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitParameterizedType(TypeSubstitutionVisitor.java:25)
        //     at com.strobel.assembler.metadata.ParameterizedType.accept(ParameterizedType.java:103)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visit(TypeSubstitutionVisitor.java:40)
        //     at com.strobel.assembler.metadata.TypeSubstitutionVisitor.visitMethod(TypeSubstitutionVisitor.java:314)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2611)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:782)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:778)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2483)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:782)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:778)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1510)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:782)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:778)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferCall(TypeAnalysis.java:2483)
        //     at com.strobel.decompiler.ast.TypeAnalysis.doInferTypeForExpression(TypeAnalysis.java:1040)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypeForExpression(TypeAnalysis.java:815)
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:684)
        //     at com.strobel.decompiler.ast.TypeAnalysis.inferTypesForVariables(TypeAnalysis.java:593)
        //     at com.strobel.decompiler.ast.TypeAnalysis.runInference(TypeAnalysis.java:405)
        //     at com.strobel.decompiler.ast.TypeAnalysis.run(TypeAnalysis.java:95)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:109)
        //     at com.strobel.decompiler.ast.AstOptimizer.optimize(AstOptimizer.java:42)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:206)
        //     at com.strobel.decompiler.languages.java.ast.AstMethodBodyBuilder.createMethodBody(AstMethodBodyBuilder.java:93)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethodBody(AstBuilder.java:868)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createMethod(AstBuilder.java:761)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addTypeMembers(AstBuilder.java:638)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeCore(AstBuilder.java:605)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createTypeNoCache(AstBuilder.java:195)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.createType(AstBuilder.java:162)
        //     at com.strobel.decompiler.languages.java.ast.AstBuilder.addType(AstBuilder.java:137)
        //     at com.strobel.decompiler.languages.java.JavaLanguage.buildAst(JavaLanguage.java:71)
        //     at com.strobel.decompiler.languages.java.JavaLanguage.decompileType(JavaLanguage.java:59)
        //     at com.strobel.decompiler.DecompilerDriver.decompileType(DecompilerDriver.java:333)
        //     at com.strobel.decompiler.DecompilerDriver.decompileJar(DecompilerDriver.java:254)
        //     at com.strobel.decompiler.DecompilerDriver.main(DecompilerDriver.java:129)
        // 
        throw new IllegalStateException("An error occurred while decompiling this method.");
    }
}
