Jump to content

[1.7.10] How change texture 'onItemRightClick'


goodmanalex

Recommended Posts

I need to change the item texture to other 

 

this is mi onItemRightClick

 

public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
Boolean enc=itemstack.isItemEnchanted();

	if(itemstack.isItemEnchanted()){ 
		itemstack.setTagCompound(null); }else{
			itemstack.addEnchantment(Enchantment.knockback, 3);}

	return itemstack;  
}

 

Could you tell me I should add code or give an example?

Link to comment
Share on other sites

I add this to my code, but i dont know how change on rightclick :SS


public class breaker extends ItemPickaxe 
{
public static final String[] breakerarray = new String[] {":breaker, breaker2"};
public int modo;
public static ToolMaterial gigabreaker = EnumHelper.addToolMaterial("gigabreaker", 4, -1, 20.0F, 0.0F, 50);
@SideOnly(Side.CLIENT)
    private IIcon[] iconArray;
public breaker(String unlocalizedName, ToolMaterial material) {
	super(material);  
	setUnlocalizedName("breaker"); 

	this.setCreativeTab(colorescraftmod.colorescraftmod); 
	setFull3D(); 

}


public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
Boolean enc=itemstack.isItemEnchanted();

	if(itemstack.isItemEnchanted()){ 
		modo=0;
		itemstack.setTagCompound(null); }else{
			itemstack.addEnchantment(Enchantment.knockback, 50);
			modo=1;}

	return itemstack; 
}
///////////////////////////////
@SideOnly(Side.CLIENT)
    @Override
    public void registerIcons(IIconRegister par1IconRegister)
    {
        this.itemIcon = par1IconRegister.registerIcon(Reference.MODID + ":breaker");
        this.iconArray = new IIcon[breakerarray.length];
        
       if(modo==1){
    	   par1IconRegister.registerIcon(Reference.MODID +breakerarray[1]);
       }
       if(modo==0){
    	   par1IconRegister.registerIcon(Reference.MODID +breakerarray[0]);
       }

    }
@Override
    @SideOnly(Side.CLIENT)
    public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
            if (modo==1) {
                    return iconArray[1];
            } else if (modo==0) {
                    return iconArray[0];
            }else {
                    return itemIcon;
            }
    }
//////////////////////
   private static Set effectiveAgainst = Sets.newHashSet(new Block[] {
		    Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, 
		    Blocks.snow_layer, Blocks.snow, Blocks.clay, Blocks.farmland, 
		    Blocks.soul_sand, Blocks.mycelium, Blocks.planks, 
		    Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, 
		    Blocks.pumpkin, Blocks.lit_pumpkin}); 
  @Override
  public float func_150893_a(ItemStack stack, Block block) {
	  if (block.getMaterial() == Material.wood || block.getMaterial() == Material.vine || block.getMaterial() == Material.plants)
          return this.efficiencyOnProperMaterial;
      return effectiveAgainst.contains(block) ? this.efficiencyOnProperMaterial : super.func_150893_a(stack, block);
  }
}

Link to comment
Share on other sites

like this?

public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer, int modo)

 

Now red line is in

 

public void registerIcons(IIconRegister par1IconRegister)

    {

        this.itemIcon = par1IconRegister.registerIcon(Reference.MODID + ":breaker");

        this.iconArray = new IIcon[breakerarray.length];

       

      if(modo==1){

      par1IconRegister.registerIcon(Reference.MODID +breakerarray[1]);

      }

      if(modo==0){

      par1IconRegister.registerIcon(Reference.MODID +breakerarray[0]);

      }

 

    }

 

    public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {

            if (modo==1) {

                    return iconArray[1];

            } else if (modo==0) {

                    return iconArray[0];

            }else {

                    return itemIcon;

            }

    }

 

Link to comment
Share on other sites

You can't add a parameter to a function and expect it to get called by magic.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You could save a number to the itemstack's nbt and change that number on right click. Then in your geticon method load the number from the nbt and say if the number is equal to whatever number, change the texture to another one

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.