Jump to content

using different durability for different items


Recommended Posts

Ok so I am trying to make a crafting item for my mod that has 2 tiers. One of the tiers I want 1 durability to be taken from the items durability EXCEPT when I am trying to upgrade it to tier 2. Then I want it to take 5 durability from it. However I am having trouble changing the amount taken based on crafting.

 

 

Crystal class (item, both tiers are called to this class)

package items;

import keystuff.myMod;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;


public class Crystals extends Item
{

   

   public Crystals()
   {

      setCreativeTab(myMod.daftcraft);
      setMaxDamage(5);

   }

   @Override
   public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack)
   {
      return false;

   }

   @Override
   public ItemStack getContainerItem(ItemStack itemStack)
   {
      
      ItemStack cStack=itemStack.copy();
      cStack.setItemDamage(cStack.getItemDamage()+1);
      cStack.stackSize=1;
      return cStack;

   }


   @Override
   public boolean hasContainerItem(ItemStack stack)
   {
      return stack.getItemDamage()<5;
   }

}//class

 

 

crafting recipe

 

GameRegistry.addRecipe(new ItemStack(rubyCrystalT2),
              " D ",
              "DRD",
              " D ",
              'R',new ItemStack(rubyCrystal,1,OreDictionary.WILDCARD_VALUE),
              'D',Items.diamond);

 

setting the items

public static Item rubyCrystal;
   public static Item rubyCrystalT2;

rubyCrystalT2=new Crystals().setUnlocalizedName("ruby tier 2");
      GameRegistry.registerItem(rubyCrystalT2,"ruby tier 2");

      rubyCrystal=new Crystals().setUnlocalizedName("ruby");
      GameRegistry.registerItem(rubyCrystal,"ruby");

 

This uses the code but only reduces durability by 1 for them all.

Any helps would be appreciated

thanks

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.