This commit is contained in:
kawaiizenbo 2023-10-10 22:14:11 -07:00
parent 48547a2c66
commit dc1e189d38
25 changed files with 259 additions and 157 deletions

View file

@ -2,6 +2,7 @@ package me.kawaiizenbo.moonlight;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -13,16 +14,17 @@ import com.google.gson.Gson;
import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.ModuleManager; import me.kawaiizenbo.moonlight.module.ModuleManager;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; import me.kawaiizenbo.moonlight.module.settings.BooleanSetting;
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
import me.kawaiizenbo.moonlight.module.settings.KeycodeSetting;
import me.kawaiizenbo.moonlight.module.settings.Setting; import me.kawaiizenbo.moonlight.module.settings.Setting;
import me.kawaiizenbo.moonlight.module.settings.StringSetting;
import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen; import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
public class Config public class Config
{ {
public static final Logger LOGGER = LoggerFactory.getLogger("mcfg");
MinecraftClient mc = MinecraftClient.getInstance(); MinecraftClient mc = MinecraftClient.getInstance();
public File configDir = new File(mc.runDirectory.getPath() + "/moonlight"); public File configDir = new File(mc.runDirectory.getPath() + "/moonlight");
public File configFile = new File(configDir, "config.json"); public File configFile = new File(configDir, "config.json");
@ -43,13 +45,14 @@ public class Config
{ {
ModuleManager.INSTANCE = new ModuleManager(); ModuleManager.INSTANCE = new ModuleManager();
Map<String, Object> mi = new HashMap<>(); Map<String, Object> mi = new HashMap<>();
for (Module_ m : ModuleManager.INSTANCE.modules) for (Module m : ModuleManager.INSTANCE.modules)
{ {
Map<String, Object> mo = new HashMap<>(); Map<String, Object> mo = new HashMap<>();
mo.put("enabled", m.enabled); mo.put("enabled", m.enabled);
Map<String, Object> ms = new HashMap<>(); Map<String, Object> ms = new HashMap<>();
for (Setting s : m.settings) for (Setting s : m.settings)
{ {
// sometimes i wish i were a nymphet instead of a massive nerd
if (s instanceof BooleanSetting) if (s instanceof BooleanSetting)
{ {
ms.put(s.name, ((BooleanSetting)s).value); ms.put(s.name, ((BooleanSetting)s).value);
@ -57,6 +60,14 @@ public class Config
else if (s instanceof DoubleSetting) else if (s instanceof DoubleSetting)
{ {
ms.put(s.name, ((DoubleSetting)s).value); ms.put(s.name, ((DoubleSetting)s).value);
}
if (s instanceof StringSetting)
{
ms.put(s.name, ((StringSetting)s).value);
}
else if (s instanceof KeycodeSetting)
{
ms.put(s.name, ((KeycodeSetting)s).value);
} }
} }
mo.put("settings", ms); mo.put("settings", ms);
@ -84,7 +95,7 @@ public class Config
ClickGUIScreen.INSTANCE = new ClickGUIScreen(); ClickGUIScreen.INSTANCE = new ClickGUIScreen();
} }
public void load() public void load() throws IOException
{ {
try try
{ {
@ -93,7 +104,7 @@ public class Config
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); throw new IOException("Failed to load config file.");
} }
} }

View file

@ -4,14 +4,16 @@ import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import me.kawaiizenbo.moonlight.module.ModuleManager; import me.kawaiizenbo.moonlight.module.ModuleManager;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; import me.kawaiizenbo.moonlight.module.settings.BooleanSetting;
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
import me.kawaiizenbo.moonlight.module.settings.KeycodeSetting;
import me.kawaiizenbo.moonlight.module.settings.Setting; import me.kawaiizenbo.moonlight.module.settings.Setting;
import me.kawaiizenbo.moonlight.module.settings.StringSetting; import me.kawaiizenbo.moonlight.module.settings.StringSetting;
import me.kawaiizenbo.moonlight.ui.clickgui.CategoryPane; import me.kawaiizenbo.moonlight.ui.clickgui.CategoryPane;
@ -37,44 +39,53 @@ public class Moonlight implements ModInitializer
public void loadConfig() public void loadConfig()
{ {
LOGGER.info("Loading config..."); try
if (CONFIG.doesConfigExist())
{ {
LOGGER.info("Loading config...");
CONFIG.load();
for (Module m : ModuleManager.INSTANCE.modules)
{
m.enabled = (boolean)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("enabled");
if (m.enabled)
{
//m.onEnable();
// this doesnt work, will probably need to mixin to client server connection or something
}
for (Setting s : m.settings)
{
if (s instanceof BooleanSetting)
{
((BooleanSetting)s).value = (boolean)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name);
}
else if (s instanceof DoubleSetting)
{
((DoubleSetting)s).value = (Double)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name);
}
else if (s instanceof StringSetting)
{
((StringSetting)s).value = (String)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name);
}
else if (s instanceof KeycodeSetting)
{
((KeycodeSetting)s).value = ((Double)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name)).intValue();
}
}
}
}
catch(Exception e)
{
LOGGER.warn("Config Error: " + e.getMessage());
LOGGER.info("Loading default config...");
CONFIG.loadDefaultConfig(); CONFIG.loadDefaultConfig();
CONFIG.save(); CONFIG.save();
} }
CONFIG.load();
for (Module_ m : ModuleManager.INSTANCE.modules)
{
m.enabled = (boolean)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("enabled");
if (m.enabled)
{
//m.onEnable();
/// brocken :(
}
for (Setting s : m.settings)
{
if (s instanceof BooleanSetting)
{
((BooleanSetting)s).value = (boolean)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name);
}
else if (s instanceof DoubleSetting)
{
((DoubleSetting)s).value = (Double)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name);
}
else if (s instanceof StringSetting)
{
((StringSetting)s).value = (String)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name);
}
}
}
} }
public void saveConfig() public void saveConfig()
{ {
LOGGER.info("Saving config..."); LOGGER.info("Saving config...");
Map<String, Object> mi = new HashMap<>(); Map<String, Object> mi = new HashMap<>();
for (Module_ m : ModuleManager.INSTANCE.modules) for (Module m : ModuleManager.INSTANCE.modules)
{ {
Map<String, Object> mo = new HashMap<>(); Map<String, Object> mo = new HashMap<>();
mo.put("enabled", m.enabled); mo.put("enabled", m.enabled);
@ -88,6 +99,14 @@ public class Moonlight implements ModInitializer
else if (s instanceof DoubleSetting) else if (s instanceof DoubleSetting)
{ {
ms.put(s.name, ((DoubleSetting)s).value); ms.put(s.name, ((DoubleSetting)s).value);
}
if (s instanceof StringSetting)
{
ms.put(s.name, ((StringSetting)s).value);
}
else if (s instanceof KeycodeSetting)
{
ms.put(s.name, ((KeycodeSetting)s).value);
} }
} }
mo.put("settings", ms); mo.put("settings", ms);

View file

@ -29,6 +29,7 @@ public class CommandManager
add(new Help()); add(new Help());
add(new Toggle()); add(new Toggle());
add(new Teleport()); add(new Teleport());
add(new SettingCommand());
commands.sort(Comparator.comparing(Command::getName)); commands.sort(Comparator.comparing(Command::getName));
} }

