Jump to content

[1.16.4] Custom recipe type doesn't work with custom machine.


vassdeniss

Recommended Posts

I made a custom machine in my mod alongside a custom recipe but I can't seem to get the output to update based on the input. Help would be appreciated!

Here is how i am trying to implement it in my container.

    public void updateOutput() {
        List<SpiritRecipe> list = world.getRecipeManager().getRecipes(ModRecipeSerializers.SPIRIT_TYPE, inventory, world);
        if (list.isEmpty()) {
            craftResultInventory.setInventorySlotContents(0, ItemStack.EMPTY);
            System.out.println("List is empty");
        } else {
            SpiritRecipe spiritRecipe = list.get(0);
            ItemStack itemstack = spiritRecipe.getCraftingResult(inventory);
            craftResultInventory.setRecipeUsed(spiritRecipe);
            craftResultInventory.setInventorySlotContents(0, itemstack);
        }
    }

    @Override
    public void onCraftMatrixChanged(IInventory inventoryIn) {
        super.onCraftMatrixChanged(inventoryIn);
        if (inventoryIn == inventory) {
            updateOutput();
        }
    }

 

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

Look at e.g. LoomContainer.

Something like this?

    @Override
    public void onCraftMatrixChanged(IInventory inventoryIn) {
        ItemStack itemStack = base.getStack();
        ItemStack itemStack1 = addition.getStack();
        ItemStack itemStack2 = result.getStack();
        if (itemStack2.isEmpty() && itemStack.isEmpty() || itemStack1.isEmpty()) {
            this.result.putStack(ItemStack.EMPTY);
        }
        
        super.onCraftMatrixChanged(inventoryIn);
        updateOutput();
    }

 

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.