Jump to content

[1.14.4] Determining if an ItemStack can be smelted (blasted or smoked)?


Recommended Posts

Posted (edited)

This is literally the best I have right now and its disgusting.

 

AbstractFurnaceTileEntity furn = (AbstractFurnaceTileEntity)te;
furn.setInventorySlotContents(0, stack.copy());
IRecipe<?> recipeIn = null;
if(furn instanceof BlastFurnaceTileEntity) {
	recipeIn = this.world.getRecipeManager().getRecipe(IRecipeType.BLASTING, furn, this.world).orElse(null);
}
else if(furn instanceof FurnaceTileEntity) {
	recipeIn = this.world.getRecipeManager().getRecipe(IRecipeType.SMELTING, furn, this.world).orElse(null);
}
else if(furn instanceof SmokerTileEntity) {
	recipeIn = this.world.getRecipeManager().getRecipe(IRecipeType.SMOKING, furn, this.world).orElse(null);
}
else return false;
return (recipeIn != null && !recipeIn.getRecipeOutput().isEmpty());

 

Any suggestions?

Edited by Draco18s

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.

Posted
3 hours ago, Draco18s said:

This is literally the best I have right now and its disgusting.

Agreed that is disgusting. Though I feel that the only viable alternatives at this point is also disgusting. One being to use reflection to access the recipes field or RecipeManager#getRecipes(IRecipeType<?>) in the RecipeManger so you can access the specific list/map of the recipe type you want. Or use the collection given by RecipeManager#getRecipes() and cache the recipes that you have already come across in a separate list/map so as to not iterate over every last recipe ever.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

AbstractFurnaceTileEntity stores its IRecipeType (BLASTING, SMELTING or SMOKING) in the protected AbstractFurnaceTileEntity#recipeType field, so you could use reflection to access this instead of using those instanceof checks. This would also handle any modded furnace that extends AbstractFurnaceTileEntity.

 

 

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
13 hours ago, Animefan8888 said:

Or use the collection given by RecipeManager#getRecipes() and cache the recipes that you have already come across in a separate list/map so as to not iterate over every last recipe ever.

Yeah, that was the thing I definitely did *not* want to do.

 

8 hours ago, Choonster said:

AbstractFurnaceTileEntity stores its IRecipeType (BLASTING, SMELTING or SMOKING) in the protected AbstractFurnaceTileEntity#recipeType field, so you could use reflection to access this instead of using those instanceof checks. This would also handle any modded furnace that extends AbstractFurnaceTileEntity.

I was afraid that that was the alternative. I don't particularly like that much either, but it would work and be more flexible.

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...

×   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.