Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

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

Developing the Spiral Power Mod .

こんにちは!お元気ですか?

why do you want to change the texture? maybe making a new itemstack wiht a different item is right for ur purpose

  • Author

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);
  }
}

  • Author

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;

            }

    }

 

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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.