OSDN Git Service

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