clickgui, make hud toggleable
This commit is contained in:
parent
05ff377b5c
commit
411790540a
8 changed files with 173 additions and 19 deletions
|
@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
import me.kawaiizenbo.moonlight.ui.HUD;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
@ -19,7 +20,7 @@ public class InGameHudMixin {
|
|||
@Inject(at = @At("TAIL"), method = "render")
|
||||
public void onRender (MatrixStack matrices, float tickDelta, CallbackInfo info)
|
||||
{
|
||||
HUD.INSTANCE.renderHUD(matrices, scaledWidth, scaledHeight);
|
||||
if (ModuleManager.INSTANCE.getModuleByName("HUD").enabled) HUD.INSTANCE.renderHUD(matrices, scaledWidth, scaledHeight);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package me.kawaiizenbo.moonlight.mixin;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
public abstract class KeyboardMixin {
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
|
@ -11,28 +11,50 @@ public class ModuleManager
|
|||
|
||||
public ModuleManager()
|
||||
{
|
||||
registerModules(new Fly());
|
||||
registerModules(
|
||||
new Fly(),
|
||||
new NoFall(),
|
||||
new HUDModule()
|
||||
);
|
||||
}
|
||||
|
||||
public void registerModule(Module_ module) {
|
||||
public void registerModule(Module_ module)
|
||||
{
|
||||
modules.add(module);
|
||||
}
|
||||
|
||||
public void registerModules(Module_... modules) {
|
||||
public void registerModules(Module_... modules)
|
||||
{
|
||||
for (Module_ module : modules) {
|
||||
this.modules.add(module);
|
||||
}
|
||||
}
|
||||
|
||||
public Module_ getModuleByName(String moduleName) {
|
||||
for(Module_ mod : modules) {
|
||||
if ((mod.name.trim().equalsIgnoreCase(moduleName)) || (mod.toString().trim().equalsIgnoreCase(moduleName.trim()))) {
|
||||
return mod;
|
||||
public Module_ getModuleByName(String moduleName)
|
||||
{
|
||||
for(Module_ module : modules)
|
||||
{
|
||||
if ((module.name.trim().equalsIgnoreCase(moduleName)))
|
||||
{
|
||||
return module;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<Module_> getModulesByCategory(Category category)
|
||||
{
|
||||
ArrayList<Module_> returnedModules = new ArrayList<>();
|
||||
for(Module_ module : modules)
|
||||
{
|
||||
if (module.category == category)
|
||||
{
|
||||
returnedModules.add(module);
|
||||
}
|
||||
}
|
||||
return returnedModules;
|
||||
}
|
||||
|
||||
public ArrayList<Module_> getEnabledModules()
|
||||
{
|
||||
ArrayList<Module_> enabledModules = new ArrayList<>();
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
|
||||
public class HUDModule extends Module_
|
||||
{
|
||||
public HUDModule()
|
||||
{
|
||||
super("HUD", "Enables or disables the Moonlight HUD.", Category.RENDER);
|
||||
this.enabled = true;
|
||||
}
|
||||
}
|
|
@ -5,11 +5,11 @@ import net.minecraft.text.Text;
|
|||
|
||||
public class AltManagerScreen extends Screen
|
||||
{
|
||||
public static AltManagerScreen INSTANCE = new AltManagerScreen();
|
||||
|
||||
public static AltManagerScreen INSTANCE = new AltManagerScreen(null);
|
||||
protected AltManagerScreen(Text title)
|
||||
protected AltManagerScreen()
|
||||
{
|
||||
super(title);
|
||||
super(Text.literal("Alt Manager"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,65 @@
|
|||
package me.kawaiizenbo.moonlight.ui.clickgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class ClickGUIScreen extends Screen
|
||||
public class ClickGUIScreen extends Screen
|
||||
{
|
||||
public static ClickGUIScreen INSTANCE = new ClickGUIScreen(null);
|
||||
protected ClickGUIScreen(Text title)
|
||||
{
|
||||
super(title);
|
||||
}
|
||||
|
||||
public static ClickGUIScreen INSTANCE = new ClickGUIScreen();
|
||||
public static ArrayList<ModuleButton> moduleButtons;
|
||||
|
||||
public ClickGUIScreen()
|
||||
{
|
||||
super(Text.literal("ClickGUI"));
|
||||
moduleButtons = new ArrayList<>();
|
||||
int yOffset;
|
||||
for (Category category : Category.values())
|
||||
{
|
||||
yOffset = 25;
|
||||
for (Module_ module : ModuleManager.INSTANCE.getModulesByCategory(category))
|
||||
{
|
||||
moduleButtons.add(new ModuleButton(module, 9+(module.category.ordinal()*65), yOffset));
|
||||
yOffset += 10;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground(matrices);
|
||||
int categoryLabelXOffset = 10;
|
||||
for (Category category : Category.values())
|
||||
{
|
||||
textRenderer.draw(matrices, category.name, categoryLabelXOffset, 10, 0xFFFFFF);
|
||||
categoryLabelXOffset += 65;
|
||||
}
|
||||
for (ModuleButton moduleButton : moduleButtons)
|
||||
{
|
||||
moduleButton.render(matrices, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
for (ModuleButton modButton : moduleButtons)
|
||||
{
|
||||
modButton.mouseClicked((int) mouseX, (int) mouseY, button);
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPause()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package me.kawaiizenbo.moonlight.ui.clickgui;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
public class ModuleButton
|
||||
{
|
||||
public Module_ module;
|
||||
public int x, y, width, height = 0;
|
||||
private MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public ModuleButton(Module_ module, int x, int y)
|
||||
{
|
||||
this.module = module;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 60;
|
||||
this.height = 10;
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY)
|
||||
{
|
||||
TextRenderer textRenderer = mc.textRenderer;
|
||||
DrawableHelper.fill(matrices, x, y, x + width, y + height, hovered(mouseX, mouseY) ? 0xFF333333 : 0xFF222222);
|
||||
textRenderer.draw(matrices, module.name, x+1, y+1, module.enabled ? 0x55FFFF : 0xFFFFFF);
|
||||
}
|
||||
|
||||
public boolean hovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int button)
|
||||
{
|
||||
if (hovered(mouseX, mouseY))
|
||||
{
|
||||
module.toggle();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,8 @@
|
|||
"InGameHUDMixin",
|
||||
"ChatInputSuggestorMixin",
|
||||
"ClientConnectionMixin",
|
||||
"LivingEntityMixin"
|
||||
"LivingEntityMixin",
|
||||
"KeyboardMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Add table
Reference in a new issue