• R/O
  • HTTP
  • SSH
  • HTTPS

ChemiCraftNext: Commit


Commit MetaInfo

Revisión331f47e33d54fd6a12a0038a74dbb637e0f6a39b (tree)
Tiempo2012-11-17 17:46:10
Autorinaka <inaka@tcrs...>
Commiterinaka

Log Message

ソース追加

Cambiar Resumen

Diferencia incremental

--- /dev/null
+++ b/src/Auxiliary.java
@@ -0,0 +1,80 @@
1+package net.minecraft.src.ChemiCraft;
2+
3+import net.minecraft.src.Block;
4+import net.minecraft.src.Item;
5+import net.minecraft.src.ItemStack;
6+import cpw.mods.fml.common.registry.LanguageRegistry;
7+
8+public class Auxiliary {
9+
10+ public Auxiliary(){
11+ }
12+
13+ class NameAuxiliary{
14+
15+ /**
16+ * とりあえず作成。あるのでボツ
17+ * @param object
18+ * @param Name
19+ */
20+ public void addName(Object object,Object name){
21+ LanguageRegistry.addName(object, (String) name);
22+ }
23+
24+ /**
25+ * こちらもあるのでボツ
26+ * @param object
27+ * @param name
28+ * @param meta
29+ */
30+ public void addName(ItemStack itemstack,Object name){
31+ LanguageRegistry.addName(itemstack, (String) name);
32+ }
33+
34+ /**
35+ * メタデータ+配列で名前を追加する(Block版)
36+ * @param object
37+ * @param name
38+ */
39+ public void addForName(Block object,Object[] name){
40+ for(int i=0;i<name.length;i++){
41+ LanguageRegistry.addName(new ItemStack(object,0,i), (String) name[i]);
42+ }
43+ }
44+
45+ /**
46+ * メタデータ+配列で名前を追加する(Item版)
47+ * @param object
48+ * @param name
49+ */
50+ public void addForName(Item object,Object[] name){
51+ for(int i=0;i<name.length;i++){
52+ LanguageRegistry.addName(new ItemStack(object,0,i), (String) name[i]);
53+ }
54+ }
55+
56+ /**
57+ * メタデータ+配列で指定した言語で名前を追加する(Block版)
58+ * @param object
59+ * @param name
60+ */
61+ public void addForLangName(Block object,String lang,Object[] name){
62+ for(int i=0;i<name.length;i++){
63+ LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, (String) name[i]);
64+ }
65+ }
66+
67+ /**
68+ * メタデータ+配列で指定した言語で名前を追加する(Item版)
69+ * @param object
70+ * @param name
71+ */
72+ public void addForLangName(Item object,String lang, Object[] name){
73+ for(int i=0;i<name.length;i++){
74+ LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, (String) name[i]);
75+ }
76+ }
77+
78+ }
79+
80+}
--- /dev/null
+++ b/src/ChemiCraft.java
@@ -0,0 +1,88 @@
1+package net.minecraft.src.ChemiCraft;
2+
3+import java.util.ArrayList;
4+import java.util.Properties;
5+
6+import net.minecraft.src.Block;
7+import net.minecraft.src.Item;
8+import net.minecraft.src.ItemStack;
9+import net.minecraftforge.common.Configuration;
10+import net.minecraftforge.common.Property;
11+import cpw.mods.fml.common.Mod;
12+import cpw.mods.fml.common.event.FMLInitializationEvent;
13+import cpw.mods.fml.common.event.FMLPostInitializationEvent;
14+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
15+import cpw.mods.fml.common.network.NetworkMod;
16+import cpw.mods.fml.common.registry.GameRegistry;
17+import cpw.mods.fml.common.registry.LanguageRegistry;
18+
19+@Mod( modid = "chemiCraft", name="ChemiCraft", version="テスト版") //ID,名前,バージョン
20+@NetworkMod(clientSideRequired = true, serverSideRequired = true, versionBounds = "[1.3.2]") //クライアント、サーバー共に必要 1.3.2用
21+
22+public class ChemiCraft
23+{
24+
25+ public static final String[] atomsName = {
26+ "Hydrogen", "Helium","Lithium","Beryllium","Boron","Carbon","Nitrogen","Oxygen","Fluorine","Neon",
27+ "Sodium","Magnesium","Aluminium","Silicon","Phosphorus","Sulfur","Chlorine","Argon","Potassium","Calcium",
28+ "Scandium","Titanium","Vanadium","Chromium","Manganese","Iron","Cobalt","Nickel","Copper","Zinc",
29+ "Gallium","Germanium","Arsenic","Selenium","Bromine","Krypton","Rubidium","Strontium","Yttorium","Zirconium",
30+ "Niobium","Molybdenum","Technetium","Ruthenium","Rhodium","Palladium","Silver","Cadmium","Indium","Tin",
31+ "Antimony","Tellurium","Iodine","Xenon","Caesium","Barium","Lanthanum","Cerium","Praseodymium","Neodymium",
32+ "Promethium","Samarium","Europium","Gadolinium","Terbium","Dysprosium","Holmium","Erbium","Thulium","Ytterbium",
33+ "Lutetium","Hafnium","Tantalum","Tungsten","Rhenium","Osmium","Iridium","Platinum","Gold","Mercury",
34+ "Thallium","Lead","Bismuth","Polonium","Astatine","Radon","Francium","Radium","Actinium","Thorium",
35+ "Protactinium","Uranium","Neptunium","Plutonium","Americium","Curium","Berkelium","Californium","Einsteinium","Fermium",
36+ "Mendelevium","Nobelium","Lawrencium","Rutherfordium","Dubnium","Seaborgium","Bohrium","Hassium","Meitnerium","Darmstadtium",
37+ "Roentgenium","Copernicium","Ununtrium","Ununquadium","Ununpentium","Ununhexium","","Ununoctium"
38+ };
39+
40+ public static final String[] atomsNameJP = {
41+ "水素", "ヘリウム"
42+ };
43+
44+ private ChemiCraftAPI chemiCraftAPI = ChemiCraftAPI.instance;
45+
46+ public static int atomsID;
47+ public static int compoundsID;
48+
49+ public static Item itemAtoms;
50+ public static Item itemCompounds;
51+
52+ private Auxiliary Auxiliary = new Auxiliary();
53+ private Auxiliary.NameAuxiliary NameAuxiliary = Auxiliary.new NameAuxiliary();
54+
55+ // コンストラクタ
56+ @Mod.Init
57+ public void chemiLoadMethod(FMLInitializationEvent event)
58+ {
59+ //化合物の追加
60+ ChemiCraftAPI.addCompound("Salt(Sodium chloride)");
61+ ChemiCraftAPI.addLangCompound("ja_JP", "塩(塩化ナトリウム)");
62+ }
63+
64+ @Mod.PreInit // 前処理
65+ public void chemiPreLoadMethod(FMLPreInitializationEvent event)
66+ {
67+ Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
68+ cfg.load();
69+ Property atomsIDProp = cfg.getItem("atomsID", 25000);
70+ Property compoundsIDProp = cfg.getItem("compoundsID", 25001);
71+ atomsID = atomsIDProp.getInt();
72+ compoundsID = compoundsIDProp.getInt();
73+ cfg.save();
74+ }
75+
76+ @Mod.PostInit // ModLoader.loadメソッドと同等
77+ public void chemiPostLoadMethod(FMLPostInitializationEvent event)
78+ {
79+ itemAtoms = new ItemAtoms(atomsID).setItemName("atoms");
80+ itemCompounds = new ItemCompounds(compoundsID).setItemName("compounds");
81+
82+ NameAuxiliary.addForName(itemAtoms, atomsName);
83+ NameAuxiliary.addForLangName(itemAtoms, "ja_JP", atomsNameJP);
84+ NameAuxiliary.addForName(itemCompounds, ChemiCraftAPI.getCompoundsName().toArray());
85+ NameAuxiliary.addForLangName(itemCompounds, "ja_JP", ChemiCraftAPI.getCompoundsLangName().toArray());
86+ }
87+
88+}
\ No newline at end of file
--- /dev/null
+++ b/src/ChemiCraftAPI.java
@@ -0,0 +1,38 @@
1+package net.minecraft.src.ChemiCraft;
2+
3+import java.util.ArrayList;
4+
5+public class ChemiCraftAPI {
6+
7+ public static ChemiCraftAPI instance = new ChemiCraftAPI();
8+
9+ private boolean addLanguage = false;
10+ private static ArrayList<String> compoundsNameList = new ArrayList();
11+ private static ArrayList<String> compoundsLangNameList = new ArrayList();
12+ private static ArrayList<String> compoundsLangList = new ArrayList();
13+
14+ public static void addCompound(String name){
15+ compoundsNameList.add(name);
16+ }
17+
18+ public static void addLangCompound(String lang, String name){
19+ compoundsLangNameList.add(name);
20+ compoundsLangList.add(lang);
21+ }
22+
23+ public static ArrayList<String> getCompoundsName(){
24+ compoundsNameList.trimToSize();
25+ return compoundsNameList;
26+ }
27+
28+ public static ArrayList<String> getCompoundsLangName(){
29+ compoundsLangNameList.trimToSize();
30+ return compoundsLangNameList;
31+ }
32+
33+ public static ArrayList<String> getCompoundsLang(){
34+ compoundsLangList.trimToSize();
35+ return compoundsLangList;
36+ }
37+
38+}
--- /dev/null
+++ b/src/ItemAtoms.java
@@ -0,0 +1,54 @@
1+package net.minecraft.src.ChemiCraft;
2+
3+import java.util.List;
4+
5+import net.minecraft.src.CreativeTabs;
6+import net.minecraft.src.EntityPlayer;
7+import net.minecraft.src.Item;
8+import net.minecraft.src.ItemStack;
9+import net.minecraft.src.World;
10+import cpw.mods.fml.common.Side;
11+import cpw.mods.fml.common.asm.SideOnly;
12+
13+public class ItemAtoms extends Item {
14+
15+ public ItemAtoms(int par1) {
16+ super(par1);
17+ this.maxStackSize = 1;
18+ this.setHasSubtypes(true);
19+ this.setMaxDamage(0);
20+ this.setCreativeTab(CreativeTabs.tabMaterials);
21+ }
22+
23+ @SideOnly(Side.CLIENT)
24+ @Override
25+ public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
26+ {
27+ for(int type = 0; type < ChemiCraft.atomsName.length; type++)
28+ {
29+ par3List.add(new ItemStack(par1, 1, type));
30+ this.setIconIndex(type);
31+ }
32+ }
33+
34+ @Override
35+ public String getItemNameIS(ItemStack par1ItemStack)
36+ {
37+ return super.getItemName() + "." + ChemiCraft.atomsName[par1ItemStack.getItemDamage()];
38+ }
39+
40+ @Override
41+ public String getTextureFile()
42+ {
43+ this.isDefaultTexture = false;
44+ return "/ChemiCraft/Atoms.png";
45+ }
46+
47+ @SideOnly(Side.CLIENT)
48+ @Override
49+ public int getIconFromDamage(int par1)
50+ {
51+ return par1;
52+ }
53+
54+}
\ No newline at end of file
--- /dev/null
+++ b/src/ItemCompounds.java
@@ -0,0 +1,52 @@
1+package net.minecraft.src.ChemiCraft;
2+
3+import java.util.List;
4+
5+import cpw.mods.fml.common.Side;
6+import cpw.mods.fml.common.asm.SideOnly;
7+import net.minecraft.src.CreativeTabs;
8+import net.minecraft.src.Item;
9+import net.minecraft.src.ItemStack;
10+
11+public class ItemCompounds extends Item {
12+
13+ public ItemCompounds(int par1) {
14+ super(par1);
15+ this.maxStackSize = 1;
16+ this.setHasSubtypes(true);
17+ this.setMaxDamage(0);
18+ this.setCreativeTab(CreativeTabs.tabMaterials);
19+ }
20+
21+ @SideOnly(Side.CLIENT)
22+ @Override
23+ public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
24+ {
25+ for(int type = 0; type < ChemiCraftAPI.getCompoundsName().toArray().length; type++)
26+ {
27+ par3List.add(new ItemStack(par1, 1, type));
28+ this.setIconIndex(type);
29+ }
30+ }
31+
32+ @Override
33+ public String getItemNameIS(ItemStack par1ItemStack)
34+ {
35+ return super.getItemName() + "." + ChemiCraftAPI.getCompoundsName().toArray()[par1ItemStack.getItemDamage()];
36+ }
37+
38+ @Override
39+ public String getTextureFile()
40+ {
41+ this.isDefaultTexture = false;
42+ return "/ChemiCraft/Compounds.png";
43+ }
44+
45+ @SideOnly(Side.CLIENT)
46+ @Override
47+ public int getIconFromDamage(int par1)
48+ {
49+ return par1;
50+ }
51+
52+}
Show on old repository browser