OSDN Git Service

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