mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-17 17:55:09 +01:00
dev: switch to stonecutter build system
- This will allow us to build the library for different Minecraft versions at the same time - Right now, only Fabric and Neoforge 1.21.10 are fully working - As a bonus, the jar is now even smaller!
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package eu.midnightdust.lib.config;
|
||||
|
||||
import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class MidnightSliderWidget extends AbstractSliderButton {
|
||||
private final EntryInfo info;
|
||||
private final MidnightConfig.Entry e;
|
||||
|
||||
public MidnightSliderWidget(int x, int y, int width, int height, Component text, double value, EntryInfo info) {
|
||||
super(x, y, width, height, text, value);
|
||||
this.e = info.entry;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMessage() {
|
||||
this.setMessage(Component.nullToEmpty(info.tempValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyValue() {
|
||||
if (info.dataType == int.class) info.setValue(((Number) (e.min() + value * (e.max() - e.min()))).intValue());
|
||||
else if (info.dataType == double.class)
|
||||
info.setValue(Math.round((e.min() + value * (e.max() - e.min())) * (double) e.precision()) / (double) e.precision());
|
||||
else if (info.dataType == float.class)
|
||||
info.setValue(Math.round((e.min() + value * (e.max() - e.min())) * (float) e.precision()) / (float) e.precision());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user