Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f816381c3 | ||
|
|
36c38bdf02 | ||
|
|
a6a6f1261e | ||
|
|
8891a57c7c | ||
|
|
e358b142c6 | ||
|
|
e7d872d75e | ||
|
|
589279342d | ||
|
|
054702999b |
No files matched your search
@@ -39,4 +39,12 @@ replay_*.log
|
||||
*.hprof
|
||||
*.jfr
|
||||
|
||||
todo.txt
|
||||
# otros
|
||||
|
||||
todo.txt
|
||||
test.java
|
||||
cambios.md
|
||||
# no está terminado
|
||||
src/main/java/me/retucio/camtweaks/module/modules/TooltipsPlus.java
|
||||
|
||||
remappedSrc/
|
||||
@@ -1,6 +1,6 @@
|
||||
# jenny's mod 2 100% real
|
||||
|
||||
mod para Minecraft Fabric 1.21.6 que añade algunas cosas QOL, mayormente relacionadas a la cámara.
|
||||
mod para Minecraft Fabric 1.21.10 que añade algunas cosas QOL, mayormente relacionadas a la cámara.
|
||||
|
||||
## instalación
|
||||
|
||||
@@ -10,19 +10,25 @@ mod para Minecraft Fabric 1.21.6 que añade algunas cosas QOL, mayormente relaci
|
||||
3. descargar el .jar
|
||||
4. moverlo a tu directorio de mods (probablemente `%appdata%/.minecraft/mods`)
|
||||
|
||||
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod
|
||||
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `1.21.10`; Fabric `0.138.3`)
|
||||
es posible que haya problemas al usarlo junto a otros mods, especialmente junto a otros clientes, pues pueden conflictar entre ellos.
|
||||
|
||||
### para frikis de 200 de iq
|
||||
1. clona el respositorio
|
||||
2. `gradlew build` para Windows o `chmod +x gradlew` + `./gradlew build` para Linux
|
||||
3. el resultado estará en `/build/libs` (el que no lleva "sources" en el nombre)
|
||||
1. clona el respositorio (`git clone https://github.com/retuci0/camera-tweaks`)
|
||||
2. entra al directorio del repositorio (`cd camera-tweaks`)
|
||||
3. `gradlew build` para Windows o `chmod +x gradlew` + `./gradlew build` para Linux (Mac es Linux)
|
||||
4. el resultado estará en `/build/libs/camtweaks-X.X.jar` (el que no lleva "sources" en el nombre)
|
||||
|
||||
## uso
|
||||
|
||||
`shift derecho` por defecto para abrir la interfaz
|
||||
|
||||
`pág. arriba` por defecto para abrir el editor del hud
|
||||
|
||||
`$` como prefijo por defecto para comandos (se autocompletan)
|
||||
|
||||
algunos módulos tienen teclas asignadas por defecto, asígnales `ESC` para desactivar sus atajos de teclado
|
||||
|
||||
## interfaz
|
||||
|
||||
- clic izquierdo para activar / desactivar módulos
|
||||
@@ -37,14 +43,17 @@ asegúrate de tener una version de Minecraft y Fabric compatibles con el mod
|
||||
- shift mientras pasas el puntero por encima de un ajuste de modos para ver los modos disponibles
|
||||
- clic derecho para ciclar hacia atrás en ajustes de modo
|
||||
- usa la rueda del ratón para mover la interfaz verticalmente
|
||||
- shift + rueda del ratón para mover todos los marcos a un rango visible en la pantalla
|
||||
|
||||
## capturas
|
||||
|
||||
<img src="screenshots/2025-08-19_23.20.15.png" alt="captura 1 (foto vieja)">
|
||||
<img src="screenshots/2025-08-22_00.18.51.png" alt="captura 2 (interfaz)">
|
||||
<img src="screenshots/2025-08-22_00.19.11.png" alt="captura 3 (interfaz)">
|
||||
<img src="screenshots/2025-08-22_00.22.41.png" alt="captura 5 (comandos)">
|
||||
<img src="screenshots/2025-08-27_18.44.41.png" alt="captura 6 (nametags & apilar bossbars)">
|
||||
<img src="screenshots/ui.png" alt="interfaz">
|
||||
<img src="screenshots/nametags.png" alt="nametags mostrando daño de un tridente">
|
||||
<img src="screenshots/chatplus.png" alt="chatplus y capturas en uso">
|
||||
<img src="screenshots/crits.png" alt="críticos">
|
||||
<img src="screenshots/fullbright.png" alt="fullbright en modo gamma cambiando el color de los shaders">
|
||||
<img src="screenshots/hud.png" alt="HUD">
|
||||
<img src="screenshots/hudeditor.png" alt="editor de HUD">
|
||||
|
||||
## contibuciones
|
||||
|
||||
@@ -52,4 +61,8 @@ sí por favor
|
||||
|
||||
## licencia
|
||||
|
||||
no sé, haz lo que quieras con esto, es puta basura xd
|
||||
no sé, haz lo que quieras con esto, es puta basura xd
|
||||
|
||||
aunque estaría guay que acreditases
|
||||
|
||||
pero bueno
|
||||
@@ -29,6 +29,10 @@ dependencies {
|
||||
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/camtweaks.accesswidener")
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# v1.5
|
||||
|
||||
## novedades
|
||||
|
||||
sigo vivo (creo)
|
||||
|
||||
### adiciones
|
||||
|
||||
- editor de hud bastante básico pero por lo general funcional (`pág. arriba` por defecto). viene con muchos bugs, ojalá me caiga un rayo.
|
||||
|
||||
### arreglos / mejoras
|
||||
|
||||
- ya no salta un error al hacer una captura con los módulos `capturas de pantalla` y `chat plus` activos
|
||||
- ahora la telemetría (abuso de privacidad al usuario de microshit) está desactivado por huevos. si quieres activarlo te jodes.
|
||||
- ahora ya no puedes abrir interfaces del mod si no estás en un mundo
|
||||
- mejorada la seguridad de algunas operaciones
|
||||
|
||||
## problemas reconocidos
|
||||
|
||||
- muchos, pero repórtalos en la página de problemas si quieres para que queden bien registrados
|
||||
@@ -1,4 +1,5 @@
|
||||
meteor client dev team
|
||||
oyvey client (1.21 port by mioclient)
|
||||
lennyboi (youtube)
|
||||
packbar by cattyn on github
|
||||
packbar by cattyn on github
|
||||
shotify mod
|
||||
@@ -4,15 +4,15 @@ org.gradle.parallel=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.21.6
|
||||
yarn_mappings=1.21.6+build.1
|
||||
loader_version=0.17.2
|
||||
minecraft_version=1.21.10
|
||||
yarn_mappings=1.21.10+build.2
|
||||
loader_version=0.17.3
|
||||
loom_version=1.11-SNAPSHOT
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.1
|
||||
mod_version=1.5
|
||||
maven_group=me.retucio
|
||||
archives_base_name=camtweaks
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.128.2+1.21.6
|
||||
fabric_version=0.135.0+1.21.10
|
||||
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 973 KiB |
|
Before Width: | Height: | Size: 1005 KiB |
|
Before Width: | Height: | Size: 942 KiB |
|
Before Width: | Height: | Size: 560 KiB |
|
Before Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 864 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 566 KiB |
|
After Width: | Height: | Size: 469 KiB |
|
After Width: | Height: | Size: 243 KiB |
|
After Width: | Height: | Size: 506 KiB |
|
After Width: | Height: | Size: 691 KiB |
@@ -10,17 +10,25 @@ import me.retucio.camtweaks.event.EventBus;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.ShutdownEvent;
|
||||
|
||||
import me.retucio.camtweaks.event.events.camtweaks.LoadClickGUIEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.LoadCommandManagerEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.LoadModuleManagerEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
|
||||
import me.retucio.camtweaks.module.modules.HUD;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.HudEditorScreen;
|
||||
import me.retucio.camtweaks.ui.HudRenderer;
|
||||
import me.retucio.camtweaks.ui.buttons.BindButton;
|
||||
import me.retucio.camtweaks.ui.buttons.SettingButton;
|
||||
import me.retucio.camtweaks.ui.buttons.TextButton;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import me.retucio.camtweaks.util.Lists;
|
||||
import me.retucio.camtweaks.util.MiscUtil;
|
||||
|
||||
|
||||
@@ -29,6 +37,7 @@ import net.fabricmc.api.ClientModInitializer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -46,20 +55,33 @@ public class CameraTweaks implements ClientModInitializer {
|
||||
public static MinecraftClient mc;
|
||||
|
||||
private Screen prevScreen;
|
||||
private boolean settingsApplied = false;
|
||||
public boolean settingsApplied = false;
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// por algún motivo aunque lo añada a los args de la JVM sigue siendo true a menos que haga esto??? puta vida
|
||||
System.setProperty("java.awt.headless", "false");
|
||||
|
||||
mc = MinecraftClient.getInstance();
|
||||
|
||||
ModuleManager.INSTANCE = new ModuleManager(EVENT_BUS);
|
||||
CommandManager.INSTANCE = new CommandManager();
|
||||
ClickGUI.INSTANCE = new ClickGUI();
|
||||
|
||||
ConfigManager.load();
|
||||
|
||||
EVENT_BUS.register(this);
|
||||
EVENT_BUS.register(MiscUtil.class);
|
||||
EVENT_BUS.register(ChatUtil.class);
|
||||
EVENT_BUS.register(HudRenderer.class);
|
||||
|
||||
Lists.init();
|
||||
|
||||
ModuleManager.INSTANCE = new ModuleManager(EVENT_BUS);
|
||||
EVENT_BUS.post(new LoadModuleManagerEvent());
|
||||
|
||||
CommandManager.INSTANCE = new CommandManager();
|
||||
EVENT_BUS.post(new LoadCommandManagerEvent());
|
||||
|
||||
ClickGUI.INSTANCE = new ClickGUI();
|
||||
HudEditorScreen.INSTANCE = new HudEditorScreen();
|
||||
EVENT_BUS.post(new LoadClickGUIEvent());
|
||||
|
||||
ConfigManager.load();
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
ConfigManager.save();
|
||||
@@ -82,17 +104,21 @@ public class CameraTweaks implements ClientModInitializer {
|
||||
|
||||
// se ejecuta cada vez que se presiona una tecla
|
||||
public void onKeyPress(int key, int action) {
|
||||
if (key == GLFW.GLFW_KEY_F3) return; // prevenir activación de módulos al usar combinaciones de F3
|
||||
ModuleManager.INSTANCE.getEnabledModules().forEach(module -> module.onKey(key, action));
|
||||
|
||||
boolean anyFocused = isAnySettingButtonFocused();
|
||||
boolean anyFocused = isAnySettingButtonFocused() || ClickGUI.INSTANCE.getSearchBar().isFocused();
|
||||
ClickGUI.INSTANCE.setAnyFocused(anyFocused);
|
||||
|
||||
if (action == GLFW.GLFW_PRESS) {
|
||||
if (action != GLFW.GLFW_RELEASE) {
|
||||
if (BindCommand.onKeyPress(key)) return;
|
||||
if (action == GLFW.GLFW_PRESS) {
|
||||
handleModuleToggle(key, anyFocused);
|
||||
handleClickGUIKey(key, anyFocused);
|
||||
handleHudEditorKey(key, anyFocused);
|
||||
}
|
||||
handleSettingButtonsKey(key, action);
|
||||
handleModuleToggle(key, anyFocused);
|
||||
handleClickGUIKey(key, anyFocused);
|
||||
} else if (action == GLFW.GLFW_RELEASE && !anyFocused) {
|
||||
} else if (!anyFocused) {
|
||||
handleModuleRelease(key);
|
||||
}
|
||||
}
|
||||
@@ -132,12 +158,30 @@ public class CameraTweaks implements ClientModInitializer {
|
||||
|
||||
// maneja la lógica de apertura de la interfaz
|
||||
private void handleClickGUIKey(int key, boolean anyFocused) {
|
||||
if (key != ClickGUISettingsFrame.guiSettings.getKey() || anyFocused) return;
|
||||
if (key != ClientSettingsFrame.guiSettings.getKey() || anyFocused) return;
|
||||
if (!(mc != null && mc.world != null && mc.player != null)) return;
|
||||
|
||||
// al parecer esto hace que con la tecla de la interfaz puedas ir cambiando de splash text en la pantalla del título
|
||||
// pero me ha hecho gracia así que así se queda
|
||||
if (mc.currentScreen != ClickGUI.INSTANCE) {
|
||||
prevScreen = mc.currentScreen;
|
||||
mc.setScreen(ClickGUI.INSTANCE);
|
||||
} else {
|
||||
ClickGUI.INSTANCE.close();
|
||||
mc.setScreen(prevScreen);
|
||||
}
|
||||
}
|
||||
|
||||
// manejar la lógica de apertura del editor de elementos del hud, con la misma lógica que handleClickGUIKey()
|
||||
private void handleHudEditorKey(int key, boolean anyFocused) {
|
||||
if (key != ModuleManager.INSTANCE.getModuleByClass(HUD.class).editorKey.getKey() || anyFocused) return;
|
||||
if (!(mc != null && mc.world != null && mc.player != null)) return;
|
||||
|
||||
if (mc.currentScreen != HudEditorScreen.INSTANCE) {
|
||||
prevScreen = mc.currentScreen;
|
||||
mc.setScreen(HudEditorScreen.INSTANCE);
|
||||
} else {
|
||||
HudEditorScreen.INSTANCE.close();
|
||||
mc.setScreen(prevScreen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.command.CommandSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
// registro de comandos
|
||||
public class CommandManager {
|
||||
@@ -28,9 +29,12 @@ public class CommandManager {
|
||||
|
||||
public static void registerCommands() {
|
||||
addCommand(new BindCommand());
|
||||
addCommand(new CopyScreenshotCommand());
|
||||
// addCommand(new EnderChestCommand()); no funciona D:
|
||||
addCommand(new PeekCommand());
|
||||
addCommand(new PrefixCommand());
|
||||
addCommand(new PurgeCommand());
|
||||
addCommand(new SaveScreenshotCommand());
|
||||
addCommand(new SendCommand());
|
||||
addCommand(new ToggleCommand());
|
||||
|
||||
@@ -44,17 +48,17 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
public static void dispatch(String message) throws CommandSyntaxException {
|
||||
dispatcher.execute(message, mc.getNetworkHandler().getCommandSource());
|
||||
dispatcher.execute(message, Objects.requireNonNull(mc.getNetworkHandler()).getCommandSource());
|
||||
}
|
||||
|
||||
public static Command getCommandByName(String name) {
|
||||
for (Command command : commands) {
|
||||
if (command.getName().equals(name))
|
||||
return command;
|
||||
if (command.getName().equals(name)) return command;
|
||||
|
||||
for (String alias : command.getAliases())
|
||||
if (alias.equals(name))
|
||||
return command;
|
||||
if (alias.equals(name)) return command;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.ScreenshotPlus;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
// se usa principalmente para el módulo ScreenshotPlus, pero también se puede usar sin él supongo
|
||||
public class CopyScreenshotCommand extends Command {
|
||||
|
||||
public CopyScreenshotCommand() {
|
||||
super("copiarcaptura", "copia la captura más reciente al portapapeles");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(ctx -> {
|
||||
ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class);
|
||||
|
||||
if (screenshotPlus.getScreenshot() != null) mc.execute(screenshotPlus::copyScreenshot);
|
||||
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package me.retucio.camtweaks.command.commands;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -21,7 +21,7 @@ public class PrefixCommand extends Command {
|
||||
builder
|
||||
.then(argument("prefijo", StringArgumentType.word()).executes(ctx -> {
|
||||
String prefix = ctx.getArgument("prefijo", String.class);
|
||||
ClickGUISettingsFrame.guiSettings.commandPrefix.setValue(prefix);
|
||||
ClientSettingsFrame.guiSettings.commandPrefix.setValue(prefix);
|
||||
ChatUtil.info(Text.literal("prefijo cambiado a " + Formatting.AQUA + prefix));
|
||||
return SUCCESS;
|
||||
}));
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.util.interfaces.IChatHud;
|
||||
import net.minecraft.client.gui.hud.ChatHud;
|
||||
import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeCommand extends Command {
|
||||
|
||||
public PurgeCommand() {
|
||||
super("purgar", "elimina mensajes del chat", "purge");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.then(argument("cantidad", IntegerArgumentType.integer(1))
|
||||
.executes(context -> {
|
||||
int amount = IntegerArgumentType.getInteger(context, "cantidad");
|
||||
purgeMessages(amount);
|
||||
return 1;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private void purgeMessages(int amount) {
|
||||
ChatHud chatHud = mc.inGameHud.getChatHud();
|
||||
|
||||
synchronized (chatHud) {
|
||||
List<ChatHudLine.Visible> visibleMessages = ((IChatHud) chatHud).smegma$getVisibleMessages();
|
||||
int toRemove = Math.min(amount, visibleMessages.size());
|
||||
for (int i = 0; i < toRemove; i++)
|
||||
visibleMessages.removeFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.ScreenshotPlus;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// se usa principalmente para el módulo ScreenshotPlus, pero también se puede usar sin él supongo
|
||||
public class SaveScreenshotCommand extends Command {
|
||||
|
||||
public SaveScreenshotCommand() {
|
||||
super("guardarcaptura", "guarda localmente la captura más reciente");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(ctx -> {
|
||||
ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class);
|
||||
|
||||
mc.execute(() -> {
|
||||
if (screenshotPlus.getScreenshot() != null) {
|
||||
try {
|
||||
screenshotPlus.saveScreenshot();
|
||||
} catch (IOException e) {
|
||||
ChatUtil.error("no se pudo guardar la captura");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.*;
|
||||
import me.retucio.camtweaks.module.settings.*;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -27,19 +26,25 @@ public class ClientConfig {
|
||||
// nombre del frame -> FrameData (que contiene extended, x & y)
|
||||
public Map<String, FrameData> extendableFrames = new HashMap<>();
|
||||
|
||||
// id del elemento del hud -> posición (x, y)
|
||||
public Map<String, int[]> hudPositions = new HashMap<>();
|
||||
|
||||
// id del elemento del hud -> true: visible / false: no visible
|
||||
public Map<String, Boolean> hudVisibilities = new HashMap<>();
|
||||
|
||||
public ClientConfig() {
|
||||
EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onToggleModule(ToggleModuleEvent event) {
|
||||
ConfigManager.setModuleState(event.getModule());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SubscribeEvent
|
||||
public void onUpdateSetting(UpdateSettingEvent event) {
|
||||
if (mc == null) return;
|
||||
if (mc == null || !event.shouldSave()) return;
|
||||
|
||||
// guardar ajustes con su respectivo tipo de valor, en formato "nombreMódulo:nombreAjuste"
|
||||
Object value = null;
|
||||
@@ -49,6 +54,7 @@ public class ClientConfig {
|
||||
case KeySetting k: value = k.getKey(); break;
|
||||
case NumberSetting n: value = n.getValue(); break;
|
||||
case StringSetting s: value = s.getValue(); break;
|
||||
case ListSetting l: value = l.getValues(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,15 @@ import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.settings.*;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// se ocupa de guardar, cargar y aplicar ajustes
|
||||
// pues no me ha dado dolores de cabeza el coso este con los NPE de los cojones...
|
||||
@@ -69,8 +71,8 @@ public class ConfigManager {
|
||||
}
|
||||
});
|
||||
|
||||
ClickGUISettingsFrame.guiSettings.setEnabled(true);
|
||||
ClickGUISettingsFrame.guiSettings.getSettings().forEach(setting -> applySetting(ClickGUISettingsFrame.guiSettings, setting));
|
||||
ClientSettingsFrame.guiSettings.setEnabled(true);
|
||||
ClientSettingsFrame.guiSettings.getSettings().forEach(setting -> applySetting(ClientSettingsFrame.guiSettings, setting));
|
||||
|
||||
CameraTweaks.LOGGER.info("módulos encendidos cargados");
|
||||
CameraTweaks.LOGGER.info("ajustes de módulos cargados");
|
||||
@@ -90,6 +92,7 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
CameraTweaks.LOGGER.info("posiciones de frames cargadas");
|
||||
ClickGUI.INSTANCE.refreshListButtons();
|
||||
}
|
||||
|
||||
public static ClientConfig getConfig() {
|
||||
@@ -102,7 +105,7 @@ public class ConfigManager {
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setSetting(Setting setting, Object value) {
|
||||
public static void setSetting(AbstractSetting setting, Object value) {
|
||||
ensureConfig();
|
||||
config.settings.put(setting.getModule().getName() + ":" + setting.getName(), value);
|
||||
save();
|
||||
@@ -111,7 +114,7 @@ public class ConfigManager {
|
||||
public static void setFramePosition(SettingsFrame frame) {
|
||||
ensureConfig();
|
||||
config.settingsFrames.put(frame.module.getName(), new int[]{frame.x, frame.y});
|
||||
ConfigManager.save();
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setExtendableFrame(String key, ClientConfig.FrameData data) {
|
||||
@@ -120,7 +123,21 @@ public class ConfigManager {
|
||||
save();
|
||||
}
|
||||
|
||||
public static void applySetting(Module parent, Setting setting) {
|
||||
public static void setHudPosition(String id, int x, int y) {
|
||||
ensureConfig();
|
||||
config.hudPositions.put(id, new int[]{x, y});
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setHudVisibility(String id, Boolean visible) {
|
||||
ensureConfig();
|
||||
config.hudVisibilities.put(id, visible);
|
||||
save();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public static void applySetting(Module parent, AbstractSetting setting) {
|
||||
String id = parent.getName() + ":" + setting.getName();
|
||||
if (config.settings.containsKey(id)) {
|
||||
Object value = config.settings.get(id);
|
||||
@@ -131,7 +148,17 @@ public class ConfigManager {
|
||||
case NumberSetting n -> n.setValue((double) value);
|
||||
case StringSetting s -> s.setValue((String) value);
|
||||
case KeySetting k -> k.setKey(value instanceof Double val ? val.intValue() : (int) value);
|
||||
default -> {}
|
||||
case ListSetting l -> {
|
||||
if (value instanceof Map<?, ?> map) {
|
||||
Map<Object, Boolean> converted = new HashMap<>();
|
||||
for (Object option : l.getOptions()) {
|
||||
Object key = String.valueOf(option);
|
||||
Object bv = map.get(key);
|
||||
converted.put(option, bv instanceof Boolean b && b);
|
||||
}
|
||||
l.setValues(converted);
|
||||
}
|
||||
} default -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.retucio.camtweaks.event.events.camtweaks;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
public class LoadClickGUIEvent extends Event {}
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.retucio.camtweaks.event.events.camtweaks;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
public class LoadCommandManagerEvent extends Event {}
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.retucio.camtweaks.event.events.camtweaks;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
public class LoadModuleManagerEvent extends Event {}
|
||||
@@ -1,18 +1,28 @@
|
||||
package me.retucio.camtweaks.event.events.camtweaks;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import me.retucio.camtweaks.module.settings.Setting;
|
||||
import me.retucio.camtweaks.module.settings.AbstractSetting;
|
||||
|
||||
// se genera cada que se cambia el valor de un ajuste
|
||||
public class UpdateSettingEvent extends Event {
|
||||
|
||||
private final Setting setting;
|
||||
private final AbstractSetting setting;
|
||||
private boolean shouldSave;
|
||||
|
||||
public UpdateSettingEvent(Setting setting) {
|
||||
public UpdateSettingEvent(AbstractSetting setting, boolean shouldSave) {
|
||||
this.setting = setting;
|
||||
this.shouldSave = shouldSave;
|
||||
}
|
||||
|
||||
public Setting getSetting() {
|
||||
public AbstractSetting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
|
||||
public boolean shouldSave() {
|
||||
return shouldSave;
|
||||
}
|
||||
|
||||
public void shouldSave(boolean value) {
|
||||
this.shouldSave = value;
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,11 @@ public abstract class ChatHudMixin implements IChatHud {
|
||||
return line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChatHudLine.Visible> smegma$getVisibleMessages() {
|
||||
return visibleMessages;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// modificar contenido del mensaje
|
||||
|
||||
@@ -3,13 +3,19 @@ package me.retucio.camtweaks.mixin;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import me.retucio.camtweaks.command.CommandManager;
|
||||
import me.retucio.camtweaks.event.events.SendMessageEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.*;
|
||||
@@ -46,4 +52,10 @@ public abstract class ClientPlayNetworkHandlerMixin {
|
||||
mc.inGameHud.getChatHud().addToMessageHistory(message);
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Redirect(method = "onEntityStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;showFloatingItem(Lnet/minecraft/item/ItemStack;)V"))
|
||||
private void noRenderTotemPop(GameRenderer instance, ItemStack floatingItem) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (!noRender.isEnabled() || noRender.totemPop.isEnabled()) mc.gameRenderer.showFloatingItem(Items.TOTEM_OF_UNDYING.getDefaultStack());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.PortalGUI;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public abstract class ClientPlayerEntityMixin {
|
||||
|
||||
@ModifyExpressionValue(method = "tickNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;"))
|
||||
private Screen allowScreensInPortals(Screen original) {
|
||||
if (ModuleManager.INSTANCE.getModuleByClass(PortalGUI.class).isEnabled()) return null;
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ClientPlayerInteractionManager.class)
|
||||
public abstract class ClientPlayerInteractionManagerMixin {
|
||||
|
||||
@Unique
|
||||
Freecam freecam;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, ClientPlayNetworkHandler networkHandler, CallbackInfo ci) {
|
||||
freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
}
|
||||
|
||||
// los paquetes ya se cancelan en la clase de Freecam, pero visualmente el bloque sigue apareciendo roto
|
||||
@Inject(method = "breakBlock", at = @At("HEAD"), cancellable = true)
|
||||
private void cancelBlockBreaking(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (freecam.isEnabled() && freecam.cancelActionPackets.isEnabled()) cir.setReturnValue(false);
|
||||
}
|
||||
|
||||
@Inject(method = "interactBlock", at = @At("HEAD"), cancellable = true)
|
||||
private void cancelBlockPlacement(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (freecam.isEnabled() && freecam.cancelActionPackets.isEnabled()) cir.setReturnValue(ActionResult.FAIL);
|
||||
}
|
||||
|
||||
@Inject(method = "interactEntity", at = @At("HEAD"), cancellable = true)
|
||||
private void cancelEntityInteractions(PlayerEntity player, Entity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (freecam.isEnabled() && freecam.cancelActionPackets.isEnabled()) cir.setReturnValue(ActionResult.FAIL);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.item.property.numeric.CompassState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(CompassState.class)
|
||||
public abstract class CompassStateMixin {
|
||||
|
||||
@Unique
|
||||
private static Freecam freecam;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(boolean wobble, CompassState.Target target, CallbackInfo ci) {
|
||||
freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "getBodyYaw", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getBodyYaw()F"))
|
||||
private static float getBodyYaw(float original) {
|
||||
if (freecam.isEnabled()) return mc.gameRenderer.getCamera().getYaw();
|
||||
return original;
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getAngleTo(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/BlockPos;)D", at = @At("RETURN"))
|
||||
private static double getAngleTo(double original, Entity entity, BlockPos blockPos) {
|
||||
if (freecam.isEnabled()) {
|
||||
Vec3d vec3d = Vec3d.ofCenter(blockPos);
|
||||
Camera camera = mc.gameRenderer.getCamera();
|
||||
return Math.atan2(vec3d.getZ() - camera.getPos().z, vec3d.getX() - camera.getPos().x) / (float) (Math.PI * 2);
|
||||
}
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.CritsPlus;
|
||||
import net.minecraft.client.particle.BillboardParticle;
|
||||
import net.minecraft.client.particle.DamageParticle;
|
||||
import net.minecraft.client.particle.ParticleTextureSheet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@Mixin(DamageParticle.class)
|
||||
public abstract class DamageParticleMixin {
|
||||
|
||||
@ModifyReturnValue(method = "getRenderType", at = @At("RETURN"))
|
||||
private BillboardParticle.RenderType makeCritsTranslucent(BillboardParticle.RenderType original) {
|
||||
if (ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class).isEnabled()) return BillboardParticle.RenderType.PARTICLE_ATLAS_TRANSLUCENT;
|
||||
return original;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Mixin(DamageParticle.Factory.class)
|
||||
abstract class DamageParticleFactoryMixin {
|
||||
|
||||
@ModifyVariable(method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDDLnet/minecraft/util/math/random/Random;)Lnet/minecraft/client/particle/Particle;", at = @At(value = "STORE"))
|
||||
private DamageParticle modifyCritColor(DamageParticle original) {
|
||||
CritsPlus crits = ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class);
|
||||
if (!crits.isEnabled()) return original;
|
||||
|
||||
if (crits.rainbow.isEnabled()) {
|
||||
float speed = 10001 - crits.rainbowSpeed.getFloatValue();
|
||||
float hue = (System.currentTimeMillis() % (int) speed) / speed;
|
||||
Color gamning = Color.getHSBColor(hue, 1, 1);
|
||||
original.setColor(
|
||||
gamning.getRed() / 255f,
|
||||
gamning.getGreen() / 255f,
|
||||
gamning.getBlue() / 255f);
|
||||
} else {
|
||||
original.setColor(
|
||||
crits.red.getFloatValue() / 255f,
|
||||
crits.green.getFloatValue() / 255f,
|
||||
crits.blue.getFloatValue() / 255f);
|
||||
}
|
||||
|
||||
original.alpha = crits.alpha.getFloatValue() / 255f;
|
||||
original.scale *= crits.scale.getFloatValue();
|
||||
original.velocityMultiplier *= crits.velocityMultipler.getFloatValue();
|
||||
original.gravityStrength *= crits.gravity.getFloatValue();
|
||||
original.setMaxAge(crits.maxAge.getIntValue());
|
||||
original.collidesWithWorld = crits.collide.isEnabled();
|
||||
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -2,40 +2,35 @@ package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.AntiInvis;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.Freelook;
|
||||
import me.retucio.camtweaks.module.modules.Nametags;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.entity.AgeableMobEntityRenderer;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.mob.Monster;
|
||||
import net.minecraft.entity.passive.PassiveEntity;
|
||||
import net.minecraft.entity.passive.TameableEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.PersistentProjectileEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.entity.vehicle.VehicleEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public abstract class EntityMixin {
|
||||
|
||||
@Shadow public int age;
|
||||
@Shadow
|
||||
public abstract Text getName();
|
||||
|
||||
@Shadow public abstract Text getName();
|
||||
|
||||
@Shadow @Nullable public abstract Text getCustomName();
|
||||
@Shadow
|
||||
public abstract EntityType<?> getType();
|
||||
|
||||
@Unique
|
||||
Freecam freecam;
|
||||
@@ -82,15 +77,9 @@ public abstract class EntityMixin {
|
||||
@ModifyReturnValue(method = "isCustomNameVisible", at = @At("RETURN"))
|
||||
private boolean renderEntityNametags(boolean original) {
|
||||
if (!nametags.isEnabled()) return original;
|
||||
return switch ((Object) this) {
|
||||
case PlayerEntity player -> nametags.namePlayers.isEnabled();
|
||||
case ItemEntity item -> nametags.nameItems.isEnabled();
|
||||
case ProjectileEntity projectile -> nametags.nameProjectiles.isEnabled();
|
||||
case Monster hostile -> nametags.nameHostileMobs.isEnabled() || original; // monster en vez de HostileEntity para también incluir slimes
|
||||
case PassiveEntity passive -> nametags.namePassiveMobs.isEnabled() || original;
|
||||
case VehicleEntity vehicle -> nametags.nameVehicles.isEnabled();
|
||||
default -> nametags.nameMiscMobs.isEnabled() || original;
|
||||
};
|
||||
if ((Object) this instanceof PersistentProjectileEntity p && p.isOnGround()) return false;
|
||||
if ((Object) this instanceof ItemEntity i && !nametags.items.isEnabled(i.getStack().getItem())) return false;
|
||||
return nametags.entities.isEnabled((this.getType()));
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getName", at = @At("RETURN"))
|
||||
@@ -98,9 +87,10 @@ public abstract class EntityMixin {
|
||||
if (!nametags.isEnabled() || !nametags.showProjectileDamage.isEnabled()) return original;
|
||||
|
||||
if ((Object) this instanceof PersistentProjectileEntity arrow) { // aunque lo llame "arrow", también cubre flechas espectrales y tridentes
|
||||
float damage = nametags.getArrowDamage(arrow);
|
||||
if (damage > 0) return original.copy().append(Text.literal(" (" + damage + ")").formatted(Formatting.RED));
|
||||
String damage = nametags.getArrowDamage(arrow);
|
||||
if (!damage.equals("0")) return original.copy().append(Text.literal(" (" + damage + ")").formatted(Formatting.RED));
|
||||
}
|
||||
|
||||
return original;
|
||||
}
|
||||
|
||||
@@ -123,4 +113,12 @@ public abstract class EntityMixin {
|
||||
if ((Object) this instanceof LivingEntity entity && entity.isBaby()) return original.copy().append(" (baby)");
|
||||
return original;
|
||||
}
|
||||
|
||||
|
||||
// otros
|
||||
|
||||
@Inject(method = "isInvisibleTo", at = @At("RETURN"), cancellable = true)
|
||||
public void renderInvisPlayers(PlayerEntity player, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ModuleManager.INSTANCE.getModuleByClass(AntiInvis.class).isEnabled()) cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.mixin.accessor.EntityRenderStateAccessor;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Nametags;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
import net.minecraft.client.render.entity.state.EntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public abstract class EntityRendererMixin<S extends EntityRenderState> {
|
||||
|
||||
@Inject(method = "renderLabelIfPresent", at = @At("HEAD"))
|
||||
private void renderSneakingPlayerNametags(S state, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
|
||||
Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
|
||||
if (nametags.isEnabled() && nametags.alwaysVisible.isEnabled())
|
||||
((EntityRenderStateAccessor) state).setSneaking(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import net.minecraft.block.enums.CameraSubmersionType;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.fog.FogModifier;
|
||||
import net.minecraft.client.render.fog.FogRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.joml.Vector4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(FogRenderer.class)
|
||||
public abstract class FogRendererMixin {
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@Redirect(method = "applyFog(Lnet/minecraft/client/render/Camera;IZLnet/minecraft/client/render/RenderTickCounter;FLnet/minecraft/client/world/ClientWorld;)Lorg/joml/Vector4f;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/fog/FogModifier;shouldApply(Lnet/minecraft/block/enums/CameraSubmersionType;Lnet/minecraft/entity/Entity;)Z"))
|
||||
private boolean noRenderFogs(FogModifier instance, CameraSubmersionType cameraSubmersionType, Entity entity) {
|
||||
if (!noRender.isEnabled()) return instance.shouldApply(cameraSubmersionType, entity);
|
||||
String className = instance.getClass().getSimpleName();
|
||||
|
||||
if ((className.equals("BlindnessEffectFogModifier") && !noRender.blindnessEffect.isEnabled())
|
||||
|| (className.equals("DarknessEffectFogModifier") && !noRender.darknessEffect.isEnabled())
|
||||
|| ((className.equals("LavaFogModifier") || className.equals("WaterFogModifier")
|
||||
|| className.equals("PowederSnowFogModifier")) && !noRender.fluidOverlay.isEnabled())
|
||||
|| (className.equals("DimensionOrBossFogModifier") && !noRender.dimensionFog.isEnabled()))
|
||||
return false;
|
||||
|
||||
return instance.shouldApply(cameraSubmersionType, entity);
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getFogColor", at = @At("RETURN"))
|
||||
private Vector4f modifyLavaFog(Vector4f original, Camera camera) {
|
||||
if (noRender.isEnabled() && !noRender.fluidOverlay.isEnabled() &&
|
||||
(camera.getSubmersionType() == CameraSubmersionType.LAVA
|
||||
|| camera.getSubmersionType() == CameraSubmersionType.WATER))
|
||||
return new Vector4f(original.x, original.y, original.z, 0f);
|
||||
|
||||
return original;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "getFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getUnderwaterVisibility()F"))
|
||||
private float noRenderUnderwaterFog(float original) {
|
||||
return (noRender.isEnabled() && !noRender.fluidOverlay.isEnabled()) ? 0 : original;
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,13 @@ import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.event.events.GetFOVEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.PerspectivePlus;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import me.retucio.camtweaks.module.modules.Zoom;
|
||||
import me.retucio.camtweaks.util.interfaces.IVec3d;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.BufferBuilderStorage;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.render.block.BlockRenderManager;
|
||||
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -20,6 +21,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
@@ -36,6 +38,9 @@ public abstract class GameRendererMixin {
|
||||
@Unique
|
||||
Freecam freecam;
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Shadow @Final
|
||||
private MinecraftClient client;
|
||||
|
||||
@@ -43,9 +48,10 @@ public abstract class GameRendererMixin {
|
||||
public abstract void updateCrosshairTarget(float tickDelta);
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, HeldItemRenderer firstPersonHeldItemRenderer, BufferBuilderStorage buffers, CallbackInfo ci) {
|
||||
private void getModules(MinecraftClient client, HeldItemRenderer firstPersonHeldItemRenderer, BufferBuilderStorage buffers, BlockRenderManager blockRenderManager, CallbackInfo ci) {
|
||||
zoom = ModuleManager.INSTANCE.getModuleByClass(Zoom.class);;
|
||||
freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getFov", at = @At("RETURN"))
|
||||
@@ -73,7 +79,7 @@ public abstract class GameRendererMixin {
|
||||
float lastYaw = cameraEntity.lastYaw;
|
||||
float lastPitch = cameraEntity.lastPitch;
|
||||
|
||||
((IVec3d) cameraEntity.getPos()).smegma$set(pos.x, pos.y - cameraEntity.getEyeHeight(cameraEntity.getPose()), pos.z);
|
||||
((IVec3d) cameraEntity.getEntityPos()).smegma$set(pos.x, pos.y - cameraEntity.getEyeHeight(cameraEntity.getPose()), pos.z);
|
||||
cameraEntity.lastX = prevPos.x;
|
||||
cameraEntity.lastY = prevPos.y - cameraEntity.getEyeHeight(cameraEntity.getPose());
|
||||
cameraEntity.lastZ = prevPos.z;
|
||||
@@ -86,7 +92,7 @@ public abstract class GameRendererMixin {
|
||||
updateCrosshairTarget(tickDelta);
|
||||
freecamDone = false;
|
||||
|
||||
((IVec3d) cameraEntity.getPos()).smegma$set(x, y, z);
|
||||
((IVec3d) cameraEntity.getEntityPos()).smegma$set(x, y, z);
|
||||
cameraEntity.lastX = lastX;
|
||||
cameraEntity.lastY = lastY;
|
||||
cameraEntity.lastZ = lastZ;
|
||||
@@ -103,4 +109,9 @@ public abstract class GameRendererMixin {
|
||||
|| (freecam.isEnabled() && !freecam.renderHands.isEnabled()))
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "renderWorld", ordinal = 6, at = @At(value = "STORE"))
|
||||
private float noRenderNauseaDistortion(float scaledNauseaEffectFactor) {
|
||||
return (noRender.isEnabled() && !noRender.nauseaEffect.isEnabled()) ? 0 : scaledNauseaEffectFactor;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,8 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.item.ItemModelManager;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.command.OrderedRenderCommandQueue;
|
||||
import net.minecraft.client.render.entity.EntityRenderManager;
|
||||
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
@@ -49,17 +50,17 @@ public abstract class HeldItemRendererMixin {
|
||||
protected abstract boolean shouldSkipHandAnimationOnSwap(ItemStack from, ItemStack to);
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, EntityRenderDispatcher entityRenderDispatcher, ItemRenderer itemRenderer, ItemModelManager itemModelManager, CallbackInfo ci) {
|
||||
private void getModules(MinecraftClient client, EntityRenderManager entityRenderDispatcher, ItemRenderer itemRenderer, ItemModelManager itemModelManager, CallbackInfo ci) {
|
||||
handView = ModuleManager.INSTANCE.getModuleByClass(HandView.class);
|
||||
}
|
||||
|
||||
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemDisplayContext;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", shift = At.Shift.BEFORE))
|
||||
private void onRenderItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
|
||||
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemDisplayContext;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;I)V", shift = At.Shift.BEFORE))
|
||||
private void onRenderItem(AbstractClientPlayerEntity player, float tickProgress, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, OrderedRenderCommandQueue orderedRenderCommandQueue, int light, CallbackInfo ci) {
|
||||
EVENT_BUS.post(new RenderHeldItemEvent(matrices, hand));
|
||||
}
|
||||
|
||||
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderArmHoldingItem(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IFFLnet/minecraft/util/Arm;)V"))
|
||||
private void onRenderArm(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
|
||||
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderArmHoldingItem(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;IFFLnet/minecraft/util/Arm;)V"))
|
||||
private void onRenderArm(AbstractClientPlayerEntity player, float tickProgress, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, OrderedRenderCommandQueue orderedRenderCommandQueue, int light, CallbackInfo ci) {
|
||||
EVENT_BUS.post(new RenderArmEvent(matrices, hand));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,15 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.ChatPlus;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import me.retucio.camtweaks.ui.HUD;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import me.retucio.camtweaks.ui.HudRenderer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@@ -16,9 +20,53 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(InGameHud.class)
|
||||
public abstract class InGameHudMixin {
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
|
||||
// norender
|
||||
|
||||
@Inject(method = "renderScoreboardSidebar*", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderScoreboard(CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.scoreboard.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderTitleAndSubtitle", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderTitles(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.titles.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderNauseaOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderNausea(DrawContext context, float nauseaStrength, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.nauseaEffect.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderSpyglassOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderSpyglass(DrawContext context, float scale, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.spyglassOverlay.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderPortalOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderPortal(DrawContext context, float nauseaStrength, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.portalOverlay.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderPumpkinBlur(DrawContext context, Identifier texture, float opacity, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.pumpkinOverlay.isEnabled() && texture.getPath().equals("textures/misc/pumpkinblur.png")) ci.cancel();
|
||||
}
|
||||
|
||||
|
||||
// otros
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
private void renderHUD(DrawContext ctx, RenderTickCounter tc, CallbackInfo ci) {
|
||||
HUD.render(ctx, tc);
|
||||
HudRenderer.render(ctx, tc);
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z"))
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.InGameOverlayRenderer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.texture.SpriteHolder;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(InGameOverlayRenderer.class)
|
||||
public abstract class InGameOverlayRendererMixin {
|
||||
|
||||
@Unique
|
||||
private static NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, SpriteHolder spriteHolder, VertexConsumerProvider vertexConsumers, CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@Inject(method = "renderFireOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private static void noRenderFireOverlay(MatrixStack matrices, VertexConsumerProvider vertexConsumers, Sprite sprite, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.fireOverlay.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderUnderwaterOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private static void noRenderUnderwaterOverlay(MinecraftClient client, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.fluidOverlay.isEnabled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@ import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Nametags;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -22,7 +24,15 @@ public abstract class ItemEntityMixin {
|
||||
if (!nametags.isEnabled()) return original;
|
||||
|
||||
int count = this.getStack().getCount();
|
||||
if (nametags.countItems.isEnabled() && count > 1) return original.copy().append(" x" + count);
|
||||
MutableText name = this.getStack().getCustomName() != null ? this.getStack().getCustomName().copyContentOnly() : original.copyContentOnly();
|
||||
|
||||
if (!name.equals(original)) name = name.formatted(Formatting.ITALIC);
|
||||
|
||||
if (nametags.countItems.isEnabled()) {
|
||||
if (count > 1) return name.copy().append(" x" + count);
|
||||
return name;
|
||||
}
|
||||
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package me.retucio.camtweaks.mixin;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.KeyEvent;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.input.KeyInput;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -14,10 +15,10 @@ import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
public abstract class KeyboardMixin {
|
||||
|
||||
@Inject(method = "onKey", at = @At("HEAD"), cancellable = true)
|
||||
private void onKeyPress(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
|
||||
CameraTweaks.INSTANCE.onKeyPress(key, action);
|
||||
private void onKeyPress(long window, int action, KeyInput input, CallbackInfo ci) {
|
||||
CameraTweaks.INSTANCE.onKeyPress(input.key(), action);
|
||||
|
||||
KeyEvent event = EVENT_BUS.post(new KeyEvent(key, scancode, action));
|
||||
KeyEvent event = EVENT_BUS.post(new KeyEvent(input.key(), input.scancode(), action));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,9 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.textures.GpuTexture;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Fullbright;
|
||||
import me.retucio.camtweaks.module.modules.PerspectivePlus;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.render.LightmapTextureManager;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -37,7 +35,12 @@ public abstract class LightmapTextureManagerMixin {
|
||||
@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V", shift = At.Shift.AFTER), cancellable = true)
|
||||
private void update(float tickProgress, CallbackInfo ci, @Local Profiler profiler) {
|
||||
if (fullbright.isEnabled() && fullbright.mode.is(Fullbright.Modes.GAMMA)) {
|
||||
RenderSystem.getDevice().createCommandEncoder().clearColorTexture(glTexture, ColorHelper.getArgb(255, 255, 255, 255));
|
||||
RenderSystem.getDevice().createCommandEncoder().clearColorTexture(glTexture, ColorHelper.getArgb(
|
||||
fullbright.alpha.getIntValue(),
|
||||
fullbright.red.getIntValue(),
|
||||
fullbright.green.getIntValue(),
|
||||
fullbright.blue.getIntValue()
|
||||
));
|
||||
profiler.pop();
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@@ -1,18 +1,55 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.Nametags;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.render.entity.PlayerEntityRenderer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(LivingEntityRenderer.class)
|
||||
public abstract class LivingEntityRendererMixin {
|
||||
public abstract class LivingEntityRendererMixin<T extends LivingEntity> {
|
||||
|
||||
@Unique
|
||||
Nametags nametags;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(EntityRendererFactory.Context ctx, EntityModel<?> model, float shadowRadius, CallbackInfo ci) {
|
||||
nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getCameraEntity()Lnet/minecraft/entity/Entity;"))
|
||||
private Entity hasLabelGetCameraEntityProxy(Entity cameraEntity) {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() ? null : cameraEntity;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSneaky()Z"))
|
||||
private boolean renderSneakingPlayerNametags(boolean original) {
|
||||
return (nametags.isEnabled() && nametags.alwaysVisible.isEnabled()) || original;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isInvisibleTo(Lnet/minecraft/entity/player/PlayerEntity;)Z"))
|
||||
private boolean renderInvisPlayerNametags(boolean original) {
|
||||
if (nametags.isEnabled() && nametags.alwaysVisible.isEnabled()) return false;
|
||||
else return original;
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At("RETURN"))
|
||||
private boolean shouldRenderPlayerNametag(boolean original, @Local(argsOnly = true) T livingEntity) {
|
||||
if (nametags.isEnabled() && livingEntity instanceof PlayerEntity) return nametags.entities.isEnabled(EntityType.PLAYER) && original;
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.OpenScreenEvent;
|
||||
import me.retucio.camtweaks.event.events.ShutdownEvent;
|
||||
@@ -10,6 +11,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@@ -37,4 +39,9 @@ public abstract class MinecraftClientMixin {
|
||||
OpenScreenEvent event = EVENT_BUS.post(new OpenScreenEvent(screen));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "isTelemetryEnabledByApi", at = @At("RETURN"), cancellable = true)
|
||||
private void disableMicropenisTelemetryShi(CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.MouseClickEvent;
|
||||
import me.retucio.camtweaks.event.events.MouseScrollEvent;
|
||||
import net.minecraft.client.Mouse;
|
||||
import net.minecraft.client.input.MouseInput;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -15,8 +16,8 @@ import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
public abstract class MouseMixin {
|
||||
|
||||
@Inject(method = "onMouseButton", at = @At("HEAD"), cancellable = true)
|
||||
private void onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) {
|
||||
MouseClickEvent event = EVENT_BUS.post(new MouseClickEvent(action, button));
|
||||
private void onMouseButton(long window, MouseInput input, int action, CallbackInfo ci) {
|
||||
MouseClickEvent event = EVENT_BUS.post(new MouseClickEvent(action, input.button()));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.DamageOverlay;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.texture.NativeImageBackedTexture;
|
||||
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(OverlayTexture.class)
|
||||
public abstract class OverlayTextureMixin implements AutoCloseable {
|
||||
|
||||
@Shadow @Final
|
||||
private NativeImageBackedTexture texture;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void modifyDamageOverlayColor(CallbackInfo ci) {
|
||||
ModuleManager.INSTANCE.getModuleByClass(DamageOverlay.class).reloadOverlay(texture);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ParticleManager.class)
|
||||
public abstract class ParticleManagerMixin {
|
||||
|
||||
@Inject(method = "addParticle(Lnet/minecraft/particle/ParticleEffect;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderParticles(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ, CallbackInfoReturnable<Particle> cir) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (!noRender.isEnabled()) return;
|
||||
if (!noRender.particles.isEnabled(parameters.getType())) cir.setReturnValue(null);
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,10 @@ public abstract class PlayerEntityMixin extends LivingEntity {
|
||||
@ModifyReturnValue(method = "getDisplayName", at = @At("RETURN"))
|
||||
private Text addHealthIndicator(Text original) {
|
||||
Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
if (nametags.isEnabled() && !nametags.namePlayers.isEnabled()) return null;
|
||||
if (!nametags.isEnabled() || !nametags.health.isEnabled()) return original;
|
||||
|
||||
float health = getHealth();
|
||||
float absorption = getAbsorptionAmount();
|
||||
Formatting color;
|
||||
|
||||
if (health < 5) color = Formatting.RED;
|
||||
@@ -34,7 +34,19 @@ public abstract class PlayerEntityMixin extends LivingEntity {
|
||||
else color = Formatting.DARK_GREEN;
|
||||
|
||||
// me gustaría también añadir un modo en el que se renderizan los corazones directamente en la nametag, pero no sé cómo hacer para las imágenes :'(
|
||||
return original.copy().append(Text.literal(" [" + color + (nametags.healthMode.is(Nametags.HealthMode.HEARTS)
|
||||
? String.format("%.2f", health / 2) : (int) health) + Formatting.RESET + "]"));
|
||||
} // redondear a dos decimales
|
||||
// ahora que lo pienso en la snapshot más reciente han metido iconos que se pueden usar en texto, y uno de ellos es un corazón :D
|
||||
String text = " [" + color +
|
||||
(nametags.healthMode.is(Nametags.HealthMode.HEARTS)
|
||||
? String.format("%.2f", health / 2) // redondear a dos decimales
|
||||
: (int) health) +
|
||||
(absorption > 0 // tener absorción en cuenta
|
||||
? Formatting.RESET + " + " + Formatting.GOLD +
|
||||
(nametags.healthMode.is(Nametags.HealthMode.HEARTS)
|
||||
? String.format("%.2f", absorption / 2)
|
||||
: Integer.toString((int) absorption))
|
||||
: "") +
|
||||
Formatting.RESET + "]";
|
||||
|
||||
return original.copy().append(text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.ScreenshotPlus;
|
||||
import net.minecraft.client.texture.NativeImage;
|
||||
import net.minecraft.client.util.ScreenshotRecorder;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(ScreenshotRecorder.class)
|
||||
public abstract class ScreenshotRecorderMixin {
|
||||
|
||||
// "method_22691" es la lambda de la función "saveScreenshot()" (por lo menos en 1.21.6)
|
||||
@Inject(method = "method_22691", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"), cancellable = true)
|
||||
private static void sendActionsMessage(NativeImage nativeImage, File file, Consumer<Text> consumer, CallbackInfo ci) {
|
||||
ScreenshotPlus screenshotPlus = getScreenshotPlus();
|
||||
if (screenshotPlus.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "method_22691", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/NativeImage;writeTo(Ljava/io/File;)V"), cancellable = true)
|
||||
private static void interceptScreenshotFile(NativeImage nativeImage, File file, Consumer<Text> consumer, CallbackInfo ci) throws IOException {
|
||||
ScreenshotPlus screenshotPlus = getScreenshotPlus();
|
||||
|
||||
// aunque el módulo esté apagado, pasar las referencias para poder usar los comandos para las capturas
|
||||
screenshotPlus.setScreenshot(nativeImage);
|
||||
screenshotPlus.setScreenshotFile(file);
|
||||
|
||||
if (!screenshotPlus.isEnabled()) return;
|
||||
|
||||
// por los threads o lo que sea
|
||||
mc.execute(screenshotPlus::sendScreenshotMessage);
|
||||
|
||||
switch (screenshotPlus.defaultAction.getValue()) {
|
||||
case COPY -> screenshotPlus.copyScreenshot(nativeImage);
|
||||
case SAVE -> screenshotPlus.saveScreenshot();
|
||||
case NONE -> ci.cancel();
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static ScreenshotPlus getScreenshotPlus() {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class);
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,12 @@ public abstract class SkyRendererMixin {
|
||||
}
|
||||
|
||||
@Inject(method = "renderSun", at = @At("HEAD"), cancellable = true)
|
||||
private void onRenderSun(float alpha, VertexConsumerProvider vertexConsumers, MatrixStack matrices, CallbackInfo ci) {
|
||||
private void onRenderSun(float alpha, MatrixStack matrices, CallbackInfo ci) {
|
||||
if (timeChanger.isEnabled() && !timeChanger.renderSun.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderMoon", at = @At("HEAD"), cancellable = true)
|
||||
private void onRenderMoon(int phase, float alpha, VertexConsumerProvider vertexConsumers, MatrixStack matrices, CallbackInfo ci) {
|
||||
private void onRenderMoon(int phase, float alpha, MatrixStack matrixStack, CallbackInfo ci) {
|
||||
if (timeChanger.isEnabled() && !timeChanger.renderMoon.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(StuckArrowsFeatureRenderer.class)
|
||||
public abstract class StuckArrowsFeatureRendererMixin {
|
||||
|
||||
@ModifyReturnValue(method = "getObjectCount", at = @At("RETURN"))
|
||||
private int noRenderStuckArrows(int original) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (noRender.isEnabled() && !noRender.stuckArrows.isEnabled()) return 0;
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import net.minecraft.client.session.telemetry.TelemetryManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Coerce;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(TelemetryManager.class)
|
||||
public class TelemetryManagerMixin {
|
||||
|
||||
@Redirect(method = "computeSender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;isTelemetryEnabledByApi()Z"))
|
||||
private boolean disableTelemetry(@Coerce Object minecraftClient) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import net.minecraft.client.font.BakedGlyph;
|
||||
import net.minecraft.client.font.GlyphProvider;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.TextColor;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
// falta italics pero no sé dónde se comprueba eso, no es aquí :P
|
||||
@Mixin(TextRenderer.Drawer.class)
|
||||
public abstract class TextRendererDrawerMixin {
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/client/font/TextRenderer;FFIIZ)V", at = @At("TAIL"))
|
||||
private void getModules(TextRenderer textRenderer, float x, float y, int color, int backgroundColor, boolean shadow, CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@Redirect(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isBold()Z"))
|
||||
private boolean noRenderBold(Style style) {
|
||||
return !(noRender.isEnabled() && !noRender.bold.isEnabled()) && style.isBold();
|
||||
}
|
||||
|
||||
@Redirect(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isUnderlined()Z"))
|
||||
private boolean noRenderUnderlined(Style style) {
|
||||
return !(noRender.isEnabled() && !noRender.underlined.isEnabled()) && style.isUnderlined();
|
||||
}
|
||||
|
||||
@Redirect(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isStrikethrough()Z"))
|
||||
private boolean noRenderStrikethrough(Style style) {
|
||||
return !(noRender.isEnabled() && !noRender.strikethrough.isEnabled()) && style.isStrikethrough();
|
||||
}
|
||||
|
||||
@ModifyArg(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer$Drawer;getRenderColor(Lnet/minecraft/text/TextColor;)I"))
|
||||
private TextColor noRenderColor(TextColor original) {
|
||||
return !noRender.color.is(NoRender.Colors.DEFAULT) ? TextColor.fromFormatting(noRender.color.getValue().toFormatting()) : original;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(TextRenderer.class)
|
||||
public abstract class TextRendererMixin {
|
||||
|
||||
@ModifyExpressionValue(method = "getGlyph", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isObfuscated()Z"))
|
||||
private boolean noRenderMTS(boolean original) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
return (!noRender.isEnabled() || noRender.scrambledText.isEnabled()) && original;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.WeatherRendering;
|
||||
import net.minecraft.client.render.state.WeatherRenderState;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.ParticlesMode;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mixin(WeatherRendering.class)
|
||||
public abstract class WeatherRenderingMixin {
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
public void getModules(CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@Inject(method = "addParticlesAndSound", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;addParticleClient(Lnet/minecraft/particle/ParticleEffect;DDDDDD)V"), cancellable = true)
|
||||
private void noRainParticles(ClientWorld world, Camera camera, int ticks, ParticlesMode particlesMode, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.rain.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderPrecipitation", at = @At("HEAD"))
|
||||
private void noRenderRainAndSnow(VertexConsumerProvider vertexConsumers, Vec3d pos, WeatherRenderState weatherRenderState, CallbackInfo ci) {
|
||||
if (noRender.isEnabled()) {
|
||||
if (!noRender.rain.isEnabled()) weatherRenderState.rainPieces.clear();
|
||||
if (!noRender.snow.isEnabled()) weatherRenderState.snowPieces.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,70 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.BlockOutline;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.NoRender;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import net.minecraft.client.render.state.WorldRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public abstract class WorldRendererMixin {
|
||||
|
||||
@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;setupTerrain(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;ZZ)V"), index = 3)
|
||||
private boolean renderSetupTerrainModifyArg(boolean hasForcedFrustum) {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || hasForcedFrustum;
|
||||
@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;method_74752(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;Z)V"), index = 2)
|
||||
private boolean renderSetupTerrainModifyArg(boolean spectator) {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || spectator;
|
||||
}
|
||||
|
||||
@Inject(method = "renderTargetBlockOutline", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderBlockOutlinesFreecam(VertexConsumerProvider.Immediate immediate, MatrixStack matrices, boolean renderBlockOutline, WorldRenderState renderStates, CallbackInfo ci) {
|
||||
Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
if (freecam.isEnabled() && !freecam.blockOutlines.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "hasBlindnessOrDarkness(Lnet/minecraft/client/render/Camera;)Z", at = @At("HEAD"), cancellable = true)
|
||||
private void hasBlindnessOrDarkness(Camera camera, CallbackInfoReturnable<Boolean> cir) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (!noRender.isEnabled()) return;
|
||||
if (!noRender.blindnessEffect.isEnabled() || !noRender.darknessEffect.isEnabled()) cir.setReturnValue(null);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderTargetBlockOutline", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/ColorHelper;withAlpha(II)I"))
|
||||
private int modifyBlockOutlineColor(int alpha, int rgb) {
|
||||
BlockOutline outline = ModuleManager.INSTANCE.getModuleByClass(BlockOutline.class);
|
||||
if (!outline.isEnabled()) return ColorHelper.withAlpha(alpha, rgb);
|
||||
|
||||
if (outline.rainbow.isEnabled()) {
|
||||
float speed = 10001 - outline.rainbowSpeed.getFloatValue(); // 10001 para evitar divisiones por cero
|
||||
float hue = (System.currentTimeMillis() % (int) speed) / speed;
|
||||
Color gamingProMax = Color.getHSBColor(hue, 1, 1);
|
||||
|
||||
return new Color(
|
||||
gamingProMax.getRed(),
|
||||
gamingProMax.getGreen(),
|
||||
gamingProMax.getBlue(),
|
||||
outline.alpha.getIntValue()
|
||||
).getRGB();
|
||||
} else {
|
||||
return new Color(
|
||||
outline.red.getIntValue(),
|
||||
outline.green.getIntValue(),
|
||||
outline.blue.getIntValue(),
|
||||
outline.alpha.getIntValue()
|
||||
).getRGB();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilUserApiService;
|
||||
import com.mojang.authlib.yggdrasil.response.UserAttributesResponse;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
// código robado de: https://github.com/kb-1000/no-telemetry
|
||||
|
||||
@Mixin(YggdrasilUserApiService.class)
|
||||
public abstract class YggdrasilUserApiServiceMixin {
|
||||
|
||||
@Redirect(method = "fetchProperties", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/yggdrasil/response/UserAttributesResponse$Privileges;getTelemetry()Z", remap = false), remap = false, require = 0)
|
||||
private boolean getTelemetry(UserAttributesResponse.Privileges instance) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.render.entity.state.EntityRenderState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(EntityRenderState.class)
|
||||
public interface EntityRenderStateAccessor {
|
||||
|
||||
@Accessor("sneaking")
|
||||
void setSneaking(boolean sneaking);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import me.retucio.camtweaks.event.events.camtweaks.ToggleModuleEvent;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.module.settings.KeySetting;
|
||||
import me.retucio.camtweaks.module.settings.Setting;
|
||||
import me.retucio.camtweaks.module.settings.AbstractSetting;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -22,13 +22,14 @@ public class Module {
|
||||
private String name;
|
||||
private String description;
|
||||
private boolean enabled;
|
||||
private boolean saveSettings = true;
|
||||
|
||||
// dejar al usuario elegir si el módulo debería apagarse tras soltar su tecla asignada, o si la tecla debería alternar su estado
|
||||
protected EnumSetting<KeyModes> keyMode = new EnumSetting<>("modo de tecla", "cómo interpretar la tecla configurada", KeyModes.class, KeyModes.TOGGLE);
|
||||
protected KeySetting bind = new KeySetting("tecla", "tecla asignada al módulo, ESC para desactivar", GLFW.GLFW_KEY_UNKNOWN);
|
||||
protected BooleanSetting notify = new BooleanSetting("notificar", "notificar en el chat al activar / desactivar", true);
|
||||
|
||||
private final List<Setting> settings = new ArrayList<>();
|
||||
private final List<AbstractSetting> settings = new ArrayList<>();
|
||||
|
||||
protected MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
@@ -40,19 +41,19 @@ public class Module {
|
||||
|
||||
|
||||
// ajustes
|
||||
public List<Setting> getSettings() {
|
||||
public List<AbstractSetting> getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <S extends Setting> S addSetting(Setting setting) {
|
||||
public <S extends AbstractSetting> S addSetting(AbstractSetting setting) {
|
||||
settings.add(setting);
|
||||
setting.setModule(this);
|
||||
return (S) setting; // por convenciencia
|
||||
}
|
||||
|
||||
public void addSettings(Setting... settings) {
|
||||
for (Setting setting : settings) addSetting(setting);
|
||||
public void addSettings(AbstractSetting... settings) {
|
||||
for (AbstractSetting setting : settings) addSetting(setting);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +116,14 @@ public class Module {
|
||||
return keyMode.is(KeyModes.HOLD);
|
||||
}
|
||||
|
||||
public boolean shouldSaveSettings() {
|
||||
return saveSettings;
|
||||
}
|
||||
|
||||
public void shouldSaveSettings(boolean value) {
|
||||
this.saveSettings = value;
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return bind.getKey();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import me.retucio.camtweaks.module.modules.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -22,19 +23,31 @@ public class ModuleManager {
|
||||
addModules();
|
||||
}
|
||||
|
||||
// por order alfabético y todo, flipas
|
||||
// por orden alfabético y todo, flipas
|
||||
private void addModules() {
|
||||
modules.add(new AntiInvis());
|
||||
modules.add(new BlockOutline());
|
||||
modules.add(new BossbarStack());
|
||||
modules.add(new ChatPlus());
|
||||
modules.add(new CritsPlus());
|
||||
modules.add(new DamageOverlay());
|
||||
modules.add(new FakePlayer());
|
||||
modules.add(new Freecam());
|
||||
modules.add(new Freelook());
|
||||
modules.add(new Fullbright());
|
||||
modules.add(new HandView());
|
||||
modules.add(new PerspectivePlus());
|
||||
modules.add(new HUD());
|
||||
modules.add(new Nametags());
|
||||
modules.add(new NoRender());
|
||||
modules.add(new PerspectivePlus());
|
||||
modules.add(new PortalGUI());
|
||||
modules.add(new ScreenshotPlus());
|
||||
modules.add(new TimeChanger());
|
||||
// modules.add(new TooltipsPlus());
|
||||
modules.add(new Zoom());
|
||||
|
||||
modules.sort(Comparator.comparing(module -> module.getName().toLowerCase()));
|
||||
|
||||
// registrar los "listeners" necesarios
|
||||
for (Module module : getEnabledModules()) {
|
||||
for (Method method : module.getClass().getDeclaredMethods()) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.EntityMixin
|
||||
*/
|
||||
|
||||
public class AntiInvis extends Module {
|
||||
|
||||
public AntiInvis() {
|
||||
super("anti invis", "te permite ver a los jugadores invisibles");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.WorldRendererMixin
|
||||
*/
|
||||
|
||||
public class BlockOutline extends Module {
|
||||
|
||||
public BooleanSetting rainbow = addSetting(new BooleanSetting("RGB", "erre ge be gueiming", false));
|
||||
public NumberSetting rainbowSpeed = addSetting(new NumberSetting("velocidad", "velocidad de la bandera gay", 2000, 0, 10000, 2));
|
||||
|
||||
public NumberSetting red = addSetting(new NumberSetting("rojo", "factor r del rbg", 0, 0, 255, 1));
|
||||
public NumberSetting green = addSetting(new NumberSetting("verde", "factor g del rgb", 0, 0, 255, 1));
|
||||
public NumberSetting blue = addSetting(new NumberSetting("azul", "factor b del rbg", 0, 0, 255, 1));
|
||||
|
||||
public NumberSetting alpha = addSetting(new NumberSetting("opacidad", "transparencia invertida", 102, 0, 255, 1));
|
||||
|
||||
public BlockOutline() {
|
||||
super("contorno", "customiza el contorno de los bloques");
|
||||
rainbow.onUpdate(v -> {
|
||||
rainbowSpeed.setVisible(v);
|
||||
red.setVisible(!v);
|
||||
green.setVisible(!v);
|
||||
blue.setVisible(!v);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import me.retucio.camtweaks.event.events.SendMessageEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.interfaces.IChatHudLine;
|
||||
import me.retucio.camtweaks.util.interfaces.IChatHudLineVisible;
|
||||
@@ -163,7 +162,7 @@ public class ChatPlus extends Module {
|
||||
GameProfile sender = getSender(line, text);
|
||||
if (sender == null) return;
|
||||
|
||||
PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(sender.getId());
|
||||
PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(sender.id());
|
||||
if (entry == null) return;
|
||||
|
||||
PlayerSkinDrawer.draw(context, entry.getSkinTextures(), 0, y, 8);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.DamageParticleMixin
|
||||
* @see me.retucio.camtweaks.mixin.DamageParticleFactoryMixin
|
||||
*/
|
||||
|
||||
public class CritsPlus extends Module {
|
||||
|
||||
public BooleanSetting rainbow = addSetting(new BooleanSetting("LUCES GAMING", "PARTÍCULAS GAMING", false));
|
||||
public NumberSetting rainbowSpeed = addSetting(new NumberSetting("velocidad del erre ge be", "qué tan gaming son las luces gaming", 1000, 0, 10000, 2));
|
||||
|
||||
public NumberSetting red = addSetting(new NumberSetting("rojo", "comunismo", 0, 0, 255, 1));
|
||||
public NumberSetting green = addSetting(new NumberSetting("verde", "vox", 0, 0, 255, 1));
|
||||
public NumberSetting blue = addSetting(new NumberSetting("azul", "metanfetamina", 255, 0, 255, 1));
|
||||
public NumberSetting alpha = addSetting(new NumberSetting("alpha", "opacidad", 255, 0, 255, 1));
|
||||
|
||||
public NumberSetting scale = addSetting(new NumberSetting("escala", "tamaño", 1, 0, 2, 0.05));
|
||||
public NumberSetting multiplier; // no sé dónde se calcula cuántas partículas aparecen :/
|
||||
public NumberSetting velocityMultipler = addSetting(new NumberSetting("dispersión", "multiplicador de la velocidad de dispersión", 1, 0, 10, 0.1));
|
||||
public NumberSetting gravity = addSetting(new NumberSetting("gravedad", "multiplicador de fuerza de gravedad", 1, 0, 10, 0.1));
|
||||
public NumberSetting maxAge = addSetting(new NumberSetting("vida máxima", "cuánto persiste la partícula", 4, 0, 50, 1));
|
||||
public BooleanSetting collide = addSetting(new BooleanSetting("colisionar", "colisionar con bloques", false));
|
||||
|
||||
public CritsPlus() {
|
||||
super("críticos", "cambia la apariencia de los críticos al gusto");
|
||||
rainbow.onUpdate(v -> {
|
||||
rainbowSpeed.setVisible(v);
|
||||
red.setVisible(!v);
|
||||
green.setVisible(!v);
|
||||
blue.setVisible(!v);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.textures.GpuTextureView;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import net.minecraft.client.texture.NativeImage;
|
||||
import net.minecraft.client.texture.NativeImageBackedTexture;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.OverlayTextureMixin
|
||||
*/
|
||||
|
||||
public class DamageOverlay extends Module {
|
||||
|
||||
public NumberSetting red = addSetting(new NumberSetting("rojo", "r o j o", 255, 0, 255, 1));
|
||||
public NumberSetting green = addSetting(new NumberSetting("verde", "v e r d e", 0, 0, 255, 1));
|
||||
public NumberSetting blue = addSetting(new NumberSetting("azul", "a z u l", 0, 0, 255, 1));
|
||||
public NumberSetting alpha = addSetting(new NumberSetting("alpha", "o p a c i d a d", 77, 0, 255, 1));
|
||||
|
||||
private NativeImageBackedTexture texture = null;
|
||||
|
||||
public DamageOverlay() {
|
||||
super("superposición de daño", "modifica el color en el que se renderiza la superposición de recibir daño");
|
||||
|
||||
NumberSetting[] settings = {red, green, blue, alpha};
|
||||
for (NumberSetting setting : settings)
|
||||
setting.onUpdate(v -> reloadOverlayIfReady());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
reloadOverlayIfReady();
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
reloadOverlayIfReady();
|
||||
super.onDisable();
|
||||
}
|
||||
|
||||
private void reloadOverlayIfReady() {
|
||||
if (texture != null && texture.getImage() != null) reloadOverlay(texture);
|
||||
}
|
||||
|
||||
// recargar el overlay (superposición)
|
||||
public void reloadOverlay(NativeImageBackedTexture texture) {
|
||||
if (this.texture == null) this.texture = texture;
|
||||
|
||||
int color = isEnabled() ?
|
||||
new Color(red.getIntValue(), green.getIntValue(), blue.getIntValue(), 255 - alpha.getIntValue()).getRGB()
|
||||
: new Color(255, 0, 0, 178).getRGB();
|
||||
|
||||
NativeImage image = texture.getImage();
|
||||
for (int y = 0; y < 8; y++)
|
||||
for (int x = 0; x < 16; x++)
|
||||
image.setColorArgb(x, y, color);
|
||||
|
||||
uploadTexture();
|
||||
}
|
||||
|
||||
// resubir las texturas
|
||||
private void uploadTexture() {
|
||||
GpuTextureView overlayTex = RenderSystem.getShaderTexture(33985);
|
||||
RenderSystem.setShaderTexture(33985, overlayTex);
|
||||
|
||||
texture.upload();
|
||||
|
||||
GpuTextureView mainTex = RenderSystem.getShaderTexture(33984);
|
||||
RenderSystem.setShaderTexture(33984, mainTex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.StringSetting;
|
||||
import net.minecraft.client.network.OtherClientPlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class FakePlayer extends Module {
|
||||
|
||||
public StringSetting name = addSetting(new StringSetting("nombre", "qué nombre asignarle al jugador", "apio boy", 22));
|
||||
|
||||
private OtherClientPlayerEntity player = null;
|
||||
|
||||
public FakePlayer() {
|
||||
super("jugador falso", "invoca una entidad de jugador falsa por motivos de testeo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (mc.world == null) return;
|
||||
|
||||
player = new OtherClientPlayerEntity(mc.world, new GameProfile(UUID.randomUUID(), name.getValue()));
|
||||
// player.copyPositionAndRotation(mc.player);
|
||||
player.copyFrom(mc.player);
|
||||
|
||||
mc.world.addEntity(player);
|
||||
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (mc.world == null || player == null) return;
|
||||
|
||||
player.setRemoved(Entity.RemovalReason.KILLED);
|
||||
player.onRemoved();
|
||||
player = null;
|
||||
|
||||
super.onDisable();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.event.Stage;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.*;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
@@ -8,6 +9,10 @@ import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import me.retucio.camtweaks.util.MiscUtil;
|
||||
import net.minecraft.client.gui.Click;
|
||||
import net.minecraft.client.input.KeyInput;
|
||||
import net.minecraft.client.input.MouseInput;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.option.Perspective;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket;
|
||||
@@ -24,6 +29,7 @@ import org.lwjgl.glfw.GLFW;
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.CameraMixin
|
||||
* @see me.retucio.camtweaks.mixin.ChunkBorderDebugRendererMixin
|
||||
* @see me.retucio.camtweaks.mixin.ClientPlayerInteractionManagerMixin
|
||||
* @see me.retucio.camtweaks.mixin.CompassStateMixin
|
||||
* @see me.retucio.camtweaks.mixin.EntityMixin
|
||||
* @see me.retucio.camtweaks.mixin.GameRendererMixin
|
||||
@@ -42,6 +48,7 @@ public class Freecam extends Module {
|
||||
public BooleanSetting stayCrouching = addSetting(new BooleanSetting("mantenerse agachado", "mantener al jugador agachado tras entrar en el modo de cámara libre", false));
|
||||
public BooleanSetting staticView = addSetting(new BooleanSetting("visión estática", "desactiva ajustes que muevan la cámara", true));
|
||||
public BooleanSetting cancelActionPackets = addSetting(new BooleanSetting("cancelar paquetes", "evita flaggear el anticheat al interactuar con bloques / entidades", true));
|
||||
public BooleanSetting blockOutlines = addSetting(new BooleanSetting("contorno de bloques", "mostrar el contorno de los bloques estando en el modo de cámara libre", true));
|
||||
|
||||
public NumberSetting speedSetting = addSetting(new NumberSetting(
|
||||
"velocidad", "velocidad de movimiento de la cámara",
|
||||
@@ -63,7 +70,7 @@ public class Freecam extends Module {
|
||||
private float yaw, pitch;
|
||||
|
||||
public Freecam() {
|
||||
super("cámara libre", "perrmite a la cámara moverse independientemente del jugador. útil para explorar alrededores");
|
||||
super("cámara libre", "permite a la cámara moverse independientemente del jugador. útil para explorar alrededores");
|
||||
assignKey(GLFW.GLFW_KEY_V);
|
||||
speedSetting.onUpdate(newSpeed -> speed = newSpeed);
|
||||
}
|
||||
@@ -139,9 +146,9 @@ public class Freecam extends Module {
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
if (mc.cameraEntity == null || perspective == null) return;
|
||||
if (mc.getCameraEntity() == null || perspective == null) return;
|
||||
|
||||
mc.cameraEntity.noClip = mc.cameraEntity.isInsideWall();
|
||||
mc.getCameraEntity().noClip = mc.getCameraEntity().isInsideWall();
|
||||
if (!perspective.isFirstPerson()) mc.options.setPerspective(Perspective.FIRST_PERSON);
|
||||
|
||||
Vec3d forward = Vec3d.fromPolar(0, yaw);
|
||||
@@ -187,12 +194,13 @@ public class Freecam extends Module {
|
||||
@SubscribeEvent
|
||||
public void onPacketSend(PacketEvent.Send event) {
|
||||
if (!isEnabled() || !cancelActionPackets.isEnabled()) return;
|
||||
if (event.getStage() != Stage.PRE) return;
|
||||
|
||||
Packet<?> p = event.getPacket();
|
||||
if (p instanceof PlayerActionC2SPacket
|
||||
|| p instanceof PlayerInteractBlockC2SPacket
|
||||
|| p instanceof PlayerInteractItemC2SPacket
|
||||
|| p instanceof HandSwingC2SPacket) {
|
||||
Packet<?> packet = event.getPacket();
|
||||
if (packet instanceof PlayerActionC2SPacket
|
||||
|| packet instanceof PlayerInteractBlockC2SPacket
|
||||
|| packet instanceof PlayerInteractItemC2SPacket
|
||||
|| packet instanceof HandSwingC2SPacket) {
|
||||
event.cancel();
|
||||
}
|
||||
}
|
||||
@@ -200,25 +208,26 @@ public class Freecam extends Module {
|
||||
@SubscribeEvent
|
||||
public void onKey(KeyEvent event) {
|
||||
if (mc.currentScreen != null) return;
|
||||
if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_F3)) return; // ?
|
||||
if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_F3)) return;
|
||||
KeyInput key = new KeyInput(event.getKey(), event.getScancode(), 0);
|
||||
|
||||
boolean shouldCancel = true;
|
||||
if (mc.options.forwardKey.matchesKey(event.getKey(), event.getScancode())) {
|
||||
if (mc.options.forwardKey.matchesKey(key)) {
|
||||
forward = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.forwardKey.setPressed(false);
|
||||
} else if (mc.options.backKey.matchesKey(event.getKey(), event.getScancode())) {
|
||||
} else if (mc.options.backKey.matchesKey(key)) {
|
||||
backward = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.backKey.setPressed(false);
|
||||
} else if (mc.options.rightKey.matchesKey(event.getKey(), event.getScancode())) {
|
||||
} else if (mc.options.rightKey.matchesKey(key)) {
|
||||
right = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.rightKey.setPressed(false);
|
||||
} else if (mc.options.leftKey.matchesKey(event.getKey(), event.getScancode())) {
|
||||
} else if (mc.options.leftKey.matchesKey(key)) {
|
||||
left = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.leftKey.setPressed(false);
|
||||
} else if (mc.options.jumpKey.matchesKey(event.getKey(), event.getScancode())) {
|
||||
} else if (mc.options.jumpKey.matchesKey(key)) {
|
||||
up = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.jumpKey.setPressed(false);
|
||||
} else if (mc.options.sneakKey.matchesKey(event.getKey(), event.getScancode())) {
|
||||
} else if (mc.options.sneakKey.matchesKey(key)) {
|
||||
down = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.sneakKey.setPressed(false);
|
||||
} else {
|
||||
@@ -231,24 +240,25 @@ public class Freecam extends Module {
|
||||
@SubscribeEvent
|
||||
public void onMouseClick(MouseClickEvent event) { // por si el restrasado del usuario usa el ratón para moverse
|
||||
if (mc.currentScreen != null) return;
|
||||
Click click = new Click(0, 0, new MouseInput(event.getButton(), 0));
|
||||
|
||||
boolean shouldCancel = true;
|
||||
if (mc.options.forwardKey.matchesKey(event.getButton(), 0)) {
|
||||
if (mc.options.forwardKey.matchesMouse(click)) {
|
||||
forward = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.forwardKey.setPressed(false);
|
||||
} else if (mc.options.backKey.matchesKey(event.getButton(), 0)) {
|
||||
} else if (mc.options.backKey.matchesMouse(click)) {
|
||||
backward = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.backKey.setPressed(false);
|
||||
} else if (mc.options.rightKey.matchesKey(event.getButton(), 0)) {
|
||||
} else if (mc.options.rightKey.matchesMouse(click)) {
|
||||
right = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.rightKey.setPressed(false);
|
||||
} else if (mc.options.leftKey.matchesKey(event.getButton(), 0)) {
|
||||
} else if (mc.options.leftKey.matchesMouse(click)) {
|
||||
left = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.leftKey.setPressed(false);
|
||||
} else if (mc.options.jumpKey.matchesKey(event.getButton(), 0)) {
|
||||
} else if (mc.options.jumpKey.matchesMouse(click)) {
|
||||
up = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.jumpKey.setPressed(false);
|
||||
} else if (mc.options.sneakKey.matchesKey(event.getButton(), 0)) {
|
||||
} else if (mc.options.sneakKey.matchesMouse(click)) {
|
||||
down = event.getAction() != GLFW.GLFW_RELEASE;
|
||||
mc.options.sneakKey.setPressed(false);
|
||||
} else {
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.retucio.camtweaks.module.modules;
|
||||
import me.retucio.camtweaks.mixin.accessor.StatusEffectInstanceAccessor;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.registry.Registries;
|
||||
@@ -16,10 +17,31 @@ public class Fullbright extends Module {
|
||||
|
||||
public EnumSetting<Modes> mode = addSetting(new EnumSetting<>("modo", "qué modo de iluminación emplear (usar poción con shaders)", Modes.class, Modes.GAMMA));
|
||||
|
||||
public NumberSetting red = addSetting(new NumberSetting("rojo", "cantidad de rojo a aplicar",
|
||||
255, 0, 255, 1));
|
||||
|
||||
public NumberSetting green = addSetting(new NumberSetting("verde", "cantidad de verde a aplicar",
|
||||
255, 0, 255, 1));
|
||||
|
||||
public NumberSetting blue = addSetting(new NumberSetting("azul", "cantidad de azul a aplicar",
|
||||
255, 0, 255, 1));
|
||||
|
||||
public NumberSetting alpha = addSetting(new NumberSetting("opacidad", "opacidad del shader",
|
||||
255, 0, 255, 1));
|
||||
|
||||
public Fullbright() {
|
||||
super("brilli brilli", "deshabilita la oscuridad");
|
||||
super("brilli brilli", "deshabilita la oscuridad (y aplica colores a los shaders)");
|
||||
assignKey(GLFW.GLFW_KEY_K);
|
||||
mode.onUpdate(mode -> { if (mode != Modes.POTION) disableNightVision(); });
|
||||
mode.onUpdate(mode -> {
|
||||
boolean v = mode.equals(Modes.GAMMA);
|
||||
red.setVisible(v);
|
||||
green.setVisible(v);
|
||||
blue.setVisible(v);
|
||||
alpha.setVisible(v);
|
||||
|
||||
if (v) disableNightVision();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,7 +56,7 @@ public class Fullbright extends Module {
|
||||
|
||||
if (mc.player.hasStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()))) {
|
||||
StatusEffectInstance instance = mc.player.getStatusEffect(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()));
|
||||
if (instance != null && instance.getDuration() < 69) ((StatusEffectInstanceAccessor) instance).setDuration(69);
|
||||
if (instance != null && instance.getDuration() < 5200) ((StatusEffectInstanceAccessor) instance).setDuration(5200);
|
||||
} else {
|
||||
mc.player.addStatusEffect(new StatusEffectInstance(Registries.STATUS_EFFECT.getEntry(StatusEffects.NIGHT_VISION.value()), 69, 0));
|
||||
}
|
||||
@@ -53,8 +75,6 @@ public class Fullbright extends Module {
|
||||
|
||||
private final String name;
|
||||
Modes(String name) { this.name = name; }
|
||||
|
||||
@Override
|
||||
public String toString() { return name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.command.CommandManager;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.TickEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.LoadClickGUIEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.LoadCommandManagerEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
@@ -12,37 +17,57 @@ import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import static me.retucio.camtweaks.util.Colors.*;
|
||||
|
||||
// módulo no visible solo para los ajustes de la interfaz (y del cliente en general)
|
||||
public class GUI extends Module {
|
||||
|
||||
public NumberSetting red = addSetting(new NumberSetting("rojo", "cantidad de rojo en el RGB del marco", 0, 0, 255, 1));
|
||||
public NumberSetting green = addSetting(new NumberSetting("verde", "cantidad de verde en el RGB del marco", 0, 0, 255, 1));
|
||||
public NumberSetting blue = addSetting(new NumberSetting("azul", "cantidad de azul en el RGB del marco", 255, 0, 255, 1));
|
||||
public NumberSetting alpha = addSetting(new NumberSetting("alpha", "opacidad del marco", 180, 0, 255, 1));
|
||||
public BooleanSetting rainbow = addSetting(new BooleanSetting("gaming", "gaming", false));
|
||||
public NumberSetting rainbowSpeed = addSetting(new NumberSetting("velocidad del gaming", "velocidad, del gaming.",
|
||||
1000, 0, 10000, 2));
|
||||
public NumberSetting saturation = addSetting(new NumberSetting("saturación del gaming", "saturación, del gaming",
|
||||
1, 0, 1, 0.01));
|
||||
public NumberSetting brightness = addSetting(new NumberSetting("brillo del gaming", "brillo, del gaming",
|
||||
0.8, 0, 1, 0.01));
|
||||
|
||||
public NumberSetting red = addSetting(new NumberSetting("rojo", "cantidad de rojo en el RGB del marco", 70, 0, 255, 1));
|
||||
public NumberSetting green = addSetting(new NumberSetting("verde", "cantidad de verde en el RGB del marco", 20, 0, 255, 1));
|
||||
public NumberSetting blue = addSetting(new NumberSetting("azul", "cantidad de azul en el RGB del marco", 210, 0, 255, 1));
|
||||
public NumberSetting alpha = addSetting(new NumberSetting("alpha", "opacidad del marco", 230, 0, 255, 1));
|
||||
|
||||
// números negativos para deslizamiento inverso, 0 para desactivar
|
||||
public NumberSetting scrollSens = addSetting(new NumberSetting("sensibilidad del scroll", "qué tan sensible es la interfaz a la rueda del ratón",
|
||||
5, 0, 15, 0.5));
|
||||
5, -15, 15, 0.5));
|
||||
public BooleanSetting scrollBar = addSetting(new BooleanSetting("barra de desplazamiento", "renderizar una barra de desplazamiento a la derecha de la interfaz", true));
|
||||
|
||||
public BooleanSetting searchBar = addSetting(new BooleanSetting("barra de búsqueda", "renderizar una barra de búsqueda que filtra resultados en todos los marcos abiertos", true));
|
||||
public BooleanSetting matchCase = addSetting(new BooleanSetting("distinguir mayúsculas", "la búsqueda es sensible a mayúsculas y minúsculas", false));
|
||||
// ^^^ no sé de qué sirve porque está todo en minúsculas pero bueno
|
||||
|
||||
public BooleanSetting blur = addSetting(new BooleanSetting("desenfoque", "desenfocar el fondo mientras la interfaz está abierta", true));
|
||||
|
||||
public StringSetting commandPrefix = addSetting(new StringSetting("prefijo", "prefijo de los comandos", "$", 10));
|
||||
public StringSetting chatName = addSetting(new StringSetting("nombre", "qué nombre usar en notificaciones por el chat", "smegma", 20));
|
||||
|
||||
public BooleanSetting multipleKeybinds = addSetting(new BooleanSetting("teclas multimódulo", "permitir asignar la misma tecla a más de un módulo", false));
|
||||
|
||||
private int prevRed, prevGreen, prevBlue;
|
||||
|
||||
public GUI() {
|
||||
super("interfaz", "ajustes de la interfaz, y otros misceláneos");
|
||||
assignKey(GLFW.GLFW_KEY_RIGHT_SHIFT);
|
||||
|
||||
// registrar aquí, porque no se añade a ModuleManager.modules. de lo contrario no podría detectar eventos
|
||||
CameraTweaks.EVENT_BUS.register(this);
|
||||
|
||||
keyMode.setVisible(false);
|
||||
notify.setVisible(false);
|
||||
|
||||
commandPrefix.onUpdate(prefix -> CommandManager.INSTANCE.setPrefix(prefix));
|
||||
red.onUpdate(r -> {frameHeadRed = r.intValue(); updateFrameHeadColor();});
|
||||
green.onUpdate(g -> {frameHeadGreen = g.intValue(); updateFrameHeadColor();});
|
||||
blue.onUpdate(b -> {frameHeadBlue = b.intValue(); updateFrameHeadColor();});
|
||||
alpha.onUpdate(a -> {frameHeadAlpha = a.intValue(); updateFrameHeadColor();});
|
||||
searchBar.onUpdate(v -> matchCase.setVisible(v));
|
||||
}
|
||||
|
||||
if (mc != null) mc.execute(() -> commandPrefix.setDefaultValue(CommandManager.INSTANCE.getPrefix()));
|
||||
@SubscribeEvent
|
||||
public void onLoadCommandManager(LoadCommandManagerEvent event) {
|
||||
commandPrefix.onUpdate(prefix -> CommandManager.INSTANCE.setPrefix(prefix));
|
||||
commandPrefix.setDefaultValue(CommandManager.INSTANCE.getPrefix());
|
||||
|
||||
chatName.onUpdate(name -> {
|
||||
ChatUtil.updatePrefix(name);
|
||||
@@ -50,12 +75,65 @@ public class GUI extends Module {
|
||||
});
|
||||
}
|
||||
|
||||
private void updateFrameHeadColor() {
|
||||
Colors.frameHeadColor = new Color(
|
||||
frameHeadRed,
|
||||
frameHeadGreen,
|
||||
frameHeadBlue,
|
||||
frameHeadAlpha
|
||||
).getRGB();
|
||||
// lógica un poco prolija pero bueno
|
||||
@SubscribeEvent
|
||||
public void onLoadClickGUI(LoadClickGUIEvent event) {
|
||||
rainbow.onUpdate(v -> {
|
||||
if (v) {
|
||||
prevRed = red.getIntValue();
|
||||
prevGreen = green.getIntValue();
|
||||
prevBlue = blue.getIntValue();
|
||||
} else {
|
||||
red.setValue(prevRed);
|
||||
green.setValue(prevGreen);
|
||||
blue.setValue(prevBlue);
|
||||
}
|
||||
|
||||
rainbowSpeed.setVisible(v);
|
||||
saturation.setVisible(v);
|
||||
brightness.setVisible(v);
|
||||
red.setVisible(!v);
|
||||
green.setVisible(!v);
|
||||
blue.setVisible(!v);
|
||||
|
||||
applyRGBAColorUpdates();
|
||||
});
|
||||
|
||||
red.onUpdate(r -> applyRGBAColorUpdates());
|
||||
green.onUpdate(g -> applyRGBAColorUpdates());
|
||||
blue.onUpdate(b -> applyRGBAColorUpdates());
|
||||
alpha.onUpdate(a -> applyRGBAColorUpdates());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.Post event) {
|
||||
if (rainbow.isEnabled()) {
|
||||
float speed = (float) (rainbowSpeed.getMax() - rainbowSpeed.getValue());
|
||||
float hue = (System.currentTimeMillis() % (long) speed) / speed;
|
||||
Color color = Color.getHSBColor(hue, saturation.getFloatValue(), brightness.getFloatValue());
|
||||
|
||||
Colors.red = color.getRed();
|
||||
Colors.green = color.getGreen();
|
||||
Colors.blue = color.getBlue();
|
||||
|
||||
updateColor();
|
||||
}
|
||||
}
|
||||
|
||||
private void applyRGBAColorUpdates() {
|
||||
Colors.red = red.getIntValue();
|
||||
Colors.green = green.getIntValue();
|
||||
Colors.blue = blue.getIntValue();
|
||||
Colors.alpha = alpha.getIntValue();
|
||||
updateColor();
|
||||
}
|
||||
|
||||
private void updateColor() {
|
||||
Colors.updateAllColors(new Color(
|
||||
Colors.red,
|
||||
Colors.green,
|
||||
Colors.blue,
|
||||
Colors.alpha
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.*;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/** lógica del HUD manejada en:
|
||||
* @see me.retucio.camtweaks.ui.HudRenderer
|
||||
* @see me.retucio.camtweaks.ui.widgets.HudElement
|
||||
* @see me.retucio.camtweaks.ui.HudEditorScreen
|
||||
*/
|
||||
|
||||
public class HUD extends Module {
|
||||
|
||||
// editor
|
||||
public KeySetting editorKey = addSetting(new KeySetting("tecla del editor", "tecla asignada al editor de elementos del hud", GLFW.GLFW_KEY_PAGE_UP));
|
||||
|
||||
// colores
|
||||
public NumberSetting red = addSetting(new NumberSetting("rojo", "cantidad de rojo", 255, 0, 255, 1));
|
||||
public NumberSetting green = addSetting(new NumberSetting("verde", "cantidad de verde", 255, 0, 255, 1));
|
||||
public NumberSetting blue = addSetting(new NumberSetting("azul", "cantidad de azul", 255, 0, 255, 1));
|
||||
|
||||
public BooleanSetting rainbow = addSetting(new BooleanSetting("arcoíris", "gay.", false));
|
||||
public NumberSetting rainbowSpeed = addSetting(new NumberSetting("velocidad del arcoíris", "velocidad del arcoíris", 1000, 0, 10000, 2));
|
||||
|
||||
public NumberSetting alpha = addSetting(new NumberSetting("opacidad", "antitransparencia", 255, 0, 255, 1));
|
||||
|
||||
// ajustes
|
||||
public BooleanSetting showOnF3 = addSetting(new BooleanSetting("mostrar en F3", "renderizar HUD en el menú de debug", false));
|
||||
public BooleanSetting shadow = addSetting(new BooleanSetting("sombra", "texto con sombra", true));
|
||||
public NumberSetting timezone = addSetting(new NumberSetting("zona horaria", "zona horaria en UTC+n", 1, -6, 6, 1));
|
||||
public EnumSetting<TimeFormat> timeFormat = addSetting(new EnumSetting<>("formato de la hora", "12h o 24h", TimeFormat.class, TimeFormat.TWENTY_FOUR_HOUR));
|
||||
public StringSetting customText = addSetting(new StringSetting("texto custom", "marca de agua (dejar vacío para quitar)", "adolf jitler inshtagram feishbuc twiter", 40));
|
||||
|
||||
public HUD() {
|
||||
super("HUD", "superposición de la pantalla con info. adicional");
|
||||
|
||||
rainbow.onUpdate(v -> {
|
||||
red.setVisible(!v);
|
||||
green.setVisible(!v);
|
||||
blue.setVisible(!v);
|
||||
rainbowSpeed.setVisible(v);
|
||||
});
|
||||
}
|
||||
|
||||
public enum TimeFormat {
|
||||
TWENTY_FOUR_HOUR("24h"),
|
||||
TWELVE_HOUR("12h");
|
||||
|
||||
final String name;
|
||||
TimeFormat(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,20 @@ import com.google.gson.JsonParser;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.module.settings.ListSetting;
|
||||
import me.retucio.camtweaks.util.Lists;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LazyEntityReference;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.PersistentProjectileEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import net.minecraft.world.entity.EntityQueriable;
|
||||
import net.minecraft.world.entity.UniquelyIdentifiable;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
@@ -29,30 +33,25 @@ import java.util.concurrent.Executors;
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.EntityMixin
|
||||
* @see me.retucio.camtweaks.mixin.ItemEntityMixin
|
||||
* @see me.retucio.camtweaks.mixin.LivingEntityRendererMixin
|
||||
* @see me.retucio.camtweaks.mixin.PlayerEntityMixin
|
||||
*/
|
||||
|
||||
public class Nametags extends Module {
|
||||
|
||||
public BooleanSetting namePlayers = addSetting(new BooleanSetting("nombrar jugadores", "renderiza el nametag de jugadores", true));
|
||||
public ListSetting<EntityType<?>> entities = addSetting(new ListSetting<>("entidades", "entidades cuyo nametag será visible",
|
||||
Lists.entityList, Lists.allFalse(Lists.entityList), Lists.entityNames));
|
||||
|
||||
public BooleanSetting alwaysVisible = addSetting(new BooleanSetting("siempre mostrar nametags", "mostrar nametag cuando el jugador está agachado o es invisible", false));
|
||||
public BooleanSetting health = addSetting(new BooleanSetting("mostrar vida", "muestra la vida de una entidad en su nametag", true));
|
||||
public EnumSetting<HealthMode> healthMode = addSetting(new EnumSetting<>("mostrar vida en", "de qué manera mostrar la vida", HealthMode.class, HealthMode.POINTS));
|
||||
public BooleanSetting alwaysVisible = addSetting(new BooleanSetting("siempre mostrar nametags", "mostrar nametags cuando no deberían de ser visibles", false));
|
||||
|
||||
public BooleanSetting namePassiveMobs = addSetting(new BooleanSetting("nombrar mobs pasivos", "renderiza el nametag de mobs pasivos", false));
|
||||
public BooleanSetting nameHostileMobs = addSetting(new BooleanSetting("nombrar mobs hostiles", "renderiza el nametag de mobs hostiles", false));
|
||||
public BooleanSetting nameMiscMobs = addSetting(new BooleanSetting("nombrar mobs neutrales", "renderiza el nametag de mobs neutrales", false));
|
||||
public BooleanSetting distinguishBabies = addSetting(new BooleanSetting("distinguir bebés", "cambia el nametag cuando una entidad está en su fase bebé", false));
|
||||
|
||||
public BooleanSetting nameProjectiles = addSetting(new BooleanSetting("nombrar proyectiles", "renderiza el nametag de proyectiles", false));
|
||||
public BooleanSetting showProjectileDamage = addSetting(new BooleanSetting("daño del proyectil", "muestra cuánto daño hace un proyectil en su nametag", false));
|
||||
|
||||
public BooleanSetting nameItems = addSetting(new BooleanSetting("nombrar items", "renderiza el nametag de items", true));
|
||||
public BooleanSetting countItems = addSetting(new BooleanSetting("contar items", "muestra cuánto de un item hay en un stack dropeado", true));
|
||||
public ListSetting<Item> items = addSetting(new ListSetting<>("items", "te permite elegir cuáles items tienen su nombre visible",
|
||||
Lists.itemList, Lists.allTrue(Lists.itemList), Lists.itemNames));
|
||||
public BooleanSetting showProjectileDamage = addSetting(new BooleanSetting("daño del proyectil", "muestra cuánto daño hace un proyectil en su nametag", true));
|
||||
|
||||
public BooleanSetting nameVehicles = addSetting(new BooleanSetting("nombrar vehículos", "renderiza el nametag de botes, minecarts, ...", false));
|
||||
public BooleanSetting showPassengers = addSetting(new BooleanSetting("mostrar pasajeros", "muestra qué pasajeros tiene el vehículo", false));
|
||||
|
||||
public BooleanSetting distinguishBabies = addSetting(new BooleanSetting("distinguir bebés", "cambia el nametag cuando una entidad está en su fase bebé", false));
|
||||
public BooleanSetting petOwner = addSetting(new BooleanSetting("mostrar dueño", "muestra el dueño de una mascota (no funciona en servers no premium)", false));
|
||||
|
||||
private final Map<UUID, String> cache = new ConcurrentHashMap<>();
|
||||
@@ -61,53 +60,48 @@ public class Nametags extends Module {
|
||||
public Nametags() {
|
||||
super("nametags", "modifica la manera en la que se renderizan los nametags");
|
||||
|
||||
nameProjectiles.onUpdate(v -> showProjectileDamage.setVisible(v));
|
||||
nameItems.onUpdate(v -> countItems.setVisible(v));
|
||||
nameVehicles.onUpdate(v -> showPassengers.setVisible(v));
|
||||
|
||||
namePassiveMobs.onUpdate(v -> distinguishBabies.setVisible(v || nameMiscMobs.isEnabled() || nameHostileMobs.isEnabled()));
|
||||
nameMiscMobs.onUpdate(v -> distinguishBabies.setVisible(v || namePassiveMobs.isEnabled() || nameHostileMobs.isEnabled()));
|
||||
nameHostileMobs.onUpdate(v -> distinguishBabies.setVisible(v || nameMiscMobs.isEnabled() || namePassiveMobs.isEnabled()));
|
||||
// entidades activadas por defecto
|
||||
entities.setEnabled(EntityType.PLAYER, true);
|
||||
entities.setEnabled(EntityType.ITEM, true);
|
||||
entities.setEnabled(EntityType.ARROW, true);
|
||||
entities.setEnabled(EntityType.SPECTRAL_ARROW, true);
|
||||
entities.setEnabled(EntityType.TRIDENT, true);
|
||||
entities.setDefaultValues(entities.getValues());
|
||||
|
||||
health.onUpdate(v -> healthMode.setVisible(v));
|
||||
}
|
||||
|
||||
public enum HealthMode {
|
||||
POINTS("hp (puntos de vida)"),
|
||||
HEARTS("corazones");
|
||||
|
||||
private final String name;
|
||||
HealthMode(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
entities.onUpdate(entities -> {
|
||||
items.setVisible(entities.get(EntityType.ITEM));
|
||||
});
|
||||
}
|
||||
|
||||
// literalmente cómo lo calcula Minecraft
|
||||
public float getArrowDamage(PersistentProjectileEntity arrow) {
|
||||
if (mc.player == null) return 0;
|
||||
public String getArrowDamage(PersistentProjectileEntity arrow) {
|
||||
if (mc.player == null) return "0";
|
||||
|
||||
double initialDamage = 2;
|
||||
double velocity = arrow.getVelocity().length();
|
||||
DamageSource damageSource = arrow.getDamageSources().arrow(arrow, arrow.getOwner());
|
||||
|
||||
if (arrow.getWeaponStack() != null)
|
||||
if (arrow.getWorld() instanceof ServerWorld world)
|
||||
initialDamage = EnchantmentHelper.getDamage(world, arrow.getWeaponStack(), mc.player, damageSource, (float) initialDamage);
|
||||
if (arrow.getWeaponStack() != null && arrow.getEntityWorld() instanceof ServerWorld world)
|
||||
initialDamage = EnchantmentHelper.getDamage(world, arrow.getWeaponStack(), mc.player, damageSource, (float) initialDamage);
|
||||
|
||||
int finalDamage = MathHelper.ceil(MathHelper.clamp(velocity * initialDamage, 0, 2.147483647E9));
|
||||
|
||||
if (arrow.isCritical()) {
|
||||
long bonus = arrow.getRandom().nextInt(finalDamage / 2 + 2);
|
||||
finalDamage = (int) Math.min(bonus + (long) finalDamage, 2147483647L);
|
||||
}
|
||||
long bonus = 0;
|
||||
if (arrow.isCritical()) bonus = finalDamage / 2 - 1;
|
||||
|
||||
return healthMode.is(HealthMode.HEARTS) ? finalDamage / 2f : finalDamage;
|
||||
if (healthMode.is(HealthMode.HEARTS)) finalDamage /= 2;
|
||||
return finalDamage + (bonus > 0 ? " ~ " + (finalDamage + bonus) : "");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getOwnerName(LazyEntityReference<LivingEntity> owner) {
|
||||
// si el dueño está en línea
|
||||
LivingEntity ownerEntity = owner.resolve(mc.world, LivingEntity.class);
|
||||
if (ownerEntity instanceof PlayerEntity playerEntity) return playerEntity.getName().getString();
|
||||
// si el dueño está en línea (de manera segura)
|
||||
if (mc.world instanceof EntityQueriable<?> queriableWorld) {
|
||||
LivingEntity ownerEntity = owner.resolve(queriableWorld, LivingEntity.class);
|
||||
if (ownerEntity instanceof PlayerEntity playerEntity) return playerEntity.getName().getString();
|
||||
}
|
||||
|
||||
// mirar si ya está en la caché
|
||||
UUID uuid = owner.getUuid();
|
||||
@@ -141,4 +135,13 @@ public class Nametags extends Module {
|
||||
|
||||
return "...";
|
||||
}
|
||||
public enum HealthMode {
|
||||
POINTS("hp (puntos de vida)"),
|
||||
HEARTS("corazones");
|
||||
|
||||
private final String name;
|
||||
HealthMode(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.module.settings.ListSetting;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import me.retucio.camtweaks.util.Lists;
|
||||
import net.minecraft.particle.ParticleType;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.ClientPlayNetworkHandlerMixin
|
||||
* @see me.retucio.camtweaks.mixin.EntityEffectParticleEffectMixin
|
||||
* @see me.retucio.camtweaks.mixin.FogRendererMixin
|
||||
* @see me.retucio.camtweaks.mixin.GameRendererMixin
|
||||
* @see me.retucio.camtweaks.mixin.InGameHudMixin
|
||||
* @see me.retucio.camtweaks.mixin.InGameOverlayRendererMixin
|
||||
* @see me.retucio.camtweaks.mixin.ParticleManagerMixin
|
||||
* @see me.retucio.camtweaks.mixin.StuckArrowsFeatureRendererMixin
|
||||
* @see me.retucio.camtweaks.mixin.TextRendererDrawerMixin
|
||||
* @see me.retucio.camtweaks.mixin.WeatherRenderingMixin
|
||||
*/
|
||||
|
||||
public class NoRender extends Module {
|
||||
|
||||
public BooleanSetting spyglassOverlay = addSetting(new BooleanSetting("catalejo", "renderizar overlay del catalejo", false));
|
||||
public BooleanSetting fluidOverlay = addSetting(new BooleanSetting("fluídos", "renderizar fluídos sobre la cámara como el agua, lava o nieve en polvo (aunque no sea un fluído)", false));
|
||||
public BooleanSetting pumpkinOverlay = addSetting(new BooleanSetting("calabaza", "renderiza el overlay de la calabaza tallada", false));
|
||||
public BooleanSetting fireOverlay = addSetting(new BooleanSetting("fuego", "renderizar llamas sobre la cámara", false));
|
||||
public BooleanSetting portalOverlay = addSetting(new BooleanSetting("portal", "renderizar el overlay del portal del nether", false));
|
||||
|
||||
public BooleanSetting rain = addSetting(new BooleanSetting("lluvia", "l l u v i a", true));
|
||||
public BooleanSetting snow = addSetting(new BooleanSetting("nieve", "n i e v e", true));
|
||||
public BooleanSetting dimensionFog = addSetting(new BooleanSetting("niebla de dimensión", "n i e b l a", true));
|
||||
public BooleanSetting endFlashes; // para cuando actualice
|
||||
|
||||
public ListSetting<ParticleType<?>> particles = addSetting(new ListSetting<>("partículas", "lista de partículas que se renderizan",
|
||||
Lists.particleList, Lists.allTrue(Lists.particleList), Lists.particleNames));
|
||||
|
||||
public BooleanSetting nauseaEffect = addSetting(new BooleanSetting("náusea", "renderizar borrachera", false));
|
||||
public BooleanSetting blindnessEffect = addSetting(new BooleanSetting("ceguera", "renderizar miopía", false));
|
||||
public BooleanSetting darknessEffect = addSetting(new BooleanSetting("oscuridad", "renderizar miedo a la oscuridad", false));
|
||||
public BooleanSetting nightVisionEffect;
|
||||
|
||||
public BooleanSetting scoreboard = addSetting(new BooleanSetting("marcador", "mostrar marcador a la derecha", false));
|
||||
public BooleanSetting titles = addSetting(new BooleanSetting("títulos", "mostrar títulos (del comando /title)", false));
|
||||
public BooleanSetting totemPop = addSetting(new BooleanSetting("tótem", "renderizar el pop del tótem", true));
|
||||
|
||||
public BooleanSetting stuckArrows = addSetting(new BooleanSetting("flechas clavadas", "renderizar flechas clavadas en jugadores", false));
|
||||
|
||||
public BooleanSetting bold = addSetting(new BooleanSetting("negrita", "letra pero §lgorda", true));
|
||||
// public BooleanSetting italics = addSetting(new BooleanSetting("cursiva", "letra pero §otorcida", true));
|
||||
public BooleanSetting underlined = addSetting(new BooleanSetting("subrayado", "letra pero §nen el suelo", true));
|
||||
public BooleanSetting strikethrough = addSetting(new BooleanSetting("tachado", "letra pero §mdiscriminada", true));
|
||||
public EnumSetting<Colors> color = addSetting(new EnumSetting<>("colores", "§co§4r§6g§eu§al§2l§9o §1g§5a§dy", Colors.class, Colors.DEFAULT));
|
||||
public BooleanSetting scrambledText = addSetting(new BooleanSetting("garabato", "engarabatar texto (o como se diga) (§kasí§r)", false));
|
||||
|
||||
public NoRender() {
|
||||
super("no render", "customiza qué se renderiza y qué no");
|
||||
}
|
||||
|
||||
public enum Colors {
|
||||
BLACK("negro"),
|
||||
DARK_BLUE("azul oscuro"),
|
||||
DARK_GREEN("verde"),
|
||||
DARK_AQUA("cian"),
|
||||
DARK_RED("granate"),
|
||||
DARK_PURPLE("morado"),
|
||||
GOLD("naranja"),
|
||||
GRAY("gris claro"),
|
||||
DARK_GRAY("gris oscuro"),
|
||||
BLUE("azul"),
|
||||
GREEN("lima"),
|
||||
AQUA("turquesa"),
|
||||
RED("rojo"),
|
||||
LIGHT_PURPLE("lila"),
|
||||
YELLOW("amarillo"),
|
||||
WHITE("blanco"),
|
||||
DEFAULT("por defecto");
|
||||
|
||||
private final String name;
|
||||
Colors(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
public Formatting toFormatting() { return (Formatting.byColorIndex(this.ordinal())); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.ClientPlayerEntityMixin
|
||||
*/
|
||||
|
||||
public class PortalGUI extends Module {
|
||||
|
||||
public PortalGUI() {
|
||||
super("interfaz en portales", "te permite abrir interfaces dentro de portales, como el chat o el inventario");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.command.CommandManager;
|
||||
import me.retucio.camtweaks.event.events.ClientClickEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.client.texture.NativeImage;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
import net.minecraft.text.HoverEvent;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/** continúa en:
|
||||
* @see me.retucio.camtweaks.mixin.ScreenshotRecorderMixin
|
||||
*/
|
||||
|
||||
public class ScreenshotPlus extends Module {
|
||||
|
||||
public BooleanSetting saveButton = addSetting(new BooleanSetting("botón de guardar", "mostrar botón para guardar la captura localmente", true));
|
||||
public BooleanSetting copyButton = addSetting(new BooleanSetting("botón de copiar", "mostrar botón para copiar la captura al portapapeles", true));
|
||||
public BooleanSetting openButton = addSetting(new BooleanSetting("botón de abrir", "mostrar botón para abrir el archivo de la captura", true));
|
||||
public BooleanSetting discardButton = addSetting(new BooleanSetting("botón de descartar", "mostrar botón para descartar la captura", true));
|
||||
|
||||
public EnumSetting<ScreenshotActions> defaultAction = addSetting(new EnumSetting<>("por defecto", "qué acción tomar por defecto",
|
||||
ScreenshotActions.class, ScreenshotActions.NONE));
|
||||
|
||||
private NativeImage screenshot;
|
||||
private File screenshotFile;
|
||||
|
||||
public ScreenshotPlus() {
|
||||
super("capturas de pantalla", "elige qué hacer tras tomar una captura de pantalla");
|
||||
}
|
||||
|
||||
public void sendScreenshotMessage() {
|
||||
MutableText baseText = Text.literal("captura de pantalla tomada\n");
|
||||
if (saveButton.isEnabled() && !defaultAction.is(ScreenshotActions.SAVE)) baseText.append(getSaveButton().append(" "));
|
||||
if (copyButton.isEnabled()) baseText.append(getCopyButton().append(" "));
|
||||
if (openButton.isEnabled() && defaultAction.is(ScreenshotActions.SAVE)) baseText.append(getOpenButton().append(" "));
|
||||
if (discardButton.isEnabled() && !defaultAction.is(ScreenshotActions.NONE)) baseText.append(getDiscardButton().append(" "));
|
||||
ChatUtil.info(baseText);
|
||||
}
|
||||
|
||||
|
||||
// acciones con la captura
|
||||
|
||||
public void copyScreenshot(NativeImage nativeImage) {
|
||||
try {
|
||||
BufferedImage bufferedImage = new BufferedImage(nativeImage.getWidth(), nativeImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
for (int x = 0; x < nativeImage.getWidth(); x++)
|
||||
for (int y = 0; y < nativeImage.getHeight(); y++)
|
||||
bufferedImage.setRGB(x, y, nativeImage.getColorArgb(x, y));
|
||||
|
||||
ScreenshotPlus.TransferableImage trans = new TransferableImage(bufferedImage);
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(trans, null);
|
||||
ChatUtil.info("captura copiada al portapapeles");
|
||||
} catch (Exception e) {
|
||||
ChatUtil.error("no se pudo copiar la captura al portapapeles");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void copyScreenshot() {
|
||||
copyScreenshot(this.screenshot);
|
||||
}
|
||||
|
||||
public void saveScreenshot(NativeImage image) throws IOException {
|
||||
image.writeTo(screenshotFile);
|
||||
ChatUtil.info(Text.literal("captura guardada como: ").append(
|
||||
Text.literal(screenshotFile.getName())
|
||||
.formatted(Formatting.UNDERLINE)
|
||||
.styled(style -> style.withClickEvent(new ClickEvent.OpenFile(screenshotFile.getAbsoluteFile())))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void saveScreenshot() throws IOException {
|
||||
saveScreenshot(this.screenshot);
|
||||
}
|
||||
|
||||
// clase ayudante para el portapapeles
|
||||
public static class TransferableImage implements Transferable {
|
||||
private final Image image;
|
||||
|
||||
public TransferableImage(Image image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataFlavor[] getTransferDataFlavors() {
|
||||
return new DataFlavor[]{DataFlavor.imageFlavor};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||
return DataFlavor.imageFlavor.equals(flavor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
|
||||
if (!DataFlavor.imageFlavor.equals(flavor))
|
||||
throw new UnsupportedFlavorException(flavor);
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// botones para el mensaje
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
private MutableText getSaveButton() {
|
||||
MutableText button = Text.literal("[GUARDAR]");
|
||||
MutableText hintBaseText = Text.literal("");
|
||||
|
||||
MutableText hintMsg = Text.literal(ScreenshotActions.SAVE.toString());
|
||||
hintMsg.setStyle(hintBaseText.getStyle().withFormatting(Formatting.GRAY));
|
||||
hintBaseText.append(hintMsg);
|
||||
|
||||
button.setStyle(button.getStyle()
|
||||
.withFormatting(Formatting.BOLD, Formatting.GOLD)
|
||||
.withClickEvent(new ClientClickEvent(CommandManager.getCommandByName("guardarcaptura").toString()))
|
||||
.withHoverEvent(new HoverEvent.ShowText(hintBaseText)));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
private MutableText getCopyButton() {
|
||||
MutableText button = Text.literal("[COPIAR]");
|
||||
MutableText hintBaseText = Text.literal("");
|
||||
|
||||
MutableText hintMsg = Text.literal(ScreenshotActions.COPY.toString());
|
||||
hintMsg.setStyle(hintBaseText.getStyle().withFormatting(Formatting.GRAY));
|
||||
hintBaseText.append(hintMsg);
|
||||
|
||||
button.setStyle(button.getStyle()
|
||||
.withFormatting(Formatting.BOLD, Formatting.AQUA)
|
||||
.withClickEvent(new ClientClickEvent(CommandManager.getCommandByName("copiarcaptura").toString()))
|
||||
.withHoverEvent(new HoverEvent.ShowText(hintBaseText)));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
private MutableText getOpenButton() {
|
||||
MutableText button = Text.literal("[ABRIR]");
|
||||
MutableText hintBaseText = Text.literal("");
|
||||
|
||||
MutableText hintMsg = Text.literal("abrir archivo de imagen");
|
||||
hintMsg.setStyle(hintBaseText.getStyle().withFormatting(Formatting.GRAY));
|
||||
hintBaseText.append(hintMsg);
|
||||
|
||||
button.setStyle(button.getStyle()
|
||||
.withFormatting(Formatting.BOLD, Formatting.GRAY)
|
||||
.withClickEvent(new ClickEvent.OpenFile(screenshotFile))
|
||||
.withHoverEvent(new HoverEvent.ShowText(hintBaseText)));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
private MutableText getDiscardButton() {
|
||||
MutableText button = Text.literal("[DESCARTAR]");
|
||||
MutableText hintBaseText = Text.literal("");
|
||||
|
||||
MutableText hintMsg = Text.literal(ScreenshotActions.NONE.toString());
|
||||
hintMsg.setStyle(hintBaseText.getStyle().withFormatting(Formatting.GRAY));
|
||||
hintBaseText.append(hintMsg);
|
||||
|
||||
button.setStyle(button.getStyle()
|
||||
.withFormatting(Formatting.BOLD, Formatting.DARK_RED)
|
||||
.withClickEvent(new ClientClickEvent(CommandManager.getCommandByName("purgar").toString("1")))
|
||||
.withHoverEvent(new HoverEvent.ShowText(hintBaseText)));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
// otros
|
||||
|
||||
public enum ScreenshotActions {
|
||||
SAVE("guardar archivo"),
|
||||
COPY("copiar al portapapeles"),
|
||||
NONE("no hacer nada");
|
||||
|
||||
private final String name;
|
||||
ScreenshotActions(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
|
||||
public NativeImage getScreenshot() {
|
||||
return screenshot;
|
||||
}
|
||||
|
||||
public void setScreenshot(NativeImage screenshot) {
|
||||
this.screenshot = screenshot;
|
||||
}
|
||||
|
||||
public File getScreenshotFile() {
|
||||
return screenshotFile;
|
||||
}
|
||||
|
||||
public void setScreenshotFile(File screenshotFile) {
|
||||
this.screenshotFile = screenshotFile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package me.retucio.camtweaks.module.modules;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.module.settings.KeySetting;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class TooltipsPlus extends Module {
|
||||
|
||||
public EnumSetting<DisplayModes> displayMode = addSetting(new EnumSetting<>(
|
||||
"mostrar", "cúando mostrar la cajita de los huevos", DisplayModes.class, DisplayModes.ALWAYS));
|
||||
|
||||
public KeySetting displayKey = addSetting(new KeySetting(
|
||||
"tecla de visualización", "tecla a presionar para mostrar la cajita", GLFW.GLFW_KEY_LEFT_CONTROL));
|
||||
|
||||
public BooleanSetting middleClickPreview = addSetting(new BooleanSetting("preview de middle click",
|
||||
"abre una interfaz con los contenidos de un bloque de almacenamiento al presionar el middle click (la ruedita)", false));
|
||||
|
||||
public EnumSetting<SizeFormat> itemSize = addSetting(new EnumSetting<>(
|
||||
"tamaño del ítem", "cómo mostrar el tamaño del ítem en memoria", SizeFormat.class, SizeFormat.NONE));
|
||||
|
||||
|
||||
|
||||
public TooltipsPlus() {
|
||||
super("tooltips plus", "mejoras varias a las cajitas de descripción de items");
|
||||
}
|
||||
|
||||
public enum DisplayModes {
|
||||
ALWAYS("siempre"),
|
||||
KEY("al presionar una tecla"),
|
||||
NEVER("nunca");
|
||||
|
||||
final String name;
|
||||
DisplayModes(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
|
||||
public enum SizeFormat {
|
||||
NONE("no mostrar"),
|
||||
BYTES("bytes"),
|
||||
KB("kilobytes"),
|
||||
MB("megabytes");
|
||||
|
||||
final String name;
|
||||
SizeFormat(String name) { this.name = name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,17 +1,21 @@
|
||||
package me.retucio.camtweaks.module.settings;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
|
||||
// base para los tipos de ajustes
|
||||
public class Setting {
|
||||
public abstract class AbstractSetting {
|
||||
|
||||
private final String name;
|
||||
private final String description;
|
||||
|
||||
private boolean visible = true;
|
||||
private boolean searchMatch = true;
|
||||
|
||||
private Module module;
|
||||
|
||||
protected Setting(String name, String description) {
|
||||
protected AbstractSetting(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
@@ -24,6 +28,14 @@ public class Setting {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public boolean isSearchMatch() {
|
||||
return searchMatch;
|
||||
}
|
||||
|
||||
public void setSearchMatch(boolean searchMatch) {
|
||||
this.searchMatch = searchMatch;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -39,4 +51,8 @@ public class Setting {
|
||||
public void setModule(Module module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public void fireUpdateEvent() {
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this, module.shouldSaveSettings()));
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
// ajuste booleano, es decir, o se encuentra encencido o apagado (similar a un interruptor)
|
||||
public class BooleanSetting extends Setting {
|
||||
public class BooleanSetting extends AbstractSetting {
|
||||
|
||||
private boolean defaultValue;
|
||||
private boolean enabled;
|
||||
@@ -31,7 +31,7 @@ public class BooleanSetting extends Setting {
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (this.enabled != enabled) {
|
||||
this.enabled = enabled;
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
fireUpdateEvent();
|
||||
if (updateListener != null) updateListener.accept(enabled);
|
||||
}
|
||||
}
|
||||
@@ -50,5 +50,6 @@ public class BooleanSetting extends Setting {
|
||||
|
||||
public void onUpdate(Consumer<Boolean> listener) {
|
||||
this.updateListener = listener;
|
||||
if (updateListener != null) updateListener.accept(enabled); // actualizar por primera vez
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,8 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
// ajuste que te deja elegir entre distintas opciones definidas, dentro de un Enum
|
||||
public class EnumSetting<E extends Enum<E>> extends Setting {
|
||||
public class EnumSetting<E extends Enum<E>> extends AbstractSetting {
|
||||
|
||||
private final Class<E> enumClass;
|
||||
private final List<E> values;
|
||||
private E defaultValue;
|
||||
|
||||
@@ -21,7 +20,6 @@ public class EnumSetting<E extends Enum<E>> extends Setting {
|
||||
|
||||
public EnumSetting(String name, String description, Class<E> enumClass, E defaultValue) {
|
||||
super(name, description);
|
||||
this.enumClass = enumClass;
|
||||
this.values = Arrays.asList(enumClass.getEnumConstants());
|
||||
this.defaultValue = defaultValue;
|
||||
this.value = defaultValue;
|
||||
@@ -36,7 +34,7 @@ public class EnumSetting<E extends Enum<E>> extends Setting {
|
||||
if (this.value != value) {
|
||||
this.value = value;
|
||||
this.index = values.indexOf(value);
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
fireUpdateEvent();
|
||||
if (updateListener != null) updateListener.accept(value);
|
||||
}
|
||||
}
|
||||
@@ -87,5 +85,6 @@ public class EnumSetting<E extends Enum<E>> extends Setting {
|
||||
|
||||
public void onUpdate(Consumer<E> listener) {
|
||||
this.updateListener = listener;
|
||||
if (updateListener != null) updateListener.accept(value);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
package me.retucio.camtweaks.module.settings;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class KeySetting extends Setting {
|
||||
public class KeySetting extends AbstractSetting {
|
||||
|
||||
private int key;
|
||||
private int defaultKey;
|
||||
@@ -33,21 +31,21 @@ public class KeySetting extends Setting {
|
||||
|
||||
if (key == GLFW.GLFW_KEY_ESCAPE) {
|
||||
this.key = GLFW.GLFW_KEY_UNKNOWN; // asignar la tecla ESC a deshabilitar la tecla
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
fireUpdateEvent();
|
||||
if (updateListener != null) updateListener.accept(key);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ModuleManager.INSTANCE != null) {
|
||||
for (Module module : ModuleManager.INSTANCE.getModules())
|
||||
if (module.getKey() == key && !ClickGUISettingsFrame.guiSettings.multipleKeybinds.isEnabled() && key != -1) {
|
||||
if (module.getKey() == key && !ClientSettingsFrame.guiSettings.multipleKeybinds.isEnabled() && key != -1) {
|
||||
module.setKey(-1);
|
||||
ChatUtil.info("tecla del módulo " + module.getName() + " restablecida");
|
||||
}
|
||||
}
|
||||
this.key = key;
|
||||
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
fireUpdateEvent();
|
||||
if (updateListener != null) updateListener.accept(key);
|
||||
}
|
||||
|
||||
@@ -69,5 +67,6 @@ public class KeySetting extends Setting {
|
||||
|
||||
public void onUpdate(Consumer<Integer> listener) {
|
||||
this.updateListener = listener;
|
||||
if (updateListener != null) updateListener.accept(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package me.retucio.camtweaks.module.settings;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ListSetting<T> extends AbstractSetting {
|
||||
|
||||
private final List<T> options;
|
||||
private Map<T, Boolean> values;
|
||||
private Map<T, Boolean> defaultValues;
|
||||
private Map<T, String> displayNames = null;
|
||||
|
||||
private Consumer<Map<T, Boolean>> updateListener;
|
||||
|
||||
public ListSetting(String name, String description, List<T> options, Map<T, Boolean> initialValues) {
|
||||
super(name, description);
|
||||
this.options = options;
|
||||
this.defaultValues = new HashMap<>();
|
||||
|
||||
for (T option : options) {
|
||||
boolean enabled = initialValues != null && initialValues.getOrDefault(option, false);
|
||||
defaultValues.put(option, enabled);
|
||||
}
|
||||
this.values = new HashMap<>(defaultValues);
|
||||
}
|
||||
|
||||
public ListSetting(String name, String description, List<T> options, Map<T, Boolean> initialValues, Map<T, String> displayNames) {
|
||||
this(name, description, options, initialValues);
|
||||
this.displayNames = displayNames;
|
||||
}
|
||||
|
||||
public boolean isEnabled(T option) {
|
||||
return values.getOrDefault(option, false);
|
||||
}
|
||||
|
||||
public void setEnabled(T option, boolean enabled) {
|
||||
if (values.containsKey(option) && values.get(option) != enabled) {
|
||||
values.put(option, enabled);
|
||||
fireUpdateEvent();
|
||||
if (updateListener != null) updateListener.accept(new HashMap<>(values));
|
||||
}
|
||||
}
|
||||
|
||||
public void toggle(T option) {
|
||||
setEnabled(option, !isEnabled(option));
|
||||
}
|
||||
|
||||
public Map<T, Boolean> getValues() {
|
||||
return new HashMap<>(values);
|
||||
}
|
||||
|
||||
public void setValues(Map<T, Boolean> values) {
|
||||
this.values = new HashMap<>(values);
|
||||
}
|
||||
|
||||
public Map<T, Boolean> getDefaultValues() {
|
||||
return new HashMap<>(defaultValues);
|
||||
}
|
||||
|
||||
public void setDefaultValues(Map<T, Boolean> values) {
|
||||
defaultValues = values;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
values.clear();
|
||||
values.putAll(defaultValues);
|
||||
fireUpdateEvent();
|
||||
if (updateListener != null) updateListener.accept(new HashMap<>(values));
|
||||
}
|
||||
|
||||
public void setAll(boolean enabled) {
|
||||
for (T option : options) values.put(option, enabled);
|
||||
}
|
||||
|
||||
public void onUpdate(Consumer<Map<T, Boolean>> listener) {
|
||||
this.updateListener = listener;
|
||||
if (updateListener != null) updateListener.accept(new HashMap<>(values));
|
||||
}
|
||||
|
||||
public List<T> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public Map<T, String> getDisplayNames() {
|
||||
return displayNames;
|
||||
}
|
||||
|
||||
public String getDisplayName(T key) {
|
||||
if (displayNames != null) return displayNames.get(key);
|
||||
return key.toString();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
// ajuste numérico, es decir, que eliges un valor númerico entre el mínimo y el máximo disponibles
|
||||
public class NumberSetting extends Setting {
|
||||
public class NumberSetting extends AbstractSetting {
|
||||
|
||||
private double value;
|
||||
private double defaultValue;
|
||||
@@ -60,7 +60,7 @@ public class NumberSetting extends Setting {
|
||||
if (this.value == value) return;
|
||||
double clamped = clamp(value, min, max);
|
||||
this.value = Math.round(clamped / increment) * increment;
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
fireUpdateEvent();
|
||||
if (updateListener != null) updateListener.accept(this.value);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,6 @@ public class NumberSetting extends Setting {
|
||||
|
||||
public void onUpdate(Consumer<Double> listener) {
|
||||
this.updateListener = listener;
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
if (updateListener != null) updateListener.accept(value);
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,9 @@ package me.retucio.camtweaks.module.settings;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class StringSetting extends Setting {
|
||||
public class StringSetting extends AbstractSetting {
|
||||
|
||||
private String value;
|
||||
private String defaultValue;
|
||||
@@ -28,7 +27,7 @@ public class StringSetting extends Setting {
|
||||
public void setValue(String value) {
|
||||
if (this.value.equals(value)) return;
|
||||
this.value = value.length() > maxLength ? value.substring(0, maxLength) : value;
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
fireUpdateEvent();
|
||||
if (updateListener != null) updateListener.accept(this.value);
|
||||
}
|
||||
|
||||
@@ -50,6 +49,6 @@ public class StringSetting extends Setting {
|
||||
|
||||
public void onUpdate(Consumer<String> listener) {
|
||||
this.updateListener = listener;
|
||||
CameraTweaks.EVENT_BUS.post(new UpdateSettingEvent(this));
|
||||
if (updateListener != null) updateListener.accept(value);
|
||||
}
|
||||
}
|
||||
@@ -2,30 +2,49 @@ package me.retucio.camtweaks.ui;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.KeyEvent;
|
||||
import me.retucio.camtweaks.event.events.MouseClickEvent;
|
||||
import me.retucio.camtweaks.event.events.MouseScrollEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.SettingsFrameEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.module.settings.AbstractSetting;
|
||||
import me.retucio.camtweaks.ui.buttons.ListButton;
|
||||
import me.retucio.camtweaks.ui.buttons.SettingButton;
|
||||
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.ModuleFrame;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.ui.widgets.ScrollBarWidget;
|
||||
import me.retucio.camtweaks.ui.widgets.SearchBarWidget;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.Click;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame.guiSettings;
|
||||
import static me.retucio.camtweaks.ui.frames.ClientSettingsFrame.guiSettings;
|
||||
|
||||
// interfaz gráfica, se abre con el shift derecho por defecto. aquí se encuentran los módulos y sus ajustes
|
||||
public class ClickGUI extends Screen {
|
||||
|
||||
public static ClickGUI INSTANCE;
|
||||
private boolean anyFocused;
|
||||
private Object selected = null;
|
||||
|
||||
private final ModuleFrame modulesFrame = new ModuleFrame(20, 30, 100, 20);
|
||||
private final List<SettingsFrame> settingsFrames = new ArrayList<>();
|
||||
private final ClickGUISettingsFrame guiSettingsFrame = new ClickGUISettingsFrame(200, 30, 100, 20);
|
||||
private final ClientSettingsFrame guiSettingsFrame = new ClientSettingsFrame(200, 30, 100, 20);
|
||||
|
||||
private final ScrollBarWidget scrollBar = new ScrollBarWidget();
|
||||
private final SearchBarWidget searchBar = new SearchBarWidget(340, 16, 300, 20);
|
||||
|
||||
private final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public ClickGUI() {
|
||||
super(Text.of("interfaz"));
|
||||
@@ -35,6 +54,21 @@ public class ClickGUI extends Screen {
|
||||
|
||||
@Override
|
||||
public void render(DrawContext ctx, int mouseX, int mouseY, float delta) {
|
||||
scrollBar.setWindowHeight(mc.getWindow().getScaledHeight());
|
||||
scrollBar.setContentHeight(calculateContentHeight());
|
||||
scrollBar.render(ctx, mouseX, mouseY);
|
||||
|
||||
int scrollOffset = scrollBar.getScrollOffset();
|
||||
|
||||
searchBar.updateRenderY(scrollOffset);
|
||||
searchBar.render(ctx, mouseX, mouseY, delta);
|
||||
searchBar.updatePosition(mouseX, mouseY);
|
||||
|
||||
// actualizar la posición de renderizado vertical de los marcos cada tick
|
||||
modulesFrame.updateRenderY(scrollOffset);
|
||||
for (SettingsFrame sf : settingsFrames)
|
||||
sf.updateRenderY(scrollOffset);
|
||||
|
||||
// renderizar el marco de los ajustes de cada módulo que lo tenga abierto. se abre haciendo clic derecho sobre el módulo
|
||||
for (SettingsFrame sf : settingsFrames.reversed()) {
|
||||
sf.render(ctx, mouseX, mouseY, delta);
|
||||
@@ -45,36 +79,105 @@ public class ClickGUI extends Screen {
|
||||
modulesFrame.render(ctx, mouseX, mouseY, delta);
|
||||
modulesFrame.updatePosition(mouseX, mouseY);
|
||||
|
||||
for (SettingsFrame sf : settingsFrames)
|
||||
sf.drawTooltips(ctx, mouseX, mouseY);
|
||||
|
||||
filterSearchResults();
|
||||
|
||||
super.render(ctx, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
// detectar clics sobre los marcos
|
||||
modulesFrame.mouseClicked(mouseX, mouseY, button);
|
||||
for (SettingsFrame sf : new ArrayList<>(settingsFrames))
|
||||
sf.mouseClicked(mouseX, mouseY, button);
|
||||
private int calculateContentHeight() {
|
||||
int bottom = modulesFrame.y + modulesFrame.h + modulesFrame.totalHeight;
|
||||
for (SettingsFrame frame : settingsFrames)
|
||||
bottom = Math.max(bottom, frame.y + frame.h + frame.totalHeight);
|
||||
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
return bottom + 20; // padding
|
||||
}
|
||||
|
||||
|
||||
public boolean mouseClicked(Click click, boolean doubled) {
|
||||
scrollBar.mouseClicked(click.x(), click.y(), click.button());
|
||||
searchBar.mouseClicked(click.x(), click.y(), click.button());
|
||||
|
||||
// detectar clics sobre los marcos
|
||||
modulesFrame.mouseClicked(click.x(), click.y(), click.button());
|
||||
for (SettingsFrame sf : new ArrayList<>(settingsFrames))
|
||||
sf.mouseClicked(click.x(), click.y(), click.button());
|
||||
|
||||
return super.mouseClicked(click, doubled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
public boolean mouseReleased(Click click) {
|
||||
scrollBar.mouseReleased(click.x(), click.y(), click.button());
|
||||
searchBar.mouseReleased(click.x(), click.y(), click.button());
|
||||
|
||||
// registrar cuándo se suelta el clic, en cada marco respectivamente
|
||||
modulesFrame.mouseReleased(mouseX, mouseY, button);
|
||||
modulesFrame.mouseReleased(click.x(), click.y(), click.button());
|
||||
for (SettingsFrame sf : new ArrayList<>(settingsFrames))
|
||||
sf.mouseRelease(mouseX, mouseY, button);
|
||||
return super.mouseReleased(mouseX, mouseY, button);
|
||||
sf.mouseRelease(click.x(), click.y(), click.button());
|
||||
return super.mouseReleased(click);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(Click click, double deltaX, double deltaY) {
|
||||
scrollBar.mouseDragged(click.y());
|
||||
return super.mouseDragged(click, deltaX, deltaY);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKey(KeyEvent event) {
|
||||
searchBar.onKey(event.getKey(), event.getAction());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMouseScroll(MouseScrollEvent event) {
|
||||
// subir y bajar la pantalla con la rueda del ratón
|
||||
if (CameraTweaks.mc.currentScreen != this) return;
|
||||
scrollBar.onMouseScroll(event.getVertical() * guiSettings.scrollSens.getValue());
|
||||
}
|
||||
|
||||
modulesFrame.y += (int) (event.getVertical() * guiSettings.scrollSens.getValue());
|
||||
for (SettingsFrame sf : settingsFrames)
|
||||
sf.y += (int) (event.getVertical() * guiSettings.scrollSens.getValue());
|
||||
@SubscribeEvent
|
||||
public void onMouseMiddleButton(MouseClickEvent event) {
|
||||
// mover todos los marcos a un punto visible al presionar shift + la rueda del ratón
|
||||
if (CameraTweaks.mc.currentScreen != this || event.getButton() != 2 || !KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) return;
|
||||
|
||||
int h = CameraTweaks.mc.getWindow().getScaledHeight();
|
||||
int minY = Math.min(modulesFrame.y, settingsFrames.stream().mapToInt(sf -> sf.y).min().orElse(modulesFrame.y));
|
||||
int maxY = Math.max(modulesFrame.y + modulesFrame.h, settingsFrames.stream().mapToInt(sf -> sf.y + sf.h).max().orElse(modulesFrame.y + modulesFrame.h));
|
||||
int correction = minY < 0 ? -minY + 4 : (maxY > h ? h - maxY - 4 : 0);
|
||||
|
||||
if (correction != 0) {
|
||||
modulesFrame.y += correction;
|
||||
settingsFrames.forEach(sf -> sf.y += correction);
|
||||
}
|
||||
}
|
||||
|
||||
public void filterSearchResults() {
|
||||
if (!guiSettings.searchBar.isEnabled()) return;
|
||||
String searchInput = searchBar.getSearchInput().trim();
|
||||
if (!guiSettings.matchCase.isEnabled()) searchInput = searchInput.toLowerCase();
|
||||
|
||||
for (SettingsFrame sf : settingsFrames) {
|
||||
for (SettingButton sb : sf.getButtons()) {
|
||||
AbstractSetting setting = sb.getSetting();
|
||||
|
||||
if (searchInput.isEmpty()) {
|
||||
setting.setSearchMatch(true);
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = setting.getName();
|
||||
String description = setting.getDescription();
|
||||
|
||||
if (!guiSettings.matchCase.isEnabled()) {
|
||||
name = name.toLowerCase();
|
||||
description = description.toLowerCase();
|
||||
}
|
||||
|
||||
setting.setSearchMatch(name.contains(searchInput) || description.contains(searchInput));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void openSettingsFrame(Module module, int x, int y) {
|
||||
@@ -85,6 +188,12 @@ public class ClickGUI extends Screen {
|
||||
CameraTweaks.EVENT_BUS.post(new SettingsFrameEvent.Open(frame));
|
||||
}
|
||||
|
||||
public void openListSettingsFrame(Module module, int x, int y) {
|
||||
if (isSettingsFrameOpen(module)) return;
|
||||
SettingsFrame frame = new SettingsFrame(module, x, y, 120, 18);
|
||||
settingsFrames.add(frame);
|
||||
}
|
||||
|
||||
// cerrar el marco de ajustes
|
||||
public void closeSettingsFrame(Module module) {
|
||||
// porque java.util.ConcurrentModificationException o algo no sé es lo único que se me ha ocurrido hacer
|
||||
@@ -93,6 +202,7 @@ public class ClickGUI extends Screen {
|
||||
if (sf.module == module) {
|
||||
CameraTweaks.EVENT_BUS.post(new SettingsFrameEvent.Close(sf));
|
||||
toRemove.add(sf);
|
||||
unselect(sf);
|
||||
}
|
||||
}
|
||||
settingsFrames.removeAll(toRemove);
|
||||
@@ -104,30 +214,92 @@ public class ClickGUI extends Screen {
|
||||
.anyMatch(sf -> sf.module.getName().equals(module.getName()));
|
||||
}
|
||||
|
||||
// no pausar el juego cuando se abre la interfaz
|
||||
|
||||
|
||||
public void refreshListButtons() {
|
||||
for (SettingsFrame frame : settingsFrames)
|
||||
for (SettingButton button : frame.getButtons())
|
||||
if (button instanceof ListButton<?> lb)
|
||||
lb.refreshDummy();
|
||||
}
|
||||
|
||||
|
||||
// métodos del súper
|
||||
|
||||
@Override
|
||||
public void close() { // evitar que al reabrir la interfaz sin previamente haber soltado el clic, se sigan arrastrando objetos
|
||||
modulesFrame.mouseReleased(0, 0, 0);
|
||||
settingsFrames.forEach(sf -> sf.mouseRelease(0, 0, 0));
|
||||
scrollBar.mouseReleased(0, 0, 0);
|
||||
searchBar.mouseReleased(0, 0, 0);
|
||||
|
||||
unselect(selected);
|
||||
super.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPause() {
|
||||
// no pausar el juego cuando se abre la interfaz
|
||||
return false;
|
||||
}
|
||||
|
||||
public ModuleFrame getModulesFrame() {
|
||||
return modulesFrame;
|
||||
}
|
||||
|
||||
public ClickGUISettingsFrame getGuiSettingsFrame() {
|
||||
return guiSettingsFrame;
|
||||
}
|
||||
|
||||
public void setAnyFocused(boolean anyFocused) {
|
||||
this.anyFocused = anyFocused;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCloseOnEsc() {
|
||||
return super.shouldCloseOnEsc() && !anyFocused;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyBlur(DrawContext ctx) {
|
||||
if (guiSettings.blur.isEnabled()) super.applyBlur(ctx);
|
||||
}
|
||||
|
||||
|
||||
// getters y setters de widgets
|
||||
|
||||
public ModuleFrame getModulesFrame() {
|
||||
return modulesFrame;
|
||||
}
|
||||
|
||||
public ClientSettingsFrame getGuiSettingsFrame() {
|
||||
return guiSettingsFrame;
|
||||
}
|
||||
|
||||
public List<SettingsFrame> getSettingsFrames() {
|
||||
return settingsFrames;
|
||||
}
|
||||
|
||||
public SearchBarWidget getSearchBar() {
|
||||
return searchBar;
|
||||
}
|
||||
|
||||
public void setAnyFocused(boolean anyFocused) {
|
||||
this.anyFocused = anyFocused;
|
||||
}
|
||||
|
||||
|
||||
// selección de widgets
|
||||
|
||||
public Object getSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setSelected(Object object) {
|
||||
this.selected = object;
|
||||
}
|
||||
|
||||
public boolean canSelect(Object object) {
|
||||
return getSelected() == null || getSelected() == object;
|
||||
}
|
||||
|
||||
public boolean trySelect(Object object) {
|
||||
if (canSelect(object)) {
|
||||
setSelected(object);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void unselect(Object object) {
|
||||
if (selected == object) setSelected(null);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.retucio.camtweaks.ui;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
|
||||
// en un principio esto iba a mostrar en pantalla los módulos activados, pero me parece innecesario. se queda aquí por si acaso
|
||||
// igual lo uso para algo...
|
||||
public class HUD {
|
||||
|
||||
private static final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public static void render(DrawContext ctx, RenderTickCounter tc) {}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package me.retucio.camtweaks.ui;
|
||||
|
||||
import me.retucio.camtweaks.config.ConfigManager;
|
||||
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.ui.widgets.HudElement;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.Click;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.input.KeyInput;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HudEditorScreen extends Screen {
|
||||
|
||||
public static HudEditorScreen INSTANCE;
|
||||
private final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
private final List<HudElement> elements = new ArrayList<>();
|
||||
@Nullable private HudElement selected = null;
|
||||
|
||||
private boolean dragging = false;
|
||||
private int dragOffsetX, dragOffsetY;
|
||||
|
||||
public HudEditorScreen() {
|
||||
super(Text.literal("editor del hud"));
|
||||
}
|
||||
|
||||
public void setElements(List<HudElement> elements) {
|
||||
this.elements.clear();
|
||||
this.elements.addAll(elements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext ctx, int mouseX, int mouseY, float delta) {
|
||||
ctx.fill(0, 0, this.width, this.height, Colors.hudEditorScreenBackgroundColor.getRGB());
|
||||
|
||||
// texto con instrucciones
|
||||
ctx.drawCenteredTextWithShadow(mc.textRenderer, "EDITOR DEL HUD", this.width / 2, this.height / 2 - mc.textRenderer.fontHeight, -1);
|
||||
ctx.drawCenteredTextWithShadow(mc.textRenderer,
|
||||
Text.literal("arrastrar para mover · click derecho para alternar visibilidad · esc para guardar y salir · shift + click derecho para restablecer"),
|
||||
this.width / 2, this.height / 2 + mc.textRenderer.fontHeight, Colors.instructionsTextColor.getRGB());
|
||||
|
||||
// dibujar elementos
|
||||
for (HudElement element : elements)
|
||||
element.renderPreview(ctx);
|
||||
|
||||
// tooltips con información sobre el elemento sobre el que está el puntero del ratón
|
||||
if (!dragging) {
|
||||
for (HudElement element : elements) {
|
||||
if (!element.isVisible()) continue;
|
||||
|
||||
if (element.contains(mouseX, mouseY)) {
|
||||
List<Text> tooltip = getTooltipFor(element);
|
||||
if (!tooltip.isEmpty()) ctx.drawTooltip(mc.textRenderer, tooltip, mouseX + 7, mouseY + 20);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.render(ctx, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(Click click, boolean doubled) {
|
||||
int mouseX = (int) click.x();
|
||||
int mouseY = (int) click.y();
|
||||
|
||||
// iterar de atrás a adelante para respetar el orden z
|
||||
for (int i = elements.size() - 1; i >= 0; i--) {
|
||||
HudElement element = elements.get(i);
|
||||
if (element.contains(mouseX, mouseY)) {
|
||||
selected = element;
|
||||
|
||||
if (click.button() == 0) {
|
||||
dragging = true;
|
||||
|
||||
dragOffsetX = mouseX - element.getX();
|
||||
dragOffsetY = mouseY - element.getY();
|
||||
|
||||
// traer el elemento seleccionado al frente
|
||||
elements.remove(i);
|
||||
elements.add(element);
|
||||
return true;
|
||||
|
||||
} else if (click.button() == 1) {
|
||||
if (mc.isShiftPressed())
|
||||
selected.resetPosition();
|
||||
else
|
||||
selected.setVisible(!selected.isVisible());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.mouseClicked(click, doubled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(Click click, double deltaX, double deltaY) {
|
||||
if (!dragging || selected == null || click.button() != 0)
|
||||
return super.mouseDragged(click, deltaX, deltaY);
|
||||
|
||||
int mouseX = (int) click.x();
|
||||
int mouseY = (int) click.y();
|
||||
|
||||
int newX = mouseX - dragOffsetX;
|
||||
int newY = mouseY - dragOffsetY;
|
||||
|
||||
// clampear para evitar que los elementos se salgan de la pantalla
|
||||
newX = Math.max(1, Math.min(newX, width - selected.getWidth() - 1));
|
||||
newY = Math.max(1, Math.min(newY, height - selected.getHeight() - 1));
|
||||
|
||||
selected.setPosition(newX, newY);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(Click click) {
|
||||
if (dragging && click.button() == 0) {
|
||||
dragging = false;
|
||||
savePositionsToConfig(); // guardar inmediatamente al config
|
||||
return true;
|
||||
} else if (click.button() == 1 && selected != null) {
|
||||
saveVisibilitiesToConfig();
|
||||
selected = null;
|
||||
return true;
|
||||
}
|
||||
selected = null;
|
||||
return super.mouseReleased(click);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(KeyInput input) {
|
||||
// esc para guardar y salir
|
||||
if (input.key() == GLFW.GLFW_KEY_ESCAPE) {
|
||||
saveAndClose();
|
||||
return true;
|
||||
}
|
||||
return super.keyPressed(input);
|
||||
}
|
||||
|
||||
private void savePositionsToConfig() {
|
||||
for (HudElement element : elements)
|
||||
ConfigManager.setHudPosition(element.getId(), element.getX(), element.getY());
|
||||
|
||||
ConfigManager.save();
|
||||
}
|
||||
|
||||
private void saveVisibilitiesToConfig() {
|
||||
for (HudElement element : elements)
|
||||
ConfigManager.setHudVisibility(element.getId(), element.isVisible());
|
||||
|
||||
ConfigManager.save();
|
||||
}
|
||||
|
||||
private void saveAndClose() {
|
||||
savePositionsToConfig();
|
||||
selected = null;
|
||||
mc.setScreen(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyBlur(DrawContext ctx) {
|
||||
if (ClientSettingsFrame.guiSettings.blur.isEnabled()) super.applyBlur(ctx);
|
||||
}
|
||||
|
||||
public boolean isSelected(HudElement element) {
|
||||
return selected == element;
|
||||
}
|
||||
|
||||
// para los tooltips
|
||||
private List<Text> getTooltipFor(HudElement element) {
|
||||
List<Text> list = new ArrayList<>();
|
||||
|
||||
switch (element.getId()) {
|
||||
case "coords" -> {
|
||||
list.add(Text.literal("coordenadas"));
|
||||
list.add(Text.literal("te muestra tu posición en el mundo en coordenadas XYZ"));
|
||||
}
|
||||
case "fps" -> {
|
||||
list.add(Text.literal("FPS"));
|
||||
list.add(Text.literal("te muestra la tasa de fotogramas por segundo del juego"));
|
||||
}
|
||||
case "tps" -> {
|
||||
list.add(Text.literal("tps"));
|
||||
list.add(Text.literal("te muestra la tasa de ticks por segundo del servidor (0-20)"));
|
||||
}
|
||||
case "customText" -> {
|
||||
list.add(Text.literal("texto custom"));
|
||||
list.add(Text.literal("te permite renderizar texto al gusto"));
|
||||
}
|
||||
case "time" -> {
|
||||
list.add(Text.literal("hora"));
|
||||
list.add(Text.literal("te muestra la hora y los minutos de la zona horaria escogida"));
|
||||
}
|
||||
default -> {
|
||||
list.add(Text.literal(element.getId()));
|
||||
list.add(Text.literal("."));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package me.retucio.camtweaks.ui;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.config.ConfigManager;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.PacketEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.UpdateSettingEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.HUD;
|
||||
import me.retucio.camtweaks.ui.widgets.HudElement;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class HudRenderer {
|
||||
|
||||
private static final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
private static float estimatedTPS = 20f;
|
||||
private long lastPacketTime = 0;
|
||||
|
||||
private static final Map<String, int[]> positions = ConfigManager.getConfig().hudPositions;
|
||||
private static final Map<String, Boolean> visibilities = ConfigManager.getConfig().hudVisibilities;
|
||||
private static final List<HudElement> elements = new ArrayList<>();
|
||||
private static boolean initialized = false;
|
||||
|
||||
private static HudElement customTextElement = null;
|
||||
|
||||
public static void initElements() {
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
|
||||
HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class);
|
||||
|
||||
// coordenadas
|
||||
addElement("coords", 2, mc.getWindow().getScaledHeight() - mc.textRenderer.fontHeight, (ctx, mx, my, delta) -> {
|
||||
drawSnappedText(ctx, getElementText("coords", delta, hud), mx, my, getColor(hud).getRGB(), hud.shadow.isEnabled());
|
||||
});
|
||||
|
||||
// FPS
|
||||
addElement("fps", 2, 2, (ctx, mx, my, delta) -> {
|
||||
drawSnappedText(ctx, getElementText("fps", 0, hud), mx, my, getColor(hud).getRGB(), hud.shadow.isEnabled());
|
||||
});
|
||||
|
||||
// TPS
|
||||
addElement("tps", 2, mc.textRenderer.fontHeight + 4, (ctx, mx, my, delta) -> {
|
||||
drawSnappedText(ctx, getElementText("tps", delta, hud), mx, my, getColor(hud).getRGB(), hud.shadow.isEnabled());
|
||||
});
|
||||
|
||||
// texto custom
|
||||
addElement("customText", mc.getWindow().getScaledWidth() / 2 - mc.textRenderer.getWidth(getElementText("customText", 0, ModuleManager.INSTANCE.getModuleByClass(HUD.class))) / 2, 2, (ctx, mx, my, delta) -> {
|
||||
drawSnappedText(ctx, getElementText("customText", delta, hud), mx, my, getColor(hud).getRGB(), hud.shadow.isEnabled());
|
||||
});
|
||||
|
||||
customTextElement = elements.stream()
|
||||
.filter(e -> e.getId().equals("customText"))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
// hora
|
||||
addElement("time", mc.getWindow().getScaledWidth() - mc.textRenderer.getWidth("04:20"), mc.getWindow().getScaledHeight() - mc.textRenderer.fontHeight - 2, (ctx, mx, my, delta) -> {
|
||||
drawSnappedText(ctx, getElementText("time", delta, hud), mx, my, getColor(hud).getRGB(), hud.shadow.isEnabled());
|
||||
});
|
||||
|
||||
HudEditorScreen.INSTANCE.setElements(getElements());
|
||||
}
|
||||
|
||||
private static void addElement(String id, int defX, int defY, HudElement.Renderer renderer) {
|
||||
int[] saved = positions.get(id);
|
||||
Boolean visible = visibilities.get(id);
|
||||
int x = saved == null ? defX : saved[0];
|
||||
int y = saved == null ? defY : saved[1];
|
||||
boolean v = visible == null || visible;
|
||||
if (visibilities.isEmpty()) v = true;
|
||||
|
||||
elements.add(new HudElement(id, defX, defY, x, y, v) {
|
||||
@Override public void render(DrawContext ctx, int mx, int my, float delta) {
|
||||
renderer.render(ctx, x, y, delta);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Color getColor(HUD hud) {
|
||||
if (hud.rainbow.isEnabled()) {
|
||||
float speed = 10001 - hud.rainbowSpeed.getFloatValue();
|
||||
float hue = (System.currentTimeMillis() % (int) speed) / speed;
|
||||
Color rgb = Color.getHSBColor(hue, 1, 1);
|
||||
return new Color(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), hud.alpha.getIntValue());
|
||||
}
|
||||
return new Color(hud.red.getIntValue(), hud.green.getIntValue(), hud.blue.getIntValue(), hud.alpha.getIntValue());
|
||||
}
|
||||
|
||||
public static void drawSnappedText(DrawContext ctx, String text, int x, int y, int color, boolean shadow) {
|
||||
int textWidth = mc.textRenderer.getWidth(text);
|
||||
int screenWidth = mc.getWindow().getScaledWidth();
|
||||
int screenHeight = mc.getWindow().getScaledHeight();
|
||||
|
||||
boolean snapRight = x > screenWidth / 2;
|
||||
int drawX = snapRight ? x + (textWidth + 2) - textWidth : x;
|
||||
|
||||
// clampear y
|
||||
y = Math.max(0, Math.min(y, screenHeight - mc.textRenderer.fontHeight));
|
||||
|
||||
// clampear x
|
||||
drawX = Math.max(0, Math.min(drawX, screenWidth - textWidth));
|
||||
|
||||
ctx.drawText(mc.textRenderer, text, drawX, y, color, shadow);
|
||||
}
|
||||
|
||||
public static void render(DrawContext ctx, RenderTickCounter tc) {
|
||||
if (ModuleManager.INSTANCE == null
|
||||
|| mc.player == null
|
||||
|| mc.getCameraEntity() == null
|
||||
|| mc.currentScreen instanceof TitleScreen
|
||||
|| mc.options.hudHidden)
|
||||
return;
|
||||
|
||||
HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class);
|
||||
if (!hud.isEnabled()) return;
|
||||
if (mc.getDebugHud().shouldShowDebugHud() && !hud.showOnF3.isEnabled()) return;
|
||||
|
||||
initElements();
|
||||
|
||||
if (mc.currentScreen instanceof HudEditorScreen) return;
|
||||
|
||||
float deltaTime = tc.getDynamicDeltaTicks();
|
||||
for (HudElement element : elements)
|
||||
if (element.isVisible()) element.render(ctx, 0, 0, deltaTime);
|
||||
}
|
||||
|
||||
public static List<HudElement> getElements() {
|
||||
return elements;
|
||||
}
|
||||
|
||||
// texto a dibujar por elemento
|
||||
public static String getElementText(String id, float delta, HUD hud) {
|
||||
switch (id) {
|
||||
case "coords" -> {
|
||||
Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
Vec3d pos = freecam.isEnabled()
|
||||
? new Vec3d(freecam.getX(delta), freecam.getY(delta), freecam.getZ(delta))
|
||||
: mc.player.getEntityPos();
|
||||
|
||||
return (int) pos.x + " " + (int) pos.y + " " + (int) pos.z;
|
||||
}
|
||||
case "fps" -> {
|
||||
return "FPS: " + mc.getCurrentFps();
|
||||
}
|
||||
case "tps" -> {
|
||||
return "TPS: " + estimatedTPS;
|
||||
}
|
||||
case "customText" -> {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(HUD.class).customText.getValue();
|
||||
}
|
||||
case "time" -> {
|
||||
ZoneOffset offset = ZoneOffset.ofHours(hud.timezone.getIntValue());
|
||||
LocalTime now = LocalTime.now(offset);
|
||||
|
||||
boolean is24 = hud.timeFormat.is(HUD.TimeFormat.TWENTY_FOUR_HOUR);
|
||||
DateTimeFormatter format = DateTimeFormatter.ofPattern(is24 ? "HH:mm" : "hh:mm a");
|
||||
return now.format(format);
|
||||
}
|
||||
default -> { return id; }
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onReceivePacket(PacketEvent.Receive event) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (lastPacketTime > 0) {
|
||||
float tps = 1000f / (now - lastPacketTime);
|
||||
estimatedTPS = Math.min(20f, tps);
|
||||
}
|
||||
lastPacketTime = now;
|
||||
}
|
||||
|
||||
/** para cuando se cambie el valor del texto custom */
|
||||
@SubscribeEvent
|
||||
public void onUpdateSetting(UpdateSettingEvent event) {
|
||||
HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class);
|
||||
|
||||
if (event.getSetting() == hud.customText) {
|
||||
if (customTextElement != null) {
|
||||
int newX = mc.getWindow().getScaledWidth() / 2 - mc.textRenderer.getWidth(hud.customText.getValue()) / 2;
|
||||
customTextElement.setX(newX);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,23 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.settings.KeySetting;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.input.KeyInput;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
// botón para configurar la tecla asignada a un módulo. comienza a escuchar al hacerle clic
|
||||
public class BindButton extends SettingButton {
|
||||
|
||||
@@ -23,25 +32,19 @@ public class BindButton extends SettingButton {
|
||||
@Override
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
int bgColor = isHovered((int) mouseX, (int) mouseY)
|
||||
? Colors.hoveredSettingButtonColor
|
||||
: Colors.settingButtonColor;
|
||||
? Colors.buttonColor.brighter().getRGB()
|
||||
: Colors.buttonColor.getRGB();
|
||||
|
||||
ctx.fill(x, y, x + w, y + height, bgColor);
|
||||
ctx.fill(x, y, x + w, y + h, bgColor);
|
||||
String label = setting.getName() + ": " + (listening ? "..." : setting.getKeyName());
|
||||
ctx.drawTextWithShadow(parent.mc.textRenderer, label, x + 5, y + 3, -1);
|
||||
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
Screen currentScreen = parent.mc.currentScreen;
|
||||
if (currentScreen != null)
|
||||
ctx.drawTooltip(Text.of(setting.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
ctx.drawText(parent.mc.textRenderer, label, x + 5, y + 3, -1, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
if (isHovered((int) mouseX, (int) mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
|
||||
if (button == 0) listening = !listening;
|
||||
else if (button == 1 && KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT))
|
||||
else if (button == 1 && mc.isShiftPressed())
|
||||
setting.reset();
|
||||
} else {
|
||||
listening = false;
|
||||
@@ -49,15 +52,29 @@ public class BindButton extends SettingButton {
|
||||
}
|
||||
|
||||
public void onKey(int key, int action) {
|
||||
if (listening && action == GLFW.GLFW_PRESS) {
|
||||
if (key == GLFW.GLFW_KEY_ESCAPE)
|
||||
setting.setKey(GLFW.GLFW_KEY_UNKNOWN);
|
||||
else
|
||||
setting.setKey(key);
|
||||
listening = false;
|
||||
if (!listening || action != GLFW.GLFW_PRESS) return;
|
||||
|
||||
if (key == GLFW.GLFW_KEY_ESCAPE) {
|
||||
setting.setKey(GLFW.GLFW_KEY_UNKNOWN);
|
||||
} else {
|
||||
for (KeyBinding bind : mc.options.allKeys) {
|
||||
boolean keyAlreadyBound = bind.matchesKey(new KeyInput(key, 0, 0));
|
||||
boolean allowMultiple = ClientSettingsFrame.guiSettings.multipleKeybinds.isEnabled();
|
||||
|
||||
if (keyAlreadyBound && !allowMultiple) {
|
||||
ChatUtil.warn("esa tecla ya está cogida por "
|
||||
+ Formatting.GREEN + "\"" + I18n.translate(bind.getId()) + "\"");
|
||||
listening = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
setting.setKey(key);
|
||||
}
|
||||
|
||||
listening = false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isFocused() {
|
||||
return listening;
|
||||
}
|
||||
@@ -67,5 +84,7 @@ public class BindButton extends SettingButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {}
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||
ClickGUI.INSTANCE.unselect(this);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.settings.EnumSetting;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
@@ -13,6 +14,8 @@ import org.lwjgl.glfw.GLFW;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
// botón para los ajustes tipo EnumSetting (de modo)
|
||||
public class CycleButton<E extends Enum<E>> extends SettingButton {
|
||||
|
||||
@@ -26,20 +29,22 @@ public class CycleButton<E extends Enum<E>> extends SettingButton {
|
||||
@Override
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
int bgColor = isHovered((int) mouseX, (int) mouseY)
|
||||
? Colors.hoveredSettingButtonColor
|
||||
: Colors.settingButtonColor;
|
||||
? Colors.buttonColor.brighter().getRGB()
|
||||
: Colors.buttonColor.getRGB();
|
||||
|
||||
ctx.fill(x, y, x + w, y + height, bgColor); // fondo del botón
|
||||
ctx.fill(x, y, x + w, y + h, bgColor); // fondo del botón
|
||||
|
||||
// texto del botón: nombre + valor de texto del enum
|
||||
String label = setting.getName() + ": " + setting.getValue().toString();
|
||||
ctx.drawTextWithShadow(parent.mc.textRenderer, label, x + 5, y + 3, -1);
|
||||
ctx.drawText(parent.mc.textRenderer, label, x + 5, y + 3, -1, true);
|
||||
}
|
||||
|
||||
// tooltip
|
||||
@Override
|
||||
public void drawTooltip(DrawContext ctx, double mouseX, double mouseY) {
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
Screen currentScreen = parent.mc.currentScreen;
|
||||
if (currentScreen != null) {
|
||||
if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) {
|
||||
if (mc.isShiftPressed()) {
|
||||
List<Text> lines = new ArrayList<>();
|
||||
lines.add(Text.literal("modos disponibles:"));
|
||||
for (Enum<?> val : setting.getValues()) {
|
||||
@@ -56,10 +61,9 @@ public class CycleButton<E extends Enum<E>> extends SettingButton {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
if (isHovered((int) mouseX, (int) mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
|
||||
if (button == 0) {
|
||||
setting.cycle(); // clic izquierdo -> ciclar
|
||||
} else if (button == 1) {
|
||||
@@ -67,7 +71,7 @@ public class CycleButton<E extends Enum<E>> extends SettingButton {
|
||||
if (KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT))
|
||||
setting.reset();
|
||||
else
|
||||
setting.cycleBackwards(); // simplemente clic derecho -> ciclar valores pero hacia atrás
|
||||
setting.cycleBackwards(); // solamente clic derecho -> ciclar valores pero hacia atrás
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,5 +81,7 @@ public class CycleButton<E extends Enum<E>> extends SettingButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {}
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||
ClickGUI.INSTANCE.unselect(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.module.settings.ListSetting;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.text.Text;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
public class ListButton<T> extends SettingButton {
|
||||
|
||||
private final ListSetting<T> setting;
|
||||
private final Module dummy;
|
||||
|
||||
private final Map<T, BooleanSetting> optionButtons = new HashMap<>();
|
||||
|
||||
public ListButton(ListSetting<T> setting, SettingsFrame parent, int offset) {
|
||||
super(setting, parent, offset);
|
||||
this.setting = setting;
|
||||
|
||||
// crear un módulo "dummy" (falso), que se le añade cada entrada en la lista como un BooleanSetting
|
||||
dummy = new Module(setting.getName(), setting.getDescription()) {
|
||||
@Override public void onEnable() {}
|
||||
@Override public void onDisable() {}
|
||||
};
|
||||
|
||||
// ocultar cosas innecesarias
|
||||
dummy.getBind().setVisible(false);
|
||||
dummy.getSettings().stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase("modo de tecla"))
|
||||
.findFirst()
|
||||
.ifPresent(s -> s.setVisible(false));
|
||||
dummy.getSettings().stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase("notificar"))
|
||||
.findFirst()
|
||||
.ifPresent(s -> s.setVisible(false));
|
||||
dummy.shouldSaveSettings(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
int bgColor = isHovered(mouseX, mouseY)
|
||||
? Colors.buttonColor.brighter().getRGB()
|
||||
: Colors.buttonColor.getRGB();
|
||||
|
||||
ctx.fill(x, y, x + w, y + h, bgColor);
|
||||
|
||||
String label = setting.getName() + " (" + countEnabled() + "/" + setting.getOptions().size() + ")";
|
||||
ctx.drawText(parent.mc.textRenderer, label, x + 5, y + 3, -1, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTooltip(DrawContext ctx, double mouseX, double mouseY) {
|
||||
if (isHovered(mouseX, mouseY))
|
||||
ctx.drawTooltip(Text.of(setting.getDescription() + "( " + countEnabled() + " de " + setting.getOptions().size() + ")"), (int) mouseX, (int) mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered(mouseX, mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
|
||||
// click izquierdo / derecho: abrir marco
|
||||
if (button <= 1 && !mc.isShiftPressed()) {
|
||||
if (ClickGUI.INSTANCE.isSettingsFrameOpen(dummy)) {
|
||||
ClickGUI.INSTANCE.closeSettingsFrame(dummy);
|
||||
return;
|
||||
}
|
||||
|
||||
rebuildDummy();
|
||||
ClickGUI.INSTANCE.openListSettingsFrame(dummy, parent.x + 40, parent.y + 40);
|
||||
// shift + clic derecho: restablecer valores
|
||||
} else if (button == 1 && mc.isShiftPressed()) {
|
||||
setting.reset();
|
||||
refreshDummy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void rebuildDummy() {
|
||||
dummy.getSettings().clear();
|
||||
optionButtons.clear();
|
||||
|
||||
setting.getOptions().stream()
|
||||
.sorted(Comparator.comparing(setting::getDisplayName, String.CASE_INSENSITIVE_ORDER))
|
||||
.forEach(option -> {
|
||||
String displayName = setting.getDisplayName(option);
|
||||
BooleanSetting b = dummy.addSetting(new BooleanSetting(
|
||||
displayName,
|
||||
"incluir " + displayName,
|
||||
setting.isEnabled(option)
|
||||
));
|
||||
b.onUpdate(value -> setting.setEnabled(option, value));
|
||||
optionButtons.put(option, b);
|
||||
});
|
||||
}
|
||||
|
||||
public void refreshDummy() {
|
||||
optionButtons.forEach((option, boolSetting) ->
|
||||
boolSetting.setEnabled(setting.isEnabled(option)));
|
||||
}
|
||||
|
||||
private int countEnabled() {
|
||||
return (int) setting.getOptions().stream().filter(setting::isEnabled).count();
|
||||
}
|
||||
|
||||
public ListSetting<T> getSetting() {
|
||||
return setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||
ClickGUI.INSTANCE.unselect(this);
|
||||
}
|
||||
}
|
||||
@@ -24,43 +24,51 @@ public class ModuleButton {
|
||||
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
ctx.fill( // dibujar el contorno del botón
|
||||
parent.x + 2, parent.y + offset + 3,
|
||||
parent.x + parent.w - 2 , parent.y + height + offset,
|
||||
parent.x + 2, parent.renderY + offset + 3,
|
||||
parent.x + parent.w - 2 , parent.renderY + height + offset,
|
||||
determineColor(mouseX, mouseY));
|
||||
|
||||
ctx.drawTextWithShadow( // dibujar el nombre del módulo
|
||||
ctx.drawText( // dibujar el nombre del módulo
|
||||
parent.mc.textRenderer, module.getName(),
|
||||
parent.x + 5, parent.y + offset + (height / 2) - (parent.mc.textRenderer.fontHeight / 2) + 2, -1);
|
||||
parent.x + 5, parent.renderY + offset + (height / 2) - (parent.mc.textRenderer.fontHeight / 2) + 2,
|
||||
-1, true);
|
||||
|
||||
// dibujar "tooltips" (cajas de texto) al pasar el puntero encima del botón, para mostrar su descripción
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
Screen currentScreen = parent.mc.currentScreen;
|
||||
if (currentScreen != null)
|
||||
ctx.drawTooltip(Text.of(module.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
if (isHovered((int) mouseX, (int) mouseY))
|
||||
ctx.drawTooltip(Text.of(module.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (button == 0) {// clic izquierdo para activar / desactivar el módulo
|
||||
module.toggle();
|
||||
} else if (button == 1) { // clic derecho para el marco de ajustes (también lo cierra si está abierto)
|
||||
if (ClickGUI.INSTANCE.isSettingsFrameOpen(module))
|
||||
ClickGUI.INSTANCE.closeSettingsFrame(module);
|
||||
else
|
||||
ClickGUI.INSTANCE.openSettingsFrame(module,
|
||||
parent.x + parent.w + 120, parent.y + offset);
|
||||
if (isHovered((int) mouseX, (int) mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
|
||||
if (button == 0) { // clic izquierdo para activar / desactivar el módulo
|
||||
module.toggle();
|
||||
} else if (button == 1) { // clic derecho para el marco de ajustes (también lo cierra si está abierto)
|
||||
if (ClickGUI.INSTANCE.isSettingsFrameOpen(module))
|
||||
ClickGUI.INSTANCE.closeSettingsFrame(module);
|
||||
else
|
||||
ClickGUI.INSTANCE.openSettingsFrame(module,
|
||||
parent.x + parent.w + 120, parent.renderY + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||
ClickGUI.INSTANCE.unselect(this);
|
||||
}
|
||||
|
||||
// verifica si el puntero del ratón se encuentra sobre el botón del módulo
|
||||
public boolean isHovered(int mouseX, int mouseY) {
|
||||
return mouseX > parent.x && mouseX < parent.x + parent.w && mouseY > parent.y + offset && mouseY < parent.y + height + offset;
|
||||
return ClickGUI.INSTANCE.canSelect(this)
|
||||
&& mouseX > parent.x
|
||||
&& mouseX < parent.x + parent.w
|
||||
&& mouseY > parent.renderY + offset
|
||||
&& mouseY < parent.renderY + height + offset;
|
||||
}
|
||||
|
||||
public int determineColor(double mouseX, double mouseY) {
|
||||
// determina el color del botón, dependiendo de si está el puntero encima y si está activado
|
||||
if (module.isEnabled())
|
||||
return isHovered((int) mouseX, (int) mouseY) ? Colors.enabledHoveredModuleButtonColor : Colors.enabledModuleButtonColor;
|
||||
return isHovered((int) mouseX, (int) mouseY) ? Colors.hoveredModuleButtonColor : Colors.moduleButtonColor;
|
||||
return isHovered((int) mouseX, (int) mouseY) ? Colors.mainColor.brighter().getRGB() : Colors.mainColor.getRGB();
|
||||
return isHovered((int) mouseX, (int) mouseY) ? Colors.buttonColor.brighter().getRGB() : Colors.buttonColor.getRGB();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,22 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.settings.Setting;
|
||||
import me.retucio.camtweaks.module.settings.AbstractSetting;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
// clase base para los botones de los ajustes
|
||||
public abstract class SettingButton {
|
||||
|
||||
protected final Setting setting;
|
||||
protected final AbstractSetting setting;
|
||||
protected final SettingsFrame parent;
|
||||
protected int offset;
|
||||
protected final int height = 15;
|
||||
|
||||
protected int x, y, w, h;
|
||||
|
||||
public SettingButton(Setting setting, SettingsFrame parent, int offset) {
|
||||
public SettingButton(AbstractSetting setting, SettingsFrame parent, int offset) {
|
||||
this.setting = setting;
|
||||
this.parent = parent;
|
||||
this.offset = offset;
|
||||
@@ -24,12 +26,23 @@ public abstract class SettingButton {
|
||||
public abstract void mouseClicked(double mouseX, double mouseY, int button);
|
||||
public abstract void mouseReleased(double mouseX, double mouseY, int button);
|
||||
|
||||
// dibujar "tooltips" (cajitas de texto bajo el puntero del ratón) con la descripción para asistir al usuario en el caso de que tenga down
|
||||
public void drawTooltip(DrawContext ctx, double mouseX, double mouseY) {
|
||||
if (isHovered((int) mouseX, (int) mouseY))
|
||||
ctx.drawTooltip(Text.of(setting.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
|
||||
protected boolean isHovered(double mouseX, double mouseY) {
|
||||
return isHovered((int) mouseX, (int) mouseY);
|
||||
}
|
||||
|
||||
protected boolean isHovered(int mouseX, int mouseY) {
|
||||
if (!ClickGUI.INSTANCE.canSelect(this)) return false;
|
||||
return mouseX > x && mouseX < x + w &&
|
||||
mouseY > y && mouseY < y + h;
|
||||
}
|
||||
|
||||
public Setting getSetting() {
|
||||
public AbstractSetting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ package me.retucio.camtweaks.ui.buttons;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.KeyEvent;
|
||||
import me.retucio.camtweaks.module.settings.NumberSetting;
|
||||
import me.retucio.camtweaks.ui.frames.ClickGUISettingsFrame;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
@@ -12,9 +13,11 @@ import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.awt.*;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
// slider (barrita) para los ajustes numéricos
|
||||
public class SliderButton extends SettingButton {
|
||||
@@ -32,15 +35,23 @@ public class SliderButton extends SettingButton {
|
||||
|
||||
@Override
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
ctx.fill(x, y, x + w, y + height, Colors.moduleButtonColor);
|
||||
Color bgColor = Colors.buttonColor;
|
||||
Color fillingColor = Colors.mainColor;
|
||||
|
||||
// calcular cómo de llena tendría que estar el "slider"
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
bgColor = bgColor.brighter();
|
||||
fillingColor = fillingColor.brighter();
|
||||
}
|
||||
|
||||
ctx.fill(x, y, x + w, y + h, bgColor.getRGB());
|
||||
|
||||
// calcular cómo de lleno tendría que estar el "slider"
|
||||
double percent = (setting.getValue() - setting.getMin()) / (setting.getMax() - setting.getMin());
|
||||
int filled = (int) (percent * w);
|
||||
ctx.fill(x, y, x + filled, y + height, Colors.sliderFillingColor);
|
||||
ctx.fill(x, y, x + filled, y + h, fillingColor.getRGB());
|
||||
|
||||
String label = setting.getName() + ": " + df.format(setting.getValue());
|
||||
ctx.drawTextWithShadow(parent.mc.textRenderer, label, x + 5, y + 3, -1);
|
||||
ctx.drawText(parent.mc.textRenderer, label, x + 5, y + 3, -1, true);
|
||||
|
||||
// lógica para el arrastre (arrastramiento?) del valor
|
||||
if (dragging) {
|
||||
@@ -49,33 +60,27 @@ public class SliderButton extends SettingButton {
|
||||
newVal = Math.round(newVal / setting.getIncrement()) * setting.getIncrement();
|
||||
setting.setValue((float) newVal);
|
||||
}
|
||||
|
||||
// dibujar "tooltips" (cajas de texto) al pasar el puntero encima del botón, para mostrar su descripción
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
Screen currentScreen = parent.mc.currentScreen;
|
||||
if (currentScreen != null)
|
||||
ctx.drawTooltip(Text.of(setting.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
if (isHovered((int) mouseX, (int) mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
|
||||
if (button == 0) dragging = true; // arrastrar con el clic izquierdo
|
||||
else if (button == 1 && KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) // restablecer al valor por defecto con shift izquerdo + clic derecho
|
||||
else if (button == 1 && mc.isShiftPressed()) // restablecer al valor por defecto con shift izquerdo + clic derecho
|
||||
setting.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||
ClickGUI.INSTANCE.unselect(this);
|
||||
if (button == 0) dragging = false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKey(KeyEvent event) {
|
||||
// de no ser de esto, si se cierra la interfaz sin haber soltado el ratón mientras se arrastraba el valor, al reabrir la interfaz se seguía arrastrando, aún habiendo soltado ya el clic
|
||||
if (event.getKey() == GLFW.GLFW_KEY_ESCAPE || event.getKey() == ClickGUISettingsFrame.guiSettings.getKey()) dragging = false;
|
||||
// de no ser de esto, si se cierra la interfaz sin haber soltado el ratón mientras se arrastraba el valor, al reabrir la interfaz se seguía arrastrando, aún habiendo soltado ya el clic
|
||||
if (event.getKey() == GLFW.GLFW_KEY_ESCAPE || event.getKey() == ClientSettingsFrame.guiSettings.getKey()) dragging = false;
|
||||
}
|
||||
|
||||
public NumberSetting getSetting() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.settings.StringSetting;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
@@ -8,6 +9,8 @@ import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.text.Text;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
// botón para los ajustes que requieran introducir texto
|
||||
public class TextButton extends SettingButton {
|
||||
|
||||
@@ -23,28 +26,23 @@ public class TextButton extends SettingButton {
|
||||
@Override
|
||||
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
|
||||
int bgColor = isHovered((int) mouseX, (int) mouseY)
|
||||
? Colors.hoveredSettingButtonColor
|
||||
: Colors.settingButtonColor;
|
||||
? Colors.buttonColor.brighter().getRGB()
|
||||
: Colors.buttonColor.getRGB();
|
||||
|
||||
ctx.fill(x, y, x + w, y + height, bgColor);
|
||||
ctx.fill(x, y, x + w, y + h, bgColor);
|
||||
|
||||
String label = setting.getName() + ": " + (typing ? buffer + "_" : setting.getValue());
|
||||
ctx.drawTextWithShadow(parent.mc.textRenderer, label, x + 5, y + 3, -1);
|
||||
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
if (parent.mc.currentScreen != null)
|
||||
ctx.drawTooltip(Text.of(setting.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
ctx.drawText(parent.mc.textRenderer, label, x + 5, y + 3, -1, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
if (isHovered((int) mouseX, (int) mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
|
||||
if (button == 0) {
|
||||
typing = true;
|
||||
buffer.setLength(0);
|
||||
buffer.append(setting.getValue()); // precargar valor anterior
|
||||
} else if (button == 1 && KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) {
|
||||
} else if (button == 1 && mc.isShiftPressed()) {
|
||||
typing = false;
|
||||
setting.reset();
|
||||
}
|
||||
@@ -53,6 +51,11 @@ public class TextButton extends SettingButton {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||
ClickGUI.INSTANCE.unselect(this);
|
||||
}
|
||||
|
||||
public void onKey(int key, int action) {
|
||||
if (!typing || action == GLFW.GLFW_RELEASE) return;
|
||||
|
||||
@@ -79,6 +82,7 @@ public class TextButton extends SettingButton {
|
||||
private void charTyped(char c) {
|
||||
if (!typing) return;
|
||||
buffer.append(c);
|
||||
if (mc.textRenderer.getWidth(setting.getName() + ": " + buffer + "_") > w - 8) onBackspace();
|
||||
}
|
||||
|
||||
public boolean isFocused() {
|
||||
@@ -92,7 +96,4 @@ public class TextButton extends SettingButton {
|
||||
private void onBackspace() {
|
||||
if (!buffer.isEmpty()) buffer.deleteCharAt(buffer.length() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.retucio.camtweaks.ui.buttons;
|
||||
|
||||
import me.retucio.camtweaks.module.settings.BooleanSetting;
|
||||
import me.retucio.camtweaks.ui.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.frames.SettingsFrame;
|
||||
import me.retucio.camtweaks.util.Colors;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
@@ -11,6 +12,8 @@ import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
// botón para los ajustes booleanos (funciona como un interruptor)
|
||||
public class ToggleButton extends SettingButton {
|
||||
|
||||
@@ -28,34 +31,27 @@ public class ToggleButton extends SettingButton {
|
||||
: Colors.disabledToggleButtonColor;
|
||||
|
||||
if (isHovered((int) mouseX, (int) mouseY))
|
||||
color = color.brighter(); // simplemente utilizar el método "built-in" de Java para hacer el botón más claro cuando el puntero se encuentra encima de él
|
||||
// quizás debería de utilizar .brighter() más, en vez de dar valores personalizados
|
||||
color = color.brighter();
|
||||
|
||||
ctx.fill(x, y, x + w, y + height, color.getRGB());
|
||||
ctx.drawTextWithShadow(parent.mc.textRenderer,
|
||||
setting.getName(), x + 5, y + 3, -1);
|
||||
|
||||
// dibujar "tooltips" (cajas de texto) al pasar el puntero encima del botón, para mostrar su descripción
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
Screen currentScreen = parent.mc.currentScreen;
|
||||
if (currentScreen != null)
|
||||
ctx.drawTooltip(Text.of(setting.getDescription()), (int) mouseX, (int) mouseY + 20);
|
||||
}
|
||||
ctx.fill(x, y, x + w, y + h, color.getRGB());
|
||||
ctx.drawText(parent.mc.textRenderer, setting.getName(), x + 5, y + 3, -1, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (isHovered((int) mouseX, (int) mouseY)) {
|
||||
if (isHovered((int) mouseX, (int) mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
|
||||
if (button == 0) setting.toggle(); // clic izquierdo para alternar
|
||||
else if (button == 1 && KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) // shift izquierdo + clic derecho para restablecer al valor por defecto
|
||||
else if (button == 1 && mc.isShiftPressed()) // shift izquierdo + clic derecho para restablecer al valor por defecto
|
||||
setting.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||
ClickGUI.INSTANCE.unselect(this);
|
||||
}
|
||||
|
||||
public BooleanSetting getSetting() {
|
||||
return setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(double mouseX, double mouseY, int button) {}
|
||||
}
|
||||