1

I made a custom crafting table back when the /testblock command was still a thing, and I found out that it's no longer in 1.14? Are there any equivalents? The world was deleted, so I can't go back and copy the code from there. I'm pretty much just trying to find another way to make a custom crafting table using commands.

(PS. The crafting table worked in the way that it would test for the items via the /testblock command inside the dispenser, it would then change the block to a dispenser with the crafted item, and then it would dispense it.)

3 Answers 3

3

You can output the result of a check to chat with execute if without a run part, but that's not the main purpose of it.

Before I edited it out, you used the tag for this question, that tells me that you still think of command blocks as mainly redstone components. They do still react to redstone, so that you can for example trigger them with a button, but since 1.7 you don't need it and since 1.9 you should actively avoid it, because using redstone slows down your command system, causes more lag than the alternatives and makes your system more fragile.

Instead, you should think about your command systems as "if X, then do Y to Z" or similar. For example this command says "hi" if there is a chicken near you:

/execute if @e[type=chicken,distance=..5] run say hi

And this command teleports every cow with the "yay" tag to the closest pig (each cow to their respective closest pig, not all to the same):

/execute as @e[type=cow,tag=yay] at @s run tp @s @e[type=pig,sort=nearest,limit=1]

It's not always the most convenient solution to convert your entire system to a single line of chain command blocks attached to a repeating command block, but it is always possible and more often than not a better solution.
Rule of thumb: If you ever attach a comparator to a command block and put something other than a lamp behind it, re-think your system.

2

A different solution that is harder to set up, but requires fewer blocks, could look like this:

To replace a diamond in the middle slot with diamond ore you would use this command:

execute if block 18 67 -119 minecraft:dispenser{Items:[{Slot:4b,id:"minecraft:diamond",Count:1b}]} run setblock 18 67 -119 minecraft:dispenser[facing=north,triggered=true]{Items:[{Slot:4b,id:"minecraft:diamond_ore",Count:1b}]}

It is important that the triggered value changes, because if it stays the same, the command will fail to put the diamond ore into the dispenser. This should not be a problem in practice though, but you should keep it in mind.

To craft a piston using this soultion you would use this command:

execute if block 18 67 -119 minecraft:dispenser{Items:[{Slot:0b,id:"minecraft:oak_planks",Count:1b},{Slot:1b,id:"minecraft:oak_planks",Count:1b},{Slot:2b,id:"minecraft:oak_planks",Count:1b},{Slot:3b,id:"minecraft:cobblestone",Count:1b},{Slot:4b,id:"minecraft:iron_ingot",Count:1b},{Slot:5b,id:"minecraft:cobblestone",Count:1b},{Slot:6b,id:"minecraft:cobblestone",Count:1b},{Slot:7b,id:"minecraft:redstone",Count:1b},{Slot:8b,id:"minecraft:cobblestone",Count:1b}]} run setblock 14 67 -119 minecraft:dispenser[facing=north]{Items:[{Slot:4b,id:"minecraft:piston",Count:1b}]}

The creaftin-table-dispenser would be at the coordinates 18 67 -119 and it should face north.

This command checks for exact values, so you cannot have more than 1 of the specified item in a slot, or it will not work (unless you set the count to something different).

Note: This command does NOT check if there are any other items in slots that are not used by the recipee, those will get deleted in the process

1

One solution could look like this:

A setup for 3 recipees

Every command block has this command:

execute if blocks ~1 ~ ~ ~1 ~ ~ 18 67 -119 all run clone ~2 ~ ~ ~2 ~ ~ 18 67 -119

And you can easily extend it.

In my case the dispensers are looking north and the "crafting-table"-dispenser is at the coordinates 18 67 -119 and it is the one in the front.

The left row of dispensers (except for the front one, which is the crafting table) contains the result of each crafting recipee. The middle row contains the recipees.

The command compares the dispenser next to it with the crafting-table dispenser and sets the crafting-table dispenser to whatever the result of your crafting recipee is.

It is important that all dispensers look in the same direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.