View file

@ -1,63 +0,0 @@
package me.kawaiizenbo.moonlight.command;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import me.kawaiizenbo.moonlight.module.Module_;
import me.kawaiizenbo.moonlight.module.ModuleManager;
import net.minecraft.command.CommandSource;
import net.minecraft.text.Text;
public class ModuleArgumentType implements ArgumentType<Module_>
{
private static final Collection<String> EXAMPLES = ModuleManager.INSTANCE.modules
.stream()
.limit(3)
.map(module -> module.name)
.collect(Collectors.toList());
private static final DynamicCommandExceptionType NO_SUCH_MODULE = new DynamicCommandExceptionType(o ->
Text.literal("Module with name " + o + " doesn't exist."));
public static ModuleArgumentType module()
{
return new ModuleArgumentType();
}
public static Module_ getModule(final CommandContext<?> context, final String name)
{
return context.getArgument(name, Module_.class);
}
@Override
public Module_ parse(StringReader reader) throws CommandSyntaxException
{
String argument = reader.readString();
Module_ module = ModuleManager.INSTANCE.getModuleByName(argument);
if (module == null) throw NO_SUCH_MODULE.create(argument);
return module;
}
@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder)
{
return CommandSource.suggestMatching(ModuleManager.INSTANCE.modules.stream().map(module -> module.name), builder);
}
@Override
public Collection<String> getExamples()
{
return EXAMPLES;
}
}

