Jump to content

[1.7.10][solved]using oredictionary to recognize ores


hsgill97@gmail.com

Recommended Posts

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);
			}
	}
}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.