broken shit
This commit is contained in:
		
							parent
							
								
									0edfc893ab
								
							
						
					
					
						commit
						5ccad6b10a
					
				
					 16 changed files with 149 additions and 24 deletions
				
			
		|  | @ -1 +1,8 @@ | |||
| # Moonlight Meadows Utility Mod for Minecraft 1.19.3 | ||||
| # Moonlight Meadows Utility Mod for Minecraft 1.20 | ||||
| 
 | ||||
| Please use this mod at your own risk   | ||||
| Requires Fabric API and Minecraft 1.20 | ||||
| 
 | ||||
| Default ClickGUI Key is Right Alt | ||||
| 
 | ||||
| Grab the latest build [here](https://nightly.link/kawaiizenbo/MoonlightMeadows/workflows/build/main/Artifacts.zip) | ||||
|  |  | |||
|  | @ -18,6 +18,6 @@ public abstract class KeyboardMixin { | |||
| 
 | ||||
| 	@Inject(method = "onKey", at = @At("HEAD"), cancellable = true) | ||||
|     public void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo info) { | ||||
|         if (key == GLFW.GLFW_KEY_RIGHT_SHIFT) MinecraftClient.getInstance().setScreen(ClickGUIScreen.INSTANCE); | ||||
|         if (key == GLFW.GLFW_KEY_RIGHT_ALT) MinecraftClient.getInstance().setScreen(ClickGUIScreen.INSTANCE); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,34 @@ | |||
| package me.kawaiizenbo.moonlight.mixin; | ||||
| 
 | ||||
| import java.util.Objects; | ||||
| import java.util.function.Consumer; | ||||
| 
 | ||||
| import org.spongepowered.asm.mixin.Final; | ||||
| import org.spongepowered.asm.mixin.Mixin; | ||||
| import org.spongepowered.asm.mixin.Shadow; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.util.ISimpleOption; | ||||
| import net.minecraft.client.MinecraftClient; | ||||
| import net.minecraft.client.option.SimpleOption; | ||||
| 
 | ||||
| @Mixin(SimpleOption.class) | ||||
| public class SimpleOptionMixin<T> implements ISimpleOption<T> | ||||
| { | ||||
| 	@Shadow T value; | ||||
| 	@Shadow @Final private Consumer<T> changeCallback; | ||||
| 	 | ||||
|     @Override | ||||
| 	public void setValueUnrestricted(T object)  | ||||
|     { | ||||
| 		if (!MinecraftClient.getInstance().isRunning())  | ||||
|         { | ||||
|             this.value = object; | ||||
|             return; | ||||
|         } | ||||
|         if (!Objects.equals(this.value, object))  | ||||
|         { | ||||
|             this.value = object; | ||||
|             this.changeCallback.accept(this.value); | ||||
|         } | ||||
| 	} | ||||
| } | ||||
|  | @ -2,6 +2,7 @@ package me.kawaiizenbo.moonlight.module.modules; | |||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.util.ISimpleOption; | ||||
| 
 | ||||
| public class Fullbright extends Module_  | ||||
| { | ||||
|  | @ -13,8 +14,7 @@ public class Fullbright extends Module_ | |||
|     @Override | ||||
|     public void onEnable() | ||||
|     { | ||||
|         // i dont know why but this makes it darker than 1.0 | ||||
|         mc.options.getGamma().setValue(100.0); | ||||
|         ((ISimpleOption<Double>)(Object)mc.options.getGamma()).setValueUnrestricted(100.0); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|  |  | |||
|  | @ -2,15 +2,28 @@ package me.kawaiizenbo.moonlight.module.modules; | |||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.Category; | ||||
| import me.kawaiizenbo.moonlight.module.Module_; | ||||
| import me.kawaiizenbo.moonlight.module.settings.ColorSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | ||||
| import me.kawaiizenbo.moonlight.ui.HUD; | ||||
| import me.kawaiizenbo.moonlight.util.ReflectionUtils; | ||||
| 
 | ||||
| public class HUDModule extends Module_  | ||||
| { | ||||
|     public ColorSetting color = new ColorSetting("Color", 0x55FFFF); | ||||
|     public DoubleSetting r = new DoubleSetting("Red", 0x55, 0, 255, 0, ReflectionUtils.tryGetMethod("updateHUD", getClass())); | ||||
|     public DoubleSetting g = new DoubleSetting("Green", 255, 0, 255, 0, ReflectionUtils.tryGetMethod("updateHUD", getClass())); | ||||
|     public DoubleSetting b = new DoubleSetting("Blue", 255, 0, 255, 0, ReflectionUtils.tryGetMethod("updateHUD", getClass())); | ||||
|     //public ColorSetting color = new ColorSetting("Color", 0x55FFFF, ReflectionUtils.tryGetMethod("updateHUD", getClass())); | ||||
|     public HUDModule() | ||||
|     { | ||||
|         super("HUD", "Enables or disables the Moonlight HUD.", Category.RENDER); | ||||
|         this.enabled = true; | ||||
|         settings.add(color); | ||||
|         settings.add(r); | ||||
|         settings.add(g); | ||||
|         settings.add(b); | ||||
|         //settings.add(color); | ||||
|     }     | ||||
| 
 | ||||
|     public static void updateHUD() | ||||
|     { | ||||
|         HUD.INSTANCE = new HUD(); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | |||
| 
 | ||||
| public class Step extends Module_ | ||||
| { | ||||
|     DoubleSetting stepHeight = new DoubleSetting("Height", 1, 1, 10, 0); | ||||
|     DoubleSetting stepHeight = new DoubleSetting("Height", 1, 1, 10, 0, null); | ||||
| 
 | ||||
|     public Step() | ||||
|     { | ||||
|  |  | |||
|  | @ -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]); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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]); | ||||
| 	} | ||||
|      | ||||
| } | ||||
|  |  | |||
|  | @ -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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,8 @@ | |||
| package me.kawaiizenbo.moonlight.ui; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.Moonlight; | ||||
| import me.kawaiizenbo.moonlight.module.ModuleManager; | ||||
| import me.kawaiizenbo.moonlight.module.modules.HUDModule; | ||||
| import me.kawaiizenbo.moonlight.util.ColorUtils; | ||||
| import me.kawaiizenbo.moonlight.util.MathUtils; | ||||
| 
 | ||||
|  | @ -14,6 +16,11 @@ public class HUD | |||
|     public static HUD INSTANCE = new HUD(); | ||||
| 	private MinecraftClient mc = MinecraftClient.getInstance(); | ||||
| 	TextRenderer textRenderer = mc.textRenderer; | ||||
|     public int hudColor = ColorUtils.rgbaToInt( | ||||
|         (int)((HUDModule)ModuleManager.INSTANCE.getModuleByName("HUD")).r.value, | ||||
|         (int)((HUDModule)ModuleManager.INSTANCE.getModuleByName("HUD")).g.value, | ||||
|         (int)((HUDModule)ModuleManager.INSTANCE.getModuleByName("HUD")).b.value, | ||||
|         255 ); | ||||
| 
 | ||||
|     public void renderHUD(DrawContext drawContext, int scaledWidth, int scaledHeight) | ||||
|     { | ||||
|  | @ -22,14 +29,14 @@ public class HUD | |||
| 
 | ||||
|         // draw stats | ||||
|         drawContext.drawTextWithShadow(textRenderer, Moonlight.clientTag + " " + Moonlight.versionTag, 2, 2, 16777215); | ||||
| 		drawContext.drawTextWithShadow(textRenderer, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], 2, 12, 0x55FFFF); | ||||
| 		drawContext.drawTextWithShadow(textRenderer, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), 2, 22, 0x55FFFF); | ||||
| 		drawContext.drawTextWithShadow(textRenderer, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), 2, scaledHeight - 20, 0x55FFFF); | ||||
| 		drawContext.drawTextWithShadow(textRenderer, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], 2, 12, hudColor); | ||||
| 		drawContext.drawTextWithShadow(textRenderer, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), 2, 22, hudColor); | ||||
| 		drawContext.drawTextWithShadow(textRenderer, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), 2, scaledHeight - 20, hudColor); | ||||
| 
 | ||||
