OSDN Git Service

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