package hmggirlfront;


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import gvclib.LoadGunStatusBase;
import gvclib.RecoilMotionReader;
import gvclib.ReloadMotionReader;
import hmggirlfront.items.ItemDollGunBase;
import hmggirlfront.items.ItemDollGun_HL;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import objmodel.AdvancedModelLoader;

public class LoadDollStatus {
	
	  
	  
	public static void load(ItemDollGunBase gun, mod_GirlFront mod, RegistryEvent.Register<Item> event, ResourceLocation status, String text) {
		//reset
		{
			
		}
		
		try {
			//IResource res = Minecraft.getMinecraft().getResourceManager().getResource(status);
			//InputStream inputStream = res.getInputStream();
			InputStream inputStream = LoadDollStatus.class.getResourceAsStream("/assets/hmggirlfront/textures/model/status/" + text);
			//if (checkBeforeReadfile(file)) 
			{
				BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));

				String str;
				while ((str = br.readLine()) != null) { // 1行ずつ読み込む
					// System.out.println(str);
					String[] type = str.split(",");

					int guntype = 0;

					if (type.length != 0) {// 1
						if(mod.proxy.getClient()){
							gun.canobj = true;
							gun.obj_true = true;
							if (type[0].equals("ObjModel")) {
								gun.obj_model = AdvancedModelLoader
										.loadModel(new ResourceLocation("hmggirlfront:textures/model/gun/" + type[1]));
							}
							if (type[0].equals("ObjTexture")) {
								gun.obj_tex = "hmggirlfront:textures/model/gun/" + type[1];
							}
							gun.arm_model = AdvancedModelLoader.loadModel(new ResourceLocation("gvclib:textures/model/arm.obj"));
							gun.arm_model2 = AdvancedModelLoader.loadModel(new ResourceLocation("gvclib:textures/model/arm2.obj"));
							gun.flash_model = AdvancedModelLoader.loadModel(new ResourceLocation("gvclib:textures/model/flash.obj"));
							if (type[0].equals("DollModel")) {
								gun.doll_model = AdvancedModelLoader
										.loadModel(new ResourceLocation("hmggirlfront:textures/model/doll/" + type[1]));
							}
							if (type[0].equals("DollTexture")) {
								gun.doll_tex = "hmggirlfront:textures/model/doll/" + type[1];
							}
							if (type[0].equals("HLModel")) {
								gun.dollhl_model = AdvancedModelLoader
										.loadModel(new ResourceLocation("hmggirlfront:textures/model/hl/" + type[1]));
							}
							if (type[0].equals("HLTexture")) {
								gun.dollhl_tex = "hmggirlfront:textures/model/hl/" + type[1];
							}
							
							
							
							
							
							
							{
								if (type[0].equals("Reload_Motion")) {
									gun.newreload = Boolean.parseBoolean(type[1]);
								}
								if (type[0].equals("ReloadMotionType")) {
									gun.reloadmotion = Integer.parseInt(type[1]);
								}
								String reloadm = null;
								if (type[0].equals("ReloadMotion")) {
									reloadm = type[1];
								}
								if(reloadm != null) {
								ResourceLocation reloadmotion = new ResourceLocation("hmggirlfront:textures/model/reload/" + reloadm);
								ReloadMotionReader.read(gun, reloadmotion);
								}
								String recoilm = null;
								if (type[0].equals("RecoilMotionType")) {
									gun.recoilmotion = Boolean.parseBoolean(type[1]);
								}
								if (type[0].equals("RecoilMotion")) {
									recoilm = type[1];
								}
								if(recoilm != null) {
								ResourceLocation recoilmotion = new ResourceLocation("hmggirlfront:textures/model/reload/" + recoilm);
								RecoilMotionReader.read(gun, recoilmotion);
								}
							}
						}
						
						if (type[0].equals("hoplites_kazu")) {
							gun.hoplites_kazu = Integer.parseInt(type[1]);
						}
						if (type[0].equals("hoplites_subarm")) {
							for(int i = 0; i < gun.hoplites_kazu; ++i) {
								if(!type[1 + i].equals("null"))gun.hoplites_subarm[i] = event.getRegistry().getValue(new ResourceLocation("hmggirlfront", type[1 + i]));
							}
						}
						if(mod.proxy.getClient()){
							if (type[0].equals("DollModel_H")) {
								for(int i = 0; i < gun.hoplites_kazu; ++i) {
									gun.doll_model_h[i] = AdvancedModelLoader
											.loadModel(new ResourceLocation("hmggirlfront:textures/model/doll/" + type[1 + i]));
								}
							}
							if (type[0].equals("DollTexture_H")) {
								for(int i = 0; i < gun.hoplites_kazu; ++i) {
									gun.doll_tex_h[i] = "hmggirlfront:textures/model/doll/" + type[1 + i];
								}
							}
							
						}
						
						if (type[0].equals("Gun_Class")) {
							gun.gun_class = Integer.parseInt(type[1]);
						}
						if (type[0].equals("DollID")) {
							gun.dollid = Integer.parseInt(type[1]);
						}
						if (type[0].equals("DollName")) {
							gun.dollname = type[1];
						}
						if (type[0].equals("DollEvasion")) {
							gun.doll_evasion = Integer.parseInt(type[1]);
						}
						if (type[0].equals("DollHP")) {
							gun.doll_hp = Integer.parseInt(type[1]);
						}
						if (type[0].equals("DollArmor")) {
							gun.doll_armor = Integer.parseInt(type[1]);
						}
						if (type[0].equals("DollHPRecovery")) {
							gun.doll_hp_recovery = Integer.parseInt(type[1]);
						}
						if (type[0].equals("DollSize")) {
							gun.doll_size = Float.parseFloat(type[1]);
						}
						
						if (type[0].equals("Doll_MinRange")) {
							gun.mobmax = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_MaxRange")) {
							gun.mobrange = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_GunCycle")) {
							gun.mobammo = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_GunBarst")) {
							gun.mobbarst = Integer.parseInt(type[1]);
						}
						
						if (type[0].equals("Doll_Crafttime")) {
							gun.doll_crafttime = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_Rare")) {
							gun.doll_rare = Integer.parseInt(type[1]);
						}
						
						if (type[0].equals("Doll_Dismantling_hp")) {
							gun.doll_d_hp = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_Dismantling_bullet")) {
							gun.doll_d_bullet = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_Dismantling_food")) {
							gun.doll_d_food = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_Dismantling_parts")) {
							gun.doll_d_parts = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_Dismantling_core")) {
							gun.doll_d_core = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_Skill_ID")) {
							gun.doll_skill = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Doll_AutoSkill_ID")) {
							gun.doll_autoskill = Integer.parseInt(type[1]);
						}
						
						LoadGunStatusBase.load(gun, event, text, type,"hmggirlfront:textures/misc/","hmggirlfront:textures/entity/");
						
						
						
						
						
						
						if(gun != null && gun instanceof ItemDollGun_HL) {
							ItemDollGun_HL gunhl = (ItemDollGun_HL) gun;
							if (type[0].equals("ridding_roteplayer")) {
								gunhl.ridding_roteplayer = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("riddng_maximum")) {
								gunhl.riddng_maximum = Integer.parseInt(type[1]);
							}
							if (type[0].equals("riddingx")) {
								for (int w1 = 0; w1 < gunhl.riddng_maximum; ++w1) {
									gunhl.riddingx[w1] = Double.parseDouble(type[w1 + 1]);
								}
							}
							if (type[0].equals("riddingy")) {
								for (int w1 = 0; w1 < gunhl.riddng_maximum; ++w1) {
									gunhl.riddingy[w1] = Double.parseDouble(type[w1 + 1]);
								}
							}
							if (type[0].equals("riddingz")) {
								for (int w1 = 0; w1 < gunhl.riddng_maximum; ++w1) {
									gunhl.riddingz[w1] = Double.parseDouble(type[w1 + 1]);
								}
							}
							if (type[0].equals("riddingx_roteplayer")) {
								for (int w1 = 0; w1 < gunhl.riddng_maximum; ++w1) {
									gunhl.riddingx_roteplayer[w1] = Double.parseDouble(type[w1 + 1]);
								}
							}
							if (type[0].equals("riddingy_roteplayer")) {
								for (int w1 = 0; w1 < gunhl.riddng_maximum; ++w1) {
									gunhl.riddingy_roteplayer[w1] = Double.parseDouble(type[w1 + 1]);
								}
							}
							if (type[0].equals("riddingz_roteplayer")) {
								for (int w1 = 0; w1 < gunhl.riddng_maximum; ++w1) {
									gunhl.riddingz_roteplayer[w1] = Double.parseDouble(type[w1 + 1]);
								}
							}

							if (type[0].equals("ridding_view1_x")) {
								gunhl.ridding_view1_x = Float.parseFloat(type[1]);
							}
							if (type[0].equals("ridding_view1_y")) {
								gunhl.ridding_view1_y = Float.parseFloat(type[1]);
							}
							if (type[0].equals("ridding_view1_z")) {
								gunhl.ridding_view1_z = Float.parseFloat(type[1]);
							}

							if (type[0].equals("ridding_view_x")) {
								gunhl.ridding_view_x = Float.parseFloat(type[1]);
							}
							if (type[0].equals("ridding_view_y")) {
								gunhl.ridding_view_y = Float.parseFloat(type[1]);
							}
							if (type[0].equals("ridding_view_z")) {
								gunhl.ridding_view_z = Float.parseFloat(type[1]);
							}

							if (type[0].equals("ridding_invisible")) {
								gunhl.ridding_invisible = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("ridding_zoom")) {
								gunhl.ridding_zoom = Float.parseFloat(type[1]);
							}

							if (type[0].equals("renderhud")) {
								gunhl.renderhud = Boolean.parseBoolean(type[1]);
							}

							if (type[0].equals("render_hud_scope")) {
								gunhl.render_hud_scope = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("render_hud_scope_zoom")) {
								gunhl.render_hud_scope_zoom = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("render_rader")) {
								gunhl.render_rader = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("aarader")) {
								gunhl.aarader = Boolean.parseBoolean(type[1]);
							}

							if (type[0].equals("roodbreak")) {
								gunhl.roodbreak = Boolean.parseBoolean(type[1]);
							}

							if(type[0].equals("vehicletype")){
								gunhl.vehicletype = Integer.parseInt(type[1]);
		            		}
							
							if (type[0].equals("movesound")) {
								gunhl.movesound = type[1];
							}
							if (type[0].equals("hp")) {
								gunhl.maxhp = Double.parseDouble(type[1]);
							}
							if (type[0].equals("width")) {
								gunhl.setwidth = Float.parseFloat(type[1]);
							}
							if (type[0].equals("height")) {
								gunhl.setheight = Float.parseFloat(type[1]);
							}
							if (type[0].equals("riddng_opentop")) {
								gunhl.riddng_opentop = Boolean.parseBoolean(type[1]);
							}

							if (type[0].equals("damage_angle")) {
								gunhl.damage_front = Float.parseFloat(type[1]);
								gunhl.damage_side = Float.parseFloat(type[2]);
								gunhl.damage_rear = Float.parseFloat(type[3]);
								gunhl.damage_top = Float.parseFloat(type[4]);
								gunhl.damage_bottom = Float.parseFloat(type[5]);
							}
							if (type[0].equals("can_turret")) {
								gunhl.can_turret = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("turret_height")) {
								gunhl.turret_height = Float.parseFloat(type[1]);
							}
							if (type[0].equals("damage_turret_angle")) {
								gunhl.damage_turret_front = Float.parseFloat(type[1]);
								gunhl.damage_turret_side = Float.parseFloat(type[1]);
								gunhl.damage_turret_rear = Float.parseFloat(type[3]);
							}

							if (type[0].equals("antibullet")) {
								gunhl.antibullet_0 = Float.parseFloat(type[1]);
								gunhl.antibullet_1 = Float.parseFloat(type[1]);
								gunhl.antibullet_2 = Float.parseFloat(type[3]);
								gunhl.antibullet_3 = Float.parseFloat(type[4]);
							}
							if (type[0].equals("ridding_damege")) {
								gunhl.ridding_damege = Float.parseFloat(type[1]);
							}
							if (type[0].equals("speed")) {
								gunhl.sp = Float.parseFloat(type[1]);
							}
							if (type[0].equals("turnspeed")) {
								gunhl.turnspeed = Float.parseFloat(type[1]);
							}
							if (type[0].equals("stepHeight")) {
								gunhl.stepHeight = Float.parseFloat(type[1]);
							}
							if (type[0].equals("trottlemax")) {
								gunhl.thmax = Float.parseFloat(type[1]);
							}
							if (type[0].equals("trottlemin")) {
								gunhl.thmin = Float.parseFloat(type[1]);
							}
							if (type[0].equals("trottleaccelerationmax")) {
								gunhl.thmaxa = Float.parseFloat(type[1]);
							}
							if (type[0].equals("trottleaccelerationmin")) {
								gunhl.thmina = Float.parseFloat(type[1]);
							}

							if (type[0].equals("angle_max")) {
								gunhl.rotationp_max = Float.parseFloat(type[1]);
							}
							if (type[0].equals("angle_min")) {
								gunhl.rotationp_min = Float.parseFloat(type[1]);
							}

							if (type[0].equals("ridding_rotation_lock")) {
								gunhl.ridding_rotation_lock = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("angle_yaw_max")) {
								gunhl.rotation_max = Float.parseFloat(type[1]);
							}

							if (type[0].equals("model_angle_base_x")) {
								gunhl.model_angle_base_x = Float.parseFloat(type[1]);
							}
							if (type[0].equals("model_angle_base_y")) {
								gunhl.model_angle_base_y = Float.parseFloat(type[1]);
							}
							if (type[0].equals("model_angle_base_z")) {
								gunhl.model_angle_base_z = Float.parseFloat(type[1]);
							}
							if (type[0].equals("model_angle_offset_x")) {
								gunhl.model_angle_offset_x = Float.parseFloat(type[1]);
							}
							if (type[0].equals("model_angle_offset_y")) {
								gunhl.model_angle_offset_y = Float.parseFloat(type[1]);
							}
							if (type[0].equals("model_angle_offset_z")) {
								gunhl.model_angle_offset_z = Float.parseFloat(type[1]);
							}
							if (type[0].equals("model_angle_x")) {
								gunhl.model_angle_x = Float.parseFloat(type[1]);
							}
							if (type[0].equals("model_angle_y")) {
								gunhl.model_angle_y = Float.parseFloat(type[1]);
							}
							if (type[0].equals("model_angle_z")) {
								gunhl.model_angle_z = Float.parseFloat(type[1]);
							}

							if (type[0].equals("mob_min_range")) {
								gunhl.mob_min_range = Integer.parseInt(type[1]);
							}
							if (type[0].equals("mob_max_range")) {
								gunhl.mob_max_range = Integer.parseInt(type[1]);
							}
							if (type[0].equals("mob_min_height")) {
								gunhl.mob_min_height = Integer.parseInt(type[1]);
							}

							if (type[0].equals("turret")) {
								gunhl.turret = Integer.parseInt(type[1]);
							}
							if (type[0].equals("turretrote")) {
								for (int w1 = 0; w1 < gunhl.turret; ++w1) {
									gunhl.turretrote[w1] = Boolean.parseBoolean(type[w1 + 1]);
								}
							}
							if (type[0].equals("arm_x")) {
								for (int w1 = 0; w1 < gunhl.turret; ++w1) {
									gunhl.arm_x[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("arm_y")) {
								for (int w1 = 0; w1 < gunhl.turret; ++w1) {
									gunhl.arm_y[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("arm_z")) {
								for (int w1 = 0; w1 < gunhl.turret; ++w1) {
									gunhl.arm_z[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("hand_x")) {
								for (int w1 = 0; w1 < gunhl.turret; ++w1) {
									gunhl.hand_x[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("hand_y")) {
								for (int w1 = 0; w1 < gunhl.turret; ++w1) {
									gunhl.hand_y[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("hand_z")) {
								for (int w1 = 0; w1 < gunhl.turret; ++w1) {
									gunhl.hand_z[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}

							if (type[0].equals("finger_type")) {
								for (int w1 = 0; w1 < gunhl.turret; ++w1) {
									gunhl.finger_type[w1] = Integer.parseInt(type[w1 + 1]);
								}
							}

							if (type[0].equals("pera")) {
								gunhl.pera = Integer.parseInt(type[1]);
							}
							if (type[0].equals("pera_x")) {
								for (int w1 = 0; w1 < gunhl.pera; ++w1) {
									gunhl.pera_x[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("pera_y")) {
								for (int w1 = 0; w1 < gunhl.pera; ++w1) {
									gunhl.pera_y[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("pera_z")) {
								for (int w1 = 0; w1 < gunhl.pera; ++w1) {
									gunhl.pera_z[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("perarote_x")) {
								for (int w1 = 0; w1 < gunhl.pera; ++w1) {
									gunhl.perarote_x[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("perarote_y")) {
								for (int w1 = 0; w1 < gunhl.pera; ++w1) {
									gunhl.perarote_y[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("perarote_z")) {
								for (int w1 = 0; w1 < gunhl.pera; ++w1) {
									gunhl.perarote_z[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}

							if (type[0].equals("rader")) {
								gunhl.rader = Integer.parseInt(type[1]);
							}
							if (type[0].equals("raderturret")) {
								for (int w1 = 0; w1 < gunhl.rader; ++w1) {
									gunhl.raderturret[w1] = Integer.parseInt(type[w1 + 1]);
								}
							}
							if (type[0].equals("rader_x")) {
								for (int w1 = 0; w1 < gunhl.rader; ++w1) {
									gunhl.rader_x[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("rader_y")) {
								for (int w1 = 0; w1 < gunhl.rader; ++w1) {
									gunhl.rader_y[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("rader_z")) {
								for (int w1 = 0; w1 < gunhl.rader; ++w1) {
									gunhl.rader_z[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("raderrote_x")) {
								for (int w1 = 0; w1 < gunhl.rader; ++w1) {
									gunhl.raderrote_x[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("raderrote_y")) {
								for (int w1 = 0; w1 < gunhl.rader; ++w1) {
									gunhl.raderrote_y[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("raderrote_z")) {
								for (int w1 = 0; w1 < gunhl.rader; ++w1) {
									gunhl.raderrote_z[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}

							if (type[0].equals("cloud")) {
								gunhl.cloud = Integer.parseInt(type[1]);
							}
							if (type[0].equals("cloud_x")) {
								for (int w1 = 0; w1 < gunhl.cloud; ++w1) {
									gunhl.cloud_x[w1] = Double.parseDouble(type[w1 + 1]);
								}
							}
							if (type[0].equals("cloud_y")) {
								for (int w1 = 0; w1 < gunhl.cloud; ++w1) {
									gunhl.cloud_y[w1] = Double.parseDouble(type[w1 + 1]);
								}
							}
							if (type[0].equals("cloud_z")) {
								for (int w1 = 0; w1 < gunhl.cloud; ++w1) {
									gunhl.cloud_z[w1] = Double.parseDouble(type[w1 + 1]);
								}
							}

							if (type[0].equals("exhaust")) {
								gunhl.exhaust = Integer.parseInt(type[1]);
							}
							if (type[0].equals("exhaust_ab")) {
								gunhl.exhaust_ab = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("exhaust_x")) {
								for (int w1 = 0; w1 < gunhl.exhaust; ++w1) {
									gunhl.exhaust_x[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("exhaust_y")) {
								for (int w1 = 0; w1 < gunhl.exhaust; ++w1) {
									gunhl.exhaust_y[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("exhaust_z")) {
								for (int w1 = 0; w1 < gunhl.exhaust; ++w1) {
									gunhl.exhaust_z[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}

							if (type[0].equals("laser_sight")) {
								gunhl.laser_sight = Integer.parseInt(type[1]);
							}
							if (type[0].equals("rote_laser_sight")) {
								for (int w1 = 0; w1 < gunhl.laser_sight; ++w1) {
									gunhl.rote_laser_sight[w1] = Boolean.parseBoolean(type[w1 + 1]);
								}
							}
							if (type[0].equals("laser_sight_x")) {
								for (int w1 = 0; w1 < gunhl.laser_sight; ++w1) {
									gunhl.laser_sight_x[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("laser_sight_y")) {
								for (int w1 = 0; w1 < gunhl.laser_sight; ++w1) {
									gunhl.laser_sight_y[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("laser_sight_z")) {
								for (int w1 = 0; w1 < gunhl.laser_sight; ++w1) {
									gunhl.laser_sight_z[w1] = Float.parseFloat(type[w1 + 1]);
								}
							}
							if (type[0].equals("laser_sight_weapon")) {
								for (int w1 = 0; w1 < gunhl.laser_sight; ++w1) {
									gunhl.laser_sight_weapon[w1] = Integer.parseInt(type[w1 + 1]);
								}
							}
							
							if(type[0].equals("spg_sighting")){
								gunhl.spg_sighting = Boolean.parseBoolean(type[1]);
		            		}
							
							if(type[0].equals("spg_min_range")){
								gunhl.spg_min_range = Integer.parseInt(type[1]);
		            		}

							// weapon1
							if (type[0].equals("weapon1true")) {
								gunhl.weapon1true = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("weapon1key")) {
								gunhl.weapon1key = Integer.parseInt(type[1]);
							}
							if (type[0].equals("w1name")) {
								gunhl.w1name = type[1];
							}
							if (type[0].equals("w1missile_aam")) {
								gunhl.w1missile_aam = Boolean.parseBoolean(type[1]);
							}
							/*if (type[0].equals("ammo1")) {
								gunhl.ammo1 = Integer.parseInt(type[1]);
							}
							/*if (type[0].equals("magazine1")) {
								gunhl.magazine = Integer.parseInt(type[1]);
							}
							if (type[0].equals("reload_time1")) {
								gunhl.reload_time1 = Integer.parseInt(type[1]);
							}*/
							if (type[0].equals("reloadsoundset1")) {
								gunhl.reloadsoundset1 = Integer.parseInt(type[1]);
							}
							if (type[0].equals("reloadsound1")) {
								gunhl.reloadsound1 = type[1];
							}
							if (type[0].equals("w1cycle")) {
								gunhl.w1cycle = Integer.parseInt(type[1]);
							}
							if (type[0].equals("w1barst")) {
								gunhl.w1barst = Integer.parseInt(type[1]);
							}
							if (type[0].equals("w1crossfire")) {
								gunhl.w1crossfire = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("w1can_cooldown")) {
								gunhl.w1can_cooldown = Boolean.parseBoolean(type[1]);
							}
							if (type[0].equals("weapon1")) {
								gunhl.weapon1 = Integer.parseInt(type[1]);
							}
							for (int w1 = 0; w1 < gunhl.weapon1; ++w1) {
								if (type[0].equals("bullet_type1")) {
									gunhl.bullet_type1[w1] = Integer.parseInt(type[w1 + 1]);
								}
								if (type[0].equals("bullet_model1")) {
									{
										gunhl.bullet_model1[w1] = "hmggirlfront:textures/entity"+ type[w1 + 1];
									}
								}
								if (type[0].equals("bullet_tex1")) {
									{
										gunhl.bullet_tex1[w1] = "hmggirlfront:textures/entity"+ type[w1 + 1];
									}
								}
								if (type[0].equals("fire_model1")) {
									{
										gunhl.fire_model1[w1] = "hmggirlfront:textures/entity"+ type[w1 + 1];
									}
								}
								if (type[0].equals("fire_tex1")) {
									{
										gunhl.fire_tex1[w1] = "hmggirlfront:textures/entity"+ type[w1 + 1];
									}
								}
								if (type[0].equals("fire_time1")) {
									{
										gunhl.fire_time1[w1] = Integer.parseInt(type[w1 + 1]);
									}
								}
								if (type[0].equals("sound_fire1")) {
									{
										gunhl.sound_fire1[w1] = type[w1 + 1];
									}
								}
								if (type[0].equals("fire_pointx1")) {
									{
										gunhl.fire_pointx1[w1] = Float.parseFloat(type[w1 + 1]);
									}
								}
								if (type[0].equals("fire_pointy1")) {
									{
										gunhl.fire_pointy1[w1] = Float.parseFloat(type[w1 + 1]);
									}
								}
								if (type[0].equals("fire_pointz1")) {
									{
										gunhl.fire_pointz1[w1] = Float.parseFloat(type[w1 + 1]);
									}
								}
								if (type[0].equals("basis_pointx1")) {
									{
										gunhl.basis_pointx1[w1] = Float.parseFloat(type[w1 + 1]);
									}
								}
								if (type[0].equals("basis_pointy1")) {
									{
										gunhl.basis_pointy1[w1] = Float.parseFloat(type[w1 + 1]);
									}
								}
								if (type[0].equals("basis_pointz1")) {
									{
										gunhl.basis_pointz1[w1] = Float.parseFloat(type[w1 + 1]);
									}
								}
								if (type[0].equals("fire_yoffset1")) {
									{
										gunhl.fire_yoffset1[w1] = Double.parseDouble(type[w1 + 1]);
									}
								}
								if (type[0].equals("rotationfollowing1")) {
									{
										gunhl.rotationfollowing1[w1] = Boolean.parseBoolean(type[w1 + 1]);
									}
								}
								if (type[0].equals("rotationfirepoint1")) {
									{
										gunhl.rotationfirepoint1[w1] = Boolean.parseBoolean(type[w1 + 1]);
									}
								}
								if (type[0].equals("rotation_player1")) {
									{
										gunhl.rotation_player1[w1] = Boolean.parseBoolean(type[w1 + 1]);
									}
								}
								if (type[0].equals("rotation_firepointbxbz1")) {
									{
										gunhl.rotation_firepointbxbz1[w1] = Boolean.parseBoolean(type[w1 + 1]);
									}
								}
								if (type[0].equals("rotation_lock_pitch_vehicle1")) {
									{
										gunhl.rotation_lock_pitch_vehicle1[w1] = Boolean.parseBoolean(type[w1 + 1]);
									}
								}
								if (type[0].equals("bullet_damage1")) {
									{
										gunhl.bullet_damage1[w1] = Integer.parseInt(type[w1 + 1]);
									}
								}
								if (type[0].equals("bullet_speed1")) {
									{
										gunhl.bullet_speed1[w1] = Float.parseFloat(type[w1 + 1]);
									}
								}
								if (type[0].equals("bullet_bure1")) {
									{
										gunhl.bullet_bure1[w1] = Float.parseFloat(type[w1 + 1]);
									}
								}
								if (type[0].equals("bullet_expower1")) {
									{
										gunhl.bullet_expower1[w1] = Float.parseFloat(type[w1 + 1]);
									}
								}
								if (type[0].equals("bullet_ex1")) {
									{
										gunhl.bullet_ex1[w1] = Boolean.parseBoolean(type[w1 + 1]);
									}
								}
								if (type[0].equals("bullet_kazu1")) {
									{
										gunhl.bullet_kazu1[w1] = Integer.parseInt(type[w1 + 1]);
									}
								}
								if (type[0].equals("bullet_gravity1")) {
									{
										gunhl.bullet_gravity1[w1] = Double.parseDouble(type[w1 + 1]);
									}
								}
								if (type[0].equals("bullet_livingtime1")) {
									{
										gunhl.bullet_livingtime1[w1] = Integer.parseInt(type[w1 + 1]);
									}
								}
							}

							if (type[0].equals("mob_w1range")) {
								gunhl.mob_w1range = Integer.parseInt(type[1]);
							}
						}
						/*
						if (type[0].equals("Knife")) {
							gun.knife = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Bullet_Type")) {
							gun.gun_type = gun.mobbullettype = Integer.parseInt(type[1]);
						}
						if (type[0].equals("BulletPower")) {
							gun.powor = Integer.parseInt(type[1]);
						}
						if (type[0].equals("BulletSpeed")) {
							gun.speed = Float.parseFloat(type[1]);
						}
						if (type[0].equals("BlletSpread")) {
							gun.bure = Float.parseFloat(type[1]);
						}
						if (type[0].equals("Recoil")) {
							gun.recoil = Double.parseDouble(type[1]);
						}
						if (type[0].equals("ReloadTime")) {
							gun.reloadtime = Integer.parseInt(type[1]);
						}
						if (type[0].equals("RemainingBullet")) {
							gun.setMaxDamage(Integer.parseInt(type[1]));
						}
						if (type[0].equals("Attacking")) {
							gun.attackDamage = Float.parseFloat(type[1]);
						}
						if (type[0].equals("AttackingSpeed")) {
							gun.attackSpeed = Double.parseDouble(type[1]);
						}
						if (type[0].equals("Motion")) {
							gun.motion = Double.parseDouble(type[1]);
						}
						if (type[0].equals("Zoom")) {
							gun.scopezoom = Float.parseFloat(type[1]);
							gun.scopezoombase = Float.parseFloat(type[1]);
						}
						if (type[0].equals("ZoomRender")) {
							gun.model_zoomrender = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("ZoomRenderType")) {
							gun.zoomre = Boolean.parseBoolean(type[1]);
							gun.zoomren = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("ZoomRenderTypeTxture")) {
							gun.zoomrent = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Cycle")) {
							gun.cycle = gun.cocktime = gun.mobcycle = Integer.parseInt(type[1]);
						}
						if (type[0].equals("Explosion")) {
							gun.exlevel = Float.parseFloat(type[1]);
						}
						if (type[0].equals("BlockDestory")) {
							gun.canex = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("GunSound")) {
							gun.sound = type[1];
							gun.soundbase = type[1];
							gun.soundsu = type[2];
						}
						if (type[0].equals("GunSoundReload")) {
							gun.soundre = type[1];
						}
						if (type[0].equals("GunSoundCooking")) {
							gun.soundco = type[1];
						}
						
						//modelset
						if (type[0].equals("ModelEquipped")) {
							gun.model_x = Float.parseFloat(type[1]);
							gun.model_y = Float.parseFloat(type[2]);
							gun.model_z = Float.parseFloat(type[3]);
						}
						if (type[0].equals("ModelHigh")) {
							gun.model_y_ads = Float.parseFloat(type[1]);
						}
						if (type[0].equals("ModelWidthX")) {
							gun.model_x_ads = Float.parseFloat(type[1]);
						}
						if (type[0].equals("ModelWidthZ")) {
							gun.model_z_ads = Float.parseFloat(type[1]);
						}
						if (type[0].equals("ModelRotationX")) {
							gun.rotationx = Float.parseFloat(type[1]);
						}
						if (type[0].equals("ModelRotationY")) {
							gun.rotationy = Float.parseFloat(type[1]);
						}
						if (type[0].equals("ModelRotationZ")) {
							gun.rotationz = Float.parseFloat(type[1]);
						}
						
						//arm
						if (type[0].equals("ModelArm")) {
							gun.canarm = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("ModelArmOffsetR")) {
							gun.arm_r_posx = Float.parseFloat(type[1]);
							gun.arm_r_posy = Float.parseFloat(type[2]);
							gun.arm_r_posz = Float.parseFloat(type[3]);
						}
						if (type[0].equals("ModelArmOffsetL")) {
							gun.arm_l_posx = Float.parseFloat(type[1]);
							gun.arm_l_posy = Float.parseFloat(type[2]);
							gun.arm_l_posz = Float.parseFloat(type[3]);
						}
						if (type[0].equals("ModelArmScaleR")) {
							gun.arm_scale_r = Float.parseFloat(type[1]);
						}
						if (type[0].equals("ModelArmScaleL")) {
							gun.arm_scale_l = Float.parseFloat(type[1]);
						}
						
						if (type[0].equals("Mat31Point")) {
							gun.mat31posx = Float.parseFloat(type[1]);
							gun.mat31posy = Float.parseFloat(type[2]);
							gun.mat31posz = Float.parseFloat(type[3]);
						}
						if (type[0].equals("Mat31Rotation")) {
							gun.mat31rotex = Float.parseFloat(type[1]);
							gun.mat31rotey = Float.parseFloat(type[2]);
							gun.mat31rotez = Float.parseFloat(type[3]);
						}
						if (type[0].equals("Mat32Point")) {
							gun.mat32posx = Float.parseFloat(type[1]);
							gun.mat32posy = Float.parseFloat(type[2]);
							gun.mat32posz = Float.parseFloat(type[3]);
						}
						if (type[0].equals("Mat32Rotation")) {
							gun.mat32rotex = Float.parseFloat(type[1]);
							gun.mat32rotey = Float.parseFloat(type[2]);
							gun.mat32rotez = Float.parseFloat(type[3]);
						}
						
						if (type[0].equals("Mat22")) {
							gun.mat22 = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Mat22Point")) {
							gun.mat22offsetx = Float.parseFloat(type[1]);
							gun.mat22offsety = Float.parseFloat(type[2]);
							gun.mat22offsetz = Float.parseFloat(type[3]);
						}
						if (type[0].equals("Mat22Rotation")) {
							gun.mat22rotationx = Float.parseFloat(type[1]);
							gun.mat22rotationy = Float.parseFloat(type[2]);
							gun.mat22rotationz = Float.parseFloat(type[3]);
						}
						if (type[0].equals("Mat25Point")) {
							gun.mat25offsetx = Float.parseFloat(type[1]);
							gun.mat25offsety = Float.parseFloat(type[2]);
							gun.mat25offsetz = Float.parseFloat(type[3]);
						}
						if (type[0].equals("Mat25Rotation")) {
							gun.mat25rotationx = Float.parseFloat(type[1]);
							gun.mat25rotationy = Float.parseFloat(type[2]);
							gun.mat25rotationz = Float.parseFloat(type[3]);
						}
						
						if (type[0].equals("SprintingPoint")) {
							gun.Sprintoffsetx = Float.parseFloat(type[1]);
							gun.Sprintoffsety = Float.parseFloat(type[2]);
							gun.Sprintoffsetz = Float.parseFloat(type[3]);
						}
						if (type[0].equals("SprintingRotation")) {
							gun.Sprintrotationx = Float.parseFloat(type[1]);
							gun.Sprintrotationy = Float.parseFloat(type[2]);
							gun.Sprintrotationz = Float.parseFloat(type[3]);
						}
						if (type[0].equals("ShotGun_Pellet")) {
							gun.shotgun_pellet = Integer.parseInt(type[1]);
						}
						
						if (type[0].equals("Fire_Offset_y")) {
							gun.fire_roteoffset_y = Float.parseFloat(type[1]);
						}
						
						if (type[0].equals("Cartridge")) {
							gun.bullet_c = Boolean.parseBoolean(type[1]);
						}
						
						//01/27
						if (type[0].equals("MuzzleJump")) {
							gun.jump = Float.parseFloat(type[1]);
						}
						if (type[0].equals("Mat2")) {
							gun.mat2 = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Mat25")) {
							gun.mat25 = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("CockedLeftHand")) {
							gun.cock_left = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("ALLCocked")) {
							gun.all_jump = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("BulletGravity")) {
							gun.gra = Float.parseFloat(type[1]);
						}
						
						
						if (type[0].equals("Mat2_CockZ")) {
							gun.model_cock_z = Float.parseFloat(type[1]);
						}
						
						//0214
						if (type[0].equals("CartridgeType")) {
							gun.c_type = Integer.parseInt(type[1]);
						}
						if (type[0].equals("DropMagazine")) {
							gun.canmagazine = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("ReloadMat31")) {
							gun.remat31 = Boolean.parseBoolean(type[1]);
						}
						
						
						
						
						//
						if (type[0].equals("ScopeTexture")) {
							gun.adstexture = "hmggirlfront:textures/misc/" +  type[1];
						}
						if (type[0].equals("RenderCross")) {
							gun.rendercross = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Automatic")) {
							gun.semi = Boolean.parseBoolean(type[1]);
						}

						if (type[0].equals("Magazine")) {
							int ii = Integer.parseInt(type[1]);
							if (ii == 0) {
								gun.magazine = event.getRegistry().getValue(new ResourceLocation(type[2], type[3]));
							}
						}
						if (type[0].equals("MagazineSG")) {
							int ii = Integer.parseInt(type[1]);
							if (ii == 0) {
								gun.magazinesg =  event.getRegistry().getValue(new ResourceLocation(type[2], type[3]));
							}
						}
						if (type[0].equals("MagazineGL")) {
							int ii = Integer.parseInt(type[1]);
							if (ii == 0) {
								gun.magazinegl =  event.getRegistry().getValue(new ResourceLocation(type[2], type[3]));
							}
						}
						gun.reload_type = 2;
						
						
						
						if (type[0].equals("Bullet_Model")) {
							gun.bullet_model = "hmggirlfront:textures/entity/" + type[1];
						}
						if (type[0].equals("Bullet_Texture")) {
							gun.bullet_tex = "hmggirlfront:textures/entity/" + type[1];
						}
						if (type[0].equals("Cartridge_Model")) {
							gun.cartridge_model = "hmggirlfront:textures/entity/" + type[1];
						}
						if (type[0].equals("Cartridge_Texture")) {
							gun.cartridge_tex ="hmggirlfront:textures/entity/" +  type[1];
						}
						if (type[0].equals("SightSetPoint")) {
							gun.am_sight_x = gun.am_sightbase_x = Float.parseFloat(type[1]);
							gun.am_sight_y = gun.am_sightbase_y = Float.parseFloat(type[2]);
							gun.am_sight_z = gun.am_sightbase_z = Float.parseFloat(type[3]);
						}
						if (type[0].equals("LightSetPoint")) {
							gun.am_light_x = Float.parseFloat(type[1]);
							gun.am_light_y = Float.parseFloat(type[2]);
							gun.am_light_z = Float.parseFloat(type[3]);
						}
						if (type[0].equals("LightSetAngle")) {
							gun.am_light_xr = Float.parseFloat(type[1]);
							gun.am_light_yr = Float.parseFloat(type[2]);
							gun.am_light_zr = Float.parseFloat(type[3]);
						}
						if (type[0].equals("MuzzleSetPoint")) {
							gun.am_supu_x = Float.parseFloat(type[1]);
							gun.am_supu_y = Float.parseFloat(type[2]);
							gun.am_supu_z = Float.parseFloat(type[3]);
						}
						if (type[0].equals("MuzzleSetAngle")) {
							gun.am_supu_xr = Float.parseFloat(type[1]);
							gun.am_supu_yr = Float.parseFloat(type[2]);
							gun.am_supu_zr = Float.parseFloat(type[3]);
						}
						if (type[0].equals("GripSetPoint")) {
							gun.am_grip_x = Float.parseFloat(type[1]);
							gun.am_grip_y = Float.parseFloat(type[2]);
							gun.am_grip_z = Float.parseFloat(type[3]);
						}
						if (type[0].equals("GripSetAngle")) {
							gun.am_grip_xr = Float.parseFloat(type[1]);
							gun.am_grip_yr = Float.parseFloat(type[2]);
							gun.am_grip_zr = Float.parseFloat(type[3]);
						}
						
						if (type[0].equals("Mugen")) {
							gun.mugen = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("MugenMag")) {
							gun.mugenmaga = Boolean.parseBoolean(type[1]);
						}
						
						
						if (type[0].equals("Shield_defence")) {
							gun.Shield_defence = Float.parseFloat(type[1]);
						}
						if (type[0].equals("AAM")) {
							gun.aam = Boolean.parseBoolean(type[1]);
						}
						
						if (type[0].equals("Render_Sight")) {
							gun.render_sight = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Render_Light")) {
							gun.render_light = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Render_Muzz")) {
							gun.render_muss = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Render_Grip")) {
							gun.render_grip = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Render_mat4_default")) {
							gun.render_mat4_unam = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Render_mat6_default")) {
							gun.render_mat6_unam = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Render_mat8_default")) {
							gun.render_mat8_unam = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Render_mat9_default")) {
							gun.render_mat9_unam = Boolean.parseBoolean(type[1]);
						}
						
						if (type[0].equals("Render_crosshair_ADS")) {
							gun.render_cross_sneak = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("RenderingLight")) {
							gun.rendering_light = Boolean.parseBoolean(type[1]);
						}
						
						if (type[0].equals("gun_can_use_underbarrel")) {
							gun.gun_can_use_underbarrel = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("gun_can_get_underbarrel")) {
							gun.gun_can_get_underbarrel = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("gun_can_set_underbarrel")) {
							gun.gun_can_set_underbarrel = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("gun_underbarrel_x")) {
							gun.gun_underbarrel_x = Float.parseFloat(type[1]);
						}
						if (type[0].equals("gun_underbarrel_y")) {
							gun.gun_underbarrel_y = Float.parseFloat(type[1]);
						}
						if (type[0].equals("gun_underbarrel_z")) {
							gun.gun_underbarrel_z = Float.parseFloat(type[1]);
						}
						
						if (type[0].equals("Render_Gun_CrossHair")) {
							gun.render_gvc_cross = Boolean.parseBoolean(type[1]);
						}
						
						
						if (type[0].equals("Render_Default_Light")) {
							gun.render_default_light = Boolean.parseBoolean(type[1]);
							gun.am_light = Boolean.parseBoolean(type[1]);
						}
						if (type[0].equals("Light_KAZU")) {
							gun.am_light_kazu = Integer.parseInt(type[1]);
						}
						if (type[0].equals("ColorLevel")) {
							for(int ii = 0; ii < gun.am_light_kazu; ++ii) {
								gun.am_colorlevel[ii] = Float.parseFloat(type[1 + ii]);
							}
						}
						*/
					}

				}
				br.close(); // ファイルを閉じる
			}
		} catch (FileNotFoundException ex) {
			ex.printStackTrace();
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}

	private static boolean checkBeforeReadfile(File file) {
		if (file.exists()) {
			if (file.isFile() && file.canRead()) {
				return true;
			}
		}

		return false;
	}
	
}
