Compare commits

...
7 Commits
Author SHA1 Message Date
retucio 44494830be v6.3 2026-09-04 12:58:41 +02:00
retucio 73682cb85d v6.2 2026-08-28 12:27:07 +02:00
retucio ac7de7a07a v6.1 2026-08-27 01:00:19 +02:00
retucio 0bd31971a0 v6.0 2026-08-23 16:50:27 +02:00
retucio 3010b164ab v5.9 2026-08-23 16:03:32 +02:00
retucio 6cb4656365 v5.8 2026-08-22 18:20:52 +02:00
retucio 272c1059ef v5.7 2026-08-19 22:57:41 +02:00
131 changed files with 5230 additions and 461 deletions

No files matched your search

+4 -4
View File
@@ -1,16 +1,16 @@
# jenny's mod 2 100% real # 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 ## instalación
### para gente normal: ### 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 2. selecionar la versión más reciente
3. descargar el .jar 3. descargar el .jar
4. moverlo a tu directorio de mods (probablemente `%appdata%/.minecraft/mods`) 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. 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 ### para frikis de 200 de iq
@@ -56,7 +56,7 @@ algunos módulos tienen teclas asignadas por defecto, asígnales `ESC` para desa
<img src="screenshots/hudeditor.png" alt="editor de HUD"> <img src="screenshots/hudeditor.png" alt="editor de HUD">
<img src="screenshots/colorpicker.png" alt="selector de colores"> <img src="screenshots/colorpicker.png" alt="selector de colores">
## contibuciones ## contribuciones
sí por favor sí por favor
+8 -16
View File
@@ -1,29 +1,21 @@
# v5.5 # v6.3
## novedades ## novedades
- actualizado a Gradle 9.7.1
### adiciones ### adiciones
#### módulos nuevos: #### módulos nuevos:
- autoataque: mantén el botón de ataque pulsado para atacar automáticamente - autominado: mina automáticamente los bloques seleccionados, con distintos modos de selección
- estiloso: haz truquitos con el ítem que tienes en la mano
#### comandos nuevos:
### arreglos / mejoras ### arreglos / mejoras
- arreglado el guardado al cerrar el juego: petaba antes de escribir nada, así que se perdía - mejoras varias a `puto gordo`
todo lo cambiado desde el último autoguardado y al volver a entrar salían los ajustes por defecto - ahora `trazos` con `uno mismo` solo te apunta en cámara libre
- el autoguardado cuenta desde el último guardado y no desde el último cambio, que tocando - nuevo ajuste de distancia máxima de renderizado para `nametags`
ajustes seguido no llegaba a guardar nunca
- guardando dos veces seguidas ya no se descarta la segunda (era la más reciente)
- las teclas de los módulos ya no se pisan entre ellas al cargar la config.
- si algo falla al aplicar los ajustes ya no se queda el mod entero sin guardar
- las listas (entidades, ítems, bloques...) se traducen al idioma del juego en vez de salir
siempre en inglés, y se guardan por nombre interno para que no dependan del idioma
- traducidos los títulos de los marcos, las descripciones de los módulos y los mensajes del
arranque, que salían en español o directamente como la clave de traducción
- añadidas las traducciones que faltaban del autoataque
## problemas reconocidos ## problemas reconocidos
+1 -1
View File
@@ -10,6 +10,6 @@ discord_rpc_version=1.0.3
neutrino_version=1.1.0 neutrino_version=1.1.0
jdk_version=25 jdk_version=25
mod_version=5.6 mod_version=6.3
maven_group=me.retucio maven_group=me.retucio
archives_base_name=sputnik archives_base_name=sputnik
+2 -3
View File
@@ -1,7 +1,6 @@
#Sat Aug 29 22:10:52 CEST 2026
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
View File
Whitespace-only changes.
+18 -2
View File
@@ -7,6 +7,8 @@ import me.retucio.sputnik.command.CommandManager;
import me.retucio.sputnik.command.commands.BindCommand; import me.retucio.sputnik.command.commands.BindCommand;
import me.retucio.sputnik.config.ConfigManager; 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.ShutdownEvent;
import me.retucio.sputnik.event.interact.OpenScreenEvent; 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.ModuleManager;
import me.retucio.sputnik.module.modules.client.Hud; 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.hud.HudRenderer;
import me.retucio.sputnik.ui.screen.ClickGui; import me.retucio.sputnik.ui.screen.ClickGui;
import me.retucio.sputnik.ui.hud.HudEditorScreen; import me.retucio.sputnik.ui.hud.HudEditorScreen;
import me.retucio.sputnik.ui.screen.UpdateScreen; import me.retucio.sputnik.ui.screen.UpdateScreen;
import me.retucio.sputnik.ui.widgets.buttons.settings.BindButton; import me.retucio.sputnik.ui.widgets.buttons.settings.BindButton;
import me.retucio.sputnik.ui.widgets.buttons.SettingButton; 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.buttons.settings.TextButton;
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel; import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
import me.retucio.sputnik.ui.widgets.panels.SettingsPanel; 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(MiscUtil.class);
EVENT_BUS.subscribe(NetworkUtil.class); EVENT_BUS.subscribe(NetworkUtil.class);
EVENT_BUS.subscribe(RenderUtil.class); EVENT_BUS.subscribe(RenderUtil.class);
EVENT_BUS.subscribe(RotationUtil.class);
EVENT_BUS.subscribe(BlockIterator.class); EVENT_BUS.subscribe(BlockIterator.class);
Lists.init(); Lists.init();
HudRenderer.INSTANCE = new HudRenderer(); HudRenderer.INSTANCE = new HudRenderer();
HudEditor.INSTANCE = new HudEditor();
MacroManager.INSTANCE = new MacroManager();
ProfileManager.INSTANCE = new ProfileManager();
CapeManager.INSTANCE = new CapeManager(); CapeManager.INSTANCE = new CapeManager();
EVENT_BUS.post(new LoadCapeManagerEvent()); EVENT_BUS.post(new LoadCapeManagerEvent());
@@ -151,11 +160,12 @@ public class Sputnik implements ClientModInitializer {
// prevenir interrumpir combos de F3 // prevenir interrumpir combos de F3
if (key == GLFW.GLFW_KEY_F3) return; if (key == GLFW.GLFW_KEY_F3) return;
boolean anyFocused = isAnySettingButtonFocused() || ClickGui.INSTANCE.getSearchBar().isFocused(); boolean anyFocused = isAnySettingButtonFocused() || ClickGui.INSTANCE.isCapturingInput();
ClickGui.INSTANCE.setAnyFocused(anyFocused); ClickGui.INSTANCE.setAnyFocused(anyFocused);
if (action != GLFW.GLFW_RELEASE) { if (action != GLFW.GLFW_RELEASE) {
if (BindCommand.onKeyPress(key)) return; if (BindCommand.onKeyPress(key)) return;
if (action == GLFW.GLFW_PRESS && MacroManager.INSTANCE.onKeyPress(key)) return;
if (action == GLFW.GLFW_PRESS) { if (action == GLFW.GLFW_PRESS) {
handleModuleToggle(key, anyFocused); handleModuleToggle(key, anyFocused);
handleClickGuiKey(key, anyFocused); handleClickGuiKey(key, anyFocused);
@@ -172,10 +182,15 @@ public class Sputnik implements ClientModInitializer {
// verifica si algún botón de ajustes está escuchando // verifica si algún botón de ajustes está escuchando
private boolean isAnySettingButtonFocused() { private boolean isAnySettingButtonFocused() {
if (ClickGui.INSTANCE == null) return false;
for (SettingsPanel sf : ClickGui.INSTANCE.getSettingsPanels()) for (SettingsPanel sf : ClickGui.INSTANCE.getSettingsPanels())
for (Button sb : sf.getButtons()) 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 true;
}
return false; return false;
} }
@@ -199,6 +214,7 @@ public class Sputnik implements ClientModInitializer {
for (SettingsPanel sf : ClickGui.INSTANCE.getSettingsPanels()) { for (SettingsPanel sf : ClickGui.INSTANCE.getSettingsPanels()) {
for (SettingButton<?> sb : sf.getButtons()) { for (SettingButton<?> sb : sf.getButtons()) {
if (sb instanceof BindButton bb) bb.onKey(key, action); 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); if (sb instanceof TextButton tb) tb.onKey(key, action);
} }
} }
@@ -9,6 +9,7 @@ import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.data.registries.VanillaRegistries;
import net.minecraft.network.chat.Component;
import java.util.List; import java.util.List;
@@ -20,12 +21,14 @@ public abstract class Command {
protected static final Minecraft mc = Minecraft.getInstance(); protected static final Minecraft mc = Minecraft.getInstance();
private final String name, description; private final String name, descriptionKey;
private final List<String> aliases; 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.name = name;
this.description = description; this.descriptionKey = descriptionKey;
this.aliases = List.of(aliases); this.aliases = List.of(aliases);
} }
@@ -56,8 +59,12 @@ public abstract class Command {
return name; return name;
} }
public String getDescription() { public String getDescriptionKey() {
return description; return descriptionKey;
}
public Component getDescription() {
return Component.translatable(descriptionKey);
} }
public List<String> getAliases() { public List<String> getAliases() {
@@ -38,10 +38,13 @@ public class CommandManager {
addCommand(new EnderChestCommand()); addCommand(new EnderChestCommand());
addCommand(new FriendCommand()); addCommand(new FriendCommand());
addCommand(new GarbageCleanerCommand()); addCommand(new GarbageCleanerCommand());
addCommand(new HelpCommand());
addCommand(new MacroCommand());
addCommand(new PanoramaCommand()); addCommand(new PanoramaCommand());
addCommand(new PeekCommand()); addCommand(new PeekCommand());
addCommand(new PluginsCommand()); addCommand(new PluginsCommand());
addCommand(new PrefixCommand()); addCommand(new PrefixCommand());
addCommand(new ProfileCommand());
addCommand(new PurgeCommand()); addCommand(new PurgeCommand());
addCommand(new RepeatCommand()); addCommand(new RepeatCommand());
addCommand(new RepeatWaitCommand()); addCommand(new RepeatWaitCommand());
@@ -24,7 +24,7 @@ public class BindCommand extends Command {
private static Module listeningModule = null; private static Module listeningModule = null;
public BindCommand() { public BindCommand() {
super("bind", Component.translatable("sputnik.commands.bind.desc").getString(), "keybind", "kb", "tecla"); super("bind", "sputnik.commands.bind.desc", "keybind", "kb", "tecla");
} }
@Override @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.Screen;
import net.minecraft.client.gui.screens.inventory.ContainerScreen; import net.minecraft.client.gui.screens.inventory.ContainerScreen;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
import net.minecraft.world.inventory.ContainerInput; 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& // 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 class ClickSlotCommand extends Command {
public ClickSlotCommand() { 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) { 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 me.retucio.sputnik.ui.widgets.panels.SettingsPanel;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import net.minecraft.network.chat.Component;
public class ConfigCommand extends Command { public class ConfigCommand extends Command {
public ConfigCommand() { public ConfigCommand() {
super("config", Component.translatable("sputnik.commands.config.desc").getString(), "ajustes", "settings"); super("config", "sputnik.commands.config.desc", "ajustes", "settings");
} }
@Override @Override
@@ -5,13 +5,12 @@ import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus; import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
import net.minecraft.commands.SharedSuggestionProvider; 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 // se usa principalmente para el módulo ScreenshotPlus, pero también se puede usar sin él supongo
public class CopyScreenshotCommand extends Command { public class CopyScreenshotCommand extends Command {
public CopyScreenshotCommand() { public CopyScreenshotCommand() {
super("copiarcaptura", Component.translatable("sputnik.commands.copyscreenshot.desc").getString(), "copyscreenshot"); super("copiarcaptura", "sputnik.commands.copyscreenshot.desc", "copyscreenshot");
} }
@Override @Override
@@ -16,7 +16,7 @@ public class EnderChestCommand extends Command {
private boolean shouldOpenEchest = false; private boolean shouldOpenEchest = false;
public EnderChestCommand() { public EnderChestCommand() {
super("echest", Component.translatable("sputnik.commands.echest.desc").getString(), "ec", "enderchest"); super("echest", "sputnik.commands.echest.desc", "ec", "enderchest");
} }
@Override @Override
@@ -15,7 +15,7 @@ import net.minecraft.world.entity.player.Player;
public class FriendCommand extends Command { public class FriendCommand extends Command {
public FriendCommand() { public FriendCommand() {
super("friend", Component.translatable("sputnik.commands.friend.desc").getString(), "amigo", "f"); super("friend", "sputnik.commands.friend.desc", "amigo", "f");
} }
@Override @Override
@@ -9,12 +9,12 @@ import net.minecraft.network.chat.Component;
public class GarbageCleanerCommand extends Command { public class GarbageCleanerCommand extends Command {
public GarbageCleanerCommand() { public GarbageCleanerCommand() {
super("gc", Component.translatable("sputnik.commands.gc.desc").getString(), "garbagecollect"); super("gc", "sputnik.commands.gc.desc", "garbagecollect");
} }
@Override @Override
public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.executes(context -> { builder.executes(ctx -> {
System.gc(); System.gc();
ChatUtil.info(Component.translatable("sputnik.commands.gc.collected")); ChatUtil.info(Component.translatable("sputnik.commands.gc.collected"));
return SUCCESS; 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());
}
}
@@ -57,7 +57,7 @@ public class PanoramaCommand extends Command {
@Nullable Path dir = null; @Nullable Path dir = null;
public PanoramaCommand() { public PanoramaCommand() {
super("panorama", Component.translatable("sputnik.commands.panorama.desc").getString()); super("panorama", "sputnik.commands.panorama.desc");
} }
private void takeScreenshot() { private void takeScreenshot() {
@@ -6,7 +6,6 @@ import me.retucio.sputnik.command.args.PlayerArgumentType;
import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.MiscUtil;
import net.minecraft.client.gui.screens.inventory.InventoryScreen; import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
import java.awt.*; import java.awt.*;
@@ -14,7 +13,7 @@ import java.awt.*;
public class PeekCommand extends Command { public class PeekCommand extends Command {
public PeekCommand() { public PeekCommand() {
super("inventario", Component.translatable("sputnik.commands.peek.desc").getString(), "invsee", "peek", "inv"); super("inventario", "sputnik.commands.peek.desc", "invsee", "peek", "inv");
} }
@Override @Override
@@ -24,7 +24,7 @@ public class PluginsCommand extends Command {
private boolean scanning = false; private boolean scanning = false;
public PluginsCommand() { 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); Sputnik.EVENT_BUS.subscribe(this);
} }
@@ -13,7 +13,7 @@ import net.minecraft.network.chat.Component;
public class PrefixCommand extends Command { public class PrefixCommand extends Command {
public PrefixCommand() { public PrefixCommand() {
super("prefijo", Component.translatable("sputnik.commands.prefix.desc").getString(), "prefix"); super("prefijo", "sputnik.commands.prefix.desc", "prefix");
} }
@Override @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.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; 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.gui.components.ChatComponent;
import net.minecraft.client.multiplayer.chat.GuiMessage; import net.minecraft.client.multiplayer.chat.GuiMessage;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
import java.awt.*;
import java.util.List; import java.util.List;
public class PurgeCommand extends Command { public class PurgeCommand extends Command {
public PurgeCommand() { public PurgeCommand() {
super("purgar", Component.translatable("sputnik.commands.purge.desc").getString(), "purge"); super("purgar", "sputnik.commands.purge.desc", "purge");
} }
@Override @Override
@@ -6,12 +6,11 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
public class RepeatCommand extends Command { public class RepeatCommand extends Command {
public RepeatCommand() { public RepeatCommand() {
super("repetir", Component.translatable("sputnik.commands.repeat.desc").getString(), "repeat"); super("repetir", "sputnik.commands.repeat.desc", "repeat");
} }
@Override @Override
@@ -6,7 +6,6 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -14,7 +13,7 @@ import java.util.concurrent.TimeUnit;
public class RepeatWaitCommand extends Command { public class RepeatWaitCommand extends Command {
public RepeatWaitCommand() { public RepeatWaitCommand() {
super("repesperar", Component.translatable("sputnik.commands.repeatwait.desc").getString(), "repeatwait"); super("repesperar", "sputnik.commands.repeatwait.desc", "repeatwait");
} }
@Override @Override
@@ -14,7 +14,7 @@ import java.io.IOException;
public class SaveScreenshotCommand extends Command { public class SaveScreenshotCommand extends Command {
public SaveScreenshotCommand() { public SaveScreenshotCommand() {
super("guardarcaptura", Component.translatable("sputnik.commands.savescreenshot.desc").getString(), "savescreenshot"); super("guardarcaptura", "sputnik.commands.savescreenshot.desc", "savescreenshot");
} }
@Override @Override
@@ -6,7 +6,6 @@ import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.mixin.accessors.ClientPacketListenerAccessor; import me.retucio.sputnik.mixin.accessors.ClientPacketListenerAccessor;
import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.LastSeenMessagesTracker; import net.minecraft.network.chat.LastSeenMessagesTracker;
import net.minecraft.network.chat.MessageSignature; import net.minecraft.network.chat.MessageSignature;
import net.minecraft.network.chat.SignedMessageBody; import net.minecraft.network.chat.SignedMessageBody;
@@ -19,7 +18,7 @@ import java.time.Instant;
public class SendCommand extends Command { public class SendCommand extends Command {
public SendCommand() { public SendCommand() {
super("enviar", Component.translatable("sputnik.commands.send.desc").getString(), "send"); super("enviar", "sputnik.commands.send.desc", "send");
} }
@Override @Override
@@ -7,7 +7,6 @@ import me.retucio.sputnik.command.args.EntityArgumentType;
import me.retucio.sputnik.event.input.KeyEvent; import me.retucio.sputnik.event.input.KeyEvent;
import me.retucio.sputnik.util.EntityUtil; import me.retucio.sputnik.util.EntityUtil;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
@@ -16,7 +15,7 @@ import java.awt.*;
public class SpectateCommand extends Command { public class SpectateCommand extends Command {
public SpectateCommand() { public SpectateCommand() {
super("espectar", Component.translatable("sputnik.commands.spectate.desc").getString(), "spectate", "spec"); super("espectar", "sputnik.commands.spectate.desc", "spectate", "spec");
} }
@Override @Override
@@ -6,7 +6,6 @@ import me.retucio.sputnik.command.args.ModuleArgumentType;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
import java.awt.*; import java.awt.*;
@@ -14,7 +13,7 @@ import java.awt.*;
public class ToggleCommand extends Command { public class ToggleCommand extends Command {
public ToggleCommand() { public ToggleCommand() {
super("alternar", Component.translatable("sputnik.commands.toggle.desc").getString(), "toggle"); super("alternar", "sputnik.commands.toggle.desc", "toggle");
} }
@Override @Override
@@ -6,7 +6,6 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -17,7 +16,7 @@ public class WaitCommand extends Command {
private static final ScheduledExecutorService DELAYED_EXECUTOR = new ScheduledThreadPoolExecutor(2); private static final ScheduledExecutorService DELAYED_EXECUTOR = new ScheduledThreadPoolExecutor(2);
public WaitCommand() { public WaitCommand() {
super("wait", Component.translatable("sputnik.commands.wait.desc").getString(), "esperar", "sleep", "delay"); super("wait", "sputnik.commands.wait.desc", "esperar", "sleep", "delay");
} }
@Override @Override
@@ -14,7 +14,8 @@ import java.util.Map;
public class BinarySerializer { public class BinarySerializer {
private static final int MAGIC_NUMBER = 0x53505554; // "SPUT" 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_NULL = 0;
private static final byte TYPE_BOOLEAN = 1; private static final byte TYPE_BOOLEAN = 1;
@@ -72,6 +73,8 @@ public class BinarySerializer {
writeStringBooleanMap(out, config.hudVisibilities); writeStringBooleanMap(out, config.hudVisibilities);
writeStringStringMap(out, config.hudImagePaths); writeStringStringMap(out, config.hudImagePaths);
writeStringStringMap(out, config.friends); writeStringStringMap(out, config.friends);
writeMacros(out, config.macros);
writeString(out, config.currentProfile);
if (config.searchBarPosition != null) { if (config.searchBarPosition != null) {
out.writeBoolean(true); out.writeBoolean(true);
@@ -104,9 +107,8 @@ public class BinarySerializer {
"formato de archivo inválido: %s", magic)); "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(); int version = in.readInt();
if (version != VERSION) { if (version < MIN_VERSION || version > VERSION) {
throw new IOException(I18nUtil.fmt("sputnik.config.error.invalidversion", throw new IOException(I18nUtil.fmt("sputnik.config.error.invalidversion",
"versión inválida: %s", version)); "versión inválida: %s", version));
} }
@@ -123,6 +125,9 @@ public class BinarySerializer {
Map<String, String> hudImagePaths = readStringStringMap(in); Map<String, String> hudImagePaths = readStringStringMap(in);
Map<String, String> friends = readStringStringMap(in); Map<String, String> 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 // leer pos. de la barra de búsqueda
int[] searchBarPosition = in.readBoolean() int[] searchBarPosition = in.readBoolean()
? new int[]{in.readInt(), in.readInt()} ? new int[]{in.readInt(), in.readInt()}
@@ -137,6 +142,8 @@ public class BinarySerializer {
config.hudVisibilities = hudVisibilities; config.hudVisibilities = hudVisibilities;
config.hudImagePaths = hudImagePaths; config.hudImagePaths = hudImagePaths;
config.friends = friends; config.friends = friends;
config.macros = macros;
config.currentProfile = currentProfile == null ? "" : currentProfile;
if (searchBarPosition != null) config.searchBarPosition = searchBarPosition; if (searchBarPosition != null) config.searchBarPosition = searchBarPosition;
return config; return config;
@@ -386,6 +393,35 @@ public class BinarySerializer {
return map; 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 { private static void writeString(DataOutputStream out, String str) throws IOException {
if (str == null) { if (str == null) {
out.writeInt(-1); out.writeInt(-1);
@@ -47,19 +47,31 @@ public class ClientConfig {
// amigos: uuid -> nombre // amigos: uuid -> nombre
public Map<String, String> friends = new HashMap<>(); 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() { public ClientConfig() {
EVENT_BUS.subscribe(this); 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 @EventListener
public void onToggleModule(ToggleModuleEvent event) { public void onToggleModule(ToggleModuleEvent event) {
if (isApplying()) return;
ConfigManager.INSTANCE.setModuleState(event.getModule()); ConfigManager.INSTANCE.setModuleState(event.getModule());
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@EventListener @EventListener
public void onUpdateSetting(UpdateSettingEvent event) { 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" // guardar ajustes con su respectivo tipo de valor, en formato "nombreMódulo:nombreAjuste"
Object value = null; Object value = null;
@@ -72,6 +84,7 @@ public class ClientConfig {
case ListSetting l: value = l.getConfigValues(); break; case ListSetting l: value = l.getConfigValues(); break;
case ColorSetting c: value = c.getConfigValue(); break; case ColorSetting c: value = c.getConfigValue(); break;
case OptionSetting o: value = o.getConfigName(); break; case OptionSetting o: value = o.getConfigName(); break;
case FileSetting f: value = f.getValue(); break;
default: break; default: break;
} }
@@ -153,6 +166,7 @@ public class ClientConfig {
@EventListener @EventListener
public void onAddFriend(FriendEvent.Add event) { public void onAddFriend(FriendEvent.Add event) {
if (isApplying()) return;
String uuid = event.getFriend().getUuid().toString(); String uuid = event.getFriend().getUuid().toString();
String name = event.getFriend().getName(); String name = event.getFriend().getName();
if (!friends.containsKey(uuid)) { if (!friends.containsKey(uuid)) {
@@ -163,6 +177,7 @@ public class ClientConfig {
@EventListener @EventListener
public void onRemoveFriend(FriendEvent.Remove event) { public void onRemoveFriend(FriendEvent.Remove event) {
if (isApplying()) return;
friends.remove(event.getFriend().getUuid().toString()); friends.remove(event.getFriend().getUuid().toString());
ConfigManager.INSTANCE.markDirty(); ConfigManager.INSTANCE.markDirty();
} }
@@ -170,4 +185,8 @@ public class ClientConfig {
public record PanelData(int x, int y, boolean extended) implements Serializable { public record PanelData(int x, int y, boolean extended) implements Serializable {
@Serial private static final long serialVersionUID = 1L; @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.Module;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.client.ClientSettingsModule; 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.*;
import me.retucio.sputnik.module.setting.settings.*; 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.HudRenderer;
import me.retucio.sputnik.ui.widgets.Panel; import me.retucio.sputnik.ui.widgets.Panel;
import me.retucio.sputnik.ui.widgets.panels.ExtendablePanel; import me.retucio.sputnik.ui.widgets.panels.ExtendablePanel;
@@ -25,7 +28,9 @@ import net.minecraft.network.chat.Component;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@@ -183,6 +188,8 @@ public class ConfigManager {
applySearchBarPosition(); applySearchBarPosition();
applyExtendablePanels(); applyExtendablePanels();
applyFriends(); applyFriends();
applyMacros();
applyHudElements();
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.applied", "ajustes aplicados")); Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.applied", "ajustes aplicados"));
} catch (Exception e) { } catch (Exception e) {
@@ -199,11 +206,44 @@ public class ConfigManager {
} }
// true mientras se está cargando la config. sobre los ajustes. lo mira KeySetting para no // 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 // 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() { public boolean isApplying() {
return applying; 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();
}
// 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();
for (Module module : ModuleManager.INSTANCE.getModules()) {
module.setEnabled(false);
module.getSettings().forEach(Setting::reset);
}
ClientSettingsPanel.clientSettings.getSettings().forEach(Setting::reset);
for (Friend friend : new ArrayList<>(FriendManager.INSTANCE.getFriends()))
FriendManager.INSTANCE.remove(friend);
MacroManager.INSTANCE.setMacros(List.of());
}
// obtener configuración actual // obtener configuración actual
public ClientConfig getConfig() { public ClientConfig getConfig() {
ensureConfig(); ensureConfig();
@@ -258,6 +298,20 @@ public class ConfigManager {
markDirty(); 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 ------------------ // ------------------ APLICAR AJUSTES ------------------
@@ -271,6 +325,26 @@ public class ConfigManager {
"amigos aplicados")); "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"}) @SuppressWarnings({"rawtypes", "unchecked"})
public void applySetting(Setting<?> setting) { public void applySetting(Setting<?> setting) {
String key = getSettingKey(setting); String key = getSettingKey(setting);
@@ -288,6 +362,7 @@ public class ConfigManager {
case ListSetting listSetting -> applyListSetting(listSetting, value); case ListSetting listSetting -> applyListSetting(listSetting, value);
case ColorSetting colorSetting -> applyColorSetting(colorSetting, value); case ColorSetting colorSetting -> applyColorSetting(colorSetting, value);
case OptionSetting optionSetting -> applyOptionSetting(optionSetting, value); case OptionSetting optionSetting -> applyOptionSetting(optionSetting, value);
case FileSetting fileSetting -> applyFileSetting(fileSetting, value);
default -> Sputnik.LOGGER.warn(I18nUtil.fmt("sputnik.config.warn.unknownsetting", default -> Sputnik.LOGGER.warn(I18nUtil.fmt("sputnik.config.warn.unknownsetting",
"watafac queseso: %s", setting.getClass().getSimpleName())); "watafac queseso: %s", setting.getClass().getSimpleName()));
} }
@@ -403,8 +478,8 @@ public class ConfigManager {
} }
private static void applyStringSetting(StringSetting setting, Object value) { private static void applyStringSetting(StringSetting setting, Object value) {
if (value instanceof String) { if (value instanceof String v) {
setting.setValue((String) value); setting.setValue(v);
} }
} }
@@ -465,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) { private static <T> void applyOptionalProperty(Map<?, ?> map, String key, Class<T> type, Consumer<T> setter) {
Object value = map.get(key); Object value = map.get(key);
if (type.isInstance(value)) { if (type.isInstance(value)) {
@@ -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.BoatFly;
import me.retucio.sputnik.module.modules.movement.Velocity; import me.retucio.sputnik.module.modules.movement.Velocity;
import me.retucio.sputnik.module.modules.render.Nametags; import me.retucio.sputnik.module.modules.render.Nametags;
import me.retucio.sputnik.util.interfaces.IVec3;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; 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.projectile.arrow.AbstractArrow;
import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
import net.minecraft.world.phys.HitResult; 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.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
@@ -8,8 +8,10 @@ import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; 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.At;
import org.spongepowered.asm.mixin.injection.Inject; 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.CallbackInfo;
@@ -31,7 +33,7 @@ public abstract class EntityRendererMixin {
@ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getTeamColor()I")) @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) { 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; return original;
} }
} }
@@ -5,10 +5,10 @@ import me.retucio.sputnik.event.network.ReceiveMessageEvent;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ChatPlus; import me.retucio.sputnik.module.modules.misc.ChatPlus;
import me.retucio.sputnik.util.interfaces.IChatComponent; import me.retucio.sputnik.mixinterfaces.IChatComponent;
import me.retucio.sputnik.util.interfaces.IGuiMessage; import me.retucio.sputnik.mixinterfaces.IGuiMessage;
import me.retucio.sputnik.util.interfaces.IGuiMessageLine; import me.retucio.sputnik.mixinterfaces.IGuiMessageLine;
import me.retucio.sputnik.util.interfaces.IChatListener; import me.retucio.sputnik.mixinterfaces.IChatListener;
import net.minecraft.client.gui.components.ChatComponent; import net.minecraft.client.gui.components.ChatComponent;
import net.minecraft.client.multiplayer.chat.GuiMessage; import net.minecraft.client.multiplayer.chat.GuiMessage;
@@ -1,7 +1,7 @@
package me.retucio.sputnik.mixin.mixins.hud; package me.retucio.sputnik.mixin.mixins.hud;
import com.mojang.authlib.GameProfile; 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.client.multiplayer.chat.GuiMessage;
import net.minecraft.util.FormattedCharSequence; import net.minecraft.util.FormattedCharSequence;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@@ -1,7 +1,7 @@
package me.retucio.sputnik.mixin.mixins.hud; package me.retucio.sputnik.mixin.mixins.hud;
import com.mojang.authlib.GameProfile; 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.client.multiplayer.chat.GuiMessage;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
@@ -84,7 +84,7 @@ public abstract class HudMixin {
// dangerous abbreviation // dangerous abbreviation
CrosshairPlus cp = ModuleManager.INSTANCE.getModuleByClass(CrosshairPlus.class); 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 w = cp.isEnabled() ? cp.width.getIntValue() : width;
int h = cp.isEnabled() ? cp.height.getIntValue() : height; int h = cp.isEnabled() ? cp.height.getIntValue() : height;
@@ -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 com.llamalad7.mixinextras.sugar.Local;
import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.event.network.JoinWorldEvent; 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.ShutdownEvent;
import me.retucio.sputnik.event.TickEvent; import me.retucio.sputnik.event.TickEvent;
import me.retucio.sputnik.event.interact.UseItemEvent; import me.retucio.sputnik.event.interact.UseItemEvent;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.camera.Freecam;
import me.retucio.sputnik.module.modules.player.FastUse; 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.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; 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; 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 net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -1,7 +1,7 @@
package me.retucio.sputnik.mixin.mixins.network; package me.retucio.sputnik.mixin.mixins.network;
import com.mojang.authlib.GameProfile; 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.client.multiplayer.chat.ChatListener;
import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component; 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.mixin.accessors.PendingRequestAccessor;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.network.RPackBypass; 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.Minecraft;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl; 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") @ModifyVariable(method = "showHitboxes", at = @At("STORE"), name = "mainColor")
private int modifyHitboxColor(int original) { private int modifyHitboxColor(int original) {
Hitboxes hitboxes = ModuleManager.INSTANCE.getModuleByClass(Hitboxes.class); Hitboxes hitboxes = ModuleManager.INSTANCE.getModuleByClass(Hitboxes.class);
if (hitboxes.isEnabled()) return hitboxes.color.getRGB(); if (hitboxes.isEnabled()) return hitboxes.color.getRgb();
return original; 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;
}
}
@@ -8,7 +8,6 @@ import me.retucio.sputnik.module.modules.camera.Freecam;
import me.retucio.sputnik.module.modules.render.Nametags; import me.retucio.sputnik.module.modules.render.Nametags;
import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; 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.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 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")) @ModifyReturnValue(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At("RETURN"))
private boolean shouldRenderPlayerNametag(boolean original, @Local(argsOnly = true) T livingEntity) { private boolean shouldRenderPlayerNametag(boolean original, @Local(argsOnly = true, name = "entity") T entity) {
if (nametags.isEnabled() && livingEntity instanceof Player) if (nametags.isEnabled() && entity instanceof Player)
return nametags.entities.isEnabled(EntityTypes.PLAYER) && original; return nametags.entities.isEnabled(EntityTypes.PLAYER) && original;
return original; return original;
} }
@Inject(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At("RETURN"), cancellable = true) @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) { private void renderSelfNametag(T entity, double distanceToCameraSq, CallbackInfoReturnable<Boolean> cir) {
if (livingEntity instanceof Player player) { if (entity instanceof Player player) {
if (player == mc.player && nametags.showSelf.getValue()) { if (player == mc.player && nametags.showSelf.getValue()) {
cir.setReturnValue(true); cir.setReturnValue(true);
cir.cancel(); 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.ModuleManager;
import me.retucio.sputnik.module.modules.network.RPackBypass; 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.components.Button;
import net.minecraft.client.gui.layouts.LinearLayout; import net.minecraft.client.gui.layouts.LinearLayout;
@@ -33,7 +33,7 @@ public class ScreenMixin {
if (watermark == null || watermark.isEmpty()) return; if (watermark == null || watermark.isEmpty()) return;
gui.text(mc.font, watermark, gui.text(mc.font, watermark,
mc.getWindow().getGuiScaledWidth() - mc.font.width(watermark) - 2, 2, 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.client.multiplayer.chat.GuiMessage;
import net.minecraft.network.chat.Component; 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; import com.mojang.authlib.GameProfile;
@@ -1,4 +1,4 @@
package me.retucio.sputnik.util.interfaces; package me.retucio.sputnik.mixinterfaces;
public interface IConfirmScreen { 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; 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 { 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 net.minecraft.core.Vec3i;
import org.joml.Vector3d; import org.joml.Vector3d;
@@ -1,6 +1,6 @@
/* code by meteorclient dev team */ /* 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.Component;
import net.minecraft.network.chat.Style; 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.event.sputnik.ToggleModuleEvent;
import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.SettingGroup;
import me.retucio.sputnik.module.setting.settings.BooleanSetting; 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.EnumSetting;
import me.retucio.sputnik.module.setting.settings.KeySetting; import me.retucio.sputnik.module.setting.settings.KeySetting;
import me.retucio.sputnik.module.setting.Setting; import me.retucio.sputnik.module.setting.Setting;
import me.retucio.sputnik.ui.hud.HudRenderer; import me.retucio.sputnik.ui.hud.HudRenderer;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import me.retucio.sputnik.util.Colors;
import me.retucio.sputnik.util.I18nUtil; import me.retucio.sputnik.util.I18nUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import java.awt.*;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -35,8 +38,6 @@ public class Module {
// ajustes que están en todos los módulos // 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( protected KeySetting bind = new KeySetting(
"tecla", "tecla",
"tecla asignada al módulo, ESC para desactivar", "tecla asignada al módulo, ESC para desactivar",
@@ -44,7 +45,7 @@ public class Module {
).translationKey("sputnik.setting.common.bind"); ).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 // 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", "modo de tecla",
"cómo interpretar la tecla configurada", "cómo interpretar la tecla configurada",
KeyMode.class, KeyMode.TOGGLE KeyMode.class, KeyMode.TOGGLE
@@ -56,12 +57,26 @@ public class Module {
true true
).translationKey("sputnik.setting.common.notify"); ).translationKey("sputnik.setting.common.notify");
protected EnumSetting<NotifyMode> notifyMode = new EnumSetting<NotifyMode>( protected EnumSetting<NotifyMode> notifyMode = new EnumSetting<>(
"modo de notificación", "modo de notificación",
"cómo notificar cuando se activa / desactiva", "cómo notificar cuando se activa / desactiva",
NotifyMode.class, NotifyMode.WIDGET NotifyMode.class, NotifyMode.WIDGET
).translationKey("sputnik.setting.common.notifymode"); ).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 List<SettingGroup> sgs = new ArrayList<>();
protected final SettingGroup sgModule = addSg(new SettingGroup("módulo", false, "sputnik.group.common.module")); 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")); protected final SettingGroup sgGeneral = addSg(new SettingGroup("general", true, "sputnik.group.common.general"));
@@ -72,14 +87,11 @@ public class Module {
this.name = name; this.name = name;
this.description = description; this.description = description;
this.category = category; 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) { public Module(String name, String description, Category category, int key) {
this.name = name; this(name, description, category);
this.description = description;
this.category = category;
sgModule.addAll(bind, keyMode, notify, notifyMode);
this.bind.setDefaultValue(key); this.bind.setDefaultValue(key);
// puto marcos // puto marcos
@@ -155,9 +167,9 @@ public class Module {
} }
} }
// onDisable no miraba notify.getValue(), así que avisaba aunque estuviera desactivado
private void notifyToggle(boolean on) { private void notifyToggle(boolean on) {
if (!notify.getValue()) return; if (!notify.getValue()) return;
if (ConfigManager.INSTANCE != null && ConfigManager.INSTANCE.isApplying()) return;
String key = on ? "sputnik.module.toggled.on" : "sputnik.module.toggled.off"; String key = on ? "sputnik.module.toggled.on" : "sputnik.module.toggled.off";
Component message = Component.translatable(key, getDisplayName()); Component message = Component.translatable(key, getDisplayName());
@@ -173,8 +185,6 @@ public class Module {
// getters y setters // 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() { public String getName() {
return name; return name;
} }
@@ -249,6 +259,10 @@ public class Module {
return bind; return bind;
} }
public boolean isVisible() { return displayed.getValue(); }
public Color getArraylistColor() { return arraylistColor.getValue(); }
public boolean isSearchMatch() { public boolean isSearchMatch() {
return searchMatch; 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.misc.*;
import me.retucio.sputnik.module.modules.movement.*; import me.retucio.sputnik.module.modules.movement.*;
import me.retucio.sputnik.module.modules.network.*; 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.player.*;
import me.retucio.sputnik.module.modules.render.*; import me.retucio.sputnik.module.modules.render.*;
import me.retucio.sputnik.module.modules.render.CritsPlus; import me.retucio.sputnik.module.modules.render.CritsPlus;
@@ -90,6 +91,7 @@ public class ModuleManager {
add(new ChestplateSwitch()); add(new ChestplateSwitch());
add(new CrystalAura()); add(new CrystalAura());
add(new HoldAttack()); add(new HoldAttack());
add(new KillAura());
add(new MaceKill()); add(new MaceKill());
add(new ProjectileTrajectories()); add(new ProjectileTrajectories());
add(new SpearKill()); add(new SpearKill());
@@ -128,6 +130,7 @@ public class ModuleManager {
add(new Headhitters()); add(new Headhitters());
add(new HitboxDesync()); add(new HitboxDesync());
add(new InfiniteElytra()); add(new InfiniteElytra());
add(new ItemMagnet());
add(new Jesus()); add(new Jesus());
add(new Parkour()); add(new Parkour());
add(new ReverseStep()); add(new ReverseStep());
@@ -142,7 +145,9 @@ public class ModuleManager {
private void addNetwork() { private void addNetwork() {
add(new BungeecordSpoofer()); add(new BungeecordSpoofer());
add(new LogoutSpots()); add(new LogoutSpots());
add(new PacketCanceller());
add(new PacketDelay()); add(new PacketDelay());
add(new PacketLogger());
add(new PacketMine()); add(new PacketMine());
add(new Reconnect()); add(new Reconnect());
add(new RPackBypass()); add(new RPackBypass());
@@ -151,6 +156,7 @@ public class ModuleManager {
private void addPlayer() { private void addPlayer() {
add(new AirPlace()); add(new AirPlace());
add(new AntiHunger()); add(new AntiHunger());
add(new AutoEat());
add(new AutoFish()); add(new AutoFish());
add(new Capes()); add(new Capes());
add(new FastUse()); add(new FastUse());
@@ -171,14 +177,17 @@ public class ModuleManager {
add(new Fonts()); add(new Fonts());
add(new GlintPlus()); add(new GlintPlus());
add(new Hitboxes()); add(new Hitboxes());
add(new ItemPhysics());
add(new Lsd()); add(new Lsd());
add(new Nametags()); add(new Nametags());
add(new NoRender()); add(new NoRender());
add(new Particles()); add(new Particles());
add(new Stylish());
add(new Tracers()); add(new Tracers());
} }
private void addWorld() { private void addWorld() {
add(new AutoMine());
add(new AutoSign()); add(new AutoSign());
add(new AutoTool()); add(new AutoTool());
add(new BlockInfo()); add(new BlockInfo());
@@ -1,12 +1,10 @@
package me.retucio.sputnik.module.modules.camera; 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.Category;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting;
import me.retucio.sputnik.module.setting.settings.NumberSetting; 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)) if (direction.is(RotationDirection.COUNTERCLOCKWISE))
yaw -= interval.getFloatValue(); yaw -= interval.getFloatValue();
mc.getConnection().send(new ServerboundMovePlayerPacket.Rot( RotationUtil.requestYaw(RotationUtil.HIGHEST, yaw, RotationUtil.Mode.SILENT);
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();
} }
private enum RotationDirection { private enum RotationDirection {
@@ -358,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 (mc.player == null) return; // el jugador probablemente nunca sea nulo bajo estas circunstancias pero quién sabe
if (event.getPacket() instanceof ClientboundPlayerCombatKillPacket packet) { if (event.getPacket() instanceof ClientboundPlayerCombatKillPacket packet) {
if (mc.player.getId() == packet.playerId()) if (mc.player.getId() == packet.playerId()) {
toggle(); toggle();
}
} else if (event.getPacket() instanceof ClientboundSetHealthPacket packet) { } else if (event.getPacket() instanceof ClientboundSetHealthPacket packet) {
if (mc.player.getHealth() - packet.getHealth() > 0 && toggleOnDamage.getValue()) { if (mc.player.getHealth() - packet.getHealth() > 0 && toggleOnDamage.getValue()) {
ChatUtil.info(Component.translatable("sputnik.module.freecam.damagedisable")); 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.Module;
import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.BooleanSetting;
import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.RotationUtil;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
/** /**
@@ -30,8 +31,7 @@ public class Rotations extends Module {
public void onTick() { public void onTick() {
if (mc.player == null) return; if (mc.player == null) return;
mc.player.setYRot(yaw.getFloatValue()); RotationUtil.request(RotationUtil.HIGHEST, yaw.getFloatValue(), pitch.getFloatValue(), RotationUtil.Mode.CLIENT);
mc.player.setXRot(pitch.getFloatValue());
if (serverSide.getValue()) if (serverSide.getValue())
mc.player.connection.send( 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.HudElement;
import me.retucio.sputnik.ui.hud.HudRenderer; import me.retucio.sputnik.ui.hud.HudRenderer;
import me.retucio.sputnik.ui.hud.HudEditorScreen; import me.retucio.sputnik.ui.hud.HudEditorScreen;
import me.retucio.sputnik.ui.hud.elements.CustomImageElement;
import me.retucio.sputnik.ui.hud.elements.DynoElement; import me.retucio.sputnik.ui.hud.elements.DynoElement;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
@@ -126,6 +127,19 @@ public class Hud extends Module {
Dynosaurs.class, Dynosaurs.SPINOSAURUS 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() { public Hud() {
super("HUD", super("HUD",
"superposición de la pantalla con info. adicional", "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); DynoElement element = (DynoElement) HudRenderer.INSTANCE.getElement(DynoElement.class);
if (element != null) element.reloadTexture(); if (element != null) element.reloadTexture();
}); });
customImagePath.onUpdate(v -> {
CustomImageElement element = (CustomImageElement) HudRenderer.INSTANCE.getElement(CustomImageElement.class);
if (element != null) element.reloadTexture();
});
} }
public enum TimeFormat { public enum TimeFormat {
@@ -171,4 +190,21 @@ public class Hud extends Module {
@Override public String toString() { return name; } @Override public String toString() { return name; }
public String toRealString() { return super.toString(); } 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() { private void doBreak() {
if (breakTimer > 0) return; if (breakTimer > 0) return;
List<Entity> crystals = new ArrayList<>();
for (Entity entity : mc.level.getEntities().getAll()) { for (Entity entity : mc.level.getEntities().getAll()) {
if (!(entity instanceof EndCrystal) || entity.distanceTo(mc.player) > mc.player.entityInteractionRange()) continue; if (!(entity instanceof EndCrystal) || entity.distanceTo(mc.player) > mc.player.entityInteractionRange()) continue;
if (rotateToBreak.getValue()) EntityUtil.lookAt(entity.getEyePosition()); crystals.add(entity);
mc.gameMode.attack(mc.player, 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(); breakTimer = breakDelay.getIntValue();
} }
@@ -254,8 +265,11 @@ public class CrystalAura extends Module {
return; return;
} }
if (rotateToPlace.getValue()) EntityUtil.lookAt(Vec3.atCenterOf(result.getBlockPos())); Runnable place = () -> mc.gameMode.startPrediction(mc.level, (sequence) -> new ServerboundUseItemOnPacket(hand, result, sequence));
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) { private void placeObby(BlockPos pos) {
@@ -273,8 +287,11 @@ public class CrystalAura extends Module {
BlockPos supportPos = pos.below(); BlockPos supportPos = pos.below();
BlockHitResult result = new BlockHitResult(Vec3.atCenterOf(supportPos), Direction.UP, supportPos, false); BlockHitResult result = new BlockHitResult(Vec3.atCenterOf(supportPos), Direction.UP, supportPos, false);
if (rotateToPlace.getValue()) EntityUtil.lookAt(Vec3.atCenterOf(pos)); Runnable place = () -> mc.gameMode.startPrediction(mc.level, (sequence) -> new ServerboundUseItemOnPacket(hand, result, sequence));
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) { private void doAutoSelect(Item item) {
@@ -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; }
}
}
@@ -5,6 +5,7 @@ import me.retucio.sputnik.module.Category;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.BooleanSetting;
import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.RotationUtil;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@@ -73,13 +74,11 @@ public class SpearKill extends Module {
float yaw = (float) (Math.toDegrees(Math.atan2(toTarget.z, toTarget.x)) - 90.0); float yaw = (float) (Math.toDegrees(Math.atan2(toTarget.z, toTarget.x)) - 90.0);
float pitch = (float) -Math.toDegrees(Math.asin(toTarget.y)); float pitch = (float) -Math.toDegrees(Math.asin(toTarget.y));
mc.player.setYRot(yaw); RotationUtil.request(RotationUtil.HIGH, yaw, pitch, RotationUtil.Mode.CLIENT);
mc.player.setYHeadRot(yaw);
mc.player.setXRot(pitch);
if (heldTicks >= 10) { if (heldTicks >= 10) {
double lungeSpeed = speed.getValue(); double lungeSpeed = speed.getValue();
Vec3 viewDir = Vec3.directionFromRotation(mc.player.getXRot(), mc.player.getYRot()); Vec3 viewDir = Vec3.directionFromRotation(pitch, yaw);
mc.player.setSprinting(true); mc.player.setSprinting(true);
mc.player.setDeltaMovement(viewDir.scale(lungeSpeed)); mc.player.setDeltaMovement(viewDir.scale(lungeSpeed));
} }
@@ -15,9 +15,9 @@ import me.retucio.sputnik.module.setting.SettingGroup;
import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.BooleanSetting;
import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import me.retucio.sputnik.util.interfaces.IGuiMessage; import me.retucio.sputnik.mixinterfaces.IGuiMessage;
import me.retucio.sputnik.util.interfaces.IGuiMessageLine; import me.retucio.sputnik.mixinterfaces.IGuiMessageLine;
import me.retucio.sputnik.util.interfaces.TextVisitor; import me.retucio.sputnik.mixinterfaces.TextVisitor;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.PlayerFaceExtractor; import net.minecraft.client.gui.components.PlayerFaceExtractor;
@@ -34,8 +34,10 @@ public class ScreenshotPlus extends Module {
private final SettingGroup sgButtons = addSg(new SettingGroup("botones", true)); private final SettingGroup sgButtons = addSg(new SettingGroup("botones", true));
public final EnumSetting<ScreenshotActions> defaultAction = sgGeneral.add(new EnumSetting<>("por defecto", "qué acción tomar por defecto", public final EnumSetting<ScreenshotActions> defaultAction = sgGeneral.add(new EnumSetting<>(
ScreenshotActions.class, ScreenshotActions.NONE)); "por defecto", "qué acción tomar por defecto",
ScreenshotActions.class, ScreenshotActions.NONE)
);
private final BooleanSetting saveButton = sgButtons.add(new BooleanSetting("botón de guardar", "mostrar botón para guardar la captura localmente", true)); private final BooleanSetting saveButton = sgButtons.add(new BooleanSetting("botón de guardar", "mostrar botón para guardar la captura localmente", true));
private final BooleanSetting copyButton = sgButtons.add(new BooleanSetting("botón de copiar", "mostrar botón para copiar la captura al portapapeles", true)); private final BooleanSetting copyButton = sgButtons.add(new BooleanSetting("botón de copiar", "mostrar botón para copiar la captura al portapapeles", true));
@@ -5,6 +5,7 @@ import me.retucio.sputnik.event.interact.UseItemEvent;
import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Category;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.RotationUtil;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
@@ -99,7 +100,7 @@ public class InfiniteElytra extends Module {
} }
} }
mc.player.setXRot(pitch); RotationUtil.requestPitch(RotationUtil.NORMAL, pitch, RotationUtil.Mode.CLIENT);
} }
@EventListener @EventListener
@@ -107,7 +108,7 @@ public class InfiniteElytra extends Module {
if (mc.player == null) return; if (mc.player == null) return;
if (mc.player.getItemInHand(event.getHand()).getItem() == Items.FIREWORK_ROCKET && !mc.player.isSpectator() && mc.player.isFallFlying()) { if (mc.player.getItemInHand(event.getHand()).getItem() == Items.FIREWORK_ROCKET && !mc.player.isSpectator() && mc.player.isFallFlying()) {
pitch = pitchUp.getFloatValue(); pitch = pitchUp.getFloatValue();
mc.player.setXRot(pitch); RotationUtil.requestPitch(RotationUtil.NORMAL, pitch, RotationUtil.Mode.CLIENT);
state = FlyState.PITCHING_DOWN; state = FlyState.PITCHING_DOWN;
lowestY = mc.player.getY(); lowestY = mc.player.getY();
} }
@@ -0,0 +1,122 @@
package me.retucio.sputnik.module.modules.movement;
import com.github.retucio.neutrino.EventListener;
import me.retucio.sputnik.event.interact.UpdateInventoryEvent;
import me.retucio.sputnik.module.Category;
import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.InventoryUtil;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ItemMagnet extends Module {
private final NumberSetting range = sgGeneral.add(new NumberSetting(
"rango", "rango de recogida de items",
6, 1, 32, 0.5f
));
@Nullable
private ItemEntity current = null;
private AABB box = null;
private final List<ItemEntity> cannotPickUp = new ArrayList<>();
private int cooldown = 0;
public ItemMagnet() {
super("imán de items", "recoge items distantes rápidamente mediante paquetes de movimiento", Category.MOVEMENT);
}
@Override
public void onEnable() {
current = null;
cooldown = 0;
}
@Override
public void onDisable() {
current = null;
cooldown = 0;
}
@Override
public void onTick() {
if (mc.player == null || mc.level == null || mc.getConnection() == null) return;
if (current != null && !current.isAlive()) {
current = null;
cooldown = 0;
}
if (current != null) {
box = mc.player.getVehicle() == null
? mc.player.getBoundingBox()
: mc.player.getVehicle().getBoundingBox().minmax(mc.player.getBoundingBox()).inflate(1.0, 0, 1.0);
if (!box.intersects(current.getBoundingBox())) {
if (cooldown > 0) {
cooldown--;
return;
}
Vec3 realPos = mc.player.position();
// tparse al item
mc.getConnection().send(new ServerboundMovePlayerPacket.Pos(
current.getX(), current.getY(), current.getZ(),
mc.player.onGround(),
mc.player.horizontalCollision
));
// para evitar desync
mc.getConnection().send(new ServerboundMovePlayerPacket.Pos(
realPos.x, realPos.y, realPos.z,
mc.player.onGround(),
mc.player.horizontalCollision
));
// pequeño margen antes de reintentar con el mismo ítem
cooldown = 2;
}
return;
}
for (Entity entity : mc.level.getEntities().getAll()) {
if (entity.is(mc.player)) continue;
if (entity.distanceToSqr(mc.player) > range.getFloatValue() * range.getFloatValue()) continue;
if (entity instanceof ItemEntity item) {
if (cannotPickUp.contains(item)) continue;
if (InventoryUtil.findSlot(stack -> stack.is(item.getItem().getItem()) && stack.getCount() < stack.getMaxStackSize()) == -1
&& mc.player.getInventory().getFreeSlot() == -1
) {
cannotPickUp.add(item);
continue;
}
current = item;
cooldown = 0;
return;
}
}
}
@EventListener
private void onInventoryChange(UpdateInventoryEvent event) {
cannotPickUp.clear();
}
}
@@ -82,6 +82,15 @@ public class Scaffold extends Module {
0.1 0.1
)).visibility(extend::getValue); )).visibility(extend::getValue);
private final NumberSetting bridgeWidth = sgBridge.add(new NumberSetting(
"ancho del puente",
"número de bloques de ancho del puente",
1,
1,
5,
1
));
/* torre */ /* torre */
@@ -160,7 +169,7 @@ public class Scaffold extends Module {
private final ColorSetting fillingColor = sgRender.add(new ColorSetting( private final ColorSetting fillingColor = sgRender.add(new ColorSetting(
"color del relleno", "color del relleno",
"color a uisar al renderizar el relleno", "color a usar al renderizar el relleno",
Colors.withAlpha(Colors.mainColor, 60), Colors.withAlpha(Colors.mainColor, 60),
false false
)).visibility(fillings::getValue); )).visibility(fillings::getValue);
@@ -228,8 +237,12 @@ public class Scaffold extends Module {
// seleccionar nivel Y // seleccionar nivel Y
double y; double y;
if (mjBridge.getValue() && mjY != null && isMoving()) { if (mjBridge.getValue()) {
y = mjY; if (mjY == null || !isMoving()) {
// no moving (or not yet initialized): keep mjY synced to the real ground level
mjY = (int) Math.floor(pos.y - 0.5);
}
y = isMoving() ? mjY : (pos.y - 0.5);
} else { } else {
y = pos.y - 0.5; y = pos.y - 0.5;
} }
@@ -243,7 +256,24 @@ public class Scaffold extends Module {
// colocar bloque // colocar bloque
bp.set(pos.x, y, pos.z); bp.set(pos.x, y, pos.z);
place(bp); BlockPos center = bp.immutable();
int width = bridgeWidth.getIntValue();
if (width > 1) {
Vec3 right = Vec3.directionFromRotation(0, mc.player.getYRot() + 90).normalize();
int leftOff = (width - 1) / 2;
int rightOff = width / 2;
for (int i = -leftOff; i <= rightOff; i++) {
BlockPos offsetPos = new BlockPos(
(int) Math.round(center.getX() + right.x * i),
center.getY(),
(int) Math.round(center.getZ() + right.z * i)
);
place(offsetPos);
}
} else {
place(center);
}
// colocar bloque encima de la cabeza // colocar bloque encima de la cabeza
if (headhitter.getValue() && mc.options.keyJump.isDown() && !mc.options.keyShift.isDown()) { if (headhitter.getValue() && mc.options.keyJump.isDown() && !mc.options.keyShift.isDown()) {
@@ -294,14 +324,6 @@ public class Scaffold extends Module {
} }
} }
@EventListener
private void onPlaceBlock(PlaceBlockEvent event) {
// guardar último valor Y para el mj bridge
if (mjBridge.getValue()) {
mjY = event.getResult().getBlockPos().getY();
}
}
@EventListener @EventListener
private void onSneak(SneakEvent event) { private void onSneak(SneakEvent event) {
// no agacharse // no agacharse
@@ -334,8 +356,8 @@ public class Scaffold extends Module {
if (NetworkUtil.placeBlock( if (NetworkUtil.placeBlock(
pos, InteractionHand.MAIN_HAND, pos, InteractionHand.MAIN_HAND,
slot, slot,
rotate.getValue(), rotate.getValue() ? RotationUtil.Mode.CLIENT : null,
rotate.getValue(), RotationUtil.NORMAL,
swingHand.getValue(), swingHand.getValue(),
true, true,
true true
@@ -377,7 +399,7 @@ public class Scaffold extends Module {
} }
private boolean isMoving() { private boolean isMoving() {
return mc.player.zza != 0 return mc.player.zza != 0
|| mc.player.xxa != 0; || mc.player.xxa != 0;
} }
@@ -0,0 +1,44 @@
package me.retucio.sputnik.module.modules.network;
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.ListSetting;
import me.retucio.sputnik.util.Lists;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketType;
import org.jspecify.annotations.NonNull;
public class PacketCanceller extends Module {
private final ListSetting<PacketType<? extends @NonNull Packet<?>>> c2s = sgGeneral.add(new ListSetting<>(
"C2S", "paquetes a cancelar, dirección servidor",
Lists.c2sPacketList, Lists.allFalse(Lists.c2sPacketList), Lists.c2sPacketNames
));
private final ListSetting<PacketType<? extends @NonNull Packet<?>>> s2c = sgGeneral.add(new ListSetting<>(
"S2C", "paquetes a cancelar, dirección cliente",
Lists.s2cPacketList, Lists.allFalse(Lists.s2cPacketList), Lists.s2cPacketNames
));
public PacketCanceller() {
super("cancelador de paquetes", "cancela los paquetes seleccionados", Category.NETWORK);
}
@EventListener
private void onPacketSend(PacketEvent.Send event) {
if (c2s.isEnabled(event.getPacket().type())) {
event.cancel();
}
}
@EventListener
private void onPacketReceive(PacketEvent.Receive event) {
if (s2c.isEnabled(event.getPacket().type())) {
event.cancel();
}
}
}
@@ -120,8 +120,6 @@ public class PacketDelay extends Module {
@EventListener @EventListener
private void onJoinWorld(JoinWorldEvent event) { private void onJoinWorld(JoinWorldEvent event) {
// el aviso iba sin condición, así que el módulo se apagaba solo al entrar
// a cualquier mundo, servidores incluidos
if (!MiscUtil.isSingleplayer()) return; if (!MiscUtil.isSingleplayer()) return;
ChatUtil.error(Component.translatable("sputnik.module.packetdelay.singleplayer")); ChatUtil.error(Component.translatable("sputnik.module.packetdelay.singleplayer"));
@@ -0,0 +1,212 @@
package me.retucio.sputnik.module.modules.network;
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.FileSetting;
import me.retucio.sputnik.module.setting.settings.ListSetting;
import me.retucio.sputnik.ui.hud.HudRenderer;
import me.retucio.sputnik.util.ChatUtil;
import me.retucio.sputnik.util.Lists;
import net.minecraft.client.Minecraft;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketType;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class PacketLogger extends Module {
private static final DateTimeFormatter TIME = DateTimeFormatter
.ofPattern("HH:mm:ss.SSS")
.withZone(ZoneId.systemDefault());
private static final int QUEUE_CAPACITY = 8192;
private static final int BATCH_SIZE = 256;
private final ListSetting<PacketType<? extends Packet<?>>> packets = sgGeneral.add(new ListSetting<>(
"paquetes", "paquetes a loguear",
Lists.packetList, Lists.allFalse(Lists.packetList), Lists.packetNames
));
private final EnumSetting<LogMode> mode = sgGeneral.add(new EnumSetting<>(
"modo de logueo", "de qué manera loguear los paquetes",
LogMode.class, LogMode.FILE
));
private final FileSetting file = sgGeneral.add(new FileSetting(
"archivo", "archivo donde loguear los paquetes",
"sputnik/packets.log"
)).visibility(() -> mode.is(LogMode.FILE));
private final BlockingQueue<String> queue = new ArrayBlockingQueue<>(QUEUE_CAPACITY);
private final AtomicInteger dropped = new AtomicInteger();
private volatile boolean running;
private volatile Thread writer;
public PacketLogger() {
super("logger de paquetes", "loguea paquetes", Category.NETWORK);
}
@Override
public void onEnable() {
startWriter();
}
@Override
public void onDisable() {
stopWriter();
}
@EventListener
private void onPacketSend(PacketEvent.Send event) {
handle("OUT", event.getPacket());
}
@EventListener
private void onPacketReceive(PacketEvent.Receive event) {
handle("IN", event.getPacket());
}
private void handle(String direction, Packet<?> packet) {
if (packet == null || !packets.isEnabled(packet.type())) return;
String name = nameOf(packet);
String body = describe(packet);
switch (mode.getValue()) {
case CHAT -> onGameThread(() -> ChatUtil.info("[" + direction + "] " + body));
case NOTIFICATION -> onGameThread(() -> HudRenderer.INSTANCE.pushNotification(name, body));
case FILE -> enqueue("[" + TIME.format(Instant.now()) + "] [" + direction + "] " + name + " " + body);
}
}
private static void onGameThread(Runnable action) {
Minecraft mc = Minecraft.getInstance();
if (mc.isSameThread()) action.run();
else mc.execute(action);
}
private static String nameOf(Packet<?> packet) {
PacketType<?> type = packet.type();
return type.id().toString();
}
private static String describe(Packet<?> packet) {
try {
return String.valueOf(packet);
} catch (Throwable t) {
return packet.getClass().getSimpleName() + " <toString failed: " + t + ">";
}
}
private void enqueue(String line) {
if (!running) return;
if (!queue.offer(line)) dropped.incrementAndGet();
}
private void startWriter() {
if (running) return;
Path path = file.getPath().toAbsolutePath();
queue.clear();
dropped.set(0);
running = true;
Thread thread = new Thread(() -> writerLoop(path), "sputnik-packet-logger");
thread.setDaemon(true);
thread.setPriority(Thread.MIN_PRIORITY);
writer = thread;
thread.start();
}
private void stopWriter() {
if (!running) return;
running = false;
Thread thread = writer;
writer = null;
if (thread == null) return;
try {
thread.join(2000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
int lost = dropped.getAndSet(0);
if (lost > 0) {
onGameThread(() -> ChatUtil.warn("se descartaron " + lost + " paquetes (cola llena)"));
}
}
private void writerLoop(Path path) {
try {
Path parent = path.getParent();
if (parent != null) Files.createDirectories(parent);
try (BufferedWriter out = Files.newBufferedWriter(
path, StandardCharsets.UTF_8,
StandardOpenOption.CREATE, StandardOpenOption.APPEND)) {
out.write("--- sesión iniciada " + Instant.now() + " ---");
out.newLine();
out.flush();
List<String> batch = new ArrayList<>(BATCH_SIZE);
while (running || !queue.isEmpty()) {
String first = queue.poll(250, TimeUnit.MILLISECONDS);
if (first == null) continue;
batch.add(first);
queue.drainTo(batch, BATCH_SIZE - 1);
for (String line : batch) {
out.write(line);
out.newLine();
}
batch.clear();
out.flush();
}
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (IOException e) {
running = false;
queue.clear();
onGameThread(() -> {
ChatUtil.error("no se pudo escribir el log: " + e.getMessage());
toggle();
});
}
}
private enum LogMode {
CHAT("chat"),
NOTIFICATION("notis"),
FILE("archivo");
private final String name;
LogMode(String name) { this.name = name; }
@Override public String toString() { return name; }
}
}
@@ -11,7 +11,7 @@ import me.retucio.sputnik.module.setting.settings.ColorSetting;
import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting;
import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import me.retucio.sputnik.util.EntityUtil; import me.retucio.sputnik.util.RotationUtil;
import me.retucio.sputnik.util.render.RenderUtil; import me.retucio.sputnik.util.render.RenderUtil;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@@ -54,8 +54,6 @@ public class PacketMine extends Module {
ClickAction.ADD_PRIORITY ClickAction.ADD_PRIORITY
)); ));
// el espacio del final es a propósito: compartía clave de config. con retryTime ("delay"),
// así que se pisaban el valor. se muestra igual porque getName() hace strip()
private final NumberSetting selectionDelay = sgGeneral.add(new NumberSetting( private final NumberSetting selectionDelay = sgGeneral.add(new NumberSetting(
"delay ", "delay ",
"delay entre selecciones de bloques", "delay entre selecciones de bloques",
@@ -278,14 +276,18 @@ public class PacketMine extends Module {
return false; return false;
} }
rotate(); Runnable mine = () -> {
mc.gameMode.startPrediction(mc.level, sequence ->
new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, dir, sequence));
mc.gameMode.startPrediction(mc.level, sequence ->
new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, dir, sequence));
};
RotationUtil.Mode rotation = getRotationMode();
if (rotation == null) mine.run();
else RotationUtil.lookAt(RotationUtil.NORMAL, Vec3.atLowerCornerOf(pos), 0, rotation, mine);
mc.gameMode.startPrediction(mc.level, sequence ->
new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, dir, sequence));
mining = true; mining = true;
mc.gameMode.startPrediction(mc.level, sequence ->
new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, dir, sequence));
return true; return true;
} }
@@ -303,13 +305,12 @@ public class PacketMine extends Module {
); );
} }
private void rotate() { private RotationUtil.Mode getRotationMode() {
Vec3 pos = Vec3.atLowerCornerOf(this.pos); return switch (rotate.getValue()) {
switch (rotate.getValue()) { case CLIENT, BOTH -> RotationUtil.Mode.CLIENT;
case CLIENT -> EntityUtil.lookAtClient(pos); case SERVER -> RotationUtil.Mode.SILENT;
case SERVER -> EntityUtil.lookAtServer(pos); case NONE -> null;
case BOTH -> EntityUtil.lookAt(pos); };
}
} }
public boolean shouldRetry() { public boolean shouldRetry() {
@@ -0,0 +1,123 @@
package me.retucio.sputnik.module.modules.player;
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.ListSetting;
import me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.InventoryUtil;
import me.retucio.sputnik.util.Lists;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.Consumable;
import net.minecraft.world.item.consume_effects.ApplyStatusEffectsConsumeEffect;
import java.util.Comparator;
import java.util.List;
public class AutoEat extends Module {
private final NumberSetting hunger = sgGeneral.add(new NumberSetting(
"hambre", "cuánta hambre es necesaria para comer (puntos de comida)",
6, 0, 19, 1
));
private final NumberSetting whenToStop = sgGeneral.add(new NumberSetting(
"cuándo parar", "cuántos puntos de comida hace falta tener para parar de comer",
20, 1, 20, 1
));
private final ListSetting<Item> blacklist = sgGeneral.add(new ListSetting<>(
"lista negra", "alimentos a NO comer",
() -> Lists.foodList,
() -> Lists.allFalseExcept(Lists.foodList, this::isBad),
() -> Lists.foodNames
));
private boolean eating;
public AutoEat() {
super("puto gordo", "come aut/omáticamente al tener hambre", Category.PLAYER);
}
@Override
public void onDisable() {
if (eating) stopEating();
super.onDisable();
}
@Override
public void onTick() {
if (mc.player == null) return;
if (eating) {
if (mc.player.getUseItemRemainingTicks() > 0) {
return;
} else {
if (mc.player.getFoodData().getFoodLevel() >= whenToStop.getIntValue()) {
stopEating();
}
}
}
if (mc.player.getFoodData().getFoodLevel() <= hunger.getIntValue()) {
List<ItemStack> sorted = InventoryUtil.findAllStacks(
stack -> stack.getItem().components().get(DataComponents.FOOD) != null
);
sorted.sort(Comparator.comparingInt(
(ItemStack s) -> s.getItem().components().get(DataComponents.FOOD).nutrition()
).reversed());
if (sorted.isEmpty()) return;
sorted.removeIf(stack -> blacklist.isEnabled(stack.getItem()));
boolean inHotbar = false;
for (ItemStack stack : sorted) {
int slot = InventoryUtil.findSlot(s -> stack == s);
if (Inventory.isHotbarSlot(slot)) {
mc.player.getInventory().setSelectedSlot(slot);
inHotbar = true;
break;
}
}
if (!inHotbar) {
int free = mc.player.getInventory().getFreeSlot();
InventoryUtil.move(InventoryUtil.findSlot(stack -> stack == sorted.getFirst()), free != -1
? free
: mc.player.getInventory().getSelectedSlot());
if (free != -1) {
mc.player.getInventory().setSelectedSlot(free);
}
}
startEating();
}
}
private void startEating() {
eating = true;
mc.options.keyUse.setDown(true);
}
private void stopEating() {
eating = false;
mc.options.keyUse.setDown(false);
}
private boolean isBad(Item item) {
Consumable consumable = item.components().get(DataComponents.CONSUMABLE);
if (consumable == null) return false;
return consumable.onConsumeEffects().stream()
.anyMatch(effect -> effect instanceof ApplyStatusEffectsConsumeEffect applyEffects
&& applyEffects.effects().stream().anyMatch(mobEffectInstance ->
!mobEffectInstance.getEffect().value().isBeneficial()));
}
}
@@ -11,6 +11,7 @@ import me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import me.retucio.sputnik.util.InventoryUtil; import me.retucio.sputnik.util.InventoryUtil;
import me.retucio.sputnik.util.Lists; import me.retucio.sputnik.util.Lists;
import me.retucio.sputnik.util.RotationUtil;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
@@ -136,23 +137,23 @@ public class NoFall extends Module {
return; return;
} }
// mirar abajo
mc.player.setXRot(180);
int slot = mc.player.getInventory().findSlotMatchingItem(mlgItem); int slot = mc.player.getInventory().findSlotMatchingItem(mlgItem);
mc.player.getInventory().setSelectedSlot(slot); mc.player.getInventory().setSelectedSlot(slot);
// usar bloque // usar bloque
if (mlgItem.getItem() instanceof BlockItem) { if (mlgItem.getItem() instanceof BlockItem) {
RotationUtil.requestPitch(RotationUtil.HIGH, 90, RotationUtil.Mode.CLIENT);
shouldUse = true; shouldUse = true;
placed = true; placed = true;
return; return;
} }
// usar ítem // mirar abajo y usar el ítem cuando el servidor lo vea
InteractionResult didPlace = mc.gameMode.useItem(mc.player, InteractionHand.MAIN_HAND); RotationUtil.request(RotationUtil.HIGH, Float.NaN, 90, 0, RotationUtil.Mode.CLIENT, () -> {
if (didPlace.consumesAction()) InteractionResult didPlace = mc.gameMode.useItem(mc.player, InteractionHand.MAIN_HAND);
placed = true; if (didPlace.consumesAction())
placed = true;
});
} }
} }
} }
@@ -39,7 +39,7 @@ public class BlockOutline extends Module {
@EventListener @EventListener
private void onRenderBlockOutline(RenderBlockOutlineEvent event) { private void onRenderBlockOutline(RenderBlockOutlineEvent event) {
event.setColor(color.getRGB()); event.setColor(color.getRgb());
event.setLineWidth(lineWidth.getFloatValue()); event.setLineWidth(lineWidth.getFloatValue());
} }
} }
@@ -20,16 +20,16 @@ import java.awt.*;
public class BreakingProgress extends Module { public class BreakingProgress extends Module {
private final SettingGroup sgOulines = addSg(new SettingGroup("contorno", true)); private final SettingGroup sgOutlines = addSg(new SettingGroup("contorno", true));
private final SettingGroup sgFilling = addSg(new SettingGroup("relleno", true)); private final SettingGroup sgFilling = addSg(new SettingGroup("relleno", true));
private final EnumSetting<BreakMode> breakMode = sgGeneral.add(new EnumSetting<>("modo de minado", "elige si el cubo se encoge o se dilata", private final EnumSetting<BreakMode> breakMode = sgGeneral.add(new EnumSetting<>("modo de minado", "elige si el cubo se encoge o se dilata",
BreakMode.class, BreakMode.INWARDS)); BreakMode.class, BreakMode.INWARDS));
private final BooleanSetting outlines = sgOulines.add(new BooleanSetting("contorno", "renderizar contorno", true)); private final BooleanSetting outlines = sgOutlines.add(new BooleanSetting("contorno", "renderizar contorno", true));
private final ColorSetting outlineColor = sgOulines.add(new ColorSetting("color del contorno", "color del contorno", private final ColorSetting outlineColor = sgOutlines.add(new ColorSetting("color del contorno", "color del contorno",
new Color(0, 255, 0, 200), false)); new Color(0, 255, 0, 200), false));
private final NumberSetting lineWidth = sgOulines.add(new NumberSetting("grosor de línea", "grosor de las líneas del contorno", 1, 1, 5, 0.1)); private final NumberSetting lineWidth = sgOutlines.add(new NumberSetting("grosor de línea", "grosor de las líneas del contorno", 1, 1, 5, 0.1));
private final BooleanSetting fillings = sgFilling.add(new BooleanSetting("relleno", "renderizar relleno", true)); private final BooleanSetting fillings = sgFilling.add(new BooleanSetting("relleno", "renderizar relleno", true));
private final ColorSetting fillingColor = sgFilling.add(new ColorSetting("color del relleno", "color del relleno", private final ColorSetting fillingColor = sgFilling.add(new ColorSetting("color del relleno", "color del relleno",
@@ -46,30 +46,30 @@ public class GlintPlus extends Module {
} }
public RenderType getGlint() { public RenderType getGlint() {
int color = getColor(); int color = getGlintColor();
if (!isEnabled() || !items.getValue()) return RenderTypes.glint(); if (!isEnabled() || !items.getValue()) return RenderTypes.glint();
return GlintRenderType.glintColor.get(color); return GlintRenderType.glintColor.get(color);
} }
public RenderType getGlintTranslucent() { public RenderType getGlintTranslucent() {
int color = getColor(); int color = getGlintColor();
if (!isEnabled() || !items.getValue()) return RenderTypes.glintTranslucent(); if (!isEnabled() || !items.getValue()) return RenderTypes.glintTranslucent();
return GlintRenderType.glintTranslucentColor.get(color); return GlintRenderType.glintTranslucentColor.get(color);
} }
public RenderType getEntityGlint() { public RenderType getEntityGlint() {
int color = getColor(); int color = getGlintColor();
if (!isEnabled() || !items.getValue()) return RenderTypes.entityGlint(); if (!isEnabled() || !items.getValue()) return RenderTypes.entityGlint();
return GlintRenderType.entityGlintColor.get(color); return GlintRenderType.entityGlintColor.get(color);
} }
public RenderType getArmorEntityGlint() { public RenderType getArmorEntityGlint() {
int color = getColor(); int color = getGlintColor();
if (!isEnabled() || !armor.getValue()) return RenderTypes.armorEntityGlint(); if (!isEnabled() || !armor.getValue()) return RenderTypes.armorEntityGlint();
return GlintRenderType.armorEntityGlintColor.get(color); return GlintRenderType.armorEntityGlintColor.get(color);
} }
public int getColor() { public int getGlintColor() {
String colorName = glintColor.getValue().getRealName().toLowerCase(); String colorName = glintColor.getValue().getRealName().toLowerCase();
switch (colorName) { switch (colorName) {
@@ -0,0 +1,165 @@
package me.retucio.sputnik.module.modules.render;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import me.retucio.sputnik.event.render.ApplyTransformationEvent;
import me.retucio.sputnik.event.render.RenderItemEntityEvent;
import me.retucio.sputnik.mixin.accessors.ItemStackRenderStateAccessor;
import me.retucio.sputnik.mixin.accessors.LayerRenderStateAccessor;
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 com.github.retucio.neutrino.EventListener;
import net.minecraft.client.renderer.item.ItemStackRenderState;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.resources.model.cuboid.ItemTransform;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.item.ItemEntity;
import org.joml.Vector3f;
import org.joml.Vector3fc;
import java.util.List;
public class ItemPhysics extends Module {
private static final float PIXEL_SIZE = 1f / 16f;
private final BooleanSetting randomRotation = sgGeneral.add(new BooleanSetting(
"rotación aleatoria",
"añade una rotación aleatoria a cada objeto",
true
));
private final RandomSource random = RandomSource.createThreadLocalInstance();
private boolean skipTransformation;
public ItemPhysics() {
super("física de objetos", "aplica física a los objetos en el suelo", Category.RENDER);
}
@EventListener
private void onRenderItemEntity(RenderItemEntityEvent event) {
event.cancel();
if (event.renderState.item.isEmpty() || event.itemEntity == null) return;
PoseStack matrices = event.matrixStack;
random.setSeed(event.itemEntity.getId() * 0x53505554L);
var accessor = (ItemStackRenderStateAccessor) event.renderState.item;
for (int i = 0; i < accessor.getActiveLayerCount(); i++) {
ItemStackRenderState.LayerRenderState layer = accessor.getLayers()[i];
ModelInfo info = getInfo(layer.prepareQuadList());
matrices.pushPose();
applyTransformation(matrices, ((LayerRenderStateAccessor) layer).sputnik$getTransform());
matrices.translate(0, info.offsetY, 0);
offsetInWater(matrices, event.itemEntity);
if (info.flat) {
matrices.mulPose(Axis.XP.rotationDegrees(90));
matrices.translate(0, 0, info.offsetZ);
}
if (randomRotation.getValue()) {
var axis = Axis.YP;
var x = 0.5f; var y = 0.0f; var z = 0.5f;
if (info.flat) {
axis = Axis.ZP;
y = 0.5f; z = 0.0f;
}
float degrees = (random.nextFloat() * 2 - 1) * 90;
matrices.translate(x, y, z);
matrices.mulPose(axis.rotationDegrees(degrees));
matrices.translate(-x, -y, -z);
}
renderLayer(event, info);
matrices.popPose();
}
}
@EventListener
private void onApplyTransformation(ApplyTransformationEvent event) {
if (skipTransformation) {
event.cancel();
}
}
private void renderLayer(RenderItemEntityEvent event, ModelInfo info) {
PoseStack matrices = event.matrixStack;
skipTransformation = true;
for (int j = 0; j < event.renderState.count; j++) {
matrices.pushPose();
if (j > 0) {
float x = (random.nextFloat() * 2 - 1) * 0.25f;
float z = (random.nextFloat() * 2 - 1) * 0.25f;
translate(matrices, info, x, 0, z);
}
event.renderState.item.submit(matrices, event.renderCommandQueue, event.light, OverlayTexture.NO_OVERLAY, event.renderState.outlineColor);
matrices.popPose();
float y = Math.max(random.nextFloat() * PIXEL_SIZE, PIXEL_SIZE / 2f);
translate(matrices, info, 0, y, 0);
}
skipTransformation = false;
}
private void translate(PoseStack matrices, ModelInfo info, float x, float y, float z) {
if (info.flat) {
float temp = y; y = z; z = -temp;
}
matrices.translate(x, y, z);
}
private void applyTransformation(PoseStack matrices, ItemTransform transform) {
transform = new ItemTransform(
transform.rotation(),
new Vector3f(transform.translation().x(), 0, transform.translation().z()),
transform.scale()
);
transform.apply(false, matrices.last());
}
private void offsetInWater(PoseStack matrices, ItemEntity entity) {
if (entity.isInWater()) {
matrices.translate(0, 0.333f, 0);
}
}
private ModelInfo getInfo(List<net.minecraft.client.resources.model.geometry.BakedQuad> quads) {
float minX = Float.MAX_VALUE, maxX = Float.MIN_VALUE;
float minY = Float.MAX_VALUE, maxY = Float.MIN_VALUE;
float minZ = Float.MAX_VALUE, maxZ = Float.MIN_VALUE;
for (var quad : quads) {
for (int i = 0; i < 4; i++) {
Vector3fc vec = quad.position(i);
minY = Math.min(minY, vec.y()); maxY = Math.max(maxY, vec.y());
minZ = Math.min(minZ, vec.z()); maxZ = Math.max(maxZ, vec.z());
minX = Math.min(minX, vec.x()); maxX = Math.max(maxX, vec.x());
}
}
if (minX == Float.MAX_VALUE) minX = 0;
if (minY == Float.MAX_VALUE) minY = 0;
if (minZ == Float.MAX_VALUE) minZ = 0;
if (maxX == Float.MIN_VALUE) maxX = 1;
if (maxY == Float.MIN_VALUE) maxY = 1;
if (maxZ == Float.MIN_VALUE) maxZ = 1;
float x = maxX - minX, y = maxY - minY, z = maxZ - minZ;
boolean flat = (x > PIXEL_SIZE && y > PIXEL_SIZE && z <= PIXEL_SIZE);
return new ModelInfo(flat, 0.5f - minY, -maxZ);
}
private record ModelInfo(boolean flat, float offsetY, float offsetZ) {}
}
@@ -13,6 +13,7 @@ import me.retucio.sputnik.module.setting.SettingGroup;
import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.BooleanSetting;
import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting;
import me.retucio.sputnik.module.setting.settings.ListSetting; import me.retucio.sputnik.module.setting.settings.ListSetting;
import me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.Lists; import me.retucio.sputnik.util.Lists;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
@@ -64,6 +65,7 @@ public class Nametags extends Module {
public final BooleanSetting alwaysVisible = sgGeneral.add(new BooleanSetting("siempre mostrar nametags", "mostrar nametag cuando el jugador está agachado o es invisible", false)); public final BooleanSetting alwaysVisible = sgGeneral.add(new BooleanSetting("siempre mostrar nametags", "mostrar nametag cuando el jugador está agachado o es invisible", false));
public final BooleanSetting showSelf = sgGeneral.add(new BooleanSetting("mostrar propio", "mostrar nametag propio", false)); public final BooleanSetting showSelf = sgGeneral.add(new BooleanSetting("mostrar propio", "mostrar nametag propio", false));
public final BooleanSetting friendNick = sgGeneral.add(new BooleanSetting("motes", "usar los motes de amigos", true)); public final BooleanSetting friendNick = sgGeneral.add(new BooleanSetting("motes", "usar los motes de amigos", true));
public final NumberSetting distance = sgGeneral.add(new NumberSetting("distancia", "distancia máxima para renderizar nametags", 1024, 1, 1024, 1));
public final BooleanSetting countItems = sgInfo.add(new BooleanSetting("contar items", "muestra cuánto de un item hay en un stack dropeado", true)); public final BooleanSetting countItems = sgInfo.add(new BooleanSetting("contar items", "muestra cuánto de un item hay en un stack dropeado", true));
public final BooleanSetting showProjectileDamage = sgInfo.add(new BooleanSetting("daño del proyectil", "muestra cuánto daño hace un proyectil en su nametag", true)); public final BooleanSetting showProjectileDamage = sgInfo.add(new BooleanSetting("daño del proyectil", "muestra cuánto daño hace un proyectil en su nametag", true));
@@ -0,0 +1,255 @@
package me.retucio.sputnik.module.modules.render;
import com.github.retucio.neutrino.EventListener;
import com.mojang.blaze3d.vertex.PoseStack;
import me.retucio.sputnik.event.input.KeyEvent;
import me.retucio.sputnik.event.render.RenderHeldItemEvent;
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.KeySetting;
import me.retucio.sputnik.module.setting.settings.NumberSetting;
import net.minecraft.world.InteractionHand;
import org.joml.Quaternionf;
import org.lwjgl.glfw.GLFW;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Stylish extends Module {
private final KeySetting key = sgGeneral.add(new KeySetting(
"tecla", "tecla a pulsar para hacer el truco",
GLFW.GLFW_KEY_Y
));
private final EnumSetting<TrickType> trick = sgGeneral.add(new EnumSetting<>(
"truco", "qué truco hacer al pulsar la tecla",
TrickType.class, TrickType.SPIN
));
private final BooleanSetting comboMode = sgGeneral.add(new BooleanSetting(
"combo", "encadena varios trucos distintos en una sola pulsación",
false
));
private final NumberSetting comboLength = sgGeneral.add(new NumberSetting(
"trucos por combo", "cuántos trucos encadenar si el combo está activado",
3, 2, 6, 1
)).visibility(comboMode::getValue);
private final NumberSetting speed = sgGeneral.add(new NumberSetting(
"velocidad", "velocidad de giro (grados/seg)",
360, 30, 2000, 1
));
private final NumberSetting spins = sgGeneral.add(new NumberSetting(
"vueltas", "cuantas vueltas completas da por truco",
1, 1, 5, 1
));
private final EnumSetting<RotateDirection> dir = sgGeneral.add(new EnumSetting<>(
"dirección", "dirección a rotar el ítem",
RotateDirection.class, RotateDirection.COUNTER_CLOCKWISE
));
private final EnumSetting<Hand> hand = sgGeneral.add(new EnumSetting<>(
"mano", "en qué mano(s) hacerlo",
Hand.class, Hand.MAIN_HAND
));
private final BooleanSetting easing = sgGeneral.add(new BooleanSetting(
"suavizado", "usa una curva de aceleración/desaceleración en vez de velocidad lineal",
true
));
private final NumberSetting cooldown = sgGeneral.add(new NumberSetting(
"cooldown", "tiempo mínimo en ms entre activaciones",
150, 0, 2000, 10
));
// estado de anim.
private boolean spinning = false;
private float progressDegrees = 0f;
private long lastTimeNanos = 0L;
private long lastTriggerMillis = 0L;
private final List<TrickType> queue = new ArrayList<>();
private int queueIndex = 0;
private final Random random = new Random();
public Stylish() {
super("estiloso", "haz truquitos con items en las manos", Category.RENDER);
}
@EventListener
private void onKey(KeyEvent event) {
if (event.getKey() != key.getValue()) return;
if (event.getAction() != GLFW.GLFW_PRESS) return;
if (spinning) return;
long now = System.currentTimeMillis();
if (now - lastTriggerMillis < cooldown.getIntValue()) return;
lastTriggerMillis = now;
buildQueue();
startNextTrick();
}
private void buildQueue() {
queue.clear();
queueIndex = 0;
if (!comboMode.getValue()) {
queue.add(resolveTrick(trick.getValue()));
return;
}
int amount = comboLength.getIntValue();
for (int i = 0; i < amount; i++) {
queue.add(resolveTrick(TrickType.RANDOM));
}
}
private TrickType resolveTrick(TrickType requested) {
if (requested != TrickType.RANDOM) return requested;
TrickType[] real = {
TrickType.SPIN, TrickType.FLIP, TrickType.ROLL,
TrickType.TWIRL, TrickType.WAVE, TrickType.POP, TrickType.THROW_CATCH
};
return real[random.nextInt(real.length)];
}
private void startNextTrick() {
if (queueIndex >= queue.size()) {
spinning = false;
return;
}
spinning = true;
progressDegrees = 0f;
lastTimeNanos = System.nanoTime();
}
@EventListener
private void onRenderHeldItem(RenderHeldItemEvent event) {
if (!spinning) return;
if ((event.getHand() == InteractionHand.MAIN_HAND && hand.is(Hand.OFF_HAND))
|| (event.getHand() == InteractionHand.OFF_HAND && hand.is(Hand.MAIN_HAND))
) {
return;
}
PoseStack matrices = event.getMatrices();
long now = System.nanoTime();
float delta = (now - lastTimeNanos) / 1_000_000_000f;
lastTimeNanos = now;
float target = 360.0f * spins.getIntValue();
progressDegrees += speed.getFloatValue() * delta;
boolean finished = progressDegrees >= target;
if (finished) progressDegrees = target;
float rawFraction = progressDegrees / target; // 0..1
float fraction = easing.getValue() ? easeInOutCubic(rawFraction) : rawFraction;
TrickType current = queue.get(queueIndex);
applyTrick(current, matrices, fraction);
if (finished) {
queueIndex++;
if (queueIndex < queue.size()) {
startNextTrick();
} else {
spinning = false;
}
}
}
private void applyTrick(TrickType type, PoseStack matrices, float fraction) {
float directionSign = dir.getValue() == RotateDirection.CLOCKWISE ? -1f : 1f;
float degrees = fraction * 360.0f * spins.getIntValue();
float angleRad = (float) Math.toRadians(degrees * directionSign);
switch (type) {
case SPIN -> matrices.mulPose(new Quaternionf().rotationZ(angleRad));
case FLIP -> matrices.mulPose(new Quaternionf().rotationX(angleRad));
case ROLL -> matrices.mulPose(new Quaternionf().rotationY(angleRad));
case TWIRL -> {
// combina spin + flip para un giro más aparatoso
matrices.mulPose(new Quaternionf().rotationZ(angleRad));
matrices.mulPose(new Quaternionf().rotationX(angleRad * 0.5f));
}
case WAVE -> {
// bamboleo tipo saludo, sin vuelta completa
float waveAngle = (float) Math.sin(fraction * Math.PI * spins.getIntValue()) * 25f;
matrices.mulPose(new Quaternionf().rotationZ((float) Math.toRadians(waveAngle * directionSign)));
}
case POP -> {
// pequeño pulso de escala, como si el ítem "respirara"
float scalePulse = 1f + (float) Math.sin(fraction * Math.PI) * 0.25f;
matrices.scale(scalePulse, scalePulse, scalePulse);
matrices.mulPose(new Quaternionf().rotationZ(angleRad * 0.3f));
}
case THROW_CATCH -> {
// el ítem "sube", gira en el aire y "cae" de vuelta
float height = (float) Math.sin(fraction * Math.PI) * 0.35f;
matrices.translate(0f, height, 0f);
matrices.mulPose(new Quaternionf().rotationX(angleRad * 2f));
}
case RANDOM -> {
// no debería llegar aquí, resolveTrick lo reemplaza antes
matrices.mulPose(new Quaternionf().rotationZ(angleRad));
}
}
}
private float easeInOutCubic(float t) {
return t < 0.5f
? 4f * t * t * t
: 1f - (float) Math.pow(-2f * t + 2f, 3) / 2f;
}
private enum TrickType {
SPIN("giro"),
FLIP("voltereta"),
ROLL("balanceo"),
TWIRL("giro doble"),
WAVE("saludo"),
POP("pulso"),
THROW_CATCH("lanzar y coger"),
RANDOM("aleatorio");
private final String name;
TrickType(String name) { this.name = name; }
@Override public String toString() { return name; }
}
private enum RotateDirection {
CLOCKWISE("sentido horario"),
COUNTER_CLOCKWISE("sentido antihorario");
private final String name;
RotateDirection(String name) { this.name = name; }
@Override public String toString() { return name; }
}
private enum Hand {
MAIN_HAND("mano principal"),
OFF_HAND("mano secundaria");
private final String name;
Hand(String name) { this.name = name; }
@Override public String toString() { return name; }
}
}
@@ -4,6 +4,8 @@ import com.github.retucio.neutrino.EventListener;
import me.retucio.sputnik.event.render.Render3DEvent; import me.retucio.sputnik.event.render.Render3DEvent;
import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Category;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.camera.Freecam;
import me.retucio.sputnik.module.setting.SettingGroup; import me.retucio.sputnik.module.setting.SettingGroup;
import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.BooleanSetting;
import me.retucio.sputnik.module.setting.settings.ColorSetting; import me.retucio.sputnik.module.setting.settings.ColorSetting;
@@ -46,7 +48,7 @@ public class Tracers extends Module {
private final BooleanSetting self = sgGeneral.add(new BooleanSetting( private final BooleanSetting self = sgGeneral.add(new BooleanSetting(
"uno mismo", "uno mismo",
"apuntarse a uno mismo en cámara libre o así", "apuntarse a uno mismo en cámara libre",
true true
)); ));
@@ -105,6 +107,7 @@ public class Tracers extends Module {
private Color getColor(Entity entity) { private Color getColor(Entity entity) {
if (!entities.isEnabled(entity.getType())) return null; if (!entities.isEnabled(entity.getType())) return null;
if (!self.getValue() && mc.player == entity) return null; if (!self.getValue() && mc.player == entity) return null;
if (self.getValue() && mc.player == entity && !ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled()) return null;
if (entity instanceof Player) return playerColor.getValue(); if (entity instanceof Player) return playerColor.getValue();
return switch (entity.getType().getCategory()) { return switch (entity.getType().getCategory()) {
@@ -0,0 +1,484 @@
package me.retucio.sputnik.module.modules.world;
import com.github.retucio.neutrino.EventListener;
import me.retucio.sputnik.event.input.MouseClickEvent;
import me.retucio.sputnik.event.interact.AttackBlockEvent;
import me.retucio.sputnik.event.network.PacketEvent;
import me.retucio.sputnik.event.render.Render3DEvent;
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.ColorSetting;
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.ChatUtil;
import me.retucio.sputnik.util.InventoryUtil;
import me.retucio.sputnik.util.Lists;
import me.retucio.sputnik.util.MiscUtil;
import me.retucio.sputnik.util.RotationUtil;
import me.retucio.sputnik.util.render.RenderUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.Tool;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.lwjgl.glfw.GLFW;
import java.awt.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class AutoMine extends Module {
private final SettingGroup sgBlocks = addSg(new SettingGroup("bloques", true));
private final SettingGroup sgRender = addSg(new SettingGroup("renderizado", true));
private final EnumSetting<SelectionMode> mode = sgGeneral.add(new EnumSetting<>(
"modo de selección",
"cómo seleccionar los bloques a minar",
SelectionMode.class,
SelectionMode.INDIVIDUAL
));
private final NumberSetting maxBlocks = sgGeneral.add(new NumberSetting(
"límite de bloques",
"cantidad máxima de bloques a seleccionar de una vez (caja / flood)",
256,
1,
4096,
1
));
private final NumberSetting retryTime = sgGeneral.add(new NumberSetting(
"delay",
"delay entre reintentos de minado",
30,
0,
1000,
1
));
private final BooleanSetting cancelOutOfReach = sgGeneral.add(new BooleanSetting(
"cancelar fuera de alcance",
"cancelar aquellos paquetes que intenten romper bloques fuera del alcance del jugador",
true
));
private final BooleanSetting autoTool = sgGeneral.add(new BooleanSetting(
"auto herramienta",
"cambiar automáticamente a la herramienta más rápida antes de minar cada bloque",
true
));
private final BooleanSetting dontBreak = sgGeneral.add(new BooleanSetting(
"no romper pico",
"evita romper la herramienta seleccionada",
true
));
private final EnumSetting<RotateMode> rotate = sgGeneral.add(new EnumSetting<>(
"rotar",
"rotar al minar bloques mediante el módulo",
RotateMode.class, RotateMode.NONE
));
private final NumberSetting packetLimiter = sgGeneral.add(new NumberSetting(
"limitar paquetes",
"limita la cantidad de paquetes enviados en un segundo (0 para desactivar)",
15000, 0, 30000, 100
));
private final ListSetting<Block> blacklist = sgBlocks.add(new ListSetting<>(
"lista negra",
"bloques a excluir de la selección",
Lists.blockList,
Lists.allFalse(Lists.blockList),
Lists.blockNames
));
private final BooleanSetting render = sgRender.add(new BooleanSetting(
"renderizar",
"renderizar un contorno alrededor de los bloques que están siendo minados",
true
));
private final ColorSetting color = sgRender.add(new ColorSetting(
"color",
"color del contorno renderizado",
new Color(0, 255, 0, 100),
false
));
private final ColorSetting pendingColor = sgRender.add(new ColorSetting(
"color de selección pendiente",
"color del contorno de la primera esquina, en modo caja, mientras se espera la segunda",
new Color(255, 255, 0, 100),
false
));
private final NumberSetting lineWidth = sgRender.add(new NumberSetting(
"grosor",
"grosor de las líneas del contorno",
2,
0.1,
10,
0.1
));
private final List<MiningBlock> miningBlocks = new ArrayList<>();
private BlockPos pendingCorner = null;
private int packetCount = 0;
private int tickCount = 0;
public AutoMine() {
super(
"auto minado",
"selecciona un área o bloques individuales para minarlos automáticamente",
Category.WORLD
);
render.onUpdate(v -> {
color.visibility(v);
pendingColor.visibility(v);
lineWidth.visibility(v);
});
}
@Override
public void onDisable() {
miningBlocks.clear();
pendingCorner = null;
packetCount = 0;
tickCount = 0;
super.onDisable();
}
@Override
public void onTick() {
if (mc.player == null || mc.level == null || mc.gameMode == null) return;
tickCount++;
if (tickCount % 20 == 0) {
tickCount = 0;
packetCount = 0;
}
if (miningBlocks.isEmpty()) return;
// se limpian bloques ya rotos, o que fueron blacklisteados después de seleccionarse
Iterator<MiningBlock> iterator = miningBlocks.iterator();
while (iterator.hasNext()) {
MiningBlock block = iterator.next();
BlockState state = mc.level.getBlockState(block.pos);
if (state.isAir() || blacklist.isEnabled(state.getBlock())) {
iterator.remove();
}
}
for (MiningBlock block : miningBlocks) {
processBlock(block);
}
}
@EventListener
private void onClick(MouseClickEvent event) {
if (mc.gui.screen() != null) return;
if (mc.level == null || mc.hitResult == null) return;
if (event.getAction() != GLFW.GLFW_PRESS) return;
if (event.getButton() != GLFW.GLFW_MOUSE_BUTTON_1) return;
BlockHitResult bhr;
if (mc.hitResult.getType() == HitResult.Type.BLOCK) {
bhr = (BlockHitResult) mc.hitResult;
} else {
return;
}
event.cancel();
BlockPos pos = bhr.getBlockPos();
Direction dir = bhr.getDirection();
Block block = mc.level.getBlockState(pos).getBlock();
// clicar un bloque ya seleccionado lo quita de la selección, sea cual sea el modo
MiningBlock existing = getMiningBlock(pos);
if (existing != null) {
miningBlocks.remove(existing);
return;
}
if (blacklist.isEnabled(block)) {
ChatUtil.warn(Component.translatable("sputnik.module.autominado.blacklisted"));
return;
}
switch (mode.getValue()) {
case INDIVIDUAL -> tryAddBlock(pos, dir);
case BOX -> handleBoxSelection(pos, dir);
case FLOOD_FILL -> handleFloodFill(pos, dir);
}
}
@EventListener
private void onRenderWorld(Render3DEvent event) {
if (!render.getValue()) return;
for (MiningBlock block : miningBlocks) {
block.render(event);
}
if (pendingCorner != null) {
renderOutline(event, pendingCorner, pendingColor.getValue());
}
}
@EventListener
private void onPacketSend(PacketEvent.Send event) {
if (packetLimiter.getValue() <= 0) return;
if (packetCount > packetLimiter.getIntValue()) {
event.cancel();
return;
}
packetCount++;
}
private void handleBoxSelection(BlockPos pos, Direction dir) {
if (pendingCorner == null) {
pendingCorner = pos;
ChatUtil.info(Component.translatable("sputnik.module.autominado.cornerselected"));
return;
}
BlockPos corner1 = pendingCorner;
BlockPos corner2 = pos;
pendingCorner = null;
int minX = Math.min(corner1.getX(), corner2.getX());
int maxX = Math.max(corner1.getX(), corner2.getX());
int minY = Math.min(corner1.getY(), corner2.getY());
int maxY = Math.max(corner1.getY(), corner2.getY());
int minZ = Math.min(corner1.getZ(), corner2.getZ());
int maxZ = Math.max(corner1.getZ(), corner2.getZ());
int added = 0;
int limit = maxBlocks.getIntValue();
outer:
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
if (added >= limit) break outer;
if (tryAddBlock(new BlockPos(x, y, z), dir)) added++;
}
}
}
ChatUtil.info(Component.translatable("sputnik.module.autominado.boxselected", added));
}
private void handleFloodFill(BlockPos origin, Direction dir) {
if (mc.level == null) return;
Block target = mc.level.getBlockState(origin).getBlock();
Set<BlockPos> visited = new HashSet<>();
Deque<BlockPos> queue = new ArrayDeque<>();
queue.add(origin);
visited.add(origin);
int added = 0;
int limit = maxBlocks.getIntValue();
while (!queue.isEmpty() && added < limit) {
BlockPos current = queue.poll();
if (mc.level.getBlockState(current).getBlock() != target) continue;
if (tryAddBlock(current, dir)) added++;
for (Direction d : Direction.values()) {
BlockPos neighbor = current.relative(d);
if (visited.contains(neighbor)) continue;
visited.add(neighbor);
if (mc.level.getBlockState(neighbor).getBlock() == target) {
queue.add(neighbor);
}
}
}
ChatUtil.info(Component.translatable("sputnik.module.autominado.floodfilled", added));
}
// false si el bloque no se pudo (o no debía) agregar: aire, ya seleccionado o en la lista negra
private boolean tryAddBlock(BlockPos pos, Direction dir) {
if (mc.level == null) return false;
if (mc.level.getBlockState(pos).isAir()) return false;
if (getMiningBlock(pos) != null) return false;
if (blacklist.isEnabled(mc.level.getBlockState(pos).getBlock())) return false;
miningBlocks.add(new MiningBlock(pos, dir));
return true;
}
private boolean processBlock(MiningBlock block) {
if (mc.level.getBlockState(block.pos).isAir()) return false;
if (!block.mining) {
return block.mine();
} else if (block.shouldRetry()) {
block.startTime = System.currentTimeMillis();
block.mining = false;
return block.mine();
}
return false;
}
private MiningBlock getMiningBlock(BlockPos pos) {
for (MiningBlock block : miningBlocks) {
if (block.pos.equals(pos)) return block;
}
return null;
}
// básicamente AutoTool::selectFastestTool, pero apuntado a un bloque puntual en vez del raycast bajo la mira
private void switchToBestTool(BlockPos pos) {
if (mc.player == null || mc.level == null) return;
BlockState state = mc.level.getBlockState(pos);
List<ItemStack> tools = InventoryUtil.findAllStacks(stack -> stack.has(DataComponents.TOOL));
Map<Float, ItemStack> speeds = new HashMap<>();
for (ItemStack tool : tools) {
int slot = mc.player.getInventory().findSlotMatchingItem(tool);
if (!Inventory.isHotbarSlot(slot)) continue;
Tool toolComponent = tool.get(DataComponents.TOOL);
if (toolComponent != null) {
speeds.put(toolComponent.getMiningSpeed(state), tool);
}
}
if (speeds.isEmpty()) return;
Float fastestSpeed = MiscUtil.getHighest(speeds.keySet().stream().toList());
ItemStack fastestTool = speeds.get(fastestSpeed);
int slot = mc.player.getInventory().findSlotMatchingItem(fastestTool);
if (slot != -1) mc.player.getInventory().setSelectedSlot(slot);
}
private void renderOutline(Render3DEvent event, BlockPos pos, Color renderColor) {
VoxelShape shape = mc.level.getBlockState(pos).getShape(mc.level, pos);
if (shape.isEmpty()) return;
RenderUtil.drawVoxelShapeOutline(
event.getMatrices(),
shape,
pos,
renderColor,
lineWidth.getFloatValue(),
false
);
}
private RotationUtil.Mode getRotationMode() {
return switch (rotate.getValue()) {
case CLIENT, BOTH -> RotationUtil.Mode.CLIENT;
case SERVER -> RotationUtil.Mode.SILENT;
case NONE -> null;
};
}
private class MiningBlock {
BlockPos pos;
Direction dir;
boolean mining = false;
long startTime;
public MiningBlock(BlockPos pos, Direction dir) {
this.pos = pos;
this.dir = dir;
this.startTime = System.currentTimeMillis();
}
public boolean mine() {
if (cancelOutOfReach.getValue()
&& mc.player.position().distanceToSqr(Vec3.atLowerCornerOf(pos)) > Math.pow(mc.player.blockInteractionRange(), 2)) {
return false;
}
if (dontBreak.getValue()
&& mc.player.isHolding(ItemStack::isDamageableItem)
&& mc.player.getMainHandItem().getMaxDamage() - mc.player.getMainHandItem().getDamageValue() <= 1) {
ChatUtil.warn(Component.translatable("sputnik.module.autominado.pickbreaking"));
toggle();
return false;
}
if (autoTool.getValue()) {
switchToBestTool(pos);
}
Runnable mine = () -> {
mc.gameMode.startPrediction(mc.level, sequence ->
new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, dir, sequence));
mc.gameMode.startPrediction(mc.level, sequence ->
new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, dir, sequence));
};
RotationUtil.Mode rotation = getRotationMode();
if (rotation == null) mine.run();
else RotationUtil.lookAt(RotationUtil.NORMAL, Vec3.atLowerCornerOf(pos), 0, rotation, mine);
mining = true;
return true;
}
public void render(Render3DEvent event) {
renderOutline(event, pos, color.getValue());
}
public boolean shouldRetry() {
return mining && (System.currentTimeMillis() - startTime >= retryTime.getValue());
}
}
private enum SelectionMode {
INDIVIDUAL("individual"),
BOX("caja"),
FLOOD_FILL("inundación");
private final String name;
SelectionMode(String name) { this.name = name; }
@Override public String toString() { return name; }
}
private enum RotateMode {
CLIENT("cámara"),
SERVER("mediante paquetes"),
BOTH("ambos"),
NONE("no");
private final String name;
RotateMode(String name) { this.name = name; }
@Override public String toString() { return name; }
}
}
@@ -6,12 +6,14 @@ import me.retucio.sputnik.event.input.MouseClickEvent;
import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Category;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.setting.settings.BooleanSetting; 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 me.retucio.sputnik.module.setting.settings.NumberSetting;
import me.retucio.sputnik.util.InventoryUtil; import me.retucio.sputnik.util.InventoryUtil;
import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.KeyUtil;
import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.MiscUtil;
import net.minecraft.core.component.DataComponents; import net.minecraft.core.component.DataComponents;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.Tool; import net.minecraft.world.item.component.Tool;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@@ -26,6 +28,11 @@ import java.util.Map;
public class AutoTool extends Module { public class AutoTool extends Module {
private final EnumSetting<AutoToolMode> mode = sgGeneral.add(new EnumSetting<>(
"modo", "de qué manera ejecutar el módulo",
AutoToolMode.class, AutoToolMode.ON_CLICK
));
private final NumberSetting delaySetting = sgGeneral.add(new NumberSetting( private final NumberSetting delaySetting = sgGeneral.add(new NumberSetting(
"delay", "delay",
"delay al cambiar de herramienta", "delay al cambiar de herramienta",
@@ -86,6 +93,11 @@ public class AutoTool extends Module {
@Override @Override
public void onTick() { public void onTick() {
if (mc.player == null) return; if (mc.player == null) return;
if (mc.gui.screen() != null) return;
if (mode.is(AutoToolMode.ON_TICK) && mc.options.keyAttack.isDown()) {
handle(KeyUtil.getKey(mc.options.keyAttack), GLFW.GLFW_PRESS);
}
if (startedMining && delaySetting.getIntValue() > 0) { if (startedMining && delaySetting.getIntValue() > 0) {
delay++; delay++;
@@ -165,10 +177,12 @@ public class AutoTool extends Module {
BlockState state = mc.level.getBlockState(bhr.getBlockPos()); BlockState state = mc.level.getBlockState(bhr.getBlockPos());
List<ItemStack> tools = InventoryUtil.findAllStacks(stack -> stack.has(DataComponents.TOOL)); List<ItemStack> tools = InventoryUtil.findAllStacks(stack -> stack.has(DataComponents.TOOL));
if (tools.isEmpty()) return;
Map<Float, ItemStack> speeds = new HashMap<>(); Map<Float, ItemStack> speeds = new HashMap<>();
for (ItemStack tool : tools) { for (ItemStack tool : tools) {
int slot = mc.player.getInventory().findSlotMatchingItem(tool);
if (!Inventory.isHotbarSlot(slot)) continue; // skip anything outside the hotbar
Tool toolComponent = tool.get(DataComponents.TOOL); Tool toolComponent = tool.get(DataComponents.TOOL);
if (toolComponent != null) { if (toolComponent != null) {
speeds.put(toolComponent.getMiningSpeed(state), tool); speeds.put(toolComponent.getMiningSpeed(state), tool);
@@ -193,4 +207,13 @@ public class AutoTool extends Module {
finishedMining = false; finishedMining = false;
switchBackDelay = 0; switchBackDelay = 0;
} }
private enum AutoToolMode {
ON_TICK("cada tick"),
ON_CLICK("cada click");
private final String name;
AutoToolMode(String name) { this.name = name; }
@Override public String toString() { return name; }
}
} }
@@ -3,6 +3,7 @@ package me.retucio.sputnik.module.modules.world;
import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Category;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.util.EntityUtil; import me.retucio.sputnik.util.EntityUtil;
import me.retucio.sputnik.util.RotationUtil;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.entity.monster.EnderMan;
@@ -52,10 +53,6 @@ public class Racist extends Module {
} }
private void lookAtEnderman(EnderMan enderman) { private void lookAtEnderman(EnderMan enderman) {
double yaw = EntityUtil.getYaw(enderman); RotationUtil.lookAt(RotationUtil.LOW, enderman, EntityUtil.Target.HEAD, 0, RotationUtil.Mode.CLIENT);
double pitch = EntityUtil.getPitch(enderman, EntityUtil.Target.HEAD);
mc.player.setYRot((float) yaw);
mc.player.setXRot((float) pitch);
} }
} }
@@ -143,7 +143,8 @@ public abstract class Setting<T> {
public void fireUpdateEvent() { public void fireUpdateEvent() {
Sputnik.EVENT_BUS.post( Sputnik.EVENT_BUS.post(
new UpdateSettingEvent(this, getModule().shouldSaveSettings())); new UpdateSettingEvent(this, getModule().shouldSaveSettings())
);
} }
public void onUpdate(Consumer<T> listener) { public void onUpdate(Consumer<T> listener) {
Loaded 100 of 131 files, more files were not shown because too many files have changed in this diff. Show more