View file

@ -0,0 +1,72 @@
package me.kawaiizenbo.moonlight.command.commands;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.kawaiizenbo.moonlight.command.Command;
import me.kawaiizenbo.moonlight.module.ModuleManager;
import me.kawaiizenbo.moonlight.module.settings.BooleanSetting;
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
import me.kawaiizenbo.moonlight.module.settings.KeycodeSetting;
import me.kawaiizenbo.moonlight.module.settings.Setting;
import me.kawaiizenbo.moonlight.module.settings.StringSetting;
import me.kawaiizenbo.moonlight.util.ChatUtils;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import me.kawaiizenbo.moonlight.module.Module;
import net.minecraft.command.CommandSource;
public class SettingCommand extends Command
{
public SettingCommand()
{
super("setting", "Change a setting of a module.");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder)
{
builder
.then(argument("module", StringArgumentType.string())
.then(argument("setting", StringArgumentType.string())
.then(argument("value", StringArgumentType.string())
.executes(context ->
{
String m = context.getArgument("module", String.class);
String s = context.getArgument("setting", String.class);
String v = context.getArgument("value", String.class);
Module module = ModuleManager.INSTANCE.getModuleByName(m);
if (module == null)
{
ChatUtils.sendMsg(ColorUtils.red + "Invalid Module Name");
return 0;
}
Setting setting = module.getSettingByName(s);
if (setting == null)
{
ChatUtils.sendMsg(ColorUtils.red + "Invalid Setting Name");
return 0;
}
// you can break this really easily and i dont feel like fixing it :3 have fun
if (setting instanceof BooleanSetting)
{
((BooleanSetting)setting).value = Boolean.parseBoolean(v);
}
else if (setting instanceof DoubleSetting)
{
((DoubleSetting)setting).value = Double.parseDouble(v);
}
if (setting instanceof StringSetting)
{
((StringSetting)setting).value = v;
}
else if (setting instanceof KeycodeSetting)
{
((KeycodeSetting)setting).value = Integer.parseInt(v);
}
return SINGLE_SUCCESS;
}))));
}
}

View file