|         // draw coordinates | ||||
|         drawContext.drawTextWithShadow(textRenderer, "X: " + ColorUtils.gray + MathUtils.round(mc.player.getX(), 1) +  | ||||
|             ColorUtils.reset + " Y: " + ColorUtils.gray + MathUtils.round(mc.player.getY(), 1) +  | ||||
|             ColorUtils.reset + " Z: " + ColorUtils.gray + MathUtils.round(mc.player.getZ(), 1), 2, scaledHeight - 10, 0x55FFFF); | ||||
|             ColorUtils.reset + " Z: " + ColorUtils.gray + MathUtils.round(mc.player.getZ(), 1), 2, scaledHeight - 10, hudColor); | ||||
|     } | ||||
| 
 | ||||
|     private double moveSpeed()  | ||||
|  |  | |||
|  | @ -27,4 +27,9 @@ public class ColorUtils | |||
|     public static String strikethrough = "\247m"; | ||||
|     public static String obfuscated = "\247k"; | ||||
| 	public static String reset = "\247r"; | ||||
| 
 | ||||
|     public static int rgbaToInt(int r, int g, int b, int a) | ||||
|     { | ||||
|         return ((a&0x0ff)<<24)|((r&0x0ff)<<16)|((g&0x0ff)<<8)|(b&0x0ff); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,6 @@ | |||
| package me.kawaiizenbo.moonlight.util; | ||||
| 
 | ||||
| public interface ISimpleOption<T> | ||||
| { | ||||
| 	public void setValueUnrestricted(T value); | ||||
| } | ||||
|  | @ -0,0 +1,35 @@ | |||
| package me.kawaiizenbo.moonlight.util; | ||||
| 
 | ||||
| import java.lang.reflect.Method; | ||||
| 
 | ||||
| public class ReflectionUtils  | ||||
| { | ||||
|     public static Method tryGetMethod(String methodName, Class<?> class1) | ||||
|     { | ||||
|         // safety be damned this is my own code i get to control when it crashes | ||||
|         try | ||||
|         { | ||||
|             return class1.getDeclaredMethod(methodName, new Class[1]); | ||||
|         } | ||||
|         catch (Exception e) | ||||
|         { | ||||
|             e.printStackTrace(); | ||||
|             return (Method)null; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static void tryCallMethod(Method method, Object... parameters) | ||||
|     { | ||||
|         // hope that shits static | ||||
|         try | ||||
|         { | ||||
|             method.invoke(null, parameters); | ||||
|         } | ||||
|         catch (Exception e) | ||||
|         { | ||||
|             // go fuck yourself | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
|          | ||||
|     } | ||||
| } | ||||
|  | @ -7,7 +7,7 @@ | |||
|   "description": "Utility mod with a focus on stability.", | ||||
|   "authors": [ | ||||
|     "KawaiiZenbo", | ||||
|     "BadGamesInc" | ||||
|     "BadGamesInc (re-used Hypnotic Code)" | ||||
|   ], | ||||
|   "contact": { | ||||
|     "homepage": "https://kawaiizenbo.me/", | ||||
|  |  | |||
|  | @ -12,7 +12,8 @@ | |||
|     "ChatInputSuggestorMixin", | ||||
|     "ClientConnectionMixin", | ||||
|     "LivingEntityMixin", | ||||
|     "KeyboardMixin" | ||||
|     "KeyboardMixin", | ||||
|     "SimpleOptionMixin" | ||||
|   ], | ||||
|   "injectors": { | ||||
|     "defaultRequire": 1 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 kawaiizenbo
						kawaiizenbo