#[Resolved] Trying to switch main hand option with keybind

23 messages · Page 1 of 1 (latest)

tender mulch
#

Yo! New to this sorry if I know very little, first time making a mod (I usually make plugins)

I am trying to make a hotkey that when pressed would toggle the options>skin customization>main hand

I have been trying stuff, I manage to do it visually with:

client.player?.let { it.mainArm = if (it.mainArm == Arm.RIGHT) Arm.LEFT else Arm.RIGHT }

But it doesn't seem to update the setting, I tried with client.options.mainArm that seems like its read only.

Is there something I am missing? A work arround? Or it just not possible?

livid oyster
#

did you check how the options screen saves its changes?

tender mulch
livid oyster
#

!!tut reading_mc_code

glass hemlockBOT
tender mulch
#

Thanks for the link, I will take a look :)

#

So I should go look at how the options menu saves the changes in the Minecraft code and try to do the same?

livid oyster
#

yeah

tender mulch
#

How do I know were to find the right class were that happens?

#

Or I just look until I find

livid oyster
#

SkinOptionsScreen

#

should probably look at its superclass, GameOptionsScreen aswell

tender mulch
#

I see I see

#

Thanks a lot for the names :)

#

It looks like its this in GameOptions not sure

this.mainArm = new SimpleOption("options.mainHand", SimpleOption.emptyTooltip(), SimpleOption.enumValueText(), new SimpleOption.PotentialValuesBasedCallbacks(Arrays.asList(Arm.values()), Arm.CODEC), Arm.RIGHT, (value) -> {
            this.sendClientSettings();
        });
livid oyster
#

GameOptionsScreen calls this.client.options.write() when its closed

tender mulch
#

I see

livid oyster
#

and you'll probably also have to send a packet to the server

tender mulch
#

Ok gonna try some stuff and see if I can figure it out HAHA

#

I apreciate all the help <3

#

Figure it out!

#
 client.player?.let { player ->
                    // Toggle the player's main arm between left and right
                    val newMainArm = if (player.mainArm == Arm.RIGHT) Arm.LEFT else Arm.RIGHT

                    // Update the game options
                    client.options.mainArm.value = newMainArm
                    client.options.write()
                }
#

That seems to work :D