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.

Featured Replies

Posted

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();
        }
    }

 

  • Author
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?

  • Author
8 minutes ago, diesieben07 said:

No, you have to call it manually from your slots. Look at the vanilla crafting containers for reference.

I will do that! Thank you very much for your time!

  • Author

As far as i can see the onMatrixChange never gets called manually? How should I go about implementing this?

  • Author
18 minutes ago, diesieben07 said:

Have you done this?

No but i meant it never gets called manually in vanilla either. I presume i need to call it whenever i place an item inside?

  • Author

because everytime i try to find a reference it never finds me one... Do I need to call it from the tile entity # insertItem?

  • Author
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();
    }

 

  • Author

From the looks of it LoomContainer still doesn't call onCraftMatrixChanged... What am i missing seriously?

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.