(SOLVED) How can I prevent items from dropping out of the output slot when a custom crafting block is destroyed?

Started by LordenjeMC on

Topic category: Help with MCreator software

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(SOLVED) How can I prevent items from dropping out of the output slot when a custom crafting block is destroyed?
Tue, 06/30/2026 - 16:07 (edited)

DeepL-Translate:

How can I prevent items from dropping out of the output slot when a custom crafting block is destroyed? I’ve looked through lots of threads and videos, but I haven’t found anywhere – not just a solution to this problem, but even a mention of it.

In every guide that creates custom crafting tables, once all conditions are met, the final item is placed in the output slot (Set n item in slot n of block [x y z] if it has inventory), and then the guide generally ends there. But what about the target item dropping out of the output slot? I wanted to create a custom crafting table similar to the vanilla crafting table: so that, when the ingredients are placed correctly, the result appears in the output slot, but you don’t have to take it – if you do take it, the required number of ingredients will be removed, and if you don’t, everything will remain in place, waiting for your next move.

I solved the issue of what happens when you exit the block’s GUI, break the block, and all items including the target item from the output slot – drop out. In principle, this is a trivial problem that’s solved simply by removing the item from the output slot when closing the GUI. But for some reason, no one mentions that the target item can drop out of the output slot along with all the ingredients if the block is destroyed by someone or something else – for example, another player, a creeper, a ghast, etc., while you’re still in the block’s GUI. What’s more, this problem isn’t solved by removing items from the output slot when the “When block destroyed by player (or by explosion)” trigger fires – I assume this is because the block has already been destroyed and the items have already dropped, so it’s too late to clear the slots.

Either I’m doing something completely wrong and need to do it differently and no one faces this problem, OR really no one took this factor or scenario into account. At least with the vanilla workbench, this doesn’t happen – everything works as it should there, and the displayed target item won’t drop if someone else destroys the workbench.

 

Edited by LordenjeMC on Tue, 06/30/2026 - 16:07
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
On gui closed, clear items…
Thu, 06/25/2026 - 15:38

On gui closed, clear items from slot 12345 whatever your output slot id is

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
fr6_17, I think you haven't…
Fri, 06/26/2026 - 06:40

fr6_17, I think you haven't quite understood what I mean. The problem is that the target item being displayed drops when someone else breaks a block while you're still in the interface. Of course, if you close the GUI – everything will be cleared, but if you don’t close it and the block gets broken, all the ingredients will drop (which is normal) along with the TARGET item that’s displayed (and that’s the problem). If there were a trigger that would execute the procedure BEFORE the block is broken, rather than after, then maybe I could solve my problem. But in this situation, there are two solutions:
1. Either don’t try to mimic the vanilla workbench by displaying the target craft item in the output slot, and change the crafting logic so as not to have to deal with this problem
2. Or maybe there is a way to do it the way I want after all, but I’m simply not experienced or knowledgeable enough to figure out how to fix it. Maybe, for example, instead of directly and literally placing the target item in the output slot, I could display only a dummy or virtual copy... But I'm not sure, and don't know

Joined Apr 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Have a procedure on the…
Sat, 06/27/2026 - 06:11

Have a procedure on the block for when it is being broken, immediately to delete the item out of the output slot, you can do this by going to the triggers for the block you connected the gui to, select the when player starts to break option, make a procedure to delete the item from output, then if a play starts to break it, it will delete, if a player attempts to break it and the gui is open, it should keep the  item there if you have the gui update on tick. add the same trigger for on broken, and it should work

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
hi-hi8989 Ahhh, darn it, I…
Sat, 06/27/2026 - 09:01

hi-hi8989 Ahhh, darn it, I didn't notice that there's a trigger called "When player starts to destroy" in the triggers. Well, that might change everything. Man, I'm so inattentive. I only saw the “When block (already) destroyed by...” triggers, but it turns out there was another trigger right BEFORE the destruction – specifically, during the process. Darn it, I’ll go back and try to achieve what I want again, this time using that trigger. Thanks, everyone, for your help. I hope everything works out. And if it does, I'll have to remember to edit the thread title by adding "SOLVED" at the beginning. ✨

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Although, of course, this…
Sat, 06/27/2026 - 09:13

Although, of course, this might only help solve part of the problem – namely, when a block is destroyed by another player – and that’s already not bad, but, as far as I can tell so far, it won’t solve the problem in cases where a block is destroyed by an explosion from a Creeper, Ghast, Wither, etc. After all, an explosion destroys a block instantly, and the only trigger related to explosions – “When block destroyed by explosion” – triggers the procedure only after the explosion has already occurred and the block has been destroyed. So it’s still not perfect, but it’s already much better. And now it’s starting to seem more and more to me that the item displayed in the vanilla workbench isn’t actually real, but rather imaginary – just a placeholder in the form of a texture – which is why there’s nothing for it to drop. I’ll think about this. I’m already starting to come up with some pretty good ideas. Thanks again, everyone!

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
That's it. I found a…
Tue, 06/30/2026 - 16:07

That's it. I found a solution to my problem. If anyone is reading this comment and has a similar question or problem, here's how I solved it:

I decided to rethink the crafting process. In the end, I removed the output slot where the target crafted item used to appear. Instead, I placed images in that GUI place that display under a specific condition (if all required resources are present in the input slots), as well as an invisible button image on top of everything; clicking it crafts the target item and consumes the resources involved in its crafting. There are as many images as there are crafting outcomes, and each one has the texture of the target item being crafted to show the player what they can craft based on the resources they’ve placed in the input slots. In other words, if nothing can be crafted, nothing will be displayed; if something can be crafted, then what’s possible will be displayed. The result is as follows:
1. The procedure for "clearing block slots and returning the items that were in them to the player's inventory" is tied to a trigger that fires when the player exits the crafting block's GUI.
2. The "When block destroyed by..." triggers do not have any procedures associated with them, since these triggers are no longer needed.
3. There are now simply placeholder images that appear only when something can be crafted from the placed items. Over these images is a functional, transparent image button; clicking it simply checks which specific resources are in the input slots and, depending on that, clears them and gives the player the target craft item.

Yes, all of this would have worked and looked simpler if I had just made crafting as straightforward as clicking a button from the start, but that’s not as interesting, and I wanted to at least visually create something similar to the vanilla workbench concept. I think the result I achieved is quite good and close enough in both principle and appearance to the vanilla workbench.