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 drz) {
        this.thirdPersonLeftHand = drz.thirdPersonLeftHand;
        this.thirdPersonRightHand = drz.thirdPersonRightHand;
        this.firstPersonLeftHand = drz.firstPersonLeftHand;
        this.firstPersonRightHand = drz.firstPersonRightHand;
        this.head = drz.head;
        this.gui = drz.gui;
        this.ground = drz.ground;
        this.fixed = drz.fixed;
    }
    
    public ItemTransforms(final ItemTransform dry1, final ItemTransform dry2, final ItemTransform dry3, final ItemTransform dry4, final ItemTransform dry5, final ItemTransform dry6, final ItemTransform dry7, final ItemTransform dry8) {
        this.thirdPersonLeftHand = dry1;
        this.thirdPersonRightHand = dry2;
        this.firstPersonLeftHand = dry3;
        this.firstPersonRightHand = dry4;
        this.head = dry5;
        this.gui = dry6;
        this.ground = dry7;
        this.fixed = dry8;
    }
    
    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 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 dry6 = this.getTransform(jsonDeserializationContext, jsonObject5, "thirdperson_righthand");
            ItemTransform dry7 = this.getTransform(jsonDeserializationContext, jsonObject5, "thirdperson_lefthand");
            if (dry7 == ItemTransform.NO_TRANSFORM) {
                dry7 = dry6;
            }
            final ItemTransform dry8 = this.getTransform(jsonDeserializationContext, jsonObject5, "firstperson_righthand");
            ItemTransform dry9 = this.getTransform(jsonDeserializationContext, jsonObject5, "firstperson_lefthand");
            if (dry9 == ItemTransform.NO_TRANSFORM) {
                dry9 = dry8;
            }
            final ItemTransform dry10 = this.getTransform(jsonDeserializationContext, jsonObject5, "head");
            final ItemTransform dry11 = this.getTransform(jsonDeserializationContext, jsonObject5, "gui");
            final ItemTransform dry12 = this.getTransform(jsonDeserializationContext, jsonObject5, "ground");
            final ItemTransform dry13 = this.getTransform(jsonDeserializationContext, jsonObject5, "fixed");
            return new ItemTransforms(dry7, dry6, dry9, dry8, dry10, dry11, dry12, dry13);
        }
        
        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;
        }
    }
}
