super(par1);
this.setHasSubtypes(true);
this.setMaxDamage(0);
- this.setCreativeTab(ChemiCraft.instance.creativeTab);
+ this.setCreativeTab(ChemiCraft.instance.creativeTabChemiCraft);
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
- for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
- if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
- return ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onItemUseHandler(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
+ try {
+ for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
+ if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
+ return ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemUseHandler(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
+ }
}
+ } catch (IndexOutOfBoundsException e) {
+ par1ItemStack.stackSize = 0;
}
return false;
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
- for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
- if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
- ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onItemRightClickHandler(par1ItemStack, par2World, par3EntityPlayer);
+ try {
+ for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
+ if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
+ ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemRightClickHandler(par1ItemStack, par2World, par3EntityPlayer);
+ }
}
+ } catch (IndexOutOfBoundsException e) {
+ par1ItemStack.stackSize = 0;
}
return par1ItemStack;
}
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
- for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
- if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
- ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
+ try {
+ for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
+ if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
+ ChemiCraftAPI.instance().getCompoundHandler().get(i).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
+ }
}
+ } catch (IndexOutOfBoundsException e) {
+ par1ItemStack.stackSize = 0;
+ par1ItemStack = null;
}
}
@SideOnly(Side.CLIENT)
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
- for(int type = 0; type < ChemiCraftAPI.getInstance().getCompoundsName().toArray().length; type++)
+ for(int type = 0; type < ChemiCraftAPI.instance().getCompoundsName().sizeKeysList(); type++)
{
par3List.add(new ItemStack(par1, 1, type));
this.setIconIndex(type);
@Override
public String getItemNameIS(ItemStack par1ItemStack){
- return super.getItemName() + "." + ChemiCraftAPI.getInstance().getCompoundsName().toArray()[par1ItemStack.getItemDamage()];
+ try {
+ return super.getItemName() + "." + ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage());
+ } catch (ArrayIndexOutOfBoundsException e) {
+ par1ItemStack.stackSize = 0;
+ }
+ return null;
}
@SideOnly(Side.CLIENT)
@Override
public int getIconFromDamage(int par1){
- for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
- if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
- return ChemiCraftAPI.getInstance().getCompoundHandler().get(i).getIconIndexHandler();
+ try {
+ for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
+ if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
+ return ChemiCraftAPI.instance().getCompoundHandler().get(i).getIconIndexHandler();
+ }
}
+ } catch (IndexOutOfBoundsException e) {
+ return 0;
}
return 0;
}