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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.