Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1eed6f957 | ||
|
|
c993d4fdac | ||
|
|
a9fd8da7f5 | ||
|
|
9b6d037b6c | ||
|
|
86594f1ca3 | ||
|
|
f074f05c51 | ||
|
|
436b79fd2b | ||
|
|
9afaa4e0c8 | ||
|
|
f794457538 | ||
|
|
ec3e633cec | ||
|
|
8f17bd8e67 | ||
|
|
dc2429918e | ||
|
|
94a9b1dade | ||
|
|
48899f85f9 | ||
|
|
347ec658bb | ||
|
|
a9cf6dd924 | ||
|
|
8e44dda9cf | ||
|
|
2329476fe4 | ||
|
|
6b2ec0e69a | ||
|
|
6fa409d60a | ||
|
|
4f816381c3 | ||
|
|
36c38bdf02 | ||
|
|
a6a6f1261e | ||
|
|
8891a57c7c | ||
|
|
e358b142c6 | ||
|
|
e7d872d75e | ||
|
|
589279342d | ||
|
|
054702999b |
No files matched your search
@@ -39,4 +39,8 @@ replay_*.log
|
||||
*.hprof
|
||||
*.jfr
|
||||
|
||||
todo.txt
|
||||
# otros
|
||||
|
||||
todo.txt
|
||||
cambios.md
|
||||
remappedSrc/
|
||||
@@ -1,28 +1,34 @@
|
||||
# jenny's mod 2 100% real
|
||||
|
||||
mod para Minecraft Fabric 1.21.6 que añade algunas cosas QOL, mayormente relacionadas a la cámara.
|
||||
mod para Minecraft Fabric 1.21.11 que añade algunas cosas QOL, mayormente relacionadas a la cámara.
|
||||
|
||||
## instalación
|
||||
|
||||
### para gente normal:
|
||||
1. ir a [lanzamientos](https://github.com/retuci0/camera-tweaks/releases)
|
||||
1. ir a [lanzamientos](https://github.com/retuci0/sputnik/releases)
|
||||
2. selecionar la versión más reciente
|
||||
3. descargar el .jar
|
||||
4. moverlo a tu directorio de mods (probablemente `%appdata%/.minecraft/mods`)
|
||||
|
||||
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod
|
||||
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `1.21.11`; Fabric `0.17.3`)
|
||||
es posible que haya problemas al usarlo junto a otros mods, especialmente junto a otros clientes, pues pueden conflictar entre ellos.
|
||||
|
||||
### para frikis de 200 de iq
|
||||
1. clona el respositorio
|
||||
2. `gradlew build` para Windows o `chmod +x gradlew` + `./gradlew build` para Linux
|
||||
3. el resultado estará en `/build/libs` (el que no lleva "sources" en el nombre)
|
||||
1. clona el respositorio (`git clone https://github.com/retuci0/sputnik`)
|
||||
2. entra al directorio del repositorio (`cd sputnik`)
|
||||
3. `gradlew build` para Windows o `chmod +x gradlew` + `./gradlew build` para Linux (Mac es Linux)
|
||||
4. el resultado estará en `/build/libs/sputnik-X.X.jar` (el que no lleva "sources" en el nombre)
|
||||
|
||||
## uso
|
||||
|
||||
`shift derecho` por defecto para abrir la interfaz
|
||||
|
||||
`pág. arriba` por defecto para abrir el editor del hud
|
||||
|
||||
`$` como prefijo por defecto para comandos (se autocompletan)
|
||||
|
||||
algunos módulos tienen teclas asignadas por defecto, asígnales `ESC` para desactivar sus atajos de teclado
|
||||
|
||||
## interfaz
|
||||
|
||||
- clic izquierdo para activar / desactivar módulos
|
||||
@@ -37,14 +43,18 @@ asegúrate de tener una version de Minecraft y Fabric compatibles con el mod
|
||||
- shift mientras pasas el puntero por encima de un ajuste de modos para ver los modos disponibles
|
||||
- clic derecho para ciclar hacia atrás en ajustes de modo
|
||||
- usa la rueda del ratón para mover la interfaz verticalmente
|
||||
- shift + rueda del ratón para mover todos los marcos a un rango visible en la pantalla
|
||||
|
||||
## capturas
|
||||
|
||||
<img src="screenshots/2025-08-19_23.20.15.png" alt="captura 1 (foto vieja)">
|
||||
<img src="screenshots/2025-08-22_00.18.51.png" alt="captura 2 (interfaz)">
|
||||
<img src="screenshots/2025-08-22_00.19.11.png" alt="captura 3 (interfaz)">
|
||||
<img src="screenshots/2025-08-22_00.22.41.png" alt="captura 5 (comandos)">
|
||||
<img src="screenshots/2025-08-27_18.44.41.png" alt="captura 6 (nametags & apilar bossbars)">
|
||||
<img src="screenshots/ui.png" alt="interfaz">
|
||||
<img src="screenshots/nametags.png" alt="nametags mostrando daño de un tridente">
|
||||
<img src="screenshots/chatplus.png" alt="chatplus y capturas en uso">
|
||||
<img src="screenshots/crits.png" alt="críticos">
|
||||
<img src="screenshots/fullbright.png" alt="fullbright en modo gamma cambiando el color de los shaders">
|
||||
<img src="screenshots/hud.png" alt="HUD">
|
||||
<img src="screenshots/hudeditor.png" alt="editor de HUD">
|
||||
<img src="screenshots/colorpicker.png" alt="selector de colores">
|
||||
|
||||
## contibuciones
|
||||
|
||||
@@ -52,4 +62,26 @@ sí por favor
|
||||
|
||||
## licencia
|
||||
|
||||
no sé, haz lo que quieras con esto, es puta basura xd
|
||||
no sé, haz lo que quieras con esto, es puta basura xd
|
||||
|
||||
aunque estaría guay que acreditases
|
||||
|
||||
pero bueno
|
||||
|
||||
## descargo de responsabilidad
|
||||
|
||||
me importa una puta mierda lo que pase al usar este mod en servers donde es baneable y así.
|
||||
|
||||
## mods recomendados
|
||||
|
||||
> mods que recomiendo usar junto a este:
|
||||
|
||||
- [fabric api (necesario)](https://modrinth.com/mod/fabric-api/): necesario para el mod
|
||||
- [sodium](https://modrinth.com/mod/sodium): mejora el rendimiento general del juego
|
||||
- [viafabricplus](https://modrinth.com/mod/viafabricplus): te permite conectarte a servidores que tengan una versión distinta a la de tu cliente
|
||||
- [xaero's world map](https://modrinth.com/mod/xaeros-world-map/) y [xaero's minimap](https://modrinth.com/mod/xaeros-minimap/): mapa chulo
|
||||
- [mod menu](https://modrinth.com/mod/modmenu): lista de los mods instalados, y sus ajustes
|
||||
- [iris](https://modrinth.com/mod/iris): shaders
|
||||
- [lambdynamiclights](https://modrinth.com/mod/lambdynamiclights): iluminación dinámica
|
||||
- [appleskin](https://modrinth.com/mod/appleskin/): información relacionada con la comida
|
||||
- [baritone (desactualizado)](https://github.com/cabaletta/baritone): google maps para juego de cubos
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version "${loom_version}"
|
||||
id 'maven-publish'
|
||||
id 'fabric-loom' version "${loom_version}"
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
@@ -11,22 +11,34 @@ base {
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven {
|
||||
name = "FDD Maven"
|
||||
url = "https://maven.firstdark.dev/releases"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// To change the versions see the gradle.properties file
|
||||
// mc
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
// mappings
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
|
||||
// fabric & su api
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
|
||||
// sistema de eventos
|
||||
modImplementation "com.github.retuci0:neutrino:${project.neutrino_version}"
|
||||
|
||||
// rpc de discord
|
||||
include(modImplementation "dev.firstdark.discordrpc:discord-rpc:1.0.3")
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/sputnik.accesswidener")
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -42,11 +54,6 @@ tasks.withType(JavaCompile).configureEach {
|
||||
}
|
||||
|
||||
java {
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
@@ -55,11 +62,12 @@ jar {
|
||||
inputs.property "archivesName", project.base.archivesName
|
||||
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${inputs.properties.archivesName}"}
|
||||
rename {
|
||||
"${it}_${inputs.properties.archivesName}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
create("mavenJava", MavenPublication) {
|
||||
@@ -68,11 +76,5 @@ publishing {
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
// Notice: This block does NOT have the same function as the block in the top level.
|
||||
// The repositories here will be used for publishing your artifact, not for
|
||||
// retrieving dependencies.
|
||||
}
|
||||
repositories {}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# v3.3
|
||||
|
||||
## novedades
|
||||
|
||||
- cambiado de sistema de eventos
|
||||
- categoría de inventario
|
||||
|
||||
### adiciones
|
||||
|
||||
#### módulos nuevos:
|
||||
|
||||
- reponer: repone items a medida que se usan de forma automática
|
||||
|
||||
### arreglos / mejoras
|
||||
|
||||
- ahora el grosor de línea de hitboxes funciona
|
||||
- ahora cabezas de chatplus funciona, a medias
|
||||
|
||||
## problemas reconocidos
|
||||
|
||||
- es posible que algunos módulos hayan dejado de funcionar correctamente, ya que he cambiado de sistema de eventos
|
||||
- muchos, pero repórtalos en la página de problemas si quieres para que queden bien registrados
|
||||
@@ -1,4 +1,15 @@
|
||||
meteor client dev team
|
||||
oyvey client (1.21 port by mioclient)
|
||||
lennyboi (youtube)
|
||||
packbar by cattyn on github
|
||||
Meteor Client: https://github.com/MeteorDevelopment/meteor-client | https://meteorclient.com
|
||||
OyVey Port: https://github.com/mioclient/oyvey-ported/
|
||||
Lenny Boi: https://www.youtube.com/@lennyboi7195
|
||||
Shotify: https://modrinth.com/mod/shotify
|
||||
No Telemetry: https://modrinth.com/mod/no-telemetry
|
||||
Trouser Streak: https://github.com/etianl/Trouser-Streak
|
||||
No More Purple: https://github.com/Pepperoni-Jabroni/NoMorePurple/
|
||||
bypass-resource-pack: https://github.com/emilyy-dev/bypass-resource-pack
|
||||
elytra-recast: https://github.com/InLieuOfLuna/elytra-recast/
|
||||
SpearHax: https://github.com/etianl/spearHax/
|
||||
ProjectileTrajectoryPreview: https://github.com/maDU59/ProjectilesTrajectoryPreview
|
||||
DupersUnited public addon: https://discord.gg/dupes | https://dupers.wtf
|
||||
|
||||
probablemente más pero como tengo demencia se me olvida
|
||||
si quieres que te acredite o quite tu código de mi mod, mándame un mensaje en discord (username: retucio) y sin problemas :)
|
||||
@@ -1,18 +1,15 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.21.6
|
||||
yarn_mappings=1.21.6+build.1
|
||||
loader_version=0.17.2
|
||||
loom_version=1.11-SNAPSHOT
|
||||
minecraft_version=1.21.11
|
||||
yarn_mappings=1.21.11+build.3
|
||||
loader_version=0.18.4
|
||||
loom_version=1.13-SNAPSHOT
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.1
|
||||
fabric_api_version=0.140.2+1.21.11
|
||||
|
||||
neutrino_version=1.1.0
|
||||
|
||||
mod_version=3.3
|
||||
maven_group=me.retucio
|
||||
archives_base_name=camtweaks
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.128.2+1.21.6
|
||||
archives_base_name=sputnik
|
||||
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 973 KiB |
|
Before Width: | Height: | Size: 1005 KiB |
|
Before Width: | Height: | Size: 942 KiB |
|
Before Width: | Height: | Size: 560 KiB |
|
Before Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 864 KiB |
|
After Width: | Height: | Size: 915 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 566 KiB |
|
After Width: | Height: | Size: 469 KiB |
|
After Width: | Height: | Size: 243 KiB |
|
After Width: | Height: | Size: 506 KiB |
|
After Width: | Height: | Size: 691 KiB |
@@ -1,158 +0,0 @@
|
||||
package me.retucio.camtweaks;
|
||||
|
||||
|
||||
import me.retucio.camtweaks.command.CommandManager;
|
||||
import me.retucio.camtweaks.command.commands.BindCommand;
|
||||
|
||||
import me.retucio.camtweaks.config.ConfigManager;
|
||||
|
||||
import me.retucio.camtweaks.event.EventBus;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.ShutdownEvent;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.buttons.BindButton;
|
||||
import me.retucio.camtweaks.ui.buttons.SettingButton;
|
||||
import me.retucio.camtweaks.ui.buttons.TextButton;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import me.retucio.camtweaks.util.MiscUtil;
|
||||
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
|
||||
|
||||
public class CameraTweaks implements ClientModInitializer {
|
||||
|
||||
// cosas necesarias
|
||||
public static final String MOD_ID = "camtweaks";
|
||||
public static final CameraTweaks INSTANCE = new CameraTweaks();
|
||||
public static final Logger LOGGER = LogManager.getLogger(CameraTweaks.class);
|
||||
public static final EventBus EVENT_BUS = new EventBus();
|
||||
public static MinecraftClient mc;
|
||||
|
||||
private Screen prevScreen;
|
||||
private boolean settingsApplied = false;
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
mc = MinecraftClient.getInstance();
|
||||
|
||||
ModuleManager.INSTANCE = new ModuleManager(EVENT_BUS);
|
||||
CommandManager.INSTANCE = new CommandManager();
|
||||
ClickGUI.INSTANCE = new ClickGUI();
|
||||
|
||||
ConfigManager.load();
|
||||
|
||||
EVENT_BUS.register(this);
|
||||
EVENT_BUS.register(MiscUtil.class);
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
ConfigManager.save();
|
||||
EVENT_BUS.post(new ShutdownEvent());
|
||||
}));
|
||||
}
|
||||
|
||||
// se ejecuta cada tick, es decir, 20 veces por segundo
|
||||
public void onTick() {
|
||||
ModuleManager.INSTANCE.getEnabledModules().forEach(Module::onTick);
|
||||
|
||||
if (!settingsApplied
|
||||
&& ConfigManager.getConfig() != null
|
||||
&& mc.player != null && mc.world != null) {
|
||||
ConfigManager.applyConfig();
|
||||
settingsApplied = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// se ejecuta cada vez que se presiona una tecla
|
||||
public void onKeyPress(int key, int action) {
|
||||
ModuleManager.INSTANCE.getEnabledModules().forEach(module -> module.onKey(key, action));
|
||||
|
||||
boolean anyFocused = isAnySettingButtonFocused();
|
||||
ClickGUI.INSTANCE.setAnyFocused(anyFocused);
|
||||
|
||||
if (action == GLFW.GLFW_PRESS) {
|
||||
if (BindCommand.onKeyPress(key)) return;
|
||||
handleSettingButtonsKey(key, action);
|
||||
handleModuleToggle(key, anyFocused);
|
||||
handleClickGUIKey(key, anyFocused);
|
||||
} else if (action == GLFW.GLFW_RELEASE && !anyFocused) {
|
||||
handleModuleRelease(key);
|
||||
}
|
||||
}
|
||||
|
||||
// verifica si algún botón de ajustes está escuchando
|
||||
private boolean isAnySettingButtonFocused() {
|
||||
for (SettingsFrame sf : ClickGUI.INSTANCE.getSettingsFrames())
|
||||
for (SettingButton sb : sf.getButtons())
|
||||
if ((sb instanceof BindButton b && b.isFocused()) || (sb instanceof TextButton t && t.isFocused()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// se ocupa de la lógica de encendido y apagado de los módulos
|
||||
private void handleModuleToggle(int key, boolean anyFocused) {
|
||||
if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return;
|
||||
|
||||
for (Module module : ModuleManager.INSTANCE.getModules()) {
|
||||
if (key != module.getKey() || anyFocused || KeyUtil.isKeyDown(GLFW.GLFW_KEY_F3)) continue; // evitar interrumpir combinaciones de teclas del F3
|
||||
|
||||
if (module.shouldToggleOnBindRelease() && !module.isEnabled())
|
||||
module.setEnabled(true);
|
||||
else if (!module.shouldToggleOnBindRelease())
|
||||
module.toggle();
|
||||
}
|
||||
}
|
||||
|
||||
// se ocupa de hacer los botones de ajustes que lo necesiten escuchar teclas
|
||||
private void handleSettingButtonsKey(int key, int action) {
|
||||
for (SettingsFrame sf : ClickGUI.INSTANCE.getSettingsFrames()) {
|
||||
for (SettingButton sb : sf.getButtons()) {
|
||||
if (sb instanceof BindButton b) b.onKey(key, action);
|
||||
else if (sb instanceof TextButton t) t.onKey(key, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// maneja la lógica de apertura de la interfaz
|
||||
private void handleClickGUIKey(int key, boolean anyFocused) {
|
||||
if (key != ClickGUISettingsFrame.guiSettings.getKey() || anyFocused) return;
|
||||
|
||||
if (mc.currentScreen != ClickGUI.INSTANCE) {
|
||||
prevScreen = mc.currentScreen;
|
||||
mc.setScreen(ClickGUI.INSTANCE);
|
||||
} else {
|
||||
mc.setScreen(prevScreen);
|
||||
}
|
||||
}
|
||||
|
||||
// se ocupa de apagar los módulos que tengan configurado hacerlo tras soltar su tecla
|
||||
private void handleModuleRelease(int key) {
|
||||
if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return;
|
||||
|
||||
for (Module module : ModuleManager.INSTANCE.getEnabledModules())
|
||||
if (module.shouldToggleOnBindRelease() && key == module.getKey())
|
||||
module.setEnabled(false);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onStop(ShutdownEvent event) {
|
||||
ConfigManager.save();
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.inventory.EnderChestInventory;
|
||||
import net.minecraft.inventory.Inventories;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.SimpleInventory;
|
||||
import net.minecraft.screen.GenericContainerScreenHandler;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
// accede a los contenidos de tu enderchest
|
||||
public class EnderChestCommand extends Command {
|
||||
|
||||
public EnderChestCommand() {
|
||||
super("echest", "muestra el contenido de tu enderchest", "ec", "enderchest");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(ctx -> {
|
||||
mc.execute(() -> { // para evitar llamar setScreen desde el hilo equivocado, que causa crashes
|
||||
EnderChestInventory enderChestInv = mc.player.getEnderChestInventory();
|
||||
|
||||
// llámame imbécil pero no tengo ni idea de por qué no se abre
|
||||
mc.setScreen(new GenericContainerScreen(
|
||||
GenericContainerScreenHandler.createGeneric9x3(mc.player.currentScreenHandler.syncId + 1, mc.player.getInventory(), enderChestInv),
|
||||
mc.player.getInventory(),
|
||||
Text.translatable("container.enderchest")
|
||||
));
|
||||
});
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
package me.retucio.camtweaks.config;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.settings.*;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
// se ocupa de guardar, cargar y aplicar ajustes
|
||||
// pues no me ha dado dolores de cabeza el coso este con los NPE de los cojones...
|
||||
public class ConfigManager {
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final File CONFIG_FILE = new File("camera_tweaks.json");
|
||||
|
||||
private static ClientConfig config = null;
|
||||
|
||||
// guardar configuraciones
|
||||
public static void save() {
|
||||
ensureConfig();
|
||||
try (FileWriter writer = new FileWriter(CONFIG_FILE)) {
|
||||
GSON.toJson(config, writer);
|
||||
CameraTweaks.LOGGER.info("ajustes guardados");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// cargar configuraciones
|
||||
public static void load() {
|
||||
CameraTweaks.LOGGER.info("ajustes cargados");
|
||||
if (!CONFIG_FILE.exists()) {
|
||||
ensureConfig();
|
||||
save();
|
||||
return;
|
||||
}
|
||||
|
||||
try (FileReader reader = new FileReader(CONFIG_FILE)) {
|
||||
config = GSON.fromJson(reader, ClientConfig.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
ensureConfig();
|
||||
}
|
||||
}
|
||||
|
||||
// aplicar configuraciones cargadas
|
||||
public static void applyConfig() {
|
||||
if (CameraTweaks.mc == null || ModuleManager.INSTANCE == null || config == null)
|
||||
return;
|
||||
|
||||
ModuleManager.INSTANCE.getModules().forEach(module -> {
|
||||
if (config.moduleStates.containsKey(module.getName()))
|
||||
module.setEnabled(config.moduleStates.get(module.getName())); // estados
|
||||
|
||||
module.getSettings().forEach(setting -> applySetting(module, setting));
|
||||
|
||||
if (config.settingsFrames.containsKey(module.getName())) {
|
||||
int[] position = config.settingsFrames.get(module.getName());
|
||||
ClickGUI.INSTANCE.openSettingsFrame(module, position[0], position[1]);
|
||||
}
|
||||
});
|
||||
|
||||
ClickGUISettingsFrame.guiSettings.setEnabled(true);
|
||||
ClickGUISettingsFrame.guiSettings.getSettings().forEach(setting -> applySetting(ClickGUISettingsFrame.guiSettings, setting));
|
||||
|
||||
CameraTweaks.LOGGER.info("módulos encendidos cargados");
|
||||
CameraTweaks.LOGGER.info("ajustes de módulos cargados");
|
||||
|
||||
ClientConfig.FrameData moduleFrameData = config.extendableFrames.get("M");
|
||||
if (moduleFrameData != null) {
|
||||
ClickGUI.INSTANCE.getModulesFrame().x = moduleFrameData.x();
|
||||
ClickGUI.INSTANCE.getModulesFrame().y = moduleFrameData.y();
|
||||
ClickGUI.INSTANCE.getModulesFrame().extended = moduleFrameData.extended();
|
||||
}
|
||||
|
||||
ClientConfig.FrameData guiSettingsData = config.extendableFrames.get("S");
|
||||
if (guiSettingsData != null) {
|
||||
ClickGUI.INSTANCE.getGuiSettingsFrame().x = guiSettingsData.x();
|
||||
ClickGUI.INSTANCE.getGuiSettingsFrame().y = guiSettingsData.y();
|
||||
ClickGUI.INSTANCE.getGuiSettingsFrame().extended = guiSettingsData.extended();
|
||||
}
|
||||
|
||||
CameraTweaks.LOGGER.info("posiciones de frames cargadas");
|
||||
}
|
||||
|
||||
public static ClientConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static void setModuleState(Module module) {
|
||||
ensureConfig();
|
||||
config.moduleStates.put(module.getName(), module.isEnabled());
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setSetting(Setting setting, Object value) {
|
||||
ensureConfig();
|
||||
config.settings.put(setting.getModule().getName() + ":" + setting.getName(), value);
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setFramePosition(SettingsFrame frame) {
|
||||
ensureConfig();
|
||||
config.settingsFrames.put(frame.module.getName(), new int[]{frame.x, frame.y});
|
||||
ConfigManager.save();
|
||||
}
|
||||
|
||||
public static void setExtendableFrame(String key, ClientConfig.FrameData data) {
|
||||
ensureConfig();
|
||||
config.extendableFrames.put(key, data);
|
||||
save();
|
||||
}
|
||||
|
||||
public static void applySetting(Module parent, Setting setting) {
|
||||
String id = parent.getName() + ":" + setting.getName();
|
||||
if (config.settings.containsKey(id)) {
|
||||
Object value = config.settings.get(id);
|
||||
|
||||
switch (setting) {
|
||||
case BooleanSetting b -> b.setEnabled((boolean) value);
|
||||
case EnumSetting e -> e.setIndex(value instanceof Double val ? val.intValue() : (int) value);
|
||||
case NumberSetting n -> n.setValue((double) value);
|
||||
case StringSetting s -> s.setValue((String) value);
|
||||
case KeySetting k -> k.setKey(value instanceof Double val ? val.intValue() : (int) value);
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ensureConfig() {
|
||||
if (config == null) config = new ClientConfig();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.retucio.camtweaks.event;
|
||||
|
||||
// evento base, cancelable (usado en mixins)
|
||||
public class Event {
|
||||
private boolean cancelled;
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
cancelled = true;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package me.retucio.camtweaks.event;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
|
||||
// al llamar un evento, se guarda en el bus de eventos, de donde luego se puede detectar si ese evento ha sucedido
|
||||
public class EventBus {
|
||||
private final Map<Class<?>, List<ListenerMethod>> listeners = new HashMap<>();
|
||||
|
||||
private record ListenerMethod(Object instance, Method method) {}
|
||||
|
||||
public void register(Object listener) {
|
||||
Class<?> targetClass;
|
||||
|
||||
if (listener instanceof Class<?> clazz) {
|
||||
targetClass = clazz; // "listeners" estáticos
|
||||
listener = null;
|
||||
} else {
|
||||
targetClass = listener.getClass();
|
||||
}
|
||||
|
||||
for (Method method : targetClass.getDeclaredMethods()) {
|
||||
if (!method.isAnnotationPresent(SubscribeEvent.class)) continue;
|
||||
if (method.getParameterCount() != 1) continue;
|
||||
|
||||
Class<?> eventType = method.getParameterTypes()[0];
|
||||
method.setAccessible(true);
|
||||
|
||||
if (listener == null && !Modifier.isStatic(method.getModifiers())) continue;
|
||||
|
||||
listeners.computeIfAbsent(eventType, k -> new ArrayList<>())
|
||||
.add(new ListenerMethod(listener, method));
|
||||
}
|
||||
}
|
||||
|
||||
public void subscribe(Object listener) { register(listener); }
|
||||
|
||||
public void unregister(Object listener) {
|
||||
for (List<ListenerMethod> list : listeners.values()) {
|
||||
list.removeIf(lm -> lm.instance == listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void unsubscribe(Object listener) { unregister(listener); }
|
||||
|
||||
public <T extends Event> T post(T event) {
|
||||
List<ListenerMethod> list = listeners.get(event.getClass());
|
||||
if (list != null) {
|
||||
for (ListenerMethod lm : new ArrayList<>(list)) { // copiar para evitar CME
|
||||
try {
|
||||
lm.method.invoke(lm.instance, event);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
public boolean isRegistered(Object listener) {
|
||||
for (List<ListenerMethod> list : listeners.values()) {
|
||||
for (ListenerMethod lm : list) {
|
||||
if (lm.instance == listener) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package me.retucio.camtweaks.event;
|
||||
|
||||
public enum Stage {
|
||||
PRE, // antes de que haya sucedido
|
||||
POST; // después de que haya sucedido
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package me.retucio.camtweaks.event;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
// anotación para registar un "listener", que escucha cuando se llama un evento
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SubscribeEvent {}
|
||||
@@ -1,9 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.ChunkOcclusionDataBuilderMixin#onChunkOcclusion
|
||||
*/
|
||||
|
||||
public class ChunkOcclusionEvent extends Event {}
|
||||
@@ -1,9 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.ClientConnectionMixin#onDisconnect
|
||||
*/
|
||||
|
||||
public class DisconnectEvent extends Event {}
|
||||
@@ -1,12 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onStop
|
||||
*/
|
||||
|
||||
public class ShutdownEvent extends Event {
|
||||
|
||||
public ShutdownEvent() {}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onTickPre
|
||||
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onTickPost
|
||||
*/
|
||||
|
||||
public class TickEvent {
|
||||
|
||||
public static class Pre extends Event {}
|
||||
public static class Post extends Event {}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events.camtweaks;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import me.retucio.camtweaks.module.settings.Setting;
|
||||
|
||||
// se genera cada que se cambia el valor de un ajuste
|
||||
public class UpdateSettingEvent extends Event {
|
||||
|
||||
private final Setting setting;
|
||||
|
||||
public UpdateSettingEvent(Setting setting) {
|
||||
this.setting = setting;
|
||||
}
|
||||
|
||||
public Setting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.item.property.numeric.CompassState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(CompassState.class)
|
||||
public abstract class CompassStateMixin {
|
||||
|
||||
@Unique
|
||||
private static Freecam freecam;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(boolean wobble, CompassState.Target target, CallbackInfo ci) {
|
||||
freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "getBodyYaw", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getBodyYaw()F"))
|
||||
private static float getBodyYaw(float original) {
|
||||
if (freecam.isEnabled()) return mc.gameRenderer.getCamera().getYaw();
|
||||
return original;
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getAngleTo(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/BlockPos;)D", at = @At("RETURN"))
|
||||
private static double getAngleTo(double original, Entity entity, BlockPos blockPos) {
|
||||
if (freecam.isEnabled()) {
|
||||
Vec3d vec3d = Vec3d.ofCenter(blockPos);
|
||||
Camera camera = mc.gameRenderer.getCamera();
|
||||
return Math.atan2(vec3d.getZ() - camera.getPos().z, vec3d.getX() - camera.getPos().x) / (float) (Math.PI * 2);
|
||||
}
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.TimeChanger;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(DimensionType.class)
|
||||
public abstract class DimensionTypeMixin {
|
||||
|
||||
@ModifyReturnValue(method = "getMoonPhase", at = @At("RETURN"))
|
||||
private int overrideMoonPhase(int original) {
|
||||
TimeChanger timeChanger = ModuleManager.INSTANCE.getModuleByClass(TimeChanger.class);
|
||||
if (timeChanger.isEnabled() && mc.world != null && !timeChanger.moonPhase.is(TimeChanger.MoonPhases.DEFAULT))
|
||||
return timeChanger.getMoonPhase();
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.Freelook;
|
||||
import me.retucio.camtweaks.module.modules.Nametags;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.entity.AgeableMobEntityRenderer;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.mob.Monster;
|
||||
import net.minecraft.entity.passive.PassiveEntity;
|
||||
import net.minecraft.entity.passive.TameableEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.PersistentProjectileEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.entity.vehicle.VehicleEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public abstract class EntityMixin {
|
||||
|
||||
@Shadow public int age;
|
||||
|
||||
@Shadow public abstract Text getName();
|
||||
|
||||
@Shadow @Nullable public abstract Text getCustomName();
|
||||
|
||||
@Unique
|
||||
Freecam freecam;
|
||||
|
||||
@Unique
|
||||
Freelook freelook;
|
||||
|
||||
@Unique
|
||||
Nametags nametags;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(EntityType type, World world, CallbackInfo ci) {
|
||||
freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
freelook = ModuleManager.INSTANCE.getModuleByClass(Freelook.class);
|
||||
nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
}
|
||||
|
||||
|
||||
// cámara libre & perspectiva libre
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Inject(method = "changeLookDirection", at = @At("HEAD"), cancellable = true)
|
||||
private void onChangeLookDirection(double cursorDeltaX, double cursorDeltaY, CallbackInfo ci) {
|
||||
if ((Object) this != mc.player) return;
|
||||
|
||||
if (freecam.isEnabled()) {
|
||||
freecam.changeLookDirection(cursorDeltaX * 0.15, cursorDeltaY * 0.15);
|
||||
ci.cancel();
|
||||
|
||||
} else if (freelook.isEnabled() && freelook.mode.is(Freelook.CameraMode.CAMERA)) {
|
||||
freelook.setYaw(freelook.getYaw() + (float) (cursorDeltaX / freelook.mouseSens.getFloatValue()));
|
||||
freelook.setPitch(freelook.getPitch() + (float) (cursorDeltaY / freelook.mouseSens.getFloatValue()));
|
||||
|
||||
if (Math.abs(freelook.getPitch()) > 90.0F) freelook.setPitch(freelook.getPitch() > 0 ? 90 : -90);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// nametags
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@ModifyReturnValue(method = "isCustomNameVisible", at = @At("RETURN"))
|
||||
private boolean renderEntityNametags(boolean original) {
|
||||
if (!nametags.isEnabled()) return original;
|
||||
return switch ((Object) this) {
|
||||
case PlayerEntity player -> nametags.namePlayers.isEnabled();
|
||||
case ItemEntity item -> nametags.nameItems.isEnabled();
|
||||
case ProjectileEntity projectile -> nametags.nameProjectiles.isEnabled();
|
||||
case Monster hostile -> nametags.nameHostileMobs.isEnabled() || original; // monster en vez de HostileEntity para también incluir slimes
|
||||
case PassiveEntity passive -> nametags.namePassiveMobs.isEnabled() || original;
|
||||
case VehicleEntity vehicle -> nametags.nameVehicles.isEnabled();
|
||||
default -> nametags.nameMiscMobs.isEnabled() || original;
|
||||
};
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getName", at = @At("RETURN"))
|
||||
private Text showProjectileDamage(Text original) {
|
||||
if (!nametags.isEnabled() || !nametags.showProjectileDamage.isEnabled()) return original;
|
||||
|
||||
if ((Object) this instanceof PersistentProjectileEntity arrow) { // aunque lo llame "arrow", también cubre flechas espectrales y tridentes
|
||||
float damage = nametags.getArrowDamage(arrow);
|
||||
if (damage > 0) return original.copy().append(Text.literal(" (" + damage + ")").formatted(Formatting.RED));
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@ModifyReturnValue(method = "getCustomName", at = @At("RETURN"))
|
||||
private Text displayEntityOwner(Text original) {
|
||||
if (!nametags.isEnabled() || !nametags.petOwner.isEnabled()) return original;
|
||||
if ((Object) this instanceof TameableEntity entity && entity.getOwnerReference() != null) {
|
||||
if (original != null) return original.copy().append(" (de " + nametags.getOwnerName(entity.getOwnerReference()) + ")");
|
||||
else return Text.of(nametags.getOwnerName(entity.getOwnerReference()));
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@ModifyReturnValue(method = "getName", at = @At("RETURN"))
|
||||
private Text showBabies(Text original) {
|
||||
if (!nametags.isEnabled() || !nametags.distinguishBabies.isEnabled()) return original;
|
||||
if ((Object) this instanceof LivingEntity entity && entity.isBaby()) return original.copy().append(" (baby)");
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.mixin.accessor.EntityRenderStateAccessor;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Nametags;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
import net.minecraft.client.render.entity.state.EntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
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(EntityRenderer.class)
|
||||
public abstract class EntityRendererMixin<S extends EntityRenderState> {
|
||||
|
||||
@Inject(method = "renderLabelIfPresent", at = @At("HEAD"))
|
||||
private void renderSneakingPlayerNametags(S state, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
|
||||
Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
|
||||
if (nametags.isEnabled() && nametags.alwaysVisible.isEnabled())
|
||||
((EntityRenderStateAccessor) state).setSneaking(false);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.ChatPlus;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import me.retucio.camtweaks.ui.HUD;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
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(InGameHud.class)
|
||||
public abstract class InGameHudMixin {
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
private void renderHUD(DrawContext ctx, RenderTickCounter tc, CallbackInfo ci) {
|
||||
HUD.render(ctx, tc);
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z"))
|
||||
private boolean alwaysRenderCrosshairInFreecam(boolean firstPerson) {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || firstPerson;
|
||||
}
|
||||
|
||||
@Inject(method = "clear", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;clear(Z)V"), cancellable = true)
|
||||
private void onClear(CallbackInfo ci) {
|
||||
ChatPlus chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class);
|
||||
if (chatPlus.isEnabled() && chatPlus.keepHistory.isEnabled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.KeyEvent;
|
||||
import net.minecraft.client.Keyboard;
|
||||
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 static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
public abstract class KeyboardMixin {
|
||||
|
||||
@Inject(method = "onKey", at = @At("HEAD"), cancellable = true)
|
||||
private void onKeyPress(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
|
||||
CameraTweaks.INSTANCE.onKeyPress(key, action);
|
||||
|
||||
KeyEvent event = EVENT_BUS.post(new KeyEvent(key, scancode, action));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(LivingEntityRenderer.class)
|
||||
public abstract class LivingEntityRendererMixin {
|
||||
|
||||
@ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getCameraEntity()Lnet/minecraft/entity/Entity;"))
|
||||
private Entity hasLabelGetCameraEntityProxy(Entity cameraEntity) {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() ? null : cameraEntity;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.OpenScreenEvent;
|
||||
import me.retucio.camtweaks.event.events.ShutdownEvent;
|
||||
import me.retucio.camtweaks.event.events.TickEvent;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
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 static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public abstract class MinecraftClientMixin {
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void onTickPre(CallbackInfo ci) {
|
||||
CameraTweaks.INSTANCE.onTick();
|
||||
EVENT_BUS.post(new TickEvent.Pre());
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("TAIL"))
|
||||
private void onTickPost(CallbackInfo ci) {
|
||||
EVENT_BUS.post(new TickEvent.Post());
|
||||
}
|
||||
|
||||
@Inject(method = "stop", at = @At("HEAD"))
|
||||
private void onStop(CallbackInfo ci) {
|
||||
EVENT_BUS.post(new ShutdownEvent());
|
||||
}
|
||||
|
||||
@Inject(method = "setScreen", at = @At("HEAD"), cancellable = true)
|
||||
private void onOpenScreen(Screen screen, CallbackInfo ci) {
|
||||
OpenScreenEvent event = EVENT_BUS.post(new OpenScreenEvent(screen));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Nametags;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
public abstract class PlayerEntityMixin extends LivingEntity {
|
||||
|
||||
protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getDisplayName", at = @At("RETURN"))
|
||||
private Text addHealthIndicator(Text original) {
|
||||
Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
if (nametags.isEnabled() && !nametags.namePlayers.isEnabled()) return null;
|
||||
if (!nametags.isEnabled() || !nametags.health.isEnabled()) return original;
|
||||
|
||||
float health = getHealth();
|
||||
Formatting color;
|
||||
|
||||
if (health < 5) color = Formatting.RED;
|
||||
else if (health < 10) color = Formatting.YELLOW;
|
||||
else if (health < 15) color = Formatting.GREEN;
|
||||
else color = Formatting.DARK_GREEN;
|
||||
|
||||
// me gustaría también añadir un modo en el que se renderizan los corazones directamente en la nametag, pero no sé cómo hacer para las imágenes :'(
|
||||
return original.copy().append(Text.literal(" [" + color + (nametags.healthMode.is(Nametags.HealthMode.HEARTS)
|
||||
? String.format("%.2f", health / 2) : (int) health) + Formatting.RESET + "]"));
|
||||
} // redondear a dos decimales
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.PerspectivePlus;
|
||||
import me.retucio.camtweaks.module.modules.TimeChanger;
|
||||
import net.minecraft.client.render.SkyRendering;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(SkyRendering.class)
|
||||
public abstract class SkyRendererMixin {
|
||||
|
||||
@Unique
|
||||
TimeChanger timeChanger;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(CallbackInfo ci) {
|
||||
timeChanger = ModuleManager.INSTANCE.getModuleByClass(TimeChanger.class);
|
||||
}
|
||||
|
||||
@Inject(method = "renderSun", at = @At("HEAD"), cancellable = true)
|
||||
private void onRenderSun(float alpha, VertexConsumerProvider vertexConsumers, MatrixStack matrices, CallbackInfo ci) {
|
||||
if (timeChanger.isEnabled() && !timeChanger.renderSun.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderMoon", at = @At("HEAD"), cancellable = true)
|
||||
private void onRenderMoon(int phase, float alpha, VertexConsumerProvider vertexConsumers, MatrixStack matrices, CallbackInfo ci) {
|
||||
if (timeChanger.isEnabled() && !timeChanger.renderMoon.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderStars", at = @At("HEAD"), cancellable = true)
|
||||
private void onRenderStars(float brightness, MatrixStack matrices, CallbackInfo ci) {
|
||||
if (timeChanger.isEnabled() && !timeChanger.renderStars.isEnabled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public abstract class WorldRendererMixin {
|
||||
|
||||
@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;setupTerrain(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;ZZ)V"), index = 3)
|
||||
private boolean renderSetupTerrainModifyArg(boolean hasForcedFrustum) {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || hasForcedFrustum;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.render.entity.state.EntityRenderState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(EntityRenderState.class)
|
||||
public interface EntityRenderStateAccessor {
|
||||
|
||||
@Accessor("sneaking")
|
||||
void setSneaking(boolean sneaking);
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package me.retucio.camtweaks.module;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.ToggleModuleEvent;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.module.settings.KeySetting;
|
||||
import me.retucio.camtweaks.module.settings.Setting;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// clase base para los módulos
|
||||
public class Module {
|
||||
|
||||
// atributos
|
||||
private String name;
|
||||
private String description;
|
||||
private boolean enabled;
|
||||
|
||||
// dejar al usuario elegir si el módulo debería apagarse tras soltar su tecla asignada, o si la tecla debería alternar su estado
|
||||
protected EnumSetting<KeyModes> keyMode = new EnumSetting<>("modo de tecla", "cómo interpretar la tecla configurada", KeyModes.class, KeyModes.TOGGLE);
|
||||
protected KeySetting bind = new KeySetting("tecla", "tecla asignada al módulo, ESC para desactivar", GLFW.GLFW_KEY_UNKNOWN);
|
||||
protected BooleanSetting notify = new BooleanSetting("notificar", "notificar en el chat al activar / desactivar", true);
|
||||
|
||||
private final List<Setting> settings = new ArrayList<>();
|
||||
|
||||
protected MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public Module(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
addSettings(bind, keyMode, notify);
|
||||
}
|
||||
|
||||
|
||||
// ajustes
|
||||
public List<Setting> getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <S extends Setting> S addSetting(Setting setting) {
|
||||
settings.add(setting);
|
||||
setting.setModule(this);
|
||||
return (S) setting; // por convenciencia
|
||||
}
|
||||
|
||||
public void addSettings(Setting... settings) {
|
||||
for (Setting setting : settings) addSetting(setting);
|
||||
}
|
||||
|
||||
|
||||
// encendido y apagado del módulo
|
||||
public void toggle() {
|
||||
enabled = !enabled;
|
||||
if (enabled) onEnable();
|
||||
else onDisable();
|
||||
CameraTweaks.EVENT_BUS.post(new ToggleModuleEvent(this));
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
if (notify.isEnabled()) ChatUtil.info(getName() + " fue activado");
|
||||
for (Method method : getClass().getDeclaredMethods())
|
||||
if (method.isAnnotationPresent(SubscribeEvent.class)) {
|
||||
CameraTweaks.EVENT_BUS.register(this);
|
||||
break;
|
||||
}
|
||||
CameraTweaks.EVENT_BUS.post(new ToggleModuleEvent(this));
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
if (notify.isEnabled()) ChatUtil.info(getName() + " fue desactivado");
|
||||
if (CameraTweaks.EVENT_BUS.isRegistered(this))
|
||||
CameraTweaks.EVENT_BUS.unregister(this);
|
||||
CameraTweaks.EVENT_BUS.post(new ToggleModuleEvent(this));
|
||||
}
|
||||
|
||||
|
||||
// otros métodos
|
||||
public void onTick() {}
|
||||
public void onKey(int key, int action) {}
|
||||
|
||||
// getters y setters
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (this.enabled == enabled) return; // para evitar NPEs al cargar ajustes porque soy imbécil
|
||||
this.enabled = enabled;
|
||||
if (enabled) onEnable();
|
||||
else onDisable();
|
||||
}
|
||||
|
||||
public boolean shouldToggleOnBindRelease() {
|
||||
return keyMode.is(KeyModes.HOLD);
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return bind.getKey();
|
||||
}
|
||||
|
||||
public void setKey(int key) {
|
||||
bind.setKey(key);
|
||||
}
|
||||
|
||||
public void assignKey(int key) {
|
||||
bind.setDefaultKey(key);
|
||||
bind.setKey(key);
|
||||
}
|
||||
|
||||
public KeySetting getBind() {
|
||||
return bind;
|
||||
}
|
||||
|
||||
public enum KeyModes {
|
||||
HOLD("mantener"),
|
||||
TOGGLE("alternar");
|
||||
|
||||
// ojalá hubiera una manera de evitar repetirse con esto pero no la hay (creo) ...
|
||||
private final String name;
|
||||
KeyModes(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package me.retucio.camtweaks.module;
|
||||
|
||||
import me.retucio.camtweaks.event.EventBus;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.module.modules.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
// donde se registran los módulos, y los "listeners" de eventos en cada módulo que lo necesite
|
||||
public class ModuleManager {
|
||||
|
||||
public static ModuleManager INSTANCE;
|
||||
|
||||
private final List<Module> modules = new ArrayList<>();
|
||||
private final EventBus eventBus;
|
||||
|
||||
public ModuleManager(EventBus bus) {
|
||||
this.eventBus = bus;
|
||||
addModules();
|
||||
}
|
||||
|
||||
// por order alfabético y todo, flipas
|
||||
private void addModules() {
|
||||
modules.add(new BossbarStack());
|
||||
modules.add(new ChatPlus());
|
||||
modules.add(new Freecam());
|
||||
modules.add(new Freelook());
|
||||
modules.add(new Fullbright());
|
||||
modules.add(new HandView());
|
||||
modules.add(new PerspectivePlus());
|
||||
modules.add(new Nametags());
|
||||
modules.add(new TimeChanger());
|
||||
modules.add(new Zoom());
|
||||
|
||||
// registrar los "listeners" necesarios
|
||||
for (Module module : getEnabledModules()) {
|
||||
for (Method method : module.getClass().getDeclaredMethods()) {
|
||||
if (method.isAnnotationPresent(SubscribeEvent.class)) {
|
||||
eventBus.register(module);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// para obtener módulos más fácilmente (por nombre, clase, o la lista completa)
|
||||
public List<Module> getModules() {
|
||||
return modules;
|
||||
}
|
||||
|
||||
public List<Module> getEnabledModules() {
|
||||
List<Module> enabledModules = new ArrayList<>();
|
||||
for (Module module : modules)
|
||||
if (module.isEnabled()) enabledModules.add(module);
|
||||
|
||||
return enabledModules;
|
||||
}
|
||||
|
||||
public Module getModuleByName(String name) {
|
||||
for (Module module : modules)
|
||||
if (module.getName().equalsIgnoreCase(name)) return module;
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T extends Module> T getModuleByClass(Class<T> clazz) {
|
||||
for (Module module : modules)
|
||||
if (clazz.isInstance(module))
|
||||
return clazz.cast(module);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.command.CommandManager;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import me.retucio.camtweaks.module.settings.StringSetting;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import static me.retucio.camtweaks.util.Colors.*;
|
||||
|
||||
// módulo no visible solo para los ajustes de la interfaz (y del cliente en general)
|
||||
public class GUI extends Module {
|
||||
|
||||
public NumberSetting red = addSetting(new NumberSetting("rojo", "cantidad de rojo en el RGB del marco", 0, 0, 255, 1));
|
||||
public NumberSetting green = addSetting(new NumberSetting("verde", "cantidad de verde en el RGB del marco", 0, 0, 255, 1));
|
||||
public NumberSetting blue = addSetting(new NumberSetting("azul", "cantidad de azul en el RGB del marco", 255, 0, 255, 1));
|
||||
public NumberSetting alpha = addSetting(new NumberSetting("alpha", "opacidad del marco", 180, 0, 255, 1));
|
||||
|
||||
public NumberSetting scrollSens = addSetting(new NumberSetting("sensibilidad del scroll", "qué tan sensible es la interfaz a la rueda del ratón",
|
||||
5, 0, 15, 0.5));
|
||||
|
||||
public StringSetting commandPrefix = addSetting(new StringSetting("prefijo", "prefijo de los comandos", "$", 10));
|
||||
public StringSetting chatName = addSetting(new StringSetting("nombre", "qué nombre usar en notificaciones por el chat", "smegma", 20));
|
||||
|
||||
public BooleanSetting multipleKeybinds = addSetting(new BooleanSetting("teclas multimódulo", "permitir asignar la misma tecla a más de un módulo", false));
|
||||
|
||||
public GUI() {
|
||||
super("interfaz", "ajustes de la interfaz, y otros misceláneos");
|
||||
assignKey(GLFW.GLFW_KEY_RIGHT_SHIFT);
|
||||
keyMode.setVisible(false);
|
||||
notify.setVisible(false);
|
||||
|
||||
commandPrefix.onUpdate(prefix -> CommandManager.INSTANCE.setPrefix(prefix));
|
||||
red.onUpdate(r -> {frameHeadRed = r.intValue(); updateFrameHeadColor();});
|
||||
green.onUpdate(g -> {frameHeadGreen = g.intValue(); updateFrameHeadColor();});
|
||||
blue.onUpdate(b -> {frameHeadBlue = b.intValue(); updateFrameHeadColor();});
|
||||
alpha.onUpdate(a -> {frameHeadAlpha = a.intValue(); updateFrameHeadColor();});
|
||||
|
||||
if (mc != null) mc.execute(() -> commandPrefix.setDefaultValue(CommandManager.INSTANCE.getPrefix()));
|
||||
|
||||
chatName.onUpdate(name -> {
|
||||
ChatUtil.updatePrefix(name);
|
||||
ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class).updateClientName();
|
||||
});
|
||||
}
|
||||
|
||||
private void updateFrameHeadColor() {
|
||||
Colors.frameHeadColor = new Color(
|
||||
frameHeadRed,
|
||||
frameHeadGreen,
|
||||
frameHeadBlue,
|
||||
frameHeadAlpha
|
||||
).getRGB();
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.RenderHeldItemEvent;
|
||||
import me.retucio.camtweaks.event.events.RenderArmEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.HeldItemRendererMixin
|
||||
*/
|
||||
|
||||
public class HandView extends Module {
|
||||
|
||||
// ajustes de animaciones
|
||||
public BooleanSetting oldAnimations = addSetting(new BooleanSetting("animaciones viejas", "como las de la 1.8, al pegar", false));
|
||||
public BooleanSetting skipSwapping = addSetting(new BooleanSetting("no swap", "se salta la animación de cambiar items de mano", false));
|
||||
public BooleanSetting noFood = addSetting(new BooleanSetting("no comer", "no renderiza la animación de comer", false));
|
||||
|
||||
// ajustes de mano principal
|
||||
public NumberSetting scaleMainX = addSetting(new NumberSetting("escala de la mano principal (X)", ".",
|
||||
1, 0.01, 5, 0.1));
|
||||
public NumberSetting scaleMainY = addSetting(new NumberSetting("escala de la mano principal (Y)", ".",
|
||||
1, 0.01, 5, 0.1));
|
||||
public NumberSetting scaleMainZ = addSetting(new NumberSetting("escala de la mano principal (Z)", ".",
|
||||
1, 0.01, 5, 0.1));
|
||||
|
||||
public NumberSetting posMainX = addSetting(new NumberSetting("posición de la mano principal (X)", ".",
|
||||
0, -3, 3, 0.1));
|
||||
public NumberSetting posMainY = addSetting(new NumberSetting("posición de la mano principal (Y)", ".",
|
||||
0, -3, 3, 0.1));
|
||||
public NumberSetting posMainZ = addSetting(new NumberSetting("posición de la mano principal (Z)", ".",
|
||||
0, -3, 3, 0.1));
|
||||
|
||||
public NumberSetting rotMainX = addSetting(new NumberSetting("rotación de la mano principal (X)", ".",
|
||||
0, -180, 180, 1));
|
||||
public NumberSetting rotMainY = addSetting(new NumberSetting("rotación de la mano principal (Y)", ".",
|
||||
0, -180, 180, 1));
|
||||
public NumberSetting rotMainZ = addSetting(new NumberSetting("rotación de la mano principal (Z)", ".",
|
||||
0, -180, 180, 1));
|
||||
|
||||
// ajustes de mano secundaria
|
||||
public NumberSetting scaleOffX = addSetting(new NumberSetting("escala de la mano secundaria (X)", ".",
|
||||
1, 0.01, 5, 0.1));
|
||||
public NumberSetting scaleOffY = addSetting(new NumberSetting("escala de la mano secundaria (Y)", ".",
|
||||
1, 0.01, 5, 0.1));
|
||||
public NumberSetting scaleOffZ = addSetting(new NumberSetting("escala de la mano secundaria (Z)", ".",
|
||||
1, 0.01, 5, 0.1));
|
||||
|
||||
public NumberSetting posOffX = addSetting(new NumberSetting("posición de la mano secundaria (X)", ".",
|
||||
0, -3, 3, 0.1));
|
||||
public NumberSetting posOffY = addSetting(new NumberSetting("posición de la mano secundaria (Y)", ".",
|
||||
0, -3, 3, 0.1));
|
||||
public NumberSetting posOffZ = addSetting(new NumberSetting("posición de la mano secundaria (Z)", ".",
|
||||
0, -3, 3, 0.1));
|
||||
|
||||
public NumberSetting rotOffX = addSetting(new NumberSetting("rotación de la mano secundaria (X)", ".",
|
||||
0, -180, 180, 1));
|
||||
public NumberSetting rotOffY = addSetting(new NumberSetting("rotación de la mano secundaria (Y)", ".",
|
||||
0, -180, 180, 1));
|
||||
public NumberSetting rotOffZ = addSetting(new NumberSetting("rotación de la mano secundaria (Z)", ".",
|
||||
0, -180, 180, 1));
|
||||
|
||||
// brazo
|
||||
public NumberSetting scaleArmX = addSetting(new NumberSetting("escala del brazo (X)", ".",
|
||||
1, 0.01, 5, 0.1));
|
||||
public NumberSetting scaleArmY = addSetting(new NumberSetting("escala del brazo (Y)", ".",
|
||||
1, 0.01, 5, 0.1));
|
||||
public NumberSetting scaleArmZ = addSetting(new NumberSetting("escala del brazo (Z)", ".",
|
||||
1, 0.01, 5, 0.1));
|
||||
|
||||
public NumberSetting posArmX = addSetting(new NumberSetting("posición del brazo (X)", ".",
|
||||
0, -3, 3, 0.1));
|
||||
public NumberSetting posArmY = addSetting(new NumberSetting("posición del brazo (Y)", ".",
|
||||
0, -3, 3, 0.1));
|
||||
public NumberSetting posArmZ = addSetting(new NumberSetting("posición del brazo (Z)", ".",
|
||||
0, -3, 3, 0.1));
|
||||
|
||||
public NumberSetting rotArmX = addSetting(new NumberSetting("rotación del brazo (X)", ".",
|
||||
0, -180, 180, 1));
|
||||
public NumberSetting rotArmY = addSetting(new NumberSetting("rotación del brazo (Y)", ".",
|
||||
0, -180, 180, 1));
|
||||
public NumberSetting rotArmZ = addSetting(new NumberSetting("rotación del brazo (Z)", ".",
|
||||
0, -180, 180, 1));
|
||||
|
||||
public HandView() {
|
||||
super("manos", "modifica la manera en la que se renderizan las manos");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onHeldItemRender(RenderHeldItemEvent event) {
|
||||
if (event.getHand() == Hand.MAIN_HAND) {
|
||||
scale(event.getMatrices(), new Vector3d(scaleMainX.getValue(), scaleMainY.getValue(), scaleMainZ.getValue()));
|
||||
translate(event.getMatrices(), new Vector3d(posMainX.getValue(), posMainY.getValue(), posMainZ.getValue()));
|
||||
rotate(event.getMatrices(), new Vector3d(rotMainX.getValue(), rotMainY.getValue(), rotMainZ.getValue()));
|
||||
}
|
||||
else {
|
||||
scale(event.getMatrices(), new Vector3d(scaleOffX.getValue(), scaleOffY.getValue(), scaleOffZ.getValue()));
|
||||
translate(event.getMatrices(), new Vector3d(posOffX.getValue(), posOffY.getValue(), posOffZ.getValue()));
|
||||
rotate(event.getMatrices(), new Vector3d(rotOffX.getValue(), rotOffY.getValue(), rotOffZ.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderArm(RenderArmEvent event) {
|
||||
scale(event.getMatrices(), new Vector3d(scaleArmX.getValue(), scaleArmY.getValue(), scaleArmZ.getValue()));
|
||||
translate(event.getMatrices(), new Vector3d(posArmX.getValue(), posArmY.getValue(), posArmZ.getValue()));
|
||||
rotate(event.getMatrices(), new Vector3d(rotArmX.getValue(), rotArmY.getValue(), rotArmZ.getValue()));
|
||||
}
|
||||
|
||||
private void rotate(MatrixStack matrix, Vector3d rotation) {
|
||||
matrix.multiply(RotationAxis.POSITIVE_X.rotationDegrees((float) rotation.x));
|
||||
matrix.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) rotation.y));
|
||||
matrix.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) rotation.z));
|
||||
}
|
||||
|
||||
private void scale(MatrixStack matrix, Vector3d scale) {
|
||||
matrix.scale((float) scale.x, (float) scale.y, (float) scale.z);
|
||||
}
|
||||
|
||||
private void translate(MatrixStack matrix, Vector3d translation) {
|
||||
matrix.translate((float) translation.x, (float) translation.y, (float) translation.z);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.LazyEntityReference;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.PersistentProjectileEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.EntityMixin
|
||||
* @see me.retucio.camtweaks.mixin.ItemEntityMixin
|
||||
* @see me.retucio.camtweaks.mixin.PlayerEntityMixin
|
||||
*/
|
||||
|
||||
public class Nametags extends Module {
|
||||
|
||||
public BooleanSetting namePlayers = addSetting(new BooleanSetting("nombrar jugadores", "renderiza el nametag de jugadores", true));
|
||||
public BooleanSetting health = addSetting(new BooleanSetting("mostrar vida", "muestra la vida de una entidad en su nametag", true));
|
||||
public EnumSetting<HealthMode> healthMode = addSetting(new EnumSetting<>("mostrar vida en", "de qué manera mostrar la vida", HealthMode.class, HealthMode.POINTS));
|
||||
public BooleanSetting alwaysVisible = addSetting(new BooleanSetting("siempre mostrar nametags", "mostrar nametags cuando no deberían de ser visibles", false));
|
||||
|
||||
public BooleanSetting namePassiveMobs = addSetting(new BooleanSetting("nombrar mobs pasivos", "renderiza el nametag de mobs pasivos", false));
|
||||
public BooleanSetting nameHostileMobs = addSetting(new BooleanSetting("nombrar mobs hostiles", "renderiza el nametag de mobs hostiles", false));
|
||||
public BooleanSetting nameMiscMobs = addSetting(new BooleanSetting("nombrar mobs neutrales", "renderiza el nametag de mobs neutrales", false));
|
||||
public BooleanSetting distinguishBabies = addSetting(new BooleanSetting("distinguir bebés", "cambia el nametag cuando una entidad está en su fase bebé", false));
|
||||
|
||||
public BooleanSetting nameProjectiles = addSetting(new BooleanSetting("nombrar proyectiles", "renderiza el nametag de proyectiles", false));
|
||||
public BooleanSetting showProjectileDamage = addSetting(new BooleanSetting("daño del proyectil", "muestra cuánto daño hace un proyectil en su nametag", false));
|
||||
|
||||
public BooleanSetting nameItems = addSetting(new BooleanSetting("nombrar items", "renderiza el nametag de items", true));
|
||||
public BooleanSetting countItems = addSetting(new BooleanSetting("contar items", "muestra cuánto de un item hay en un stack dropeado", true));
|
||||
|
||||
public BooleanSetting nameVehicles = addSetting(new BooleanSetting("nombrar vehículos", "renderiza el nametag de botes, minecarts, ...", false));
|
||||
public BooleanSetting showPassengers = addSetting(new BooleanSetting("mostrar pasajeros", "muestra qué pasajeros tiene el vehículo", false));
|
||||
|
||||
public BooleanSetting petOwner = addSetting(new BooleanSetting("mostrar dueño", "muestra el dueño de una mascota (no funciona en servers no premium)", false));
|
||||
|
||||
private final Map<UUID, String> cache = new ConcurrentHashMap<>();
|
||||
private static final ExecutorService executor = Executors.newCachedThreadPool();
|
||||
|
||||
public Nametags() {
|
||||
super("nametags", "modifica la manera en la que se renderizan los nametags");
|
||||
|
||||
nameProjectiles.onUpdate(v -> showProjectileDamage.setVisible(v));
|
||||
nameItems.onUpdate(v -> countItems.setVisible(v));
|
||||
nameVehicles.onUpdate(v -> showPassengers.setVisible(v));
|
||||
|
||||
namePassiveMobs.onUpdate(v -> distinguishBabies.setVisible(v || nameMiscMobs.isEnabled() || nameHostileMobs.isEnabled()));
|
||||
nameMiscMobs.onUpdate(v -> distinguishBabies.setVisible(v || namePassiveMobs.isEnabled() || nameHostileMobs.isEnabled()));
|
||||
nameHostileMobs.onUpdate(v -> distinguishBabies.setVisible(v || nameMiscMobs.isEnabled() || namePassiveMobs.isEnabled()));
|
||||
|
||||
health.onUpdate(v -> healthMode.setVisible(v));
|
||||
}
|
||||
|
||||
public enum HealthMode {
|
||||
POINTS("hp (puntos de vida)"),
|
||||
HEARTS("corazones");
|
||||
|
||||
private final String name;
|
||||
HealthMode(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
|
||||
// literalmente cómo lo calcula Minecraft
|
||||
public float getArrowDamage(PersistentProjectileEntity arrow) {
|
||||
if (mc.player == null) return 0;
|
||||
|
||||
double initialDamage = 2;
|
||||
double velocity = arrow.getVelocity().length();
|
||||
DamageSource damageSource = arrow.getDamageSources().arrow(arrow, arrow.getOwner());
|
||||
|
||||
if (arrow.getWeaponStack() != null)
|
||||
if (arrow.getWorld() instanceof ServerWorld world)
|
||||
initialDamage = EnchantmentHelper.getDamage(world, arrow.getWeaponStack(), mc.player, damageSource, (float) initialDamage);
|
||||
|
||||
int finalDamage = MathHelper.ceil(MathHelper.clamp(velocity * initialDamage, 0, 2.147483647E9));
|
||||
|
||||
if (arrow.isCritical()) {
|
||||
long bonus = arrow.getRandom().nextInt(finalDamage / 2 + 2);
|
||||
finalDamage = (int) Math.min(bonus + (long) finalDamage, 2147483647L);
|
||||
}
|
||||
|
||||
return healthMode.is(HealthMode.HEARTS) ? finalDamage / 2f : finalDamage;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getOwnerName(LazyEntityReference<LivingEntity> owner) {
|
||||
// si el dueño está en línea
|
||||
LivingEntity ownerEntity = owner.resolve(mc.world, LivingEntity.class);
|
||||
if (ownerEntity instanceof PlayerEntity playerEntity) return playerEntity.getName().getString();
|
||||
|
||||
// mirar si ya está en la caché
|
||||
UUID uuid = owner.getUuid();
|
||||
String cachedName = cache.get(uuid);
|
||||
if (cachedName != null) return cachedName;
|
||||
|
||||
cache.put(uuid, "..."); // mientras se obtiene el nombre
|
||||
|
||||
// si no está en la caché, ni en línea, obtener nombre de los servers de Mojang
|
||||
executor.execute(() -> {
|
||||
try {
|
||||
String url = "https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString().replace("-", "");
|
||||
HttpURLConnection req = (HttpURLConnection) new URL(url).openConnection();
|
||||
req.setRequestMethod("GET");
|
||||
req.setConnectTimeout(5000);
|
||||
req.setReadTimeout(5000);
|
||||
if (req.getResponseCode() != 200) {
|
||||
cache.put(uuid, "?");
|
||||
return;
|
||||
}
|
||||
|
||||
JsonObject obj = JsonParser.parseReader(new InputStreamReader(req.getInputStream())).getAsJsonObject();
|
||||
String name = obj.get("name").getAsString();
|
||||
cache.put(uuid, name);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
cache.put(uuid, "?");
|
||||
}
|
||||
});
|
||||
|
||||
return "...";
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.MouseScrollEvent;
|
||||
import me.retucio.camtweaks.event.events.PerspectiveChangeEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.*;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
// continúa en CameraMixin
|
||||
public class PerspectivePlus extends Module {
|
||||
|
||||
private double distance;
|
||||
|
||||
// ajustes
|
||||
public BooleanSetting clip = addSetting(new BooleanSetting(
|
||||
"clip", "atravesar bloques con la cámara", true));
|
||||
|
||||
public NumberSetting defaultDistance = addSetting(new NumberSetting(
|
||||
"distancia", "distancia a la que está la cámara del jugador por defecto",
|
||||
4, 1, 20, 0.2));
|
||||
|
||||
public NumberSetting scrollSens = addSetting(new NumberSetting(
|
||||
"sensibilidad del scroll", "sensibilidad de la rueda del ratón (0 para desactivar)",
|
||||
1, 0, 8, 0.1));
|
||||
|
||||
public KeySetting scrollKey = addSetting(new KeySetting("tecla del scroll", "qué tecla mantener para usar la rueda del ratón", GLFW.GLFW_KEY_LEFT_ALT));
|
||||
|
||||
public PerspectivePlus() {
|
||||
super("perspectiva plus", "añade cositas chulas al cambio de perspectiva");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
distance = defaultDistance.getValue();
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPerspectiveChange(PerspectiveChangeEvent event) {
|
||||
distance = defaultDistance.getValue();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMouseScroll(MouseScrollEvent event) {
|
||||
if (mc.options.getPerspective() == net.minecraft.client.option.Perspective.FIRST_PERSON
|
||||
|| mc.currentScreen != null || scrollSens.getValue() <= 0) return;
|
||||
|
||||
if (KeyUtil.isKeyDown(scrollKey.getKey())) {
|
||||
distance -= event.getVertical() / 4 * (scrollSens.getValue() * distance);
|
||||
event.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public double getDistance() {
|
||||
return distance;
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.PacketEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket;
|
||||
|
||||
// continúa en ClientWorldPropertiesMixin, DimensionTypeMixin,
|
||||
public class TimeChanger extends Module {
|
||||
|
||||
public BooleanSetting renderSun = addSetting(new BooleanSetting("sol", "que haya sol o no", true));
|
||||
public BooleanSetting renderMoon = addSetting(new BooleanSetting("luna", "que haya luna o no", true));
|
||||
public BooleanSetting renderStars = addSetting(new BooleanSetting("estrellas", "que hayan estrellas o no", true));
|
||||
|
||||
public EnumSetting<MoonPhases> moonPhase = addSetting(new EnumSetting<>("fase lunar", "fase lunar actual", MoonPhases.class, MoonPhases.DEFAULT));
|
||||
public NumberSetting time = addSetting(new NumberSetting("hora", "hora del juego", 0, -20000, 20000, 1));
|
||||
|
||||
public TimeChanger() {
|
||||
super("cielo custom", "te deja cambiar visualmente el progreso del día");
|
||||
renderMoon.onUpdate(v -> moonPhase.setVisible(v));
|
||||
}
|
||||
|
||||
private long realTime;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (mc.world == null) return;
|
||||
realTime = mc.world.getTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (mc.world == null) return;
|
||||
mc.world.getLevelProperties().setTimeOfDay(realTime);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacketReceive(PacketEvent.Receive event) {
|
||||
if (event.getPacket() instanceof WorldTimeUpdateS2CPacket packet) {
|
||||
realTime = packet.timeOfDay();
|
||||
event.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
if (mc.world == null) return;
|
||||
mc.world.getLevelProperties().setTimeOfDay(time.getLongValue());
|
||||
}
|
||||
|
||||
public int getMoonPhase() {
|
||||
if (mc.world == null) return -1;
|
||||
|
||||
return switch (moonPhase.getValue()) {
|
||||
case DEFAULT -> (int) (mc.world.getLunarTime() / 24000L) % 8;
|
||||
case FULL_MOON -> 0;
|
||||
case WANING_GIBBOUS -> 1;
|
||||
case LAST_QUARTER -> 2;
|
||||
case WANING_CRESCENT -> 3;
|
||||
case NEW_MOON -> 4;
|
||||
case WAXING_CRESCENT -> 5;
|
||||
case FIRST_QUARTER -> 6;
|
||||
case WAXING_GIBBOUS -> 7;
|
||||
};
|
||||
}
|
||||
|
||||
public enum MoonPhases {
|
||||
DEFAULT("por defecto"),
|
||||
FULL_MOON("luna llena"),
|
||||
WANING_GIBBOUS("menguante gibosa"),
|
||||
LAST_QUARTER("cuarto menguante"),
|
||||
WANING_CRESCENT("luna vieja"),
|
||||
NEW_MOON("luna nueva"),
|
||||
WAXING_CRESCENT("creciente"),
|
||||
FIRST_QUARTER("cuarto creciente"),
|
||||
WAXING_GIBBOUS("creciente gibosa");
|
||||
|
||||
private final String name;
|
||||
MoonPhases(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.GetFOVEvent;
|
||||
import me.retucio.camtweaks.event.events.MouseScrollEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.KeySetting;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
// continúa en GameRendererMixin
|
||||
public class Zoom extends Module {
|
||||
|
||||
public BooleanSetting showHands = addSetting(new BooleanSetting("mostrar manos", "esconde o muestra las manos al hacer zoom", true));
|
||||
public BooleanSetting showHUD = addSetting(new BooleanSetting("mostrar HUD", "esconde o muestra los indicadores en pantalla", true));
|
||||
|
||||
public NumberSetting scrollSens = addSetting(new NumberSetting("sensibilidad del scroll", "sensibilidad de la rueda del ratón (0 para desactivar)",
|
||||
0.4, 0, 8, 0.1));
|
||||
|
||||
public KeySetting scrollKey = addSetting(new KeySetting("tecla del scroll", "qué tecla mantener para usar la rueda del ratón", GLFW.GLFW_KEY_LEFT_CONTROL));
|
||||
|
||||
public NumberSetting defaultZoom = addSetting(new NumberSetting("zoom", "cantidad de zoom",
|
||||
6, 1, 10, 0.1));
|
||||
|
||||
public NumberSetting mouseSensMultiplier = addSetting(new NumberSetting("sensibilidad", "multiplicador de la sensibilidad del ratón",
|
||||
0.7, 0.01, 1, 0.05));
|
||||
|
||||
public BooleanSetting smoothCam = addSetting(new BooleanSetting("cámara cinemática", "usa la cámara cinemática mientras hagas zoom", false));
|
||||
|
||||
private boolean prevSmoothCam;
|
||||
private double prevMouseSens;
|
||||
private double prevFov;
|
||||
private boolean prevHUD;
|
||||
private double value;
|
||||
|
||||
public Zoom() {
|
||||
super("zoom", "lupa");
|
||||
super.keyMode.setValue(KeyModes.HOLD);
|
||||
super.keyMode.setDefaultValue(KeyModes.HOLD);
|
||||
super.notify.setEnabled(false);
|
||||
super.notify.setDefaultValue(false);
|
||||
assignKey(GLFW.GLFW_KEY_F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (mc.options == null) return;
|
||||
|
||||
CameraTweaks.EVENT_BUS.register(this);
|
||||
|
||||
prevSmoothCam = mc.options.smoothCameraEnabled;
|
||||
prevMouseSens = mc.options.getMouseSensitivity().getValue();
|
||||
prevFov = mc.options.getFov().getValue();
|
||||
prevHUD = mc.options.hudHidden;
|
||||
mc.options.hudHidden = !showHUD.isEnabled();
|
||||
|
||||
value = defaultZoom.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (mc.options == null) return;
|
||||
CameraTweaks.EVENT_BUS.unregister(this);
|
||||
|
||||
mc.options.smoothCameraEnabled = prevSmoothCam;
|
||||
mc.options.getMouseSensitivity().setValue(prevMouseSens);
|
||||
mc.options.hudHidden = prevHUD;
|
||||
|
||||
mc.worldRenderer.scheduleTerrainUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
mc.options.smoothCameraEnabled = smoothCam.isEnabled();
|
||||
if (!smoothCam.isEnabled())
|
||||
mc.options.getMouseSensitivity().setValue(prevMouseSens * mouseSensMultiplier.getValue());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
private void onMouseScroll(MouseScrollEvent event) {
|
||||
boolean key = scrollKey.getKey() == GLFW.GLFW_KEY_UNKNOWN || KeyUtil.isKeyDown(scrollKey.getKey());
|
||||
if (isEnabled() && scrollSens.getValue() > 0 && key) {
|
||||
value += event.getVertical() * 0.25 * (scrollSens.getValue() * value);
|
||||
if (value < 1) value = 1;
|
||||
|
||||
event.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
private void onGetFov(GetFOVEvent event) {
|
||||
event.setFov((float) (event.getFov() / value));
|
||||
|
||||
if (prevFov != event.getFov()) mc.worldRenderer.scheduleTerrainUpdate();
|
||||
prevFov = event.getFov();
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package me.retucio.camtweaks.module.settings;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
// ajuste booleano, es decir, o se encuentra encencido o apagado (similar a un interruptor)
|
||||
public class BooleanSetting extends Setting {
|
||||
|
||||
private boolean defaultValue;
|
||||
private boolean enabled;
|
||||
|
||||
private Consumer<Boolean> updateListener;
|
||||
|
||||
public BooleanSetting(String name, String description, boolean defaultValue) {
|
||||
super(name, description);
|
||||
this.enabled = defaultValue;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public void toggle() {
|
||||
setEnabled(!enabled);
|
||||
if (updateListener != null) updateListener.accept(enabled);
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (this.enabled != enabled) {
|
||||
this.enabled = enabled;
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
if (updateListener != null) updateListener.accept(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefaultValue(boolean value) {
|
||||
defaultValue = value;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
setEnabled(defaultValue);
|
||||
}
|
||||
|
||||
public void onUpdate(Consumer<Boolean> listener) {
|
||||
this.updateListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package me.retucio.camtweaks.module.settings;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class KeySetting extends Setting {
|
||||
|
||||
private int key;
|
||||
private int defaultKey;
|
||||
|
||||
private Consumer<Integer> updateListener;
|
||||
|
||||
public KeySetting(String name, String description, int defaultKey) {
|
||||
super(name, description);
|
||||
this.key = defaultKey;
|
||||
this.defaultKey = defaultKey;
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(int key) {
|
||||
if (this.key == key) return;
|
||||
|
||||
if (key == GLFW.GLFW_KEY_ESCAPE) {
|
||||
this.key = GLFW.GLFW_KEY_UNKNOWN; // asignar la tecla ESC a deshabilitar la tecla
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
if (updateListener != null) updateListener.accept(key);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ModuleManager.INSTANCE != null) {
|
||||
for (Module module : ModuleManager.INSTANCE.getModules())
|
||||
if (module.getKey() == key && !ClickGUISettingsFrame.guiSettings.multipleKeybinds.isEnabled() && key != -1) {
|
||||
module.setKey(-1);
|
||||
ChatUtil.info("tecla del módulo " + module.getName() + " restablecida");
|
||||
}
|
||||
}
|
||||
this.key = key;
|
||||
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
if (updateListener != null) updateListener.accept(key);
|
||||
}
|
||||
|
||||
public int getDefaultKey() {
|
||||
return defaultKey;
|
||||
}
|
||||
|
||||
public void setDefaultKey(int key) {
|
||||
this.defaultKey = key;
|
||||
}
|
||||
|
||||
public String getKeyName() {
|
||||
return KeyUtil.getKeyName(key);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
setKey(defaultKey);
|
||||
}
|
||||
|
||||
public void onUpdate(Consumer<Integer> listener) {
|
||||
this.updateListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package me.retucio.camtweaks.module.settings;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
|
||||
// base para los tipos de ajustes
|
||||
public class Setting {
|
||||
|
||||
private final String name;
|
||||
private final String description;
|
||||
private boolean visible = true;
|
||||
|
||||
private Module module;
|
||||
|
||||
protected Setting(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Module getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(Module module) {
|
||||
this.module = module;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package me.retucio.camtweaks.module.settings;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class StringSetting extends Setting {
|
||||
|
||||
private String value;
|
||||
private String defaultValue;
|
||||
private final int maxLength;
|
||||
|
||||
private Consumer<String> updateListener;
|
||||
|
||||
public StringSetting(String name, String description, String defaultValue, int maxLength) {
|
||||
super(name, description);
|
||||
this.value = defaultValue;
|
||||
this.defaultValue = defaultValue;
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
if (this.value.equals(value)) return;
|
||||
this.value = value.length() > maxLength ? value.substring(0, maxLength) : value;
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
if (updateListener != null) updateListener.accept(this.value);
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
setValue(defaultValue);
|
||||
}
|
||||
|
||||
public int getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
public void onUpdate(Consumer<String> listener) {
|
||||
this.updateListener = listener;
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package me.retucio.camtweaks.ui;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.MouseScrollEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.SettingsFrameEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.ModuleFrame;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame.guiSettings;
|
||||
|
||||
// interfaz gráfica, se abre con el shift derecho por defecto. aquí se encuentran los módulos y sus ajustes
|
||||
public class ClickGUI extends Screen {
|
||||
|
||||
public static ClickGUI INSTANCE;
|
||||
private boolean anyFocused;
|
||||
|
||||
private final ModuleFrame modulesFrame = new ModuleFrame(20, 30, 100, 20);
|
||||
private final List<SettingsFrame> settingsFrames = new ArrayList<>();
|
||||
private final ClickGUISettingsFrame guiSettingsFrame = new ClickGUISettingsFrame(200, 30, 100, 20);
|
||||
|
||||
public ClickGUI() {
|
||||
super(Text.of("interfaz"));
|
||||
settingsFrames.add(guiSettingsFrame);
|
||||
CameraTweaks.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext ctx, int mouseX, int mouseY, float delta) {
|
||||
// renderizar el marco de los ajustes de cada módulo que lo tenga abierto. se abre haciendo clic derecho sobre el módulo
|
||||
for (SettingsFrame sf : settingsFrames.reversed()) {
|
||||
sf.render(ctx, mouseX, mouseY, delta);
|
||||
sf.updatePosition(mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderizar el marco de los módulos
|
||||
modulesFrame.render(ctx, mouseX, mouseY, delta);
|
||||
modulesFrame.updatePosition(mouseX, mouseY);
|
||||
|
||||
super.render(ctx, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
// detectar clics sobre los marcos
|
||||
modulesFrame.mouseClicked(mouseX, mouseY, button);
|
||||
for (SettingsFrame sf : new ArrayList<>(settingsFrames))
|
||||
sf.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
// registrar cuándo se suelta el clic, en cada marco respectivamente
|
||||
modulesFrame.mouseReleased(mouseX, mouseY, button);
|
||||
for (SettingsFrame sf : new ArrayList<>(settingsFrames))
|
||||
sf.mouseRelease(mouseX, mouseY, button);
|
||||
return super.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMouseScroll(MouseScrollEvent event) {
|
||||
// subir y bajar la pantalla con la rueda del ratón
|
||||
if (CameraTweaks.mc.currentScreen != this) return;
|
||||
|
||||
modulesFrame.y += (int) (event.getVertical() * guiSettings.scrollSens.getValue());
|
||||
for (SettingsFrame sf : settingsFrames)
|
||||
sf.y += (int) (event.getVertical() * guiSettings.scrollSens.getValue());
|
||||
}
|
||||
|
||||
public void openSettingsFrame(Module module, int x, int y) {
|
||||
// abrir un marco donde se encuentran los ajustes del módulo deseado
|
||||
if (isSettingsFrameOpen(module)) return; // permitir un solo marco de ajustes por módulo
|
||||
SettingsFrame frame = new SettingsFrame(module, x, y, 120, 20);
|
||||
settingsFrames.add(frame);
|
||||
CameraTweaks.EVENT_BUS.post(new SettingsFrameEvent.Open(frame));
|
||||
}
|
||||
|
||||
// cerrar el marco de ajustes
|
||||
public void closeSettingsFrame(Module module) {
|
||||
// porque java.util.ConcurrentModificationException o algo no sé es lo único que se me ha ocurrido hacer
|
||||
List<SettingsFrame> toRemove = new ArrayList<>();
|
||||
for (SettingsFrame sf : settingsFrames) {
|
||||
if (sf.module == module) {
|
||||
CameraTweaks.EVENT_BUS.post(new SettingsFrameEvent.Close(sf));
|
||||
toRemove.add(sf);
|
||||
}
|
||||
}
|
||||
settingsFrames.removeAll(toRemove);
|
||||
}
|
||||
|
||||
// verificar si un módulo tiene su marco de ajustes abierto
|
||||
public boolean isSettingsFrameOpen(Module module) {
|
||||
return settingsFrames.stream()
|
||||
.anyMatch(sf -> sf.module.getName().equals(module.getName()));
|
||||
}
|
||||
|
||||
// no pausar el juego cuando se abre la interfaz
|
||||
@Override
|
||||
public boolean shouldPause() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ModuleFrame getModulesFrame() {
|
||||
return modulesFrame;
|
||||
}
|
||||
|
||||
public ClickGUISettingsFrame getGuiSettingsFrame() {
|
||||
return guiSettingsFrame;
|
||||
}
|
||||
|
||||
public void setAnyFocused(boolean anyFocused) {
|
||||
this.anyFocused = anyFocused;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCloseOnEsc() {
|
||||
return super.shouldCloseOnEsc() && !anyFocused;
|
||||
}
|
||||
|
||||
public List<SettingsFrame> getSettingsFrames() {
|
||||
return settingsFrames;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.retucio.camtweaks.ui;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
|
||||
// en un principio esto iba a mostrar en pantalla los módulos activados, pero me parece innecesario. se queda aquí por si acaso
|
||||
// igual lo uso para algo...
|
||||
public class HUD {
|
||||
|
||||
private static final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public static void render(DrawContext ctx, RenderTickCounter tc) {}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.settings.KeySetting;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
// botón para configurar la tecla asignada a un módulo. comienza a escuchar al hacerle clic
|
||||
public class BindButton extends SettingButton {
|
||||
|
||||
private final KeySetting setting;
|
||||
private boolean listening = false;
|
||||
|
||||
public BindButton(KeySetting setting, SettingsFrame parent, int offset) {
|
||||
super(setting, parent, offset);
|
||||
this.setting = setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
int bgColor = isHovered((int) mouseX, (int) mouseY)
|
||||
? Colors.hoveredSettingButtonColor
|
||||
: Colors.settingButtonColor;
|
||||
|
||||
ctx.fill(x, y, x + w, y + height, bgColor);
|
||||
String label = setting.getName() + ": " + (listening ? "..." : setting.getKeyName());
|
||||
ctx.drawTextWithShadow(parent.mc.textRenderer, label, x + 5, y + 3, -1);
|
||||
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
Screen currentScreen = parent.mc.currentScreen;
|
||||
if (currentScreen != null)
|
||||
ctx.drawTooltip(Text.of(setting.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
if (button == 0) listening = !listening;
|
||||
else if (button == 1 && KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT))
|
||||
setting.reset();
|
||||
} else {
|
||||
listening = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void onKey(int key, int action) {
|
||||
if (listening && action == GLFW.GLFW_PRESS) {
|
||||
if (key == GLFW.GLFW_KEY_ESCAPE)
|
||||
setting.setKey(GLFW.GLFW_KEY_UNKNOWN);
|
||||
else
|
||||
setting.setKey(key);
|
||||
listening = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFocused() {
|
||||
return listening;
|
||||
}
|
||||
|
||||
public KeySetting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.ModuleFrame;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
// clase para el botón para cada módulo
|
||||
public class ModuleButton {
|
||||
|
||||
public Module module;
|
||||
public ModuleFrame parent;
|
||||
public int offset;
|
||||
public final int height = 18;
|
||||
|
||||
public ModuleButton(Module module, ModuleFrame parent, int offset) {
|
||||
this.module = module;
|
||||
this.parent = parent;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
ctx.fill( // dibujar el contorno del botón
|
||||
parent.x + 2, parent.y + offset + 3,
|
||||
parent.x + parent.w - 2 , parent.y + height + offset,
|
||||
determineColor(mouseX, mouseY));
|
||||
|
||||
ctx.drawTextWithShadow( // dibujar el nombre del módulo
|
||||
parent.mc.textRenderer, module.getName(),
|
||||
parent.x + 5, parent.y + offset + (height / 2) - (parent.mc.textRenderer.fontHeight / 2) + 2, -1);
|
||||
|
||||
// dibujar "tooltips" (cajas de texto) al pasar el puntero encima del botón, para mostrar su descripción
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
Screen currentScreen = parent.mc.currentScreen;
|
||||
if (currentScreen != null)
|
||||
ctx.drawTooltip(Text.of(module.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (button == 0) {// clic izquierdo para activar / desactivar el módulo
|
||||
module.toggle();
|
||||
} else if (button == 1) { // clic derecho para el marco de ajustes (también lo cierra si está abierto)
|
||||
if (ClickGUI.INSTANCE.isSettingsFrameOpen(module))
|
||||
ClickGUI.INSTANCE.closeSettingsFrame(module);
|
||||
else
|
||||
ClickGUI.INSTANCE.openSettingsFrame(module,
|
||||
parent.x + parent.w + 120, parent.y + offset);
|
||||
}
|
||||
}
|
||||
|
||||
// verifica si el puntero del ratón se encuentra sobre el botón del módulo
|
||||
public boolean isHovered(int mouseX, int mouseY) {
|
||||
return mouseX > parent.x && mouseX < parent.x + parent.w && mouseY > parent.y + offset && mouseY < parent.y + height + offset;
|
||||
}
|
||||
|
||||
public int determineColor(double mouseX, double mouseY) {
|
||||
// determina el color del botón, dependiendo de si está el puntero encima y si está activado
|
||||
if (module.isEnabled())
|
||||
return isHovered((int) mouseX, (int) mouseY) ? Colors.enabledHoveredModuleButtonColor : Colors.enabledModuleButtonColor;
|
||||
return isHovered((int) mouseX, (int) mouseY) ? Colors.hoveredModuleButtonColor : Colors.moduleButtonColor;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.settings.Setting;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
// clase base para los botones de los ajustes
|
||||
public abstract class SettingButton {
|
||||
|
||||
protected final Setting setting;
|
||||
protected final SettingsFrame parent;
|
||||
protected int offset;
|
||||
protected final int height = 15;
|
||||
|
||||
protected int x, y, w, h;
|
||||
|
||||
public SettingButton(Setting setting, SettingsFrame parent, int offset) {
|
||||
this.setting = setting;
|
||||
this.parent = parent;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public abstract void render(DrawContext ctx, double mouseX, double mouseY, float delta);
|
||||
public abstract void mouseClicked(double mouseX, double mouseY, int button);
|
||||
public abstract void mouseReleased(double mouseX, double mouseY, int button);
|
||||
|
||||
protected boolean isHovered(int mouseX, int mouseY) {
|
||||
return mouseX > x && mouseX < x + w &&
|
||||
mouseY > y && mouseY < y + h;
|
||||
}
|
||||
|
||||
public Setting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getW() {
|
||||
return w;
|
||||
}
|
||||
|
||||
public void setW(int w) {
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public int getH() {
|
||||
return h;
|
||||
}
|
||||
|
||||
public void setH(int h) {
|
||||
this.h = h;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.KeyEvent;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
// slider (barrita) para los ajustes numéricos
|
||||
public class SliderButton extends SettingButton {
|
||||
|
||||
private final NumberSetting setting;
|
||||
private boolean dragging = false;
|
||||
public final DecimalFormat df; // usar formato decimal para el valor del ajuste
|
||||
|
||||
public SliderButton(NumberSetting setting, SettingsFrame parent, int offset) {
|
||||
super(setting, parent, offset);
|
||||
this.setting = setting;
|
||||
this.df = new DecimalFormat("#.##"); // solo mostrar dos décimales
|
||||
EVENT_BUS.subscribe(this); // para poder escuchar teclas
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
ctx.fill(x, y, x + w, y + height, Colors.moduleButtonColor);
|
||||
|
||||
// calcular cómo de llena tendría que estar el "slider"
|
||||
double percent = (setting.getValue() - setting.getMin()) / (setting.getMax() - setting.getMin());
|
||||
int filled = (int) (percent * w);
|
||||
ctx.fill(x, y, x + filled, y + height, Colors.sliderFillingColor);
|
||||
|
||||
String label = setting.getName() + ": " + df.format(setting.getValue());
|
||||
ctx.drawTextWithShadow(parent.mc.textRenderer, label, x + 5, y + 3, -1);
|
||||
|
||||
// lógica para el arrastre (arrastramiento?) del valor
|
||||
if (dragging) {
|
||||
double newVal = setting.getMin() + ((mouseX - x) / (double) w) * (setting.getMax() - setting.getMin());
|
||||
newVal = Math.max(setting.getMin(), Math.min(setting.getMax(), newVal));
|
||||
newVal = Math.round(newVal / setting.getIncrement()) * setting.getIncrement();
|
||||
setting.setValue((float) newVal);
|
||||
}
|
||||
|
||||
// dibujar "tooltips" (cajas de texto) al pasar el puntero encima del botón, para mostrar su descripción
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
Screen currentScreen = parent.mc.currentScreen;
|
||||
if (currentScreen != null)
|
||||
ctx.drawTooltip(Text.of(setting.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
if (button == 0) dragging = true; // arrastrar con el clic izquierdo
|
||||
else if (button == 1 && KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) // restablecer al valor por defecto con shift izquerdo + clic derecho
|
||||
setting.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||
if (button == 0) dragging = false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKey(KeyEvent event) {
|
||||
// de no ser de esto, si se cierra la interfaz sin haber soltado el ratón mientras se arrastraba el valor, al reabrir la interfaz se seguía arrastrando, aún habiendo soltado ya el clic
|
||||
if (event.getKey() == GLFW.GLFW_KEY_ESCAPE || event.getKey() == ClickGUISettingsFrame.guiSettings.getKey()) dragging = false;
|
||||
}
|
||||
|
||||
public NumberSetting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
// botón para los ajustes booleanos (funciona como un interruptor)
|
||||
public class ToggleButton extends SettingButton {
|
||||
|
||||
private final BooleanSetting setting;
|
||||
|
||||
public ToggleButton(BooleanSetting setting, SettingsFrame parent, int offset) {
|
||||
super(setting, parent, offset);
|
||||
this.setting = setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
Color color = setting.isEnabled()
|
||||
? Colors.enabledToggleButtonColor
|
||||
: Colors.disabledToggleButtonColor;
|
||||
|
||||
if (isHovered((int) mouseX, (int) mouseY))
|
||||
color = color.brighter(); // simplemente utilizar el método "built-in" de Java para hacer el botón más claro cuando el puntero se encuentra encima de él
|
||||
// quizás debería de utilizar .brighter() más, en vez de dar valores personalizados
|
||||
|
||||
ctx.fill(x, y, x + w, y + height, color.getRGB());
|
||||
ctx.drawTextWithShadow(parent.mc.textRenderer,
|
||||
setting.getName(), x + 5, y + 3, -1);
|
||||
|
||||
// dibujar "tooltips" (cajas de texto) al pasar el puntero encima del botón, para mostrar su descripción
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
Screen currentScreen = parent.mc.currentScreen;
|
||||
if (currentScreen != null)
|
||||
ctx.drawTooltip(Text.of(setting.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
if (button == 0) setting.toggle(); // clic izquierdo para alternar
|
||||
else if (button == 1 && KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) // shift izquierdo + clic derecho para restablecer al valor por defecto
|
||||
setting.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public BooleanSetting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package me.retucio.camtweaks.ui.frames;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.GUISettingsFrameEvent;
|
||||
import me.retucio.camtweaks.module.modules.GUI;
|
||||
import me.retucio.camtweaks.ui.buttons.SettingButton;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ClickGUISettingsFrame extends SettingsFrame {
|
||||
|
||||
public static final GUI guiSettings = new GUI();
|
||||
public boolean extended = false;
|
||||
private String title = "ajustes de la interfaz -";
|
||||
|
||||
public ClickGUISettingsFrame(int x, int y, int w, int h) {
|
||||
super(guiSettings, x, y, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext ctx, int mouseX, int mouseY, float delta) {
|
||||
updateWidth();
|
||||
ctx.fill(x, y, x + w, y + h, Colors.frameHeadColor);
|
||||
|
||||
ctx.drawText(mc.textRenderer, title,
|
||||
x + (w / 2) - (mc.textRenderer.getWidth(title) / 2),
|
||||
y + (h / 2) - (mc.textRenderer.fontHeight / 2),
|
||||
-1, false);
|
||||
|
||||
List<SettingButton> visibleButtons = settingButtons.stream()
|
||||
.filter(sb -> sb.getSetting().isVisible())
|
||||
.toList();
|
||||
|
||||
if (extended) {
|
||||
int currentY = y + h + 3;
|
||||
ctx.fill(x, currentY - 2, x + w, currentY + visibleButtons.size() * h, Colors.frameBGColor);
|
||||
|
||||
for (SettingButton sb : visibleButtons) {
|
||||
sb.setX(x + 4);
|
||||
sb.setY(currentY);
|
||||
sb.setW(w - 8);
|
||||
sb.setH(h);
|
||||
sb.render(ctx, mouseX, mouseY, delta);
|
||||
currentY += h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
if (button == 0) {
|
||||
dragging = true;
|
||||
dragX = (int) (mouseX - x);
|
||||
dragY = (int) (mouseY - y);
|
||||
} else if (button == 1) {
|
||||
extended = !extended;
|
||||
title = extended ? "ajustes de la interfaz -" : "ajustes de la interfaz +";
|
||||
CameraTweaks.EVENT_BUS.post(new GUISettingsFrameEvent.Extend());
|
||||
}
|
||||
}
|
||||
|
||||
if (!extended) return; // solo dejar clicar en los módulos si el marco está extendido
|
||||
for (SettingButton settingButton : settingButtons)
|
||||
settingButton.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseRelease(double mouseX, double mouseY, int button) {
|
||||
if (button == 0 && dragging) {
|
||||
CameraTweaks.EVENT_BUS.post(new GUISettingsFrameEvent.Move());
|
||||
}
|
||||
super.mouseRelease(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
package me.retucio.camtweaks.ui.frames;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.ModuleFrameEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.ui.buttons.ModuleButton;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// marco para los módulos
|
||||
public class ModuleFrame {
|
||||
|
||||
public int x, y, w, h, dragX, dragY;
|
||||
public boolean dragging, extended;
|
||||
public String title = "módulos -";
|
||||
|
||||
private final List<ModuleButton> moduleButtons = new ArrayList<>();
|
||||
|
||||
public MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public ModuleFrame(int x, int y, int w, int h) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
dragging = false;
|
||||
extended = true;
|
||||
|
||||
// determinar el saliente para cada botón de módulo
|
||||
int offset = h;
|
||||
for (Module module : ModuleManager.INSTANCE.getModules()) {
|
||||
moduleButtons.add(new ModuleButton(module, this, offset));
|
||||
updateWidth();
|
||||
offset += h;
|
||||
}
|
||||
}
|
||||
|
||||
void updateWidth() {
|
||||
// asegurarse de que todos los botones caben en el marco, haciendo que la anchura se ajuste al texto más largo
|
||||
if (mc.textRenderer == null) return;
|
||||
|
||||
int maxWidth = mc.textRenderer.getWidth(title);
|
||||
for (ModuleButton button : moduleButtons) {
|
||||
String text = button.module.getName();
|
||||
int textWidth = mc.textRenderer.getWidth(text);
|
||||
maxWidth = Math.max(maxWidth, textWidth);
|
||||
}
|
||||
this.w = maxWidth + 22;
|
||||
}
|
||||
|
||||
public void render(DrawContext ctx, int mouseX, int mouseY, float delta) {
|
||||
updateWidth();
|
||||
ctx.fill(x, y, x + w, y + h, Colors.frameHeadColor); // cabeza del marco
|
||||
// título del marco
|
||||
ctx.drawText(mc.textRenderer, title,
|
||||
x + (w / 2) - (mc.textRenderer.getWidth(title) / 2),
|
||||
y + ( h /2) - (mc.textRenderer.fontHeight / 2),
|
||||
-1, false);
|
||||
|
||||
// dibujar sus módulos solo si está extendido
|
||||
if (extended) {
|
||||
int totalHeight = moduleButtons.size() * h + 3;
|
||||
ctx.fill( // fondo para los botones
|
||||
x, y + h + 1,
|
||||
x + w, y + h + totalHeight,
|
||||
Colors.frameBGColor);
|
||||
|
||||
// dibujar los botones para cada módulo
|
||||
for (ModuleButton moduleButton : moduleButtons)
|
||||
moduleButton.render(ctx, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
// registrar clics
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
if (button == 0) { // clic izquierdo para arrastrarlo
|
||||
dragging = true;
|
||||
dragX = (int) (mouseX - x);
|
||||
dragY = (int) (mouseY - y);
|
||||
} else if (button == 1) { // clic derecho para extenderlo
|
||||
extended = !extended;
|
||||
title = extended ? "módulos -" : "módulos +";
|
||||
CameraTweaks.EVENT_BUS.post(new ModuleFrameEvent.Extend());
|
||||
}
|
||||
}
|
||||
|
||||
if (!extended) return; // solo dejar clicar en los módulos si el marco está extendido
|
||||
for (ModuleButton moduleButton : moduleButtons) {
|
||||
if (moduleButton.isHovered((int) mouseX, (int) mouseY)) {
|
||||
moduleButton.mouseClicked(mouseX, mouseY, button);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// detectar cuándo se suelta el clic
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||
if (button == 0 && dragging) {
|
||||
dragging = false;
|
||||
}
|
||||
CameraTweaks.EVENT_BUS.post(new ModuleFrameEvent.Move());
|
||||
}
|
||||
|
||||
// verificar si el puntero del ratón se encuentra encima
|
||||
public boolean isHovered(double mouseX, double mouseY) {
|
||||
return mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h;
|
||||
}
|
||||
|
||||
// actualizar la posición al arrastrar el marco
|
||||
public void updatePosition(double mouseX, double mouseY) {
|
||||
if (dragging) {
|
||||
x = (int) (mouseX - dragX);
|
||||
y = (int) (mouseY - dragY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
package me.retucio.camtweaks.ui.frames;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.SettingsFrameEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.*;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.buttons.*;
|
||||
import me.retucio.camtweaks.ui.buttons.SliderButton;
|
||||
import me.retucio.camtweaks.ui.buttons.TextButton;
|
||||
import me.retucio.camtweaks.ui.buttons.ToggleButton;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// marco para los botones de los ajustes de cada módulo
|
||||
public class SettingsFrame {
|
||||
|
||||
private final String title;
|
||||
public final Module module;
|
||||
final List<SettingButton> settingButtons = new ArrayList<>();
|
||||
|
||||
public int x, y, w, h;
|
||||
boolean dragging;
|
||||
int dragX, dragY;
|
||||
|
||||
public final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public SettingsFrame(Module module, int x, int y, int w, int h) {
|
||||
this.module = module;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
|
||||
// añadir el respectivo tipo de botón de cada ajuste a la lista de botones
|
||||
int offset = h;
|
||||
for (Setting setting : module.getSettings()) {
|
||||
if (!setting.isVisible()) continue;
|
||||
switch (setting) {
|
||||
case BooleanSetting b -> {
|
||||
addButton(new ToggleButton(b, this, offset));
|
||||
offset += 18;
|
||||
} case NumberSetting n -> {
|
||||
addButton(new SliderButton(n, this, offset));
|
||||
offset += 18;
|
||||
} case EnumSetting e -> {
|
||||
addButton(new CycleButton<>(e, this, offset));
|
||||
offset += 18;
|
||||
} case KeySetting k -> {
|
||||
addButton(new BindButton(k, this, offset));
|
||||
offset += 18;
|
||||
} case StringSetting s -> {
|
||||
addButton(new TextButton(s, this, offset));
|
||||
offset += 18;
|
||||
} default -> {}
|
||||
}
|
||||
}
|
||||
title = "ajustes de " + module.getName() + " -";
|
||||
}
|
||||
|
||||
public void addButton(SettingButton button) {
|
||||
settingButtons.add(button);
|
||||
updateWidth(); // actualizar anchura del frame tras cada iteración
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
void updateWidth() {
|
||||
// asegurarse de que todos los botones caben en el marco, haciendo que la anchura se ajuste al texto más largo
|
||||
if (mc.textRenderer == null) return;
|
||||
|
||||
int maxWidth = mc.textRenderer.getWidth(title);
|
||||
for (SettingButton button : settingButtons) {
|
||||
String text = button.getSetting().getName();
|
||||
|
||||
switch (button) {
|
||||
case SliderButton sliderButton -> text += ": " + sliderButton.df.format((sliderButton.getSetting()).getValue());
|
||||
case CycleButton cycleButton -> text += ": " + cycleButton.getSetting().getValue();
|
||||
case BindButton bindButton -> text += ": " + bindButton.getSetting().getKeyName();
|
||||
case TextButton textButton -> text += ": " + textButton.getSetting().getValue();
|
||||
default -> {}
|
||||
}
|
||||
|
||||
int textWidth = mc.textRenderer.getWidth(text);
|
||||
maxWidth = Math.max(maxWidth, textWidth);
|
||||
}
|
||||
this.w = maxWidth + 22;
|
||||
}
|
||||
|
||||
public void render(DrawContext ctx, int mouseX, int mouseY, float delta) {
|
||||
updateWidth();
|
||||
ctx.fill(x, y, x + w, y + h, module.isEnabled()
|
||||
? Colors.enabledToggleButtonColor.getRGB()
|
||||
: Colors.disabledToggleButtonColor.getRGB());
|
||||
|
||||
ctx.drawText(mc.textRenderer, title,
|
||||
x + (w / 2) - (mc.textRenderer.getWidth(title) / 2),
|
||||
y + (h / 2) - (mc.textRenderer.fontHeight / 2),
|
||||
-1, false);
|
||||
|
||||
List<SettingButton> visibleButtons = settingButtons.stream()
|
||||
.filter(sb -> sb.getSetting().isVisible())
|
||||
.toList();
|
||||
|
||||
int currentY = y + h + 3;
|
||||
ctx.fill(x, currentY - 2, x + w, currentY + visibleButtons.size() * h, Colors.frameBGColor);
|
||||
|
||||
for (SettingButton sb : visibleButtons) {
|
||||
sb.setX(x + 4);
|
||||
sb.setY(currentY);
|
||||
sb.setW(w - 8);
|
||||
sb.setH(h);
|
||||
sb.render(ctx, mouseX, mouseY, delta);
|
||||
currentY += h;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
if (button == 0) {
|
||||
dragging = true;
|
||||
dragX = (int) (mouseX - x);
|
||||
dragY = (int) (mouseY - y);
|
||||
} else if (button == 1) {
|
||||
ClickGUI.INSTANCE.closeSettingsFrame(module);
|
||||
}
|
||||
}
|
||||
|
||||
for (SettingButton sb : settingButtons)
|
||||
if (sb.getSetting().isVisible())
|
||||
sb.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
public void mouseRelease(double mouseX, double mouseY, int button) {
|
||||
if (button == 0) {
|
||||
dragging = false;
|
||||
CameraTweaks.EVENT_BUS.post(new SettingsFrameEvent.Move(this));
|
||||
}
|
||||
for (SettingButton sb : settingButtons)
|
||||
if (sb.getSetting().isVisible()) sb.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
public void updatePosition(double mouseX, double mouseY) {
|
||||
if (dragging) {
|
||||
x = (int) (mouseX - dragX);
|
||||
y = (int) (mouseY - dragY);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHovered(double mouseX, double mouseY) {
|
||||
return mouseX > x && mouseX < x + w &&
|
||||
mouseY > y && mouseY < y + h;
|
||||
}
|
||||
|
||||
public List<SettingButton> getButtons() {
|
||||
return settingButtons;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package me.retucio.camtweaks.ui.widgets;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gl.RenderPipelines;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class SearchBarWidget extends TextFieldWidget {
|
||||
|
||||
private static final Identifier MENU_LIST_BACKGROUND_TEXTURE = Identifier.ofVanilla("textures/gui/menu_list_background.png");
|
||||
private static final Identifier INWORLD_MENU_LIST_BACKGROUND_TEXTURE = Identifier.ofVanilla("textures/gui/inworld_menu_list_background.png");
|
||||
|
||||
private boolean hookBackground;
|
||||
|
||||
public SearchBarWidget(TextRenderer textRenderer, int width, int height) {
|
||||
super(textRenderer, width, height, Text.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
|
||||
if (drawsBackground()) drawBackground(context);
|
||||
|
||||
hookBackground = true;
|
||||
super.renderWidget(context, mouseX, mouseY, deltaTicks);
|
||||
hookBackground = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean drawsBackground() {
|
||||
if (hookBackground) return false;
|
||||
return super.drawsBackground();
|
||||
}
|
||||
|
||||
private void drawBackground(DrawContext context) {
|
||||
Identifier identifier = MinecraftClient.getInstance().world == null ? MENU_LIST_BACKGROUND_TEXTURE : INWORLD_MENU_LIST_BACKGROUND_TEXTURE;
|
||||
context.drawTexture(
|
||||
RenderPipelines.GUI,
|
||||
identifier,
|
||||
this.getX(),
|
||||
this.getY(),
|
||||
this.getRight(),
|
||||
this.getBottom(),
|
||||
this.getWidth(),
|
||||
this.getHeight(),
|
||||
32,
|
||||
32
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package me.retucio.camtweaks.util;
|
||||
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
// cosas útiles relacionadas al chat
|
||||
public class ChatUtil {
|
||||
|
||||
private static final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
private static String prefix = Formatting.GREEN + "[" + ClickGUISettingsFrame.guiSettings.chatName.getValue() + "] ";
|
||||
|
||||
public static void addMessage(String text) {
|
||||
if (mc.inGameHud == null) return;
|
||||
mc.inGameHud.getChatHud().addMessage(Text.of(text));
|
||||
}
|
||||
|
||||
public static void addMessage(Text text) {
|
||||
if (mc.inGameHud == null) return;
|
||||
mc.inGameHud.getChatHud().addMessage(text);
|
||||
}
|
||||
|
||||
public static void addMessageWithPrefix(String text) {
|
||||
addMessageWithPrefix(Text.of(text));
|
||||
}
|
||||
|
||||
public static void addMessageWithPrefix(Text text) {
|
||||
addMessage(Text.literal(prefix + Formatting.RESET).append(text));
|
||||
}
|
||||
|
||||
public static void info(String text) {
|
||||
addMessage(Text.literal(prefix + Formatting.RESET + text));
|
||||
}
|
||||
|
||||
public static void info(Text text) {
|
||||
addMessage(Text.literal(prefix + Formatting.RESET).append(text));
|
||||
}
|
||||
|
||||
public static void warn(String text) {
|
||||
addMessage(Text.literal(prefix + Formatting.YELLOW + text));
|
||||
}
|
||||
|
||||
public static void warn(Text text) {
|
||||
addMessage(Text.literal(prefix + Formatting.YELLOW).append(text));
|
||||
}
|
||||
|
||||
public static void error(String text) {
|
||||
addMessage(Text.literal(prefix + Formatting.RED + text));
|
||||
}
|
||||
|
||||
public static void error(Text text) {
|
||||
addMessage(Text.literal(prefix + Formatting.RED).append(text));
|
||||
}
|
||||
|
||||
public static void sendServerMessage(String text) {
|
||||
sendServerMessage(Text.of(text));
|
||||
}
|
||||
|
||||
public static void sendServerMessage(Text text) {
|
||||
if (mc.player == null) return;
|
||||
mc.player.sendMessage(text, false);
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public static String getPrefixNoFormatting() {
|
||||
return "[" + ClickGUISettingsFrame.guiSettings.chatName.getValue() + "] ";
|
||||
}
|
||||
|
||||
public static void updatePrefix(String newPrefix) {
|
||||
prefix = Formatting.GREEN + "[" + newPrefix + "] ";
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package me.retucio.camtweaks.util;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import static me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame.guiSettings;
|
||||
|
||||
|
||||
// clase para los colores, para no repetirme (regla DRY)
|
||||
// si se ve especificado como color en algún lado "-1", significa blanco
|
||||
public class Colors {
|
||||
|
||||
public static int frameHeadRed = guiSettings.red.getIntValue();
|
||||
public static int frameHeadGreen = guiSettings.green.getIntValue();
|
||||
public static int frameHeadBlue = guiSettings.blue.getIntValue();
|
||||
public static int frameHeadAlpha = guiSettings.alpha.getIntValue();
|
||||
|
||||
public static int frameHeadColor = new Color(
|
||||
frameHeadRed,
|
||||
frameHeadGreen,
|
||||
frameHeadBlue,
|
||||
frameHeadAlpha
|
||||
).getRGB();
|
||||
|
||||
public static int frameBGColor = new Color(60, 60, 60, 70).getRGB();
|
||||
|
||||
public static int enabledHoveredModuleButtonColor = new Color(20, 20, 255, 180).getRGB();
|
||||
public static int enabledModuleButtonColor = new Color(0, 0, 255, 180).getRGB();
|
||||
public static int hoveredModuleButtonColor = new Color(30, 30, 30, 100).getRGB();
|
||||
public static int moduleButtonColor = new Color(40, 40, 40, 75).getRGB();
|
||||
|
||||
public static int hoveredSettingButtonColor = new Color(30, 30, 30, 100).getRGB();
|
||||
public static int settingButtonColor = new Color(40, 40, 40, 75).getRGB();
|
||||
public static int sliderFillingColor = new Color(60, 120, 220, 180).getRGB();
|
||||
|
||||
// necesitan ser de tipo java.awt.Color para utilizar el método .brighter()
|
||||
public static Color enabledToggleButtonColor = new Color(0, 180, 0, 180);
|
||||
public static Color disabledToggleButtonColor = new Color(120, 30, 30, 150);
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package me.retucio.camtweaks.util;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.mixin.accessor.KeyBindingAccessor;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
// cosas útiles relacionadas a las teclas
|
||||
public class KeyUtil {
|
||||
|
||||
public static boolean isKeyDown(int key) {
|
||||
return GLFW.glfwGetKey(
|
||||
CameraTweaks.mc.getWindow().getHandle(),
|
||||
key) != GLFW.GLFW_RELEASE;
|
||||
}
|
||||
|
||||
public static boolean isKeyDown(KeyBinding key) {
|
||||
return GLFW.glfwGetKey(
|
||||
CameraTweaks.mc.getWindow().getHandle(),
|
||||
((KeyBindingAccessor) key).getBoundKey().getCode()
|
||||
) != GLFW.GLFW_RELEASE;
|
||||
}
|
||||
|
||||
public static String getKeyName(int key) {
|
||||
if (key == GLFW.GLFW_KEY_UNKNOWN) return "ninguna";
|
||||
|
||||
String name = GLFW.glfwGetKeyName(key, 0);
|
||||
if (name != null) return name.toUpperCase();
|
||||
|
||||
// para teclas especiales
|
||||
return switch (key) {
|
||||
case GLFW.GLFW_KEY_SPACE -> "espacio";
|
||||
case GLFW.GLFW_KEY_LEFT_SHIFT -> "shift izquierdo";
|
||||
case GLFW.GLFW_KEY_RIGHT_SHIFT -> "shift derecho";
|
||||
case GLFW.GLFW_KEY_LEFT_CONTROL -> "ctrl izquierdo";
|
||||
case GLFW.GLFW_KEY_RIGHT_CONTROL -> "ctrl derecho";
|
||||
case GLFW.GLFW_KEY_LEFT_ALT -> "alt izquierdo";
|
||||
case GLFW.GLFW_KEY_RIGHT_ALT -> "alt gr";
|
||||
case GLFW.GLFW_KEY_TAB -> "tab";
|
||||
case GLFW.GLFW_KEY_ENTER -> "enter";
|
||||
case GLFW.GLFW_KEY_BACKSPACE -> "borrar";
|
||||
case GLFW.GLFW_KEY_DELETE -> "suprimir";
|
||||
case GLFW.GLFW_KEY_UP -> "arriba";
|
||||
case GLFW.GLFW_KEY_DOWN -> "abajo";
|
||||
case GLFW.GLFW_KEY_LEFT -> "izquierda";
|
||||
case GLFW.GLFW_KEY_RIGHT -> "derecha";
|
||||
default -> { // F1–F25
|
||||
if (key >= GLFW.GLFW_KEY_F1 && key <= GLFW.GLFW_KEY_F25)
|
||||
yield "F" + (key - GLFW.GLFW_KEY_F1 + 1);
|
||||
yield "tecla " + key;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// quizás debería de añadir layouts...
|
||||
public static String shiftKey(String c) {
|
||||
return switch (c) {
|
||||
case "`" -> "~";
|
||||
case "1" -> "!";
|
||||
case "2" -> "@";
|
||||
case "3" -> "#";
|
||||
case "4" -> "$";
|
||||
case "5" -> "%";
|
||||
case "6" -> "^";
|
||||
case "7" -> "&";
|
||||
case "8" -> "*";
|
||||
case "9" -> "(";
|
||||
case "0" -> ")";
|
||||
case "-" -> "_";
|
||||
case "=" -> "+";
|
||||
case "[" -> "{";
|
||||
case "]" -> "}";
|
||||
case "\\" -> "|";
|
||||
case ";" -> ":";
|
||||
case "'" -> "\"";
|
||||
case "," -> "<";
|
||||
case "." -> ">";
|
||||
case "/" -> "?";
|
||||
default -> c.toUpperCase();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package me.retucio.camtweaks.util;
|
||||
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.TickEvent;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
public class MiscUtil {
|
||||
|
||||
public static Screen screen;
|
||||
|
||||
private MiscUtil() {}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onTick(TickEvent.Post event) {
|
||||
if (screen != null && mc.currentScreen == null) {
|
||||
mc.setScreen(screen);
|
||||
screen = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyVector(Vector3d destination, Vec3d source) {
|
||||
destination.x = source.x;
|
||||
destination.y = source.y;
|
||||
destination.z = source.z;
|
||||
}
|
||||
|
||||
public static Vector3d getEntityVector(Vector3d vector, Entity entity, double tickDelta) {
|
||||
vector.x = MathHelper.lerp(tickDelta, entity.lastRenderX, entity.getX());
|
||||
vector.y = MathHelper.lerp(tickDelta, entity.lastRenderY, entity.getY());
|
||||
vector.z = MathHelper.lerp(tickDelta, entity.lastRenderZ, entity.getZ());
|
||||
return vector;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package me.retucio.camtweaks.util.interfaces;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public interface IChatHud {
|
||||
|
||||
void smegma$add(Text message, int id);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.retucio.camtweaks.util.interfaces;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public interface IChatHudLine {
|
||||
|
||||
String smegma$getText();
|
||||
|
||||
int smegma$getId();
|
||||
void smegma$setId(int id);
|
||||
|
||||
GameProfile smegma$getSender();
|
||||
void smegma$setSender(GameProfile profile);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package me.retucio.camtweaks.util.interfaces;
|
||||
|
||||
public interface IChatHudLineVisible extends IChatHudLine {
|
||||
|
||||
boolean smegma$isStartOfEntry();
|
||||
void smegma$setStartOfEntry(boolean start);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package me.retucio.camtweaks.util.interfaces;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public interface IMessageHandler {
|
||||
|
||||
GameProfile smegma$getSender();
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.retucio.camtweaks.util.interfaces;
|
||||
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
public interface IVec3d {
|
||||
|
||||
void smegma$set(double x, double y, double z);
|
||||
default void smegma$set(Vec3i vec) { smegma$set(vec.getX(), vec.getY(), vec.getZ()); }
|
||||
default void semgma$set(Vector3d vec) { smegma$set(vec.x, vec.y, vec.z); }
|
||||
|
||||
void smegma$setXZ(double x, double z);
|
||||
void smegma$setY(double y);
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
package me.retucio.sputnik;
|
||||
|
||||
import com.github.retucio.neutrino.EventBus;
|
||||
import me.retucio.sputnik.cape.CapeManager;
|
||||
import me.retucio.sputnik.command.CommandManager;
|
||||
import me.retucio.sputnik.command.commands.BindCommand;
|
||||
|
||||
import me.retucio.sputnik.config.ConfigManager;
|
||||
|
||||
import me.retucio.sputnik.event.ShutdownEvent;
|
||||
import me.retucio.sputnik.event.interact.OpenScreenEvent;
|
||||
import me.retucio.sputnik.event.sputnik.LoadCapeManagerEvent;
|
||||
import me.retucio.sputnik.event.sputnik.LoadClickGUIEvent;
|
||||
import me.retucio.sputnik.event.sputnik.LoadCommandManagerEvent;
|
||||
import me.retucio.sputnik.event.sputnik.LoadModuleManagerEvent;
|
||||
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.client.HUD;
|
||||
|
||||
import me.retucio.sputnik.ui.hud.HudRenderer;
|
||||
import me.retucio.sputnik.ui.screen.ClickGUI;
|
||||
import me.retucio.sputnik.ui.hud.HudEditorScreen;
|
||||
import me.retucio.sputnik.ui.screen.UpdateScreen;
|
||||
import me.retucio.sputnik.ui.widgets.buttons.settings.BindButton;
|
||||
import me.retucio.sputnik.ui.widgets.buttons.SettingButton;
|
||||
import me.retucio.sputnik.ui.widgets.buttons.settings.TextButton;
|
||||
import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame;
|
||||
import me.retucio.sputnik.ui.widgets.frames.SettingsFrame;
|
||||
import me.retucio.sputnik.ui.widgets.Button;
|
||||
|
||||
import me.retucio.sputnik.util.*;
|
||||
import me.retucio.sputnik.util.KeyUtil;
|
||||
import me.retucio.sputnik.util.render.DrawUtil;
|
||||
import me.retucio.sputnik.util.render.RenderUtil;
|
||||
|
||||
import me.retucio.sputnik.util.render.Textures;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ChatScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.AbstractCommandBlockScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.AnvilScreen;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
|
||||
public class Sputnik implements ClientModInitializer {
|
||||
|
||||
// cosas necesarias
|
||||
public static final Sputnik INSTANCE = new Sputnik();
|
||||
public static final EventBus EVENT_BUS = new EventBus();
|
||||
public static final Logger LOGGER = LogManager.getLogger(Sputnik.class);
|
||||
public static MinecraftClient mc;
|
||||
|
||||
// id y versión
|
||||
public static final String MOD_ID = "sputnik";
|
||||
public static final String MOD_VERSION = FabricLoader.getInstance()
|
||||
.getModContainer(MOD_ID)
|
||||
.orElseThrow()
|
||||
.getMetadata()
|
||||
.getVersion()
|
||||
.getFriendlyString();
|
||||
|
||||
private Screen prevScreen;
|
||||
public static boolean settingsApplied = false;
|
||||
|
||||
static {
|
||||
// puta vida
|
||||
System.setProperty("java.awt.headless", "false");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
mc = MinecraftClient.getInstance();
|
||||
ConfigManager.load();
|
||||
|
||||
VersionChecker.check();
|
||||
|
||||
EVENT_BUS.subscribe(this);
|
||||
|
||||
EVENT_BUS.subscribe(ChatUtil.class);
|
||||
EVENT_BUS.subscribe(DrawUtil.class);
|
||||
EVENT_BUS.subscribe(EntityUtil.class);
|
||||
EVENT_BUS.subscribe(InventoryUtil.class);
|
||||
EVENT_BUS.subscribe(MiscUtil.class);
|
||||
EVENT_BUS.subscribe(NetworkUtil.class);
|
||||
EVENT_BUS.subscribe(RenderUtil.class);
|
||||
|
||||
Lists.init();
|
||||
Textures.init();
|
||||
|
||||
CapeManager.INSTANCE = new CapeManager();
|
||||
EVENT_BUS.post(new LoadCapeManagerEvent());
|
||||
|
||||
ModuleManager.INSTANCE = new ModuleManager();
|
||||
EVENT_BUS.post(new LoadModuleManagerEvent());
|
||||
|
||||
CommandManager.INSTANCE = new CommandManager();
|
||||
EVENT_BUS.post(new LoadCommandManagerEvent());
|
||||
|
||||
ClickGUI.INSTANCE = new ClickGUI();
|
||||
HudEditorScreen.INSTANCE = new HudEditorScreen();
|
||||
EVENT_BUS.post(new LoadClickGUIEvent());
|
||||
|
||||
mc.execute(HudRenderer::init);
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
EVENT_BUS.post(new ShutdownEvent());
|
||||
}));
|
||||
}
|
||||
|
||||
// se ejecuta cada tick, es decir, 20 veces por segundo
|
||||
public void onTick() {
|
||||
if (!settingsApplied
|
||||
&& ConfigManager.getConfig() != null
|
||||
&& !ConfigManager.hasLoaded()) {
|
||||
ConfigManager.applyConfig();
|
||||
settingsApplied = true;
|
||||
}
|
||||
|
||||
ModuleManager.INSTANCE.getEnabledModules().forEach(Module::onTick);
|
||||
mc.getWindow().setTitle(ClientSettingsFrame.guiSettings.windowTitle.getValue());
|
||||
}
|
||||
|
||||
|
||||
// se ejecuta cada vez que se presiona una tecla
|
||||
public void onKey(int key, int action) {
|
||||
if (key == GLFW.GLFW_KEY_F3) return; // prevenir activación de módulos al usar combinaciones de F3
|
||||
|
||||
boolean anyFocused = isAnySettingButtonFocused() || ClickGUI.INSTANCE.getSearchBar().isFocused();
|
||||
ClickGUI.INSTANCE.setAnyFocused(anyFocused);
|
||||
|
||||
if (action != GLFW.GLFW_RELEASE) {
|
||||
if (BindCommand.onKeyPress(key)) return;
|
||||
if (action == GLFW.GLFW_PRESS) {
|
||||
handleModuleToggle(key, anyFocused);
|
||||
handleClickGUIKey(key, anyFocused);
|
||||
handleHudEditorKey(key, anyFocused);
|
||||
}
|
||||
handleSettingButtonsKey(key, action);
|
||||
} else if (!anyFocused) {
|
||||
handleModuleRelease(key);
|
||||
}
|
||||
}
|
||||
|
||||
// verifica si algún botón de ajustes está escuchando
|
||||
private boolean isAnySettingButtonFocused() {
|
||||
for (SettingsFrame sf : ClickGUI.INSTANCE.getSettingsFrames())
|
||||
for (Button sb : sf.getButtons())
|
||||
if ((sb instanceof BindButton b && b.isFocused()) || (sb instanceof TextButton t && t.isFocused()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// se ocupa de la lógica de encendido y apagado de los módulos
|
||||
private void handleModuleToggle(int key, boolean anyFocused) {
|
||||
if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return;
|
||||
|
||||
for (Module module : ModuleManager.INSTANCE.getModules()) {
|
||||
if (key != module.getKey() || anyFocused || KeyUtil.isKeyDown(GLFW.GLFW_KEY_F3)) continue; // evitar interrumpir combinaciones de teclas del F3
|
||||
|
||||
if (module.shouldToggleOnBindRelease() && !module.isEnabled())
|
||||
module.setEnabled(true);
|
||||
else if (!module.shouldToggleOnBindRelease())
|
||||
module.toggle();
|
||||
}
|
||||
}
|
||||
|
||||
// se ocupa de hacer los botones de ajustes que lo necesiten escuchar teclas
|
||||
private void handleSettingButtonsKey(int key, int action) {
|
||||
for (SettingsFrame sf : ClickGUI.INSTANCE.getSettingsFrames()) {
|
||||
for (SettingButton<?> sb : sf.getButtons()) {
|
||||
if (sb instanceof BindButton bb) bb.onKey(key, action);
|
||||
if (sb instanceof TextButton tb) tb.onKey(key, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// maneja la lógica de apertura de la interfaz
|
||||
private void handleClickGUIKey(int key, boolean anyFocused) {
|
||||
if (key != ClientSettingsFrame.guiSettings.getKey() || anyFocused || isOnTypingScreen())
|
||||
return;
|
||||
|
||||
if (mc.currentScreen != ClickGUI.INSTANCE) {
|
||||
prevScreen = mc.currentScreen;
|
||||
mc.setScreen(ClickGUI.INSTANCE);
|
||||
} else {
|
||||
ClickGUI.INSTANCE.close();
|
||||
mc.setScreen(prevScreen);
|
||||
}
|
||||
}
|
||||
|
||||
// manejar la lógica de apertura del editor de elementos del hud, con la misma lógica que handleClickGUIKey()
|
||||
private void handleHudEditorKey(int key, boolean anyFocused) {
|
||||
HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class);
|
||||
if (key != hud.editorKey.getValue() || anyFocused || isOnTypingScreen()) return;
|
||||
|
||||
if (mc.currentScreen != HudEditorScreen.INSTANCE) {
|
||||
if (!hud.isEnabled()) {
|
||||
ChatUtil.warn("HUD está desactivado, lumbreras");
|
||||
return;
|
||||
}
|
||||
prevScreen = mc.currentScreen;
|
||||
mc.setScreen(HudEditorScreen.INSTANCE);
|
||||
} else {
|
||||
HudEditorScreen.INSTANCE.close();
|
||||
mc.setScreen(prevScreen);
|
||||
}
|
||||
}
|
||||
|
||||
// se ocupa de apagar los módulos que tengan configurado hacerlo tras soltar su tecla
|
||||
private void handleModuleRelease(int key) {
|
||||
if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return;
|
||||
|
||||
for (Module module : ModuleManager.INSTANCE.getEnabledModules())
|
||||
if (module.shouldToggleOnBindRelease() && key == module.getKey())
|
||||
module.setEnabled(false);
|
||||
}
|
||||
|
||||
private boolean isOnTypingScreen() {
|
||||
return mc.currentScreen instanceof ChatScreen
|
||||
|| mc.currentScreen instanceof AnvilScreen
|
||||
|| mc.currentScreen instanceof AbstractSignEditScreen
|
||||
|| mc.currentScreen instanceof AbstractCommandBlockScreen;
|
||||
}
|
||||
|
||||
// notificar al usuario de que hay una actualización disponible, si la hay
|
||||
public void onSetScreen(OpenScreenEvent event) {
|
||||
if (VersionChecker.shouldShowScreen && event.getScreen() instanceof TitleScreen) {
|
||||
event.cancel();
|
||||
VersionChecker.shouldShowScreen = false;
|
||||
mc.execute(() -> mc.currentScreen = new UpdateScreen());
|
||||
}
|
||||
}
|
||||
|
||||
public void onStop(ShutdownEvent event) {
|
||||
ConfigManager.save();
|
||||
}
|
||||
|
||||
public static String getVersionName() {
|
||||
return MOD_ID + "_v" + MOD_VERSION + "_" + SharedConstants.getGameVersion().name();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package me.retucio.sputnik.cape;
|
||||
|
||||
import me.retucio.sputnik.Sputnik;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.texture.NativeImage;
|
||||
import net.minecraft.client.texture.NativeImageBackedTexture;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class Cape {
|
||||
|
||||
private final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
private final String name;
|
||||
private final Identifier id;
|
||||
private NativeImage img;
|
||||
private NativeImageBackedTexture texture;
|
||||
|
||||
public Cape(String name) {
|
||||
this.name = name;
|
||||
this.id = Identifier.of(Sputnik.MOD_ID, "textures/capes/" + name + ".png");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
this.img = loadTexture(this.id);
|
||||
}
|
||||
|
||||
public NativeImage loadTexture(Identifier id) {
|
||||
try (InputStream inputStream = mc.getResourceManager().getResource(id).get().getInputStream()) {
|
||||
return NativeImage.read(inputStream);
|
||||
} catch (IOException e) {
|
||||
Sputnik.LOGGER.error("ups: {}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void register() {
|
||||
texture = new NativeImageBackedTexture(null, img);
|
||||
mc.getTextureManager().registerTexture(id, texture);
|
||||
img = null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Identifier getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public NativeImageBackedTexture getTexture() {
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name.replace('-', ' ');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package me.retucio.sputnik.cape;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static me.retucio.sputnik.Sputnik.mc;
|
||||
|
||||
public class CapeManager {
|
||||
|
||||
public static CapeManager INSTANCE;
|
||||
|
||||
private final List<Cape> capes = new ArrayList<>();
|
||||
|
||||
public CapeManager() {
|
||||
addCapes();
|
||||
}
|
||||
|
||||
public void addCapes() {
|
||||
addCape("sputnik");
|
||||
addCape("half-life");
|
||||
addCape("hollow-knight");
|
||||
|
||||
addCape("cherry-blossom");
|
||||
addCape("migrator");
|
||||
addCape("minecraft");
|
||||
addCape("pancakes");
|
||||
addCape("vanilla");
|
||||
|
||||
addCape("tiktok");
|
||||
addCape("twitch");
|
||||
|
||||
addCape("mojang");
|
||||
addCape("mojang-old");
|
||||
addCape("mojang-old-old");
|
||||
|
||||
addCape("minecon-2011");
|
||||
addCape("minecon-2012");
|
||||
addCape("minecon-2013");
|
||||
addCape("minecon-2015");
|
||||
addCape("minecon-2016");
|
||||
addCape("experience-2025");
|
||||
|
||||
addCape("15th-anniversary");
|
||||
addCape("bedrock");
|
||||
addCape("birthday");
|
||||
addCape("copper");
|
||||
addCape("eye-blossom");
|
||||
addCape("mcc-15");
|
||||
addCape("prismarine");
|
||||
addCape("turtle");
|
||||
addCape("valentine");
|
||||
|
||||
addCape("chinese-translator");
|
||||
addCape("cobalt");
|
||||
addCape("mojira-mod");
|
||||
addCape("millionth-customer");
|
||||
addCape("realms-mapmaker");
|
||||
addCape("scrolls-champion");
|
||||
addCape("translator");
|
||||
|
||||
addCape("cheapsh0t");
|
||||
addCape("dannybstyle");
|
||||
addCape("julianclark");
|
||||
addCape("mrmessiah");
|
||||
|
||||
for (Cape cape : capes) {
|
||||
mc.execute(cape::load);
|
||||
mc.execute(cape::register);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCape(String name) {
|
||||
capes.add(new Cape(name));
|
||||
}
|
||||
|
||||
public Cape getCape(String name) {
|
||||
for (Cape cape : capes)
|
||||
if (cape.getName().equalsIgnoreCase(name))
|
||||
return cape;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Cape> getCapes() {
|
||||
return capes;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.retucio.camtweaks.command;
|
||||
package me.retucio.sputnik.command;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
@@ -65,7 +65,7 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return me.retucio.camtweaks.command.CommandManager.INSTANCE.getPrefix() + name;
|
||||
return me.retucio.sputnik.command.CommandManager.INSTANCE.getPrefix() + name;
|
||||
}
|
||||
|
||||
public String toString(String... args) {
|
||||
@@ -1,14 +1,18 @@
|
||||
package me.retucio.camtweaks.command;
|
||||
package me.retucio.sputnik.command;
|
||||
|
||||
import com.github.retucio.neutrino.EventListener;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import me.retucio.camtweaks.command.commands.*;
|
||||
import me.retucio.sputnik.Sputnik;
|
||||
import me.retucio.sputnik.command.commands.*;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
// registro de comandos
|
||||
public class CommandManager {
|
||||
@@ -28,13 +32,32 @@ public class CommandManager {
|
||||
|
||||
public static void registerCommands() {
|
||||
addCommand(new BindCommand());
|
||||
// addCommand(new EnderChestCommand()); no funciona D:
|
||||
addCommand(new ClickSlotCommand());
|
||||
addCommand(new ConfigCommand());
|
||||
addCommand(new CopyScreenshotCommand());
|
||||
addCommand(new EnderChestCommand());
|
||||
addCommand(new GarbageCleanerCommand());
|
||||
addCommand(new PeekCommand());
|
||||
addCommand(new PluginsCommand());
|
||||
addCommand(new PrefixCommand());
|
||||
addCommand(new PurgeCommand());
|
||||
addCommand(new RepeatCommand());
|
||||
addCommand(new SaveScreenshotCommand());
|
||||
addCommand(new SendCommand());
|
||||
addCommand(new SpectateCommand());
|
||||
addCommand(new ToggleCommand());
|
||||
addCommand(new WaitCommand());
|
||||
|
||||
commands.sort(Comparator.comparing(Command::getName));
|
||||
|
||||
for (Command command : commands) {
|
||||
for (Method method : command.getClass().getDeclaredMethods()) {
|
||||
if (method.isAnnotationPresent(EventListener.class)) {
|
||||
Sputnik.EVENT_BUS.subscribe(command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCommand(Command command) {
|
||||
@@ -44,17 +67,17 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
public static void dispatch(String message) throws CommandSyntaxException {
|
||||
dispatcher.execute(message, mc.getNetworkHandler().getCommandSource());
|
||||
dispatcher.execute(message, Objects.requireNonNull(mc.getNetworkHandler()).getCommandSource());
|
||||
}
|
||||
|
||||
public static Command getCommandByName(String name) {
|
||||
for (Command command : commands) {
|
||||
if (command.getName().equals(name))
|
||||
return command;
|
||||
if (command.getName().equals(name)) return command;
|
||||
|
||||
for (String alias : command.getAliases())
|
||||
if (alias.equals(name))
|
||||
return command;
|
||||
if (alias.equals(name)) return command;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
package me.retucio.sputnik.command.args;
|
||||
|
||||
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.retucio.sputnik.util.EntityUtil;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static me.retucio.sputnik.Sputnik.mc;
|
||||
|
||||
|
||||
// para autocompletar entidades
|
||||
public class EntityArgumentType implements ArgumentType<Entity> {
|
||||
|
||||
public static final EntityArgumentType INSTANCE = new EntityArgumentType();
|
||||
private static final DynamicCommandExceptionType NO_SUCH_ENTITY = new DynamicCommandExceptionType(
|
||||
name -> Text.literal("Entidad \"" + name + "\" no encontrada"));
|
||||
|
||||
private static final Collection<String> EXAMPLES = List.of(
|
||||
"AdlerHitdolf",
|
||||
"@p"
|
||||
);
|
||||
|
||||
private static final Pattern UUID_PATTERN = Pattern.compile(
|
||||
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
|
||||
);
|
||||
|
||||
private EntityArgumentType() {}
|
||||
|
||||
@Override
|
||||
public Entity parse(StringReader reader) throws CommandSyntaxException {
|
||||
String argument = reader.readString();
|
||||
|
||||
if (mc.world == null)
|
||||
throw NO_SUCH_ENTITY.create(argument);
|
||||
|
||||
if (argument.startsWith("@"))
|
||||
return parseSelector(argument);
|
||||
|
||||
if (isUUID(argument)) {
|
||||
UUID uuid = UUID.fromString(argument);
|
||||
return findEntityByUUID(uuid);
|
||||
}
|
||||
|
||||
return findPlayerByName(argument);
|
||||
}
|
||||
|
||||
private boolean isUUID(String input) {
|
||||
return UUID_PATTERN.matcher(input).matches();
|
||||
}
|
||||
|
||||
private Entity parseSelector(String selector) throws CommandSyntaxException {
|
||||
if (mc.player == null) throw NO_SUCH_ENTITY.create(selector);
|
||||
|
||||
return switch (selector.toLowerCase()) {
|
||||
case "@p" ->
|
||||
findNearestPlayer();
|
||||
case "@r" ->
|
||||
findRandomPlayer();
|
||||
case "@s" ->
|
||||
mc.player;
|
||||
case "@a" -> throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument()
|
||||
.createWithContext(new StringReader(selector));
|
||||
default -> {
|
||||
if (selector.startsWith("@e"))
|
||||
yield parseEntitySelector(selector);
|
||||
else if (selector.startsWith("@p") && selector.length() > 2)
|
||||
yield parsePlayerSelector(selector);
|
||||
throw NO_SUCH_ENTITY.create(selector);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Entity findNearestPlayer() throws CommandSyntaxException {
|
||||
PlayerEntity nearest = null;
|
||||
double nearestDistance = Double.MAX_VALUE;
|
||||
|
||||
for (PlayerEntity player : mc.world.getPlayers()) {
|
||||
if (player == mc.player) continue;
|
||||
|
||||
double distance = mc.player.squaredDistanceTo(player);
|
||||
if (distance < nearestDistance) {
|
||||
nearestDistance = distance;
|
||||
nearest = player;
|
||||
}
|
||||
}
|
||||
|
||||
if (nearest == null)
|
||||
throw NO_SUCH_ENTITY.create("@p");
|
||||
|
||||
return nearest;
|
||||
}
|
||||
|
||||
private Entity findRandomPlayer() throws CommandSyntaxException {
|
||||
List<PlayerEntity> players = new ArrayList<>(mc.world.getPlayers());
|
||||
if (players.isEmpty()) throw NO_SUCH_ENTITY.create("@r");
|
||||
|
||||
players.remove(mc.player);
|
||||
if (players.isEmpty()) return mc.player;
|
||||
|
||||
Random random = new Random();
|
||||
return players.get(random.nextInt(players.size()));
|
||||
}
|
||||
|
||||
private Entity parseEntitySelector(String selector) throws CommandSyntaxException {
|
||||
if (selector.equals("@e")) {
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
for (Entity entity : mc.world.getEntities())
|
||||
if (!(entity instanceof PlayerEntity))
|
||||
entities.add(entity);
|
||||
|
||||
if (entities.isEmpty()) throw NO_SUCH_ENTITY.create(selector);
|
||||
|
||||
Random random = new Random();
|
||||
return entities.get(random.nextInt(entities.size()));
|
||||
}
|
||||
|
||||
if (selector.startsWith("@e[type=")) {
|
||||
String type = selector.substring(8, selector.length() - 1);
|
||||
return findEntityByType(type);
|
||||
}
|
||||
|
||||
throw NO_SUCH_ENTITY.create(selector);
|
||||
}
|
||||
|
||||
private Entity parsePlayerSelector(String selector) throws CommandSyntaxException {
|
||||
return findNearestPlayer();
|
||||
}
|
||||
|
||||
private Entity findEntityByType(String type) throws CommandSyntaxException {
|
||||
List<Entity> matchingEntities = new ArrayList<>();
|
||||
|
||||
for (Entity entity : mc.world.getEntities()) {
|
||||
String entityType = entity.getType().getTranslationKey();
|
||||
if (entityType.contains(type.toLowerCase().replace("minecraft:", "")))
|
||||
matchingEntities.add(entity);
|
||||
}
|
||||
|
||||
if (matchingEntities.isEmpty()) throw NO_SUCH_ENTITY.create(type);
|
||||
|
||||
Entity nearest = null;
|
||||
double nearestDistance = Double.MAX_VALUE;
|
||||
|
||||
for (Entity entity : matchingEntities) {
|
||||
double distance = mc.player.squaredDistanceTo(entity);
|
||||
if (distance < nearestDistance) {
|
||||
nearestDistance = distance;
|
||||
nearest = entity;
|
||||
}
|
||||
}
|
||||
|
||||
return nearest;
|
||||
}
|
||||
|
||||
private Entity findEntityByUUID(UUID uuid) throws CommandSyntaxException {
|
||||
for (Entity entity : mc.world.getEntities())
|
||||
if (entity.getUuid().equals(uuid))
|
||||
return entity;
|
||||
|
||||
throw NO_SUCH_ENTITY.create(uuid.toString());
|
||||
}
|
||||
|
||||
private PlayerEntity findPlayerByName(String name) throws CommandSyntaxException {
|
||||
for (PlayerEntity player : mc.world.getPlayers())
|
||||
if (player.getName().getString().equalsIgnoreCase(name))
|
||||
return player;
|
||||
|
||||
throw NO_SUCH_ENTITY.create(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
|
||||
if (mc.world != null)
|
||||
for (PlayerEntity player : mc.world.getPlayers())
|
||||
builder.suggest(player.getName().getString());
|
||||
|
||||
|
||||
builder.suggest("@p");
|
||||
builder.suggest("@r");
|
||||
builder.suggest("@s");
|
||||
|
||||
Entity lookingAt = EntityUtil.getEntityPlayerIsLookingAt();
|
||||
if (lookingAt != null)
|
||||
builder.suggest(lookingAt.getUuid().toString());
|
||||
|
||||
return builder.buildFuture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getExamples() {
|
||||
return EXAMPLES;
|
||||
}
|
||||
|
||||
public static Entity get(CommandContext<?> context, String name) {
|
||||
return context.getArgument(name, Entity.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package me.retucio.sputnik.command.args;
|
||||
|
||||
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 net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class EnumArgumentType<T extends Enum<T>> implements ArgumentType<T> {
|
||||
|
||||
private static final DynamicCommandExceptionType NO_SUCH_TYPE = new DynamicCommandExceptionType((value) -> Text.of(" argumento inválido: " + value));
|
||||
|
||||
private final T[] values;
|
||||
|
||||
public EnumArgumentType(T defaultValue) {
|
||||
this.values = defaultValue.getDeclaringClass().getEnumConstants();
|
||||
}
|
||||
|
||||
public static <T extends Enum<T>> EnumArgumentType<T> enumArgument(T defaultValue) {
|
||||
return new EnumArgumentType<>(defaultValue);
|
||||
}
|
||||
|
||||
public static <T extends Enum<T>> T getEnum(CommandContext<?> context, String name, T defaultValue) {
|
||||
return context.getArgument(name, defaultValue.getDeclaringClass());
|
||||
}
|
||||
|
||||
public T parse(StringReader reader) throws CommandSyntaxException {
|
||||
String argument = reader.readString();
|
||||
return Arrays.stream(this.values)
|
||||
.filter((value) -> value.toString().equals(argument))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> NO_SUCH_TYPE.create(argument)
|
||||
);
|
||||
}
|
||||
|
||||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
|
||||
return CommandSource.suggestMatching(Arrays.stream(this.values).map(e -> e.toString().toLowerCase()), builder);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.retucio.camtweaks.command.args;
|
||||
package me.retucio.sputnik.command.args;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
@@ -7,8 +7,9 @@ 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.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.util.MiscUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
@@ -19,7 +20,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class ModuleArgumentType implements ArgumentType<Module> {
|
||||
|
||||
public static final ModuleArgumentType INSTANCE = new ModuleArgumentType();
|
||||
private static final DynamicCommandExceptionType unknownModuleE = new DynamicCommandExceptionType(
|
||||
|
||||
private static final DynamicCommandExceptionType UNKNOWN_MODULE = new DynamicCommandExceptionType(
|
||||
name -> Text.literal("módulo \"" + name + "\" no encontrado"));
|
||||
|
||||
private static final Collection<String> examples = ModuleManager.INSTANCE.getModules()
|
||||
@@ -29,13 +31,14 @@ public class ModuleArgumentType implements ArgumentType<Module> {
|
||||
public Module parse(StringReader reader) throws CommandSyntaxException {
|
||||
String argument = reader.readString().replace("_", " ");
|
||||
Module module = ModuleManager.INSTANCE.getModuleByName(argument);
|
||||
if (module == null) throw unknownModuleE.create(argument);
|
||||
if (module == null) throw UNKNOWN_MODULE.create(argument);
|
||||
return module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
|
||||
return CommandSource.suggestMatching(ModuleManager.INSTANCE.getModules().stream().map(module -> module.getName().replace(" ", "_")), builder);
|
||||
return CommandSource.suggestMatching(ModuleManager.INSTANCE.getModules()
|
||||
.stream().map(module -> MiscUtil.removeAccentMarks(module.getName().replace(" ", "_"))), builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.retucio.camtweaks.command.args;
|
||||
package me.retucio.sputnik.command.args;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
@@ -15,7 +15,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
import static me.retucio.sputnik.Sputnik.mc;
|
||||
|
||||
// para autocompletar nombres de jugadores
|
||||
public class PlayerArgumentType implements ArgumentType<PlayerEntity> {
|
||||
@@ -45,7 +45,8 @@ public class PlayerArgumentType implements ArgumentType<PlayerEntity> {
|
||||
|
||||
@Override
|
||||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
|
||||
return CommandSource.suggestMatching(mc.world.getPlayers().stream().map(abstractClientPlayerEntity -> abstractClientPlayerEntity.getName().getString()), builder);
|
||||
return CommandSource.suggestMatching(mc.world.getPlayers().stream().map(
|
||||
abstractClientPlayerEntity -> abstractClientPlayerEntity.getName().getString()), builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,12 +1,12 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.command.args.ModuleArgumentType;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.KeySetting;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.command.args.ModuleArgumentType;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import me.retucio.sputnik.module.setting.settings.KeySetting;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import me.retucio.sputnik.util.KeyUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
@@ -42,8 +42,7 @@ public class BindCommand extends Command {
|
||||
public static boolean onKeyPress(int key) {
|
||||
if (listeningModule == null) return false;
|
||||
KeySetting bind = listeningModule.getBind();
|
||||
if (bind != null)
|
||||
bind.setKey(key);
|
||||
if (bind != null) bind.setValue(key);
|
||||
|
||||
ChatUtil.info(
|
||||
Text.of("la tecla " + Formatting.AQUA + KeyUtil.getKeyName(key) + Formatting.RESET +
|
||||
@@ -0,0 +1,35 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.command.args.EnumArgumentType;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
|
||||
// https://cdn.discordapp.com/attachments/1456079799045980400/1457154232737206375/dupersunited-public-addon-1.21.11-3.1.3.jar?ex=69735be1&is=69720a61&hm=77fb6faee49762e0a812661f0d98931e89cb725db711c45722249d0efe3b91e4&
|
||||
public class ClickSlotCommand extends Command {
|
||||
|
||||
public ClickSlotCommand() {
|
||||
super("clickslot", "simula un clic a un slot");
|
||||
}
|
||||
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.then(argument("slot", IntegerArgumentType.integer())
|
||||
.then(argument("botón", IntegerArgumentType.integer())
|
||||
.then(argument("acción", EnumArgumentType.enumArgument(SlotActionType.SWAP))
|
||||
.executes(context -> {
|
||||
int slot = context.getArgument("slot", Integer.class), button = context.getArgument("botón", Integer.class);
|
||||
SlotActionType action = context.getArgument("acción", SlotActionType.class);
|
||||
Screen screen = mc.currentScreen;
|
||||
int syncId = (screen instanceof GenericContainerScreen gcScreen) ? gcScreen.getScreenHandler().syncId : 0;
|
||||
mc.interactionManager.clickSlot(syncId, slot, button, action, mc.player);
|
||||
return SUCCESS;
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.command.args.ModuleArgumentType;
|
||||
import me.retucio.sputnik.ui.screen.ClickGUI;
|
||||
import me.retucio.sputnik.ui.widgets.frames.SettingsFrame;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
|
||||
public class ConfigCommand extends Command {
|
||||
|
||||
public ConfigCommand() {
|
||||
super("config", "abre el marco de ajustes de un módulo", "ajustes", "settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder
|
||||
.then(argument("módulo", ModuleArgumentType.INSTANCE)
|
||||
.executes(ctx -> {
|
||||
mc.execute(() -> openSf(ctx));
|
||||
return SUCCESS;
|
||||
})
|
||||
.then(argument("x", IntegerArgumentType.integer())
|
||||
.then(argument("y", IntegerArgumentType.integer())
|
||||
.executes(ctx -> {
|
||||
mc.execute(() -> openSfWithPos(ctx,
|
||||
ctx.getArgument("x", Integer.class),
|
||||
ctx.getArgument("y", Integer.class)));
|
||||
return SUCCESS;
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private void openSf(CommandContext<CommandSource> ctx) {
|
||||
Module module = ctx.getArgument("módulo", Module.class);
|
||||
mc.setScreen(ClickGUI.INSTANCE);
|
||||
|
||||
if (ClickGUI.INSTANCE.isSettingsFrameOpen(module)) return;
|
||||
|
||||
SettingsFrame sf = ClickGUI.INSTANCE.getSfOfModule(module);
|
||||
int x = mc.getWindow().getScaledWidth() / 2 - sf.getW() / 2;
|
||||
int y = 67;
|
||||
|
||||
ClickGUI.INSTANCE.openSettingsFrame(module, x, y);
|
||||
}
|
||||
|
||||
private void openSfWithPos(CommandContext<CommandSource> ctx, int x, int y) {
|
||||
Module module = ctx.getArgument("módulo", Module.class);
|
||||
mc.setScreen(ClickGUI.INSTANCE);
|
||||
|
||||
if (ClickGUI.INSTANCE.isSettingsFrameOpen(module)) {
|
||||
SettingsFrame sf = ClickGUI.INSTANCE.getSfOfModule(module);
|
||||
sf.setX(x);
|
||||
sf.setY(y);
|
||||
}
|
||||
|
||||
ClickGUI.INSTANCE.openSettingsFrame(module, x, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
// se usa principalmente para el módulo ScreenshotPlus, pero también se puede usar sin él supongo
|
||||
public class CopyScreenshotCommand extends Command {
|
||||
|
||||
public CopyScreenshotCommand() {
|
||||
super("copiarcaptura", "copia la captura más reciente al portapapeles");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(ctx -> {
|
||||
ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class);
|
||||
|
||||
if (screenshotPlus.getScreenshot() != null) mc.execute(screenshotPlus::copyScreenshot);
|
||||
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.event.TickEvent;
|
||||
import me.retucio.sputnik.ui.screen.PreviewScreen;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import me.retucio.sputnik.util.InventoryUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
// accede a los contenidos de tu enderchest
|
||||
public class EnderChestCommand extends Command {
|
||||
|
||||
private boolean shouldOpenEchest = false;
|
||||
|
||||
public EnderChestCommand() {
|
||||
super("echest", "muestra el contenido de tu enderchest (solo de ver)", "ec", "enderchest");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(ctx -> {
|
||||
mc.execute(() -> {
|
||||
if (mc.player == null) return;
|
||||
if (InventoryUtil.getEchestInv() == null) {
|
||||
ChatUtil.warn("necesitas abrir un enderchest una vez primero");
|
||||
return;
|
||||
}
|
||||
|
||||
shouldOpenEchest = true;
|
||||
});
|
||||
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
|
||||
public void onTick(TickEvent.Post event) {
|
||||
if (shouldOpenEchest) {
|
||||
shouldOpenEchest = false;
|
||||
if (InventoryUtil.getEchestInv() != null)
|
||||
mc.setScreen(new PreviewScreen(InventoryUtil.getEchestInv(), null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class GarbageCleanerCommand extends Command {
|
||||
|
||||
public GarbageCleanerCommand() {
|
||||
super("gc", "limpia la ram mediante el recolector de basura (gc)", "garbagecollect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(context -> {
|
||||
System.gc();
|
||||
ChatUtil.info(Text.of("basura recolectada"));
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.command.args.PlayerArgumentType;
|
||||
import me.retucio.camtweaks.util.MiscUtil;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.command.args.PlayerArgumentType;
|
||||
import me.retucio.sputnik.util.MiscUtil;
|
||||
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import me.retucio.sputnik.Sputnik;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.event.network.PacketEvent;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
|
||||
import net.minecraft.client.network.ClientCommandSource;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class PluginsCommand extends Command {
|
||||
private final Set<String> plugins = new HashSet<>();
|
||||
private boolean scanning = false;
|
||||
|
||||
public PluginsCommand() {
|
||||
super("plugins", "busca los plugins que tenga el server", "pl", "serverplugins");
|
||||
Sputnik.EVENT_BUS.subscribe(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(context -> {
|
||||
if (mc.isIntegratedServerRunning()) {
|
||||
ChatUtil.error("estás en un solo jugador");
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
if (scanning) {
|
||||
ChatUtil.error("calmaaa");
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
plugins.clear();
|
||||
scanning = true;
|
||||
|
||||
findNamespaces();
|
||||
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
|
||||
private void findNamespaces() {
|
||||
try {
|
||||
ClientPlayNetworkHandler networkHandler = mc.getNetworkHandler();
|
||||
if (networkHandler == null || networkHandler.getCommandDispatcher() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RootCommandNode<ClientCommandSource> root = networkHandler.getCommandDispatcher().getRoot();
|
||||
root.getChildren().forEach(this::checkNodeForPlugins);
|
||||
|
||||
if (!plugins.isEmpty()) {
|
||||
ChatUtil.info(plugins.size() + " namespace(s) encontrado(s) de comandos:");
|
||||
plugins.stream()
|
||||
.sorted()
|
||||
.forEach(plugin -> ChatUtil.info(" - " + plugin));
|
||||
}
|
||||
|
||||
displayResults();
|
||||
|
||||
} catch (Exception e) {
|
||||
ChatUtil.error("error analizando comandos: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNodeForPlugins(CommandNode<ClientCommandSource> node) {
|
||||
String name = node.getName();
|
||||
|
||||
if (name.contains(":")) {
|
||||
String namespace = name.split(":")[0];
|
||||
if (!namespace.equalsIgnoreCase("minecraft")
|
||||
&& !namespace.equalsIgnoreCase("bukkit")
|
||||
&& !namespace.equalsIgnoreCase("spigot")
|
||||
&& !namespace.equalsIgnoreCase("paper")) {
|
||||
plugins.add(namespace);
|
||||
}
|
||||
}
|
||||
|
||||
node.getChildren().forEach(this::checkNodeForPlugins);
|
||||
}
|
||||
|
||||
private void onPacketReceive(PacketEvent.Receive event) {
|
||||
if (!scanning) return;
|
||||
|
||||
if (event.getPacket() instanceof CommandTreeS2CPacket) {
|
||||
findNamespaces();
|
||||
}
|
||||
}
|
||||
|
||||
private void displayResults() {
|
||||
if (!plugins.isEmpty()) {
|
||||
ChatUtil.info(plugins.size() + " plugin(s) encontrado(s)");
|
||||
plugins.stream().sorted()
|
||||
.forEach(plugin -> ChatUtil.info(" - " + plugin));
|
||||
} else {
|
||||
ChatUtil.warn("sin plugins (probablemente)");
|
||||
}
|
||||
|
||||
scanning = false;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
@@ -21,7 +21,7 @@ public class PrefixCommand extends Command {
|
||||
builder
|
||||
.then(argument("prefijo", StringArgumentType.word()).executes(ctx -> {
|
||||
String prefix = ctx.getArgument("prefijo", String.class);
|
||||
ClickGUISettingsFrame.guiSettings.commandPrefix.setValue(prefix);
|
||||
ClientSettingsFrame.guiSettings.commandPrefix.setValue(prefix);
|
||||
ChatUtil.info(Text.literal("prefijo cambiado a " + Formatting.AQUA + prefix));
|
||||
return SUCCESS;
|
||||
}));
|
||||
@@ -0,0 +1,40 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.util.interfaces.IChatHud;
|
||||
import net.minecraft.client.gui.hud.ChatHud;
|
||||
import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeCommand extends Command {
|
||||
|
||||
public PurgeCommand() {
|
||||
super("purgar", "elimina mensajes del chat", "purge");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.then(argument("cantidad", IntegerArgumentType.integer(1))
|
||||
.executes(context -> {
|
||||
int amount = IntegerArgumentType.getInteger(context, "cantidad");
|
||||
purgeMessages(amount);
|
||||
return 1;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private void purgeMessages(int amount) {
|
||||
ChatHud chatHud = mc.inGameHud.getChatHud();
|
||||
|
||||
synchronized (chatHud) {
|
||||
List<ChatHudLine.Visible> visibleMessages = ((IChatHud) chatHud).sputnik$getVisibleMessages();
|
||||
int toRemove = Math.min(amount, visibleMessages.size());
|
||||
for (int i = 0; i < toRemove; i++)
|
||||
visibleMessages.removeFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
public class RepeatCommand extends Command {
|
||||
|
||||
public RepeatCommand() {
|
||||
super("repetir", "repite un comando x veces", "repeat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder
|
||||
.then(argument("veces", IntegerArgumentType.integer(1))
|
||||
.then(argument("comando", StringArgumentType.greedyString())
|
||||
.executes(ctx -> {
|
||||
int j = ctx.getArgument("veces", Integer.class);
|
||||
String command = ctx.getArgument("comando", String.class);
|
||||
for (int i = 0; i < j; i++) {
|
||||
ChatUtil.simulateChatMessage(command);
|
||||
}
|
||||
return SUCCESS;
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// se usa principalmente para el módulo ScreenshotPlus, pero también se puede usar sin él supongo
|
||||
public class SaveScreenshotCommand extends Command {
|
||||
|
||||
public SaveScreenshotCommand() {
|
||||
super("guardarcaptura", "guarda localmente la captura más reciente");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(ctx -> {
|
||||
ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class);
|
||||
|
||||
mc.execute(() -> {
|
||||
if (screenshotPlus.getScreenshot() != null) {
|
||||
try {
|
||||
screenshotPlus.saveScreenshot();
|
||||
} catch (IOException e) {
|
||||
ChatUtil.error("no se pudo guardar la captura");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.mixin.accessor.ClientPlayNetworkHandlerAccessor;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.mixin.accessors.ClientPlayNetworkHandlerAccessor;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.network.encryption.NetworkEncryptionUtils;
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.network.message.LastSeenMessagesCollector;
|
||||
import net.minecraft.network.message.MessageBody;
|
||||
import net.minecraft.network.message.MessageSignatureData;
|
||||
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||