Revisión | 556edcd0ce173618dd6c90bbb6a857d6c1ff64fb (tree) |
---|---|
Tiempo | 2012-11-21 20:18:44 |
Autor | inaka <inaka@tcrs...> |
Commiter | inaka |
代理コミット
ソース追加
変更
@@ -57,8 +57,7 @@ public class ChemiCraft | ||
57 | 57 | public void chemiLoadMethod(FMLInitializationEvent event) |
58 | 58 | { |
59 | 59 | //化合物の追加 |
60 | - ChemiCraftAPI.addCompound("Salt(Sodium chloride)"); | |
61 | - ChemiCraftAPI.addLangCompound("ja_JP", "塩(塩化ナトリウム)"); | |
60 | + ChemiCraftAPI.addLangCompound("ja_JP", "Salt", "塩(塩化ナトリウム)"); | |
62 | 61 | } |
63 | 62 | |
64 | 63 | @Mod.PreInit // 前処理 |
@@ -83,6 +82,9 @@ public class ChemiCraft | ||
83 | 82 | NameAuxiliary.addForLangName(itemAtoms, "ja_JP", atomsNameJP); |
84 | 83 | NameAuxiliary.addForName(itemCompounds, ChemiCraftAPI.getCompoundsName().toArray()); |
85 | 84 | NameAuxiliary.addForLangName(itemCompounds, "ja_JP", ChemiCraftAPI.getCompoundsLangName().toArray()); |
85 | + | |
86 | + ChemiCraftAPI.addCompoundHandler("Salt", new CompoundHandlerTest()); | |
87 | + | |
86 | 88 | } |
87 | 89 | |
88 | 90 | } |
\ No newline at end of file |
@@ -10,13 +10,18 @@ public class ChemiCraftAPI { | ||
10 | 10 | private static ArrayList<String> compoundsNameList = new ArrayList(); |
11 | 11 | private static ArrayList<String> compoundsLangNameList = new ArrayList(); |
12 | 12 | private static ArrayList<String> compoundsLangList = new ArrayList(); |
13 | + private static ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>(); | |
14 | + private static ArrayList<String> compoundHandlerItemNames = new ArrayList<String>(); | |
13 | 15 | |
14 | 16 | public static void addCompound(String name){ |
15 | 17 | compoundsNameList.add(name); |
18 | + compoundsLangNameList.add(""); | |
19 | + compoundsLangList.add(""); | |
16 | 20 | } |
17 | 21 | |
18 | - public static void addLangCompound(String lang, String name){ | |
19 | - compoundsLangNameList.add(name); | |
22 | + public static void addLangCompound(String lang, String englishName, String langName){ | |
23 | + compoundsNameList.add(englishName); | |
24 | + compoundsLangNameList.add(langName); | |
20 | 25 | compoundsLangList.add(lang); |
21 | 26 | } |
22 | 27 |
@@ -35,4 +40,20 @@ public class ChemiCraftAPI { | ||
35 | 40 | return compoundsLangList; |
36 | 41 | } |
37 | 42 | |
43 | + public static void addCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){ | |
44 | + ChemiCraftAPI.compoundHandlers.add(compoundHandler); | |
45 | + compoundHandlerItemNames.add(handlerItemName); | |
46 | + } | |
47 | + | |
48 | + public static ArrayList<ICompoundHandler> getCompoundHandler(){ | |
49 | + compoundHandlers.trimToSize(); | |
50 | + return compoundHandlers; | |
51 | + | |
52 | + } | |
53 | + | |
54 | + public static ArrayList<String> getCompoundHandlerItemName(){ | |
55 | + compoundHandlerItemNames.trimToSize(); | |
56 | + return compoundHandlerItemNames; | |
57 | + } | |
58 | + | |
38 | 59 | } |
@@ -0,0 +1,28 @@ | ||
1 | +package net.minecraft.src.ChemiCraft; | |
2 | + | |
3 | +import net.minecraft.src.Entity; | |
4 | +import net.minecraft.src.EntityPlayer; | |
5 | +import net.minecraft.src.ItemStack; | |
6 | +import net.minecraft.src.World; | |
7 | + | |
8 | +public class CompoundHandlerTest implements ICompoundHandler { | |
9 | + | |
10 | + @Override | |
11 | + public void onRightClickHandler(ItemStack par1ItemStack, World par2World, | |
12 | + EntityPlayer par3EntityPlayer) { | |
13 | + | |
14 | + } | |
15 | + | |
16 | + @Override | |
17 | + public ItemStack onItemUseHandler(ItemStack par1ItemStack, | |
18 | + EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, | |
19 | + int par6, int par7, float par8, float par9, float par10) { | |
20 | + return null; | |
21 | + } | |
22 | + | |
23 | + @Override | |
24 | + public void onUpdateHandler(ItemStack par1ItemStack, World par2World, | |
25 | + Entity par3Entity, int par4, boolean par5) { | |
26 | + } | |
27 | + | |
28 | +} |
@@ -0,0 +1,16 @@ | ||
1 | +package net.minecraft.src.ChemiCraft; | |
2 | + | |
3 | +import net.minecraft.src.Entity; | |
4 | +import net.minecraft.src.EntityPlayer; | |
5 | +import net.minecraft.src.ItemStack; | |
6 | +import net.minecraft.src.World; | |
7 | + | |
8 | +public interface ICompoundHandler { | |
9 | + | |
10 | + void onRightClickHandler(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer); | |
11 | + | |
12 | + ItemStack onItemUseHandler(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10); | |
13 | + | |
14 | + void onUpdateHandler(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5); | |
15 | + | |
16 | +} |
@@ -5,8 +5,10 @@ import java.util.List; | ||
5 | 5 | import cpw.mods.fml.common.Side; |
6 | 6 | import cpw.mods.fml.common.asm.SideOnly; |
7 | 7 | import net.minecraft.src.CreativeTabs; |
8 | +import net.minecraft.src.Entity; | |
8 | 9 | import net.minecraft.src.Item; |
9 | 10 | import net.minecraft.src.ItemStack; |
11 | +import net.minecraft.src.World; | |
10 | 12 | |
11 | 13 | public class ItemCompounds extends Item { |
12 | 14 |
@@ -18,6 +20,17 @@ public class ItemCompounds extends Item { | ||
18 | 20 | this.setCreativeTab(CreativeTabs.tabMaterials); |
19 | 21 | } |
20 | 22 | |
23 | + @Override | |
24 | + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){ | |
25 | + for(int i=0;i < ChemiCraftAPI.getCompoundsName().size();i++){ | |
26 | + for(int j=0;j < ChemiCraftAPI.getCompoundHandlerItemName().size();j++){ | |
27 | + if(ChemiCraftAPI.getCompoundsName().get(i).equals(ChemiCraftAPI.getCompoundHandlerItemName().get(i))){ | |
28 | + ChemiCraftAPI.getCompoundHandler().get(j).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5); | |
29 | + } | |
30 | + } | |
31 | + } | |
32 | + } | |
33 | + | |
21 | 34 | @SideOnly(Side.CLIENT) |
22 | 35 | @Override |
23 | 36 | public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) |