OSDN Git Service

471e34ddb15fd2243fcb3424fc04ba060baef868
[chemicraft/chemicraft.git] / common / chemicraft / ChemiCraft.java
1 package chemicraft;\r
2 \r
3 import net.minecraft.block.Block;\r
4 import net.minecraft.block.material.Material;\r
5 import net.minecraft.creativetab.CreativeTabs;\r
6 import net.minecraft.item.Item;\r
7 import net.minecraft.item.ItemStack;\r
8 import net.minecraftforge.common.Configuration;\r
9 import net.minecraftforge.common.Property;\r
10 import chemicraft.block.BlockChemicalCombinationTable;\r
11 import chemicraft.block.BlockChemicalCraftingTable;\r
12 import chemicraft.block.BlockDecompositionTable;\r
13 import chemicraft.block.BlockToolAndWeaponCraftingTable;\r
14 import chemicraft.compounds.CompoundWater;\r
15 import chemicraft.debug.CommandDeleteItem;\r
16 import chemicraft.debug.CommandGenDebugRoom;\r
17 import chemicraft.debug.CommandSetTile;\r
18 import chemicraft.item.ItemAtoms;\r
19 import chemicraft.item.ItemAtomsGrenade;\r
20 import chemicraft.item.ItemCompounds;\r
21 import chemicraft.item.ItemGasCollectingBottle;\r
22 import chemicraft.system.CommonProxy;\r
23 import chemicraft.system.PacketHandler;\r
24 import chemicraft.tileentity.TileEntityChemicalCombinationTable;\r
25 import chemicraft.tileentity.TileEntityChemicalCraftingTable;\r
26 import chemicraft.tileentity.TileEntityDecompositionTable;\r
27 import chemicraft.tileentity.TileEntityToolAndWeaponCraftingTable;\r
28 import chemicraft.util.Auxiliary;\r
29 import chemicraft.util.Auxiliary.ArrayAuxiliary;\r
30 import chemicraft.util.Auxiliary.NameAuxiliary;\r
31 import chemicraft.util.CreativeTabAtoms;\r
32 import chemicraft.util.NBTRecipeGrenade;\r
33 import cpw.mods.fml.common.Mod;\r
34 import cpw.mods.fml.common.SidedProxy;\r
35 import cpw.mods.fml.common.event.FMLPostInitializationEvent;\r
36 import cpw.mods.fml.common.event.FMLPreInitializationEvent;\r
37 import cpw.mods.fml.common.event.FMLServerStartingEvent;\r
38 import cpw.mods.fml.common.network.NetworkMod;\r
39 import cpw.mods.fml.common.network.NetworkRegistry;\r
40 import cpw.mods.fml.common.registry.GameRegistry;\r
41 \r
42 /**\r
43  * ChemiCraft本体\r
44  * @author P.C.C.\r
45  *\r
46  */\r
47 @Mod(modid = "chemiCraft", name = "ChemiCraft", version = "beta")\r
48 // ID,名前,バージョン\r
49 @NetworkMod(clientSideRequired = true, serverSideRequired = true, versionBounds = "1.3.2", channels = "chemicraft", packetHandler = PacketHandler.class)\r
50 // クライアント、サーバー共に必要 1.3.2用\r
51 public class ChemiCraft {\r
52 \r
53         public static final String[] ATOMSNAME = {\r
54                 "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon",\r
55                 "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium",\r
56                 "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttorium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium",\r
57                 "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium",\r
58                 "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum",\r
59                 "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium",\r
60                 "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium",\r
61                 "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Ununtrium", "Ununquadium", "Ununpentium", "Ununhexium", "Ununseptium", "Ununoctium" };\r
62 \r
63         public static final String[] ATOMSNAMEJP = {\r
64                 "水素", "ヘリウム", "リチウム", "ベリウム", "ホウ素", "炭素", "窒素", "酸素", "フッ素", "ネオン", "ナトリウム", "マグネシウム", "アルミニウム", "ケイ素", "リン", "硫黄", "塩素", "アルゴン", "カリウム", "カルシウム", "スカンジウム",\r
65                 "チタン", "バナジウム", "クロム", "マンガン", "鉄", "コバルト", "ニッケル", "銅", "亜鉛", "ガリウム", "ゲルマニウム", "ヒ素", "セレン", "臭素", "クリプトン", "ルビジウム", "ストロンチウム", "イットリウム", "ジルコニウム", "ニオブ", "モリブデン", "テクネチウム", "ルテニウム",\r
66                 "ロジウム", "パラジウム", "銀", "カドミウム", "インジウム", "スズ", "アンチモン", "テルル", "ヨウ素", "キセノン", "セシウム", "バリウム", "ランタン", "セリウム", "プラセオジム", "ネオジム", "プロメチウム", "サマリウム", "ユウロビウム", "ガドリニウム", "テルビウム", "ジスプロニウム",\r
67                 "ホルミウム", "エルビウム", "ツリウム", "イッテルビウム", "ルテチウム", "ハフニウム", "タンタル", "タングステン", "レニウム", "オスミウム", "イリジウム", "白金", "金", "水銀", "タリウム", "鉛", "ビスマス", "ポロニウム", "アスタチン", "ラドン", "フランシウム", "ラジウム",\r
68                 "アクチニウム", "トリウム", "プロトアクチウム", "ウラン", "ネプツニウム", "プルトニウム", "アメリシウム", "キュリウム", "バークリウム", "カルホルニウム", "アインスタイニウム", "フェルミウム", "メンデレビウム", "ノーベリウム", "ローレンシウム", "ラサホージウム", "ドブニウム", "シーボーギウム",\r
69                 "ボーリウム", "ハッシウム", "マイトネリウム", "ダームスタチウム", "レントゲニウム", "コペルニシウム", "ウンウントリウム", "ウンウンクアジウム", "ウンウンペンチウム", "ウンウンヘキシウム", "ウンウンセプチウム", "ウンウンオクチウム" };\r
70 \r
71         /**\r
72          * このmodのインスタンス\r
73          */\r
74         @Mod.Instance("chemiCraft")\r
75         public static ChemiCraft instance;\r
76 \r
77         /**\r
78          * ChemiCraftのProxy.\r
79          */\r
80         @SidedProxy(clientSide = "chemicraft.client.ClientProxy", serverSide = "chemicraft.system.CommonProxy")\r
81         public static CommonProxy proxy;\r
82 \r
83         /**\r
84          * ChemiCraftのCreativeTab.\r
85          */\r
86         public static final CreativeTabs creativeTab = new CreativeTabAtoms("ChemiCraft");\r
87 \r
88         /**\r
89          * ItemID.\r
90          */\r
91         public int atomsID;\r
92         public int compoundsID;\r
93         public int gasCollectingBottleID;\r
94         public int atomGrenadeID;\r
95 \r
96         /**\r
97          * BlockID.\r
98          */\r
99         public int decompositionTableID;\r
100         public int chemicalConbinationTableID;\r
101         public int toolAndWeaponCraftingTableID;\r
102         public int chemicalCraftingTableID;\r
103 \r
104         /**\r
105          * GUIID.\r
106          */\r
107         public int guiDecompositionTableID;\r
108         public int guiChemicalCombinationTableID;\r
109         public int guiToolAndWeaponCraftingTableID;\r
110         public int guiChemicalCraftingTableID;\r
111 \r
112         /**\r
113          * Block型変数.\r
114          */\r
115         public Block blockDecompositionTable;\r
116         public Block blockChemicalCombinationTable;\r
117         public Block blockToolAndWeaponCraftingTable;\r
118         public Block blockChemicalCraftingTable;\r
119 \r
120         /**\r
121          * Item型変数.\r
122          */\r
123         public Item itemAtoms;\r
124         public Item itemCompounds;\r
125         public Item itemGasCollectingBottle;\r
126         public Item itemAtomGrenade;\r
127 \r
128         /**\r
129          * このmodで使用するTextureのパス.\r
130          */\r
131         public String itemAtomsTexture = "/chemicraft/items/Atoms.png";\r
132         public String itemCompoundsTexture = "/chemicraft/items/Compounds.png";\r
133         public String itemTexture = "/chemicraft/items/items.png";\r
134         public String blockChemicalCraftingTableTexture = "/chemicraft/blocks/CCTable.png";\r
135         public String guiDecompositionTexture = "/chemicraft/guis/Decomposition.png";\r
136         public String guiChemicalCombinationTexture = "/chemicraft/guis/ChemicalCombination.png";\r
137         public String guiToolAndWeaponCraftingTexture = "/chemicraft/guis/ToolAndWeaponCrafting.png";\r
138         public String guiChemicalCraftingTexture = "/chemicraft/guis/MaterialCrafting.png";\r
139 \r
140         /**\r
141          * このmodに必要な補助クラスのインスタンス.\r
142          */\r
143         public Auxiliary auxiliary = new Auxiliary();\r
144         public NameAuxiliary nameAuxiliary = new NameAuxiliary();\r
145         public ArrayAuxiliary arrayAuxiliary = new ArrayAuxiliary();\r
146 \r
147         private ChemiCraftAPI api = ChemiCraftAPI.getInstance();\r
148         private ChemiCraftData chemicalData = new ChemiCraftData();\r
149 \r
150         @Mod.PreInit\r
151         public void chemiPreLoadMethod(final FMLPreInitializationEvent event) {\r
152                 Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());\r
153                 cfg.load();\r
154 \r
155                 Property decompositionTableIDProp = cfg.getBlock("DecompositionTable", 2400);\r
156                 Property chemicalCombinationTableIDProp = cfg.getBlock("ChemicalCombinationID", 2401);\r
157                 Property toolAndWeaponCraftingTableIDProp = cfg.getBlock("ToolAndWeaponCraftingTableID", 2402);\r
158                 Property chemicalCraftingTableIDProp = cfg.getBlock("ChemicalCraftingTableID", 2403);\r
159 \r
160                 Property atomsIDProp = cfg.getItem("AtomsID", 25000);\r
161                 Property compoundsIDProp = cfg.getItem("CompoundsID", 25001);\r
162                 Property gasCollectingBottleIDProp = cfg.getItem("gasCollectingBottleID", 25002);\r
163                 Property atomGrenadeIDProp = cfg.getItem("AtomGrenadeID", 25003);\r
164 \r
165                 Property guiDecompositionTableIDProp = cfg.get("GUI", "GUIChemicalCraftingTableID", 1000);\r
166                 Property guiChemicalCombinationTableIDProp = cfg.get("GUI", "GUIChemicalCombinationTableID", 1001);\r
167                 Property guiToolAndWeaponCraftingTableIDProp = cfg.get("GUI", "GUIToolAndWeaponCraftingTableID", 1002);\r
168                 Property guiChemicalCraftingTableIDProp = cfg.get("GUI", "GUIChemicalCraftingTableID", 1003);\r
169 \r
170 \r
171                 this.decompositionTableID = decompositionTableIDProp.getInt();\r
172                 this.chemicalConbinationTableID = chemicalCombinationTableIDProp.getInt();\r
173                 this.toolAndWeaponCraftingTableID = toolAndWeaponCraftingTableIDProp.getInt();\r
174                 this.chemicalCraftingTableID = chemicalCraftingTableIDProp.getInt();\r
175                 this.atomsID = atomsIDProp.getInt();\r
176                 this.compoundsID = compoundsIDProp.getInt();\r
177                 this.gasCollectingBottleID = gasCollectingBottleIDProp.getInt();\r
178                 this.atomGrenadeID = atomGrenadeIDProp.getInt();\r
179                 this.guiDecompositionTableID = guiDecompositionTableIDProp.getInt();\r
180                 this.guiChemicalCombinationTableID = guiChemicalCombinationTableIDProp.getInt();\r
181                 this.guiToolAndWeaponCraftingTableID = guiToolAndWeaponCraftingTableIDProp.getInt();\r
182                 this.guiChemicalCraftingTableID = guiChemicalCraftingTableIDProp.getInt();\r
183 \r
184                 cfg.save();\r
185         }\r
186 \r
187         @Mod.ServerStarting\r
188         public void serverStarting(final FMLServerStartingEvent event) {\r
189                 event.registerServerCommand(new CommandSetTile());\r
190                 event.registerServerCommand(new CommandDeleteItem());\r
191                 event.registerServerCommand(new CommandGenDebugRoom());\r
192         }\r
193 \r
194         @Mod.PostInit\r
195         public void chemiPostLoadMethod(final FMLPostInitializationEvent event) {\r
196                 this.settingProcessing(event);\r
197                 this.apiProcessing(event);\r
198                 this.debug(event);\r
199         }\r
200 \r
201         private void settingProcessing(final FMLPostInitializationEvent event) {\r
202 \r
203                 // Blockを追加します\r
204                 this.blockDecompositionTable = new BlockDecompositionTable(this.decompositionTableID, 0, Material.ground).\r
205                                 setHardness(2.0F).\r
206                                 setResistance(0.0F).\r
207                                 setStepSound(Block.soundStoneFootstep).\r
208                                 setBlockName("DecompositionTable");\r
209                 this.blockChemicalCombinationTable = new BlockChemicalCombinationTable(this.chemicalConbinationTableID, 0, Material.ground).\r
210                                 setHardness(2.0F).\r
211                                 setResistance(0.0F).\r
212                                 setStepSound(Block.soundStoneFootstep).\r
213                                 setBlockName("ChemicalCombinationTable");\r
214                 this.blockToolAndWeaponCraftingTable = new BlockToolAndWeaponCraftingTable(this.toolAndWeaponCraftingTableID, 0, Material.ground).\r
215                                 setHardness(2.0F).\r
216                                 setResistance(0.0F).\r
217                                 setStepSound(Block.soundStoneFootstep).\r
218                                 setBlockName("ToolAndWeaponCraftingTable");\r
219                 this.blockChemicalCraftingTable = new BlockChemicalCraftingTable(chemicalCraftingTableID, 0, Material.ground).\r
220                                 setHardness(2.0F).\r
221                                 setResistance(0.0F).\r
222                                 setStepSound(Block.soundStoneFootstep).\r
223                                 setBlockName("ChemicalCraftingTable");\r
224 \r
225                 // Itemを追加します\r
226                 this.itemAtoms = new ItemAtoms(this.atomsID).setItemName("atoms");\r
227                 this.itemCompounds = new ItemCompounds(this.compoundsID).setItemName("compounds");\r
228                 this.itemGasCollectingBottle = new ItemGasCollectingBottle(this.gasCollectingBottleID).setItemName("gasCollectingBottle").setIconIndex(0);\r
229                 this.itemAtomGrenade = new ItemAtomsGrenade(this.atomGrenadeID).setItemName("grenade").setIconIndex(1);\r
230 \r
231                 // BlockをMinecraftに登録します\r
232                 GameRegistry.registerBlock(this.blockDecompositionTable, "BlockDecompositionTable");\r
233                 GameRegistry.registerBlock(this.blockChemicalCombinationTable, "BlockChemicalCombinationTable");\r
234                 GameRegistry.registerBlock(this.blockToolAndWeaponCraftingTable, "BlockToolAndWeaponCraftingTable");\r
235                 GameRegistry.registerBlock(this.blockChemicalCraftingTable, "BlockMaterialCraftingTable");\r
236 \r
237                 // Blockの名前を設定します\r
238                 this.nameAuxiliary.addName(this.blockDecompositionTable, "DecompositionTable");\r
239                 this.nameAuxiliary.addName(this.blockDecompositionTable, "ja_JP", "分解台");\r
240                 this.nameAuxiliary.addName(this.blockChemicalCombinationTable, "ChemicalCombinationTable");\r
241                 this.nameAuxiliary.addName(this.blockChemicalCombinationTable, "ja_JP", "化合台");\r
242                 this.nameAuxiliary.addName(blockToolAndWeaponCraftingTable, "ToolAndWeaponCraftingTable");\r
243                 this.nameAuxiliary.addName(blockToolAndWeaponCraftingTable, "ja_JP", "ツール&武器製作台");\r
244                 this.nameAuxiliary.addName(blockChemicalCraftingTable, "ChemicalCraftingTable");\r
245                 this.nameAuxiliary.addName(blockChemicalCraftingTable, "ja_JP", "素材製作台");\r
246 \r
247                 // Itemの名前を設定します\r
248                 this.nameAuxiliary.addName(this.itemAtoms, ATOMSNAME);\r
249                 this.nameAuxiliary.addName(this.itemAtoms, "ja_JP", ATOMSNAMEJP);\r
250                 this.nameAuxiliary.addName(this.itemGasCollectingBottle, "GasCollectingBottle");\r
251                 this.nameAuxiliary.addName(this.itemGasCollectingBottle, "ja_JP", "集気瓶");\r
252                 this.nameAuxiliary.addName(this.itemAtomGrenade, "AtomGrenade");\r
253                 this.nameAuxiliary.addName(this.itemAtomGrenade, "元素手榴弾");\r
254 \r
255                 // TileEntityを追加します\r
256                 GameRegistry.registerTileEntity(TileEntityDecompositionTable.class, "DecompositionTable");\r
257                 GameRegistry.registerTileEntity(TileEntityChemicalCombinationTable.class, "TileEntityChemicalCombinationTable");\r
258                 GameRegistry.registerTileEntity(TileEntityToolAndWeaponCraftingTable.class, "TileEntityToolAndWeaponCraftingTable");\r
259                 GameRegistry.registerTileEntity(TileEntityChemicalCraftingTable.class, "TileEntityChemicalCraftingTable");\r
260 \r
261                 // GUIを追加します\r
262                 NetworkRegistry.instance().registerGuiHandler(instance, proxy);\r
263 \r
264                 // 描画関係の読み込み\r
265                 proxy.registerRenderInformation();\r
266 \r
267                 //化学作業台類のレシピを追加します\r
268                 GameRegistry.addRecipe(new ItemStack(this.blockDecompositionTable),\r
269                                 new Object[]{\r
270                         "XYX", "ZAZ", "ZZZ",\r
271                         Character.valueOf('X'), new ItemStack(Item.ingotIron),\r
272                         Character.valueOf('Y'), new ItemStack(Block.workbench),\r
273                         Character.valueOf('Z'), new ItemStack(Block.stone),\r
274                         Character.valueOf('A'), new ItemStack(Block.tnt),\r
275                 });\r
276                 GameRegistry.addRecipe(new ItemStack(this.blockChemicalCombinationTable),\r
277                                 new Object[]{\r
278                         "XYX", "ZAZ", "ZZZ",\r
279                         Character.valueOf('X'), new ItemStack(Item.ingotIron),\r
280                         Character.valueOf('Y'), new ItemStack(Block.workbench),\r
281                         Character.valueOf('Z'), new ItemStack(Block.stone),\r
282                         Character.valueOf('A'), new ItemStack(Block.obsidian),\r
283                 });\r
284                 GameRegistry.addRecipe(new ItemStack(this.blockToolAndWeaponCraftingTable),\r
285                                 new Object[]{\r
286                         "XYX", "ZAZ", "ZZZ",\r
287                         Character.valueOf('X'), new ItemStack(Item.ingotIron),\r
288                         Character.valueOf('Y'), new ItemStack(Block.workbench),\r
289                         Character.valueOf('Z'), new ItemStack(Block.stone),\r
290                         Character.valueOf('A'), new ItemStack(Item.pickaxeSteel),\r
291                 });\r
292                 GameRegistry.addRecipe(new ItemStack(this.blockChemicalCraftingTable),\r
293                                 new Object[]{\r
294                         "XYX", "ZAZ", "ZZZ",\r
295                         Character.valueOf('X'), new ItemStack(Item.ingotIron),\r
296                         Character.valueOf('Y'), new ItemStack(Block.workbench),\r
297                         Character.valueOf('Z'), new ItemStack(Block.stone),\r
298                         Character.valueOf('A'), new ItemStack(this.itemAtoms, 1, 0),\r
299                 });\r
300 \r
301                 // 化合物を追加します\r
302                 api.addLangCompound("ja_JP", "CarbonMonoxide", "一酸化炭素");\r
303                 api.addLangCompound("ja_JP", "CarbonDioxide", "二酸化炭素");\r
304                 api.addLangCompound("ja_JP", "Water", "水");\r
305                 api.addCompound("Test");\r
306
307 \r
308                 //化合物のHandlerを設定します\r
309                 api.settingCompoundHandler("Water", new CompoundWater());\r
310 \r
311                 //化合物のレシピを追加します\r
312                 api.addChemicalCombinationRecipe(new String[]{"H", "O"}, new Integer[]{2, 1}, new ItemStack(this.itemCompounds, 1, api.getCompound("Water")));\r
313 \r
314                 //手榴弾の追加\r
315                 api.addMaterialRecipe(\r
316                                 new ItemStack[]{\r
317                                                 null,\r
318                                                 new ItemStack(Block.stone),\r
319                                                 null,\r
320                                                 new ItemStack(Block.stone),\r
321                                                 new ItemStack(Item.gunpowder),\r
322                                                 new ItemStack(Block.stone),\r
323                                                 null,\r
324                                                 new ItemStack(Block.stone),\r
325                                                 null\r
326                                 },\r
327                                 new ItemStack(this.itemAtomGrenade, 16, 0),\r
328                                 new NBTRecipeGrenade()\r
329                                 );\r
330         }\r
331 \r
332         private void apiProcessing(final FMLPostInitializationEvent event) {\r
333                 // API用の処理\r
334                 this.nameAuxiliary.addName(itemCompounds, api.getInstance().getCompoundsName().toArray());\r
335                 for (int i = 0; i < api.getCompoundsLang().size(); i++) {\r
336                         this.nameAuxiliary.addName(itemCompounds, api.getCompoundsLang().get(i), api.getInstance().getCompoundsLangName().toArray());\r
337                 }\r
338         }\r
339 \r
340         private void debug(final FMLPostInitializationEvent event) {\r
341         }\r
342 \r
343 }