OSDN Git Service

372656ac6903403b403f536706c761334ba23ddc
[chemicraft/chemicraft.git] / common / chemicraft / ChemiCraft.java
1 package chemicraft;\r
2 \r
3 import net.minecraft.src.Block;\r
4 import net.minecraft.src.CreativeTabs;\r
5 import net.minecraft.src.Item;\r
6 import net.minecraft.src.Material;\r
7 import net.minecraftforge.common.Configuration;\r
8 import net.minecraftforge.common.Property;\r
9 import chemicraft.Auxiliary.NameAuxiliary;\r
10 import cpw.mods.fml.common.Mod;\r
11 import cpw.mods.fml.common.SidedProxy;\r
12 import cpw.mods.fml.common.event.FMLPostInitializationEvent;\r
13 import cpw.mods.fml.common.event.FMLPreInitializationEvent;\r
14 import cpw.mods.fml.common.network.NetworkMod;\r
15 import cpw.mods.fml.common.network.NetworkRegistry;\r
16 import cpw.mods.fml.common.registry.GameRegistry;\r
17 \r
18 /**\r
19  * ChemiCraft本体\r
20  *\r
21  * @author P.C.C.\r
22  *\r
23  */\r
24 @Mod(modid = "chemiCraft", name = "ChemiCraft", version = "beta")\r
25 // ID,名前,バージョン\r
26 @NetworkMod(clientSideRequired = true, serverSideRequired = false, versionBounds = "1.3.2", channels = "chemicraft", packetHandler = PacketHandler.class)\r
27 // クライアント、サーバー共に必要 1.3.2用\r
28 public class ChemiCraft {\r
29 \r
30         public final String[] atomsName = { "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon",\r
31                         "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium",\r
32                         "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttorium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium",\r
33                         "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium",\r
34                         "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum",\r
35                         "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium",\r
36                         "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium",\r
37                         "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Ununtrium", "Ununquadium", "Ununpentium", "Ununhexium", "Ununseptium", "Ununoctium" };\r
38 \r
39         public final String[] atomsNameJP = { "水素", "ヘリウム", "リチウム", "ベリウム", "ホウ素", "炭素", "窒素", "酸素", "フッ素", "ネオン", "ナトリウム", "マグネシウム", "アルミニウム", "ケイ素", "リン", "硫黄", "塩素", "アルゴン", "カリウム", "カルシウム", "スカンジウム",\r
40                         "チタン", "バナジウム", "クロム", "マンガン", "鉄", "コバルト", "ニッケル", "銅", "亜鉛", "ガリウム", "ゲルマニウム", "ヒ素", "セレン", "臭素", "クリプトン", "ルビジウム", "ストロンチウム", "イットリウム", "ジルコニウム", "ニオブ", "モリブデン", "テクネチウム", "ルテニウム",\r
41                         "ロジウム", "パラジウム", "銀", "カドミウム", "インジウム", "スズ", "アンチモン", "テルル", "ヨウ素", "キセノン", "セシウム", "バリウム", "ランタン", "セリウム", "プラセオジム", "ネオジム", "プロメチウム", "サマリウム", "ユウロビウム", "ガドリニウム", "テルビウム", "ジスプロニウム",\r
42                         "ホルミウム", "エルビウム", "ツリウム", "イッテルビウム", "ルテチウム", "ハフニウム", "タンタル", "タングステン", "レニウム", "オスミウム", "イリジウム", "白金", "金", "水銀", "タリウム", "鉛", "ビスマス", "ポロニウム", "アスタチン", "ラドン", "フランシウム", "ラジウム",\r
43                         "アクチニウム", "トリウム", "プロトアクチウム", "ウラン", "ネプツニウム", "プルトニウム", "アメリシウム", "キュリウム", "バークリウム", "カルホルニウム", "アインスタイニウム", "フェルミウム", "メンデレビウム", "ノーベリウム", "ローレンシウム", "ラサホージウム", "ドブニウム", "シーボーギウム",\r
44                         "ボーリウム", "ハッシウム", "マイトネリウム", "ダームスタチウム", "レントゲニウム", "コペルニシウム", "ウンウントリウム", "ウンウンクアジウム", "ウンウンペンチウム", "ウンウンヘキシウム", "ウンウンセプチウム", "ウンウンオクチウム" };\r
45 \r
46         /**\r
47          * このmodのインスタンス\r
48          */\r
49         @Mod.Instance("chemiCraft")\r
50         public static ChemiCraft instance;\r
51 \r
52         /**\r
53          * ChemiCraftのProxy\r
54          */\r
55         @SidedProxy(clientSide = "chemicraft.client.ClientProxy", serverSide = "chemicraft.CommonProxy")\r
56         public static CommonProxy proxy;\r
57 \r
58         /**\r
59          * ChemiCraftのCreativeTab\r
60          */\r
61         public CreativeTabs creativeTab = new CreativeTabAtoms("ChemiCraft");\r
62 \r
63         /**\r
64          * ItemID\r
65          */\r
66         public int atomsID;\r
67         public int compoundsID;\r
68         public int gasCollectingBottleID;\r
69 \r
70         /**\r
71          * BlockID\r
72          */\r
73         public int decompositionTableID;\r
74         public int chemicalConbinationTableID;\r
75         public int toolAndWeaponCraftingTableID;\r
76         public int materialCraftingTableID;\r
77 \r
78         /**\r
79          * GUIID\r
80          */\r
81         public int guiDecompositionTableID;\r
82         public int guiChemicalCombinationTableID;\r
83         public int guiToolAndWeaponCraftingTableID;\r
84         public int guiMaterialCraftingTableID;\r
85 \r
86         /**\r
87          * Block型変数\r
88          */\r
89         public Block blockDecompositionTable;\r
90         public Block blockChemicalCombinationTable;\r
91         public Block blockToolAndWeaponCraftingTable;\r
92         public Block blockMaterialCraftingTable;\r
93 \r
94         /**\r
95          * Item型変数\r
96          */\r
97         public Item itemAtoms;\r
98         public Item itemCompounds;\r
99         public Item itemGasCollectingBottle;\r
100 \r
101         /**\r
102          * このmodで使用するTextureのパス\r
103          */\r
104         public String itemAtomsTexture = "/chemicraft/items/Atoms.png";\r
105         public String itemCompoundsTexture = "/chemicraft/items/Compounds.png";\r
106         public String blockChemicalCraftingTableTexture = "/chemicraft/blocks/CCTable.png";\r
107         public String guiDecompositionTexture = "/chemicraft/guis/Decomposition.png";\r
108         public String guiChemicalCombinationTexture = "/chemicraft/guis/ChemicalCombination.png";\r
109         public String guiToolAndWeaponCraftingTexture = "/chemicraft/guis/ToolAndWeaponCrafting.png";\r
110         public String guiMaterialCraftingTexture = "/chemicraft/guis/MaterialCrafting.png";\r
111 \r
112         /**\r
113          * このmodに必要な補助クラスのインスタンス\r
114          */\r
115         private Auxiliary Auxiliary = new Auxiliary();\r
116         private NameAuxiliary NameAuxiliary = Auxiliary.new NameAuxiliary();\r
117 \r
118 \r
119         @Mod.PreInit\r
120         public void chemiPreLoadMethod(FMLPreInitializationEvent event) {\r
121                 Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());\r
122                 cfg.load();\r
123 \r
124                 Property decompositionTableIDProp = cfg.getBlock("DecompositionTable", 2400);\r
125                 Property chemicalCombinationTableIDProp = cfg.getBlock("ChemicalCombinationID", 2401);\r
126                 Property toolAndWeaponCraftingTableIDProp = cfg.getBlock("ToolAndWeaponCraftingTableID", 2402);\r
127                 Property materialCraftingTableIDProp = cfg.getBlock("MaterialCraftingTableID", 2403);\r
128 \r
129                 Property atomsIDProp = cfg.getItem("AtomsID", 25000);\r
130                 Property compoundsIDProp = cfg.getItem("CompoundsID", 25001);\r
131                 Property gasCollectingBottleIDProp = cfg.getItem("gasCollectingBottleID", 25002);\r
132 \r
133                 Property guiDecompositionTableIDProp = cfg.get("GUI", "GUIChemicalCraftingTableID", 1000);\r
134                 Property guiChemicalCombinationTableIDProp = cfg.get("GUI", "GUIChemicalCombinationTableID", 1001);\r
135                 Property guiToolAndWeaponCraftingTableIDProp = cfg.get("GUI", "GUIToolAndWeaponCraftingTableID", 1002);\r
136                 Property guiMaterialCraftingTableIDProp = cfg.get("GUI", "GUIMaterialCraftingTableID", 1003);\r
137 \r
138 \r
139                 this.decompositionTableID = decompositionTableIDProp.getInt();\r
140                 this.chemicalConbinationTableID = chemicalCombinationTableIDProp.getInt();\r
141                 this.toolAndWeaponCraftingTableID = toolAndWeaponCraftingTableIDProp.getInt();\r
142                 this.materialCraftingTableID = materialCraftingTableIDProp.getInt();\r
143                 this.atomsID = atomsIDProp.getInt();\r
144                 this.compoundsID = compoundsIDProp.getInt();\r
145                 this.gasCollectingBottleID = gasCollectingBottleIDProp.getInt();\r
146                 this.guiDecompositionTableID = guiDecompositionTableIDProp.getInt();\r
147                 this.guiChemicalCombinationTableID = guiChemicalCombinationTableIDProp.getInt();\r
148                 this.guiToolAndWeaponCraftingTableID = guiToolAndWeaponCraftingTableIDProp.getInt();\r
149                 this.guiMaterialCraftingTableID = guiMaterialCraftingTableIDProp.getInt();\r
150 \r
151                 cfg.save();\r
152 \r
153                 // 描画関係の読み込み\r
154                 proxy.registerRenderInformation();\r
155         }\r
156 \r
157 \r
158         @Mod.PostInit\r
159         public void chemiPostLoadMethod(FMLPostInitializationEvent event) {\r
160                 // API用の処理\r
161                 this.NameAuxiliary.addName(itemCompounds, ChemiCraftAPI.getCompoundsName().toArray());\r
162                 this.NameAuxiliary.addName(itemCompounds, "ja_JP", ChemiCraftAPI.getCompoundsLangName().toArray());\r
163 \r
164                 // Blockを追加します\r
165                 this.blockDecompositionTable = new BlockDecompositionTable(this.decompositionTableID, 0, Material.ground).setHardness(2.0F).setResistance(0.0F).setStepSound(Block.soundStoneFootstep).setBlockName("DecompositionTable");\r
166                 this.blockChemicalCombinationTable = new BlockChemicalCombinationTable(this.chemicalConbinationTableID, 0, Material.ground).setHardness(2.0F).setResistance(0.0F).setStepSound(Block.soundStoneFootstep).setBlockName("ChemicalCombinationTable");\r
167                 this.blockToolAndWeaponCraftingTable = new BlockToolAndMaterialCraftingTable(this.toolAndWeaponCraftingTableID, 0, Material.ground).setHardness(2.0F).setResistance(0.0F).setStepSound(Block.soundStoneFootstep).setBlockName("ToolAndWeaponCraftingTable");\r
168                 this.blockMaterialCraftingTable = new BlockMaterialCraftingTable(materialCraftingTableID, 0, Material.ground).setHardness(2.0F).setResistance(0.0F).setStepSound(Block.soundStoneFootstep).setBlockName("MaterialCraftingTable");\r
169 \r
170 \r
171                 // Itemを追加します\r
172                 this.itemAtoms = new ItemAtoms(this.atomsID).setItemName("atoms");\r
173                 this.itemCompounds = new ItemCompounds(this.compoundsID).setItemName("compounds");\r
174                 this.itemGasCollectingBottle = new ItemGasCollectingBottle(this.gasCollectingBottleID).setItemName("gasCollectingBottle");\r
175 \r
176                 // BlockをMinecraftに登録します\r
177                 GameRegistry.registerBlock(this.blockDecompositionTable);\r
178                 GameRegistry.registerBlock(this.blockChemicalCombinationTable);\r
179                 GameRegistry.registerBlock(this.blockToolAndWeaponCraftingTable);\r
180                 GameRegistry.registerBlock(this.blockMaterialCraftingTable);\r
181 \r
182                 // Blockの名前を設定します\r
183                 this.NameAuxiliary.addName(this.blockDecompositionTable, "DecompositionTable");\r
184                 this.NameAuxiliary.addName(this.blockDecompositionTable, "ja_JP", "分解台");\r
185                 this.NameAuxiliary.addName(this.blockChemicalCombinationTable, "ChemicalCombinationTable");\r
186                 this.NameAuxiliary.addName(this.blockChemicalCombinationTable, "ja_JP", "化合台");\r
187                 this.NameAuxiliary.addName(blockToolAndWeaponCraftingTable, "ToolAndWeaponCraftingTable");\r
188                 this.NameAuxiliary.addName(blockToolAndWeaponCraftingTable, "ja_JP", "ツール&武器製作台");\r
189                 this.NameAuxiliary.addName(blockMaterialCraftingTable, "MaterialCraftingTable");\r
190                 this.NameAuxiliary.addName(blockMaterialCraftingTable, "ja_JP", "素材製作台");\r
191 \r
192 \r
193                 // Itemの名前を設定します\r
194                 this.NameAuxiliary.addName(this.itemAtoms, atomsName);\r
195                 this.NameAuxiliary.addName(this.itemAtoms, "ja_JP", atomsNameJP);\r
196                 this.NameAuxiliary.addName(this.itemGasCollectingBottle, "GasCollectingBottle");\r
197                 this.NameAuxiliary.addName(this.itemGasCollectingBottle, "ja_JP", "集気瓶");\r
198 \r
199                 // TileEntityを追加します\r
200                 GameRegistry.registerTileEntity(TileEntityDecompositionTable.class, "DecompositionTable");\r
201                 GameRegistry.registerTileEntity(TileEntityChemicalCombinationTable.class, "TileEntityChemicalCombinationTable");\r
202                 GameRegistry.registerTileEntity(TileEntityToolAndWeaponCraftingTable.class, "TileEntityToolAndWeaponCraftingTable");\r
203                 GameRegistry.registerTileEntity(TileEntityMaterialCraftingTable.class, "TileEntityMaterialCraftingTable");\r
204 \r
205                 // GUIを追加します\r
206                 NetworkRegistry.instance().registerGuiHandler(instance, proxy);\r
207 \r
208                 //Textureをpreloadします\r
209                 proxy.registerTextures();\r
210         }\r
211 \r
212 }