Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign Up Now!
  • There is an ongoing Game Jam event! Learn more here

How do I disable the 2x2 crafting?

Joined
Sep 8, 2020
Messages
25
So I've seen some games where if you try to use the vanilla 2x2 crafting in your inventory, it closes your inventory so you can't vanilla craft to make vanilla items. I've heard it is hard to explain, but if anyone knows how to, can you tell me? It could be easier to type it out. Thank you
 

EmeralDev

Well-known member
Joined
Sep 7, 2020
Messages
161
what you want to do is this:

Code:
On Player Click Own Inv()
{
    If Variable(gameValue.getClickedIndex>=37)
    {
        CancelEvent();
    }
}
that should work, if it doesn't then tell me :)
 
Joined
Sep 8, 2020
Messages
25
Hey, thanks for the help, but for whatever reason it doesn't work. It disables most of the armor and offhand slots, but not the crafting menu. Also, when i send myself the Clicked Slot Index in the chat, and I click the crafting menu, nothing appears. Is there another trick to it?
 

RDM

Moderator
Moderator
Joined
Sep 6, 2020
Messages
25
@TheExtremeBurger

Also, when i send myself the Clicked Slot Index in the chat, and I click the crafting menu, nothing appears.
If that's the case, then you most likely can't check if the crafting inventory has been clicked through direct means, unless there's some uber simple "If Player Clicks Crafting Table Menu" action that I don't know of.

It appears that Click Own Inv doesn't run with crafting menus, so my recommendation would be to find something that does run when you click on the crafting menu slots. Test everything that could potentially work thoroughly. You can also still figure out if the crafting menu is clicked by checking if you aren't clicking on your inventory slots, but in order to do that we've got to sort out the crafting menu not being detected first.

I'll most likely have time today or tomorrow to find something concrete if you're still having trouble by then.
 

EmeralDev

Well-known member
Joined
Sep 7, 2020
Messages
161
Hey, thanks for the help, but for whatever reason it doesn't work. It disables most of the armor and offhand slots, but not the crafting menu. Also, when i send myself the Clicked Slot Index in the chat, and I click the crafting menu, nothing appears. Is there another trick to it?
it might not be 37. try toying around with numbers maybe with a sendmessage(eventClickedSlotIndex);
also, instead of cancel event, do close inventory as that might work better
 

stinkey

Member
Joined
Sep 8, 2020
Messages
24
you can try doing on click, get the inventory menu items (this will default to the 2x2 crafting if you are opening your own inv iirc) and see whether the list is equal to [air, air, air, air, air]. if its NOT equal, cancel event.

edit: or just a loop
 
Last edited:

DFIdentity

Active member
Joined
Sep 9, 2020
Messages
68
As RDM said, Player Event: ClickOwnInv doesn't activate when you click the crafting menu at all, so it won't output anything no matter what code you put in to detect that.
 

Vulcanowo

New member
Joined
Sep 11, 2020
Messages
19
I've seen games that force your inventory to close whenever you put something in the crafting grid. I'm not sure how they do it, though.
They probably check if they lost an item when they clicked, so they made sure it didnt just go in the inventory
 
Joined
Sep 8, 2020
Messages
25
I've experimented a bit, and for whatever reason, you can find the items in the game value Inventory Menu Items, without an actual Inventory Menu open. Additionally, the Inventory Menu Name game value will say "Crafting" when you don't have an actual inventory menu open. So, I believe you have to check if your "menu" name is "crafting", and if there is anything in there, your inventory is closed. Only thing is, I don't know what the name really is. I've tried just "Crafting" with the natural italics, and that didn't seem to work.
 
Joined
Sep 8, 2020
Messages
25
I've found how to disable it!

What you do, is, on a loop:

If Var: (GameValue: OpenInvTitle) Contains txt(Crafting)

Then, Set Variable: Join Text var(%default inventory items) to gameValue: InventoryMenuItems

Now, an If Var: var(%default inventory items) =! airairairairair

Then PlayerAction: CloseInventory

sorry if the explanation is bad, i can't write instructions well, especially in a semi code format lol
also, "airairairairair" is the 5 inventory slots of the Crafting menu. Using jointext doesn't put in spaces

also, thx stinkey, I didn't see the message until now, and I figured it out lol
 

The Cube

New member
Joined
Sep 16, 2020
Messages
3
There is a method to do this that I am aware of (I thought of it a while back and my brain is peanut-sized so there's probably a much better solution) and I'll go over that.

To start, you need to first create a variable on join, that being an item variable that is equal to air. For those unaware of how to do this, you use a Set Item Type setvar. In there, place one should be the variable, place two should have any unmodified item (stone, dirt, grass, etc) and place three a text item "air". This will create an air item stores as a variable. After this, you need to create a list consisting of exactly 5 of that variable.

Once you have this set up, you likely want to place the code to prevent 2x2 crafting on a one-tick loop. First have an ifvar checking if the Open Inventory Title game value is equal to a text item "Crafting". Within that, place another ifvar, checking if your air list variable is not equal to the Inventory Menu Items game value. The reason this second ifvar checks if you have placed anything within the crafting grid, and the first ensures the code does not run if your inventory is not open - otherwise you get a nice little softlock.
 

The Cube

New member
Joined
Sep 16, 2020
Messages
3
I've found how to disable it!

What you do, is, on a loop:

If Var: (GameValue: OpenInvTitle) Contains txt(Crafting)

Then, Set Variable: Join Text var(%default inventory items) to gameValue: InventoryMenuItems

Now, an If Var: var(%default inventory items) =! airairairairair

Then PlayerAction: CloseInventory

sorry if the explanation is bad, i can't write instructions well, especially in a semi code format lol
also, "airairairairair" is the 5 inventory slots of the Crafting menu. Using jointext doesn't put in spaces

also, thx stinkey, I didn't see the message until now, and I figured it out lol
wow mean you posted it before me
 
Top Bottom