Jump to content

Recommended Posts

Posted (edited)

I am using PlayerController.windowClick to organize my Inventory. For testing purpose I have made a loop, that should swap the 9 slots of hotbar with 9 horizontal slots from inventory:

Minecraft mc = Minecraft.getInstance();
if ( mc.player == null ) return;
PlayerEntity player = mc.player;
PlayerController pc = mc.playerController;
ClickType click = ClickType.SWAP;
for ( int i = 1; i < 4; i ++ ) {
	for ( int j = 0; j < 9; j ++ ) {
		int k = j + i * 9;
		pc.windowClick(0, k, 0, click, player);
		pc.windowClick(0, k + 9, 0, click, player);
		pc.windowClick(0, k, 0, click, player);
	}
}

 It swaps the hotbar slots from 1 to 8 perfectly, but the hotbar slot 0 ( or in inventory it is 36 ) just does not react to windowClick with clickType.SWAP... I tested with clickType.THROW and it dropped the item successfully... What is going on?

Edited by Kemuri Senpai
Posted

Hmm... But the Method takes this arguments in my opinion:

1) Inventory ID, in code above it's 0

2) Slot ID to interact with

3) whether a right-click

4) Type of interaction

5) The player

 

What do you mean by "taking in two slot IDs"?

Posted (edited)

However, I still have a question 😅

pc.windowClick(0, 37, 0, click, player);
pc.windowClick(0, 38, 0, click, player);
pc.windowClick(0, 37, 0, click, player);

works as I wanted. It swaps the second and the third item in my hotbar. But 

pc.windowClick(0, 36, 0, click, player);
pc.windowClick(0, 37, 0, click, player);
pc.windowClick(0, 36, 0, click, player);

does not swap the first and the second... It actually does nothing

Edited by Kemuri Senpai
Posted

Ow, I see, so the second "0" i use, is only a placeholder? I could also use any other slot I want?...

So I even could swap two slots without the three commands? Just with one:

clickWindow( inventoryID, 36, 1, click, player )?

I expect this to swap two first slots in hotbar.. Is it how it works?

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.