package net.minecraft.client.renderer.block.model;

import com.google.gson.JsonParseException;
import com.google.gson.JsonObject;
import com.google.gson.JsonDeserializationContext;
import java.lang.reflect.Type;
import com.google.gson.JsonElement;
import com.google.gson.JsonDeserializer;

public class ItemTransforms {
    public static final ItemTransforms NO_TRANSFORMS;
    public final ItemTransform thirdPersonLeftHand;
    public final ItemTransform thirdPersonRightHand;
    public final ItemTransform firstPersonLeftHand;
    public final ItemTransform firstPersonRightHand;
    public final ItemTransform head;
    public final ItemTransform gui;
    public final ItemTransform ground;
    public final ItemTransform fixed;
    
    private ItemTransforms() {
        this(ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM, ItemTransform.NO_TRANSFORM);
    }
    
    public ItemTransforms(final ItemTransforms edf) {
        this.thirdPersonLeftHand = edf.thirdPersonLeftHand;
        this.thirdPersonRightHand = edf.thirdPersonRightHand;
        this.firstPersonLeftHand = edf.firstPersonLeftHand;
        this.firstPersonRightHand = edf.firstPersonRightHand;
        this.head = edf.head;
        this.gui = edf.gui;
        this.ground = edf.ground;
        this.fixed = edf.fixed;
    }
    
    public ItemTransforms(final ItemTransform ede1, final ItemTransform ede2, final ItemTransform ede3, final ItemTransform ede4, final ItemTransform ede5, final ItemTransform ede6, final ItemTransform ede7, final ItemTransform ede8) {
        this.thirdPersonLeftHand = ede1;
        this.thirdPersonRightHand = ede2;
        this.firstPersonLeftHand = ede3;
        this.firstPersonRightHand = ede4;
        this.head = ede5;
        this.gui = ede6;
        this.ground = ede7;
        this.fixed = ede8;
    }
    
    public ItemTransform getTransform(final TransformType b) {
        switch (b) {
            case THIRD_PERSON_LEFT_HAND: {
                return this.thirdPersonLeftHand;
            }
            case THIRD_PERSON_RIGHT_HAND: {
                return this.thirdPersonRightHand;
            }
            case FIRST_PERSON_LEFT_HAND: {
                return this.firstPersonLeftHand;
            }
            case FIRST_PERSON_RIGHT_HAND: {
                return this.firstPersonRightHand;
            }
            case HEAD: {
                return this.head;
            }
            case GUI: {
                return this.gui;
            }
            case GROUND: {
                return this.ground;
            }
            case FIXED: {
                return this.fixed;
            }
            default: {
                return ItemTransform.NO_TRANSFORM;
            }
        }
    }
    
    public boolean hasTransform(final TransformType b) {
        return this.getTransform(b) != ItemTransform.NO_TRANSFORM;
    }
    
    static {
        NO_TRANSFORMS = new ItemTransforms();
    }
    
    public enum TransformType {
        NONE, 
        THIRD_PERSON_LEFT_HAND, 
        THIRD_PERSON_RIGHT_HAND, 
        FIRST_PERSON_LEFT_HAND, 
        FIRST_PERSON_RIGHT_HAND, 
        HEAD, 
        GUI, 
        GROUND, 
        FIXED;
        
        public boolean firstPerson() {
            return this == TransformType.FIRST_PERSON_LEFT_HAND || this == TransformType.FIRST_PERSON_RIGHT_HAND;
        }
    }
    
    public static class Deserializer implements JsonDeserializer<ItemTransforms> {
        protected Deserializer() {
        }
        
        @Override
        public ItemTransforms deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
            final JsonObject jsonObject5 = jsonElement.getAsJsonObject();
            final ItemTransform ede6 = this.getTransform(jsonDeserializationContext, jsonObject5, "thirdperson_righthand");
            ItemTransform ede7 = this.getTransform(jsonDeserializationContext, jsonObject5, "thirdperson_lefthand");
            if (ede7 == ItemTransform.NO_TRANSFORM) {
                ede7 = ede6;
            }
            final ItemTransform ede8 = this.getTransform(jsonDeserializationContext, jsonObject5, "firstperson_righthand");
            ItemTransform ede9 = this.getTransform(jsonDeserializationContext, jsonObject5, "firstperson_lefthand");
            if (ede9 == ItemTransform.NO_TRANSFORM) {
                ede9 = ede8;
            }
            final ItemTransform ede10 = this.getTransform(jsonDeserializationContext, jsonObject5, "head");
            final ItemTransform ede11 = this.getTransform(jsonDeserializationContext, jsonObject5, "gui");
            final ItemTransform ede12 = this.getTransform(jsonDeserializationContext, jsonObject5, "ground");
            final ItemTransform ede13 = this.getTransform(jsonDeserializationContext, jsonObject5, "fixed");
            return new ItemTransforms(ede7, ede6, ede9, ede8, ede10, ede11, ede12, ede13);
        }
        
        private ItemTransform getTransform(final JsonDeserializationContext jsonDeserializationContext, final JsonObject jsonObject, final String string) {
            if (jsonObject.has(string)) {
                return jsonDeserializationContext.<ItemTransform>deserialize(jsonObject.get(string), ItemTransform.class);
            }
            return ItemTransform.NO_TRANSFORM;
        }
    }
}
