Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1a03f3ddb | ||
|
|
44494830be | ||
|
|
73682cb85d | ||
|
|
ac7de7a07a | ||
|
|
0bd31971a0 | ||
|
|
3010b164ab | ||
|
|
6cb4656365 | ||
|
|
272c1059ef | ||
|
|
e0f8523809 | ||
|
|
81fc25c33d |
No files matched your search
@@ -0,0 +1,82 @@
|
||||
<p align="center">
|
||||
<a href="README.md"><img src="https://img.shields.io/badge/lang-Español-yellow.svg" alt="español"></a>
|
||||
<a href="README.en.md"><img src="https://img.shields.io/badge/lang-English-blue.svg" alt="english"></a>
|
||||
</p>
|
||||
|
||||
# jenny's mod 2 (100% real)
|
||||
|
||||
> Minecraft Fabric 26.2 mod that adds some "QOL" features, mostly related to the camera.
|
||||
|
||||
## installation
|
||||
|
||||
### for normal people:
|
||||
1. go to [releases](https://codeberg.org/retucio/sputnik/releases)
|
||||
2. choose the most recent version
|
||||
3. download the .jar file
|
||||
4. move it to your mods dir (prolly `%appdata%/.minecraft/mods`)
|
||||
|
||||
|
||||
make sure to have a Minecraft and Fabric version compatible with the mod (MC `26.2`; Fabric `0.19.3`)
|
||||
|
||||
issues could arise when using it with other mods, especially other clients, since they could conflict
|
||||
|
||||
### for nerds
|
||||
1. clone the repo (`git clone https://codeberg.org/retucio/sputnik`)
|
||||
2. enter the repo dir (`cd sputnik`)
|
||||
3. `gradlew build` for Windows (ew) or `chmod +x gradlew` + `./gradlew build` for Unix-likes (Linux & Mac)
|
||||
4. the built .jar will be found in `/build/libs/sputnik-X.X.jar`
|
||||
|
||||
## usage
|
||||
|
||||
`rshift` by default to open the GUI
|
||||
|
||||
`insert` by default to open the HUD editor
|
||||
|
||||
`$` as prefix for commands (autocompleted)
|
||||
|
||||
some modules have keys assigned by default, assign them `ESC` to unbind them.
|
||||
|
||||
## ui
|
||||
|
||||
- left click to toggle modules
|
||||
- right click to open its settings
|
||||
- left click + drag to move a panel
|
||||
- right click on a panel's header to expand/contract it, or to close it
|
||||
- left click over settings to change them
|
||||
- shift + right click on a setting to reset it to its default value
|
||||
- place the mouse cursor over a module/setting to read its description
|
||||
|
||||
## screenshots
|
||||
|
||||
<img src="screenshots/automine.png" alt="auto mine">
|
||||
<img src="screenshots/blockesp.png" alt="block ESP + light overlay">
|
||||
<img src="screenshots/camtweaks.png" alt="perspective plus">
|
||||
<img src="screenshots/chatplus.png" alt="chatplus + nametags + screenshots plus">
|
||||
<img src="screenshots/clickgui.png" alt="click GUI">
|
||||
<img src="screenshots/freecam.png" alt="freecam + tracers">
|
||||
<img src="screenshots/hudeditor.png" alt="HUD editor">
|
||||
<img src="screenshots/itemphysics.png" alt="item physics">
|
||||
<img src="screenshots/lsd.png" alt="lsd module">
|
||||
<img src="screenshots/macros.png" alt="macros tab">
|
||||
<img src="screenshots/trajectories.png" alt="projectile trajectories">
|
||||
|
||||
|
||||
## contribution
|
||||
|
||||
yes please (PRs are welcome)
|
||||
|
||||
## license
|
||||
|
||||
[CC0 license](LICENSE)
|
||||
|
||||
## disclaimer
|
||||
|
||||
i don't give a single fuck what happens to you when using this mod on servers where its features are bannable and such.
|
||||
|
||||
## deps
|
||||
|
||||
- [fabric api](https://modrinth.com/mod/fabric-api/)
|
||||
|
||||
## notes
|
||||
|
||||
this mod IS BUGGY. VERY BUGGY, i know. i started this project when i was 14 and the codebase is such a mess i refuse to fix it. i might rewrite it in a future, though.
|
||||
@@ -1,23 +1,28 @@
|
||||
<p align="center">
|
||||
<a href="README.md"><img src="https://img.shields.io/badge/lang-Español-yellow.svg" alt="español"></a>
|
||||
<a href="README.en.md"><img src="https://img.shields.io/badge/lang-English-blue.svg" alt="english"></a>
|
||||
</p>
|
||||
|
||||
# jenny's mod 2 100% real
|
||||
|
||||
mod para Minecraft Fabric 26.1.2 que añade algunas cosas QOL, mayormente relacionadas a la cámara.
|
||||
> mod para Minecraft Fabric 26.2 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/sputnik/releases)
|
||||
1. ir a [lanzamientos](https://codeberg.org/retucio/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 (MC `26.1.2`; Fabric `0.19.2`)
|
||||
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `26.2`; Fabric `0.19.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 (`git clone https://github.com/retuci0/sputnik`)
|
||||
1. clona el respositorio (`git clone https://codeberg.org/retucio/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)
|
||||
3. `gradlew build` para Windows (ew) o `chmod +x gradlew` + `./gradlew build` para Unix-likes (Linux & Mac)
|
||||
4. el resultado estará en `/build/libs/sputnik-X.X.jar`
|
||||
|
||||
## uso
|
||||
|
||||
@@ -33,55 +38,42 @@ algunos módulos tienen teclas asignadas por defecto, asígnales `ESC` para desa
|
||||
|
||||
- clic izquierdo para activar / desactivar módulos
|
||||
- clic derecho para abrir sus ajustes
|
||||
- clic izquierdo + arrastrar para mover marcos
|
||||
- clic izquierdo + arrastrar para mover paneles
|
||||
- clic derecho en la cabeza del marco para expandirlo / contraerlo o para cerrarlo
|
||||
- clic izquierdo sobre ajustes para modificarlos
|
||||
- shift + clic derecho sobre ajustes para restablecerlos
|
||||
- posiciona el puntero del ratón sobre un módulo o ajuste para leer su descripción
|
||||
|
||||
### protips
|
||||
- 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/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/automine.png" alt="auto minado">
|
||||
<img src="screenshots/blockesp.png" alt="resaltado de bloques + superposición de luz">
|
||||
<img src="screenshots/camtweaks.png" alt="perspectiva plus">
|
||||
<img src="screenshots/chatplus.png" alt="chatplus + nametags + capturas">
|
||||
<img src="screenshots/clickgui.png" alt="interfaz">
|
||||
<img src="screenshots/freecam.png" alt="cámara libre + trazos">
|
||||
<img src="screenshots/hudeditor.png" alt="editor de HUD">
|
||||
<img src="screenshots/colorpicker.png" alt="selector de colores">
|
||||
<img src="screenshots/itemphysics.png" alt="físicas de items">
|
||||
<img src="screenshots/lsd.png" alt="LSD">
|
||||
<img src="screenshots/macros.png" alt="macros">
|
||||
<img src="screenshots/trajectories.png" alt="trayectorias">
|
||||
|
||||
## contibuciones
|
||||
## contribuciones
|
||||
|
||||
sí por favor
|
||||
|
||||
## licencia
|
||||
|
||||
no sé, haz lo que quieras con esto, es puta basura xd
|
||||
|
||||
aunque estaría guay que acreditases
|
||||
|
||||
pero bueno
|
||||
[licencia CC0](LICENSE)
|
||||
|
||||
## descargo de responsabilidad
|
||||
|
||||
me importa una puta mierda lo que pase al usar este mod en servers donde es baneable y así.
|
||||
|
||||
## mods recomendados
|
||||
## dependencias
|
||||
|
||||
> mods que recomiendo usar junto a este:
|
||||
- [fabric api](https://modrinth.com/mod/fabric-api/)
|
||||
|
||||
- [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
|
||||
## notas
|
||||
|
||||
este mod tiene MUCHOS bugs. empecé este proyecto cuando tenía 14 años y no sabía una mierda de programar. el código es un puto desastre y me niego a arreglarlo. puede que en un futuro reescriba el mod o algo. no sé.
|
||||
@@ -1,15 +1,20 @@
|
||||
# v5.4.1
|
||||
# v6.4
|
||||
|
||||
## novedades
|
||||
|
||||
- README en inglés
|
||||
- capturas actualizadas (las de los README)
|
||||
|
||||
### adiciones
|
||||
|
||||
#### módulos nuevos:
|
||||
|
||||
### arreglos / mejoras
|
||||
|
||||
- actualizado todos los links a GitHub para reflejar la migración a Codeberg.
|
||||
- ahora la detección de clics sobre cabezales de grupos de ajustes funciona correctamente
|
||||
|
||||
## problemas reconocidos
|
||||
|
||||
- `reponer` no funciona
|
||||
- `copiar` tras sacar una captura con `capturas` no funciona correctamente
|
||||
- lo de siempre.
|
||||
@@ -10,6 +10,8 @@ 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
|
||||
Stardust: https://github.com/0xTas/stardust/
|
||||
|
||||
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 :)
|
||||
si quieres que te acredite o quite tu código de mi mod, mándame un mensaje en discord (username: retucio) y sin problemas :)
|
||||
también es probable que haya créditos sueltos en forma de comentarios donde haya usado código ajeno
|
||||
@@ -10,6 +10,6 @@ discord_rpc_version=1.0.3
|
||||
neutrino_version=1.1.0
|
||||
jdk_version=25
|
||||
|
||||
mod_version=5.4
|
||||
mod_version=6.4
|
||||
maven_group=me.retucio
|
||||
archives_base_name=sputnik
|
||||
@@ -1,7 +1,6 @@
|
||||
#Sat Aug 29 22:10:52 CEST 2026
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
After Width: | Height: | Size: 2.2 MiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 3.4 MiB |
|
Before Width: | Height: | Size: 864 KiB After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 796 KiB |
|
Before Width: | Height: | Size: 915 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 566 KiB |
|
Before Width: | Height: | Size: 469 KiB |
|
Before Width: | Height: | Size: 243 KiB After Width: | Height: | Size: 700 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 506 KiB |
|
After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 691 KiB |
@@ -7,6 +7,8 @@ import me.retucio.sputnik.command.CommandManager;
|
||||
import me.retucio.sputnik.command.commands.BindCommand;
|
||||
|
||||
import me.retucio.sputnik.config.ConfigManager;
|
||||
import me.retucio.sputnik.config.ProfileManager;
|
||||
import me.retucio.sputnik.macro.MacroManager;
|
||||
|
||||
import me.retucio.sputnik.event.ShutdownEvent;
|
||||
import me.retucio.sputnik.event.interact.OpenScreenEvent;
|
||||
@@ -17,12 +19,14 @@ 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.HudEditor;
|
||||
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.FileButton;
|
||||
import me.retucio.sputnik.ui.widgets.buttons.settings.TextButton;
|
||||
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
||||
import me.retucio.sputnik.ui.widgets.panels.SettingsPanel;
|
||||
@@ -99,12 +103,17 @@ public class Sputnik implements ClientModInitializer {
|
||||
EVENT_BUS.subscribe(MiscUtil.class);
|
||||
EVENT_BUS.subscribe(NetworkUtil.class);
|
||||
EVENT_BUS.subscribe(RenderUtil.class);
|
||||
EVENT_BUS.subscribe(RotationUtil.class);
|
||||
|
||||
EVENT_BUS.subscribe(BlockIterator.class);
|
||||
|
||||
Lists.init();
|
||||
|
||||
HudRenderer.INSTANCE = new HudRenderer();
|
||||
HudEditor.INSTANCE = new HudEditor();
|
||||
|
||||
MacroManager.INSTANCE = new MacroManager();
|
||||
ProfileManager.INSTANCE = new ProfileManager();
|
||||
|
||||
CapeManager.INSTANCE = new CapeManager();
|
||||
EVENT_BUS.post(new LoadCapeManagerEvent());
|
||||
@@ -135,11 +144,8 @@ public class Sputnik implements ClientModInitializer {
|
||||
|
||||
// se ejecuta cada tick, es decir, 20 veces por segundo
|
||||
public void onTick() {
|
||||
if (!settingsApplied
|
||||
&& ConfigManager.INSTANCE.getConfig() != null
|
||||
&& !ConfigManager.INSTANCE.hasLoaded()) {
|
||||
ConfigManager.INSTANCE.applyConfig();
|
||||
settingsApplied = true;
|
||||
if (!settingsApplied && !ConfigManager.INSTANCE.hasLoaded()) {
|
||||
settingsApplied = ConfigManager.INSTANCE.applyConfig();
|
||||
}
|
||||
|
||||
ModuleManager.INSTANCE.getEnabledModules().forEach(Module::onTick);
|
||||
@@ -154,14 +160,15 @@ public class Sputnik implements ClientModInitializer {
|
||||
// prevenir interrumpir combos de F3
|
||||
if (key == GLFW.GLFW_KEY_F3) return;
|
||||
|
||||
boolean anyFocused = isAnySettingButtonFocused() || ClickGui.INSTANCE.getSearchBar().isFocused();
|
||||
boolean anyFocused = isAnySettingButtonFocused() || ClickGui.INSTANCE.isCapturingInput();
|
||||
ClickGui.INSTANCE.setAnyFocused(anyFocused);
|
||||
|
||||
if (action != GLFW.GLFW_RELEASE) {
|
||||
if (BindCommand.onKeyPress(key)) return;
|
||||
if (action == GLFW.GLFW_PRESS && MacroManager.INSTANCE.onKeyPress(key)) return;
|
||||
if (action == GLFW.GLFW_PRESS) {
|
||||
handleModuleToggle(key, anyFocused);
|
||||
handleClickGUIKey(key, anyFocused);
|
||||
handleClickGuiKey(key, anyFocused);
|
||||
handleHudEditorKey(key, anyFocused);
|
||||
}
|
||||
// solo reenviar teclas del teclado
|
||||
@@ -175,10 +182,15 @@ public class Sputnik implements ClientModInitializer {
|
||||
|
||||
// verifica si algún botón de ajustes está escuchando
|
||||
private boolean isAnySettingButtonFocused() {
|
||||
if (ClickGui.INSTANCE == null) return false;
|
||||
for (SettingsPanel sf : ClickGui.INSTANCE.getSettingsPanels())
|
||||
for (Button sb : sf.getButtons())
|
||||
if ((sb instanceof BindButton b && b.isFocused()) || (sb instanceof TextButton t && t.isFocused()))
|
||||
if ((sb instanceof BindButton b && b.isFocused())
|
||||
|| (sb instanceof TextButton t && t.isFocused())
|
||||
|| (sb instanceof FileButton f && f.isFocused())
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -202,13 +214,14 @@ public class Sputnik implements ClientModInitializer {
|
||||
for (SettingsPanel sf : ClickGui.INSTANCE.getSettingsPanels()) {
|
||||
for (SettingButton<?> sb : sf.getButtons()) {
|
||||
if (sb instanceof BindButton bb) bb.onKey(key, action);
|
||||
if (sb instanceof FileButton fb) fb.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) {
|
||||
private void handleClickGuiKey(int key, boolean anyFocused) {
|
||||
if (key != ClientSettingsPanel.clientSettings.getKey() || anyFocused || isOnTypingScreen())
|
||||
return;
|
||||
|
||||
@@ -221,7 +234,7 @@ public class Sputnik implements ClientModInitializer {
|
||||
}
|
||||
}
|
||||
|
||||
// manejar la lógica de apertura del editor de elementos del hud, con la misma lógica que handleClickGUIKey()
|
||||
// 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;
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,12 +21,14 @@ public abstract class Command {
|
||||
|
||||
protected static final Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
private final String name, description;
|
||||
private final String name, descriptionKey;
|
||||
private final List<String> aliases;
|
||||
|
||||
public Command(String name, String description, String... aliases) {
|
||||
// la descripción se guarda como clave de traducción, no como texto ya resuelto: los comandos
|
||||
// se construyen antes de que se cargue el idioma, así que hay que traducirla al mostrarla
|
||||
public Command(String name, String descriptionKey, String... aliases) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.descriptionKey = descriptionKey;
|
||||
this.aliases = List.of(aliases);
|
||||
}
|
||||
|
||||
@@ -56,8 +59,12 @@ public abstract class Command {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
public String getDescriptionKey() {
|
||||
return descriptionKey;
|
||||
}
|
||||
|
||||
public Component getDescription() {
|
||||
return Component.translatable(descriptionKey);
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
|
||||
@@ -38,9 +38,13 @@ public class CommandManager {
|
||||
addCommand(new EnderChestCommand());
|
||||
addCommand(new FriendCommand());
|
||||
addCommand(new GarbageCleanerCommand());
|
||||
addCommand(new HelpCommand());
|
||||
addCommand(new MacroCommand());
|
||||
addCommand(new PanoramaCommand());
|
||||
addCommand(new PeekCommand());
|
||||
addCommand(new PluginsCommand());
|
||||
addCommand(new PrefixCommand());
|
||||
addCommand(new ProfileCommand());
|
||||
addCommand(new PurgeCommand());
|
||||
addCommand(new RepeatCommand());
|
||||
addCommand(new RepeatWaitCommand());
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BindCommand extends Command {
|
||||
private static Module listeningModule = null;
|
||||
|
||||
public BindCommand() {
|
||||
super("bind", Component.translatable("sputnik.commands.bind.desc").getString(), "keybind", "kb", "tecla");
|
||||
super("bind", "sputnik.commands.bind.desc", "keybind", "kb", "tecla");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,14 +7,13 @@ import me.retucio.sputnik.command.args.EnumArgumentType;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.ContainerScreen;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.inventory.ContainerInput;
|
||||
|
||||
// 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", Component.translatable("sputnik.commands.clickslot.desc").getString(), "cs");
|
||||
super("clickslot", "sputnik.commands.clickslot.desc", "cs");
|
||||
}
|
||||
|
||||
public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
|
||||
|
||||
@@ -9,12 +9,11 @@ import me.retucio.sputnik.ui.screen.ClickGui;
|
||||
import me.retucio.sputnik.ui.widgets.panels.SettingsPanel;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class ConfigCommand extends Command {
|
||||
|
||||
public ConfigCommand() {
|
||||
super("config", Component.translatable("sputnik.commands.config.desc").getString(), "ajustes", "settings");
|
||||
super("config", "sputnik.commands.config.desc", "ajustes", "settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,13 +5,12 @@ import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
// 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", Component.translatable("sputnik.commands.copyscreenshot.desc").getString(), "copyscreenshot");
|
||||
super("copiarcaptura", "sputnik.commands.copyscreenshot.desc", "copyscreenshot");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ public class EnderChestCommand extends Command {
|
||||
private boolean shouldOpenEchest = false;
|
||||
|
||||
public EnderChestCommand() {
|
||||
super("echest", Component.translatable("sputnik.commands.echest.desc").getString(), "ec", "enderchest");
|
||||
super("echest", "sputnik.commands.echest.desc", "ec", "enderchest");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.minecraft.world.entity.player.Player;
|
||||
public class FriendCommand extends Command {
|
||||
|
||||
public FriendCommand() {
|
||||
super("friend", Component.translatable("sputnik.commands.friend.desc").getString(), "amigo", "f");
|
||||
super("friend", "sputnik.commands.friend.desc", "amigo", "f");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,12 +9,12 @@ import net.minecraft.network.chat.Component;
|
||||
public class GarbageCleanerCommand extends Command {
|
||||
|
||||
public GarbageCleanerCommand() {
|
||||
super("gc", Component.translatable("sputnik.commands.gc.desc").getString(), "garbagecollect");
|
||||
super("gc", "sputnik.commands.gc.desc", "garbagecollect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
|
||||
builder.executes(context -> {
|
||||
builder.executes(ctx -> {
|
||||
System.gc();
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.gc.collected"));
|
||||
return SUCCESS;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.command.CommandManager;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class HelpCommand extends Command {
|
||||
|
||||
public HelpCommand() {
|
||||
super("help", Component.translatable("sputnik.commands.help.desc").getString(), "?", "ayuda", "h");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
|
||||
builder.executes(ctx -> {
|
||||
for (Command command : CommandManager.commands) {
|
||||
ChatUtil.info(CommandManager.INSTANCE.getPrefix()
|
||||
+ ChatFormatting.BOLD + command.getName() + ": "
|
||||
+ ChatFormatting.RESET + ChatFormatting.GRAY + command.getDescription().getString());
|
||||
}
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.macro.Macro;
|
||||
import me.retucio.sputnik.macro.MacroManager;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import me.retucio.sputnik.util.KeyUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MacroCommand extends Command {
|
||||
|
||||
private static final SuggestionProvider<SharedSuggestionProvider> MACROS = (ctx, builder) ->
|
||||
SharedSuggestionProvider.suggest(
|
||||
MacroManager.INSTANCE.getMacros().stream().map(Macro::getName), builder);
|
||||
|
||||
public MacroCommand() {
|
||||
super("macro", "sputnik.commands.macro.desc", "macros");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
|
||||
builder
|
||||
.executes(ctx -> {
|
||||
list();
|
||||
return SUCCESS;
|
||||
})
|
||||
.then(literal("list").executes(ctx -> {
|
||||
list();
|
||||
return SUCCESS;
|
||||
}))
|
||||
.then(literal("add")
|
||||
.then(argument("nombre", StringArgumentType.word()).executes(ctx -> {
|
||||
String name = ctx.getArgument("nombre", String.class);
|
||||
|
||||
if (MacroManager.INSTANCE.add(new Macro(name)))
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.macro.added",
|
||||
ChatFormatting.AQUA + name));
|
||||
else
|
||||
ChatUtil.error(Component.translatable("sputnik.commands.macro.exists", name));
|
||||
return SUCCESS;
|
||||
})))
|
||||
.then(literal("remove")
|
||||
.then(argument("nombre", StringArgumentType.word()).suggests(MACROS).executes(ctx -> {
|
||||
Macro macro = get(ctx.getArgument("nombre", String.class));
|
||||
if (macro == null) return SUCCESS;
|
||||
|
||||
MacroManager.INSTANCE.remove(macro);
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.macro.removed",
|
||||
ChatFormatting.AQUA + macro.getName()));
|
||||
return SUCCESS;
|
||||
})))
|
||||
.then(literal("line")
|
||||
.then(argument("nombre", StringArgumentType.word()).suggests(MACROS)
|
||||
.then(argument("línea", StringArgumentType.greedyString()).executes(ctx -> {
|
||||
Macro macro = get(ctx.getArgument("nombre", String.class));
|
||||
if (macro == null) return SUCCESS;
|
||||
|
||||
String line = ctx.getArgument("línea", String.class);
|
||||
macro.getLines().add(line);
|
||||
MacroManager.INSTANCE.save();
|
||||
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.macro.lineadded",
|
||||
ChatFormatting.AQUA + macro.getName()));
|
||||
return SUCCESS;
|
||||
}))))
|
||||
.then(literal("clear")
|
||||
.then(argument("nombre", StringArgumentType.word()).suggests(MACROS).executes(ctx -> {
|
||||
Macro macro = get(ctx.getArgument("nombre", String.class));
|
||||
if (macro == null) return SUCCESS;
|
||||
|
||||
macro.getLines().clear();
|
||||
MacroManager.INSTANCE.save();
|
||||
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.macro.cleared",
|
||||
ChatFormatting.AQUA + macro.getName()));
|
||||
return SUCCESS;
|
||||
})))
|
||||
.then(literal("run")
|
||||
.then(argument("nombre", StringArgumentType.word()).suggests(MACROS).executes(ctx -> {
|
||||
Macro macro = get(ctx.getArgument("nombre", String.class));
|
||||
if (macro != null) macro.run();
|
||||
return SUCCESS;
|
||||
})));
|
||||
}
|
||||
|
||||
private static Macro get(String name) {
|
||||
Macro macro = MacroManager.INSTANCE.getByName(name);
|
||||
if (macro == null) ChatUtil.error(Component.translatable("sputnik.commands.macro.notfound", name));
|
||||
return macro;
|
||||
}
|
||||
|
||||
private static void list() {
|
||||
List<Macro> macros = MacroManager.INSTANCE.getMacros();
|
||||
|
||||
if (macros.isEmpty()) {
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.macro.none"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.macro.list", macros.size()));
|
||||
for (Macro macro : macros)
|
||||
ChatUtil.addMessage(ChatFormatting.GRAY + " - " + macro.getName()
|
||||
+ ChatFormatting.DARK_GRAY + " [" + KeyUtil.getKeyName(macro.getKey()) + "] "
|
||||
+ macro.getLines().size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
|
||||
import com.github.retucio.neutrino.EventListener;
|
||||
import me.retucio.sputnik.Sputnik;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.event.TickEvent;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import me.retucio.sputnik.util.MiscUtil;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.WorldVersion;
|
||||
import net.minecraft.client.Screenshot;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.metadata.pack.PackFormat;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
|
||||
/**
|
||||
* literalmente robado de <a href="https://github.com/0xTas/stardust/blob/main/src/main/java/dev/stardust/commands/Panorama.java">aquí</a>
|
||||
*/
|
||||
|
||||
public class PanoramaCommand extends Command {
|
||||
|
||||
private int i = -1;
|
||||
int timer = 10;
|
||||
|
||||
boolean ready = false;
|
||||
boolean warming = false;
|
||||
|
||||
private float prevYaw;
|
||||
private float prevPitch;
|
||||
|
||||
private int prevWidth;
|
||||
private int prevHeight;
|
||||
|
||||
private boolean prevHudHidden;
|
||||
|
||||
@Nullable Path dir = null;
|
||||
|
||||
public PanoramaCommand() {
|
||||
super("panorama", "sputnik.commands.panorama.desc");
|
||||
}
|
||||
|
||||
private void takeScreenshot() {
|
||||
if (dir == null) return;
|
||||
|
||||
Screenshot.grab(
|
||||
dir.toFile(),
|
||||
"panorama_" + i + ".png",
|
||||
mc.gameRenderer.mainRenderTarget(),
|
||||
1, msg -> Sputnik.LOGGER.info(msg.getString())
|
||||
);
|
||||
|
||||
i++;
|
||||
warming = false;
|
||||
}
|
||||
|
||||
private void begin(String name) {
|
||||
if (mc.player == null) return;
|
||||
|
||||
dir = FabricLoader.getInstance().getGameDir().resolve(Sputnik.MOD_ID + "/panoramas/" + name);
|
||||
dir.toFile().mkdirs();
|
||||
|
||||
i = 0;
|
||||
warming = false;
|
||||
|
||||
prevYaw = mc.player.getYRot();
|
||||
prevPitch = mc.player.getXRot();
|
||||
prevWidth = mc.getWindow().getWidth();
|
||||
prevHeight = mc.getWindow().getHeight();
|
||||
prevHudHidden = mc.gui.hud.isHidden();
|
||||
|
||||
mc.getWindow().setWidth(4096);
|
||||
mc.getWindow().setHeight(4096);
|
||||
mc.gameRenderer.mainRenderTarget().resize(4096, 4096);
|
||||
}
|
||||
|
||||
private void assembleResourcePack() {
|
||||
if (dir == null) return;
|
||||
|
||||
Path resourcePacks = FabricLoader.getInstance().getGameDir().resolve("resourcepacks");
|
||||
Path screenshotsFolder = FabricLoader.getInstance().getGameDir().resolve(Sputnik.MOD_ID + "/panoramas/" + dir.getFileName() + "/screenshots");
|
||||
Path customBaseFolder = resourcePacks.resolve(dir.getFileName());
|
||||
Path customPackFolder = customBaseFolder.resolve("assets/minecraft/textures/gui/title/background/");
|
||||
customPackFolder.toFile().mkdirs();
|
||||
|
||||
String mcMeta =
|
||||
"""
|
||||
{
|
||||
"pack":
|
||||
{
|
||||
"min_format": [65, 0],
|
||||
"max_format": [%d, 0],
|
||||
"description": "%s"
|
||||
}
|
||||
}
|
||||
""".formatted(
|
||||
getPackVersion(),
|
||||
Component.translatable("sputnik.commands.panorama.packdesc").getString()
|
||||
);
|
||||
|
||||
try {
|
||||
int luckyNumber = ThreadLocalRandom.current().nextInt(6);
|
||||
Files.walkFileTree(screenshotsFolder, new SimpleFileVisitor<>() {
|
||||
public @NonNull FileVisitResult visitFile(@NonNull Path file, @NonNull BasicFileAttributes attrs) {
|
||||
MiscUtil.copy(file.toFile(), customPackFolder.resolve(file.getFileName()).toFile());
|
||||
|
||||
// pack.png random de alguna de los screenshots
|
||||
if (file.getFileName().toString().contains(String.valueOf(luckyNumber))) {
|
||||
MiscUtil.copy(file.toFile(), customBaseFolder.resolve("pack.png").toFile());
|
||||
}
|
||||
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
|
||||
File packMeta = customBaseFolder.resolve("pack.mcmeta").toFile();
|
||||
if (!packMeta.createNewFile()) {
|
||||
ChatUtil.error(Component.translatable("sputnik.commands.panorama.errorassemble").getString());
|
||||
return;
|
||||
}
|
||||
Files.write(packMeta.toPath(), mcMeta.getBytes());
|
||||
|
||||
// eliminar el efecto vignette feo de cojones que usa Minecraft por defecto
|
||||
BufferedImage transparentOverlay = new BufferedImage(16, 128, BufferedImage.TYPE_INT_ARGB);
|
||||
File overlayImage = customPackFolder.resolve("panorama_overlay.png").toFile();
|
||||
ImageIO.write(transparentOverlay, "PNG", overlayImage);
|
||||
} catch (Exception e) {
|
||||
ChatUtil.error("error de i/o");
|
||||
Sputnik.LOGGER.error(e);
|
||||
}
|
||||
|
||||
ready = false;
|
||||
if (mc.player != null) {
|
||||
mc.player.playSound(SoundEvents.AMETHYST_BLOCK_CHIME, 1f, 1f);
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.panorama.ready").getString());
|
||||
}
|
||||
}
|
||||
|
||||
@EventListener
|
||||
private void onTick(TickEvent.Post event) {
|
||||
if (mc.player == null || dir == null) return;
|
||||
|
||||
if (timer > 0) {
|
||||
--timer;
|
||||
return;
|
||||
} else {
|
||||
timer = 10;
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
assembleResourcePack();
|
||||
}
|
||||
if (i < 0) return;
|
||||
|
||||
switch (i) {
|
||||
case 0 -> {
|
||||
if (!warming) {
|
||||
mc.gameRenderer.mainCamera().enablePanoramicMode();
|
||||
mc.gameRenderer.setRenderBlockOutline(false);
|
||||
mc.execute(() -> {
|
||||
synchronized (mc.levelRenderer) {
|
||||
mc.levelRenderer.notifyAll();
|
||||
}
|
||||
});
|
||||
if (!mc.gui.hud.isHidden()) mc.gui.hud.toggle();
|
||||
mc.player.setYRot(prevYaw);
|
||||
mc.player.setXRot(0f);
|
||||
warming = true;
|
||||
} else takeScreenshot();
|
||||
}
|
||||
case 1 -> {
|
||||
if (!warming) {
|
||||
mc.player.setYRot((prevYaw + 90f) % 360f);
|
||||
mc.player.setXRot(0f);
|
||||
warming = true;
|
||||
} else takeScreenshot();
|
||||
}
|
||||
case 2 -> {
|
||||
if (!warming) {
|
||||
mc.player.setYRot((prevYaw + 180f) % 360f);
|
||||
mc.player.setXRot(0f);
|
||||
warming = true;
|
||||
} else takeScreenshot();
|
||||
}
|
||||
case 3 -> {
|
||||
if (!warming) {
|
||||
mc.player.setYRot((prevYaw - 90f) % 360f);
|
||||
mc.player.setXRot(0f);
|
||||
warming = true;
|
||||
} else takeScreenshot();
|
||||
}
|
||||
case 4 -> {
|
||||
if (!warming) {
|
||||
mc.player.setYRot(prevYaw);
|
||||
mc.player.setXRot(-90f);
|
||||
warming = true;
|
||||
} else takeScreenshot();
|
||||
}
|
||||
default -> {
|
||||
if (!warming) {
|
||||
mc.player.setYRot(prevYaw);
|
||||
mc.player.setXRot(90f);
|
||||
warming = true;
|
||||
} else {
|
||||
takeScreenshot();
|
||||
i = -1;
|
||||
mc.player.setYRot(prevYaw);
|
||||
mc.player.setXRot(prevPitch);
|
||||
mc.gameRenderer.mainCamera().disablePanoramicMode();
|
||||
mc.gameRenderer.setRenderBlockOutline(true);
|
||||
mc.getWindow().setWidth(prevWidth);
|
||||
mc.getWindow().setHeight(prevHeight);
|
||||
if (mc.gui.hud.isHidden() != prevHudHidden) mc.gui.hud.toggle();
|
||||
mc.gameRenderer.mainRenderTarget().resize(prevWidth, prevHeight);
|
||||
mc.execute(() -> {
|
||||
synchronized (mc.levelRenderer) {
|
||||
mc.levelRenderer.notifyAll();
|
||||
}
|
||||
});
|
||||
|
||||
timer = 100; // esperar a que las capturas se escriban
|
||||
ready = true;
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.panorama.finalizing").getString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
|
||||
builder.then(
|
||||
argument("name", StringArgumentType.word()).executes(ctx -> {
|
||||
String name = ctx.getArgument("name", String.class);
|
||||
begin(name);
|
||||
return SUCCESS;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public static int getPackVersion() {
|
||||
WorldVersion version = SharedConstants.getCurrentVersion();
|
||||
PackFormat format = version.packVersion(PackType.CLIENT_RESOURCES);
|
||||
return format.major();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import me.retucio.sputnik.command.args.PlayerArgumentType;
|
||||
import me.retucio.sputnik.util.MiscUtil;
|
||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -14,7 +13,7 @@ import java.awt.*;
|
||||
public class PeekCommand extends Command {
|
||||
|
||||
public PeekCommand() {
|
||||
super("inventario", Component.translatable("sputnik.commands.peek.desc").getString(), "invsee", "peek", "inv");
|
||||
super("inventario", "sputnik.commands.peek.desc", "invsee", "peek", "inv");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,7 @@ public class PluginsCommand extends Command {
|
||||
private boolean scanning = false;
|
||||
|
||||
public PluginsCommand() {
|
||||
super("plugins", Component.translatable("sputnik.commands.plugins.desc").getString(), "pl", "serverplugins");
|
||||
super("plugins", "sputnik.commands.plugins.desc", "pl", "serverplugins");
|
||||
Sputnik.EVENT_BUS.subscribe(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.network.chat.Component;
|
||||
public class PrefixCommand extends Command {
|
||||
|
||||
public PrefixCommand() {
|
||||
super("prefijo", Component.translatable("sputnik.commands.prefix.desc").getString(), "prefix");
|
||||
super("prefijo", "sputnik.commands.prefix.desc", "prefix");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package me.retucio.sputnik.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.config.ConfigManager;
|
||||
import me.retucio.sputnik.config.ProfileManager;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ProfileCommand extends Command {
|
||||
|
||||
private static final SuggestionProvider<SharedSuggestionProvider> PROFILES = (ctx, builder) ->
|
||||
SharedSuggestionProvider.suggest(ProfileManager.INSTANCE.getProfileNames(), builder);
|
||||
|
||||
public ProfileCommand() {
|
||||
super("perfil", "sputnik.commands.profile.desc", "profile", "perfiles", "profiles");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
|
||||
builder
|
||||
.executes(ctx -> {
|
||||
list();
|
||||
return SUCCESS;
|
||||
})
|
||||
.then(literal("list").executes(ctx -> {
|
||||
list();
|
||||
return SUCCESS;
|
||||
}))
|
||||
.then(literal("save")
|
||||
.then(argument("nombre", StringArgumentType.word()).executes(ctx -> {
|
||||
String name = ctx.getArgument("nombre", String.class);
|
||||
|
||||
if (!ProfileManager.isValidName(name)) {
|
||||
ChatUtil.error(Component.translatable("sputnik.commands.profile.invalidname", name));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
if (ProfileManager.INSTANCE.save(name)) {
|
||||
ConfigManager.INSTANCE.save();
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.profile.saved",
|
||||
ChatFormatting.AQUA + name));
|
||||
} else {
|
||||
ChatUtil.error(Component.translatable("sputnik.commands.profile.savefailed", name));
|
||||
}
|
||||
return SUCCESS;
|
||||
})))
|
||||
.then(literal("load")
|
||||
.then(argument("nombre", StringArgumentType.word()).suggests(PROFILES).executes(ctx -> {
|
||||
String name = ctx.getArgument("nombre", String.class);
|
||||
|
||||
if (ProfileManager.INSTANCE.load(name))
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.profile.loaded",
|
||||
ChatFormatting.AQUA + name));
|
||||
else
|
||||
ChatUtil.error(Component.translatable("sputnik.commands.profile.notfound", name));
|
||||
return SUCCESS;
|
||||
})))
|
||||
.then(literal("delete")
|
||||
.then(argument("nombre", StringArgumentType.word()).suggests(PROFILES).executes(ctx -> {
|
||||
String name = ctx.getArgument("nombre", String.class);
|
||||
|
||||
if (ProfileManager.INSTANCE.delete(name))
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.profile.deleted",
|
||||
ChatFormatting.AQUA + name));
|
||||
else
|
||||
ChatUtil.error(Component.translatable("sputnik.commands.profile.notfound", name));
|
||||
return SUCCESS;
|
||||
})));
|
||||
}
|
||||
|
||||
private static void list() {
|
||||
List<String> profiles = ProfileManager.INSTANCE.getProfileNames();
|
||||
|
||||
if (profiles.isEmpty()) {
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.profile.none"));
|
||||
return;
|
||||
}
|
||||
|
||||
String current = ProfileManager.INSTANCE.getCurrent();
|
||||
ChatUtil.info(Component.translatable("sputnik.commands.profile.list", profiles.size()));
|
||||
for (String profile : profiles)
|
||||
ChatUtil.addMessage((profile.equals(current) ? ChatFormatting.GREEN : ChatFormatting.GRAY) + " - " + profile);
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,17 @@ 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.IChatComponent;
|
||||
import me.retucio.sputnik.mixinterfaces.IChatComponent;
|
||||
import net.minecraft.client.gui.components.ChatComponent;
|
||||
import net.minecraft.client.multiplayer.chat.GuiMessage;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeCommand extends Command {
|
||||
|
||||
public PurgeCommand() {
|
||||
super("purgar", Component.translatable("sputnik.commands.purge.desc").getString(), "purge");
|
||||
super("purgar", "sputnik.commands.purge.desc", "purge");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,12 +6,11 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class RepeatCommand extends Command {
|
||||
|
||||
public RepeatCommand() {
|
||||
super("repetir", Component.translatable("sputnik.commands.repeat.desc").getString(), "repeat");
|
||||
super("repetir", "sputnik.commands.repeat.desc", "repeat");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -14,7 +13,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class RepeatWaitCommand extends Command {
|
||||
|
||||
public RepeatWaitCommand() {
|
||||
super("repesperar", Component.translatable("sputnik.commands.repeatwait.desc").getString(), "repeatwait");
|
||||
super("repesperar", "sputnik.commands.repeatwait.desc", "repeatwait");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.io.IOException;
|
||||
public class SaveScreenshotCommand extends Command {
|
||||
|
||||
public SaveScreenshotCommand() {
|
||||
super("guardarcaptura", Component.translatable("sputnik.commands.savescreenshot.desc").getString(), "savescreenshot");
|
||||
super("guardarcaptura", "sputnik.commands.savescreenshot.desc", "savescreenshot");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,6 @@ import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.mixin.accessors.ClientPacketListenerAccessor;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.LastSeenMessagesTracker;
|
||||
import net.minecraft.network.chat.MessageSignature;
|
||||
import net.minecraft.network.chat.SignedMessageBody;
|
||||
@@ -19,7 +18,7 @@ import java.time.Instant;
|
||||
public class SendCommand extends Command {
|
||||
|
||||
public SendCommand() {
|
||||
super("enviar", Component.translatable("sputnik.commands.send.desc").getString(), "send");
|
||||
super("enviar", "sputnik.commands.send.desc", "send");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,6 @@ import me.retucio.sputnik.command.args.EntityArgumentType;
|
||||
import me.retucio.sputnik.event.input.KeyEvent;
|
||||
import me.retucio.sputnik.util.EntityUtil;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@@ -16,7 +15,7 @@ import java.awt.*;
|
||||
public class SpectateCommand extends Command {
|
||||
|
||||
public SpectateCommand() {
|
||||
super("espectar", Component.translatable("sputnik.commands.spectate.desc").getString(), "spectate", "spec");
|
||||
super("espectar", "sputnik.commands.spectate.desc", "spectate", "spec");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,6 @@ import me.retucio.sputnik.command.args.ModuleArgumentType;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -14,7 +13,7 @@ import java.awt.*;
|
||||
public class ToggleCommand extends Command {
|
||||
|
||||
public ToggleCommand() {
|
||||
super("alternar", Component.translatable("sputnik.commands.toggle.desc").getString(), "toggle");
|
||||
super("alternar", "sputnik.commands.toggle.desc", "toggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.sputnik.command.Command;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
@@ -17,7 +16,7 @@ public class WaitCommand extends Command {
|
||||
private static final ScheduledExecutorService DELAYED_EXECUTOR = new ScheduledThreadPoolExecutor(2);
|
||||
|
||||
public WaitCommand() {
|
||||
super("wait", Component.translatable("sputnik.commands.wait.desc").getString(), "esperar", "sleep", "delay");
|
||||
super("wait", "sputnik.commands.wait.desc", "esperar", "sleep", "delay");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.retucio.sputnik.config;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import me.retucio.sputnik.util.I18nUtil;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -14,7 +14,8 @@ import java.util.Map;
|
||||
public class BinarySerializer {
|
||||
|
||||
private static final int MAGIC_NUMBER = 0x53505554; // "SPUT"
|
||||
private static final int VERSION = 2;
|
||||
private static final int VERSION = 3;
|
||||
private static final int MIN_VERSION = 2;
|
||||
|
||||
private static final byte TYPE_NULL = 0;
|
||||
private static final byte TYPE_BOOLEAN = 1;
|
||||
@@ -72,6 +73,8 @@ public class BinarySerializer {
|
||||
writeStringBooleanMap(out, config.hudVisibilities);
|
||||
writeStringStringMap(out, config.hudImagePaths);
|
||||
writeStringStringMap(out, config.friends);
|
||||
writeMacros(out, config.macros);
|
||||
writeString(out, config.currentProfile);
|
||||
|
||||
if (config.searchBarPosition != null) {
|
||||
out.writeBoolean(true);
|
||||
@@ -85,44 +88,63 @@ public class BinarySerializer {
|
||||
public static ClientConfig readConfig(File file)
|
||||
throws IOException {
|
||||
if (!file.exists() || file.length() == 0) {
|
||||
throw new IOException(Component.translatable("sputnik.config.error.empty").getString());
|
||||
throw new IOException(I18nUtil.fmt("sputnik.config.error.empty",
|
||||
"archivo de config. vacío o inexistente"));
|
||||
}
|
||||
|
||||
try (DataInputStream in = new DataInputStream(
|
||||
new BufferedInputStream(new FileInputStream(file)))) {
|
||||
|
||||
if (file.length() < 8) {
|
||||
throw new IOException(Component.translatable("sputnik.config.error.toosmall").getString());
|
||||
throw new IOException(I18nUtil.fmt("sputnik.config.error.toosmall",
|
||||
"archivo demasiado pequeño para ser válido"));
|
||||
}
|
||||
|
||||
// verificar cabezal
|
||||
int magic = in.readInt();
|
||||
if (magic != MAGIC_NUMBER) {
|
||||
throw new IOException(Component.translatable("sputnik.config.error.invalidformat", magic).getString());
|
||||
throw new IOException(I18nUtil.fmt("sputnik.config.error.invalidformat",
|
||||
"formato de archivo inválido: %s", magic));
|
||||
}
|
||||
|
||||
// todo: sustituir por lógica de migración en vez de simplemente no aceptarlo
|
||||
int version = in.readInt();
|
||||
if (version != VERSION) {
|
||||
throw new IOException(Component.translatable("sputnik.config.error.invalidversion", version).getString());
|
||||
if (version < MIN_VERSION || version > VERSION) {
|
||||
throw new IOException(I18nUtil.fmt("sputnik.config.error.invalidversion",
|
||||
"versión inválida: %s", version));
|
||||
}
|
||||
|
||||
ClientConfig config = new ClientConfig();
|
||||
// leer mapas. se leen a locales y la ClientConfig se construye al final: su
|
||||
// constructor la suscribe al bus de eventos, así que crearla antes de terminar
|
||||
// de leer dejaba una config. huérfana escuchando si el archivo estaba corrupto
|
||||
Map<String, Boolean> moduleStates = readStringBooleanMap(in);
|
||||
Map<String, Object> settings = readSettingsMap(in);
|
||||
Map<String, int[]> settingsPanels = readStringIntArrayMap(in);
|
||||
Map<String, ClientConfig.PanelData> extendablePanels = readExtendablePanels(in);
|
||||
Map<String, int[]> hudPositions = readStringIntArrayMap(in);
|
||||
Map<String, Boolean> hudVisibilities = readStringBooleanMap(in);
|
||||
Map<String, String> hudImagePaths = readStringStringMap(in);
|
||||
Map<String, String> friends = readStringStringMap(in);
|
||||
|
||||
// leer mapas
|
||||
config.moduleStates = readStringBooleanMap(in);
|
||||
config.settings = readSettingsMap(in);
|
||||
config.settingsPanels = readStringIntArrayMap(in);
|
||||
config.extendablePanels = readExtendablePanels(in);
|
||||
config.hudPositions = readStringIntArrayMap(in);
|
||||
config.hudVisibilities = readStringBooleanMap(in);
|
||||
config.hudImagePaths = readStringStringMap(in);
|
||||
config.friends = readStringStringMap(in);
|
||||
List<ClientConfig.MacroData> macros = version >= 3 ? readMacros(in) : new ArrayList<>();
|
||||
String currentProfile = version >= 3 ? readString(in) : "";
|
||||
|
||||
// leer pos. de la barra de búsqueda
|
||||
if (in.readBoolean()) {
|
||||
config.searchBarPosition = new int[]{in.readInt(), in.readInt()};
|
||||
}
|
||||
int[] searchBarPosition = in.readBoolean()
|
||||
? new int[]{in.readInt(), in.readInt()}
|
||||
: null;
|
||||
|
||||
ClientConfig config = new ClientConfig();
|
||||
config.moduleStates = moduleStates;
|
||||
config.settings = settings;
|
||||
config.settingsPanels = settingsPanels;
|
||||
config.extendablePanels = extendablePanels;
|
||||
config.hudPositions = hudPositions;
|
||||
config.hudVisibilities = hudVisibilities;
|
||||
config.hudImagePaths = hudImagePaths;
|
||||
config.friends = friends;
|
||||
config.macros = macros;
|
||||
config.currentProfile = currentProfile == null ? "" : currentProfile;
|
||||
if (searchBarPosition != null) config.searchBarPosition = searchBarPosition;
|
||||
|
||||
return config;
|
||||
}
|
||||
@@ -371,6 +393,35 @@ public class BinarySerializer {
|
||||
return map;
|
||||
}
|
||||
|
||||
private static void writeMacros(DataOutputStream out, List<ClientConfig.MacroData> macros)
|
||||
throws IOException {
|
||||
if (macros == null) {
|
||||
out.writeInt(0);
|
||||
return;
|
||||
}
|
||||
out.writeInt(macros.size());
|
||||
for (ClientConfig.MacroData macro : macros) {
|
||||
writeString(out, macro.name());
|
||||
out.writeInt(macro.key());
|
||||
out.writeInt(macro.lines().size());
|
||||
for (String line : macro.lines()) writeString(out, line);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ClientConfig.MacroData> readMacros(DataInputStream in) throws IOException {
|
||||
int size = in.readInt();
|
||||
List<ClientConfig.MacroData> macros = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String name = readString(in);
|
||||
int key = in.readInt();
|
||||
int lineCount = in.readInt();
|
||||
List<String> lines = new ArrayList<>(lineCount);
|
||||
for (int j = 0; j < lineCount; j++) lines.add(readString(in));
|
||||
macros.add(new ClientConfig.MacroData(name, key, lines));
|
||||
}
|
||||
return macros;
|
||||
}
|
||||
|
||||
private static void writeString(DataOutputStream out, String str) throws IOException {
|
||||
if (str == null) {
|
||||
out.writeInt(-1);
|
||||
|
||||
@@ -47,19 +47,31 @@ public class ClientConfig {
|
||||
// amigos: uuid -> nombre
|
||||
public Map<String, String> friends = new HashMap<>();
|
||||
|
||||
public List<MacroData> macros = new ArrayList<>();
|
||||
|
||||
// perfil cargado actualmente, vacío si es la config. suelta
|
||||
public String currentProfile = "";
|
||||
|
||||
public ClientConfig() {
|
||||
EVENT_BUS.subscribe(this);
|
||||
}
|
||||
|
||||
// mientras se aplica una config. los cambios vienen de ella, así que reescribirla es
|
||||
// como poco redundante, y al cambiar de perfil pisaba lo que aún no se había aplicado
|
||||
private static boolean isApplying() {
|
||||
return ConfigManager.INSTANCE != null && ConfigManager.INSTANCE.isApplying();
|
||||
}
|
||||
|
||||
@EventListener
|
||||
public void onToggleModule(ToggleModuleEvent event) {
|
||||
if (isApplying()) return;
|
||||
ConfigManager.INSTANCE.setModuleState(event.getModule());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@EventListener
|
||||
public void onUpdateSetting(UpdateSettingEvent event) {
|
||||
if (mc == null || !event.shouldSave()) return;
|
||||
if (mc == null || !event.shouldSave() || isApplying()) return;
|
||||
|
||||
// guardar ajustes con su respectivo tipo de valor, en formato "nombreMódulo:nombreAjuste"
|
||||
Object value = null;
|
||||
@@ -71,7 +83,8 @@ public class ClientConfig {
|
||||
case StringSetting s: value = s.getValue(); break;
|
||||
case ListSetting l: value = l.getConfigValues(); break;
|
||||
case ColorSetting c: value = c.getConfigValue(); break;
|
||||
case OptionSetting o: value = o.getDisplayName(); break;
|
||||
case OptionSetting o: value = o.getConfigName(); break;
|
||||
case FileSetting f: value = f.getValue(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -153,6 +166,7 @@ public class ClientConfig {
|
||||
|
||||
@EventListener
|
||||
public void onAddFriend(FriendEvent.Add event) {
|
||||
if (isApplying()) return;
|
||||
String uuid = event.getFriend().getUuid().toString();
|
||||
String name = event.getFriend().getName();
|
||||
if (!friends.containsKey(uuid)) {
|
||||
@@ -163,6 +177,7 @@ public class ClientConfig {
|
||||
|
||||
@EventListener
|
||||
public void onRemoveFriend(FriendEvent.Remove event) {
|
||||
if (isApplying()) return;
|
||||
friends.remove(event.getFriend().getUuid().toString());
|
||||
ConfigManager.INSTANCE.markDirty();
|
||||
}
|
||||
@@ -170,4 +185,8 @@ public class ClientConfig {
|
||||
public record PanelData(int x, int y, boolean extended) implements Serializable {
|
||||
@Serial private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
public record MacroData(String name, int key, List<String> lines) implements Serializable {
|
||||
@Serial private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,11 @@ import me.retucio.sputnik.friend.FriendManager;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.client.ClientSettingsModule;
|
||||
import me.retucio.sputnik.macro.Macro;
|
||||
import me.retucio.sputnik.macro.MacroManager;
|
||||
import me.retucio.sputnik.module.setting.*;
|
||||
import me.retucio.sputnik.module.setting.settings.*;
|
||||
import me.retucio.sputnik.ui.hud.HudElement;
|
||||
import me.retucio.sputnik.ui.hud.HudRenderer;
|
||||
import me.retucio.sputnik.ui.widgets.Panel;
|
||||
import me.retucio.sputnik.ui.widgets.panels.ExtendablePanel;
|
||||
@@ -19,18 +22,21 @@ import me.retucio.sputnik.ui.screen.ClickGui;
|
||||
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
||||
import me.retucio.sputnik.ui.widgets.panels.SettingsPanel;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import me.retucio.sputnik.util.I18nUtil;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
// se ocupa de guardar, cargar y aplicar ajustes
|
||||
@@ -42,8 +48,9 @@ public class ConfigManager {
|
||||
public static ConfigManager INSTANCE;
|
||||
|
||||
private boolean loaded = false;
|
||||
private boolean applying = false;
|
||||
private boolean dirty = false;
|
||||
private long lastDirtyTime = 0L;
|
||||
private long lastSaveTime = System.currentTimeMillis();
|
||||
private ClientConfig config = null;
|
||||
|
||||
private final ExecutorService saveExecutor = Executors.newSingleThreadExecutor(r -> {
|
||||
@@ -52,7 +59,10 @@ public class ConfigManager {
|
||||
return t;
|
||||
});
|
||||
|
||||
private final AtomicBoolean saveQueued = new AtomicBoolean(false);
|
||||
// instantánea pendiente de escribir. si llega otra antes de que el hilo de fondo escriba,
|
||||
// sustituye a la anterior en vez de descartarse (que era lo que pasaba con un simple
|
||||
// "ya hay uno en cola": se tiraba justo la más reciente y se perdían esos cambios)
|
||||
private final AtomicReference<byte[]> pending = new AtomicReference<>();
|
||||
|
||||
|
||||
// ------------------ MÉTODOS PRINCIPALES ------------------
|
||||
@@ -60,58 +70,81 @@ public class ConfigManager {
|
||||
// guardar configuraciones
|
||||
public void save() {
|
||||
if (!loaded) return;
|
||||
ensureConfig();
|
||||
|
||||
// serializar a bytes en el hilo principal (snapshot inmediato, evita race conditions)
|
||||
final byte[] snapshot;
|
||||
try {
|
||||
snapshot = BinarySerializer.toBytes(config);
|
||||
} catch (IOException e) {
|
||||
Sputnik.LOGGER.error(Component.translatable("sputnik.config.error.serialization").getString(), e);
|
||||
return;
|
||||
}
|
||||
|
||||
// si ya hay un guardado en cola, no añadir otro
|
||||
if (!saveQueued.compareAndSet(false, true)) return;
|
||||
|
||||
saveExecutor.execute(() -> {
|
||||
try {
|
||||
BinarySerializer.writeBytes(snapshot, CONFIG_FILE);
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.saved").getString());
|
||||
} catch (IOException e) {
|
||||
Sputnik.LOGGER.error(Component.translatable("sputnik.config.error.saving").getString(), e);
|
||||
} finally {
|
||||
saveQueued.set(false);
|
||||
}
|
||||
});
|
||||
writeSnapshot(false);
|
||||
}
|
||||
|
||||
public void saveOnShutdown() {
|
||||
// esperar a que termine cualquier guardado en curso, luego guardar síncronamente
|
||||
// no aceptar más tareas y esperar a que termine el guardado en curso
|
||||
saveExecutor.shutdown();
|
||||
try {
|
||||
// dar hasta 5 segundos para que termine el guardado en curso
|
||||
if (!saveExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
|
||||
Sputnik.LOGGER.warn(Component.translatable("sputnik.config.warn.thread").getString());
|
||||
Sputnik.LOGGER.warn(I18nUtil.fmt("sputnik.config.warn.thread",
|
||||
"el hilo de guardado no terminó a tiempo"));
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
// guardado final sincrónico por si había cambios pendientes no guardados
|
||||
if (dirty) save();
|
||||
// el guardado final va en este mismo hilo: el executor ya está cerrado, así que
|
||||
// encolar la escritura lanzaba RejectedExecutionException y no se guardaba NADA al
|
||||
// cerrar el juego. o sea que se perdía todo lo hecho desde el último autoguardado
|
||||
if (!loaded) return;
|
||||
writeSnapshot(true);
|
||||
}
|
||||
|
||||
// serializa en el hilo actual (instantánea inmediata, evita race conditions) y escribe
|
||||
// en el de fondo, salvo que se pida síncrono (al cerrar)
|
||||
private void writeSnapshot(boolean sync) {
|
||||
ensureConfig();
|
||||
|
||||
final byte[] snapshot;
|
||||
try {
|
||||
snapshot = BinarySerializer.toBytes(config);
|
||||
} catch (IOException e) {
|
||||
Sputnik.LOGGER.error(I18nUtil.fmt("sputnik.config.error.serialization",
|
||||
"error al serializar ajustes"), e);
|
||||
return;
|
||||
}
|
||||
|
||||
dirty = false;
|
||||
lastSaveTime = System.currentTimeMillis();
|
||||
|
||||
if (sync) {
|
||||
writeToDisk(snapshot);
|
||||
return;
|
||||
}
|
||||
|
||||
// si ya había una instantánea esperando, la tarea encolada recogerá ésta
|
||||
if (pending.getAndSet(snapshot) != null) return;
|
||||
|
||||
saveExecutor.execute(() -> {
|
||||
byte[] bytes = pending.getAndSet(null);
|
||||
if (bytes != null) writeToDisk(bytes);
|
||||
});
|
||||
}
|
||||
|
||||
private static void writeToDisk(byte[] bytes) {
|
||||
try {
|
||||
BinarySerializer.writeBytes(bytes, CONFIG_FILE);
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.saved", "ajustes guardados"));
|
||||
} catch (IOException e) {
|
||||
Sputnik.LOGGER.error(I18nUtil.fmt("sputnik.config.error.saving",
|
||||
"error al guardar ajustes"), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.loading").getString());
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.loading", "cargando ajustes..."));
|
||||
|
||||
if (CONFIG_FILE.exists()) {
|
||||
try {
|
||||
config = BinarySerializer.readConfig(CONFIG_FILE);
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.loaded").getString());
|
||||
setConfig(BinarySerializer.readConfig(CONFIG_FILE));
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.loaded", "ajustes cargados"));
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
Sputnik.LOGGER.error(Component.translatable("sputnik.config.error.loading").getString(), e);
|
||||
Sputnik.LOGGER.error(I18nUtil.fmt("sputnik.config.error.loading",
|
||||
"error cargando ajustes, intentando json"), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,35 +152,96 @@ public class ConfigManager {
|
||||
if (LEGACY_JSON_FILE.exists()) {
|
||||
try (FileReader reader = new FileReader(LEGACY_JSON_FILE)) {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
config = gson.fromJson(reader, ClientConfig.class);
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.json").getString());
|
||||
setConfig(gson.fromJson(reader, ClientConfig.class));
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.json",
|
||||
"ajustes json cargados (migración)"));
|
||||
|
||||
save();
|
||||
// aquí `loaded` todavía es false (se pone al aplicar), así que save() no
|
||||
// haría nada: la migración se escribe directamente
|
||||
writeSnapshot(true);
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
Sputnik.LOGGER.error(Component.translatable("sputnik.config.error.json").getString(), e);
|
||||
Sputnik.LOGGER.error(I18nUtil.fmt("sputnik.config.error.json",
|
||||
"error cargando json, usando defaults"), e);
|
||||
}
|
||||
}
|
||||
|
||||
// crear nuevo config
|
||||
ensureConfig();
|
||||
writeSnapshot(true);
|
||||
}
|
||||
|
||||
// aplicar configuraciones cargadas. devuelve false si todavía no se puede (falta algo por
|
||||
// construir), para que se reintente en el siguiente tick en vez de quedarse sin aplicar
|
||||
public boolean applyConfig() {
|
||||
if (!shouldApply()) return false;
|
||||
|
||||
applying = true;
|
||||
try {
|
||||
// los del mod primero: entre ellos está "teclas multimódulo", que decide si al
|
||||
// asignar una tecla se le quita a los demás módulos. aplicándolos los últimos,
|
||||
// las teclas de los módulos se cargaban con el valor por defecto de ese ajuste
|
||||
applyClientSettings();
|
||||
applyModuleStates();
|
||||
applyModuleSettings();
|
||||
applySettingsPanels();
|
||||
applySearchBarPosition();
|
||||
applyExtendablePanels();
|
||||
applyFriends();
|
||||
applyMacros();
|
||||
applyHudElements();
|
||||
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.applied", "ajustes aplicados"));
|
||||
} catch (Exception e) {
|
||||
// si algo peta a medio aplicar no se puede dejar `loaded` en false: save() no
|
||||
// haría nada en toda la sesión y se perdería la config. entera al cerrar
|
||||
Sputnik.LOGGER.error(I18nUtil.fmt("sputnik.config.error.applying",
|
||||
"error aplicando ajustes"), e);
|
||||
} finally {
|
||||
applying = false;
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// true mientras se está cargando la config. sobre los ajustes. lo mira KeySetting para no
|
||||
// tratar las teclas guardadas como si el usuario las acabara de asignar, y ClientConfig
|
||||
// para no reescribir en la config. lo que se le está aplicando
|
||||
public boolean isApplying() {
|
||||
return applying;
|
||||
}
|
||||
|
||||
// sustituye la config. viva por otra y la vuelca sobre el estado actual del cliente
|
||||
public void replaceConfig(ClientConfig newConfig) {
|
||||
applying = true;
|
||||
try {
|
||||
resetLiveState();
|
||||
} finally {
|
||||
applying = false;
|
||||
}
|
||||
|
||||
setConfig(newConfig);
|
||||
loaded = false;
|
||||
applyConfig();
|
||||
save();
|
||||
}
|
||||
|
||||
// aplicar configuraciones cargadas
|
||||
public void applyConfig() {
|
||||
if (!shouldApply()) return;
|
||||
// lo que no venga en la config. nueva tiene que quedarse en su valor por defecto, no en
|
||||
// el que tuviera el perfil anterior
|
||||
private void resetLiveState() {
|
||||
if (ClickGui.INSTANCE != null) ClickGui.INSTANCE.closeAllSettingsPanels();
|
||||
|
||||
applyModuleStates();
|
||||
applyModuleSettings();
|
||||
applySettingsPanels();
|
||||
applySearchBarPosition();
|
||||
applyClientSettings();
|
||||
applyExtendablePanels();
|
||||
applyFriends();
|
||||
for (Module module : ModuleManager.INSTANCE.getModules()) {
|
||||
module.setEnabled(false);
|
||||
module.getSettings().forEach(Setting::reset);
|
||||
}
|
||||
ClientSettingsPanel.clientSettings.getSettings().forEach(Setting::reset);
|
||||
|
||||
loaded = true;
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.applied").getString());
|
||||
for (Friend friend : new ArrayList<>(FriendManager.INSTANCE.getFriends()))
|
||||
FriendManager.INSTANCE.remove(friend);
|
||||
|
||||
MacroManager.INSTANCE.setMacros(List.of());
|
||||
}
|
||||
|
||||
// obtener configuración actual
|
||||
@@ -204,6 +298,20 @@ public class ConfigManager {
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setMacros(List<Macro> macros) {
|
||||
ensureConfig();
|
||||
config.macros = macros.stream()
|
||||
.map(macro -> new ClientConfig.MacroData(macro.getName(), macro.getKey(), List.copyOf(macro.getLines())))
|
||||
.toList();
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setCurrentProfile(String name) {
|
||||
ensureConfig();
|
||||
config.currentProfile = name;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
|
||||
// ------------------ APLICAR AJUSTES ------------------
|
||||
|
||||
@@ -213,7 +321,28 @@ public class ConfigManager {
|
||||
friend.setName(name);
|
||||
FriendManager.INSTANCE.add(friend);
|
||||
});
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.friends").getString());
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.friends",
|
||||
"amigos aplicados"));
|
||||
}
|
||||
|
||||
public void applyMacros() {
|
||||
MacroManager.INSTANCE.setMacros(config.macros.stream()
|
||||
.map(data -> new Macro(data.name(), data.key(), data.lines()))
|
||||
.toList());
|
||||
}
|
||||
|
||||
// el HudRenderer coloca sus elementos al construirse, pero al cambiar de perfil ya existen
|
||||
public void applyHudElements() {
|
||||
if (HudRenderer.INSTANCE == null) return;
|
||||
|
||||
for (HudElement element : HudRenderer.INSTANCE.getElements()) {
|
||||
int[] position = config.hudPositions.get(element.getId());
|
||||
if (position != null && position.length == 2) element.setPosition(position[0], position[1]);
|
||||
else element.resetPosition();
|
||||
|
||||
Boolean visible = config.hudVisibilities.get(element.getId());
|
||||
element.setVisible(visible == null || visible);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@@ -233,8 +362,9 @@ public class ConfigManager {
|
||||
case ListSetting listSetting -> applyListSetting(listSetting, value);
|
||||
case ColorSetting colorSetting -> applyColorSetting(colorSetting, value);
|
||||
case OptionSetting optionSetting -> applyOptionSetting(optionSetting, value);
|
||||
default -> Sputnik.LOGGER.warn(Component.translatable("sputnik.config.warn.unknownsetting",
|
||||
setting.getClass().getSimpleName()).getString());
|
||||
case FileSetting fileSetting -> applyFileSetting(fileSetting, value);
|
||||
default -> Sputnik.LOGGER.warn(I18nUtil.fmt("sputnik.config.warn.unknownsetting",
|
||||
"watafac queseso: %s", setting.getClass().getSimpleName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,14 +374,16 @@ public class ConfigManager {
|
||||
module.setEnabled(config.moduleStates.get(module.getName()));
|
||||
}
|
||||
});
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.modulestates").getString());
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.modulestates",
|
||||
"estados de módulos aplicados"));
|
||||
}
|
||||
|
||||
private void applyModuleSettings() {
|
||||
ModuleManager.INSTANCE.getModules().forEach(module -> {
|
||||
module.getSettings().forEach(this::applySetting);
|
||||
});
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.modulesettings").getString());
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.modulesettings",
|
||||
"ajustes de módulos aplicados"));
|
||||
}
|
||||
|
||||
private void applySettingsPanels() {
|
||||
@@ -259,14 +391,16 @@ public class ConfigManager {
|
||||
Module module = ModuleManager.INSTANCE.getModuleByName(moduleName);
|
||||
|
||||
if (module == null) {
|
||||
Sputnik.LOGGER.warn(Component.translatable("sputnik.config.warn.nullmodule", moduleName).getString());
|
||||
Sputnik.LOGGER.warn(I18nUtil.fmt("sputnik.config.warn.nullmodule",
|
||||
"\"null\" como módulo (\"%s\")", moduleName));
|
||||
return;
|
||||
}
|
||||
|
||||
ClickGui.INSTANCE.openSettingsPanel(module, position[0], position[1]);
|
||||
});
|
||||
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.settingspanels").getString());
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.settingspanels",
|
||||
"estados de marcos de ajustes aplicados"));
|
||||
}
|
||||
|
||||
private void applySearchBarPosition() {
|
||||
@@ -274,13 +408,15 @@ public class ConfigManager {
|
||||
ClickGui.INSTANCE.getSearchBar().setX(config.searchBarPosition[0]);
|
||||
ClickGui.INSTANCE.getSearchBar().setY(config.searchBarPosition[1]);
|
||||
}
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.searchbar").getString());
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.searchbar",
|
||||
"posición de la barra de búsqueda aplicada"));
|
||||
}
|
||||
|
||||
private void applyClientSettings() {
|
||||
ClientSettingsPanel.clientSettings.setEnabled(true);
|
||||
ClientSettingsPanel.clientSettings.getSettings().forEach(this::applySetting);
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.clientsettings").getString());
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.clientsettings",
|
||||
"ajustes del cliente aplicados"));
|
||||
}
|
||||
|
||||
private void applyExtendablePanels() {
|
||||
@@ -290,7 +426,8 @@ public class ConfigManager {
|
||||
applyExtendablePanel(ClickGui.INSTANCE.getClientSettingsPanel());
|
||||
applyExtendablePanel(ClickGui.INSTANCE.getFriendsPanel());
|
||||
|
||||
Sputnik.LOGGER.info(Component.translatable("sputnik.config.info.extendablepanels").getString());
|
||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.extendablepanels",
|
||||
"posiciones de marcos extendibles aplicadas"));
|
||||
ClickGui.INSTANCE.refreshListButtons();
|
||||
}
|
||||
|
||||
@@ -341,8 +478,8 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
private static void applyStringSetting(StringSetting setting, Object value) {
|
||||
if (value instanceof String) {
|
||||
setting.setValue((String) value);
|
||||
if (value instanceof String v) {
|
||||
setting.setValue(v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,8 +496,14 @@ public class ConfigManager {
|
||||
Map<T, Boolean> convertedValues = new HashMap<>();
|
||||
|
||||
for (T option : setting.getOptions()) {
|
||||
String key = setting.getDisplayName(option);
|
||||
String key = setting.getConfigName(option);
|
||||
Object booleanValue = map.get(key);
|
||||
|
||||
// compatibilidad con configs. de antes, cuando la clave era el nombre ya
|
||||
// traducido (el de vanilla en inglés). sin esto la lista entera se quedaba
|
||||
// en false, o sea que al usuario se le borraba lo que tuviera marcado
|
||||
if (booleanValue == null) booleanValue = map.get(I18nUtil.vanillaName(key));
|
||||
|
||||
convertedValues.put(option, booleanValue instanceof Boolean && (Boolean) booleanValue);
|
||||
}
|
||||
|
||||
@@ -397,6 +540,12 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyFileSetting(FileSetting setting, Object value) {
|
||||
if (value instanceof String v) {
|
||||
setting.setValue(v);
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> void applyOptionalProperty(Map<?, ?> map, String key, Class<T> type, Consumer<T> setter) {
|
||||
Object value = map.get(key);
|
||||
if (type.isInstance(value)) {
|
||||
@@ -411,12 +560,24 @@ public class ConfigManager {
|
||||
return setting.getSg().getModule().getName() + ":" + setting.getTrueName();
|
||||
}
|
||||
|
||||
// ClickGui incluida: los marcos y la barra de búsqueda se aplican sobre ella, y se
|
||||
// construye en una tarea aparte. si todavía no está, mejor esperar al siguiente tick
|
||||
private boolean shouldApply() {
|
||||
return Sputnik.mc != null && ModuleManager.INSTANCE != null && config != null;
|
||||
return Sputnik.mc != null && ModuleManager.INSTANCE != null
|
||||
&& ClickGui.INSTANCE != null && config != null;
|
||||
}
|
||||
|
||||
private void ensureConfig() {
|
||||
if (config == null) config = new ClientConfig();
|
||||
if (config == null) setConfig(new ClientConfig());
|
||||
}
|
||||
|
||||
// ClientConfig se suscribe al bus en su constructor, así que al reemplazarla hay que
|
||||
// dar de baja a la anterior: si no, la vieja seguía escuchando y escribiendo en un
|
||||
// mapa que ya no era el que se guarda
|
||||
private void setConfig(ClientConfig newConfig) {
|
||||
if (config == newConfig) return;
|
||||
if (config != null) Sputnik.EVENT_BUS.unsubscribe(config);
|
||||
config = newConfig;
|
||||
}
|
||||
|
||||
public boolean hasLoaded() {
|
||||
@@ -425,7 +586,6 @@ public class ConfigManager {
|
||||
|
||||
public void markDirty() {
|
||||
this.dirty = true;
|
||||
this.lastDirtyTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
@@ -438,13 +598,14 @@ public class ConfigManager {
|
||||
ClientSettingsModule settings = ClientSettingsPanel.clientSettings;
|
||||
if (!settings.autosave.getValue()) return;
|
||||
|
||||
// desde el último guardado, no desde el último cambio: contando desde el cambio,
|
||||
// tocando ajustes cada menos del intervalo no se autoguardaba nunca
|
||||
long intervalMs = (long) (settings.autosaveInterval.getValue() * 1000);
|
||||
if (System.currentTimeMillis() - lastDirtyTime < intervalMs) return;
|
||||
if (System.currentTimeMillis() - lastSaveTime < intervalMs) return;
|
||||
|
||||
HudRenderer.INSTANCE.pushNotification(
|
||||
Component.translatable("sputnik.config.autosaving.title").getString(),
|
||||
Component.translatable("sputnik.config.autosaving.desc").getString());
|
||||
save();
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package me.retucio.sputnik.config;
|
||||
|
||||
import me.retucio.sputnik.Sputnik;
|
||||
import me.retucio.sputnik.util.I18nUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ProfileManager {
|
||||
|
||||
public static final int MAX_NAME_LENGTH = 32;
|
||||
|
||||
private static final File DIR = new File("sputnik/profiles");
|
||||
private static final String EXTENSION = ".dat";
|
||||
|
||||
public static ProfileManager INSTANCE;
|
||||
|
||||
public List<String> getProfileNames() {
|
||||
File[] files = DIR.listFiles((dir, name) -> name.endsWith(EXTENSION));
|
||||
if (files == null) return List.of();
|
||||
|
||||
List<String> names = new ArrayList<>();
|
||||
for (File file : files) {
|
||||
String name = file.getName();
|
||||
names.add(name.substring(0, name.length() - EXTENSION.length()));
|
||||
}
|
||||
names.sort(Comparator.naturalOrder());
|
||||
return names;
|
||||
}
|
||||
|
||||
public boolean exists(String name) {
|
||||
return fileOf(name).exists();
|
||||
}
|
||||
|
||||
public String getCurrent() {
|
||||
return ConfigManager.INSTANCE.getConfig().currentProfile;
|
||||
}
|
||||
|
||||
// vuelca la config. viva en el perfil y lo deja como actual
|
||||
public boolean save(String name) {
|
||||
if (!isValidName(name)) return false;
|
||||
|
||||
if (!DIR.exists() && !DIR.mkdirs()) {
|
||||
Sputnik.LOGGER.error(I18nUtil.fmt("sputnik.profile.error.dir",
|
||||
"no se pudo crear el directorio de perfiles"));
|
||||
return false;
|
||||
}
|
||||
|
||||
ConfigManager.INSTANCE.setCurrentProfile(name);
|
||||
try {
|
||||
BinarySerializer.writeConfig(ConfigManager.INSTANCE.getConfig(), fileOf(name));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Sputnik.LOGGER.error(I18nUtil.fmt("sputnik.profile.error.saving",
|
||||
"error al guardar el perfil \"%s\"", name), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean load(String name) {
|
||||
if (!exists(name)) return false;
|
||||
|
||||
ClientConfig profile;
|
||||
try {
|
||||
profile = BinarySerializer.readConfig(fileOf(name));
|
||||
} catch (IOException e) {
|
||||
Sputnik.LOGGER.error(I18nUtil.fmt("sputnik.profile.error.loading",
|
||||
"error al cargar el perfil \"%s\"", name), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
profile.currentProfile = name;
|
||||
ConfigManager.INSTANCE.replaceConfig(profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean delete(String name) {
|
||||
if (!exists(name)) return false;
|
||||
if (!fileOf(name).delete()) return false;
|
||||
|
||||
if (name.equals(getCurrent())) ConfigManager.INSTANCE.setCurrentProfile("");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isValidName(String name) {
|
||||
return name != null
|
||||
&& !name.isBlank()
|
||||
&& name.length() <= MAX_NAME_LENGTH
|
||||
&& name.matches("[a-zA-Z0-9 _-]+");
|
||||
}
|
||||
|
||||
private static File fileOf(String name) {
|
||||
return new File(DIR, name + EXTENSION);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package me.retucio.sputnik.event.interact;
|
||||
|
||||
import com.github.retucio.neutrino.Event;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class UpdateInventoryEvent extends Event {
|
||||
|
||||
private final List<ItemStack> prev;
|
||||
|
||||
public UpdateInventoryEvent(List<ItemStack> prev) {
|
||||
this.prev = prev;
|
||||
}
|
||||
|
||||
public List<ItemStack> getPrev() {
|
||||
return prev;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package me.retucio.sputnik.event.render;
|
||||
|
||||
import com.github.retucio.neutrino.Event;
|
||||
import net.minecraft.client.resources.model.cuboid.ItemTransform;
|
||||
|
||||
|
||||
public class ApplyTransformationEvent extends Event {
|
||||
|
||||
private final ItemTransform transformation;
|
||||
private final boolean leftHanded;
|
||||
|
||||
public ApplyTransformationEvent(ItemTransform transformation, boolean leftHanded) {
|
||||
this.transformation = transformation;
|
||||
this.leftHanded = leftHanded;
|
||||
}
|
||||
|
||||
public ItemTransform getTransformation() {
|
||||
return transformation;
|
||||
}
|
||||
|
||||
public boolean isLeftHanded() {
|
||||
return leftHanded;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.retucio.sputnik.event.render;
|
||||
|
||||
import com.github.retucio.neutrino.Event;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import me.retucio.sputnik.mixinterfaces.IEntityRenderState;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.client.renderer.entity.state.ItemEntityRenderState;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
|
||||
public class RenderItemEntityEvent extends Event {
|
||||
|
||||
public final ItemEntity itemEntity;
|
||||
public final ItemEntityRenderState renderState;
|
||||
public final PoseStack matrixStack;
|
||||
public final SubmitNodeCollector renderCommandQueue;
|
||||
public final int light;
|
||||
|
||||
public RenderItemEntityEvent(ItemEntityRenderState renderState, PoseStack matrixStack, SubmitNodeCollector renderCommandQueue, int light) {
|
||||
this.itemEntity = (ItemEntity) ((IEntityRenderState) renderState).sputnik$getEntity();
|
||||
this.renderState = renderState;
|
||||
this.matrixStack = matrixStack;
|
||||
this.renderCommandQueue = renderCommandQueue;
|
||||
this.light = light;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package me.retucio.sputnik.macro;
|
||||
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Macro {
|
||||
|
||||
private String name;
|
||||
private int key;
|
||||
private final List<String> lines = new ArrayList<>();
|
||||
|
||||
private boolean searchMatch = true;
|
||||
|
||||
public Macro(String name) {
|
||||
this(name, GLFW.GLFW_KEY_UNKNOWN, List.of());
|
||||
}
|
||||
|
||||
public Macro(String name, int key, List<String> lines) {
|
||||
this.name = name;
|
||||
this.key = key;
|
||||
this.lines.addAll(lines);
|
||||
}
|
||||
|
||||
// cada línea se manda como si el usuario la hubiera escrito en el chat, así que valen
|
||||
// comandos del mod, comandos del servidor y mensajes normales
|
||||
public void run() {
|
||||
if (Minecraft.getInstance().player == null) return;
|
||||
for (String line : lines) {
|
||||
if (!line.isBlank()) ChatUtil.simulateChatMessage(line);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public int getKey() { return key; }
|
||||
public void setKey(int key) { this.key = key; }
|
||||
|
||||
public List<String> getLines() { return lines; }
|
||||
|
||||
public void setLines(List<String> lines) {
|
||||
this.lines.clear();
|
||||
this.lines.addAll(lines);
|
||||
}
|
||||
|
||||
public boolean isSearchMatch() { return searchMatch; }
|
||||
public void setSearchMatch(boolean searchMatch) { this.searchMatch = searchMatch; }
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package me.retucio.sputnik.macro;
|
||||
|
||||
import me.retucio.sputnik.config.ConfigManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MacroManager {
|
||||
|
||||
public static MacroManager INSTANCE;
|
||||
|
||||
private final List<Macro> macros = new ArrayList<>();
|
||||
|
||||
public boolean add(Macro macro) {
|
||||
if (getByName(macro.getName()) != null) return false;
|
||||
macros.add(macro);
|
||||
save();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void remove(Macro macro) {
|
||||
macros.remove(macro);
|
||||
save();
|
||||
}
|
||||
|
||||
public Macro getByName(String name) {
|
||||
for (Macro macro : macros) {
|
||||
if (macro.getName().equalsIgnoreCase(name)) return macro;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean onKeyPress(int key) {
|
||||
if (key == GLFW.GLFW_KEY_UNKNOWN || Minecraft.getInstance().gui.screen() != null) return false;
|
||||
|
||||
boolean ran = false;
|
||||
for (Macro macro : new ArrayList<>(macros)) {
|
||||
if (macro.getKey() != key) continue;
|
||||
macro.run();
|
||||
ran = true;
|
||||
}
|
||||
return ran;
|
||||
}
|
||||
|
||||
public void setMacros(List<Macro> macros) {
|
||||
this.macros.clear();
|
||||
this.macros.addAll(macros);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (ConfigManager.INSTANCE != null) ConfigManager.INSTANCE.setMacros(macros);
|
||||
}
|
||||
|
||||
public List<Macro> getMacros() {
|
||||
return macros;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package me.retucio.sputnik.mixin.accessors;
|
||||
|
||||
import net.minecraft.client.renderer.item.ItemStackRenderState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
|
||||
@Mixin(ItemStackRenderState.class)
|
||||
public interface ItemStackRenderStateAccessor {
|
||||
|
||||
@Accessor("activeLayerCount")
|
||||
int getActiveLayerCount();
|
||||
|
||||
@Accessor("layers")
|
||||
ItemStackRenderState.LayerRenderState[] getLayers();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.retucio.sputnik.mixin.accessors;
|
||||
|
||||
import net.minecraft.client.renderer.item.ItemStackRenderState;
|
||||
import net.minecraft.client.resources.model.cuboid.ItemTransform;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
|
||||
@Mixin(ItemStackRenderState.LayerRenderState.class)
|
||||
public interface LayerRenderStateAccessor {
|
||||
|
||||
@Accessor("itemTransform")
|
||||
ItemTransform sputnik$getTransform();
|
||||
}
|
||||
@@ -11,9 +11,7 @@ import me.retucio.sputnik.module.modules.misc.AntiInvis;
|
||||
import me.retucio.sputnik.module.modules.movement.BoatFly;
|
||||
import me.retucio.sputnik.module.modules.movement.Velocity;
|
||||
import me.retucio.sputnik.module.modules.render.Nametags;
|
||||
import me.retucio.sputnik.util.interfaces.IVec3;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -25,8 +23,6 @@ import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.arrow.AbstractArrow;
|
||||
import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector3d;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@@ -8,8 +8,10 @@ import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
|
||||
@@ -31,7 +33,7 @@ public abstract class EntityRendererMixin {
|
||||
|
||||
@ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getTeamColor()I"))
|
||||
private int setGlowESPColor(int original, @Local(argsOnly = true) Entity entity) {
|
||||
if (esp.isEnabled() && esp.mode.is(EntityEsp.ESPMode.GLOW) && esp.entities.isEnabled(entity.getType())) return esp.glowColor.getRGB();
|
||||
if (esp.isEnabled() && esp.mode.is(EntityEsp.ESPMode.GLOW) && esp.entities.isEnabled(entity.getType())) return esp.glowColor.getRgb();
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,10 @@ import me.retucio.sputnik.event.network.ReceiveMessageEvent;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.misc.ChatPlus;
|
||||
|
||||
import me.retucio.sputnik.util.interfaces.IChatComponent;
|
||||
import me.retucio.sputnik.util.interfaces.IGuiMessage;
|
||||
import me.retucio.sputnik.util.interfaces.IGuiMessageLine;
|
||||
import me.retucio.sputnik.util.interfaces.IChatListener;
|
||||
import me.retucio.sputnik.mixinterfaces.IChatComponent;
|
||||
import me.retucio.sputnik.mixinterfaces.IGuiMessage;
|
||||
import me.retucio.sputnik.mixinterfaces.IGuiMessageLine;
|
||||
import me.retucio.sputnik.mixinterfaces.IChatListener;
|
||||
|
||||
import net.minecraft.client.gui.components.ChatComponent;
|
||||
import net.minecraft.client.multiplayer.chat.GuiMessage;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.retucio.sputnik.mixin.mixins.hud;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import me.retucio.sputnik.util.interfaces.IGuiMessageLine;
|
||||
import me.retucio.sputnik.mixinterfaces.IGuiMessageLine;
|
||||
import net.minecraft.client.multiplayer.chat.GuiMessage;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.retucio.sputnik.mixin.mixins.hud;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import me.retucio.sputnik.util.interfaces.IGuiMessage;
|
||||
import me.retucio.sputnik.mixinterfaces.IGuiMessage;
|
||||
import net.minecraft.client.multiplayer.chat.GuiMessage;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
||||
@@ -84,7 +84,7 @@ public abstract class HudMixin {
|
||||
// dangerous abbreviation
|
||||
CrosshairPlus cp = ModuleManager.INSTANCE.getModuleByClass(CrosshairPlus.class);
|
||||
|
||||
int color = cp.isEnabled() ? cp.color.getRGB() : -1;
|
||||
int color = cp.isEnabled() ? cp.color.getRgb() : -1;
|
||||
int w = cp.isEnabled() ? cp.width.getIntValue() : width;
|
||||
int h = cp.isEnabled() ? cp.height.getIntValue() : height;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Screenshot;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -19,14 +20,14 @@ import java.util.function.Consumer;
|
||||
@Mixin(Screenshot.class)
|
||||
public abstract class ScreenshotMixin {
|
||||
|
||||
@Inject(method = "lambda$grab$1", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"), cancellable = true)
|
||||
private static void sendActionsMessage(NativeImage image, File file, Consumer<?> callback, CallbackInfo ci) {
|
||||
@Inject(method = "lambda$grab$3", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"), cancellable = true)
|
||||
private static void sendActionsMessage(NativeImage image, File file, Consumer<Component> callback, CallbackInfo ci) {
|
||||
ScreenshotPlus screenshotPlus = getScreenshotPlus();
|
||||
if (screenshotPlus.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "lambda$grab$1", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/NativeImage;writeToFile(Ljava/io/File;)V"), cancellable = true)
|
||||
private static void interceptScreenshotFile(NativeImage image, File file, Consumer<?> callback, CallbackInfo ci) throws IOException {
|
||||
@Inject(method = "lambda$grab$3", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/NativeImage;writeToFile(Ljava/io/File;)V"), cancellable = true)
|
||||
private static void interceptScreenshotFile(NativeImage image, File file, Consumer<Component> callback, CallbackInfo ci) throws IOException {
|
||||
ScreenshotPlus screenshotPlus = getScreenshotPlus();
|
||||
|
||||
// aunque el módulo esté apagado, pasar las referencias para poder usar los comandos para las capturas
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.retucio.sputnik.mixin.mixins.item;
|
||||
|
||||
import me.retucio.sputnik.Sputnik;
|
||||
import me.retucio.sputnik.event.render.RenderItemEntityEvent;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
import net.minecraft.client.renderer.entity.ItemEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.ItemEntityRenderState;
|
||||
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||
|
||||
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(ItemEntityRenderer.class)
|
||||
public class ItemEntityRendererMixin {
|
||||
|
||||
@Inject(method = "submit(Lnet/minecraft/client/renderer/entity/state/ItemEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/state/level/CameraRenderState;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSubmit(ItemEntityRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera, CallbackInfo ci) {
|
||||
RenderItemEntityEvent event = Sputnik.EVENT_BUS.post(
|
||||
new RenderItemEntityEvent(
|
||||
state,
|
||||
poseStack,
|
||||
submitNodeCollector,
|
||||
state.lightCoords
|
||||
)
|
||||
);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package me.retucio.sputnik.mixin.mixins.item;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import me.retucio.sputnik.Sputnik;
|
||||
import me.retucio.sputnik.event.render.ApplyTransformationEvent;
|
||||
import net.minecraft.client.resources.model.cuboid.ItemTransform;
|
||||
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(ItemTransform.class)
|
||||
public abstract class ItemTransformMixin {
|
||||
@Inject(method = "apply", at = @At("HEAD"), cancellable = true)
|
||||
private void onApply(boolean applyLeftHandFix, PoseStack.Pose pose, CallbackInfo ci) {
|
||||
ApplyTransformationEvent event = Sputnik.EVENT_BUS.post(new ApplyTransformationEvent((ItemTransform) (Object) this, applyLeftHandFix));
|
||||
if (event.isCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,14 @@ package me.retucio.sputnik.mixin.mixins.misc;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import me.retucio.sputnik.Sputnik;
|
||||
import me.retucio.sputnik.event.network.JoinWorldEvent;
|
||||
import me.retucio.sputnik.event.interact.OpenScreenEvent;
|
||||
import me.retucio.sputnik.event.ShutdownEvent;
|
||||
import me.retucio.sputnik.event.TickEvent;
|
||||
import me.retucio.sputnik.event.interact.UseItemEvent;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.camera.Freecam;
|
||||
import me.retucio.sputnik.module.modules.player.FastUse;
|
||||
import me.retucio.sputnik.util.interfaces.IVec3;
|
||||
import me.retucio.sputnik.mixinterfaces.IVec3;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.retucio.sputnik.mixin.mixins.misc;
|
||||
|
||||
import me.retucio.sputnik.util.Lists;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.component.DataComponentMap;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Holder.Reference.class)
|
||||
public abstract class ReferenceMixin<T> {
|
||||
|
||||
@Shadow
|
||||
private @Nullable DataComponentMap components;
|
||||
|
||||
@Shadow
|
||||
private @Nullable T value;
|
||||
|
||||
@Inject(method = "bindComponents", at = @At("TAIL"))
|
||||
private void onBindComponents(DataComponentMap components, CallbackInfo ci) {
|
||||
if (this.components == null || !this.components.has(DataComponents.FOOD)) return;
|
||||
if (!(this.value instanceof Item item)) return;
|
||||
|
||||
Lists.foodList.add(item);
|
||||
Lists.foodNames.put(item, BuiltInRegistries.ITEM.getKey(item).toLanguageKey());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.retucio.sputnik.mixin.mixins.misc;
|
||||
|
||||
import me.retucio.sputnik.util.interfaces.IVec3;
|
||||
import me.retucio.sputnik.mixinterfaces.IVec3;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.retucio.sputnik.mixin.mixins.network;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import me.retucio.sputnik.util.interfaces.IChatListener;
|
||||
import me.retucio.sputnik.mixinterfaces.IChatListener;
|
||||
import net.minecraft.client.multiplayer.chat.ChatListener;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
@@ -4,7 +4,7 @@ import me.retucio.sputnik.mixin.accessors.PackConfirmScreenAccessor;
|
||||
import me.retucio.sputnik.mixin.accessors.PendingRequestAccessor;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.network.RPackBypass;
|
||||
import me.retucio.sputnik.util.interfaces.IConfirmScreen;
|
||||
import me.retucio.sputnik.mixinterfaces.IConfirmScreen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.retucio.sputnik.mixin.mixins.player;
|
||||
|
||||
import me.retucio.sputnik.Sputnik;
|
||||
import me.retucio.sputnik.event.interact.UpdateInventoryEvent;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
|
||||
@Mixin(Inventory.class)
|
||||
public abstract class InventoryMixin {
|
||||
|
||||
@Shadow @Final
|
||||
private NonNullList<ItemStack> items;
|
||||
|
||||
@Inject(method = "setChanged", at = @At("HEAD"))
|
||||
private void onChange(CallbackInfo ci) {
|
||||
Sputnik.EVENT_BUS.post(new UpdateInventoryEvent(items));
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public abstract class EntityHitboxDebugRendererMixin {
|
||||
@ModifyVariable(method = "showHitboxes", at = @At("STORE"), name = "mainColor")
|
||||
private int modifyHitboxColor(int original) {
|
||||
Hitboxes hitboxes = ModuleManager.INSTANCE.getModuleByClass(Hitboxes.class);
|
||||
if (hitboxes.isEnabled()) return hitboxes.color.getRGB();
|
||||
if (hitboxes.isEnabled()) return hitboxes.color.getRgb();
|
||||
return original;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.retucio.sputnik.mixin.mixins.render;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import me.retucio.sputnik.mixinterfaces.IEntityRenderState;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
|
||||
@Mixin(EntityRenderDispatcher.class)
|
||||
public abstract class EntityRenderDispatcherMixin {
|
||||
@ModifyExpressionValue(
|
||||
method = "extractEntity(Lnet/minecraft/world/entity/Entity;F)Lnet/minecraft/client/renderer/entity/state/EntityRenderState;",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;createRenderState(Lnet/minecraft/world/entity/Entity;F)Lnet/minecraft/client/renderer/entity/state/EntityRenderState;")
|
||||
)
|
||||
private <E extends Entity> EntityRenderState getAndUpdateRenderState$setEntity(EntityRenderState state, E entity, float partialTicks) {
|
||||
((IEntityRenderState) state).sputnik$setEntity(entity);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.retucio.sputnik.mixin.mixins.render;
|
||||
|
||||
import me.retucio.sputnik.mixinterfaces.IEntityRenderState;
|
||||
import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
|
||||
@Mixin(EntityRenderState.class)
|
||||
public abstract class EntityRenderStateMixin implements IEntityRenderState {
|
||||
@Unique
|
||||
private Entity entity;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity sputnik$getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sputnik$setEntity(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import me.retucio.sputnik.event.render.Render3DEvent;
|
||||
import me.retucio.sputnik.event.render.RenderBlockOutlineEvent;
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.camera.Freecam;
|
||||
import me.retucio.sputnik.util.render.SputnikBuffers;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||
@@ -42,6 +43,7 @@ public abstract class LevelRendererMixin {
|
||||
|
||||
profiler.push(Sputnik.MOD_ID + "-3d");
|
||||
EVENT_BUS.post(new Render3DEvent(matrices, dt, cameraState));
|
||||
SputnikBuffers.flush(); // antes de que empiece el hud
|
||||
|
||||
profiler.pop();
|
||||
matrices.popPose();
|
||||
|
||||
@@ -8,7 +8,6 @@ import me.retucio.sputnik.module.modules.camera.Freecam;
|
||||
import me.retucio.sputnik.module.modules.render.Nametags;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@@ -16,6 +15,7 @@ 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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@@ -49,19 +49,27 @@ public abstract class LivingEntityRendererMixin<T extends LivingEntity> {
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At("RETURN"))
|
||||
private boolean shouldRenderPlayerNametag(boolean original, @Local(argsOnly = true) T livingEntity) {
|
||||
if (nametags.isEnabled() && livingEntity instanceof Player)
|
||||
private boolean shouldRenderPlayerNametag(boolean original, @Local(argsOnly = true, name = "entity") T entity) {
|
||||
if (nametags.isEnabled() && entity instanceof Player)
|
||||
return nametags.entities.isEnabled(EntityTypes.PLAYER) && original;
|
||||
return original;
|
||||
}
|
||||
|
||||
@Inject(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At("RETURN"), cancellable = true)
|
||||
private void renderSelfNametag(T livingEntity, double d, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (livingEntity instanceof Player player) {
|
||||
private void renderSelfNametag(T entity, double distanceToCameraSq, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (entity instanceof Player player) {
|
||||
if (player == mc.player && nametags.showSelf.getValue()) {
|
||||
cir.setReturnValue(true);
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyArg(method = "extractNameTags(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;extractNameTags(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/client/renderer/entity/state/EntityRenderState;FDD)V"), index = 3)
|
||||
private double modifyNametagRenderDistance(double original) {
|
||||
if (nametags.isEnabled()) {
|
||||
return nametags.distance.getValue();
|
||||
}
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package me.retucio.sputnik.mixin.mixins.screen;
|
||||
|
||||
import me.retucio.sputnik.module.ModuleManager;
|
||||
import me.retucio.sputnik.module.modules.network.RPackBypass;
|
||||
import me.retucio.sputnik.util.interfaces.IConfirmScreen;
|
||||
import me.retucio.sputnik.mixinterfaces.IConfirmScreen;
|
||||
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.layouts.LinearLayout;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ScreenMixin {
|
||||
if (watermark == null || watermark.isEmpty()) return;
|
||||
gui.text(mc.font, watermark,
|
||||
mc.getWindow().getGuiScaledWidth() - mc.font.width(watermark) - 2, 2,
|
||||
ClientSettingsPanel.clientSettings.color.getRGB(), false
|
||||
ClientSettingsPanel.clientSettings.color.getRgb(), false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.retucio.sputnik.util.interfaces;
|
||||
package me.retucio.sputnik.mixinterfaces;
|
||||
|
||||
import net.minecraft.client.multiplayer.chat.GuiMessage;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.retucio.sputnik.util.interfaces;
|
||||
package me.retucio.sputnik.mixinterfaces;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.retucio.sputnik.util.interfaces;
|
||||
package me.retucio.sputnik.mixinterfaces;
|
||||
|
||||
public interface IConfirmScreen {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package me.retucio.sputnik.mixinterfaces;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
|
||||
public interface IEntityRenderState {
|
||||
|
||||
@Nullable
|
||||
Entity sputnik$getEntity();
|
||||
|
||||
void sputnik$setEntity(Entity entity);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.retucio.sputnik.util.interfaces;
|
||||
package me.retucio.sputnik.mixinterfaces;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.retucio.sputnik.util.interfaces;
|
||||
package me.retucio.sputnik.mixinterfaces;
|
||||
|
||||
public interface IGuiMessageLine extends IGuiMessage {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.retucio.sputnik.util.interfaces;
|
||||
package me.retucio.sputnik.mixinterfaces;
|
||||
|
||||
import net.minecraft.core.Vec3i;
|
||||
import org.joml.Vector3d;
|
||||
@@ -1,6 +1,6 @@
|
||||
/* code by meteorclient dev team */
|
||||
|
||||
package me.retucio.sputnik.util.interfaces;
|
||||
package me.retucio.sputnik.mixinterfaces;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
@@ -6,16 +6,19 @@ import me.retucio.sputnik.config.ConfigManager;
|
||||
import me.retucio.sputnik.event.sputnik.ToggleModuleEvent;
|
||||
import me.retucio.sputnik.module.setting.SettingGroup;
|
||||
import me.retucio.sputnik.module.setting.settings.BooleanSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.ColorSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.EnumSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.KeySetting;
|
||||
import me.retucio.sputnik.module.setting.Setting;
|
||||
import me.retucio.sputnik.ui.hud.HudRenderer;
|
||||
import me.retucio.sputnik.util.ChatUtil;
|
||||
import me.retucio.sputnik.util.Colors;
|
||||
import me.retucio.sputnik.util.I18nUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -35,8 +38,6 @@ public class Module {
|
||||
|
||||
// ajustes que están en todos los módulos
|
||||
|
||||
// estos cuatro están en los 93 módulos, así que comparten clave en vez de derivar una por módulo
|
||||
|
||||
protected KeySetting bind = new KeySetting(
|
||||
"tecla",
|
||||
"tecla asignada al módulo, ESC para desactivar",
|
||||
@@ -44,7 +45,7 @@ public class Module {
|
||||
).translationKey("sputnik.setting.common.bind");
|
||||
|
||||
// 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<KeyMode> keyMode = new EnumSetting<KeyMode>(
|
||||
protected EnumSetting<KeyMode> keyMode = new EnumSetting<>(
|
||||
"modo de tecla",
|
||||
"cómo interpretar la tecla configurada",
|
||||
KeyMode.class, KeyMode.TOGGLE
|
||||
@@ -56,12 +57,26 @@ public class Module {
|
||||
true
|
||||
).translationKey("sputnik.setting.common.notify");
|
||||
|
||||
protected EnumSetting<NotifyMode> notifyMode = new EnumSetting<NotifyMode>(
|
||||
protected EnumSetting<NotifyMode> notifyMode = new EnumSetting<>(
|
||||
"modo de notificación",
|
||||
"cómo notificar cuando se activa / desactiva",
|
||||
NotifyMode.class, NotifyMode.WIDGET
|
||||
).translationKey("sputnik.setting.common.notifymode");
|
||||
|
||||
protected BooleanSetting displayed = new BooleanSetting(
|
||||
"visible",
|
||||
"mostrar en el arraylist del HUD",
|
||||
true
|
||||
).translationKey("sputnik.setting.common.displayed");;
|
||||
|
||||
protected ColorSetting arraylistColor = new ColorSetting(
|
||||
"color del arraylist",
|
||||
"color a usar en el arraylist para el nombre del módulo",
|
||||
new Color(Colors.red, Colors.green, Colors.blue, Colors.alpha),
|
||||
true
|
||||
).translationKey("sputnik.setting.common.arraylistcolor")
|
||||
.visibility(displayed::getValue);
|
||||
|
||||
protected final List<SettingGroup> sgs = new ArrayList<>();
|
||||
protected final SettingGroup sgModule = addSg(new SettingGroup("módulo", false, "sputnik.group.common.module"));
|
||||
protected final SettingGroup sgGeneral = addSg(new SettingGroup("general", true, "sputnik.group.common.general"));
|
||||
@@ -72,21 +87,14 @@ public class Module {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
sgModule.addAll(bind, keyMode, notify, notifyMode);
|
||||
sgModule.addAll(bind, keyMode, notify, notifyMode, displayed, arraylistColor);
|
||||
}
|
||||
|
||||
public Module(String name, String description, Category category, int key) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
sgModule.addAll(bind, keyMode, notify, notifyMode);
|
||||
this(name, description, category);
|
||||
this.bind.setDefaultValue(key);
|
||||
|
||||
// puto marcos
|
||||
// la clave tiene que salir igual que en ConfigManager#getSettingKey, o sea con los
|
||||
// nombres internos: Module#getName ya lo es, pero en los ajustes el traducido es
|
||||
// getName() y el interno getTrueName(). si no cuadran no se encuentra la tecla
|
||||
// guardada y se le pisa al usuario con la de por defecto
|
||||
if (ConfigManager.INSTANCE.getConfig().settings
|
||||
.get(this.getName() + ":" + bind.getTrueName()) == null)
|
||||
this.bind.setValue(key);
|
||||
@@ -159,9 +167,9 @@ public class Module {
|
||||
}
|
||||
}
|
||||
|
||||
// onDisable no miraba notify.getValue(), así que avisaba aunque estuviera desactivado
|
||||
private void notifyToggle(boolean on) {
|
||||
if (!notify.getValue()) return;
|
||||
if (ConfigManager.INSTANCE != null && ConfigManager.INSTANCE.isApplying()) return;
|
||||
|
||||
String key = on ? "sputnik.module.toggled.on" : "sputnik.module.toggled.off";
|
||||
Component message = Component.translatable(key, getDisplayName());
|
||||
@@ -177,8 +185,6 @@ public class Module {
|
||||
|
||||
// getters y setters
|
||||
|
||||
// OJO: nombre interno. es la clave de la config. (moduleStates, getSettingKey, settingsPanels)
|
||||
// y no se traduce nunca. para mostrarlo al usuario usar getDisplayName()
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -253,6 +259,10 @@ public class Module {
|
||||
return bind;
|
||||
}
|
||||
|
||||
public boolean isVisible() { return displayed.getValue(); }
|
||||
|
||||
public Color getArraylistColor() { return arraylistColor.getValue(); }
|
||||
|
||||
public boolean isSearchMatch() {
|
||||
return searchMatch;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import me.retucio.sputnik.module.modules.inventory.*;
|
||||
import me.retucio.sputnik.module.modules.misc.*;
|
||||
import me.retucio.sputnik.module.modules.movement.*;
|
||||
import me.retucio.sputnik.module.modules.network.*;
|
||||
import me.retucio.sputnik.module.modules.network.PacketLogger;
|
||||
import me.retucio.sputnik.module.modules.player.*;
|
||||
import me.retucio.sputnik.module.modules.render.*;
|
||||
import me.retucio.sputnik.module.modules.render.CritsPlus;
|
||||
@@ -89,6 +90,8 @@ public class ModuleManager {
|
||||
add(new AttributeSwapper());
|
||||
add(new ChestplateSwitch());
|
||||
add(new CrystalAura());
|
||||
add(new HoldAttack());
|
||||
add(new KillAura());
|
||||
add(new MaceKill());
|
||||
add(new ProjectileTrajectories());
|
||||
add(new SpearKill());
|
||||
@@ -127,6 +130,7 @@ public class ModuleManager {
|
||||
add(new Headhitters());
|
||||
add(new HitboxDesync());
|
||||
add(new InfiniteElytra());
|
||||
add(new ItemMagnet());
|
||||
add(new Jesus());
|
||||
add(new Parkour());
|
||||
add(new ReverseStep());
|
||||
@@ -141,7 +145,9 @@ public class ModuleManager {
|
||||
private void addNetwork() {
|
||||
add(new BungeecordSpoofer());
|
||||
add(new LogoutSpots());
|
||||
add(new PacketCanceller());
|
||||
add(new PacketDelay());
|
||||
add(new PacketLogger());
|
||||
add(new PacketMine());
|
||||
add(new Reconnect());
|
||||
add(new RPackBypass());
|
||||
@@ -150,6 +156,7 @@ public class ModuleManager {
|
||||
private void addPlayer() {
|
||||
add(new AirPlace());
|
||||
add(new AntiHunger());
|
||||
add(new AutoEat());
|
||||
add(new AutoFish());
|
||||
add(new Capes());
|
||||
add(new FastUse());
|
||||
@@ -170,14 +177,17 @@ public class ModuleManager {
|
||||
add(new Fonts());
|
||||
add(new GlintPlus());
|
||||
add(new Hitboxes());
|
||||
add(new ItemPhysics());
|
||||
add(new Lsd());
|
||||
add(new Nametags());
|
||||
add(new NoRender());
|
||||
add(new Particles());
|
||||
add(new Stylish());
|
||||
add(new Tracers());
|
||||
}
|
||||
|
||||
private void addWorld() {
|
||||
add(new AutoMine());
|
||||
add(new AutoSign());
|
||||
add(new AutoTool());
|
||||
add(new BlockInfo());
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package me.retucio.sputnik.module.modules.camera;
|
||||
|
||||
import com.github.retucio.neutrino.EventListener;
|
||||
import me.retucio.sputnik.event.network.PacketEvent;
|
||||
import me.retucio.sputnik.module.Category;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import me.retucio.sputnik.module.setting.settings.EnumSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.NumberSetting;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import me.retucio.sputnik.util.RotationUtil;
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,18 +45,7 @@ public class Autism extends Module {
|
||||
if (direction.is(RotationDirection.COUNTERCLOCKWISE))
|
||||
yaw -= interval.getFloatValue();
|
||||
|
||||
mc.getConnection().send(new ServerboundMovePlayerPacket.Rot(
|
||||
yaw,
|
||||
mc.player.getXRot(),
|
||||
mc.player.onGround(),
|
||||
mc.player.horizontalCollision
|
||||
));
|
||||
}
|
||||
|
||||
@EventListener
|
||||
private void onPacketSend(PacketEvent.Send event) {
|
||||
if (event.getPacket() instanceof ServerboundMovePlayerPacket.Rot packet
|
||||
&& packet.getYRot(yaw) != yaw) event.cancel();
|
||||
RotationUtil.requestYaw(RotationUtil.HIGHEST, yaw, RotationUtil.Mode.SILENT);
|
||||
}
|
||||
|
||||
private enum RotationDirection {
|
||||
|
||||
@@ -177,15 +177,14 @@ public class Freecam extends Module {
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
// allChanged() ya no existe; ahora hay que pasarle el estado a mano
|
||||
private static void invalidateChunks() {
|
||||
if (mc.level == null) return;
|
||||
mc.levelRenderer.invalidateCompiledGeometry(mc.level, mc.options, mc.gameRenderer.mainCamera(), mc.getBlockColors());
|
||||
mc.levelExtractor.allChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (reloadChunks.getValue()) mc.execute(Freecam::invalidateChunks);
|
||||
if (reloadChunks.getValue()) invalidateChunks();
|
||||
|
||||
mc.options.setCameraType(perspective);
|
||||
crouching = false;
|
||||
@@ -359,8 +358,9 @@ public class Freecam extends Module {
|
||||
if (mc.player == null) return; // el jugador probablemente nunca sea nulo bajo estas circunstancias pero quién sabe
|
||||
|
||||
if (event.getPacket() instanceof ClientboundPlayerCombatKillPacket packet) {
|
||||
if (mc.player.getId() == packet.playerId())
|
||||
if (mc.player.getId() == packet.playerId()) {
|
||||
toggle();
|
||||
}
|
||||
} else if (event.getPacket() instanceof ClientboundSetHealthPacket packet) {
|
||||
if (mc.player.getHealth() - packet.getHealth() > 0 && toggleOnDamage.getValue()) {
|
||||
ChatUtil.info(Component.translatable("sputnik.module.freecam.damagedisable"));
|
||||
|
||||
@@ -6,6 +6,7 @@ import me.retucio.sputnik.module.Category;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import me.retucio.sputnik.module.setting.settings.BooleanSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.NumberSetting;
|
||||
import me.retucio.sputnik.util.RotationUtil;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
|
||||
/**
|
||||
@@ -30,8 +31,7 @@ public class Rotations extends Module {
|
||||
public void onTick() {
|
||||
if (mc.player == null) return;
|
||||
|
||||
mc.player.setYRot(yaw.getFloatValue());
|
||||
mc.player.setXRot(pitch.getFloatValue());
|
||||
RotationUtil.request(RotationUtil.HIGHEST, yaw.getFloatValue(), pitch.getFloatValue(), RotationUtil.Mode.CLIENT);
|
||||
|
||||
if (serverSide.getValue())
|
||||
mc.player.connection.send(
|
||||
|
||||
@@ -7,6 +7,7 @@ import me.retucio.sputnik.module.setting.settings.*;
|
||||
import me.retucio.sputnik.ui.hud.HudElement;
|
||||
import me.retucio.sputnik.ui.hud.HudRenderer;
|
||||
import me.retucio.sputnik.ui.hud.HudEditorScreen;
|
||||
import me.retucio.sputnik.ui.hud.elements.CustomImageElement;
|
||||
import me.retucio.sputnik.ui.hud.elements.DynoElement;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@@ -126,6 +127,19 @@ public class Hud extends Module {
|
||||
Dynosaurs.class, Dynosaurs.SPINOSAURUS
|
||||
));
|
||||
|
||||
public FileSetting customImagePath = sgElements.add(new FileSetting(
|
||||
"ruta de imagen",
|
||||
"ruta de la imagen a renderizar en el elemento de imagen custom",
|
||||
""
|
||||
));
|
||||
|
||||
public EnumSetting<SpeedUnits> speedUnit = sgElements.add(new EnumSetting<>(
|
||||
"velocidad",
|
||||
"unidad a usar para la velocidad",
|
||||
SpeedUnits.class,
|
||||
SpeedUnits.BPS
|
||||
));
|
||||
|
||||
public Hud() {
|
||||
super("HUD",
|
||||
"superposición de la pantalla con info. adicional",
|
||||
@@ -137,6 +151,11 @@ public class Hud extends Module {
|
||||
DynoElement element = (DynoElement) HudRenderer.INSTANCE.getElement(DynoElement.class);
|
||||
if (element != null) element.reloadTexture();
|
||||
});
|
||||
|
||||
customImagePath.onUpdate(v -> {
|
||||
CustomImageElement element = (CustomImageElement) HudRenderer.INSTANCE.getElement(CustomImageElement.class);
|
||||
if (element != null) element.reloadTexture();
|
||||
});
|
||||
}
|
||||
|
||||
public enum TimeFormat {
|
||||
@@ -171,4 +190,21 @@ public class Hud extends Module {
|
||||
@Override public String toString() { return name; }
|
||||
public String toRealString() { return super.toString(); }
|
||||
}
|
||||
|
||||
public enum SpeedUnits {
|
||||
BPT("bloques/tick", "b/t"),
|
||||
BPS("bloques/segundo", "b/s"),
|
||||
KBPH("kilobloques/hora", "kb/h");
|
||||
|
||||
private final String name;
|
||||
private final String symbol;
|
||||
|
||||
SpeedUnits(String name, String symbol) {
|
||||
this.name = name;
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
@Override public String toString() { return name; }
|
||||
public String getSymbol() { return symbol; }
|
||||
}
|
||||
}
|
||||
@@ -234,11 +234,22 @@ public class CrystalAura extends Module {
|
||||
|
||||
private void doBreak() {
|
||||
if (breakTimer > 0) return;
|
||||
|
||||
List<Entity> crystals = new ArrayList<>();
|
||||
for (Entity entity : mc.level.getEntities().getAll()) {
|
||||
if (!(entity instanceof EndCrystal) || entity.distanceTo(mc.player) > mc.player.entityInteractionRange()) continue;
|
||||
if (rotateToBreak.getValue()) EntityUtil.lookAt(entity.getEyePosition());
|
||||
mc.gameMode.attack(mc.player, entity);
|
||||
crystals.add(entity);
|
||||
}
|
||||
|
||||
if (!crystals.isEmpty()) {
|
||||
Runnable attack = () -> crystals.forEach(crystal -> mc.gameMode.attack(mc.player, crystal));
|
||||
|
||||
// solo se puede apuntar a uno, así que se rompen todos rotando solo al primero
|
||||
if (rotateToBreak.getValue())
|
||||
RotationUtil.lookAt(RotationUtil.HIGH, crystals.getFirst().getEyePosition(), attack);
|
||||
else attack.run();
|
||||
}
|
||||
|
||||
breakTimer = breakDelay.getIntValue();
|
||||
}
|
||||
|
||||
@@ -254,8 +265,11 @@ public class CrystalAura extends Module {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rotateToPlace.getValue()) EntityUtil.lookAt(Vec3.atCenterOf(result.getBlockPos()));
|
||||
mc.gameMode.startPrediction(mc.level, (sequence) -> new ServerboundUseItemOnPacket(hand, result, sequence));
|
||||
Runnable place = () -> mc.gameMode.startPrediction(mc.level, (sequence) -> new ServerboundUseItemOnPacket(hand, result, sequence));
|
||||
|
||||
if (rotateToPlace.getValue())
|
||||
RotationUtil.lookAt(RotationUtil.HIGH, Vec3.atCenterOf(result.getBlockPos()), place);
|
||||
else place.run();
|
||||
}
|
||||
|
||||
private void placeObby(BlockPos pos) {
|
||||
@@ -273,8 +287,11 @@ public class CrystalAura extends Module {
|
||||
BlockPos supportPos = pos.below();
|
||||
BlockHitResult result = new BlockHitResult(Vec3.atCenterOf(supportPos), Direction.UP, supportPos, false);
|
||||
|
||||
if (rotateToPlace.getValue()) EntityUtil.lookAt(Vec3.atCenterOf(pos));
|
||||
mc.gameMode.startPrediction(mc.level, (sequence) -> new ServerboundUseItemOnPacket(hand, result, sequence));
|
||||
Runnable place = () -> mc.gameMode.startPrediction(mc.level, (sequence) -> new ServerboundUseItemOnPacket(hand, result, sequence));
|
||||
|
||||
if (rotateToPlace.getValue())
|
||||
RotationUtil.lookAt(RotationUtil.HIGH, Vec3.atCenterOf(pos), place);
|
||||
else place.run();
|
||||
}
|
||||
|
||||
private void doAutoSelect(Item item) {
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package me.retucio.sputnik.module.modules.combat;
|
||||
|
||||
import me.retucio.sputnik.module.Category;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import me.retucio.sputnik.module.setting.settings.BooleanSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.EnumSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.NumberSetting;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
|
||||
|
||||
/**
|
||||
* @author retucio
|
||||
*/
|
||||
|
||||
public class HoldAttack extends Module {
|
||||
|
||||
private final EnumSetting<AttackMode> mode = sgGeneral.add(new EnumSetting<>(
|
||||
"modo de ataque",
|
||||
"cómo atacar",
|
||||
AttackMode.class,
|
||||
AttackMode.TIME
|
||||
));
|
||||
|
||||
private final NumberSetting timeCooldown = sgGeneral.add(new NumberSetting(
|
||||
"cooldown",
|
||||
"cómo de llena tiene que estar la barra de ataque antes de atacar",
|
||||
84.8f, 0.0f, 100.0f, 0.1f
|
||||
)).visibility(() -> mode.is(AttackMode.TIME));
|
||||
|
||||
private final NumberSetting spamCooldown = sgGeneral.add(new NumberSetting(
|
||||
"cooldown ",
|
||||
"cada cuánto atacar, en ticks",
|
||||
0, 0, 40, 1
|
||||
)).visibility(() -> mode.is(AttackMode.SPAM));
|
||||
|
||||
private final BooleanSetting attackInScreens = sgGeneral.add(new BooleanSetting(
|
||||
"atacar en pantallas",
|
||||
"atacar aun estando en una pantalla",
|
||||
false
|
||||
));
|
||||
|
||||
private int counter = 0;
|
||||
|
||||
public HoldAttack() {
|
||||
super("autoataque", "mantén pulsado el clic para atacar automáticamente", Category.COMBAT);
|
||||
mode.onUpdate(v -> counter = 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
counter = 0;
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
if (mc.player == null || mc.gameMode == null || mc.getCameraEntity() == null) return;
|
||||
|
||||
counter++;
|
||||
|
||||
if (mc.gui.screen() != null && !attackInScreens.getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mc.options.keyAttack.isDown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(mc.hitResult instanceof EntityHitResult ehr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode.is(AttackMode.TIME)) {
|
||||
if (mc.player.getAttackStrengthScale(0) < timeCooldown.getNormalizedValue()) {
|
||||
return;
|
||||
}
|
||||
} else if (mode.is(AttackMode.SPAM)) {
|
||||
if (counter < spamCooldown.getIntValue()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mc.gameMode.attack(mc.player, ehr.getEntity());
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
private enum AttackMode {
|
||||
SPAM("spamear"),
|
||||
TIME("timear");
|
||||
|
||||
private final String name;
|
||||
AttackMode(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package me.retucio.sputnik.module.modules.combat;
|
||||
|
||||
import me.retucio.sputnik.module.Category;
|
||||
import me.retucio.sputnik.module.Module;
|
||||
import me.retucio.sputnik.module.setting.SettingGroup;
|
||||
import me.retucio.sputnik.module.setting.settings.BooleanSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.EnumSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.ListSetting;
|
||||
import me.retucio.sputnik.module.setting.settings.NumberSetting;
|
||||
import me.retucio.sputnik.util.Lists;
|
||||
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
||||
|
||||
public class KillAura extends Module {
|
||||
|
||||
private final SettingGroup sgEntities = addSg(new SettingGroup("entidades", true));
|
||||
|
||||
private final NumberSetting reach = sgGeneral.add(new NumberSetting(
|
||||
"alcance", "qué tan lejos extender el brazo",
|
||||
3.0f, 0.1f, 64.0f, 0.1f
|
||||
));
|
||||
|
||||
private final EnumSetting<AttackMode> attackMode = sgGeneral.add(new EnumSetting<>(
|
||||
"modo de ataque", "elige de qué manera atacar",
|
||||
AttackMode.class, AttackMode.TIMED
|
||||
));
|
||||
|
||||
private final NumberSetting cooldownPercentage = sgGeneral.add(new NumberSetting(
|
||||
"porcentaje de cooldown", "cuánto esperar a que se llene la barrita de ataque",
|
||||
100, 0, 100, 1
|
||||
));
|
||||
|
||||
private final BooleanSetting swingHand = sgGeneral.add(new BooleanSetting(
|
||||
"mover la mano", "mover la mano al atacar",
|
||||
true
|
||||
));
|
||||
|
||||
private final EnumSetting<ListMode> listMode = sgEntities.add(new EnumSetting<>(
|
||||
"modo de lista", "cómo interpretar la lista",
|
||||
ListMode.class, ListMode.WHITELIST
|
||||
));
|
||||
|
||||
private final ListSetting<EntityType<? extends Entity>> whitelist = sgEntities.add(new ListSetting<>(
|
||||
"entidades", "qué entidades atacar",
|
||||
Lists.entityList, Lists.allFalse(Lists.entityList), Lists.entityNames
|
||||
)).visibility(() -> listMode.is(ListMode.WHITELIST));
|
||||
|
||||
private final ListSetting<EntityType<? extends Entity>> blacklist = sgEntities.add(new ListSetting<>(
|
||||
"entidades ", "qué entidades NO atacar",
|
||||
Lists.entityList, Lists.allFalse(Lists.entityList), Lists.entityNames
|
||||
)).visibility(() -> listMode.is(ListMode.BLACKLIST));
|
||||
|
||||
public KillAura() {
|
||||
super("killaura", "si la violencia no funciona, es porque no has aplicado la suficiente", Category.COMBAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
if (mc.player == null || mc.level == null) return;
|
||||
|
||||
Entity target = findClosestTarget();
|
||||
if (target != null) {
|
||||
attack(target);
|
||||
}
|
||||
}
|
||||
|
||||
private Entity findClosestTarget() {
|
||||
Entity closest = null;
|
||||
double closestDistSq = reach.getValue() * reach.getValue();
|
||||
|
||||
for (Entity entity : mc.level.getEntities().getAll()) {
|
||||
if (!shouldAttack(entity)) continue;
|
||||
|
||||
double distSq = entity.distanceToSqr(mc.player);
|
||||
if (distSq > closestDistSq) continue;
|
||||
|
||||
closest = entity;
|
||||
closestDistSq = distSq;
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
private void attack(Entity entity) {
|
||||
if (mc.player.getAttackStrengthScale(0) < cooldownPercentage.getNormalizedValue()
|
||||
&& attackMode.is(AttackMode.TIMED)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mc.level.isTickingEntity(entity)) return;
|
||||
|
||||
if (swingHand.getValue()) {
|
||||
mc.player.swing(InteractionHand.MAIN_HAND);
|
||||
}
|
||||
|
||||
mc.gameMode.attack(mc.player, entity);
|
||||
}
|
||||
|
||||
private boolean shouldAttack(Entity entity) {
|
||||
if (entity.is(mc.player)) return false;
|
||||
if (!entity.isAlive()) return false;
|
||||
if (entity.distanceToSqr(mc.player) > reach.getValue() * reach.getValue()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return switch (listMode.getValue()) {
|
||||
case WHITELIST -> whitelist.isEnabled(entity.getType());
|
||||
case BLACKLIST -> !blacklist.isEnabled(entity.getType());
|
||||
};
|
||||
}
|
||||
|
||||
private enum AttackMode {
|
||||
TIMED("timeado"),
|
||||
SPAM("spam");
|
||||
|
||||
private final String name;
|
||||
AttackMode(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
|
||||
private enum ListMode {
|
||||
WHITELIST("lista blanca (incluir)"),
|
||||
BLACKLIST("lista negra (excluir)");
|
||||
|
||||
private final String name;
|
||||
ListMode(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
|
||||
}
|
||||