Jump to content

Random Code Issue - Swapping an Inventory Item


AEtherchild

Recommended Posts

Howdy

I'm attempting to create a Tool that, when it destroys a Block, has a random chance of turning itself into a different Item with the same damage value. Here's the command within the ItemSharpAxe class

 

 

public ItemStack onBlockDestroyedBy(ItemStack var1, World var2, int var3, int var4, int var5, int var6, EntityPlayer var7)
{
Random var8 = new Random();
for (int i = 0; i < 1; i++) {int var9 = var8.nextInt(31);}
	int var10 = var1.getItemDamage();
	//int var11 = var1.itemID == mod_SharpenedTools.SharpStoneAxe.shiftedIndex ? ItemTool.axeStone.shiftedIndex : (var1.itemID == mod_SharpenedTools.SharpIronAxe.shiftedIndex ? ItemTool.axeSteel.shiftedIndex : (var1.itemID == mod_SharpenedTools.SharpGoldAxe.shiftedIndex ? ItemTool.axeGold.shiftedIndex : (var1.itemID == mod_SharpenedTools.SharpDiamondAxe.shiftedIndex ? ItemTool.axeDiamond.shiftedIndex: 0)));
	int var12 = var7.inventory.currentItem;
	ItemStack var13 = new ItemStack(var11, 1, var10);
	if (var10 == 0)
	{
		--var1.stackSize;
		ItemStack var13 = new ItemStack(Item.axeSteel.shiftedIndex, 1, var10);
		var7.inventory.addItemStackToInventory(var13);
	}
	return var1;
}

 

 

I've tried various different setups that I was thinking would swap the currently in-use ItemSharpTool for its respective Vanilla tool, but to no avail. I'm not ACTUALLY convinced that it's necessary to be within an onBlockDestroyedBy command. Any help with this?

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.