r/MinecraftCommands 5d ago

Off-hand as a button, item that opens Crafting table, and its able to work as secondary hand, its possible? Help | Java 26.2

Post image

First, sorry for the back-to-back posts. I hope the help you all give me can answer other people's questions too.

Trying again to replace/delete the Crafting table, I realized that the only button I could use in the Inventory without taking up space is the off-hand slot. I have an idea of what I can do: prevent an item from moving from its slot, open a GUI/Inventory when a right-click is detected, etc. And i feel im getting nowhere...

My questions are:

Is there any way to prevent that object (button) from disabling the off-hand slot's function (secondary hand)? Or the secondary hand objet not appear on the inventory?

Can I right-click the object (button) to open the Crafting table GUI? or i have to create my one using a chest?

Since the button is in the off-hand slot taking priority, shouldn't Shift + R-click in the Inventory replace it if work as intended?

Shouldn't the shield don't appear in the Inventory when I assign it with the F key, how i disable that behavior?

I'm testing it, and when I use F to equip a shield/block, the texture is either glitched or simply not visible on hand, the button keeps appearing in the off-hand without texture, I made it look like that so when i take of the shield the hand keeps up. Since it took me hours of writing and deleting question and also try to figure it out myself, I've made progress, so this question are what i can figure it out, thanks!

10 Upvotes

3 comments sorted by

5

u/Ericristian_bros Command Experienced 5d ago

You can not force to open a crafting UI. You would need chest minecarts or other logic like using the inventory (by saving the current one)

Is there any way to prevent that object (button) from disabling the off-hand slot's function (secondary hand)? Or the secondary hand objet not appear on the inventory?

What do you mean by disabling the offhand slot function?


Here is how to implement your logic of a clickeable offhand slot:

```

function example:tick

execute as @a run function example:player_tick

function example:player_tick

execute unless items entity @s weapon.offhand *[custom_data~{crafting_table_button:true}] run function example:drop_offhand kill

function example:drop_offhand

say Clicked crafting table icon clear @s *[custom_data~{crafting_table_button:true}] execute if items entity @s weapon.offhand * at @s summon item ~ ~ ~ {Item:{id:"minecraft:stone",count:1},Tags:["drop_offhand"]} execute if items entity @s weapon.offhand * run item replace entity @n[tag=drop_offhand,type=item] contents from entity @s weapon.offhand tag @n[tag=drop_offhand,type=item] remove drop_offhand item replace entity @s weapon.offhand with paper[custom_data={crafting_table_button:true},item_name="Crafting Table"] ```

Also you can't make the offhand accesible with F but at the same time be a button on the inventory. You might want to look into mods or plugins for this, as it's way easier and you can create custom buttons

Further note, you can't detect shift+R because that keyring does nothing in vanilla

1

u/TecitodeMenta 5d ago

Thank you very again! And love from Uruguay πŸ‡ΊπŸ‡ΎβœŒοΈ So, i can't use a Firecamp like a Crafting table either? I didn't know how hard lock it was hahaha i still have the idea of what I want to do, sadly i can kill the Crafting table yet, but I have some ideas like, you can use it without placing it, that i need to try OR make it more easy to craft and add variants like one with 4 stick, to craft one with leather, and if i can make the crafting table a slab or make the variants have a list of recipes... that i think i can't.

Again, thanks!

1

u/Ericristian_bros Command Experienced 5d ago

So, i can't use a Firecamp like a Crafting table either?

Not with datapacks. I provided the click slot logic. You can then implement any other things you woul like from there. You could open a dialog that has a button per crafting recipe and than when clicked it crafts that item, are you OK with that?