#How to make a button in the screen menu to adjust an rgb color

86 messages · Page 1 of 1 (latest)

tight temple
#

@dense vessel ;-;......

#

btw @dense vessel i made it so when u look at an entity that is in ur reach it channges the hitbox color

#

usding mixin

#

now i need to make that color changable from the client

#

so u know

#

i can publish the mod

#

;-;

tight temple
#

i made the button

#

and i made a screen

#

but idk how to make a button that returns a float and is scrollable

#

like the fov button

#

and when i tried to find the fov button

#

i couldnt

tight temple
#

@gentle saddle ;-;

tight temple
tight temple
#

@gentle saddle are u there?

gentle saddle
#

@tight temple The example given already does it with a float though?

tight temple
#

i basically want to make a scrollwheel that returns a float that i can use in mixin code

#

3 of them exacly

gentle saddle
#

First what is it that you want? A slider or wheel? If it is a slider than you can just use the provided code and modify it to your situation. If you want a wheel... I do not think there is a builtin function for it, so probably a library would be the best option.

gentle saddle
#

This one, yes, that is what the code I provided does (though you need some minor modifications)

tight temple
#

files

#

and btw I am making this mod in 1.18.2 so ;-;

gentle saddle
#

I literally linked you 2 (!) files, one for adapting the slider widget; and the other for how to use it like the other widgets. Nothing more and nothing less.

tight temple
#

i dont want a texture ;-;

#

nvm

#

@gentle saddle whats that

#

@gentle saddle tons of clas dont exist in 1.18.2 ;-;

gentle saddle
tight temple
tight temple
#

how can i use it to return a float

gentle saddle
#

When you understand that file it should have a similar interface to the other widgets, and as linked in #1259109952514035762 message you can see how it works in 1.18.2 (since mine is for 1.21 you would need to make some changes)

#

You give it a callback function, when the user changes the value you handle it from there.

tight temple
gentle saddle
tight temple
#

btw there are no tutorials

#

i made a normal button on the main menu screen

#

that is supposed to make mew go to the screen i created

#

idk how to register buttons in the screen that i created

#

1.18.2 doesnt have a wiki

gentle saddle
#

The wiki gives a general idea of how to do it. You will have to adapt it to your own version like everyone else. (And that sadly takes time, just like I spend hours today to get model datagen to work properly.)

tight temple
#

even the wiki doesnt show how to use sliderwidget

gentle saddle
#

Nope because I would have to get 1.18.2 and have to program it, etc. I ain't gonna spend time on that

tight temple
gentle saddle
#

So many options to use with that

tight temple
#

and how can i regiwster it

gentle saddle
#

Do you know what a callback is?

tight temple
gentle saddle
#

A callback is a function pointer/lambda expression that is executed after a certain event occurs. In the case of the slider code I write for BeeInfo it is when the value has changed. Thus when the value changed the function you set as the callback will be called.

tight temple
#

i just want it to get me a return

gentle saddle
#

...

tight temple
gentle saddle
#

Nope

tight temple
#

'='

tight temple
#

:-

gentle saddle
#

Not really, I think it is best that you figure it out by trying at this point.

tight temple
#

pretty please '='

gentle saddle
#

What is there to explain, I think there is nothing to explain anymore. You click a button and the button's callback is called, than you execute your code. You slide a slider and the slider's callback is called, than you execute your code.

I really do not know how to explain it simpler or better honestly.

tight temple
#

like how to do it

gentle saddle
#
  1. https://github.com/Scillman/mc-scillman-beeinfo/blob/7870f5239cb11e47c31b49b2c0d73393ccd88b1c/src/client/java/com/github/scillman/minecraft/beeinfo/gui/PercentageSliderWidget.java#L16 takes a callback parameter, this is a function pointer/lambda expression to the code you wish to execute.
  2. https://github.com/Scillman/mc-scillman-beeinfo/blob/7870f5239cb11e47c31b49b2c0d73393ccd88b1c/src/client/java/com/github/scillman/minecraft/beeinfo/gui/PercentageSliderWidget.java#L37 when the slider's value changed the callback is called by the slider code.
  3. https://github.com/Scillman/mc-scillman-beeinfo/blob/7870f5239cb11e47c31b49b2c0d73393ccd88b1c/src/client/java/com/github/scillman/minecraft/beeinfo/gui/OptionsScreen.java#L118 when creating a slider you pass in a function/lambda to be executed when the value changed as seen on line 118
  4. https://github.com/Scillman/mc-scillman-beeinfo/blob/7870f5239cb11e47c31b49b2c0d73393ccd88b1c/src/client/java/com/github/scillman/minecraft/beeinfo/gui/OptionsScreen.java#L70 the function that is being called when the slider's value has changed

I think it is better to use the code as a reference because you do not seem to understand it otherwise. (May I advise you to Google it up online to make it easier)

GitHub

Contribute to Scillman/mc-scillman-beeinfo development by creating an account on GitHub.

GitHub

Contribute to Scillman/mc-scillman-beeinfo development by creating an account on GitHub.

tight temple
#

@gentle saddle what is modsettings

gentle saddle
#

A configuration file. But that is not important, you can store your variable wherever you want

gentle saddle
#

In my case the sender is the widget that send the information; e.g. the SliderWidget slider1

tight temple
#

in the callback

gentle saddle
#

Sorry, but I am gonna stop helping here. You can just look into the code I provided or ask someone else for help.