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.

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

Featured Replies

Posted

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

  • Author

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

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.