#How to make a button in the screen menu to adjust an rgb color
86 messages · Page 1 of 1 (latest)
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
;-;
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
@gentle saddle ;-;
If it is just a slider:
https://github.com/Scillman/mc-scillman-beeinfo/blob/fabric-1.21.0/src/client/java/com/github/scillman/minecraft/beeinfo/gui/PercentageSliderWidget.java
https://github.com/Scillman/mc-scillman-beeinfo/blob/fabric-1.21.0/src/client/java/com/github/scillman/minecraft/beeinfo/gui/OptionsScreen.java
so how can i use it to set a float?
@gentle saddle are u there?
@tight temple The example given already does it with a float though?
how to implement it
i basically want to make a scrollwheel that returns a float that i can use in mixin code
3 of them exacly
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.
u know the fov bar?
??
This one, yes, that is what the code I provided does (though you need some minor modifications)
ur code has like 4 file
files
and btw I am making this mod in 1.18.2 so ;-;
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.
Near identical: https://maven.fabricmc.net/docs/yarn-1.18.2+build.3/net/minecraft/client/gui/widget/SliderWidget.html
declaration: package: net.minecraft.client.gui.widget, class: SliderWidget
i dont want a texture ;-;
nvm
@gentle saddle whats that
@gentle saddle tons of clas dont exist in 1.18.2 ;-;
Why are you even looking there? 🤔
what file do i need
alr i have that
how can i use it to return a float
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.
:-
idk how to register it to my screen ;-;
Than follow a tutorial on how to add a button first. When you do move onto the slider.
i made a button
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
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.)
orrrrrrrrrrr u can tell me how to do it
even the wiki doesnt show how to use sliderwidget
Nope because I would have to get 1.18.2 and have to program it, etc. I ain't gonna spend time on that
just show me how to register a slider in 1.21 ansd ill adapt
declaration: package: net.minecraft.client.gui.screen, class: Screen
So many options to use with that
what is the updatecallback class do
and how can i regiwster it
Do you know what a callback is?
something that calls a method?
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.
i dont have a condition
i just want it to get me a return
...
can u get on a vc?
Nope
'='
Not really, I think it is best that you figure it out by trying at this point.
💀
pretty please '='
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.
just explain the callback
like how to do it
- https://github.com/Scillman/mc-scillman-beeinfo/blob/7870f5239cb11e47c31b49b2c0d73393ccd88b1c/src/client/java/com/github/scillman/minecraft/beeinfo/gui/PercentageSliderWidget.java#L16 takes a
callbackparameter, this is a function pointer/lambda expression to the code you wish to execute. - 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
callbackis called by the slider code. - 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
- 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)
@gentle saddle what is modsettings
A configuration file. But that is not important, you can store your variable wherever you want
what did u set ur sender to be
In my case the sender is the widget that send the information; e.g. the SliderWidget slider1
what did u set it to
in the callback
Sorry, but I am gonna stop helping here. You can just look into the code I provided or ask someone else for help.