h
This commit is contained in:
parent
3de1c7130a
commit
e5b783553b
10 changed files with 56 additions and 31 deletions
|
@ -33,6 +33,10 @@ dependencies {
|
|||
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/moonlight.accesswidener")
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ org.gradle.parallel=true
|
|||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.19.3
|
||||
yarn_mappings=1.19.3+build.5
|
||||
loader_version=0.14.14
|
||||
loader_version=0.14.17
|
||||
|
||||
# Mod Properties
|
||||
mod_version = dev
|
||||
|
|
|
@ -50,7 +50,6 @@ public abstract class ChatInputSuggestorMixin
|
|||
if (reader.canRead(length) && reader.getString().startsWith(prefix, reader.getCursor())) {
|
||||
reader.setCursor(reader.getCursor() + length);
|
||||
assert this.client.player != null;
|
||||
// Pretty much copy&paste from the refresh method
|
||||
CommandDispatcher<CommandSource> commandDispatcher = CommandManager.get().getDispatcher();
|
||||
if (this.parse == null) {
|
||||
this.parse = commandDispatcher.parse(reader, CommandManager.get().getCommandSource());
|
||||
|
|
|
@ -2,24 +2,15 @@ package me.kawaiizenbo.moonlight.module.modules;
|
|||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import me.kawaiizenbo.moonlight.module.settings.BooleanSetting;
|
||||
import me.kawaiizenbo.moonlight.module.settings.ColorSetting;
|
||||
|
||||
public class HUDModule extends Module_
|
||||
{
|
||||
public BooleanSetting enableLogo = new BooleanSetting("Logo", true);
|
||||
public BooleanSetting enableFPS = new BooleanSetting("FPS", true);
|
||||
public BooleanSetting enablePing = new BooleanSetting("Ping", true);
|
||||
public BooleanSetting enableSpeed = new BooleanSetting("Speed", true);
|
||||
public BooleanSetting enableCoordinates = new BooleanSetting("Coordinates", true);
|
||||
|
||||
public ColorSetting color = new ColorSetting("Color", 0x55FFFF);
|
||||
public HUDModule()
|
||||
{
|
||||
super("HUD", "Enables or disables the Moonlight HUD.", Category.RENDER);
|
||||
this.enabled = true;
|
||||
settings.add(enableLogo);
|
||||
settings.add(enableFPS);
|
||||
settings.add(enablePing);
|
||||
settings.add(enableSpeed);
|
||||
settings.add(enableCoordinates);
|
||||
settings.add(color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,41 @@
|
|||
package me.kawaiizenbo.moonlight.module.settings;
|
||||
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class ColorSetting extends Setting
|
||||
{
|
||||
public int value;
|
||||
public int r;
|
||||
public int g;
|
||||
public int b;
|
||||
|
||||
|
||||
public ColorSetting(String name, int value)
|
||||
{
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.height = 64;
|
||||
this.r = (value >> 16) & 0xFF;
|
||||
this.g = (value >> 8) & 0xFF;
|
||||
this.b = value & 0xFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int x, int y, int mouseX, int mouseY)
|
||||
{
|
||||
super.render(matrices, x, y, mouseX, mouseY);
|
||||
DrawableHelper.drawTextWithShadow(matrices, 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);
|
||||
DrawableHelper.fillGradient(matrices, x+100, y+2, x+112, y+62, redDisplayEndColor, redDisplayStartColor, 0);
|
||||
DrawableHelper.fillGradient(matrices, x+115, y+2, x+127, y+62, greenDisplayEndColor, greenDisplayStartColor, 0);
|
||||
DrawableHelper.fillGradient(matrices, x+130, y+2, x+142, y+62, blueDisplayEndColor, blueDisplayStartColor, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,14 @@ public class Setting
|
|||
{
|
||||
public String name;
|
||||
protected TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
public int height = 24;
|
||||
|
||||
int x = 0, y = 0;
|
||||
public void render(MatrixStack matrices, int x, int y, int mouseX, int mouseY)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
DrawableHelper.fill(matrices, x, y, x+192, y+24, hovered(mouseX, mouseY) ? 0xFF444444: 0xFF222222);
|
||||
DrawableHelper.fill(matrices, x, y, x+192, y+height, hovered(mouseX, mouseY) ? 0xFF444444: 0xFF222222);
|
||||
|
||||
}
|
||||
|
||||
|
@ -27,6 +28,6 @@ public class Setting
|
|||
|
||||
protected boolean hovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseX <= x + 192 && mouseY >= y && mouseY <= y + 24;
|
||||
return mouseX >= x && mouseX <= x + 192 && mouseY >= y && mouseY <= y + height;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
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;
|
||||
|
||||
|
@ -16,7 +14,6 @@ public class HUD
|
|||
public static HUD INSTANCE = new HUD();
|
||||
private MinecraftClient mc = MinecraftClient.getInstance();
|
||||
TextRenderer textRenderer = mc.textRenderer;
|
||||
HUDModule hm = (HUDModule)ModuleManager.INSTANCE.getModuleByName("HUD");
|
||||
|
||||
public void renderHUD(MatrixStack matrix, int scaledWidth, int scaledHeight)
|
||||
{
|
||||
|
@ -24,18 +21,13 @@ public class HUD
|
|||
if (mc.options.debugEnabled) return;
|
||||
|
||||
// draw stats
|
||||
if (hm.enableLogo.value)
|
||||
textRenderer.drawWithShadow(matrix, Moonlight.clientTag + " " + Moonlight.versionTag, 2, 2, 16777215);
|
||||
if (hm.enableFPS.value)
|
||||
textRenderer.drawWithShadow(matrix, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], 2, 12, 0x55FFFF);
|
||||
if (hm.enablePing.value)
|
||||
textRenderer.drawWithShadow(matrix, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), 2, 22, 0x55FFFF);
|
||||
|
||||
if (hm.enableSpeed.value)
|
||||
textRenderer.drawWithShadow(matrix, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), 2, scaledHeight - 20, 0x55FFFF);
|
||||
textRenderer.drawWithShadow(matrix, Moonlight.clientTag + " " + Moonlight.versionTag, 2, 2, 16777215);
|
||||
textRenderer.drawWithShadow(matrix, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], 2, 12, 0x55FFFF);
|
||||
textRenderer.drawWithShadow(matrix, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), 2, 22, 0x55FFFF);
|
||||
textRenderer.drawWithShadow(matrix, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), 2, scaledHeight - 20, 0x55FFFF);
|
||||
|
||||
if (hm.enableCoordinates.value)
|
||||
textRenderer.drawWithShadow(matrix, "X: " + ColorUtils.gray + MathUtils.round(mc.player.getX(), 1) +
|
||||
// draw coordinates
|
||||
textRenderer.drawWithShadow(matrix, "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);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class SettingsScreen extends Screen
|
|||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.render(matrices, (width/2)-96, yOffset, mouseX, mouseY);
|
||||
yOffset += 25;
|
||||
yOffset += setting.height + 1;
|
||||
}
|
||||
// add keybind setting here eventually
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"me.kawaiizenbo.moonlight.Moonlight"
|
||||
]
|
||||
},
|
||||
"accessWidener" : "moonlight.accesswidener",
|
||||
"mixins": [
|
||||
"moonlight.mixins.json"
|
||||
],
|
||||
|
|
2
src/main/resources/moonlight.accesswidener
Normal file
2
src/main/resources/moonlight.accesswidener
Normal file
|
@ -0,0 +1,2 @@
|
|||
accessWidener v1 named
|
||||
accessible method net/minecraft/client/gui/DrawableHelper fillGradient (Lnet/minecraft/client/util/math/MatrixStack;IIIIIII)V
|
Loading…
Add table
Reference in a new issue