@ -1,11 +1,11 @@
package me.kawaiizenbo.moonlight.command.commands; package me.kawaiizenbo.moonlight.command.commands;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.kawaiizenbo.moonlight.command.Command; import me.kawaiizenbo.moonlight.command.Command;
import me.kawaiizenbo.moonlight.command.ModuleArgumentType; import me.kawaiizenbo.moonlight.module.ModuleManager;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
public class Toggle extends Command public class Toggle extends Command
@ -19,13 +19,12 @@ public class Toggle extends Command
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) public void build(LiteralArgumentBuilder<CommandSource> builder)
{ {
builder.then(argument("module", new ModuleArgumentType()).executes(context -> builder.then(argument("module", StringArgumentType.string())
.executes(context ->
{ {
ClientPlayerEntity player = mc.player; String m = context.getArgument("module", String.class);
assert player != null; Module module = ModuleManager.INSTANCE.getModuleByName(m);
module.toggle();
Module_ m = context.getArgument("module", Module_.class);
m.toggle();
return SINGLE_SUCCESS; return SINGLE_SUCCESS;
})); }));

View file

@ -19,7 +19,6 @@ public class ClientConnectionMixin
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true) @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true)
public void send(Packet<?> packet, CallbackInfo ci) public void send(Packet<?> packet, CallbackInfo ci)
{ {
// Call commands if the prefix is sent
if(packet instanceof ChatMessageC2SPacket && ((ChatMessageC2SPacket) packet).chatMessage().startsWith(CommandManager.get().getPrefix())) if(packet instanceof ChatMessageC2SPacket && ((ChatMessageC2SPacket) packet).chatMessage().startsWith(CommandManager.get().getPrefix()))
{ {
try try

View file

@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import me.kawaiizenbo.moonlight.module.ModuleManager; import me.kawaiizenbo.moonlight.module.ModuleManager;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.MovementType; import net.minecraft.entity.MovementType;
@ -18,7 +18,7 @@ public class ClientPlayerEntityMixin
@Inject(method = "move", at = @At(value = "TAIL"), cancellable = true) @Inject(method = "move", at = @At(value = "TAIL"), cancellable = true)
public void onMove(MovementType type, Vec3d movement, CallbackInfo ci) public void onMove(MovementType type, Vec3d movement, CallbackInfo ci)
{ {
for (Module_ m : ModuleManager.INSTANCE.getEnabledModules()) for (Module m : ModuleManager.INSTANCE.getEnabledModules())
{ {
m.onMotion(type, movement); m.onMotion(type, movement);
} }
@ -27,7 +27,7 @@ public class ClientPlayerEntityMixin
@Inject(method = "tick", at = @At(value = "HEAD"), cancellable = true) @Inject(method = "tick", at = @At(value = "HEAD"), cancellable = true)
public void onTick(CallbackInfo ci) public void onTick(CallbackInfo ci)
{ {
for (Module_ m : ModuleManager.INSTANCE.getEnabledModules()) for (Module m : ModuleManager.INSTANCE.getEnabledModules())
{ {
if (MinecraftClient.getInstance().player != null) m.tick(); if (MinecraftClient.getInstance().player != null) m.tick();
} }
@ -36,7 +36,7 @@ public class ClientPlayerEntityMixin
@Inject(method = "init", at = @At(value = "TAIL"), cancellable = true) @Inject(method = "init", at = @At(value = "TAIL"), cancellable = true)
public void onInit(CallbackInfo ci) public void onInit(CallbackInfo ci)
{ {
for (Module_ m : ModuleManager.INSTANCE.getEnabledModules()) for (Module m : ModuleManager.INSTANCE.getEnabledModules())
{ {
m.onEnable(); m.onEnable();
} }

View file

@ -8,6 +8,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.ModuleManager;
import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen; import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen;
import net.minecraft.client.Keyboard; import net.minecraft.client.Keyboard;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
@ -17,7 +19,18 @@ public abstract class KeyboardMixin {
@Shadow @Final private MinecraftClient client; @Shadow @Final private MinecraftClient client;
@Inject(method = "onKey", at = @At("HEAD"), cancellable = true) @Inject(method = "onKey", at = @At("HEAD"), cancellable = true)
public void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo info) { public void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo info)
{
System.out.println("Keyboard event occured: " + java.awt.event.KeyEvent.getKeyText(key) + " (keycode "+key+")");
if (key == GLFW.GLFW_KEY_RIGHT_ALT) MinecraftClient.getInstance().setScreen(ClickGUIScreen.INSTANCE); if (key == GLFW.GLFW_KEY_RIGHT_ALT) MinecraftClient.getInstance().setScreen(ClickGUIScreen.INSTANCE);
for (Module m : ModuleManager.INSTANCE.modules)
{
System.out.println("checking against module:" + m.name);
if (key == m.keybind.value)
{
System.out.println("yup, we gotem :3");
m.toggle();
}
}
} }
} }

View file

@ -10,7 +10,7 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.MovementType; import net.minecraft.entity.MovementType;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
public abstract class Module_ public abstract class Module
{ {
protected static MinecraftClient mc = MinecraftClient.getInstance(); protected static MinecraftClient mc = MinecraftClient.getInstance();
public String name; public String name;
@ -22,7 +22,7 @@ public abstract class Module_
public BooleanSetting showInModulesList = new BooleanSetting("Show in Modules List", true); public BooleanSetting showInModulesList = new BooleanSetting("Show in Modules List", true);
public KeycodeSetting keybind = new KeycodeSetting("Keybind", 0); public KeycodeSetting keybind = new KeycodeSetting("Keybind", 0);
public Module_(String name, String description, Category category) public Module(String name, String description, Category category)
{ {
this.name = name; this.name = name;
this.description = description; this.description = description;
@ -46,4 +46,24 @@ public abstract class Module_
onDisable(); onDisable();
} }
} }
public Setting getSettingByName(String settingName)
{
for(Setting setting : settings)
{
if ((setting.name.trim().equalsIgnoreCase(settingName)))
{
return setting;
}
}
return null;
}
protected void addSettings(Setting... settings)
{
for(Setting setting : settings)
{
this.settings.add(setting);
}
}
} }

View file

@ -7,7 +7,7 @@ import me.kawaiizenbo.moonlight.module.modules.*;
public class ModuleManager public class ModuleManager
{ {
public static ModuleManager INSTANCE = new ModuleManager(); public static ModuleManager INSTANCE = new ModuleManager();
public ArrayList<Module_> modules = new ArrayList<>(); public ArrayList<Module> modules = new ArrayList<>();
public ModuleManager() public ModuleManager()
{ {
@ -18,25 +18,21 @@ public class ModuleManager
new Step(), new Step(),
new Fullbright(), new Fullbright(),
new Speed(), new Speed(),
new ModulesList() new ModulesList(),
new TestModule()
); );
} }
public void registerModule(Module_ module)
{
modules.add(module);
}
public void registerModules(Module_... modules) private void registerModules(Module... modules)
{ {
for (Module_ module : modules) { for (Module module : modules) {
this.modules.add(module); this.modules.add(module);
} }
} }
public Module_ getModuleByName(String moduleName) public Module getModuleByName(String moduleName)
{ {
for(Module_ module : modules) for(Module module : modules)
{ {
if ((module.name.trim().equalsIgnoreCase(moduleName))) if ((module.name.trim().equalsIgnoreCase(moduleName)))
{ {
@ -46,10 +42,10 @@ public class ModuleManager
return null; return null;
} }
public ArrayList<Module_> getModulesByCategory(Category category) public ArrayList<Module> getModulesByCategory(Category category)
{ {
ArrayList<Module_> returnedModules = new ArrayList<>(); ArrayList<Module> returnedModules = new ArrayList<>();
for(Module_ module : modules) for(Module module : modules)
{ {
if (module.category == category) if (module.category == category)
{ {
@ -59,10 +55,10 @@ public class ModuleManager
return returnedModules; return returnedModules;
} }
public ArrayList<Module_> getEnabledModules() public ArrayList<Module> getEnabledModules()
{ {
ArrayList<Module_> enabledModules = new ArrayList<>(); ArrayList<Module> enabledModules = new ArrayList<>();
for (Module_ module : modules) for (Module module : modules)
{ {
if (!module.enabled) if (!module.enabled)
continue; continue;

View file

@ -1,9 +1,9 @@
package me.kawaiizenbo.moonlight.module.modules; package me.kawaiizenbo.moonlight.module.modules;
import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
public class Fly extends Module_ public class Fly extends Module
{ {
public Fly() public Fly()

View file

@ -1,10 +1,10 @@
package me.kawaiizenbo.moonlight.module.modules; package me.kawaiizenbo.moonlight.module.modules;
import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.util.ISimpleOption; import me.kawaiizenbo.moonlight.util.ISimpleOption;
public class Fullbright extends Module_ public class Fullbright extends Module
{ {
public Fullbright() public Fullbright()
{ {

View file

@ -2,13 +2,13 @@ package me.kawaiizenbo.moonlight.module.modules;
import me.kawaiizenbo.moonlight.Moonlight; import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; import me.kawaiizenbo.moonlight.module.settings.BooleanSetting;
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
import me.kawaiizenbo.moonlight.ui.HUDOverlay; import me.kawaiizenbo.moonlight.ui.HUDOverlay;
import me.kawaiizenbo.moonlight.util.ColorUtils; import me.kawaiizenbo.moonlight.util.ColorUtils;
public class HUDModule extends Module_ public class HUDModule extends Module
{ {
public BooleanSetting clientTag = new BooleanSetting("Client Tag", true); public BooleanSetting clientTag = new BooleanSetting("Client Tag", true);
public DoubleSetting r = new DoubleSetting("Red", 0x55, 0, 255, 0); public DoubleSetting r = new DoubleSetting("Red", 0x55, 0, 255, 0);

View file

@ -1,9 +1,9 @@
package me.kawaiizenbo.moonlight.module.modules; package me.kawaiizenbo.moonlight.module.modules;
import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
public class ModulesList extends Module_ public class ModulesList extends Module
{ {
public ModulesList() public ModulesList()
{ {

View file

@ -1,10 +1,10 @@
package me.kawaiizenbo.moonlight.module.modules; package me.kawaiizenbo.moonlight.module.modules;
import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
public class NoFall extends Module_ public class NoFall extends Module
{ {
public NoFall() public NoFall()
{ {

View file

@ -1,12 +1,12 @@
package me.kawaiizenbo.moonlight.module.modules; package me.kawaiizenbo.moonlight.module.modules;
import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
import net.minecraft.entity.MovementType; import net.minecraft.entity.MovementType;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
public class Speed extends Module_ public class Speed extends Module
{ {
DoubleSetting speed = new DoubleSetting("Speed", 2, 0.1, 10, 1); DoubleSetting speed = new DoubleSetting("Speed", 2, 0.1, 10, 1);
public Speed() public Speed()
@ -17,6 +17,7 @@ public class Speed extends Module_
@Override @Override
public void onMotion(MovementType type, Vec3d movement) public void onMotion(MovementType type, Vec3d movement)
{ {
// ???
mc.player.addVelocity(movement); mc.player.addVelocity(movement);
} }

View file

@ -1,10 +1,10 @@
package me.kawaiizenbo.moonlight.module.modules; package me.kawaiizenbo.moonlight.module.modules;
import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
public class Step extends Module_ public class Step extends Module
{ {
DoubleSetting stepHeight = new DoubleSetting("Height", 1, 1, 10, 0); DoubleSetting stepHeight = new DoubleSetting("Height", 1, 1, 10, 0);

View file

@ -0,0 +1,20 @@
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.DoubleSetting;
import me.kawaiizenbo.moonlight.module.settings.StringSetting;
public class TestModule extends Module
{
public BooleanSetting bs = new BooleanSetting("BooleanSetting", false);
public DoubleSetting ds = new DoubleSetting("DoubleSetting", 1, 0, 10, 10);
public StringSetting ss = new StringSetting("StringSetting", "string");
public TestModule()
{
super("Test Module", "Used for testing module features.", Category.WORLD);
addSettings(bs, ds, ss);
}
}

View file

@ -1,5 +1,9 @@
package me.kawaiizenbo.moonlight.module.settings; package me.kawaiizenbo.moonlight.module.settings;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
public class StringSetting extends Setting public class StringSetting extends Setting
{ {
public String value; public String value;
@ -9,4 +13,14 @@ public class StringSetting extends Setting
this.name = name; this.name = name;
this.value = value; this.value = value;
} }
@Override
public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer)
{
super.render(drawContext, x, y, mouseX, mouseY, textRenderer);
drawContext.drawTextWithShadow(textRenderer, Text.literal(name), x+2, y+4, 0xFFFFFF);
int twidth = textRenderer.getWidth(value);
drawContext.drawTextWithShadow(textRenderer, value, x+190-twidth, y+4, 0xFFFFFF);
drawContext.drawTextWithShadow(textRenderer, "WIP, please use the .setting command", x+2, y+14, 0xFFFFFF);
}
} }

View file

@ -4,7 +4,7 @@ import java.util.ArrayList;
import me.kawaiizenbo.moonlight.Moonlight; import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.module.ModuleManager; import me.kawaiizenbo.moonlight.module.ModuleManager;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
@ -13,7 +13,7 @@ public class ModulesListOverlay
{ {
public static ModulesListOverlay INSTANCE = new ModulesListOverlay(); public static ModulesListOverlay INSTANCE = new ModulesListOverlay();
private MinecraftClient mc = MinecraftClient.getInstance(); private MinecraftClient mc = MinecraftClient.getInstance();
private ArrayList<Module_> enabledModules = ModuleManager.INSTANCE.getEnabledModules(); private ArrayList<Module> enabledModules = ModuleManager.INSTANCE.getEnabledModules();
public void render(DrawContext drawContext, int scaledWidth, int scaledHeight) public void render(DrawContext drawContext, int scaledWidth, int scaledHeight)
{ {
@ -21,7 +21,7 @@ public class ModulesListOverlay
if (mc.getDebugHud().shouldShowDebugHud()) return; if (mc.getDebugHud().shouldShowDebugHud()) return;
int yOffset = 0; int yOffset = 0;
for (Module_ m : enabledModules) for (Module m : enabledModules)
{ {
if (!m.showInModulesList.value) continue; if (!m.showInModulesList.value) continue;
int nameWidth = mc.textRenderer.getWidth(m.name); int nameWidth = mc.textRenderer.getWidth(m.name);

View file

@ -4,7 +4,7 @@ import java.util.ArrayList;
import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.ModuleManager; import me.kawaiizenbo.moonlight.module.ModuleManager;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
@ -24,7 +24,7 @@ public class CategoryPane
this.y = initialY; this.y = initialY;
this.collapsed = collapsed; this.collapsed = collapsed;
moduleButtons = new ArrayList<ModuleButton>(); moduleButtons = new ArrayList<ModuleButton>();
for (Module_ m : ModuleManager.INSTANCE.getModulesByCategory(category)) for (Module m : ModuleManager.INSTANCE.getModulesByCategory(category))
{ {
moduleButtons.add(new ModuleButton(m)); moduleButtons.add(new ModuleButton(m));
} }

View file

@ -17,7 +17,7 @@ public class KeybindScreen extends Screen
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
{ {
this.renderBackground(drawContext, mouseX, mouseY, delta); this.renderBackground(drawContext, mouseX, mouseY, delta);
drawContext.drawCenteredTextWithShadow(textRenderer, "Press any key", width/2, height/2, 0xFFFFFFFF); drawContext.drawCenteredTextWithShadow(textRenderer, "Press any key (may not work, use .setting instead)", width/2, height/2, 0xFFFFFFFF);
} }
@Override @Override

View file

@ -1,17 +1,17 @@
package me.kawaiizenbo.moonlight.ui.clickgui; package me.kawaiizenbo.moonlight.ui.clickgui;
import me.kawaiizenbo.moonlight.Moonlight; import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
public class ModuleButton public class ModuleButton
{ {
public Module_ module; public Module module;
public int x, y, width, height = 0; public int x, y, width, height = 0;
public ModuleButton(Module_ module) public ModuleButton(Module module)
{ {
this.module = module; this.module = module;
this.width = 92; this.width = 92;

View file

@ -1,6 +1,6 @@
package me.kawaiizenbo.moonlight.ui.clickgui; package me.kawaiizenbo.moonlight.ui.clickgui;
import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.settings.Setting; import me.kawaiizenbo.moonlight.module.settings.Setting;
import me.kawaiizenbo.moonlight.ui.TextButton; import me.kawaiizenbo.moonlight.ui.TextButton;
import me.kawaiizenbo.moonlight.util.ColorUtils; import me.kawaiizenbo.moonlight.util.ColorUtils;
@ -10,13 +10,13 @@ import net.minecraft.text.Text;
public class SettingsScreen extends Screen public class SettingsScreen extends Screen
{ {
private Module_ module; private Module module;
private TextButton backButton; private TextButton backButton;
boolean dragging = false; boolean dragging = false;
int startX, startY, x = 4, y = 4, windowWidth = 224, windowHeight = 192; int startX, startY, x = 4, y = 4, windowWidth = 224, windowHeight = 192;
public SettingsScreen(Module_ module) public SettingsScreen(Module module)
{ {
super(Text.literal("Settings")); super(Text.literal("Settings"));
this.module = module; this.module = module;