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

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?

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.