mech.setArmorType(armorType.substring(armorType.indexOf(':')+1));
String thisArmorType = armorType.substring(armorType.indexOf(':')+1).replace(" Armor", ""); if (thisArmorType.length() > 0) { mech.setArmorType(thisArmorType); } else { mech.setArmorType(EquipmentType.T_ARMOR_STANDARD); }
    public Entity getEntity() throws EntityLoadingException {        try {            Mech mech;            if (chassisConfig.indexOf("Quad") != -1) {                mech = new QuadMech();            } else {                mech = new BipedMech();            }            if (!version.trim().equalsIgnoreCase("Version:1.0")) {                throw new EntityLoadingException("Wrong MTF file version.");            }            // aarg!  those stupid sub-names in parenthesis screw everything up            // we may do something different in the future, but for now, I'm            // going to strip them out            int pindex = name.indexOf("(");            if (pindex == -1) {                mech.setChassis(name.trim());            } else {                mech.setChassis(name.substring(0, pindex - 1).trim());            }            mech.setModel(model.trim());            mech.setYear(Integer.parseInt(this.techYear.substring(4).trim()));            if (chassisConfig.indexOf("Omni") != -1) {                mech.setOmni(true);            }            if (techBase.substring(9).trim().equals("Inner Sphere")) {                switch (Integer.parseInt(rulesLevel.substring(12).trim())) {                case 1 :                    mech.setTechLevel(TechConstants.T_IS_LEVEL_1);                    break;                case 2 :                    mech.setTechLevel(TechConstants.T_IS_LEVEL_2);                    break;                case 3 :                    mech.setTechLevel(TechConstants.T_IS_LEVEL_3);                    break;                default :                    throw new EntityLoadingException("Unsupported tech level: " + rulesLevel.substring(12).trim());                }            } else if (techBase.substring(9).trim().equals("Clan")) {                switch (Integer.parseInt(rulesLevel.substring(12).trim())) {                case 2 :                    mech.setTechLevel(TechConstants.T_CLAN_LEVEL_2);                    break;                case 3 :                    mech.setTechLevel(TechConstants.T_CLAN_LEVEL_3);                    break;                default :                    throw new EntityLoadingException("Unsupported tech level: " + rulesLevel.substring(12).trim());                }            } else if (techBase.substring(9).trim().equals("Mixed (IS Chassis)")) {                mech.setTechLevel(TechConstants.T_IS_LEVEL_3);                mech.setMixedTech(true);            } else if (techBase.substring(9).trim().equals("Mixed (Clan Chassis)")) {                mech.setTechLevel(TechConstants.T_CLAN_LEVEL_3);                mech.setMixedTech(true);            } else if (techBase.substring(9).trim().equals("Mixed")) {                throw new EntityLoadingException("Unsupported tech base: \"Mixed\" is no longer allowed by itself.  You must specify \"Mixed (IS Chassis)\" or \"Mixed (Clan Chassis)\".");            } else {                throw new EntityLoadingException("Unsupported tech base: " + techBase.substring(9).trim());            }            mech.setWeight((float)Integer.parseInt(tonnage.substring(5)));            mech.setOriginalWalkMP(Integer.parseInt(walkMP.substring(8)));            mech.setOriginalJumpMP(Integer.parseInt(jumpMP.substring(8)));            boolean dblSinks = heatSinks.substring(14).equalsIgnoreCase("Double");            int expectedSinks = Integer.parseInt(heatSinks.substring(11, 14).trim());            mech.autoSetInternal();            mech.setArmorType(armorType.substring(armorType.indexOf(':')+1));            mech.initializeArmor(Integer.parseInt(larmArmor.substring(9)), Mech.LOC_LARM);            mech.initializeArmor(Integer.parseInt(rarmArmor.substring(9)), Mech.LOC_RARM);            mech.initializeArmor(Integer.parseInt(ltArmor.substring(9)), Mech.LOC_LT);            mech.initializeArmor(Integer.parseInt(rtArmor.substring(9)), Mech.LOC_RT);            mech.initializeArmor(Integer.parseInt(ctArmor.substring(9)), Mech.LOC_CT);            mech.initializeArmor(Integer.parseInt(headArmor.substring(9)), Mech.LOC_HEAD);            mech.initializeArmor(Integer.parseInt(llegArmor.substring(9)), Mech.LOC_LLEG);            mech.initializeArmor(Integer.parseInt(rlegArmor.substring(9)), Mech.LOC_RLEG);            mech.initializeRearArmor(Integer.parseInt(ltrArmor.substring(10)), Mech.LOC_LT);            mech.initializeRearArmor(Integer.parseInt(rtrArmor.substring(10)), Mech.LOC_RT);            mech.initializeRearArmor(Integer.parseInt(ctrArmor.substring(10)), Mech.LOC_CT);            // oog, crits.            compactCriticals(mech);            // we do these in reverse order to get the outermost            //  locations first, which is necessary for split crits to work            for (int i = mech.locations() - 1; i >= 0; i--) {                parseCrits(mech, i);            }            if (mech.isClan()) {                mech.addClanCase();            }            // add any heat sinks not allocated            mech.addEngineSinks(expectedSinks - mech.heatSinks(), dblSinks);            return mech;        } catch (NumberFormatException ex) {            throw new EntityLoadingException("NumberFormatException parsing file");        } catch (NullPointerException ex) {            throw new EntityLoadingException("NullPointerException parsing file");        } catch (StringIndexOutOfBoundsException ex) {            throw new EntityLoadingException("StringIndexOutOfBoundsException parsing file");        }    }