• R/O
  • HTTP
  • SSH
  • HTTPS

ChemiCraftNext: Commit


Commit MetaInfo

Revisión556edcd0ce173618dd6c90bbb6a857d6c1ff64fb (tree)
Tiempo2012-11-21 20:18:44
Autorinaka <inaka@tcrs...>
Commiterinaka

Log Message

代理コミット
ソース追加
変更

Cambiar Resumen

Diferencia incremental

--- a/src/ChemiCraft.java
+++ b/src/ChemiCraft.java
@@ -57,8 +57,7 @@ public class ChemiCraft
5757 public void chemiLoadMethod(FMLInitializationEvent event)
5858 {
5959 //化合物の追加
60- ChemiCraftAPI.addCompound("Salt(Sodium chloride)");
61- ChemiCraftAPI.addLangCompound("ja_JP", "塩(塩化ナトリウム)");
60+ ChemiCraftAPI.addLangCompound("ja_JP", "Salt", "塩(塩化ナトリウム)");
6261 }
6362
6463 @Mod.PreInit // 前処理
@@ -83,6 +82,9 @@ public class ChemiCraft
8382 NameAuxiliary.addForLangName(itemAtoms, "ja_JP", atomsNameJP);
8483 NameAuxiliary.addForName(itemCompounds, ChemiCraftAPI.getCompoundsName().toArray());
8584 NameAuxiliary.addForLangName(itemCompounds, "ja_JP", ChemiCraftAPI.getCompoundsLangName().toArray());
85+
86+ ChemiCraftAPI.addCompoundHandler("Salt", new CompoundHandlerTest());
87+
8688 }
8789
8890 }
\ No newline at end of file
--- a/src/ChemiCraftAPI.java
+++ b/src/ChemiCraftAPI.java
@@ -10,13 +10,18 @@ public class ChemiCraftAPI {
1010 private static ArrayList<String> compoundsNameList = new ArrayList();
1111 private static ArrayList<String> compoundsLangNameList = new ArrayList();
1212 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>();
1315
1416 public static void addCompound(String name){
1517 compoundsNameList.add(name);
18+ compoundsLangNameList.add("");
19+ compoundsLangList.add("");
1620 }
1721
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);
2025 compoundsLangList.add(lang);
2126 }
2227
@@ -35,4 +40,20 @@ public class ChemiCraftAPI {
3540 return compoundsLangList;
3641 }
3742
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+
3859 }
--- /dev/null
+++ b/src/CompoundHandlerTest.java
@@ -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+}
--- /dev/null
+++ b/src/ICompoundHandler.java
@@ -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+}
--- a/src/ItemCompounds.java
+++ b/src/ItemCompounds.java
@@ -5,8 +5,10 @@ import java.util.List;
55 import cpw.mods.fml.common.Side;
66 import cpw.mods.fml.common.asm.SideOnly;
77 import net.minecraft.src.CreativeTabs;
8+import net.minecraft.src.Entity;
89 import net.minecraft.src.Item;
910 import net.minecraft.src.ItemStack;
11+import net.minecraft.src.World;
1012
1113 public class ItemCompounds extends Item {
1214
@@ -18,6 +20,17 @@ public class ItemCompounds extends Item {
1820 this.setCreativeTab(CreativeTabs.tabMaterials);
1921 }
2022
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+
2134 @SideOnly(Side.CLIENT)
2235 @Override
2336 public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
Show on old repository browser