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 have a custom pickaxe that mines the ore and all ores around it and I'm not sure how to account for Silk Touch.

Here is the code:

public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int x, int y, int z, EntityLivingBase par7EntityLivingBase)
    {
	super.onBlockDestroyed(par1ItemStack, par2World, par3, x, y, z, par7EntityLivingBase);
	if(!par7EntityLivingBase.isSneaking())
	{
		String st1 = Integer.toString(par2World.getBlockId(x, y, z));
		String st2 = st1 + ":" + Integer.toString(par2World.getBlockMetadata(x, y, z));
		if(Arrays.asList(this.ores).contains(st1) || Arrays.asList(this.ores).contains(st2))
		{
			//par2World.destroyBlock(x, y, z, true);
			this.repeatMine(par2World, x, y, z);
		}
	}
        return true;
    }

public void repeatMine(World world, int x, int y, int z)
{
	for(int i = -1; i <= 1; i++)
	{
		for(int j = -1; j <= 1; j++)
		{
			for(int k = -1; k <= 1; k++)
			{
				String st1 = Integer.toString(world.getBlockId(x + i, y + j, z + k));
				String st2 = st1 + ":" + Integer.toString(world.getBlockMetadata(x + i, y + j, z + k));
				if(Arrays.asList(this.ores).contains(st1) || Arrays.asList(this.ores).contains(st2))
				{
					world.destroyBlock(x + i, y + j, z + k, true);
					this.repeatMine(world, x + i, y + j, z + k);
				}
			}
		}
	}
}

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Use

EnchantmentHelper#getEnchantmentLevel(enchId, itemStack)

where

enchId

is the ID of the enchantment (e.g. Enchantment#fortune#effectId) and

itemStack

is the ItemStack you want to check (in your case the stack passed as parameter in your method).

The method returns 0 if it isn't enchanted, else it returns the level of the enchantment.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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.