OSDN Git Service

代理コミット
authorinaka <inaka@tcrsnc.com>
Wed, 21 Nov 2012 11:18:44 +0000 (20:18 +0900)
committerinaka <inaka@tcrsnc.com>
Wed, 21 Nov 2012 11:18:44 +0000 (20:18 +0900)
ソース追加
変更

src/ChemiCraft.java
src/ChemiCraftAPI.java
src/CompoundHandlerTest.java [new file with mode: 0644]
src/ICompoundHandler.java [new file with mode: 0644]
src/ItemCompounds.java

index c2c6578..905682b 100644 (file)
@@ -57,8 +57,7 @@ public class ChemiCraft
        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
+               ChemiCraftAPI.addLangCompound("ja_JP", "Salt", "\89\96(\89\96\89»\83i\83g\83\8a\83E\83\80)");\r
        }\r
 \r
        @Mod.PreInit  // \91O\8f\88\97\9d\r
@@ -83,6 +82,9 @@ public class ChemiCraft
                NameAuxiliary.addForLangName(itemAtoms, "ja_JP", atomsNameJP);\r
                NameAuxiliary.addForName(itemCompounds, ChemiCraftAPI.getCompoundsName().toArray());\r
                NameAuxiliary.addForLangName(itemCompounds, "ja_JP", ChemiCraftAPI.getCompoundsLangName().toArray());\r
+\r
+               ChemiCraftAPI.addCompoundHandler("Salt", new CompoundHandlerTest());\r
+\r
        }\r
 \r
 }
\ No newline at end of file
index 5d5be58..f624aa7 100644 (file)
@@ -10,13 +10,18 @@ public class ChemiCraftAPI {
        private static ArrayList<String> compoundsNameList = new ArrayList();
        private static ArrayList<String> compoundsLangNameList = new ArrayList();
        private static ArrayList<String> compoundsLangList = new ArrayList();
+       private static ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
+       private static ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
 
        public static void addCompound(String name){
                compoundsNameList.add(name);
+               compoundsLangNameList.add("");
+               compoundsLangList.add("");
        }
 
-       public static void addLangCompound(String lang, String name){
-               compoundsLangNameList.add(name);
+       public static void addLangCompound(String lang, String englishName, String langName){
+               compoundsNameList.add(englishName);
+               compoundsLangNameList.add(langName);
                compoundsLangList.add(lang);
        }
 
@@ -35,4 +40,20 @@ public class ChemiCraftAPI {
                return compoundsLangList;
        }
 
+       public static void addCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
+               ChemiCraftAPI.compoundHandlers.add(compoundHandler);
+               compoundHandlerItemNames.add(handlerItemName);
+       }
+
+       public static ArrayList<ICompoundHandler> getCompoundHandler(){
+               compoundHandlers.trimToSize();
+               return compoundHandlers;
+
+       }
+
+       public static ArrayList<String> getCompoundHandlerItemName(){
+               compoundHandlerItemNames.trimToSize();
+               return compoundHandlerItemNames;
+       }
+
 }
diff --git a/src/CompoundHandlerTest.java b/src/CompoundHandlerTest.java
new file mode 100644 (file)
index 0000000..ea9acc8
--- /dev/null
@@ -0,0 +1,28 @@
+package net.minecraft.src.ChemiCraft;
+
+import net.minecraft.src.Entity;
+import net.minecraft.src.EntityPlayer;
+import net.minecraft.src.ItemStack;
+import net.minecraft.src.World;
+
+public class CompoundHandlerTest implements ICompoundHandler {
+
+       @Override
+       public void onRightClickHandler(ItemStack par1ItemStack, World par2World,
+                       EntityPlayer par3EntityPlayer) {
+
+       }
+
+       @Override
+       public ItemStack onItemUseHandler(ItemStack par1ItemStack,
+                       EntityPlayer par2EntityPlayer, World par3World, int par4, int par5,
+                       int par6, int par7, float par8, float par9, float par10) {
+               return null;
+       }
+
+       @Override
+       public void onUpdateHandler(ItemStack par1ItemStack, World par2World,
+                       Entity par3Entity, int par4, boolean par5) {
+       }
+
+}
diff --git a/src/ICompoundHandler.java b/src/ICompoundHandler.java
new file mode 100644 (file)
index 0000000..d099281
--- /dev/null
@@ -0,0 +1,16 @@
+package net.minecraft.src.ChemiCraft;
+
+import net.minecraft.src.Entity;
+import net.minecraft.src.EntityPlayer;
+import net.minecraft.src.ItemStack;
+import net.minecraft.src.World;
+
+public interface ICompoundHandler {
+
+       void onRightClickHandler(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer);
+
+       ItemStack onItemUseHandler(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10);
+
+       void onUpdateHandler(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5);
+
+}
index 6c521b5..36bad92 100644 (file)
@@ -5,8 +5,10 @@ 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.Entity;
 import net.minecraft.src.Item;
 import net.minecraft.src.ItemStack;
+import net.minecraft.src.World;
 
 public class ItemCompounds extends Item {
 
@@ -18,6 +20,17 @@ public class ItemCompounds extends Item {
                this.setCreativeTab(CreativeTabs.tabMaterials);
        }
 
+       @Override
+       public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
+               for(int i=0;i < ChemiCraftAPI.getCompoundsName().size();i++){
+                       for(int j=0;j < ChemiCraftAPI.getCompoundHandlerItemName().size();j++){
+                               if(ChemiCraftAPI.getCompoundsName().get(i).equals(ChemiCraftAPI.getCompoundHandlerItemName().get(i))){
+                                       ChemiCraftAPI.getCompoundHandler().get(j).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
+                               }
+                       }
+               }
+       }
+
        @SideOnly(Side.CLIENT)
        @Override
        public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)