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