Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


vassdeniss
 Share

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

9 minutes ago, diesieben07 said:

Does it find the recipe? Does the recipe work properly? Have you tried using the debugger?

I didn’t thought of a debugger. Ill check now. The output doesnt change so no it doesnt work properly. Are the methods written properly?

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.