OSDN Git Service

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