broken shit

This commit is contained in:
kawaiizenbo 2023-06-11 10:59:20 -07:00
parent 0edfc893ab
commit 5ccad6b10a
16 changed files with 149 additions and 24 deletions

View file

@ -1,5 +1,8 @@
package me.kawaiizenbo.moonlight.module.settings;
import java.lang.reflect.Method;
import me.kawaiizenbo.moonlight.util.ReflectionUtils;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
@ -7,10 +10,11 @@ public class BooleanSetting extends Setting
{
public boolean value;
public BooleanSetting(String name, boolean value)
public BooleanSetting(String name, boolean value, Method onValueChanged)
{
this.name = name;
this.value = value;
this.onValueChanged = onValueChanged;
}
@Override
@ -29,6 +33,7 @@ public class BooleanSetting extends Setting
if (hovered((int)mouseX, (int)mouseY) && button == 0)
{
this.value = !value;
ReflectionUtils.tryCallMethod(onValueChanged, new Object[0]);
}
}
}

View file

@ -1,5 +1,8 @@
package me.kawaiizenbo.moonlight.module.settings;
import java.lang.reflect.Method;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
@ -11,11 +14,12 @@ public class ColorSetting extends Setting
public int b;
public ColorSetting(String name, int value)
public ColorSetting(String name, int value, Method onValueChanged)
{
this.name = name;
this.value = value;
this.height = 64;
this.onValueChanged = onValueChanged;
this.r = (value >> 16) & 0xFF;
this.g = (value >> 8) & 0xFF;
this.b = value & 0xFF;
@ -26,12 +30,12 @@ public class ColorSetting extends Setting
{
super.render(drawContext, x, y, mouseX, mouseY);
drawContext.drawTextWithShadow(textRenderer, Text.literal(name), x+2, y+2, 0xFFFFFF);
int redDisplayStartColor = ((255&0x0ff)<<24)|((0&0x0ff)<<16)|((g&0x0ff)<<8)|(b&0x0ff);
int redDisplayEndColor = ((255&0x0ff)<<24)|((255&0x0ff)<<16)|((g&0x0ff)<<8)|(b&0x0ff);
int greenDisplayStartColor = ((255&0x0ff)<<24)|((r&0x0ff)<<16)|((0&0x0ff)<<8)|(b&0x0ff);
int greenDisplayEndColor = ((255&0x0ff)<<24)|((r&0x0ff)<<16)|((255&0x0ff)<<8)|(b&0x0ff);
int blueDisplayStartColor = ((255&0x0ff)<<24)|((r&0x0ff)<<16)|((g&0x0ff)<<8)|(0&0x0ff);
int blueDisplayEndColor = ((255&0x0ff)<<24)|((r&0x0ff)<<16)|((g&0x0ff)<<8)|(255&0x0ff);
int redDisplayStartColor = ColorUtils.rgbaToInt(0, g, b, 255);
int redDisplayEndColor = ColorUtils.rgbaToInt(255, g, b, 255);
int greenDisplayStartColor = ColorUtils.rgbaToInt(r, 0, b, 255);
int greenDisplayEndColor = ColorUtils.rgbaToInt(r, 255, b, 255);
int blueDisplayStartColor = ColorUtils.rgbaToInt(r, g, 0, 255);
int blueDisplayEndColor = ColorUtils.rgbaToInt(r, g, 255, 255);
drawContext.fillGradient(x+80, y+2, x+92, y+62, redDisplayEndColor, redDisplayStartColor, 0);
drawContext.fillGradient(x+95, y+2, x+107, y+62, greenDisplayEndColor, greenDisplayStartColor, 0);
drawContext.fillGradient(x+110, y+2, x+122, y+62, blueDisplayEndColor, blueDisplayStartColor, 0);

View file

@ -1,6 +1,9 @@
package me.kawaiizenbo.moonlight.module.settings;
import java.lang.reflect.Method;
import me.kawaiizenbo.moonlight.util.MathUtils;
import me.kawaiizenbo.moonlight.util.ReflectionUtils;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
@ -12,10 +15,11 @@ public class DoubleSetting extends Setting
boolean sliding = false;
public DoubleSetting(String name, double value, double min, double max, int roundingPlace)
public DoubleSetting(String name, double value, double min, double max, int roundingPlace, Method onValueChanged)
{
this.name = name;
this.value = value;
this.onValueChanged = onValueChanged;
this.min = min;
this.max = max;
this.roundingPlace = roundingPlace;
@ -62,6 +66,7 @@ public class DoubleSetting extends Setting
public void mouseReleased(double mouseX, double mouseY, int button)
{
sliding = false;
ReflectionUtils.tryCallMethod(onValueChanged, new Object[0]);
}
}

View file

@ -1,5 +1,7 @@
package me.kawaiizenbo.moonlight.module.settings;
import java.lang.reflect.Method;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
@ -7,6 +9,7 @@ import net.minecraft.client.gui.DrawContext;
public class Setting
{
public String name;
public Method onValueChanged;
protected TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
public int height = 24;