Compare commits
55 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
995f452c2f | ||
![]() |
faf56e1e16 | ||
![]() |
72ec2869b8 | ||
![]() |
75c83f0ca7 | ||
![]() |
8abcd7341e | ||
![]() |
2e01a65ab4 | ||
![]() |
8f9a6005f5 | ||
![]() |
1b0729658d | ||
![]() |
fd96ca5d42 | ||
![]() |
bd5573c48f | ||
![]() |
854ce7201c | ||
![]() |
ccbb4c00ce | ||
![]() |
a055d56084 | ||
![]() |
206d076fbb | ||
![]() |
b8bb14081e | ||
![]() |
e5d1d3ef73 | ||
![]() |
90347f7476 | ||
![]() |
8f6646b7e0 | ||
![]() |
31ecdd4f04 | ||
![]() |
9ab102a648 | ||
![]() |
a3e7e885ac | ||
![]() |
00e91b98aa | ||
![]() |
253ee1d5be | ||
![]() |
92a2db9d89 | ||
![]() |
42eef68a66 | ||
![]() |
eb50de42e0 | ||
![]() |
507ed6b7e5 | ||
![]() |
6cd03fab06 | ||
![]() |
69b444c3c2 | ||
![]() |
c68631010d | ||
![]() |
08031c32ba | ||
![]() |
b84aac97b2 | ||
![]() |
02305cf7cc | ||
![]() |
5c2a78474a | ||
![]() |
3ad5af7ea7 | ||
![]() |
4b1e0b4fa9 | ||
![]() |
72eb688172 | ||
![]() |
430ff443a6 | ||
![]() |
8fc80a75b8 | ||
![]() |
d70d0dc0d0 | ||
![]() |
dc1e189d38 | ||
![]() |
48547a2c66 | ||
![]() |
ce8dd2ebed | ||
![]() |
0982c30299 | ||
![]() |
a18cb2a137 | ||
![]() |
6e584de0e6 | ||
![]() |
b58eedfb9c | ||
![]() |
2a89f212e5 | ||
![]() |
26756e8c86 | ||
![]() |
f95fd5d587 | ||
![]() |
94be9291bf | ||
![]() |
5ccad6b10a | ||
![]() |
0edfc893ab | ||
![]() |
f41e477e28 | ||
![]() |
6e7d77dea3 |
14
.github/workflows/build.yml
vendored
|
@ -1,8 +1,3 @@
|
|||
# Automatically build the project and run any configured tests for every push
|
||||
# and submitted pull request. This can help catch issues that only occur on
|
||||
# certain platforms or Java versions, and provides a first line of defence
|
||||
# against bad commits.
|
||||
|
||||
name: build
|
||||
on: [pull_request, push]
|
||||
|
||||
|
@ -10,12 +5,11 @@ jobs:
|
|||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
# Use these Java versions
|
||||
java: [
|
||||
17, # Current Java LTS & minimum supported by Minecraft
|
||||
21, # java version used since 1.20.5
|
||||
]
|
||||
# and run on both Linux and Windows
|
||||
os: [ubuntu-22.04, windows-2022]
|
||||
# only linux
|
||||
os: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: checkout repository
|
||||
|
@ -28,12 +22,10 @@ jobs:
|
|||
java-version: ${{ matrix.java }}
|
||||
distribution: 'microsoft'
|
||||
- name: make gradle wrapper executable
|
||||
if: ${{ runner.os != 'Windows' }}
|
||||
run: chmod +x ./gradlew
|
||||
- name: build
|
||||
run: ./gradlew build
|
||||
- name: capture build artifacts
|
||||
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Artifacts
|
||||
|
|
25
README.md
|
@ -1 +1,24 @@
|
|||
# Moonlight Meadows Utility Mod for Minecraft 1.19.3
|
||||
# Moonlight Meadows Utility Mod for Modern versions of Minecraft
|
||||
|
||||
Requires Fabric, Fabric API, and Minecraft 1.21
|
||||
|
||||
Default ClickGUI Key is Right Alt.
|
||||
|
||||
Grab the latest release build [here](https://github.com/kawaiizenbo/MoonlightMeadows/releases)
|
||||
Grab the latest nightly build [here](https://nightly.link/kawaiizenbo/MoonlightMeadows/workflows/build/main/Artifacts.zip)
|
||||
|
||||
## Screenshots
|
||||

|
||||
*Title Screen*
|
||||
|
||||

|
||||
*In-Game HUD*
|
||||
|
||||

|
||||
*ClickGUI*
|
||||
|
||||
|
||||
## Disclaimer
|
||||
Please use this mod at your own risk, we are not responsible for any serious injury or death caused by this mod.
|
||||
Do not use while operating heavy machinery.
|
||||
This project is not affiliated with Mojang or Microsoft.
|
||||
|
|
10
build.gradle
|
@ -1,10 +1,10 @@
|
|||
plugins {
|
||||
id 'fabric-loom' version '1.0-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.8-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
version = project.mod_version
|
||||
|
@ -46,8 +46,8 @@ processResources {
|
|||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
||||
it.options.release = 17
|
||||
// Minecraft 1.20.5 (24w14a) upwards uses Java 21.
|
||||
it.options.release = 21
|
||||
}
|
||||
|
||||
java {
|
||||
|
|
|
@ -4,14 +4,14 @@ org.gradle.parallel=true
|
|||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.19.3
|
||||
yarn_mappings=1.19.3+build.5
|
||||
loader_version=0.14.17
|
||||
minecraft_version=1.21.4
|
||||
yarn_mappings=1.21.4+build.8
|
||||
loader_version=0.16.10
|
||||
|
||||
# Mod Properties
|
||||
mod_version = dev
|
||||
mod_version = 0.4.0
|
||||
maven_group = me.kawaiizenbo
|
||||
archives_base_name = moonlight
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.75.1+1.19.3
|
||||
fabric_version=0.115.0+1.21.4
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
29
gradlew
vendored
|
@ -83,10 +83,8 @@ done
|
|||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
@ -133,10 +131,13 @@ location of your Java installation."
|
|||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
|
@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
|
@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
|||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
|
BIN
readme-assets/clickgui-old.png
Normal file
After Width: | Height: | Size: 186 KiB |
BIN
readme-assets/clickgui.png
Normal file
After Width: | Height: | Size: 248 KiB |
BIN
readme-assets/ingame-old.png
Normal file
After Width: | Height: | Size: 281 KiB |
BIN
readme-assets/ingame.png
Normal file
After Width: | Height: | Size: 405 KiB |
BIN
readme-assets/title-old.png
Normal file
After Width: | Height: | Size: 555 KiB |
BIN
readme-assets/title.png
Normal file
After Width: | Height: | Size: 556 KiB |
175
src/main/java/me/kawaiizenbo/moonlight/Config.java
Normal file
|
@ -0,0 +1,175 @@
|
|||
package me.kawaiizenbo.moonlight;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
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.IndexSetting;
|
||||
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.ui.clickgui.ClickGUIScreen;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModuleManager;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
public class Config
|
||||
{
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
public File configDir = new File(mc.runDirectory.getPath() + "/moonlight");
|
||||
public File configFile = new File(configDir, "config.json");
|
||||
public Map<String, Object> config = new HashMap<>();
|
||||
protected static Gson gson = new Gson();
|
||||
|
||||
public Config()
|
||||
{
|
||||
configDir.mkdirs();
|
||||
}
|
||||
|
||||
public boolean doesConfigExist()
|
||||
{
|
||||
return !Files.exists(configFile.toPath());
|
||||
}
|
||||
|
||||
public void loadDefaultConfig()
|
||||
{
|
||||
ModuleManager.INSTANCE = new ModuleManager();
|
||||
config.put("theme", 2);
|
||||
Map<String, Object> mi = new HashMap<>();
|
||||
for (Module m : ModuleManager.INSTANCE.modules)
|
||||
{
|
||||
Map<String, Object> mo = new HashMap<>();
|
||||
mo.put("enabled", m.enabled);
|
||||
Map<String, Object> ms = new HashMap<>();
|
||||
for (Setting s : m.settings)
|
||||
{
|
||||
if (s instanceof BooleanSetting)
|
||||
{
|
||||
ms.put(s.name, ((BooleanSetting)s).value);
|
||||
}
|
||||
else if (s instanceof DoubleSetting)
|
||||
{
|
||||
ms.put(s.name, ((DoubleSetting)s).value);
|
||||
}
|
||||
else if (s instanceof StringSetting)
|
||||
{
|
||||
ms.put(s.name, ((StringSetting)s).value);
|
||||
}
|
||||
else if (s instanceof KeycodeSetting)
|
||||
{
|
||||
ms.put(s.name, ((KeycodeSetting)s).value);
|
||||
}
|
||||
else if (s instanceof IndexSetting)
|
||||
{
|
||||
ms.put(s.name, ((IndexSetting)s).index);
|
||||
}
|
||||
}
|
||||
mo.put("settings", ms);
|
||||
mi.put(m.name, mo);
|
||||
}
|
||||
config.put("modules", mi);
|
||||
|
||||
HUDModuleManager.INSTANCE = new HUDModuleManager();
|
||||
Map<String, Object> hi = new HashMap<>();
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
Map<String, Object> ho = new HashMap<>();
|
||||
ho.put("enabled", h.enabled);
|
||||
Map<String, Object> hs = new HashMap<>();
|
||||
for (Setting s : h.settings)
|
||||
{
|
||||
if (s instanceof BooleanSetting)
|
||||
{
|
||||
hs.put(s.name, ((BooleanSetting)s).value);
|
||||
}
|
||||
else if (s instanceof DoubleSetting)
|
||||
{
|
||||
hs.put(s.name, ((DoubleSetting)s).value);
|
||||
}
|
||||
else if (s instanceof StringSetting)
|
||||
{
|
||||
hs.put(s.name, ((StringSetting)s).value);
|
||||
}
|
||||
else if (s instanceof KeycodeSetting)
|
||||
{
|
||||
hs.put(s.name, ((KeycodeSetting)s).value);
|
||||
}
|
||||
else if (s instanceof IndexSetting)
|
||||
{
|
||||
hs.put(s.name, ((IndexSetting)s).index);
|
||||
}
|
||||
}
|
||||
ho.put("settings", hs);
|
||||
ho.put("x", h.x);
|
||||
ho.put("y", h.y);
|
||||
hi.put(h.name, ho);
|
||||
}
|
||||
config.put("hud", hi);
|
||||
int xOffset = 4;
|
||||
int yOffset = 4;
|
||||
Map<String, Object> pi = new HashMap<>();
|
||||
for (Category category : Category.values())
|
||||
{
|
||||
Map<String, Object> po = new HashMap<>();
|
||||
if (xOffset > 400)
|
||||
{
|
||||
xOffset = 4;
|
||||
yOffset = 128;
|
||||
}
|
||||
po.put("x", xOffset);
|
||||
po.put("y", yOffset);
|
||||
po.put("collapsed", false);
|
||||
pi.put(category.name, po);
|
||||
xOffset += 100;
|
||||
}
|
||||
config.put("panes", pi);
|
||||
ClickGUIScreen.INSTANCE = new ClickGUIScreen();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load() throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
String configText = new String(Files.readAllBytes(configFile.toPath()));
|
||||
config = (Map<String, Object>)gson.fromJson(configText, Map.class);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IOException("Failed to load config file.");
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!doesConfigExist()) configFile.createNewFile();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
try
|
||||
{
|
||||
String configText = gson.toJson(config);
|
||||
FileWriter writer = new FileWriter(configFile);
|
||||
writer.write(configText);
|
||||
writer.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,26 @@
|
|||
package me.kawaiizenbo.moonlight;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
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.IndexSetting;
|
||||
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.theme.Theme;
|
||||
import me.kawaiizenbo.moonlight.ui.clickgui.CategoryPane;
|
||||
import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModuleManager;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
|
||||
public class Moonlight implements ModInitializer
|
||||
|
@ -11,11 +28,177 @@ public class Moonlight implements ModInitializer
|
|||
public static final Moonlight INSTANCE = new Moonlight();
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("Moonlight");
|
||||
public static final String clientTag = ColorUtils.aqua + "Moonlight Meadows";
|
||||
public static final String versionTag = ColorUtils.magenta + "v0.dev";
|
||||
public static final String versionTag = ColorUtils.magenta + "v0.4.0";
|
||||
public static Theme THEME = Theme.DARK;
|
||||
public static int THEME_IDX = 2;
|
||||
public static Config CONFIG = new Config();
|
||||
|
||||
@Override
|
||||
public void onInitialize()
|
||||
{
|
||||
LOGGER.info("Moonlight loading...");
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
LOGGER.info("Loading config...");
|
||||
CONFIG.load();
|
||||
THEME_IDX = ((Double)CONFIG.config.get("theme")).intValue();
|
||||
THEME = Theme.THEME_LIST[THEME_IDX];
|
||||
for (Module m : ModuleManager.INSTANCE.modules)
|
||||
{
|
||||
m.enabled = (boolean)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("enabled");
|
||||
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();
|
||||
}
|
||||
else if (s instanceof IndexSetting)
|
||||
{
|
||||
((IndexSetting)s).index = ((Double)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name)).intValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (HUDModule m : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
m.enabled = (boolean)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("hud")).get(m.name)).get("enabled");
|
||||
m.x = ((Double)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("hud")).get(m.name)).get("x")).intValue();
|
||||
m.y = ((Double)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("hud")).get(m.name)).get("y")).intValue();
|
||||
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("hud")).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("hud")).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("hud")).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("hud")).get(m.name)).get("settings")).get(s.name)).intValue();
|
||||
}
|
||||
else if (s instanceof IndexSetting)
|
||||
{
|
||||
((IndexSetting)s).index = ((Double)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("hud")).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.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveConfig()
|
||||
{
|
||||
LOGGER.info("Saving config...");
|
||||
CONFIG.config.put("theme", THEME_IDX);
|
||||
Map<String, Object> mi = new HashMap<>();
|
||||
for (Module m : ModuleManager.INSTANCE.modules)
|
||||
{
|
||||
Map<String, Object> mo = new HashMap<>();
|
||||
mo.put("enabled", m.enabled);
|
||||
Map<String, Object> ms = new HashMap<>();
|
||||
for (Setting s : m.settings)
|
||||
{
|
||||
if (s instanceof BooleanSetting)
|
||||
{
|
||||
ms.put(s.name, ((BooleanSetting)s).value);
|
||||
}
|
||||
else if (s instanceof DoubleSetting)
|
||||
{
|
||||
ms.put(s.name, ((DoubleSetting)s).value);
|
||||
}
|
||||
else if (s instanceof StringSetting)
|
||||
{
|
||||
ms.put(s.name, ((StringSetting)s).value);
|
||||
}
|
||||
else if (s instanceof KeycodeSetting)
|
||||
{
|
||||
ms.put(s.name, ((KeycodeSetting)s).value);
|
||||
}
|
||||
else if (s instanceof IndexSetting)
|
||||
{
|
||||
ms.put(s.name, ((IndexSetting)s).index);
|
||||
}
|
||||
}
|
||||
mo.put("settings", ms);
|
||||
mi.put(m.name, mo);
|
||||
}
|
||||
CONFIG.config.put("modules", mi);
|
||||
|
||||
Map<String, Object> hi = new HashMap<>();
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
Map<String, Object> ho = new HashMap<>();
|
||||
ho.put("enabled", h.enabled);
|
||||
Map<String, Object> hs = new HashMap<>();
|
||||
for (Setting s : h.settings)
|
||||
{
|
||||
if (s instanceof BooleanSetting)
|
||||
{
|
||||
hs.put(s.name, ((BooleanSetting)s).value);
|
||||
}
|
||||
else if (s instanceof DoubleSetting)
|
||||
{
|
||||
hs.put(s.name, ((DoubleSetting)s).value);
|
||||
}
|
||||
else if (s instanceof StringSetting)
|
||||
{
|
||||
hs.put(s.name, ((StringSetting)s).value);
|
||||
}
|
||||
else if (s instanceof KeycodeSetting)
|
||||
{
|
||||
hs.put(s.name, ((KeycodeSetting)s).value);
|
||||
}
|
||||
else if (s instanceof IndexSetting)
|
||||
{
|
||||
hs.put(s.name, ((IndexSetting)s).index);
|
||||
}
|
||||
}
|
||||
ho.put("settings", hs);
|
||||
ho.put("x", h.x);
|
||||
ho.put("y", h.y);
|
||||
hi.put(h.name, ho);
|
||||
}
|
||||
CONFIG.config.put("hud", hi);
|
||||
|
||||
Map<String, Object> pi = new HashMap<>();
|
||||
for (CategoryPane c : ClickGUIScreen.INSTANCE.categoryPanes)
|
||||
{
|
||||
Map<String, Object> po = new HashMap<>();
|
||||
po.put("x", c.x);
|
||||
po.put("y", c.y);
|
||||
po.put("collapsed", c.collapsed);
|
||||
pi.put(c.category.name, po);
|
||||
}
|
||||
CONFIG.config.put("panes", pi);
|
||||
CONFIG.save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ public class CommandManager
|
|||
add(new Help());
|
||||
add(new Toggle());
|
||||
add(new Teleport());
|
||||
add(new Reset());
|
||||
add(new DeathPos());
|
||||
commands.sort(Comparator.comparing(Command::getName));
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package me.kawaiizenbo.moonlight.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
|
||||
import me.kawaiizenbo.moonlight.command.Command;
|
||||
import me.kawaiizenbo.moonlight.util.ChatUtils;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.util.math.GlobalPos;
|
||||
|
||||
public class DeathPos extends Command
|
||||
{
|
||||
public DeathPos()
|
||||
{
|
||||
super("deathpos", "Shows your last death position.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder)
|
||||
{
|
||||
builder.executes(context ->
|
||||
{
|
||||
GlobalPos pos = null;
|
||||
try
|
||||
{
|
||||
pos = mc.player.getLastDeathPos().get();
|
||||
if (pos == null) throw new Exception();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ChatUtils.sendMsg(ColorUtils.reset + "You have not died in this world.");
|
||||
return SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
ChatUtils.sendMsg(ColorUtils.reset + "You last died at: " +
|
||||
ColorUtils.aqua + " X: " + ColorUtils.gray + pos.pos().getX() +
|
||||
ColorUtils.aqua + " Y: " + ColorUtils.gray + pos.pos().getY() +
|
||||
ColorUtils.aqua + " Z: " + ColorUtils.gray + pos.pos().getZ()
|
||||
);
|
||||
return SINGLE_SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -20,13 +20,13 @@ public class Help extends Command
|
|||
{
|
||||
builder.executes(context ->
|
||||
{
|
||||
for (Command cmd : CommandManager.get().getAll()) {
|
||||
for (Command cmd : CommandManager.get().getAll())
|
||||
{
|
||||
ChatUtils.sendMsg(ColorUtils.aqua + "Command: " + ColorUtils.gray + cmd.getName());
|
||||
ChatUtils.sendMsg(ColorUtils.gray + cmd.getDescription());
|
||||
ChatUtils.sendMsg(ColorUtils.gray + "");
|
||||
}
|
||||
return SINGLE_SUCCESS;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package me.kawaiizenbo.moonlight.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.command.Command;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
public class Reset extends Command
|
||||
{
|
||||
public Reset()
|
||||
{
|
||||
super("reset", "Resets all config options.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder)
|
||||
{
|
||||
builder.executes(context ->
|
||||
{
|
||||
Moonlight.CONFIG.loadDefaultConfig();
|
||||
return SINGLE_SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
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.command.ModuleArgumentType;
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
public class Toggle extends Command
|
||||
|
@ -13,19 +14,18 @@ public class Toggle extends Command
|
|||
|
||||
public Toggle()
|
||||
{
|
||||
super("toggle", "Toggle a module.");
|
||||
super("toggle", "Toggle a module on or off.");
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
assert player != null;
|
||||
|
||||
Module_ m = context.getArgument("module", Module_.class);
|
||||
m.toggle();
|
||||
String m = context.getArgument("module", String.class);
|
||||
Module module = ModuleManager.INSTANCE.getModuleByName(m);
|
||||
MinecraftClient.getInstance().send(() -> module.toggle());
|
||||
|
||||
return SINGLE_SUCCESS;
|
||||
}));
|
||||
|
|
|
@ -10,16 +10,15 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|||
import me.kawaiizenbo.moonlight.command.CommandManager;
|
||||
import me.kawaiizenbo.moonlight.util.ChatUtils;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public class ClientConnectionMixin
|
||||
{
|
||||
@Inject(method = "send(Lnet/minecraft/network/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)
|
||||
{
|
||||
// Call commands if the prefix is sent
|
||||
if(packet instanceof ChatMessageC2SPacket && ((ChatMessageC2SPacket) packet).chatMessage().startsWith(CommandManager.get().getPrefix()))
|
||||
{
|
||||
try
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package me.kawaiizenbo.moonlight.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.module.Module;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public class ClientPlayerEntityMixin
|
||||
{
|
||||
@Inject(method = "move", at = @At(value = "TAIL"), cancellable = true)
|
||||
public void onMove(MovementType type, Vec3d movement, CallbackInfo ci)
|
||||
{
|
||||
for (Module m : ModuleManager.INSTANCE.getEnabledModules())
|
||||
{
|
||||
m.onMotion(type, movement);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Inject(method = "tick", at = @At(value = "HEAD"), cancellable = true)
|
||||
public void onTick(CallbackInfo ci)
|
||||
{
|
||||
for (Module m : ModuleManager.INSTANCE.getEnabledModules())
|
||||
{
|
||||
if (MinecraftClient.getInstance().player != null) m.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At(value = "TAIL"), cancellable = true)
|
||||
public void onInit(CallbackInfo ci)
|
||||
{
|
||||
for (Module m : ModuleManager.INSTANCE.getEnabledModules())
|
||||
{
|
||||
m.onEnable();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +1,32 @@
|
|||
package me.kawaiizenbo.moonlight.mixin;
|
||||
|
||||
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.module.ModuleManager;
|
||||
import me.kawaiizenbo.moonlight.ui.HUD;
|
||||
import me.kawaiizenbo.moonlight.module.modules.HUDEnabler;
|
||||
import me.kawaiizenbo.moonlight.ui.LegacyHUD;
|
||||
import me.kawaiizenbo.moonlight.ui.ModulesListOverlay;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
|
||||
@Mixin(InGameHud.class)
|
||||
public class InGameHudMixin {
|
||||
|
||||
@Shadow private int scaledWidth;
|
||||
@Shadow private int scaledHeight;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "render")
|
||||
public void onRender (MatrixStack matrices, float tickDelta, CallbackInfo info)
|
||||
public void onRender (DrawContext drawContext, RenderTickCounter tickCounter, CallbackInfo info)
|
||||
{
|
||||
if (ModuleManager.INSTANCE.getModuleByName("HUD").enabled) HUD.INSTANCE.renderHUD(matrices, scaledWidth, scaledHeight);
|
||||
HUDEnabler hudModule = (HUDEnabler)ModuleManager.INSTANCE.getModuleByName("HUD");
|
||||
if (hudModule.enabled)
|
||||
{
|
||||
if (hudModule.mode.index == 1) LegacyHUD.INSTANCE.render(drawContext, drawContext.getScaledWindowWidth(), drawContext.getScaledWindowHeight());
|
||||
else HUDRenderer.INSTANCE.render(drawContext);
|
||||
}
|
||||
if (ModuleManager.INSTANCE.getModuleByName("ModulesList").enabled) ModulesListOverlay.INSTANCE.render(drawContext, drawContext.getScaledWindowWidth(), drawContext.getScaledWindowHeight());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,16 +8,27 @@ 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.Module;
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
public abstract class KeyboardMixin {
|
||||
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);
|
||||
public void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo info)
|
||||
{
|
||||
if (key == GLFW.GLFW_KEY_RIGHT_ALT) MinecraftClient.getInstance().setScreen(ClickGUIScreen.INSTANCE);
|
||||
for (Module m : ModuleManager.INSTANCE.modules)
|
||||
{
|
||||
if (key == m.keybind.value && action == GLFW.GLFW_PRESS && MinecraftClient.getInstance().currentScreen == null)
|
||||
{
|
||||
m.toggle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package me.kawaiizenbo.moonlight.mixin;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public class LivingEntityMixin
|
||||
{
|
||||
@Inject(at = @At("HEAD"), method = "tick()V")
|
||||
private void init(CallbackInfo info)
|
||||
{
|
||||
for (Module_ mod : ModuleManager.INSTANCE.getEnabledModules())
|
||||
{
|
||||
if (MinecraftClient.getInstance().player != null) mod.tick();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package me.kawaiizenbo.moonlight.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public class MinecraftClientMixin
|
||||
{
|
||||
@Inject(at = @At("TAIL"), method = "scheduleStop")
|
||||
public void onShutdown(CallbackInfo ci) {
|
||||
Moonlight.INSTANCE.saveConfig();
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package me.kawaiizenbo.moonlight.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.altmanager.AltManagerScreen;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
@Mixin(MultiplayerScreen.class)
|
||||
public class MultiplayerScreenMixin extends Screen
|
||||
{
|
||||
protected MultiplayerScreenMixin(Text title)
|
||||
{
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "init")
|
||||
private void altManagerButton(CallbackInfo callbackInfo)
|
||||
{
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.literal("Alt Manager"), this::gotoAltManagerScreen)
|
||||
.position(this.width - 102, 2)
|
||||
.size(100, 20)
|
||||
.build());
|
||||
}
|
||||
|
||||
private void gotoAltManagerScreen(ButtonWidget button)
|
||||
{
|
||||
MinecraftClient.getInstance().setScreen(AltManagerScreen.INSTANCE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package me.kawaiizenbo.moonlight.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
import net.minecraft.block.PowderSnowBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
@Mixin(PowderSnowBlock.class)
|
||||
public class PowderSnowBlockMixin
|
||||
{
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "canWalkOnPowderSnow", cancellable = true)
|
||||
private static void canWalkOnPowderSnow(Entity entity, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (ModuleManager.INSTANCE.getModuleByName("Anti Powder Snow").enabled) cir.setReturnValue(true);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package me.kawaiizenbo.moonlight.mixin;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.ui.altmanager.AltManagerScreen;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -10,13 +9,9 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
|
@ -37,26 +32,12 @@ public abstract class TitleScreenMixin extends Screen
|
|||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "render")
|
||||
private void clientTag(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info)
|
||||
private void clientTag(DrawContext drawContext, int mouseX, int mouseY, float delta, CallbackInfo info)
|
||||
{
|
||||
float f = this.doBackgroundFade ? (Util.getMeasuringTimeMs() - this.backgroundFadeStart) / 1000.0F : 1.0F;
|
||||
float g = this.doBackgroundFade ? MathHelper.clamp(f - 1.0F, 0.0F, 1.0F) : 1.0F;
|
||||
int l = MathHelper.ceil(g * 255.0F) << 24;
|
||||
|
||||
DrawableHelper.drawStringWithShadow(matrices, this.textRenderer, Moonlight.clientTag + " " + Moonlight.versionTag, 2, 2, 16777215 | l);
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "init")
|
||||
private void altManagerButton(CallbackInfo callbackInfo)
|
||||
{
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.literal("Alt Manager"), this::gotoAltManagerScreen)
|
||||
.position(this.width - 102, 2)
|
||||
.size(100, 20)
|
||||
.build());
|
||||
}
|
||||
|
||||
private void gotoAltManagerScreen(ButtonWidget button)
|
||||
{
|
||||
MinecraftClient.getInstance().setScreen(AltManagerScreen.INSTANCE);
|
||||
drawContext.drawTextWithShadow(this.textRenderer, Moonlight.clientTag + " " + Moonlight.versionTag, 2, 2, 16777215 | l);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,20 @@ package me.kawaiizenbo.moonlight.module;
|
|||
|
||||
public enum Category
|
||||
{
|
||||
COMBAT("Combat"),
|
||||
MOVEMENT("Movement"),
|
||||
RENDER("Render"),
|
||||
WORLD("World"),
|
||||
PLAYER("Player"),
|
||||
CHAT("Chat");
|
||||
COMBAT("Combat", 0xFFFF5555),
|
||||
MOVEMENT("Movement", 0xFFFF55FF),
|
||||
RENDER("Render", 0xFF5555FF),
|
||||
WORLD("World", 0xFF55FF55),
|
||||
PLAYER("Player", 0xFF00AAAA),
|
||||
CHAT("Chat", 0xFFFFAA00),
|
||||
SPECIAL("Special", 0xFFFFFFFF);
|
||||
|
||||
public String name;
|
||||
public int color;
|
||||
|
||||
Category(String name)
|
||||
Category(String name, int color)
|
||||
{
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
|
70
src/main/java/me/kawaiizenbo/moonlight/module/Module.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package me.kawaiizenbo.moonlight.module;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.settings.BooleanSetting;
|
||||
import me.kawaiizenbo.moonlight.module.settings.KeycodeSetting;
|
||||
import me.kawaiizenbo.moonlight.module.settings.Setting;
|
||||
import me.kawaiizenbo.moonlight.ui.ModulesListOverlay;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public abstract class Module
|
||||
{
|
||||
protected static MinecraftClient mc = MinecraftClient.getInstance();
|
||||
public String name;
|
||||
public String description;
|
||||
public Category category;
|
||||
public boolean enabled;
|
||||
public ArrayList<Setting> settings;
|
||||
public boolean showEditButton;
|
||||
|
||||
public BooleanSetting showInModulesList = new BooleanSetting("Show in Modules List", true);
|
||||
public KeycodeSetting keybind = new KeycodeSetting("Keybind", 0);
|
||||
|
||||
public Module(String name, String description, Category category)
|
||||
{
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
settings = new ArrayList<>();
|
||||
settings.add(showInModulesList);
|
||||
settings.add(keybind);
|
||||
}
|
||||
|
||||
public void onEnable() { ModulesListOverlay.INSTANCE.update(); }
|
||||
public void onDisable() { ModulesListOverlay.INSTANCE.update(); }
|
||||
public void onMotion(MovementType type, Vec3d movement) {}
|
||||
public void tick() {}
|
||||
|
||||
public void toggle()
|
||||
{
|
||||
enabled = !enabled;
|
||||
if(enabled) {
|
||||
onEnable();
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,34 +7,39 @@ import me.kawaiizenbo.moonlight.module.modules.*;
|
|||
public class ModuleManager
|
||||
{
|
||||
public static ModuleManager INSTANCE = new ModuleManager();
|
||||
public ArrayList<Module_> modules = new ArrayList<>();
|
||||
public ArrayList<Module> modules = new ArrayList<>();
|
||||
|
||||
public ModuleManager()
|
||||
{
|
||||
registerModules(
|
||||
new Fly(),
|
||||
new NoFall(),
|
||||
new HUDModule(),
|
||||
new HUDEnabler(),
|
||||
new Step(),
|
||||
new Fullbright()
|
||||
new Fullbright(),
|
||||
new Speed(),
|
||||
new ModulesList(),
|
||||
new ChatSpammer(),
|
||||
new Rotation(),
|
||||
new AutoJump(),
|
||||
new Reach(),
|
||||
new AntiPowderSnow(),
|
||||
new AutoTotem(),
|
||||
new AutoWalk()
|
||||
/*new Timer()*/
|
||||
);
|
||||
}
|
||||
|
||||
public void registerModule(Module_ module)
|
||||
private void registerModules(Module... modules)
|
||||
{
|
||||
modules.add(module);
|
||||
}
|
||||
|
||||
public void registerModules(Module_... modules)
|
||||
{
|
||||
for (Module_ module : modules) {
|
||||
for (Module module : modules) {
|
||||
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)))
|
||||
{
|
||||
|
@ -44,10 +49,10 @@ public class ModuleManager
|
|||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<Module_> getModulesByCategory(Category category)
|
||||
public ArrayList<Module> getModulesByCategory(Category category)
|
||||
{
|
||||
ArrayList<Module_> returnedModules = new ArrayList<>();
|
||||
for(Module_ module : modules)
|
||||
ArrayList<Module> returnedModules = new ArrayList<>();
|
||||
for(Module module : modules)
|
||||
{
|
||||
if (module.category == category)
|
||||
{
|
||||
|
@ -57,10 +62,10 @@ public class ModuleManager
|
|||
return returnedModules;
|
||||
}
|
||||
|
||||
public ArrayList<Module_> getEnabledModules()
|
||||
public ArrayList<Module> getEnabledModules()
|
||||
{
|
||||
ArrayList<Module_> enabledModules = new ArrayList<>();
|
||||
for (Module_ module : modules)
|
||||
ArrayList<Module> enabledModules = new ArrayList<>();
|
||||
for (Module module : modules)
|
||||
{
|
||||
if (!module.enabled)
|
||||
continue;
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
package me.kawaiizenbo.moonlight.module;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.settings.Setting;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
public abstract class Module_
|
||||
{
|
||||
protected static MinecraftClient mc = MinecraftClient.getInstance();
|
||||
public String name;
|
||||
public String description;
|
||||
public Category category;
|
||||
public boolean enabled;
|
||||
public ArrayList<Setting> settings;
|
||||
public int keyBind;
|
||||
|
||||
public Module_(String name, String description, Category category)
|
||||
{
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
settings = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void onEnable() {}
|
||||
public void onDisable() {}
|
||||
public void tick() {}
|
||||
|
||||
public void toggle()
|
||||
{
|
||||
enabled = !enabled;
|
||||
if(enabled) {
|
||||
onEnable();
|
||||
} else {
|
||||
onDisable();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
|
||||
public class AntiPowderSnow extends Module
|
||||
{
|
||||
public AntiPowderSnow()
|
||||
{
|
||||
super("Anti Powder Snow", "Allows the player to walk on powder snow.", Category.PLAYER);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
|
||||
import me.kawaiizenbo.moonlight.util.Timer;
|
||||
|
||||
public class AutoJump extends Module
|
||||
{
|
||||
public DoubleSetting delay = new DoubleSetting("Delay (Seconds)", 1, 0.1, 10, 1);
|
||||
private Timer timer = new Timer();
|
||||
|
||||
public AutoJump()
|
||||
{
|
||||
super("Auto Jump", "Automatically jumps on a timer.", Category.MOVEMENT);
|
||||
settings.add(delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (timer.hasTimeElapsed((long)delay.value * 1000, true) && mc.player.isOnGround() && mc.player.hasVehicle() == false)
|
||||
{
|
||||
mc.player.jump();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
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 net.minecraft.item.Items;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
|
||||
public class AutoTotem extends Module
|
||||
{
|
||||
public BooleanSetting overrideItems = new BooleanSetting("Override other items", false);
|
||||
|
||||
public AutoTotem()
|
||||
{
|
||||
super("Auto Totem", "Automatically puts totems in offhand.", Category.COMBAT);
|
||||
settings.add(overrideItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (mc.player.getInventory().offHand.get(0).getItem() != Items.TOTEM_OF_UNDYING)
|
||||
{
|
||||
if((!mc.player.getInventory().offHand.isEmpty()) && !overrideItems.value) return;
|
||||
for (int i = 0; i <= 35; i++)
|
||||
{
|
||||
if (mc.player.getInventory().getStack(i).getItem() == Items.TOTEM_OF_UNDYING)
|
||||
{
|
||||
mc.interactionManager.clickSlot(0, i, 8, SlotActionType.SWAP, mc.player);
|
||||
mc.interactionManager.clickSlot(0, 45, 8, SlotActionType.SWAP, mc.player);
|
||||
mc.interactionManager.clickSlot(0, i, 8, SlotActionType.SWAP, mc.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
|
||||
public class AutoWalk extends Module
|
||||
{
|
||||
|
||||
public AutoWalk()
|
||||
{
|
||||
super("Auto Walk", "Automatically moves forward.", Category.MOVEMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
mc.options.forwardKey.setPressed(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
super.onDisable();
|
||||
mc.options.forwardKey.setPressed(false);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
|
||||
import me.kawaiizenbo.moonlight.module.settings.StringSetting;
|
||||
import me.kawaiizenbo.moonlight.util.Timer;
|
||||
|
||||
public class ChatSpammer extends Module
|
||||
{
|
||||
public StringSetting message = new StringSetting("Message", "E4PE4J");
|
||||
public DoubleSetting delay = new DoubleSetting("Delay (Seconds)", 1, 0.1, 10, 1);
|
||||
private Timer timer = new Timer();
|
||||
|
||||
public ChatSpammer()
|
||||
{
|
||||
super("Chat Spammer", "Spams a selected message in chat.", Category.CHAT);
|
||||
settings.add(message);
|
||||
settings.add(delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (timer.hasTimeElapsed((long)delay.value * 1000, true))
|
||||
{
|
||||
mc.player.networkHandler.sendChatMessage(message.value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
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()
|
||||
|
@ -20,6 +20,7 @@ public class Fly extends Module_
|
|||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
super.onDisable();
|
||||
mc.player.getAbilities().flying = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,28 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import me.kawaiizenbo.moonlight.util.ISimpleOption;
|
||||
|
||||
public class Fullbright extends Module_
|
||||
public class Fullbright extends Module
|
||||
{
|
||||
public Fullbright()
|
||||
{
|
||||
super("Fullbright", "Allows you to see in the dark.", Category.RENDER);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
// i dont know why but this makes it darker than 1.0
|
||||
mc.options.getGamma().setValue(100.0);
|
||||
super.onEnable();
|
||||
((ISimpleOption<Double>)(Object)mc.options.getGamma()).setValueUnrestricted(100.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
super.onDisable();
|
||||
mc.options.getGamma().setValue(1.0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import me.kawaiizenbo.moonlight.module.settings.IndexSetting;
|
||||
|
||||
public class HUDEnabler extends Module
|
||||
{
|
||||
public IndexSetting mode = new IndexSetting("Mode", 0, "Modular", "Legacy");
|
||||
|
||||
public HUDEnabler()
|
||||
{
|
||||
super("HUD", "The Moonlight HUD.", Category.RENDER);
|
||||
this.enabled = true;
|
||||
this.showInModulesList.value = false;
|
||||
this.showEditButton = true;
|
||||
settings.add(mode);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
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;
|
||||
|
||||
public class HUDModule extends Module_
|
||||
{
|
||||
public ColorSetting color = new ColorSetting("Color", 0x55FFFF);
|
||||
public HUDModule()
|
||||
{
|
||||
super("HUD", "Enables or disables the Moonlight HUD.", Category.RENDER);
|
||||
this.enabled = true;
|
||||
settings.add(color);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
|
||||
public class ModulesList extends Module
|
||||
{
|
||||
public ModulesList()
|
||||
{
|
||||
super("ModulesList", "Shows enabled modules on side of screen", Category.RENDER);
|
||||
this.enabled = true;
|
||||
this.showInModulesList.value = false;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
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;
|
||||
|
||||
public class NoFall extends Module_
|
||||
public class NoFall extends Module
|
||||
{
|
||||
public NoFall()
|
||||
{
|
||||
|
@ -14,6 +14,6 @@ public class NoFall extends Module_
|
|||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if(mc.player.fallDistance >= 2.5) mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true));
|
||||
if(mc.player.fallDistance >= 2.5) mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true, false));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
|
||||
public class Reach extends Module
|
||||
{
|
||||
DoubleSetting blockRange = new DoubleSetting("Block Range", 4.5, 1, 10, 1);
|
||||
DoubleSetting entityRange = new DoubleSetting("Entity Range", 3.0, 1, 10, 1);
|
||||
double oldBe = 4.5;
|
||||
double oldEe = 3.0;
|
||||
|
||||
public Reach()
|
||||
{
|
||||
super("Reach", "Extends player interaction distance.", Category.MOVEMENT);
|
||||
settings.add(blockRange);
|
||||
settings.add(entityRange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
super.onEnable();
|
||||
oldBe = mc.player.getAttributeInstance(EntityAttributes.BLOCK_INTERACTION_RANGE).getBaseValue();
|
||||
oldEe = mc.player.getAttributeInstance(EntityAttributes.ENTITY_INTERACTION_RANGE).getBaseValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
mc.player.getAttributeInstance(EntityAttributes.BLOCK_INTERACTION_RANGE).setBaseValue(blockRange.value);
|
||||
mc.player.getAttributeInstance(EntityAttributes.ENTITY_INTERACTION_RANGE).setBaseValue(entityRange.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
super.onDisable();
|
||||
mc.player.getAttributeInstance(EntityAttributes.BLOCK_INTERACTION_RANGE).setBaseValue(oldBe);
|
||||
mc.player.getAttributeInstance(EntityAttributes.ENTITY_INTERACTION_RANGE).setBaseValue(oldEe);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
|
||||
|
||||
public class Rotation extends Module
|
||||
{
|
||||
DoubleSetting pitch = new DoubleSetting("Pitch", 0, 0, 360, 0);
|
||||
DoubleSetting yaw = new DoubleSetting("Yaw", 0, 0, 360, 0);
|
||||
|
||||
public Rotation()
|
||||
{
|
||||
super("Rotation", "Locks camera to specified pitch and yaw.", Category.PLAYER);
|
||||
settings.add(pitch);
|
||||
settings.add(yaw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
mc.player.setPitch((float)pitch.value);
|
||||
mc.player.setYaw((float)yaw.value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
|
||||
public class Speed extends Module
|
||||
{
|
||||
double old = 0.1;
|
||||
|
||||
DoubleSetting speed = new DoubleSetting("Speed", 1.4, 0.1, 10, 1);
|
||||
public Speed()
|
||||
{
|
||||
super("Speed", "Allows you to move faster.", Category.MOVEMENT);
|
||||
settings.add(speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
super.onEnable();
|
||||
old = mc.player.getAttributeInstance(EntityAttributes.MOVEMENT_SPEED).getBaseValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
mc.player.getAttributeInstance(EntityAttributes.MOVEMENT_SPEED).setBaseValue(speed.value/10d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
super.onDisable();
|
||||
mc.player.getAttributeInstance(EntityAttributes.MOVEMENT_SPEED).setBaseValue(old);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +1,14 @@
|
|||
package me.kawaiizenbo.moonlight.module.modules;
|
||||
|
||||
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 net.minecraft.entity.attribute.EntityAttributes;
|
||||
|
||||
public class Step extends Module_
|
||||
public class Step extends Module
|
||||
{
|
||||
DoubleSetting stepHeight = new DoubleSetting("Height", 1, 1, 10, 0);
|
||||
double old = 0.6;
|
||||
|
||||
public Step()
|
||||
{
|
||||
|
@ -14,15 +16,23 @@ public class Step extends Module_
|
|||
settings.add(stepHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
super.onEnable();
|
||||
old = mc.player.getAttributeInstance(EntityAttributes.STEP_HEIGHT).getBaseValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
mc.player.stepHeight = (float)stepHeight.value;
|
||||
mc.player.getAttributeInstance(EntityAttributes.STEP_HEIGHT).setBaseValue(stepHeight.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
mc.player.stepHeight = 0.5f;
|
||||
super.onDisable();
|
||||
mc.player.getAttributeInstance(EntityAttributes.STEP_HEIGHT).setBaseValue(old);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
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;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
super.onEnable();
|
||||
System.out.println("Test Module Enabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
super.onDisable();
|
||||
System.out.println("Test Module Disabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMotion(MovementType type, Vec3d movement)
|
||||
{
|
||||
System.out.println("Test Module motion");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
System.out.println("Test Module Tick");
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
package me.kawaiizenbo.moonlight.module.settings;
|
||||
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class BooleanSetting extends Setting
|
||||
|
@ -15,13 +16,13 @@ public class BooleanSetting extends Setting
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int x, int y, int mouseX, int mouseY)
|
||||
public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer)
|
||||
{
|
||||
super.render(matrices, x, y, mouseX, mouseY);
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, Text.literal(name), x+2, y+8, 0xFFFFFF);
|
||||
DrawableHelper.fill(matrices, x+175, y+7, x+185, y+17, 0xFFFFFFFF);
|
||||
DrawableHelper.fill(matrices, x+176, y+8, x+184, y+16, 0xFF222222);
|
||||
DrawableHelper.fill(matrices, x+177, y+9, x+183, y+15, value ? 0xFF55FFFF : 0xFF222222);
|
||||
super.render(drawContext, x, y, mouseX, mouseY, textRenderer);
|
||||
drawContext.drawText(textRenderer, Text.literal(name), x+2, y+8, Moonlight.THEME.text.getRGB(), false);
|
||||
drawContext.fill(x+180, y+7, x+190, y+17, Moonlight.THEME.border.getRGB());
|
||||
drawContext.fill(x+181, y+8, x+189, y+16, Moonlight.THEME.background.getRGB());
|
||||
drawContext.fill(x+182, y+9, x+188, y+15, value ? Moonlight.THEME.accent.getRGB() : Moonlight.THEME.background.getRGB());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package me.kawaiizenbo.moonlight.module.settings;
|
||||
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
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+80, y+2, x+92, y+62, redDisplayEndColor, redDisplayStartColor, 0);
|
||||
DrawableHelper.fillGradient(matrices, x+95, y+2, x+107, y+62, greenDisplayEndColor, greenDisplayStartColor, 0);
|
||||
DrawableHelper.fillGradient(matrices, x+110, y+2, x+122, y+62, blueDisplayEndColor, blueDisplayStartColor, 0);
|
||||
textRenderer.drawWithShadow(matrices, Text.literal("Red: " + r), x+130, y+10, 0xFFFFFFFF);
|
||||
textRenderer.drawWithShadow(matrices, Text.literal("Green: " + g), x+130, y+26, 0xFFFFFFFF);
|
||||
textRenderer.drawWithShadow(matrices, Text.literal("Blue: " + b), x+130, y+42, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package me.kawaiizenbo.moonlight.module.settings;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.util.MathUtils;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class DoubleSetting extends Setting
|
||||
|
@ -23,10 +24,10 @@ public class DoubleSetting extends Setting
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int x, int y, int mouseX, int mouseY)
|
||||
public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer)
|
||||
{
|
||||
super.render(matrices, x, y, mouseX, mouseY);
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, Text.literal(name), x+2, y+2, 0xFFFFFF);
|
||||
super.render(drawContext, x, y, mouseX, mouseY, textRenderer);
|
||||
drawContext.drawText(textRenderer, Text.literal(name), x+2, y+4, Moonlight.THEME.text.getRGB(), false);
|
||||
double diff = Math.min(100, Math.max(0, (mouseX - x)/1.9));
|
||||
|
||||
if (sliding)
|
||||
|
@ -43,11 +44,11 @@ public class DoubleSetting extends Setting
|
|||
}
|
||||
|
||||
String valueString = ""+MathUtils.round(value, roundingPlace);
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, Text.literal(valueString), (x+190)-textRenderer.getWidth(valueString), y+2, 0xFFFFFF);
|
||||
DrawableHelper.fill(matrices, x+2, y+16, x+190, y+18, 0xFF666666);
|
||||
drawContext.drawText(textRenderer, Text.literal(valueString), (x+190)-textRenderer.getWidth(valueString), y+4, Moonlight.THEME.text.getRGB(), false);
|
||||
drawContext.fill(x+2, y+16, x+190, y+18, 0xFF777777);
|
||||
int scaledValue = (int)((value/max)*190);
|
||||
DrawableHelper.fill(matrices, x+2, y+16, (x+2)+scaledValue, y+18, 0xFF55FFFF);
|
||||
DrawableHelper.fill(matrices, x+2+(scaledValue-1), y+14, x+2+(scaledValue+1), y+20, 0xFFFFFFFF);
|
||||
drawContext.fill(x+2, y+16, (x+2)+scaledValue, y+18, Moonlight.THEME.accent.getRGB());
|
||||
drawContext.fill(x+2+(scaledValue-1), y+14, x+2+(scaledValue+1), y+20, Moonlight.THEME.border.getRGB());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package me.kawaiizenbo.moonlight.module.settings;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.util.DrawUtils;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class IndexSetting extends Setting
|
||||
{
|
||||
public int index;
|
||||
public String[] elements;
|
||||
|
||||
public IndexSetting(String name, int index, String... elements)
|
||||
{
|
||||
this.name = name;
|
||||
this.index = index;
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
@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.drawText(textRenderer, Text.literal(name), x+2, y+8, Moonlight.THEME.text.getRGB(), false);
|
||||
drawContext.fill(x+96, y+5, x+190, y+19, Moonlight.THEME.border.getRGB());
|
||||
drawContext.fill(x+97, y+6, x+189, y+18, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
|
||||
drawContext.drawText(textRenderer, elements[index], x+98, y+8, Moonlight.THEME.text.getRGB(), false);
|
||||
drawContext.drawGuiTexture(RenderLayer::getGuiTextured, DrawUtils.getThemedGUIIcon("updown", Moonlight.THEME.background), x+177, y+6, 12, 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
if (hovered((int)mouseX, (int)mouseY) && button == 0)
|
||||
{
|
||||
if (index >= elements.length-1) index = 0;
|
||||
else index++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package me.kawaiizenbo.moonlight.module.settings;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.util.KeycodeUtils;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class KeycodeSetting extends Setting
|
||||
{
|
||||
public int value;
|
||||
private boolean isWaiting = false;
|
||||
|
||||
public KeycodeSetting(String name, int value)
|
||||
{
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
if (isWaiting)
|
||||
{
|
||||
isWaiting = false;
|
||||
return;
|
||||
}
|
||||
if (hovered((int)mouseX, (int)mouseY) && button == 0)
|
||||
{
|
||||
isWaiting = true;
|
||||
}
|
||||
}
|
||||
|
||||
@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.drawText(textRenderer, Text.literal(name), x+2, y+8, Moonlight.THEME.text.getRGB(), false);
|
||||
if (isWaiting)
|
||||
{
|
||||
String waiting = "Press any key.";
|
||||
int twwidth = textRenderer.getWidth(waiting);
|
||||
drawContext.drawText(textRenderer, waiting, x+190-twwidth, y+8, Moonlight.THEME.text.getRGB(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
String key = KeycodeUtils.keyTable[value];
|
||||
if (value == GLFW.GLFW_KEY_UNKNOWN) key = "";
|
||||
int twidth = textRenderer.getWidth(key);
|
||||
drawContext.drawText(textRenderer, key, x+190-twidth, y+8, Moonlight.THEME.text.getRGB(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
if (isWaiting)
|
||||
{
|
||||
if (keyCode == 256)
|
||||
{
|
||||
// escape was pressed, exit safely
|
||||
isWaiting = false;
|
||||
return;
|
||||
}
|
||||
value = keyCode;
|
||||
isWaiting = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +1,19 @@
|
|||
package me.kawaiizenbo.moonlight.module.settings;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
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)
|
||||
public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
DrawableHelper.fill(matrices, x, y, x+192, y+height, hovered(mouseX, mouseY) ? 0xFF444444: 0xFF222222);
|
||||
drawContext.fill(x, y, x+192, y+24, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB(): Moonlight.THEME.background.getRGB());
|
||||
|
||||
}
|
||||
|
||||
|
@ -28,6 +25,6 @@ public class Setting
|
|||
|
||||
protected boolean hovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseX <= x + 192 && mouseY >= y && mouseY <= y + height;
|
||||
return mouseX >= x && mouseX <= x + 192 && mouseY >= y && mouseY <= y + 24;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,72 @@
|
|||
package me.kawaiizenbo.moonlight.module.settings;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.util.KeycodeUtils;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class StringSetting extends Setting
|
||||
{
|
||||
public String value;
|
||||
private boolean focused = false;
|
||||
|
||||
public StringSetting(String name, String value)
|
||||
{
|
||||
this.name = name;
|
||||
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.drawText(textRenderer, Text.literal(name), x+2, y+8, Moonlight.THEME.text.getRGB(), false);
|
||||
int twidth = textRenderer.getWidth(value);
|
||||
drawContext.fill(x+96, y+5, x+190, y+19, Moonlight.THEME.border.getRGB());
|
||||
drawContext.fill(x+97, y+6, x+189, y+18, Moonlight.THEME.background.getRGB());
|
||||
int cursorPos = x+98+twidth;
|
||||
if (focused) drawContext.fill(cursorPos, y+7, cursorPos+1, y+17, Moonlight.THEME.accent.getRGB());
|
||||
drawContext.drawText(textRenderer, value, x+98, y+8, Moonlight.THEME.text.getRGB(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
if (focused)
|
||||
{
|
||||
focused = false;
|
||||
return;
|
||||
}
|
||||
if (hovered((int)mouseX, (int)mouseY) && button == 0)
|
||||
{
|
||||
focused = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
if (focused)
|
||||
{
|
||||
if (keyCode == 256 || keyCode == 257)
|
||||
{
|
||||
// escape or enter was pressed, exit safely
|
||||
focused = false;
|
||||
return;
|
||||
}
|
||||
if (keyCode == 259)
|
||||
{
|
||||
// backspace, remove a character
|
||||
if (value.length() > 0) value = value.substring(0, value.length() - 1);
|
||||
return;
|
||||
}
|
||||
if (keyCode > 96) return; // not a typing key
|
||||
String append = KeycodeUtils.keyTable[keyCode];
|
||||
if (modifiers == 1) append = KeycodeUtils.shiftedKeyTable[keyCode];
|
||||
if (append == "Unknown") return;
|
||||
if (append == "Space") append = " ";
|
||||
value += append;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
81
src/main/java/me/kawaiizenbo/moonlight/theme/Theme.java
Normal file
|
@ -0,0 +1,81 @@
|
|||
package me.kawaiizenbo.moonlight.theme;
|
||||
|
||||
public class Theme
|
||||
{
|
||||
public static final Theme LIGHT = new Theme(
|
||||
"Light",
|
||||
new ThemeColor(0x222222),
|
||||
new ThemeColor(0xFFFFFF),
|
||||
new ThemeColor(0xFFFFFF),
|
||||
new ThemeColor(0xDDDDDD),
|
||||
new ThemeColor(0x00AAAA),
|
||||
new ThemeColor(0x55FFFF),
|
||||
new ThemeColor(0x222222),
|
||||
false,
|
||||
false
|
||||
);
|
||||
public static final Theme HIGHCONTRAST = new Theme(
|
||||
"High Contrast",
|
||||
new ThemeColor(0x000000),
|
||||
new ThemeColor(0xFFFFFF),
|
||||
new ThemeColor(0xFFFFFF),
|
||||
new ThemeColor(0x777777),
|
||||
new ThemeColor(0x00AAAA),
|
||||
new ThemeColor(0xFFFFFF),
|
||||
new ThemeColor(0x000000),
|
||||
false,
|
||||
true
|
||||
);
|
||||
public static final Theme DARK = new Theme(
|
||||
"Dark",
|
||||
new ThemeColor(0xFFFFFF),
|
||||
new ThemeColor(0xFFFFFF),
|
||||
new ThemeColor(0x222222),
|
||||
new ThemeColor(0x333333),
|
||||
new ThemeColor(0x55FFFF),
|
||||
new ThemeColor(0x55FFFF),
|
||||
new ThemeColor(0xFFFFFF),
|
||||
false,
|
||||
false
|
||||
);
|
||||
public static final Theme[] THEME_LIST =
|
||||
{
|
||||
LIGHT, HIGHCONTRAST, DARK
|
||||
};
|
||||
|
||||
public String name;
|
||||
public ThemeColor text;
|
||||
public ThemeColor headerText;
|
||||
public ThemeColor background;
|
||||
public ThemeColor hover;
|
||||
public ThemeColor accent;
|
||||
public ThemeColor hudAccent;
|
||||
public ThemeColor border;
|
||||
public boolean useDarkIcons;
|
||||
public boolean themedWindowBorders;
|
||||
|
||||
public Theme(
|
||||
String name,
|
||||
ThemeColor text,
|
||||
ThemeColor headerText,
|
||||
ThemeColor background,
|
||||
ThemeColor hover,
|
||||
ThemeColor accent,
|
||||
ThemeColor hudAccent,
|
||||
ThemeColor border,
|
||||
boolean useDarkIcons,
|
||||
boolean themedWindowBorders
|
||||
)
|
||||
{
|
||||
this.name = name;
|
||||
this.text = text;
|
||||
this.headerText = headerText;
|
||||
this.background = background;
|
||||
this.hover = hover;
|
||||
this.accent = accent;
|
||||
this.hudAccent = hudAccent;
|
||||
this.border = border;
|
||||
this.useDarkIcons = useDarkIcons;
|
||||
this.themedWindowBorders = themedWindowBorders;
|
||||
}
|
||||
}
|
32
src/main/java/me/kawaiizenbo/moonlight/theme/ThemeColor.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package me.kawaiizenbo.moonlight.theme;
|
||||
|
||||
public class ThemeColor
|
||||
{
|
||||
public int r, g, b;
|
||||
|
||||
public ThemeColor(int r, int g, int b)
|
||||
{
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public ThemeColor(int RGBcolor)
|
||||
{
|
||||
this.r = (RGBcolor&0x00FF0000)>>16;
|
||||
this.g = (RGBcolor&0x0000FF00)>>8;
|
||||
this.b = (RGBcolor&0x000000FF)>>0;
|
||||
}
|
||||
|
||||
public int getRGB()
|
||||
{
|
||||
return ((255&0x0ff)<<24)|((r&0x0ff)<<16)|((g&0x0ff)<<8)|(b&0x0ff);
|
||||
}
|
||||
|
||||
public void setRGB(int RGBcolor)
|
||||
{
|
||||
this.r = RGBcolor&0x00FF0000;
|
||||
this.g = RGBcolor&0x0000FF00;
|
||||
this.b = RGBcolor&0x000000FF;
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package me.kawaiizenbo.moonlight.ui;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import me.kawaiizenbo.moonlight.util.MathUtils;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class HUD
|
||||
{
|
||||
public static HUD INSTANCE = new HUD();
|
||||
private MinecraftClient mc = MinecraftClient.getInstance();
|
||||
TextRenderer textRenderer = mc.textRenderer;
|
||||
|
||||
public void renderHUD(MatrixStack matrix, int scaledWidth, int scaledHeight)
|
||||
{
|
||||
// do not draw if F3 enabled
|
||||
if (mc.options.debugEnabled) return;
|
||||
|
||||
// draw stats
|
||||
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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
private double moveSpeed()
|
||||
{
|
||||
Vec3d move = new Vec3d(mc.player.getX() - mc.player.prevX, 0, mc.player.getZ() - mc.player.prevZ).multiply(20);
|
||||
|
||||
return Math.abs(MathUtils.length2D(move)) ;
|
||||
}
|
||||
}
|
45
src/main/java/me/kawaiizenbo/moonlight/ui/LegacyHUD.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package me.kawaiizenbo.moonlight.ui;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import me.kawaiizenbo.moonlight.util.MathUtils;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class LegacyHUD
|
||||
{
|
||||
// This is deprecated and will be removed in a later version
|
||||
public static LegacyHUD INSTANCE = new LegacyHUD();
|
||||
private MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public void render(DrawContext drawContext, int scaledWidth, int scaledHeight)
|
||||
{
|
||||
// do not draw if F3 enabled
|
||||
if (mc.getDebugHud().shouldShowDebugHud()) return;
|
||||
|
||||
// draw stats
|
||||
drawContext.drawTextWithShadow(mc.textRenderer, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], 2, 2, 0xFF55FFFF);
|
||||
drawContext.drawTextWithShadow(mc.textRenderer, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), 2, 12, 0xFF55FFFF);
|
||||
drawContext.drawTextWithShadow(mc.textRenderer, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), 2, scaledHeight - 20, 0xFF55FFFF);
|
||||
|
||||
// draw coordinates
|
||||
drawContext.drawTextWithShadow(mc.textRenderer,
|
||||
"X: " + ColorUtils.gray + String.format("%.1f", mc.player.getX()) + ColorUtils.reset +
|
||||
" Y: " + ColorUtils.gray + String.format("%.1f", mc.player.getY()) + ColorUtils.reset +
|
||||
" Z: " + ColorUtils.gray + String.format("%.1f", mc.player.getZ()), 2, scaledHeight - 10, 0xFF55FFFF
|
||||
);
|
||||
|
||||
// draw client tag
|
||||
drawContext.drawTextWithShadow(mc.textRenderer, Moonlight.clientTag + " " + Moonlight.versionTag,
|
||||
scaledWidth - mc.textRenderer.getWidth(Moonlight.clientTag + " " + Moonlight.versionTag) - 2, scaledHeight - 10, 16777215);
|
||||
}
|
||||
|
||||
private double moveSpeed()
|
||||
{
|
||||
Vec3d move = new Vec3d(mc.player.getX() - mc.player.prevX, 0, mc.player.getZ() - mc.player.prevZ).multiply(20);
|
||||
|
||||
return Math.abs(MathUtils.length2D(move)) ;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package me.kawaiizenbo.moonlight.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class ModulesListOverlay
|
||||
{
|
||||
// this will be replaced with a new hud version at some point
|
||||
|
||||
public static ModulesListOverlay INSTANCE = new ModulesListOverlay();
|
||||
private MinecraftClient mc = MinecraftClient.getInstance();
|
||||
private ArrayList<Module> enabledModules = ModuleManager.INSTANCE.getEnabledModules();
|
||||
|
||||
public void render(DrawContext drawContext, int scaledWidth, int scaledHeight)
|
||||
{
|
||||
// do not draw if F3 enabled
|
||||
if (mc.getDebugHud().shouldShowDebugHud()) return;
|
||||
|
||||
int yOffset = 0;
|
||||
for (Module m : enabledModules)
|
||||
{
|
||||
if (!m.showInModulesList.value) continue;
|
||||
int nameWidth = mc.textRenderer.getWidth(m.name);
|
||||
drawContext.fill(scaledWidth - nameWidth - 8, yOffset, scaledWidth, yOffset+12, 0x77222222);
|
||||
drawContext.fill(scaledWidth - 2, yOffset, scaledWidth, yOffset+12, 0xFF55FFFF);
|
||||
drawContext.drawText(mc.textRenderer, m.name, scaledWidth - nameWidth - 4, yOffset + 2, 0xFFFFFFFF, false);
|
||||
yOffset += 12;
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
enabledModules = ModuleManager.INSTANCE.getEnabledModules();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package me.kawaiizenbo.moonlight.ui;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class SetScreenButton
|
||||
{
|
||||
String text;
|
||||
Screen screen;
|
||||
int x, y, width;
|
||||
|
||||
public SetScreenButton(String text, int x, int y, Screen screen)
|
||||
{
|
||||
this.text = text;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.screen = screen;
|
||||
}
|
||||
|
||||
public void render(DrawContext drawContext, TextRenderer textRenderer, int mouseX, int mouseY, int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
width = textRenderer.getWidth(text);
|
||||
drawContext.fill(x-1, y-1, x + width + 1, y + 10, hovered(mouseX, mouseY) ? 0x22222222 : 0);
|
||||
drawContext.drawText(textRenderer, Text.literal(text), x, y, Moonlight.THEME.headerText.getRGB(), false);
|
||||
}
|
||||
|
||||
public boolean hovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 10;
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY)
|
||||
{
|
||||
if (hovered(mouseX, mouseY))
|
||||
{
|
||||
MinecraftClient.getInstance().setScreen(screen);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package me.kawaiizenbo.moonlight.ui;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class TextButton
|
||||
{
|
||||
String text;
|
||||
int x, y, color, width;
|
||||
|
||||
public TextButton(String text, int x, int y, int color)
|
||||
{
|
||||
this.text = text;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, TextRenderer textRenderer, int mouseX, int mouseY)
|
||||
{
|
||||
width = textRenderer.getWidth(text);
|
||||
DrawableHelper.fill(matrices, x-1, y-1, x + width + 1, y + 10, hovered(mouseX, mouseY) ? 0xFF444444 : 0xFF222222);
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, Text.literal(text), x, y, color);
|
||||
}
|
||||
|
||||
public boolean hovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 10;
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY)
|
||||
{
|
||||
if (hovered(mouseX, mouseY))
|
||||
{
|
||||
// i have no clue how to pass a method so this is kind of stupid
|
||||
MinecraftClient.getInstance().setScreen(ClickGUIScreen.INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package me.kawaiizenbo.moonlight.ui.altmanager;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class AltManagerScreen extends Screen
|
||||
{
|
||||
public static AltManagerScreen INSTANCE = new AltManagerScreen();
|
||||
|
||||
protected AltManagerScreen()
|
||||
{
|
||||
super(Text.literal("Alt Manager"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackgroundTexture(0);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package me.kawaiizenbo.moonlight.ui.clickgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
import me.kawaiizenbo.moonlight.util.DrawUtils;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class CategoryPane
|
||||
{
|
||||
public Category category;
|
||||
public int x, y, height, width = 96;
|
||||
int startX, startY;
|
||||
boolean dragging = false;
|
||||
public boolean collapsed = false;
|
||||
ArrayList<ModuleButton> moduleButtons;
|
||||
Identifier icon;
|
||||
|
||||
public CategoryPane(Category category, int initialX, int initialY, boolean collapsed)
|
||||
{
|
||||
this.category = category;
|
||||
this.x = initialX;
|
||||
this.y = initialY;
|
||||
this.collapsed = collapsed;
|
||||
moduleButtons = new ArrayList<ModuleButton>();
|
||||
icon = DrawUtils.getThemedGUIIcon(category.name.toLowerCase());
|
||||
for (Module m : ModuleManager.INSTANCE.getModulesByCategory(category))
|
||||
{
|
||||
moduleButtons.add(new ModuleButton(m));
|
||||
}
|
||||
if (moduleButtons.size() == 0) collapsed = true;
|
||||
height = (moduleButtons.size()*12) + 18;
|
||||
}
|
||||
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta, TextRenderer textRenderer)
|
||||
{
|
||||
if (dragging)
|
||||
{
|
||||
x = mouseX - startX;
|
||||
y = mouseY - startY;
|
||||
}
|
||||
drawContext.fill(x, y, x+width, collapsed ? y+16 : y+height, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : category.color);
|
||||
//drawContext.fill(x+2, y+2, x+(width-2), y+14, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
|
||||
drawContext.drawGuiTexture(RenderLayer::getGuiTextured, icon, x+2, y+2, 12, 12);
|
||||
drawContext.drawText(textRenderer, category.name, x+16, y+4, Moonlight.THEME.headerText.getRGB(), false);
|
||||
if (!collapsed)
|
||||
{
|
||||
int buttonYOffset = y+16;
|
||||
for (ModuleButton m : moduleButtons)
|
||||
{
|
||||
m.render(drawContext, mouseX, mouseY, x+2, buttonYOffset, textRenderer);
|
||||
buttonYOffset += 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x+2 && mouseX <= x+(width-2) && mouseY >= y+2 && mouseY <= y+14;
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int button)
|
||||
{
|
||||
for (ModuleButton moduleButton : moduleButtons)
|
||||
{
|
||||
if (moduleButton.mouseClicked(mouseX, mouseY, button)) return;
|
||||
}
|
||||
if (hovered(mouseX, mouseY) && button == 1) collapsed = !collapsed;
|
||||
else if (hovered(mouseX, mouseY) && button == 0)
|
||||
{
|
||||
startX = (int)mouseX-x;
|
||||
startY = (int)mouseY-y;
|
||||
dragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(int mouseX, int mouseY, int button)
|
||||
{
|
||||
dragging = false;
|
||||
}
|
||||
}
|
|
@ -1,62 +1,76 @@
|
|||
package me.kawaiizenbo.moonlight.ui.clickgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.module.Category;
|
||||
import me.kawaiizenbo.moonlight.module.ModuleManager;
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import me.kawaiizenbo.moonlight.theme.Theme;
|
||||
import me.kawaiizenbo.moonlight.util.MathUtils;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
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 static ClickGUIScreen INSTANCE = new ClickGUIScreen();
|
||||
public static ArrayList<ModuleButton> moduleButtons;
|
||||
public ArrayList<CategoryPane> categoryPanes;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ClickGUIScreen()
|
||||
{
|
||||
super(Text.literal("ClickGUI"));
|
||||
moduleButtons = new ArrayList<>();
|
||||
int yOffset;
|
||||
categoryPanes = new ArrayList<CategoryPane>();
|
||||
Map<String, Object> panePos = ((Map<String, Object>)Moonlight.CONFIG.config.get("panes"));
|
||||
for (Category category : Category.values())
|
||||
{
|
||||
yOffset = 25;
|
||||
for (Module_ module : ModuleManager.INSTANCE.getModulesByCategory(category))
|
||||
{
|
||||
moduleButtons.add(new ModuleButton(module, 9+(module.category.ordinal()*70), yOffset));
|
||||
yOffset += 14;
|
||||
if(category.name == "Special") continue;
|
||||
int xOffset = MathUtils.d2iSafe(((Map<String, Object>)panePos.get(category.name)).get("x"));
|
||||
int yOffset = MathUtils.d2iSafe(((Map<String, Object>)panePos.get(category.name)).get("y"));
|
||||
boolean collapsed = (boolean)((Map<String, Object>)panePos.get(category.name)).get("collapsed");
|
||||
categoryPanes.add(new CategoryPane(category, xOffset, yOffset, collapsed));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground(matrices);
|
||||
int categoryLabelXOffset = 10;
|
||||
for (Category category : Category.values())
|
||||
this.renderBackground(drawContext, mouseX, mouseY, delta);
|
||||
drawContext.fill(width-80, height-16, width, height, Moonlight.THEME.border.getRGB());
|
||||
drawContext.fill(width-78, height-14, width-2, height-2, (mouseX > width-80 && mouseY > height-16) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
|
||||
drawContext.drawText(textRenderer, "Change Theme", width-75, height-12, Moonlight.THEME.text.getRGB(), false);
|
||||
for (CategoryPane category : categoryPanes)
|
||||
{
|
||||
textRenderer.draw(matrices, category.name, categoryLabelXOffset, 10, 0xFFFFFF);
|
||||
categoryLabelXOffset += 70;
|
||||
}
|
||||
for (ModuleButton moduleButton : moduleButtons)
|
||||
{
|
||||
moduleButton.render(matrices, mouseX, mouseY);
|
||||
category.render(drawContext, mouseX, mouseY, delta, textRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
for (ModuleButton modButton : moduleButtons)
|
||||
for (CategoryPane category : categoryPanes)
|
||||
{
|
||||
modButton.mouseClicked((int) mouseX, (int) mouseY, button);
|
||||
category.mouseClicked((int) mouseX, (int) mouseY, button);
|
||||
}
|
||||
if (mouseX > width-80 && mouseY > height-16)
|
||||
{
|
||||
if (Moonlight.THEME_IDX >= Theme.THEME_LIST.length-1) Moonlight.THEME_IDX = 0;
|
||||
else Moonlight.THEME_IDX++;
|
||||
Moonlight.THEME = Theme.THEME_LIST[Moonlight.THEME_IDX];
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button)
|
||||
{
|
||||
for (CategoryPane category : categoryPanes)
|
||||
{
|
||||
category.mouseReleased((int) mouseX, (int) mouseY, button);
|
||||
}
|
||||
return super.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPause()
|
||||
{
|
||||
|
|
|
@ -1,31 +1,29 @@
|
|||
package me.kawaiizenbo.moonlight.ui.clickgui;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
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;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class ModuleButton
|
||||
{
|
||||
public Module_ module;
|
||||
public Module module;
|
||||
public int x, y, width, height = 0;
|
||||
private MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public ModuleButton(Module_ module, int x, int y)
|
||||
public ModuleButton(Module module)
|
||||
{
|
||||
this.module = module;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 70;
|
||||
this.height = 14;
|
||||
this.width = 92;
|
||||
this.height = 12;
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY)
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, int x, int y, TextRenderer textRenderer)
|
||||
{
|
||||
TextRenderer textRenderer = mc.textRenderer;
|
||||
DrawableHelper.fill(matrices, x, y, x + width, y + height, hovered(mouseX, mouseY) ? 0xFF333333 : 0xFF222222);
|
||||
textRenderer.draw(matrices, module.name, x+3, y+3, module.enabled ? 0x55FFFF : 0xFFFFFF);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
drawContext.fill(x, y, x + width, y + height, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
|
||||
drawContext.drawText(textRenderer, module.name, x+2, y+2, module.enabled ? Moonlight.THEME.accent.getRGB() : Moonlight.THEME.text.getRGB(), false);
|
||||
}
|
||||
|
||||
public boolean hovered(int mouseX, int mouseY)
|
||||
|
@ -33,7 +31,7 @@ public class ModuleButton
|
|||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int button)
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int button)
|
||||
{
|
||||
if (hovered(mouseX, mouseY))
|
||||
{
|
||||
|
@ -45,6 +43,8 @@ public class ModuleButton
|
|||
{
|
||||
MinecraftClient.getInstance().setScreen(new SettingsScreen(module));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,62 @@
|
|||
package me.kawaiizenbo.moonlight.ui.clickgui;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import me.kawaiizenbo.moonlight.module.settings.Setting;
|
||||
import me.kawaiizenbo.moonlight.ui.TextButton;
|
||||
import me.kawaiizenbo.moonlight.ui.SetScreenButton;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.editor.HUDEditorScreen;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class SettingsScreen extends Screen
|
||||
{
|
||||
private Module_ module;
|
||||
private TextButton backButton;
|
||||
private Module module;
|
||||
private SetScreenButton backButton;
|
||||
private SetScreenButton editButton;
|
||||
|
||||
protected SettingsScreen(Module_ module)
|
||||
boolean dragging = false;
|
||||
int startX, startY, x = (ClickGUIScreen.INSTANCE.width/2)-112, y = (ClickGUIScreen.INSTANCE.height/2)-96, windowWidth = 224, windowHeight = 192;
|
||||
|
||||
public SettingsScreen(Module module)
|
||||
{
|
||||
super(Text.literal("Settings"));
|
||||
backButton = new SetScreenButton(ColorUtils.underline + "< Back", x+4, y+4, ClickGUIScreen.INSTANCE);
|
||||
editButton = new SetScreenButton(ColorUtils.underline + "Edit", x+windowWidth-22, y+4, HUDEditorScreen.INSTANCE);
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground(matrices);
|
||||
DrawableHelper.fill(matrices, (width/2)-112, (height/2)-96, (width/2)+112, (height/2)+96, 0xFF222222);
|
||||
DrawableHelper.drawCenteredText(matrices, textRenderer, module.name, width/2, (height/2)-88, 0xFFFFFF);
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, Text.literal(module.description), (width/2)-104, (height/2)-72, 0xFFFFFF);
|
||||
backButton = new TextButton(ColorUtils.underline + "< Back", (width/2)-104, (height/2)-88, 0xFFFFFF);
|
||||
backButton.render(matrices, textRenderer, mouseX, mouseY);
|
||||
int yOffset = (height/2)-56;
|
||||
this.renderBackground(drawContext, mouseX, mouseY, delta);
|
||||
|
||||
// move window if dragging
|
||||
if (dragging)
|
||||
{
|
||||
x = mouseX - startX;
|
||||
y = mouseY - startY;
|
||||
}
|
||||
drawContext.fill(x, y, x+windowWidth, y+windowHeight, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : module.category.color);
|
||||
drawContext.fill(x+2, y+2, x+windowWidth-2, y+windowHeight-2, Moonlight.THEME.background.getRGB());
|
||||
drawContext.fill(x, y, x+windowWidth, y+16, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : module.category.color);
|
||||
//drawContext.fill(x+2, y+2, x+(windowWidth-2), y+14, Moonlight.THEME.background.getRGB());
|
||||
drawContext.drawText(textRenderer, module.name, x+((windowWidth/2)-(textRenderer.getWidth(module.name)/2)), y+4, Moonlight.THEME.headerText.getRGB(), false);
|
||||
drawContext.drawText(textRenderer, module.description, x+8, y+24, Moonlight.THEME.text.getRGB(), false);
|
||||
backButton.render(drawContext, textRenderer, mouseX, mouseY, x+4, y+4);
|
||||
if (module.showEditButton) editButton.render(drawContext, textRenderer, mouseX, mouseY, x+windowWidth-22, y+4);
|
||||
int yOffset = y+40;
|
||||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.render(matrices, (width/2)-96, yOffset, mouseX, mouseY);
|
||||
yOffset += setting.height + 1;
|
||||
setting.render(drawContext, x+16, yOffset, mouseX, mouseY, textRenderer);
|
||||
yOffset += 25;
|
||||
}
|
||||
// add keybind setting here eventually
|
||||
}
|
||||
|
||||
public boolean barHovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +68,14 @@ public class SettingsScreen extends Screen
|
|||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
if (barHovered((int)mouseX, (int)mouseY))
|
||||
{
|
||||
startX = (int)mouseX-x;
|
||||
startY = (int)mouseY-y;
|
||||
dragging = true;
|
||||
}
|
||||
backButton.mouseClicked((int)mouseX, (int)mouseY);
|
||||
editButton.mouseClicked((int)mouseX, (int)mouseY);
|
||||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.mouseClicked(mouseX, mouseY, button);
|
||||
|
@ -58,6 +86,7 @@ public class SettingsScreen extends Screen
|
|||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button)
|
||||
{
|
||||
dragging = false;
|
||||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.mouseReleased(mouseX, mouseY, button);
|
||||
|
|
68
src/main/java/me/kawaiizenbo/moonlight/ui/hud/HUDModule.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.module.settings.Setting;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public abstract class HUDModule
|
||||
{
|
||||
public int x, y, height, width;
|
||||
public String name;
|
||||
int startX, startY;
|
||||
boolean dragging = false;
|
||||
public boolean enabled = false;
|
||||
public ArrayList<Setting> settings;
|
||||
|
||||
protected static MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public HUDModule(String name, int x, int y)
|
||||
{
|
||||
this.name = name;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
settings = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
|
||||
{
|
||||
if (editMode)
|
||||
{
|
||||
if (dragging)
|
||||
{
|
||||
x = mouseX - startX;
|
||||
y = mouseY - startY;
|
||||
}
|
||||
drawContext.fill(x-1, y-1, x+width+1, y+height+1, enabled ? Moonlight.THEME.accent.getRGB() : 0xFF555555);
|
||||
drawContext.fill(x, y, x+width, y+height, 0xFF222222);
|
||||
}
|
||||
}
|
||||
|
||||
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) && button == 0)
|
||||
{
|
||||
startX = (int)mouseX-x;
|
||||
startY = (int)mouseY-y;
|
||||
dragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(int mouseX, int mouseY, int button)
|
||||
{
|
||||
dragging = false;
|
||||
}
|
||||
|
||||
public void toggle()
|
||||
{
|
||||
enabled = !enabled;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.hud.modules.*;
|
||||
|
||||
public class HUDModuleManager
|
||||
{
|
||||
public static HUDModuleManager INSTANCE = new HUDModuleManager();
|
||||
public ArrayList<HUDModule> modules = new ArrayList<>();
|
||||
|
||||
public HUDModuleManager()
|
||||
{
|
||||
registerModules(
|
||||
new ClientTag(2, 2),
|
||||
new FPS(2, 12),
|
||||
new Ping(2, 22),
|
||||
new MovementSpeed(2, 32),
|
||||
new Coordinates(2, 42),
|
||||
new ArmorDisplay(2, 52),
|
||||
new TotemCounter(20, 52)
|
||||
//new TestModuleHUD(20, 50)
|
||||
);
|
||||
}
|
||||
|
||||
private void registerModules(HUDModule... modules)
|
||||
{
|
||||
for (HUDModule module : modules) {
|
||||
this.modules.add(module);
|
||||
}
|
||||
}
|
||||
|
||||
public HUDModule getModuleByName(String moduleName)
|
||||
{
|
||||
for(HUDModule module : modules)
|
||||
{
|
||||
if ((module.name.trim().equalsIgnoreCase(moduleName)))
|
||||
{
|
||||
return module;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<HUDModule> getEnabledModules()
|
||||
{
|
||||
ArrayList<HUDModule> enabledModules = new ArrayList<>();
|
||||
for (HUDModule module : modules)
|
||||
{
|
||||
if (!module.enabled)
|
||||
continue;
|
||||
enabledModules.add(module);
|
||||
}
|
||||
return enabledModules;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class HUDRenderer
|
||||
{
|
||||
public static HUDRenderer INSTANCE = new HUDRenderer();
|
||||
private MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public void render(DrawContext drawContext)
|
||||
{
|
||||
// do not draw if F3 enabled
|
||||
if (mc.getDebugHud().shouldShowDebugHud()) return;
|
||||
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.getEnabledModules())
|
||||
{
|
||||
// mouse coords are not needed when not in edit mode
|
||||
h.render(drawContext, 0, 0, mc.textRenderer, false, true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.editor;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModuleManager;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class HUDEditorScreen extends Screen
|
||||
{
|
||||
public static HUDEditorScreen INSTANCE = new HUDEditorScreen();
|
||||
HUDModuleList moduleList;
|
||||
|
||||
public HUDEditorScreen()
|
||||
{
|
||||
super(Text.literal("HUD Editor"));
|
||||
moduleList = new HUDModuleList(256, 2, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground(drawContext, mouseX, mouseY, delta);
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
h.render(drawContext, mouseX, mouseY, textRenderer, true, h.enabled);
|
||||
}
|
||||
moduleList.render(drawContext, mouseX, mouseY, delta, textRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
h.mouseClicked((int)mouseX, (int)mouseY, button);
|
||||
}
|
||||
moduleList.mouseClicked((int)mouseX, (int)mouseY, button);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button)
|
||||
{
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
h.mouseReleased((int)mouseX, (int)mouseY, button);
|
||||
}
|
||||
moduleList.mouseReleased((int)mouseX, (int)mouseY, button);
|
||||
return super.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPause()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.editor;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class HUDModuleButton
|
||||
{
|
||||
public HUDModule module;
|
||||
public int x, y, width, height = 0;
|
||||
|
||||
public HUDModuleButton(HUDModule module)
|
||||
{
|
||||
this.module = module;
|
||||
this.width = 124;
|
||||
this.height = 12;
|
||||
}
|
||||
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, int x, int y, TextRenderer textRenderer)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
drawContext.fill(x, y, x + width, y + height, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
|
||||
drawContext.drawText(textRenderer, module.name, x+2, y+2, module.enabled ? Moonlight.THEME.accent.getRGB() : Moonlight.THEME.text.getRGB(), false);
|
||||
if (!module.settings.isEmpty()) drawContext.drawGuiTexture(RenderLayer::getGuiTextured, Identifier.of("moonlight", "settings"), x+width-12, y, 12, 12);
|
||||
}
|
||||
|
||||
public boolean hovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
|
||||
}
|
||||
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int button)
|
||||
{
|
||||
if (hovered(mouseX, mouseY))
|
||||
{
|
||||
if (button == 0)
|
||||
{
|
||||
module.toggle();
|
||||
}
|
||||
else if (button == 1)
|
||||
{
|
||||
if (!module.settings.isEmpty()) MinecraftClient.getInstance().setScreen(new HUDModuleSettingsScreen(module));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.editor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModuleManager;
|
||||
import me.kawaiizenbo.moonlight.util.DrawUtils;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class HUDModuleList
|
||||
{
|
||||
public int x, y, height, width = 128;
|
||||
int startX, startY;
|
||||
boolean dragging = false;
|
||||
public boolean collapsed = false;
|
||||
ArrayList<HUDModuleButton> buttons;
|
||||
|
||||
public HUDModuleList(int initialX, int initialY, boolean collapsed)
|
||||
{
|
||||
this.x = initialX;
|
||||
this.y = initialY;
|
||||
this.collapsed = collapsed;
|
||||
buttons = new ArrayList<HUDModuleButton>();
|
||||
for (HUDModule m : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
buttons.add(new HUDModuleButton(m));
|
||||
}
|
||||
if (buttons.size() == 0) collapsed = true;
|
||||
height = (buttons.size()*12) + 18;
|
||||
}
|
||||
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta, TextRenderer textRenderer)
|
||||
{
|
||||
if (dragging)
|
||||
{
|
||||
x = mouseX - startX;
|
||||
y = mouseY - startY;
|
||||
}
|
||||
drawContext.fill(x, y, x+width, collapsed ? y+16 : y+height, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : Moonlight.THEME.accent.getRGB());
|
||||
//drawContext.fill(x+2, y+2, x+(width-2), y+14, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
|
||||
drawContext.drawGuiTexture(RenderLayer::getGuiTextured, DrawUtils.getThemedGUIIcon("hud"), x+2, y+2, 12, 12);
|
||||
drawContext.drawText(textRenderer, "HUD Modules", x+16, y+4, Moonlight.THEME.headerText.getRGB(), false);
|
||||
if (!collapsed)
|
||||
{
|
||||
int buttonYOffset = y+16;
|
||||
for (HUDModuleButton m : buttons)
|
||||
{
|
||||
m.render(drawContext, mouseX, mouseY, x+2, buttonYOffset, textRenderer);
|
||||
buttonYOffset += 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x+2 && mouseX <= x+(width-2) && mouseY >= y+2 && mouseY <= y+14;
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int button)
|
||||
{
|
||||
for (HUDModuleButton moduleButton : buttons)
|
||||
{
|
||||
if (moduleButton.mouseClicked(mouseX, mouseY, button)) return;
|
||||
}
|
||||
if (hovered(mouseX, mouseY) && button == 1) collapsed = !collapsed;
|
||||
else if (hovered(mouseX, mouseY) && button == 0)
|
||||
{
|
||||
startX = (int)mouseX-x;
|
||||
startY = (int)mouseY-y;
|
||||
dragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(int mouseX, int mouseY, int button)
|
||||
{
|
||||
dragging = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.editor;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.module.settings.Setting;
|
||||
import me.kawaiizenbo.moonlight.ui.SetScreenButton;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class HUDModuleSettingsScreen extends Screen
|
||||
{
|
||||
// adapted for hud modules
|
||||
private HUDModule module;
|
||||
private SetScreenButton backButton;
|
||||
|
||||
boolean dragging = false;
|
||||
int startX, startY, x = (HUDEditorScreen.INSTANCE.width/2)-112, y = (HUDEditorScreen.INSTANCE.height/2)-96, windowWidth = 224, windowHeight = 192;
|
||||
|
||||
public HUDModuleSettingsScreen(HUDModule module)
|
||||
{
|
||||
super(Text.literal("Settings"));
|
||||
backButton = new SetScreenButton(ColorUtils.underline + "< Back", x+4, y+4, HUDEditorScreen.INSTANCE);
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground(drawContext, mouseX, mouseY, delta);
|
||||
|
||||
// move window if dragging
|
||||
if (dragging)
|
||||
{
|
||||
x = mouseX - startX;
|
||||
y = mouseY - startY;
|
||||
}
|
||||
drawContext.fill(x, y, x+windowWidth, y+windowHeight, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : Moonlight.THEME.accent.getRGB());
|
||||
drawContext.fill(x+2, y+2, x+windowWidth-2, y+windowHeight-2, Moonlight.THEME.background.getRGB());
|
||||
drawContext.fill(x, y, x+windowWidth, y+16, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : Moonlight.THEME.accent.getRGB());
|
||||
//drawContext.fill(x+2, y+2, x+(windowWidth-2), y+14, Moonlight.THEME.background.getRGB());
|
||||
drawContext.drawText(textRenderer, module.name, x+((windowWidth/2)-(textRenderer.getWidth(module.name)/2)), y+4, Moonlight.THEME.headerText.getRGB(), false);
|
||||
backButton.render(drawContext, textRenderer, mouseX, mouseY, x+4, y+4);
|
||||
int yOffset = y+24;
|
||||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.render(drawContext, x+16, yOffset, mouseX, mouseY, textRenderer);
|
||||
yOffset += 25;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean barHovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPause()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
if (barHovered((int)mouseX, (int)mouseY))
|
||||
{
|
||||
startX = (int)mouseX-x;
|
||||
startY = (int)mouseY-y;
|
||||
dragging = true;
|
||||
}
|
||||
backButton.mouseClicked((int)mouseX, (int)mouseY);
|
||||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button)
|
||||
{
|
||||
dragging = false;
|
||||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
return super.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.keyPressed(keyCode, scanCode, modifiers);
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, modifiers);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ArmorDisplay extends HUDModule
|
||||
{
|
||||
|
||||
public ArmorDisplay(int x, int y)
|
||||
{
|
||||
super("Armor Display", x, y);
|
||||
this.width = 16;
|
||||
this.height = 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
|
||||
{
|
||||
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
|
||||
int yOffset = 0;
|
||||
for (int i = 39; i >= 36; i--)
|
||||
{
|
||||
ItemStack piece = mc.player.getInventory().getStack(i);
|
||||
drawContext.drawItem(piece, x, y+yOffset);
|
||||
drawContext.drawStackOverlay(textRenderer, piece, x, y+yOffset);
|
||||
yOffset += 16;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class ClientTag extends HUDModule
|
||||
{
|
||||
public ClientTag(int x, int y)
|
||||
{
|
||||
super("Client Tag", x, y);
|
||||
this.width = 128;
|
||||
this.height = 8;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
|
||||
{
|
||||
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
|
||||
drawContext.drawTextWithShadow(mc.textRenderer, Moonlight.clientTag + " " + Moonlight.versionTag, x, y, 16777215);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class Coordinates extends HUDModule
|
||||
{
|
||||
public Coordinates(int x, int y)
|
||||
{
|
||||
super("Coordinates", x, y);
|
||||
this.width = 128;
|
||||
this.height = 8;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
|
||||
{
|
||||
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
|
||||
drawContext.drawTextWithShadow(mc.textRenderer,
|
||||
"X: " + ColorUtils.gray + String.format("%.1f", mc.player.getX()) + ColorUtils.reset +
|
||||
" Y: " + ColorUtils.gray + String.format("%.1f", mc.player.getY()) + ColorUtils.reset +
|
||||
" Z: " + ColorUtils.gray + String.format("%.1f", mc.player.getZ()), x, y, Moonlight.THEME.hudAccent.getRGB()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class FPS extends HUDModule
|
||||
{
|
||||
public FPS(int x, int y)
|
||||
{
|
||||
super("FPS", x, y);
|
||||
this.width = 48;
|
||||
this.height = 8;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
|
||||
{
|
||||
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
|
||||
drawContext.drawTextWithShadow(mc.textRenderer, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], x, y, Moonlight.THEME.hudAccent.getRGB());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import me.kawaiizenbo.moonlight.util.MathUtils;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class MovementSpeed extends HUDModule
|
||||
{
|
||||
public MovementSpeed(int x, int y)
|
||||
{
|
||||
super("Movement Speed", x, y);
|
||||
this.width = 72;
|
||||
this.height = 8;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
|
||||
{
|
||||
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
|
||||
drawContext.drawTextWithShadow(mc.textRenderer, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), x, y, Moonlight.THEME.hudAccent.getRGB());
|
||||
}
|
||||
|
||||
private double moveSpeed()
|
||||
{
|
||||
Vec3d move = new Vec3d(mc.player.getX() - mc.player.prevX, 0, mc.player.getZ() - mc.player.prevZ).multiply(20);
|
||||
return Math.abs(MathUtils.length2D(move)) ;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class Ping extends HUDModule
|
||||
{
|
||||
public Ping(int x, int y)
|
||||
{
|
||||
super("Ping", x, y);
|
||||
this.width = 48;
|
||||
this.height = 8;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
|
||||
{
|
||||
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
|
||||
drawContext.drawTextWithShadow(mc.textRenderer, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), x, y, Moonlight.THEME.hudAccent.getRGB());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.settings.DoubleSetting;
|
||||
import me.kawaiizenbo.moonlight.module.settings.StringSetting;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class TestModuleHUD extends HUDModule
|
||||
{
|
||||
public StringSetting text = new StringSetting("Text", "hii :3");
|
||||
public DoubleSetting number = new DoubleSetting("test", 1, 0, 10, 0);
|
||||
|
||||
public TestModuleHUD(int x, int y)
|
||||
{
|
||||
super("Test HUD Module", x, y);
|
||||
this.width = 96;
|
||||
this.height = 8;
|
||||
settings.add(text);
|
||||
settings.add(number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
|
||||
{
|
||||
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
|
||||
drawContext.drawText(textRenderer, text.value, x, y, 0xFFFFFF, false);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
|
||||
public class TotemCounter extends HUDModule
|
||||
{
|
||||
|
||||
public TotemCounter(int x, int y)
|
||||
{
|
||||
super("Totem Counter", x, y);
|
||||
this.width = 24;
|
||||
this.height = 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
|
||||
{
|
||||
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
|
||||
int count = 0;
|
||||
for (int i = 0; i < 36; i++)
|
||||
{
|
||||
ItemStack stack = mc.player.getInventory().getStack(i);
|
||||
if (stack.getItem() == Items.TOTEM_OF_UNDYING) count += stack.getCount();
|
||||
}
|
||||
drawContext.drawItem(Items.TOTEM_OF_UNDYING.getDefaultStack(), x, y);
|
||||
drawContext.drawTextWithShadow(textRenderer, count+"", x+16, y+8, 16777215);
|
||||
}
|
||||
}
|
|
@ -1,29 +1,15 @@
|
|||
package me.kawaiizenbo.moonlight.util;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
public class ChatUtils
|
||||
{
|
||||
private static MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public static void sendMsg(String message)
|
||||
{
|
||||
sendMsg(null, null, Text.literal(message));
|
||||
}
|
||||
|
||||
public static void sendMsg(@Nullable String prefixTitle, @Nullable Formatting prefixColor, Text msg)
|
||||
{
|
||||
if (mc.world == null) return;
|
||||
|
||||
//Text message = Text.literal("");
|
||||
//message.append(CommandManager.get().getPrefix());
|
||||
//if (prefixTitle != null) message.append(CommandManager.get().getPrefix());
|
||||
//message.append(msg);
|
||||
|
||||
mc.inGameHud.getChatHud().addMessage(msg);
|
||||
mc.inGameHud.getChatHud().addMessage(Text.literal(message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,14 @@ 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);
|
||||
}
|
||||
|
||||
public static int rgbToInt(int r, int g, int b)
|
||||
{
|
||||
return ((r&0x0ff)<<16)|((g&0x0ff)<<8)|(b&0x0ff);
|
||||
}
|
||||
}
|
||||
|
|
21
src/main/java/me/kawaiizenbo/moonlight/util/DrawUtils.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package me.kawaiizenbo.moonlight.util;
|
||||
|
||||
import me.kawaiizenbo.moonlight.Moonlight;
|
||||
import me.kawaiizenbo.moonlight.theme.ThemeColor;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class DrawUtils
|
||||
{
|
||||
public static Identifier getThemedGUIIcon(String textureName, ThemeColor invert)
|
||||
{
|
||||
boolean mode = ((invert.r + invert.g + invert.b) / 3) > 77;
|
||||
String addition = mode ? "_light" : "";
|
||||
return Identifier.of("moonlight", textureName+addition);
|
||||
}
|
||||
|
||||
public static Identifier getThemedGUIIcon(String textureName)
|
||||
{
|
||||
String addition = Moonlight.THEME.useDarkIcons ? "_light" : "";
|
||||
return Identifier.of("moonlight", textureName+addition);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package me.kawaiizenbo.moonlight.util;
|
||||
|
||||
public interface ISimpleOption<T>
|
||||
{
|
||||
public void setValueUnrestricted(T value);
|
||||
}
|
710
src/main/java/me/kawaiizenbo/moonlight/util/KeycodeUtils.java
Normal file
|
@ -0,0 +1,710 @@
|
|||
package me.kawaiizenbo.moonlight.util;
|
||||
|
||||
public class KeycodeUtils
|
||||
{
|
||||
public static String[] keyTable = {
|
||||
"",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Space",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"'",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
",",
|
||||
"-",
|
||||
".",
|
||||
"/",
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"Unknown",
|
||||
";",
|
||||
"Unknown",
|
||||
"=",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
"f",
|
||||
"g",
|
||||
"h",
|
||||
"i",
|
||||
"j",
|
||||
"k",
|
||||
"l",
|
||||
"m",
|
||||
"n",
|
||||
"o",
|
||||
"p",
|
||||
"q",
|
||||
"r",
|
||||
"s",
|
||||
"t",
|
||||
"u",
|
||||
"v",
|
||||
"w",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"[",
|
||||
"\\",
|
||||
"]",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"`",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"World 1",
|
||||
"World 2",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Escape",
|
||||
"Enter",
|
||||
"Tab",
|
||||
"Backspace",
|
||||
"Insert",
|
||||
"Delete",
|
||||
"Right",
|
||||
"Left",
|
||||
"Down",
|
||||
"Up",
|
||||
"Page Up",
|
||||
"Page Down",
|
||||
"Home",
|
||||
"End",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Caps Lock",
|
||||
"Scroll Lock",
|
||||
"Num Lock",
|
||||
"Print Screen",
|
||||
"Pause",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"F1",
|
||||
"F2",
|
||||
"F3",
|
||||
"F4",
|
||||
"F5",
|
||||
"F6",
|
||||
"F7",
|
||||
"F8",
|
||||
"F9",
|
||||
"F10",
|
||||
"F11",
|
||||
"F12",
|
||||
"F13",
|
||||
"F14",
|
||||
"F15",
|
||||
"F16",
|
||||
"F17",
|
||||
"F18",
|
||||
"F19",
|
||||
"F20",
|
||||
"F21",
|
||||
"F22",
|
||||
"F23",
|
||||
"F24",
|
||||
"F25",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Num 0",
|
||||
"Num 1",
|
||||
"Num 2",
|
||||
"Num 3",
|
||||
"Num 4",
|
||||
"Num 5",
|
||||
"Num 6",
|
||||
"Num 7",
|
||||
"Num 8",
|
||||
"Num 9",
|
||||
"Num .",
|
||||
"Num /",
|
||||
"Num *",
|
||||
"Num -",
|
||||
"Num +",
|
||||
"Num Enter",
|
||||
"Num =",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Left Shift",
|
||||
"Left Control",
|
||||
"Left Alt",
|
||||
"Left Command",
|
||||
"Right Shift",
|
||||
"Right Control",
|
||||
"Right Alt",
|
||||
"Right Command",
|
||||
"Menu",
|
||||
"Last",
|
||||
};
|
||||
|
||||
public static String[] shiftedKeyTable = {
|
||||
"",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Space",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"\"",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"<",
|
||||
"_",
|
||||
">",
|
||||
"?",
|
||||
")",
|
||||
"!",
|
||||
"@",
|
||||
"#",
|
||||
"$",
|
||||
"%",
|
||||
"^",
|
||||
"&",
|
||||
"*",
|
||||
"(",
|
||||
"Unknown",
|
||||
":",
|
||||
"Unknown",
|
||||
"+",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H",
|
||||
"I",
|
||||
"J",
|
||||
"K",
|
||||
"L",
|
||||
"M",
|
||||
"N",
|
||||
"O",
|
||||
"P",
|
||||
"Q",
|
||||
"R",
|
||||
"S",
|
||||
"T",
|
||||
"U",
|
||||
"V",
|
||||
"W",
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"{",
|
||||
"|",
|
||||
"}",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"~",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"World 1",
|
||||
"World 2",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Escape",
|
||||
"Enter",
|
||||
"Tab",
|
||||
"Backspace",
|
||||
"Insert",
|
||||
"Delete",
|
||||
"Right",
|
||||
"Left",
|
||||
"Down",
|
||||
"Up",
|
||||
"Page Up",
|
||||
"Page Down",
|
||||
"Home",
|
||||
"End",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Caps Lock",
|
||||
"Scroll Lock",
|
||||
"Num Lock",
|
||||
"Print Screen",
|
||||
"Pause",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"F1",
|
||||
"F2",
|
||||
"F3",
|
||||
"F4",
|
||||
"F5",
|
||||
"F6",
|
||||
"F7",
|
||||
"F8",
|
||||
"F9",
|
||||
"F10",
|
||||
"F11",
|
||||
"F12",
|
||||
"F13",
|
||||
"F14",
|
||||
"F15",
|
||||
"F16",
|
||||
"F17",
|
||||
"F18",
|
||||
"F19",
|
||||
"F20",
|
||||
"F21",
|
||||
"F22",
|
||||
"F23",
|
||||
"F24",
|
||||
"F25",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Num 0",
|
||||
"Num 1",
|
||||
"Num 2",
|
||||
"Num 3",
|
||||
"Num 4",
|
||||
"Num 5",
|
||||
"Num 6",
|
||||
"Num 7",
|
||||
"Num 8",
|
||||
"Num 9",
|
||||
"Num .",
|
||||
"Num /",
|
||||
"Num *",
|
||||
"Num -",
|
||||
"Num +",
|
||||
"Num Enter",
|
||||
"Num =",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Left Shift",
|
||||
"Left Control",
|
||||
"Left Alt",
|
||||
"Left Command",
|
||||
"Right Shift",
|
||||
"Right Control",
|
||||
"Right Alt",
|
||||
"Right Command",
|
||||
"Menu",
|
||||
"Last",
|
||||
};
|
||||
}
|
|
@ -17,6 +17,19 @@ public class MathUtils
|
|||
return bd.doubleValue();
|
||||
}
|
||||
|
||||
public static int d2iSafe(Object value)
|
||||
{
|
||||
int out = 0;
|
||||
try
|
||||
{
|
||||
out = (int)Math.floor((double)value);
|
||||
} catch (Exception e)
|
||||
{
|
||||
out = (int)value;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static double length2D(Vec3d vec3d)
|
||||
{
|
||||
return MathHelper.sqrt((float)(vec3d.x * vec3d.x + vec3d.z * vec3d.z));
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
32
src/main/java/me/kawaiizenbo/moonlight/util/Timer.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package me.kawaiizenbo.moonlight.util;
|
||||
|
||||
public class Timer
|
||||
{
|
||||
public long lastMS = System.currentTimeMillis();
|
||||
|
||||
public void reset()
|
||||
{
|
||||
lastMS = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean hasTimeElapsed(long time, boolean reset)
|
||||
{
|
||||
if (lastMS > System.currentTimeMillis())
|
||||
{
|
||||
lastMS = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis()-lastMS > time)
|
||||
{
|
||||
if (reset) reset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 167 B |
After Width: | Height: | Size: 366 B |
After Width: | Height: | Size: 190 B |
After Width: | Height: | Size: 382 B |
BIN
src/main/resources/assets/moonlight/textures/gui/sprites/hud.png
Normal file
After Width: | Height: | Size: 354 B |
After Width: | Height: | Size: 358 B |
After Width: | Height: | Size: 181 B |