Posted December 26, 20204 yr 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 December 26, 20204 yr by Kemuri Senpai
December 26, 20204 yr Author Did this windowClick method change since 1.12? I am actually using the same principe as in https://github.com/kulttuuri/quick-hotbar-mod/blob/1.12/src/main/java/com/kulttuuri/quickhotbar/QuickHotbarEventHandler.java#L472
December 26, 20204 yr Author 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"?
December 26, 20204 yr Author I still do not understand, as in https://stackoverflow.com/questions/60443432/using-minecrafts-playercontroller-windowclick it says, slot 0 is the crafting table Output, so how could the "parameter" be a slot ID? Cause then, the github example would be wrong Edited December 26, 20204 yr by Kemuri Senpai
December 26, 20204 yr Author Okay, currently no acces to my computer, I will check it Thank you, so far
December 26, 20204 yr Author 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 December 26, 20204 yr by Kemuri Senpai
December 26, 20204 yr Author 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?
December 26, 20204 yr Author Damn, thank you! I was so focused on the code from github, assuming that he is doing it correctly... How can I upvote you?
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.