package chemicraft;
import java.util.ArrayList;
+import java.util.HashMap;
import net.minecraft.src.ItemStack;
import chemicraft.system.ChemiCraftCraftingManager;
/**
+ * 化合物の文字列をダメージ値に変換します。
+ */
+ private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
+
+
+ /**
* List of item name of handler to compounds.
*/
private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
public int getDamageByName(String englishName){
for(int i = 0;i < compoundsNameList.size();i++){
if(englishName.equals(compoundsNameList.get(i))){
+ compoundHash.put(englishName, i);
return i;
}
}
+ public int getCompound(String key){
+ if(compoundHash.get(key) != null){
+ return compoundHash.get(key);
+ } else {
+ return -1;
+ }
+ }
+
+
+
/**
* setting compound handler.
* @param handlerItemName
package chemicraft.item;
+import net.minecraft.src.Block;
+import net.minecraft.src.BlockFire;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
import chemicraft.ChemiCraft;
+import chemicraft.ChemiCraftAPI;
import chemicraft.util.MathHelperPlus;
public class ItemGasCollectingBottle extends ItemAtomInfoContainer
}
} else {
if (result3 == 0) {
- this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, 0), par3EntityPlayer);
+ this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, ChemiCraftAPI.instance.getCompound("CarbonDioxide")), par3EntityPlayer);
} else if (result3 == 1) {
this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 9), par3EntityPlayer);
} else if (result3 == 2) {
}
}
}
+
+ // デバッグ用
if (par2World.isRemote) {
par3EntityPlayer.addChatMessage("result1=" + result1 + " result2=" + result2 + " result3=" + result3);
}
+
return par1ItemStack;
}
}
@Override
+ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
+ {
+ int var11 = par3World.getBlockId(par4, par5, par6);
+ Block block = Block.blocksList[var11];
+
+ if (block instanceof BlockFire){
+ par1ItemStack.damageItem(1, par2EntityPlayer);
+
+ int result1 = MathHelperPlus.probability(99, 1);
+
+ if (result1 == 0) {
+ this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemCompounds, 1, ChemiCraftAPI.instance.getCompound("CarbonDioxide")), par2EntityPlayer);
+ } else {
+ this.isStackOrDrop(new ItemStack(ChemiCraft.instance.itemAtoms, 1, 17), par2EntityPlayer);
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+ @Override
public String getTextureFile()
{
return "/chemicraft/items/items.png";