OSDN Git Service

290790b66df3096caf43389b7fa2c743c10e12cb
[chemicraft/chemicraft.git] / common / chemicraft / ChemiCraft.java
1 package 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.BiomeManager;
9 import net.minecraftforge.common.Configuration;
10 import net.minecraftforge.common.DimensionManager;
11 import net.minecraftforge.common.Property;
12 import chemicraft.block.BlockChemicalCombinationTable;
13 import chemicraft.block.BlockChemicalCraftingTable;
14 import chemicraft.block.BlockPyrolysisTable;
15 import chemicraft.block.BlockToolAndWeaponCraftingTable;
16 import chemicraft.compounds.CompoundWater;
17 import chemicraft.debug.CommandDeleteItem;
18 import chemicraft.debug.CommandGenDebugRoom;
19 import chemicraft.debug.CommandSetTile;
20 import chemicraft.item.ItemAtoms;
21 import chemicraft.item.ItemAtomsGrenade;
22 import chemicraft.item.ItemCompounds;
23 import chemicraft.item.ItemGasCollectingBottle;
24 import chemicraft.system.CommonProxy;
25 import chemicraft.system.PacketHandler;
26 import chemicraft.tileentity.TileEntityChemicalCombinationTable;
27 import chemicraft.tileentity.TileEntityChemicalCraftingTable;
28 import chemicraft.tileentity.TileEntityPyrolysisTable;
29 import chemicraft.tileentity.TileEntityToolAndWeaponCraftingTable;
30 import chemicraft.util.Auxiliary;
31 import chemicraft.util.Auxiliary.ArrayAuxiliary;
32 import chemicraft.util.Auxiliary.NameAuxiliary;
33 import chemicraft.util.CreativeTabAtoms;
34 import chemicraft.util.NBTRecipeGrenade;
35 import chemicraft.util.WorldProviderChemical;
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
105         /**
106          * GUIID.
107          */
108         public int guiPyrolysisTableID;
109         public int guiChemicalCombinationTableID;
110         public int guiToolAndWeaponCraftingTableID;
111         public int guiChemicalCraftingTableID;
112
113         /**
114          * Block型変数.
115          */
116         public Block blockPyrolysisTable;
117         public Block blockChemicalCombinationTable;
118         public Block blockToolAndWeaponCraftingTable;
119         public Block blockChemicalCraftingTable;
120
121         /**
122          * Item型変数.
123          */
124         public Item itemAtoms;
125         public Item itemCompounds;
126         public Item itemGasCollectingBottle;
127         public Item itemAtomGrenade;
128
129         /**
130          * このmodで使用するTextureのパス.
131          */
132         public String itemAtomsTexture = "/chemicraft/items/Atoms.png";
133         public String itemCompoundsTexture = "/chemicraft/items/Compounds.png";
134         public String itemTexture = "/chemicraft/items/items.png";
135         public String blockChemicalCraftingTableTexture = "/chemicraft/blocks/cctable.png";
136         public String guiPyrolysisTexture = "/chemicraft/guis/Pyrolysis.png";
137         public String guiChemicalCombinationTexture = "/chemicraft/guis/ChemicalCombination.png";
138         public String guiToolAndWeaponCraftingTexture = "/chemicraft/guis/ToolAndWeaponCrafting.png";
139         public String guiChemicalCraftingTexture = "/chemicraft/guis/MaterialCrafting.png";
140
141         /**
142          * このmodに必要な補助クラスのインスタンス.
143          */
144         public Auxiliary auxiliary = new Auxiliary();
145         public NameAuxiliary nameAuxiliary = new NameAuxiliary();
146         public ArrayAuxiliary arrayAuxiliary = new ArrayAuxiliary();
147
148         private ChemiCraftAPI api = ChemiCraftAPI.getInstance();
149         private ChemiCraftData chemicalData = new ChemiCraftData();
150
151         @Mod.PreInit
152         public void chemiPreLoadMethod(final FMLPreInitializationEvent event) {
153                 Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
154                 cfg.load();
155
156                 Property pyrolysisTableIDProp = cfg.getBlock("PyrolysisTable", 2400);
157                 Property chemicalCombinationTableIDProp = cfg.getBlock("ChemicalCombinationID", 2401);
158                 Property toolAndWeaponCraftingTableIDProp = cfg.getBlock("ToolAndWeaponCraftingTableID", 2402);
159                 Property chemicalCraftingTableIDProp = cfg.getBlock("ChemicalCraftingTableID", 2403);
160
161                 Property atomsIDProp = cfg.getItem("AtomsID", 25000);
162                 Property compoundsIDProp = cfg.getItem("CompoundsID", 25001);
163                 Property gasCollectingBottleIDProp = cfg.getItem("gasCollectingBottleID", 25002);
164                 Property atomGrenadeIDProp = cfg.getItem("AtomGrenadeID", 25003);
165
166                 Property guiPyrolysisTableIDProp = cfg.get("GUI", "GUIPyrolysisID", 1000);
167                 Property guiChemicalCombinationTableIDProp = cfg.get("GUI", "GUIChemicalCombinationTableID", 1001);
168                 Property guiToolAndWeaponCraftingTableIDProp = cfg.get("GUI", "GUIToolAndWeaponCraftingTableID", 1002);
169                 Property guiChemicalCraftingTableIDProp = cfg.get("GUI", "GUIChemicalCraftingTableID", 1003);
170
171
172                 this.pyrolysisTableID = pyrolysisTableIDProp.getInt();
173                 this.chemicalConbinationTableID = chemicalCombinationTableIDProp.getInt();
174                 this.toolAndWeaponCraftingTableID = toolAndWeaponCraftingTableIDProp.getInt();
175                 this.chemicalCraftingTableID = chemicalCraftingTableIDProp.getInt();
176                 this.atomsID = atomsIDProp.getInt();
177                 this.compoundsID = compoundsIDProp.getInt();
178                 this.gasCollectingBottleID = gasCollectingBottleIDProp.getInt();
179                 this.atomGrenadeID = atomGrenadeIDProp.getInt();
180                 this.guiPyrolysisTableID = guiPyrolysisTableIDProp.getInt();
181                 this.guiChemicalCombinationTableID = guiChemicalCombinationTableIDProp.getInt();
182                 this.guiToolAndWeaponCraftingTableID = guiToolAndWeaponCraftingTableIDProp.getInt();
183                 this.guiChemicalCraftingTableID = guiChemicalCraftingTableIDProp.getInt();
184
185                 cfg.save();
186         }
187
188         @Mod.ServerStarting
189         public void serverStarting(final FMLServerStartingEvent event) {
190                 event.registerServerCommand(new CommandSetTile());
191                 event.registerServerCommand(new CommandDeleteItem());
192                 event.registerServerCommand(new CommandGenDebugRoom());
193         }
194
195         @Mod.PostInit
196         public void chemiPostLoadMethod(final FMLPostInitializationEvent event) {
197                 this.settingProcessing(event);
198                 this.apiProcessing(event);
199                 this.debug(event);
200         }
201
202         private void settingProcessing(final FMLPostInitializationEvent event) {
203
204                 // Blockを追加します
205                 this.blockPyrolysisTable = new BlockPyrolysisTable(this.pyrolysisTableID, 0, Material.ground).
206                                 setHardness(2.0F).
207                                 setResistance(0.0F).
208                                 setStepSound(Block.soundStoneFootstep).
209                                 setBlockName("PyrolysisTable");
210                 this.blockChemicalCombinationTable = new BlockChemicalCombinationTable(this.chemicalConbinationTableID, 0, Material.ground).
211                                 setHardness(2.0F).
212                                 setResistance(0.0F).
213                                 setStepSound(Block.soundStoneFootstep).
214                                 setBlockName("ChemicalCombinationTable");
215                 this.blockToolAndWeaponCraftingTable = new BlockToolAndWeaponCraftingTable(this.toolAndWeaponCraftingTableID, 0, Material.ground).
216                                 setHardness(2.0F).
217                                 setResistance(0.0F).
218                                 setStepSound(Block.soundStoneFootstep).
219                                 setBlockName("ToolAndWeaponCraftingTable");
220                 this.blockChemicalCraftingTable = new BlockChemicalCraftingTable(chemicalCraftingTableID, 0, Material.ground).
221                                 setHardness(2.0F).
222                                 setResistance(0.0F).
223                                 setStepSound(Block.soundStoneFootstep).
224                                 setBlockName("ChemicalCraftingTable");
225
226                 // Itemを追加します
227                 this.itemAtoms = new ItemAtoms(this.atomsID).setItemName("atoms");
228                 this.itemCompounds = new ItemCompounds(this.compoundsID).setItemName("compounds");
229                 this.itemGasCollectingBottle = new ItemGasCollectingBottle(this.gasCollectingBottleID).setItemName("gasCollectingBottle").setIconIndex(0);
230                 this.itemAtomGrenade = new ItemAtomsGrenade(this.atomGrenadeID).setItemName("grenade").setIconIndex(1);
231
232                 // BlockをMinecraftに登録します
233                 GameRegistry.registerBlock(this.blockPyrolysisTable, "BlockPyrolysisTable");
234                 GameRegistry.registerBlock(this.blockChemicalCombinationTable, "BlockChemicalCombinationTable");
235                 GameRegistry.registerBlock(this.blockToolAndWeaponCraftingTable, "BlockToolAndWeaponCraftingTable");
236                 GameRegistry.registerBlock(this.blockChemicalCraftingTable, "BlockMaterialCraftingTable");
237
238                 // Blockの名前を設定します
239                 this.nameAuxiliary.addName(this.blockPyrolysisTable, "PyrolysisTable");
240                 this.nameAuxiliary.addName(this.blockPyrolysisTable, "ja_JP", "熱分解台");
241                 this.nameAuxiliary.addName(this.blockChemicalCombinationTable, "ChemicalCombinationTable");
242                 this.nameAuxiliary.addName(this.blockChemicalCombinationTable, "ja_JP", "化合台");
243                 this.nameAuxiliary.addName(blockToolAndWeaponCraftingTable, "ToolAndWeaponCraftingTable");
244                 this.nameAuxiliary.addName(blockToolAndWeaponCraftingTable, "ja_JP", "ツール&武器製作台");
245                 this.nameAuxiliary.addName(blockChemicalCraftingTable, "ChemicalCraftingTable");
246                 this.nameAuxiliary.addName(blockChemicalCraftingTable, "ja_JP", "素材製作台");
247
248                 // Itemの名前を設定します
249                 this.nameAuxiliary.addName(this.itemAtoms, ATOMSNAME);
250                 this.nameAuxiliary.addName(this.itemAtoms, "ja_JP", ATOMSNAMEJP);
251                 this.nameAuxiliary.addName(this.itemGasCollectingBottle, "GasCollectingBottle");
252                 this.nameAuxiliary.addName(this.itemGasCollectingBottle, "ja_JP", "集気瓶");
253                 this.nameAuxiliary.addName(this.itemAtomGrenade, "AtomGrenade");
254                 this.nameAuxiliary.addName(this.itemAtomGrenade, "元素手榴弾");
255
256                 // TileEntityを追加します
257                 GameRegistry.registerTileEntity(TileEntityPyrolysisTable.class, "TileEntityPyrolysisTable");
258                 GameRegistry.registerTileEntity(TileEntityChemicalCombinationTable.class, "TileEntityChemicalCombinationTable");
259                 GameRegistry.registerTileEntity(TileEntityToolAndWeaponCraftingTable.class, "TileEntityToolAndWeaponCraftingTable");
260                 GameRegistry.registerTileEntity(TileEntityChemicalCraftingTable.class, "TileEntityChemicalCraftingTable");
261
262                 // GUIを追加します
263                 NetworkRegistry.instance().registerGuiHandler(instance, proxy);
264
265                 // 描画関係の読み込み
266                 proxy.registerRenderInformation();
267
268                 //化学作業台類のレシピを追加します
269                 GameRegistry.addRecipe(new ItemStack(this.blockPyrolysisTable),
270                                 new Object[]{
271                         "XYX", "ZAZ", "ZZZ",
272                         Character.valueOf('X'), new ItemStack(Item.ingotIron),
273                         Character.valueOf('Y'), new ItemStack(Block.workbench),
274                         Character.valueOf('Z'), new ItemStack(Block.stone),
275                         Character.valueOf('A'), new ItemStack(Item.bucketLava),
276                 });
277                 GameRegistry.addRecipe(new ItemStack(this.blockChemicalCombinationTable),
278                                 new Object[]{
279                         "XYX", "ZAZ", "ZZZ",
280                         Character.valueOf('X'), new ItemStack(Item.ingotIron),
281                         Character.valueOf('Y'), new ItemStack(Block.workbench),
282                         Character.valueOf('Z'), new ItemStack(Block.stone),
283                         Character.valueOf('A'), new ItemStack(Block.obsidian),
284                 });
285                 GameRegistry.addRecipe(new ItemStack(this.blockToolAndWeaponCraftingTable),
286                                 new Object[]{
287                         "XYX", "ZAZ", "ZZZ",
288                         Character.valueOf('X'), new ItemStack(Item.ingotIron),
289                         Character.valueOf('Y'), new ItemStack(Block.workbench),
290                         Character.valueOf('Z'), new ItemStack(Block.stone),
291                         Character.valueOf('A'), new ItemStack(Item.pickaxeSteel),
292                 });
293                 GameRegistry.addRecipe(new ItemStack(this.blockChemicalCraftingTable),
294                                 new Object[]{
295                         "XYX", "ZAZ", "ZZZ",
296                         Character.valueOf('X'), new ItemStack(Item.ingotIron),
297                         Character.valueOf('Y'), new ItemStack(Block.workbench),
298                         Character.valueOf('Z'), new ItemStack(Block.stone),
299                         Character.valueOf('A'), new ItemStack(this.itemAtoms, 1, 0),
300                 });
301
302                 // 化合物を追加します
303                 api.addLangCompound("ja_JP", "CarbonMonoxide", "一酸化炭素");
304                 api.addLangCompound("ja_JP", "CarbonDioxide", "二酸化炭素");
305                 api.addLangCompound("ja_JP", "Water", "水");
306                 api.addCompound("Test");
307
308
309                 //化合物のHandlerを設定します
310                 api.settingCompoundHandler("Water", new CompoundWater());
311
312                 //化合物のレシピを追加します
313                 api.addChemicalCombinationRecipe(new String[]{"H", "O"}, new Integer[]{2, 1}, new ItemStack(this.itemCompounds, 1, api.getCompound("Water")));
314
315                 //手榴弾の追加
316                 api.addMaterialRecipe(
317                                 new ItemStack[]{
318                                                 null,
319                                                 new ItemStack(Block.stone),
320                                                 null,
321                                                 new ItemStack(Block.stone),
322                                                 new ItemStack(Item.gunpowder),
323                                                 new ItemStack(Block.stone),
324                                                 null,
325                                                 new ItemStack(Block.stone),
326                                                 null
327                                 },
328                                 new ItemStack(this.itemAtomGrenade, 16, 0),
329                                 new NBTRecipeGrenade()
330                                 );
331                 //Tickingの追加
332                 this.proxy.registerTickHandler();
333         }
334
335         private void apiProcessing(final FMLPostInitializationEvent event) {
336                 // API用の処理
337                 this.nameAuxiliary.addName(itemCompounds, api.getInstance().getCompoundsName().toArray());
338                 for (int i = 0; i < api.getCompoundsLang().size(); i++) {
339                         this.nameAuxiliary.addName(itemCompounds, api.getCompoundsLang().get(i), api.getInstance().getCompoundsLangName().toArray());
340                 }
341         }
342
343         private void debug(final FMLPostInitializationEvent event) {
344         }
345
346 }