Jump to content

[1.16.5] Recipe from .getRecipeFor() returns null when extending AbstractFurnaceTileEntity


UselessRobot

Recommended Posts

I've been trying to make a tile entity that extends AbstractFurnaceTileEntity but have run into a bump with getting the recipe from the smelting recipetype. I've had a look at some older posts about getting recipes from existing recipetypes but I can't quite make out what I'm missing. I've been able to narrow down my issue to my "implementation" of burn below:

Spoiler
	protected boolean canBurn(@Nullable IRecipe<?> recipe) {
		if(recipe == null) {
			TileEntityOnly.LOGGER.info("recipe is null.");
			
		}
		if (!itemHandler.getStackInSlot(0).isEmpty() && recipe != null) {
			//recipes are null fix this part
			ItemStack resultStack = ((IRecipe<ISidedInventory>) recipe).assemble(this);

			if (resultStack.isEmpty()) {
				return false;
			} else {
				ItemStack outputStack = itemHandler.getStackInSlot(2);
				if (outputStack.isEmpty()) {
					return true;
				} else if (!outputStack.sameItem(resultStack)) {
					return false;
				} else if (
						outputStack.getCount() + resultStack.getCount() <= this.getMaxStackSize() && 
						outputStack.getCount() + resultStack.getCount() <= outputStack.getMaxStackSize()
						) { // Forge fix: make furnace respect stack sizes in furnace recipes
					return true;
				} else {
					return outputStack.getCount() + resultStack.getCount() <= resultStack.getMaxStackSize(); // Forge fix: make furnace respect stack sizes in furnace recipes
				}
			}
		} else {
			return false;
		}
	}

 

Any help would be appreciated.

Repository link: https://github.com/Lucidcream/tile_entity_only-1.16

Link to comment
Share on other sites

That's something big I missed. Considering the purpose of this mod I think it'd be better for me to not use AbstractFurnaceTileEntity and instead extend TileEntity and just use the smelting RecipeType.

Thanks for the help

EDIT:

After a closer look, RecipeTypes is also based on IInventory so it'd be more convenient to extend AbstractFurnaceTileEntity anyway. Though the main reason I had done this was that I was unable to get the burnProgress and litTime from AbstractFurnaceTileEntity. Is there anything stopping me from sending this information to my block's Screen?

Edited by UselessRobot
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.