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 cutom pickaxe called enderPickaxe. I want the pickAxe to double all ores and smelt it. The code I have will double and smelt anything that is smeltable.How would i finds ores only so mining a log or cobble won't double and smelt it. Is there a function like boolean isOre(ItemStack x) that would make it easy to check. This is how I currently do it

 

	@SubscribeEvent
public void onBlockHarvest(HarvestDropsEvent event)
{
	if(event.harvester.getHeldItem()!=null&&event.harvester.getHeldItem().getItem() instanceof enderPickaxe)
	{
		ItemStack stack = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(event.block,1,event.blockMetadata));

			if(stack!=null)
			{
				ItemStack x=new ItemStack(stack.getItem(),2);
				event.drops.clear();
				event.drops.add(x);
			}
	}
}

That won't necessarily work.  You've dropped the metadata from the smelting result.  It also ignores ore blocks that don't drop blocks, but items, which can then be smelted, you'd need to look at the event.drops arraylist.

 

That said, to answer your question:

OreDictionary.getOreName(OreDictionary.getOreIDs(stack));

Note that that is not valud code, as getOreIDs() returns an array.

 

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.

  • Author

if(OreDictionary.getOreIDs(stack)[0]!=0)

 

the array contains integer of all ids associated with the ore. I just check if it has a value or is the initial value of zero.

 

would something like this work to check if it is an ore.

 

The other points you mention yes I realize it and I will fix it so it checks if it is smelt able then smelt it and double and if the drops are items then double it.

Stone is registered "stone" in the oredict, along with other blocks.  So "is it an ore" may not be true.

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.