Posted September 8, 201510 yr 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?
September 8, 201510 yr 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 . こんにちは!お元気ですか?
September 8, 201510 yr why do you want to change the texture? maybe making a new itemstack wiht a different item is right for ur purpose
September 8, 201510 yr 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); } }
September 8, 201510 yr 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; } }
September 8, 201510 yr 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.
September 8, 201510 yr 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.
September 8, 201510 yr Author yes yes... but u can show me a little example please? im very noob Edit i solve it with onupdate ^^
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.