OSDN Git Service

ソース追加
authorinaka <inaka@tcrsnc.com>
Sat, 17 Nov 2012 08:46:10 +0000 (17:46 +0900)
committerinaka <inaka@tcrsnc.com>
Sat, 17 Nov 2012 08:46:10 +0000 (17:46 +0900)
src/Auxiliary.java [new file with mode: 0644]
src/ChemiCraft.java [new file with mode: 0644]
src/ChemiCraftAPI.java [new file with mode: 0644]
src/ItemAtoms.java [new file with mode: 0644]
src/ItemCompounds.java [new file with mode: 0644]

diff --git a/src/Auxiliary.java b/src/Auxiliary.java
new file mode 100644 (file)
index 0000000..2473a02
--- /dev/null
@@ -0,0 +1,80 @@
+package net.minecraft.src.ChemiCraft;\r
+\r
+import net.minecraft.src.Block;\r
+import net.minecraft.src.Item;\r
+import net.minecraft.src.ItemStack;\r
+import cpw.mods.fml.common.registry.LanguageRegistry;\r
+\r
+public class Auxiliary {\r
+\r
+       public Auxiliary(){\r
+       }\r
+\r
+       class NameAuxiliary{\r
+\r
+               /**\r
+                * \82Æ\82è\82 \82¦\82¸\8dì\90¬\81B\82 \82é\82Ì\82Å\83{\83c\r
+                * @param object\r
+                * @param Name\r
+                */\r
+               public void addName(Object object,Object name){\r
+                       LanguageRegistry.addName(object, (String) name);\r
+               }\r
+\r
+               /**\r
+                * \82±\82¿\82ç\82à\82 \82é\82Ì\82Å\83{\83c\r
+                * @param object\r
+                * @param name\r
+                * @param meta\r
+                */\r
+               public void addName(ItemStack itemstack,Object name){\r
+                       LanguageRegistry.addName(itemstack, (String) name);\r
+               }\r
+\r
+               /**\r
+                * \83\81\83^\83f\81[\83^+\94z\97ñ\82Å\96¼\91O\82ð\92Ç\89Á\82·\82é(Block\94Å)\r
+                * @param object\r
+                * @param name\r
+                */\r
+               public void addForName(Block object,Object[] name){\r
+                       for(int i=0;i<name.length;i++){\r
+                               LanguageRegistry.addName(new ItemStack(object,0,i), (String) name[i]);\r
+                       }\r
+               }\r
+\r
+               /**\r
+                * \83\81\83^\83f\81[\83^+\94z\97ñ\82Å\96¼\91O\82ð\92Ç\89Á\82·\82é(Item\94Å)\r
+                * @param object\r
+                * @param name\r
+                */\r
+               public void addForName(Item object,Object[] name){\r
+                       for(int i=0;i<name.length;i++){\r
+                               LanguageRegistry.addName(new ItemStack(object,0,i), (String) name[i]);\r
+                       }\r
+               }\r
+\r
+               /**\r
+                * \83\81\83^\83f\81[\83^+\94z\97ñ\82Å\8ew\92è\82µ\82½\8c¾\8cê\82Å\96¼\91O\82ð\92Ç\89Á\82·\82é(Block\94Å)\r
+                * @param object\r
+                * @param name\r
+                */\r
+               public void addForLangName(Block object,String lang,Object[] name){\r
+                       for(int i=0;i<name.length;i++){\r
+                               LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, (String) name[i]);\r
+                       }\r
+               }\r
+\r
+               /**\r
+                * \83\81\83^\83f\81[\83^+\94z\97ñ\82Å\8ew\92è\82µ\82½\8c¾\8cê\82Å\96¼\91O\82ð\92Ç\89Á\82·\82é(Item\94Å)\r
+                * @param object\r
+                * @param name\r
+                */\r
+               public void addForLangName(Item object,String lang, Object[] name){\r
+                       for(int i=0;i<name.length;i++){\r
+                               LanguageRegistry.instance().addNameForObject(new ItemStack(object,0,i), lang, (String) name[i]);\r
+                       }\r
+               }\r
+\r
+       }\r
+\r
+}\r
diff --git a/src/ChemiCraft.java b/src/ChemiCraft.java
new file mode 100644 (file)
index 0000000..c2c6578
--- /dev/null
@@ -0,0 +1,88 @@
+package net.minecraft.src.ChemiCraft;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Properties;\r
+\r
+import net.minecraft.src.Block;\r
+import net.minecraft.src.Item;\r
+import net.minecraft.src.ItemStack;\r
+import net.minecraftforge.common.Configuration;\r
+import net.minecraftforge.common.Property;\r
+import cpw.mods.fml.common.Mod;\r
+import cpw.mods.fml.common.event.FMLInitializationEvent;\r
+import cpw.mods.fml.common.event.FMLPostInitializationEvent;\r
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;\r
+import cpw.mods.fml.common.network.NetworkMod;\r
+import cpw.mods.fml.common.registry.GameRegistry;\r
+import cpw.mods.fml.common.registry.LanguageRegistry;\r
+\r
+@Mod( modid = "chemiCraft", name="ChemiCraft", version="\83e\83X\83g\94Å") //ID,\96¼\91O,\83o\81[\83W\83\87\83\93\r
+@NetworkMod(clientSideRequired = true, serverSideRequired = true, versionBounds = "[1.3.2]") //\83N\83\89\83C\83A\83\93\83g\81A\83T\81[\83o\81[\8b¤\82É\95K\97v 1.3.2\97p\r
+\r
+public class ChemiCraft\r
+{\r
+\r
+       public static final String[] atomsName = {\r
+               "Hydrogen", "Helium","Lithium","Beryllium","Boron","Carbon","Nitrogen","Oxygen","Fluorine","Neon",\r
+               "Sodium","Magnesium","Aluminium","Silicon","Phosphorus","Sulfur","Chlorine","Argon","Potassium","Calcium",\r
+               "Scandium","Titanium","Vanadium","Chromium","Manganese","Iron","Cobalt","Nickel","Copper","Zinc",\r
+               "Gallium","Germanium","Arsenic","Selenium","Bromine","Krypton","Rubidium","Strontium","Yttorium","Zirconium",\r
+               "Niobium","Molybdenum","Technetium","Ruthenium","Rhodium","Palladium","Silver","Cadmium","Indium","Tin",\r
+               "Antimony","Tellurium","Iodine","Xenon","Caesium","Barium","Lanthanum","Cerium","Praseodymium","Neodymium",\r
+               "Promethium","Samarium","Europium","Gadolinium","Terbium","Dysprosium","Holmium","Erbium","Thulium","Ytterbium",\r
+               "Lutetium","Hafnium","Tantalum","Tungsten","Rhenium","Osmium","Iridium","Platinum","Gold","Mercury",\r
+               "Thallium","Lead","Bismuth","Polonium","Astatine","Radon","Francium","Radium","Actinium","Thorium",\r
+               "Protactinium","Uranium","Neptunium","Plutonium","Americium","Curium","Berkelium","Californium","Einsteinium","Fermium",\r
+               "Mendelevium","Nobelium","Lawrencium","Rutherfordium","Dubnium","Seaborgium","Bohrium","Hassium","Meitnerium","Darmstadtium",\r
+               "Roentgenium","Copernicium","Ununtrium","Ununquadium","Ununpentium","Ununhexium","","Ununoctium"\r
+       };\r
+\r
+       public static final String[] atomsNameJP = {\r
+               "\90\85\91f", "\83w\83\8a\83E\83\80"\r
+       };\r
+\r
+       private ChemiCraftAPI chemiCraftAPI = ChemiCraftAPI.instance;\r
+\r
+       public static int atomsID;\r
+       public static int compoundsID;\r
+\r
+       public static Item itemAtoms;\r
+       public static Item itemCompounds;\r
+\r
+       private Auxiliary Auxiliary = new Auxiliary();\r
+       private Auxiliary.NameAuxiliary NameAuxiliary = Auxiliary.new NameAuxiliary();\r
+\r
+       // \83R\83\93\83X\83g\83\89\83N\83^\r
+       @Mod.Init\r
+       public void chemiLoadMethod(FMLInitializationEvent event)\r
+       {\r
+               //\89»\8d\87\95¨\82Ì\92Ç\89Á\r
+               ChemiCraftAPI.addCompound("Salt(Sodium chloride)");\r
+               ChemiCraftAPI.addLangCompound("ja_JP", "\89\96(\89\96\89»\83i\83g\83\8a\83E\83\80)");\r
+       }\r
+\r
+       @Mod.PreInit  // \91O\8f\88\97\9d\r
+       public void chemiPreLoadMethod(FMLPreInitializationEvent event)\r
+       {\r
+               Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());\r
+               cfg.load();\r
+               Property atomsIDProp = cfg.getItem("atomsID", 25000);\r
+               Property compoundsIDProp = cfg.getItem("compoundsID", 25001);\r
+               atomsID = atomsIDProp.getInt();\r
+               compoundsID = compoundsIDProp.getInt();\r
+               cfg.save();\r
+       }\r
+\r
+       @Mod.PostInit // ModLoader.load\83\81\83\\83b\83h\82Æ\93¯\93\99\r
+       public void chemiPostLoadMethod(FMLPostInitializationEvent event)\r
+       {\r
+               itemAtoms = new ItemAtoms(atomsID).setItemName("atoms");\r
+               itemCompounds = new ItemCompounds(compoundsID).setItemName("compounds");\r
+\r
+               NameAuxiliary.addForName(itemAtoms, atomsName);\r
+               NameAuxiliary.addForLangName(itemAtoms, "ja_JP", atomsNameJP);\r
+               NameAuxiliary.addForName(itemCompounds, ChemiCraftAPI.getCompoundsName().toArray());\r
+               NameAuxiliary.addForLangName(itemCompounds, "ja_JP", ChemiCraftAPI.getCompoundsLangName().toArray());\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/src/ChemiCraftAPI.java b/src/ChemiCraftAPI.java
new file mode 100644 (file)
index 0000000..5d5be58
--- /dev/null
@@ -0,0 +1,38 @@
+package net.minecraft.src.ChemiCraft;
+
+import java.util.ArrayList;
+
+public class ChemiCraftAPI {
+
+       public static ChemiCraftAPI instance = new ChemiCraftAPI();
+
+       private boolean addLanguage = false;
+       private static ArrayList<String> compoundsNameList = new ArrayList();
+       private static ArrayList<String> compoundsLangNameList = new ArrayList();
+       private static ArrayList<String> compoundsLangList = new ArrayList();
+
+       public static void addCompound(String name){
+               compoundsNameList.add(name);
+       }
+
+       public static void addLangCompound(String lang, String name){
+               compoundsLangNameList.add(name);
+               compoundsLangList.add(lang);
+       }
+
+       public static ArrayList<String> getCompoundsName(){
+               compoundsNameList.trimToSize();
+               return compoundsNameList;
+       }
+
+       public static ArrayList<String> getCompoundsLangName(){
+               compoundsLangNameList.trimToSize();
+               return compoundsLangNameList;
+       }
+
+       public static ArrayList<String> getCompoundsLang(){
+               compoundsLangList.trimToSize();
+               return compoundsLangList;
+       }
+
+}
diff --git a/src/ItemAtoms.java b/src/ItemAtoms.java
new file mode 100644 (file)
index 0000000..c0afa7e
--- /dev/null
@@ -0,0 +1,54 @@
+package net.minecraft.src.ChemiCraft;
+
+import java.util.List;
+
+import net.minecraft.src.CreativeTabs;
+import net.minecraft.src.EntityPlayer;
+import net.minecraft.src.Item;
+import net.minecraft.src.ItemStack;
+import net.minecraft.src.World;
+import cpw.mods.fml.common.Side;
+import cpw.mods.fml.common.asm.SideOnly;
+
+public class ItemAtoms extends Item {
+
+    public ItemAtoms(int par1) {
+        super(par1);
+        this.maxStackSize = 1;
+        this.setHasSubtypes(true);
+        this.setMaxDamage(0);
+        this.setCreativeTab(CreativeTabs.tabMaterials);
+    }
+
+    @SideOnly(Side.CLIENT)
+    @Override
+    public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
+    {
+        for(int type = 0; type < ChemiCraft.atomsName.length; type++)
+        {
+              par3List.add(new ItemStack(par1, 1, type));
+              this.setIconIndex(type);
+        }
+    }
+
+    @Override
+    public String getItemNameIS(ItemStack par1ItemStack)
+    {
+        return super.getItemName() + "." + ChemiCraft.atomsName[par1ItemStack.getItemDamage()];
+    }
+
+    @Override
+    public String getTextureFile()
+    {
+        this.isDefaultTexture = false;
+        return "/ChemiCraft/Atoms.png";
+    }
+
+    @SideOnly(Side.CLIENT)
+    @Override
+    public int getIconFromDamage(int par1)
+    {
+        return par1;
+    }
+
+}
\ No newline at end of file
diff --git a/src/ItemCompounds.java b/src/ItemCompounds.java
new file mode 100644 (file)
index 0000000..6c521b5
--- /dev/null
@@ -0,0 +1,52 @@
+package net.minecraft.src.ChemiCraft;
+
+import java.util.List;
+
+import cpw.mods.fml.common.Side;
+import cpw.mods.fml.common.asm.SideOnly;
+import net.minecraft.src.CreativeTabs;
+import net.minecraft.src.Item;
+import net.minecraft.src.ItemStack;
+
+public class ItemCompounds extends Item {
+
+       public ItemCompounds(int par1) {
+               super(par1);
+               this.maxStackSize = 1;
+               this.setHasSubtypes(true);
+               this.setMaxDamage(0);
+               this.setCreativeTab(CreativeTabs.tabMaterials);
+       }
+
+       @SideOnly(Side.CLIENT)
+       @Override
+       public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
+       {
+               for(int type = 0; type < ChemiCraftAPI.getCompoundsName().toArray().length; type++)
+               {
+                       par3List.add(new ItemStack(par1, 1, type));
+                       this.setIconIndex(type);
+               }
+       }
+
+       @Override
+       public String getItemNameIS(ItemStack par1ItemStack)
+       {
+               return super.getItemName() + "." + ChemiCraftAPI.getCompoundsName().toArray()[par1ItemStack.getItemDamage()];
+       }
+
+       @Override
+       public String getTextureFile()
+       {
+               this.isDefaultTexture = false;
+               return "/ChemiCraft/Compounds.png";
+       }
+
+       @SideOnly(Side.CLIENT)
+       @Override
+       public int getIconFromDamage(int par1)
+       {
+               return par1;
+       }
+
+}