Compare commits

...
7 Commits
Author SHA1 Message Date
retuci0 9afaa4e0c8 v2.6 2026-01-11 11:12:44 +01:00
retuci0 f794457538 v2.5 2026-01-06 18:09:52 +01:00
retuci0 ec3e633cec v2.4 2026-01-05 22:16:01 +01:00
retuci0 8f17bd8e67 v2.3 - sputnik rename 2026-01-04 17:46:51 +01:00
retuci0 dc2429918e v2.2 2026-01-04 11:40:06 +01:00
retuci0 94a9b1dade v2.1 2026-01-02 13:59:08 +01:00
retuci0 48899f85f9 v2.0.1 2026-01-01 18:29:46 +01:00
425 changed files with 7572 additions and 4262 deletions

No files matched your search

+1 -3
View File
@@ -43,6 +43,4 @@ replay_*.log
todo.txt
cambios.md
remappedSrc/
src/main/java/me/retucio/camtweaks/ui/widgets/Frame.java
src/main/java/me/retucio/camtweaks/ui/widgets/Button.java
remappedSrc/
+6 -5
View File
@@ -5,19 +5,19 @@ mod para Minecraft Fabric 1.21.10 que añade algunas cosas QOL, mayormente relac
## instalación
### para gente normal:
1. ir a [lanzamientos](https://github.com/retuci0/camera-tweaks/releases)
1. ir a [lanzamientos](https://github.com/retuci0/sputnik/releases)
2. selecionar la versión más reciente
3. descargar el .jar
4. moverlo a tu directorio de mods (probablemente `%appdata%/.minecraft/mods`)
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `1.21.10`; Fabric `0.138.3`)
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `1.21.11`; Fabric `0.17.3`)
es posible que haya problemas al usarlo junto a otros mods, especialmente junto a otros clientes, pues pueden conflictar entre ellos.
### para frikis de 200 de iq
1. clona el respositorio (`git clone https://github.com/retuci0/camera-tweaks`)
2. entra al directorio del repositorio (`cd camera-tweaks`)
1. clona el respositorio (`git clone https://github.com/retuci0/sputnik`)
2. entra al directorio del repositorio (`cd sputnik`)
3. `gradlew build` para Windows o `chmod +x gradlew` + `./gradlew build` para Linux (Mac es Linux)
4. el resultado estará en `/build/libs/camtweaks-X.X.jar` (el que no lleva "sources" en el nombre)
4. el resultado estará en `/build/libs/sputnik-X.X.jar` (el que no lleva "sources" en el nombre)
## uso
@@ -54,6 +54,7 @@ algunos módulos tienen teclas asignadas por defecto, asígnales `ESC` para desa
<img src="screenshots/fullbright.png" alt="fullbright en modo gamma cambiando el color de los shaders">
<img src="screenshots/hud.png" alt="HUD">
<img src="screenshots/hudeditor.png" alt="editor de HUD">
<img src="screenshots/colorpicker.png" alt="selector de colores">
## contibuciones
+2 -3
View File
@@ -24,12 +24,11 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
}
loom {
accessWidenerPath = file("src/main/resources/camtweaks.accesswidener")
accessWidenerPath = file("src/main/resources/sputnik.accesswidener")
}
processResources {
+13 -13
View File
@@ -1,27 +1,27 @@
# v2.0
# v2.6
## novedades
### adiciones
- ajuste de opción: similar a enumsetting, pero abre un marco de selección, igual que listsetting.
- layouts de teclado (en_us y es_es) (fuck azerty)
- comando `$config` para abrir el marco de ajustes de un módulo
- elemento del hud que muestra la rotación de la cámara del jugador
#### módulos nuevos:
- resaltado de bloques: resalta bloques de cierto tipo renderizando una caja con su forma, visible a través de paredes
- delay de paquetes: simula un ping alto añadiendo delay a los paquetes
- inventario plus: te permite mover items a cualquier slot del inventario mediante teclas (ej.: d + tecla para slot 4);
- progreso de minado: muestra el progreso de minado de un bloque de una manera más visual, mediante cajas de color
- mano secundaria: equipa de manera automática un ítem en tu mano secundaria
- moverse en interfaz: te permite utilizar las teclas de movimiento con ciertas interfaces abiertas (configurable)
- fuentes: cambia la tipografía que usa todo el juego a una custom
- escalones: actúa con la altura deseada como si se estuviesen subiendo escalones
- escalones inversos: escalones, pabajo
- partículas: genera particulas artificiales
### arreglos / mejoras
- ahora se pueden mostrar también las coordenadas del nether en el elemento del hud para coordenadas
- ahora ChatPlus utilizará los corchetes [] para mostrar la hora (antes era <>), además de también detectar cuando un jugador se une a la hora de dibujar las cabezas
- ahora puedes elegir el sonido en aviso de baja dur., junto a la altura y volumen de este
- ya no se pueden abrir interfaces del mod estando en pantallas donde se suele escribir (chat, carteles, etc.)
- arreglado algunos problemas con las configuraciones
- ahora puedes cambiar el grosor de las líneas del contorno de los bloques
- arreglada la compatibilidad con meteor client
- optimizado y mejorado superposición de luz y resaltado de bloques
- ahora, en los marcos de seleccion única, en el tooltip de cada opción dice "seleccionar" en lugar de "incluir"
- ahora precoz también tiene una opción de reducir el cooldown al minar bloques
## problemas reconocidos
+1
View File
@@ -6,6 +6,7 @@ No Telemetry: https://modrinth.com/mod/no-telemetry
Trouser Streak: https://github.com/etianl/Trouser-Streak
No More Purple: https://github.com/Pepperoni-Jabroni/NoMorePurple/
bypass-resource-pack: https://github.com/emilyy-dev/bypass-resource-pack
elytra-recast: https://github.com/InLieuOfLuna/elytra-recast/
probablemente más pero como tengo demencia se me olvida
si quieres que te acredite o quite tu código de mi mod, mándame un mensaje en discord (username: retucio) y sin problemas :)
+9 -9
View File
@@ -1,13 +1,13 @@
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
minecraft_version=1.21.10
yarn_mappings=1.21.10+build.2
loader_version=0.17.3
loom_version=1.11-SNAPSHOT
minecraft_version=1.21.11
yarn_mappings=1.21.11+build.3
loader_version=0.18.4
loom_version=1.13-SNAPSHOT
mod_version=2.0
fabric_api_version=0.140.2+1.21.11
mod_version=2.6
maven_group=me.retucio
archives_base_name=camtweaks
fabric_version=0.135.0+1.21.10
archives_base_name=sputnik
Binary file not shown.

After

Width:  |  Height:  |  Size: 915 KiB

BIN
View File
Binary file not shown.
@@ -1,9 +0,0 @@
package me.retucio.camtweaks.event.events;
import me.retucio.camtweaks.event.Event;
/**
* @see me.retucio.camtweaks.mixin.ChunkOcclusionDataBuilderMixin#onChunkOcclusion
*/
public class ChunkOcclusionEvent extends Event {}
@@ -1,12 +0,0 @@
package me.retucio.camtweaks.event.events;
import me.retucio.camtweaks.event.Event;
/**
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onStop
*/
public class ShutdownEvent extends Event {
public ShutdownEvent() {}
}
@@ -1,14 +0,0 @@
package me.retucio.camtweaks.event.events;
import me.retucio.camtweaks.event.Event;
/**
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onTickPre
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onTickPost
*/
public class TickEvent {
public static class Pre extends Event {}
public static class Post extends Event {}
}
@@ -1,19 +0,0 @@
package me.retucio.camtweaks.mixin;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import me.retucio.camtweaks.module.ModuleManager;
import me.retucio.camtweaks.module.modules.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;
}
}
@@ -1,30 +0,0 @@
package me.retucio.camtweaks.mixin;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.sugar.Local;
import me.retucio.camtweaks.module.ModuleManager;
import me.retucio.camtweaks.module.modules.TimeChanger;
import me.retucio.camtweaks.util.ChatUtil;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import static me.retucio.camtweaks.CameraTweaks.mc;
@Mixin(DimensionType.class)
public abstract class DimensionTypeMixin {
// no consigo arreglar lo de que la fase lunar por defecto siempre sea luna llena
@ModifyReturnValue(method = "getMoonPhase", at = @At("RETURN"))
private int overrideMoonPhase(int original, @Local(argsOnly = true) long time) {
TimeChanger timeChanger = ModuleManager.INSTANCE.getModuleByClass(TimeChanger.class);
if (timeChanger == null || !timeChanger.isEnabled() || mc.world == null) {
return original;
}
if (timeChanger.moonPhase.is(TimeChanger.MoonPhases.DEFAULT))
return (int) (time / 24000L % 8L + 8L) % 8;
return timeChanger.getMoonPhase();
}
}
@@ -1,14 +0,0 @@
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");
}
}
@@ -1,39 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.AttackEntityEvent;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.BooleanSetting;
import me.retucio.camtweaks.module.settings.NumberSetting;
public class AttributeSwapper extends Module {
public NumberSetting slot = addSetting(new NumberSetting("slot", "slot al que cambiar", 1, 1, 9, 1));
public BooleanSetting swap = addSetting(new BooleanSetting("cambiar de vuelta", "volver al slot inicial tras haber aplicado el swapping", true));
public NumberSetting swapDelay = addSetting(new NumberSetting("delay de cambio de vuelta", "tiempo que se tarda en volver al slot inicial", 1, 1, 20, 1));
private int delay = 0;
private int prevSlot = -1;
public AttributeSwapper() {
super("attribute-swapper", "utiliza el \"attribute swapping\" entre dos herramientas para negar daño de durabilidad o aplicar encantamientos adicionales a estas");
}
@Override
public void onTick() {
if (mc.player == null || !swap.isEnabled()) return;
if (delay < swapDelay.getIntValue()) delay++;
if (delay >= swapDelay.getIntValue() && prevSlot != -1) {
mc.player.getInventory().setSelectedSlot(prevSlot);
prevSlot = -1;
delay = 0;
}
}
@SubscribeEvent
public void onAttack(AttackEntityEvent event) {
prevSlot = mc.player.getInventory().getSelectedSlot();
mc.player.getInventory().setSelectedSlot(slot.getIntValue() - 1);
delay = 0;
}
}
@@ -1,96 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.RenderWorldEvent;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.BooleanSetting;
import me.retucio.camtweaks.module.settings.ColorSetting;
import me.retucio.camtweaks.module.settings.ListSetting;
import me.retucio.camtweaks.module.settings.NumberSetting;
import me.retucio.camtweaks.util.Colors;
import me.retucio.camtweaks.util.Lists;
import me.retucio.camtweaks.util.render.RenderUtil;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.shape.VoxelShape;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class BlockESP extends Module {
public ListSetting<Block> blocks = addSetting(new ListSetting<>("bloques", "bloques a resaltar",
Lists.blockList, Lists.allFalse(Lists.blockList), Lists.blockNames));
public NumberSetting radius = addSetting(new NumberSetting("radio", "radio de búsqueda de bloques", 24, 2, 128, 1));
public BooleanSetting outlines = addSetting(new BooleanSetting("contorno", "renderizar contorno de bloques", true));
public ColorSetting outlineColor = addSetting(new ColorSetting("color del contorno", "color del contorno", Colors.CELESTE, false));
public NumberSetting lineWidth = addSetting(new NumberSetting("grosor del contorno", "grosor de las líneas del contorno", 1, 1, 5, 0.2));
public BooleanSetting fillings = addSetting(new BooleanSetting("relleno", "renderizar relleno de bloques", true));
public ColorSetting fillingColor = addSetting(new ColorSetting("color del relleno", "color del relleno", new Color(57, 177, 215, 67), false));
public BlockESP() {
super("resaltado de bloques", "te muestra la posición de cierto tipo de bloque renderizando una caja con su forma");
outlines.onUpdate(v -> {
outlineColor.setVisible(v);
lineWidth.setVisible(v);
});
fillings.onUpdate(v -> fillingColor.setVisible(v));
}
@SubscribeEvent
public void onRenderWorld(RenderWorldEvent event) {
if (mc.player == null || mc.world == null) return;
for (Block block : blocks.getOptions()) {
if (blocks.isEnabled(block)) {
List<BlockPos> blocksToHighlight = getNearbyBlocks(block);
for (BlockPos pos : blocksToHighlight) {
if (outlines.isEnabled()) {
RenderUtil.drawVoxelShapeOutline(
event.getMatrices(),
getVoxelShape(pos),
pos,
outlineColor.getColor(),
lineWidth.getFloatValue());
}
if (fillings.isEnabled()) {
RenderUtil.drawVoxelShapeFilled(
event.getMatrices(),
getVoxelShape(pos),
pos,
fillingColor.getColor());
}
}
}
}
}
private List<BlockPos> getNearbyBlocks(Block block) {
List<BlockPos> blockPosList = new ArrayList<>();
for (int i = -radius.getIntValue(); i < radius.getIntValue(); i++) {
for (int j = -radius.getIntValue(); j < radius.getIntValue(); j++) {
for (int k = -radius.getIntValue(); k < radius.getIntValue(); k++) {
BlockPos pos = mc.player.getBlockPos().add(new Vec3i(i, j, k));
if (mc.world.getBlockState(pos).getBlock() == block) {
blockPosList.add(pos);
}
}
}
}
return blockPosList;
}
private VoxelShape getVoxelShape(BlockPos pos) {
return mc.world.getBlockState(pos).getOutlineShape(mc.world, pos);
}
}
@@ -1,22 +0,0 @@
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.ColorSetting;
import me.retucio.camtweaks.module.settings.NumberSetting;
import java.awt.*;
/** continúa en:
* @see me.retucio.camtweaks.mixin.WorldRendererMixin
*/
public class BlockOutline extends Module {
public ColorSetting color = addSetting(new ColorSetting("color", "color del contorno de los bloques",
new Color(0, 0, 0, 102), true));
public BlockOutline() {
super("contorno", "customiza el contorno de los bloques");
}
}
@@ -1,21 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.StringSetting;
import me.retucio.camtweaks.util.ChatUtil;
public class BungeecordSpoofer extends Module {
public StringSetting address = addSetting(new StringSetting("dirección", "la dirección IP que será enviada al server", "127.0.0.1", 15));
public BungeecordSpoofer() {
super("spoofer de bungeecord", "te permite conectarte a los servidores backend de un server bungeecord mal configurado");
address.onUpdate(text -> {
if (!text.matches("^[0-9a-f\\\\.:]{0,45}$")) {
address.setValue(address.getDefaultValue());
ChatUtil.error("dirección IP inválida");
}
});
}
}
@@ -1,25 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.PacketEvent;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.StringSetting;
import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket;
public class ColoredSigns extends Module {
public StringSetting symbol = addSetting(new StringSetting("símbolo", "símbolo a reemplazar por \"§\"", "&", 5));
public ColoredSigns() {
super("carteles gays", "te permite usar un símbolo a elegir como § para añadir formato a estos.");
}
@SubscribeEvent
public void onSendPacket(PacketEvent.Send event) {
if (event.getPacket() instanceof UpdateSignC2SPacket packet) {
for (int i = 0; i < 4; i++) {
packet.getText()[i] = packet.getText()[i].replace(symbol.getValue(), "\247" + "\247a");
}
}
}
}
@@ -1,29 +0,0 @@
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.ColorSetting;
import me.retucio.camtweaks.module.settings.NumberSetting;
import java.awt.*;
/** continúa en:
* @see me.retucio.camtweaks.mixin.DamageParticleMixin
* @see me.retucio.camtweaks.mixin.DamageParticleFactoryMixin
*/
public class CritsPlus extends Module {
public ColorSetting color = addSetting(new ColorSetting("color", "color de las partículas", new Color(0, 0, 255, 255), false));
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", 10, 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");
}
}
@@ -1,29 +0,0 @@
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;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
public class FastUse extends Module {
public BooleanSetting items = addSetting(new BooleanSetting("items", "usar items precozmente", true));
public NumberSetting itemCooldown = addSetting(new NumberSetting("cooldown de items", "cooldown para usar items en ticks", 0, 0, 4, 1));
public BooleanSetting blocks = addSetting(new BooleanSetting("bloques", "colocar bloques precozmente", true));
public NumberSetting blockCooldown = addSetting(new NumberSetting("cooldown de bloques", "cooldown para colocar bloques en ticks", 0, 0, 4, 1));
public FastUse() {
super("precoz", "hace cosas como usar items o colocar bloques más rápido");
items.onUpdate(v -> itemCooldown.setVisible(v));
blocks.onUpdate(v -> blockCooldown.setVisible(v));
}
public int getCooldown(ItemStack stack) {
if (stack.getItem() instanceof BlockItem && blocks.isEnabled()) return blockCooldown.getIntValue();
if (items.isEnabled() && !(stack.getItem() instanceof BlockItem)) return itemCooldown.getIntValue();
else return 4; // cooldown por defecto, 4 ticks
}
}
@@ -1,84 +0,0 @@
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;
import me.retucio.camtweaks.module.settings.ColorSetting;
import me.retucio.camtweaks.module.settings.NumberSetting;
import me.retucio.camtweaks.module.settings.StringSetting;
import me.retucio.camtweaks.util.ChatUtil;
import me.retucio.camtweaks.util.Colors;
import org.lwjgl.glfw.GLFW;
import java.awt.*;
// módulo no visible solo para los ajustes de la interfaz (y del cliente en general)
public class GUI extends Module {
public ColorSetting color = addSetting(new ColorSetting("color", "color principal de la interfaz y el mod",
new Color(70, 20, 210, 230), false));
// 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, -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 watermark = addSetting(new StringSetting("marca de agua", "marca de agua para interfaces (dejar vacío para desactivar)", CameraTweaks.getVersionName(), 40));
public StringSetting commandPrefix = addSetting(new StringSetting("prefijo", "prefijo de los comandos", "$", 10));
public StringSetting chatName = addSetting(new StringSetting("nombre", "qué nombre usar en notificaciones por el chat", "smegma", 20));
public BooleanSetting multipleKeybinds = addSetting(new BooleanSetting("teclas multimódulo", "permitir asignar la misma tecla a más de un módulo", false));
public GUI() {
super("interfaz", "ajustes de la interfaz, y otros misceláneos", GLFW.GLFW_KEY_RIGHT_SHIFT);
CameraTweaks.EVENT_BUS.register(this);
keyMode.setVisible(false);
notify.setVisible(false);
searchBar.onUpdate(v -> matchCase.setVisible(v));
}
@SubscribeEvent
public void onLoadCommandManager(LoadCommandManagerEvent event) {
commandPrefix.onUpdate(CommandManager.INSTANCE::setPrefix);
commandPrefix.setDefaultValue(CommandManager.INSTANCE.getPrefix());
chatName.onUpdate(name -> {
ChatUtil.updatePrefix(name);
ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class).updateClientName();
});
}
@SubscribeEvent
public void onLoadClickGUI(LoadClickGUIEvent event) {
color.onUpdate(v -> {
Colors.red = color.getR();
Colors.green = color.getG();
Colors.blue = color.getB();
Colors.alpha = color.getA();
Colors.updateAllColors(new Color(Colors.red, Colors.green, Colors.blue, Colors.alpha));
});
}
@SubscribeEvent
public void onTick(TickEvent.Post event) {
if (color.isRainbow()) {
Colors.red = color.getR();
Colors.green = color.getG();
Colors.blue = color.getB();
Colors.updateAllColors(new Color(Colors.red, Colors.green, Colors.blue, Colors.alpha));
}
}
}
@@ -1,58 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.*;
import me.retucio.camtweaks.ui.hud.CoordsElement;
import me.retucio.camtweaks.ui.hud.HudElement;
import me.retucio.camtweaks.ui.hud.HudRenderer;
import me.retucio.camtweaks.ui.hud.HudEditorScreen;
import org.lwjgl.glfw.GLFW;
import java.awt.*;
/** lógica del HUD manejada en:
* @see HudRenderer
* @see HudElement
* @see 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));
// ajustes
public ColorSetting color = addSetting(new ColorSetting("color", "color del texto de los elementos del HUD",
new Color(255, 255, 255, 255), false));
public BooleanSetting showOnF3 = addSetting(new BooleanSetting("mostrar en F3", "renderizar HUD en el menú de debug", false));
public BooleanSetting showOnChat = addSetting(new BooleanSetting("mostrar en chat", "renderizar HUD en la pantalla del chat", 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 EnumSetting<CoordsMode> coordsMode = addSetting(new EnumSetting<>("modo de coordenadas", "qué coordenadas mostrar", CoordsMode.class, CoordsMode.OVERWORLD));
public HUD() {
super("HUD", "superposición de la pantalla con info. adicional");
}
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; }
}
public enum CoordsMode {
OVERWORLD("superficie"),
NETHER("nether"),
BOTH("ambas");
private final String name;
CoordsMode(String name) { this.name = name; }
@Override public String toString() { return name; }
}
}
@@ -1,131 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.RenderHeldItemEvent;
import me.retucio.camtweaks.event.events.RenderArmEvent;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.BooleanSetting;
import me.retucio.camtweaks.module.settings.NumberSetting;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Hand;
import net.minecraft.util.math.RotationAxis;
import org.joml.Vector3d;
/** continúa en:
* @see me.retucio.camtweaks.mixin.HeldItemRendererMixin
*/
public class HandView extends Module {
// ajustes de animaciones
public BooleanSetting oldAnimations = addSetting(new BooleanSetting("animaciones viejas", "como las de la 1.8, al pegar", false));
public BooleanSetting skipSwapping = addSetting(new BooleanSetting("no swap", "se salta la animación de cambiar items de mano", false));
public BooleanSetting noFood = addSetting(new BooleanSetting("no comer", "no renderiza la animación de comer", false));
// ajustes de mano principal
public NumberSetting scaleMainX = addSetting(new NumberSetting("escala de la mano principal (X)", ".",
1, 0.01, 5, 0.1));
public NumberSetting scaleMainY = addSetting(new NumberSetting("escala de la mano principal (Y)", ".",
1, 0.01, 5, 0.1));
public NumberSetting scaleMainZ = addSetting(new NumberSetting("escala de la mano principal (Z)", ".",
1, 0.01, 5, 0.1));
public NumberSetting posMainX = addSetting(new NumberSetting("posición de la mano principal (X)", ".",
0, -3, 3, 0.1));
public NumberSetting posMainY = addSetting(new NumberSetting("posición de la mano principal (Y)", ".",
0, -3, 3, 0.1));
public NumberSetting posMainZ = addSetting(new NumberSetting("posición de la mano principal (Z)", ".",
0, -3, 3, 0.1));
public NumberSetting rotMainX = addSetting(new NumberSetting("rotación de la mano principal (X)", ".",
0, -180, 180, 1));
public NumberSetting rotMainY = addSetting(new NumberSetting("rotación de la mano principal (Y)", ".",
0, -180, 180, 1));
public NumberSetting rotMainZ = addSetting(new NumberSetting("rotación de la mano principal (Z)", ".",
0, -180, 180, 1));
// ajustes de mano secundaria
public NumberSetting scaleOffX = addSetting(new NumberSetting("escala de la mano secundaria (X)", ".",
1, 0.01, 5, 0.1));
public NumberSetting scaleOffY = addSetting(new NumberSetting("escala de la mano secundaria (Y)", ".",
1, 0.01, 5, 0.1));
public NumberSetting scaleOffZ = addSetting(new NumberSetting("escala de la mano secundaria (Z)", ".",
1, 0.01, 5, 0.1));
public NumberSetting posOffX = addSetting(new NumberSetting("posición de la mano secundaria (X)", ".",
0, -3, 3, 0.1));
public NumberSetting posOffY = addSetting(new NumberSetting("posición de la mano secundaria (Y)", ".",
0, -3, 3, 0.1));
public NumberSetting posOffZ = addSetting(new NumberSetting("posición de la mano secundaria (Z)", ".",
0, -3, 3, 0.1));
public NumberSetting rotOffX = addSetting(new NumberSetting("rotación de la mano secundaria (X)", ".",
0, -180, 180, 1));
public NumberSetting rotOffY = addSetting(new NumberSetting("rotación de la mano secundaria (Y)", ".",
0, -180, 180, 1));
public NumberSetting rotOffZ = addSetting(new NumberSetting("rotación de la mano secundaria (Z)", ".",
0, -180, 180, 1));
// brazo
public NumberSetting scaleArmX = addSetting(new NumberSetting("escala del brazo (X)", ".",
1, 0.01, 5, 0.1));
public NumberSetting scaleArmY = addSetting(new NumberSetting("escala del brazo (Y)", ".",
1, 0.01, 5, 0.1));
public NumberSetting scaleArmZ = addSetting(new NumberSetting("escala del brazo (Z)", ".",
1, 0.01, 5, 0.1));
public NumberSetting posArmX = addSetting(new NumberSetting("posición del brazo (X)", ".",
0, -3, 3, 0.1));
public NumberSetting posArmY = addSetting(new NumberSetting("posición del brazo (Y)", ".",
0, -3, 3, 0.1));
public NumberSetting posArmZ = addSetting(new NumberSetting("posición del brazo (Z)", ".",
0, -3, 3, 0.1));
public NumberSetting rotArmX = addSetting(new NumberSetting("rotación del brazo (X)", ".",
0, -180, 180, 1));
public NumberSetting rotArmY = addSetting(new NumberSetting("rotación del brazo (Y)", ".",
0, -180, 180, 1));
public NumberSetting rotArmZ = addSetting(new NumberSetting("rotación del brazo (Z)", ".",
0, -180, 180, 1));
public HandView() {
super("manos", "modifica la manera en la que se renderizan las manos");
}
@SubscribeEvent
public void onHeldItemRender(RenderHeldItemEvent event) {
if (event.getHand() == Hand.MAIN_HAND) {
scale(event.getMatrices(), new Vector3d(scaleMainX.getValue(), scaleMainY.getValue(), scaleMainZ.getValue()));
translate(event.getMatrices(), new Vector3d(posMainX.getValue(), posMainY.getValue(), posMainZ.getValue()));
rotate(event.getMatrices(), new Vector3d(rotMainX.getValue(), rotMainY.getValue(), rotMainZ.getValue()));
}
else {
scale(event.getMatrices(), new Vector3d(scaleOffX.getValue(), scaleOffY.getValue(), scaleOffZ.getValue()));
translate(event.getMatrices(), new Vector3d(posOffX.getValue(), posOffY.getValue(), posOffZ.getValue()));
rotate(event.getMatrices(), new Vector3d(rotOffX.getValue(), rotOffY.getValue(), rotOffZ.getValue()));
}
}
@SubscribeEvent
public void onRenderArm(RenderArmEvent event) {
scale(event.getMatrices(), new Vector3d(scaleArmX.getValue(), scaleArmY.getValue(), scaleArmZ.getValue()));
translate(event.getMatrices(), new Vector3d(posArmX.getValue(), posArmY.getValue(), posArmZ.getValue()));
rotate(event.getMatrices(), new Vector3d(rotArmX.getValue(), rotArmY.getValue(), rotArmZ.getValue()));
}
private void rotate(MatrixStack matrix, Vector3d rotation) {
matrix.multiply(RotationAxis.POSITIVE_X.rotationDegrees((float) rotation.x));
matrix.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) rotation.y));
matrix.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) rotation.z));
}
private void scale(MatrixStack matrix, Vector3d scale) {
matrix.scale((float) scale.x, (float) scale.y, (float) scale.z);
}
private void translate(MatrixStack matrix, Vector3d translation) {
matrix.translate((float) translation.x, (float) translation.y, (float) translation.z);
}
}
@@ -1,16 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.module.Module;
public class Headhitters extends Module {
public Headhitters() {
super("headhitters", "mantén pulsado el espacio para hacer headhitting sin tener que espamearlo");
}
@Override
public void onTick() {
if (mc.player == null) return;
mc.player.jumpingCooldown = 0;
}
}
@@ -1,96 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.RenderWorldEvent;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.BooleanSetting;
import me.retucio.camtweaks.module.settings.ColorSetting;
import me.retucio.camtweaks.module.settings.NumberSetting;
import me.retucio.camtweaks.util.render.RenderUtil;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.LightType;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class LightOverlay extends Module {
public NumberSetting radius = addSetting(new NumberSetting("radio", "radio a tener en cuenta al renderizar superposición",
16, 5, 128, 1));
public NumberSetting yRadius = addSetting(new NumberSetting("rango vertical", "distancia vertical a tener en cuenta",
4, 1, 16, 1));
public NumberSetting interval = addSetting(new NumberSetting("intervalo", "cada cuántos ticks comprobar el nivel de luz",
10, 1, 80, 1));
public ColorSetting lightColor = addSetting(new ColorSetting("color de la luz", "color de los bloques con luz",
new Color(0, 255, 0, 67), false));
public ColorSetting darknessColor = addSetting(new ColorSetting("color de oscuridad", "color de bloques con 0 luz",
new Color(255, 0, 0, 67), false));
public BooleanSetting onWater = addSetting(new BooleanSetting("en agua", "mostrar también bloques cubiertos en agua", true));
List<BlockPos> blocks = new ArrayList<>();
public LightOverlay() {
super("superposición de luz", "te muestra el nivel de luz en bloques, para prevenir mob spawns");
}
@SubscribeEvent
public void onRenderWorld(RenderWorldEvent event) {
if (mc.player == null || mc.world == null) return;
if (mc.player.age % interval.getIntValue() == 0) {
blocks = findExposedBlocks(
radius.getIntValue(),
yRadius.getIntValue()
);
}
for (BlockPos block : blocks) {
if (mc.world.getBlockState(block).isAir() || !mc.world.getBlockState(block.up()).isAir()) continue;
if (!mc.world.isTopSolid(block, mc.player) || !mc.world.getBlockState(block).isOpaque()) continue;
int light = mc.world.getLightLevel(LightType.BLOCK, block.up());
Color color = light == 0 ? darknessColor.getColor()
: new Color(
(lightColor.getR() / 15) * light,
(lightColor.getG() / 15) * light,
(lightColor.getB() / 15) * light,
lightColor.getA());
RenderUtil.drawBlockFaceFilled(event.getMatrices(), block, Direction.UP, color, 0.001f);
}
}
private List<BlockPos> findExposedBlocks(int radius, int yRadius) {
List<BlockPos> results = new ArrayList<>();
BlockPos pos = mc.player.getBlockPos();
int minX = pos.getX() - radius;
int maxX = pos.getX() + radius;
int minY = Math.max(mc.world.getDimension().minY(), pos.getY() - yRadius);
int maxY = Math.min(mc.world.getDimension().height() - 1, pos.getY() + yRadius);
int minZ = pos.getZ() - radius;
int maxZ = pos.getZ() + radius;
maxY = Math.min(maxY, mc.world.getDimension().height() - 2);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = minY; y <= maxY; y++) {
BlockPos current = new BlockPos(x, y, z);
BlockPos above = current.up();
if (!mc.world.isAir(current) && (mc.world.isAir(above) || (mc.world.isWater(above) && onWater.isEnabled())))
results.add(current);
}
}
}
return results;
}
}
@@ -1,24 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.BooleanSetting;
import net.minecraft.entity.Entity;
import net.minecraft.registry.tag.ItemTags;
public class NoMiningInterruptions extends Module {
public BooleanSetting withPickaxeOnly = addSetting(new BooleanSetting("solo con pico", "ignorar entidades solamente cuando se sujeta un pico", false));
public NoMiningInterruptions() {
super("minar sin interrupción", "te permite minar bloques a través de entidades");
}
public boolean shouldIgnoreEntity(Entity entity) {
if (entity == null || !this.isEnabled()) return false;
if (withPickaxeOnly.isEnabled())
return (mc.player.getMainHandStack().isIn(ItemTags.PICKAXES) || mc.player.getOffHandStack().isIn(ItemTags.PICKAXES));
return true;
}
}
@@ -1,85 +0,0 @@
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.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.StatusEffectFogModifierMixin
* @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 endFlashes = addSetting(new BooleanSetting("flashes del end", "renderizar los recientemente añadidos flashes en el end", true));
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 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())); }
}
}
@@ -1,14 +0,0 @@
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");
}
}
@@ -1,29 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.module.Module;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.text.Text;
/** continúa en:
* @see me.retucio.camtweaks.mixin.ClientCommonNetworkHandlerMixin
* @see me.retucio.camtweaks.mixin.ConfirmScreenMixin
* @see me.retucio.camtweaks.mixin.ResourcePackPolicyMixin
* @see me.retucio.camtweaks.mixin.ServerConnectorMixin
* @see me.retucio.camtweaks.mixin.ServerInfoMixin
*/
public class RPackBypass extends Module {
public String TAG_NAME = "bypassTextures";
public String ENUM_NAME = "BYPASS";
public Text BYPASS_TEXT = Text.literal("nuh uh");
public RPackBypass() {
super("bypassear packs", "te permite omitir packs de recursos forzados por servers");
}
public ServerInfo.ResourcePackPolicy getPolicy() {
return ServerInfo.ResourcePackPolicy.valueOf(ENUM_NAME);
}
}
@@ -1,41 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.ChangeRotationEvent;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.BooleanSetting;
import me.retucio.camtweaks.module.settings.NumberSetting;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
public class Rotations extends Module {
public NumberSetting yaw = addSetting(new NumberSetting("guiñada", "eje vertical - giro horizontal (yaw)", 0, -180, 180, 1));
public NumberSetting pitch = addSetting(new NumberSetting("cabeceo", "eje horizontal - giro vertical (pitch)", 0, -90, 90, 1));
public BooleanSetting smooth = addSetting(new BooleanSetting("evitar movimiento", "cancela todo movimiento de la cámara", false));
public BooleanSetting serverSide = addSetting(new BooleanSetting("serverside", "espamea paquetes de rotación al servidor", false));
public Rotations() {
super("rotaciones", "te permite forzar una rotación específica");
}
@Override
public void onTick() {
if (mc.player == null) return;
mc.player.setYaw(yaw.getFloatValue());
mc.player.setPitch(pitch.getFloatValue());
if (serverSide.isEnabled())
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(
yaw.getFloatValue(), pitch.getFloatValue(), mc.player.isOnGround(), mc.player.horizontalCollision));
}
@SubscribeEvent
public void onChangeRotation(ChangeRotationEvent event) {
if (smooth.isEnabled()
&& (event.getYaw() != yaw.getFloatValue() || event.getPitch() != pitch.getFloatValue())){
event.cancel();
}}
}
@@ -1,88 +0,0 @@
package me.retucio.camtweaks.module.modules;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.PacketEvent;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.BooleanSetting;
import me.retucio.camtweaks.module.settings.EnumSetting;
import me.retucio.camtweaks.module.settings.NumberSetting;
import me.retucio.camtweaks.util.ChatUtil;
import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket;
// continúa en ClientWorldPropertiesMixin, DimensionTypeMixin,
public class TimeChanger extends Module {
public BooleanSetting renderSun = addSetting(new BooleanSetting("sol", "que haya sol o no", true));
public BooleanSetting renderMoon = addSetting(new BooleanSetting("luna", "que haya luna o no", true));
public BooleanSetting renderStars = addSetting(new BooleanSetting("estrellas", "que hayan estrellas o no", true));
public EnumSetting<MoonPhases> moonPhase = addSetting(new EnumSetting<>("fase lunar", "fase lunar actual", MoonPhases.class, MoonPhases.DEFAULT));
public NumberSetting time = addSetting(new NumberSetting("hora", "hora del juego", 0, -20000, 20000, 1));
public TimeChanger() {
super("cielo custom", "te deja cambiar visualmente el progreso del día");
renderMoon.onUpdate(v -> moonPhase.setVisible(v));
}
private long realTime;
@Override
public void onEnable() {
if (mc.world == null) return;
realTime = mc.world.getTime();
super.onEnable();
}
@Override
public void onDisable() {
if (mc.world == null) return;
mc.world.getLevelProperties().setTimeOfDay(realTime);
super.onDisable();
}
@SubscribeEvent
public void onPacketReceive(PacketEvent.Receive event) {
if (event.getPacket() instanceof WorldTimeUpdateS2CPacket packet) {
realTime = packet.timeOfDay();
event.cancel();
}
}
@Override
public void onTick() {
if (mc.world == null) return;
mc.world.getLevelProperties().setTimeOfDay(time.getLongValue());
}
public int getMoonPhase() {
if (mc.world == null) return -1;
return switch (moonPhase.getValue()) {
case DEFAULT -> -1;
case FULL_MOON -> 0;
case WANING_GIBBOUS -> 1;
case LAST_QUARTER -> 2;
case WANING_CRESCENT -> 3;
case NEW_MOON -> 4;
case WAXING_CRESCENT -> 5;
case FIRST_QUARTER -> 6;
case WAXING_GIBBOUS -> 7;
};
}
public enum MoonPhases {
DEFAULT("por defecto"),
FULL_MOON("luna llena"),
WANING_GIBBOUS("menguante gibosa"),
LAST_QUARTER("cuarto menguante"),
WANING_CRESCENT("luna vieja"),
NEW_MOON("luna nueva"),
WAXING_CRESCENT("creciente"),
FIRST_QUARTER("cuarto creciente"),
WAXING_GIBBOUS("creciente gibosa");
private final String name;
MoonPhases(String name) { this.name = name; }
@Override public String toString() { return name; }
}
}
@@ -1,96 +0,0 @@
package me.retucio.camtweaks.ui.buttons;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.ColorSetting;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import me.retucio.camtweaks.ui.frames.SettingsFrame;
import me.retucio.camtweaks.util.ChatUtil;
import me.retucio.camtweaks.util.Colors;
import me.retucio.camtweaks.util.render.DrawUtil;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import static me.retucio.camtweaks.CameraTweaks.mc;
public class ColorButton extends SettingButton {
private final ColorSetting setting;
public ColorButton(ColorSetting setting, SettingsFrame parent, int offset) {
super(setting, parent, offset);
this.setting = setting;
}
@Override
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
// fondo
Color bgColor = isHovered((int) mouseX, (int) mouseY)
? Colors.buttonColor.brighter()
: Colors.buttonColor;
ctx.fill(x, y, x + w, y + h, bgColor.getRGB());
// prev. del color
int previewSize = h - 6;
int previewX = x + 5;
int previewY = y + 3;
DrawUtil.drawBorder(ctx, previewX - 1, previewY - 1, previewSize + 2, previewSize + 2, setting.isRainbow() ? Colors.mainColor.getRGB() : -1);
ctx.fill(previewX, previewY, previewX + previewSize, previewY + previewSize, setting.getColor().getRGB());
// texto
String label = setting.getName();
int textX = previewX + previewSize + 5;
ctx.drawText(parent.mc.textRenderer, label, textX, y + 3, -1, true);
// valor actual
String valueText = setting.isRainbow() ? "gay." : Colors.ARGBtoHex(setting.getA(), setting.getR(), setting.getG(), setting.getB());
int valueWidth = parent.mc.textRenderer.getWidth(valueText);
ctx.drawText(parent.mc.textRenderer, valueText, x + w - valueWidth - 5, y + 3, -1, true);
}
@Override
public void drawTooltip(DrawContext ctx, double mouseX, double mouseY) {
if (isHovered((int) mouseX, (int) mouseY)) {
List<Text> tooltip = new ArrayList<>();
tooltip.add(Text.of(setting.getDescription()));
tooltip.add(setting.getTooltipText());
ctx.drawTooltip(mc.textRenderer, tooltip, (int) mouseX, (int) mouseY + 20);
}
}
@Override
public void mouseClicked(double mouseX, double mouseY, int button) {
if (isHovered((int) mouseX, (int) mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
if (button == 0) {
// click izq.: abrir selector de colores
ClickGUI.INSTANCE.openColorPickerFrame(setting.getModule(), setting, parent.x + parent.w + 120, parent.renderY + offset);
} else if (button == 1 && mc.isShiftPressed()) {
// shift + clic dcho.: restablecer color
setting.reset();
}
}
}
@Override
public void mouseReleased(double mouseX, double mouseY, int button) {
ClickGUI.INSTANCE.unselect(this);
}
@Override
public void mouseDragged(double mouseX, double mouseY) {}
public ColorSetting getSetting() {
return setting;
}
public void refreshDummy() {
// This is called when the color picker frame needs to be refreshed
// We'll update any linked dummy module in the color picker frame
}
}
@@ -1,77 +0,0 @@
package me.retucio.camtweaks.ui.buttons;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import me.retucio.camtweaks.ui.frames.ModuleFrame;
import me.retucio.camtweaks.util.Colors;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
// clase para el botón para cada módulo
public class ModuleButton {
private final Module module;
public ModuleFrame parent;
public int offset;
public final int height = 18;
public ModuleButton(Module module, ModuleFrame parent, int offset) {
this.module = module;
this.parent = parent;
this.offset = offset;
}
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
ctx.fill( // dibujar el contorno del botón
parent.x + 2, parent.renderY + offset + 3,
parent.x + parent.w - 2 , parent.renderY + height + offset,
determineColor(mouseX, mouseY));
ctx.drawText( // dibujar el nombre del módulo
parent.mc.textRenderer, module.getName(),
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))
ctx.drawTooltip(Text.of(module.getDescription()), (int) mouseX, (int) mouseY + 20);
}
public void mouseClicked(double mouseX, double mouseY, int button) {
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 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.mainColor.brighter().getRGB() : Colors.mainColor.getRGB();
return isHovered((int) mouseX, (int) mouseY) ? Colors.buttonColor.brighter().getRGB() : Colors.buttonColor.getRGB();
}
public Module getModule() {
return module;
}
}
@@ -1,80 +0,0 @@
package me.retucio.camtweaks.ui.buttons;
import me.retucio.camtweaks.module.settings.Setting;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import me.retucio.camtweaks.ui.frames.SettingsFrame;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
// clase base para los botones de los ajustes
public abstract class SettingButton {
protected final Setting setting;
protected final SettingsFrame parent;
protected int offset;
protected int x, y, w, h;
public SettingButton(Setting setting, SettingsFrame parent, int offset) {
this.setting = setting;
this.parent = parent;
this.offset = offset;
}
public abstract void render(DrawContext ctx, double mouseX, double mouseY, float delta);
public abstract void mouseClicked(double mouseX, double mouseY, int button);
public abstract void mouseReleased(double mouseX, double mouseY, int button);
public abstract void mouseDragged(double mouseX, double mouseY);
// 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() {
return setting;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getW() {
return w;
}
public void setW(int w) {
this.w = w;
}
public int getH() {
return h;
}
public void setH(int h) {
this.h = h;
}
}
@@ -1,56 +0,0 @@
package me.retucio.camtweaks.ui.buttons;
import me.retucio.camtweaks.module.settings.BooleanSetting;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import me.retucio.camtweaks.ui.frames.SettingsFrame;
import me.retucio.camtweaks.util.Colors;
import net.minecraft.client.gui.DrawContext;
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 {
private final BooleanSetting setting;
public ToggleButton(BooleanSetting setting, SettingsFrame parent, int offset) {
super(setting, parent, offset);
this.setting = setting;
}
@Override
public void render(DrawContext ctx, double mouseX, double mouseY, float delta) {
Color color = setting.isEnabled()
? Colors.enabledToggleButtonColor
: Colors.disabledToggleButtonColor;
if (isHovered((int) mouseX, (int) mouseY))
color = color.brighter();
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) && ClickGUI.INSTANCE.trySelect(this)) {
if (button == 0) setting.toggle(); // clic izquierdo para alternar
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);
}
@Override
public void mouseDragged(double mouseX, double mouseY) {}
public BooleanSetting getSetting() {
return setting;
}
}
@@ -1,91 +0,0 @@
package me.retucio.camtweaks.ui.frames;
import me.retucio.camtweaks.CameraTweaks;
import me.retucio.camtweaks.event.events.camtweaks.GUISettingsFrameEvent;
import me.retucio.camtweaks.module.modules.GUI;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import me.retucio.camtweaks.ui.buttons.SettingButton;
import me.retucio.camtweaks.util.Colors;
import net.minecraft.client.gui.DrawContext;
import java.util.List;
public class ClientSettingsFrame extends SettingsFrame {
public static final GUI guiSettings = new GUI();
public boolean extended = false;
private final String title = "ajustes del mod";
public ClientSettingsFrame(int x, int y, int w, int h) {
super(guiSettings, x, y, w, h);
}
@Override
public void render(DrawContext ctx, int mouseX, int mouseY, float delta) {
updateWidth();
ctx.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB());
ctx.drawText(mc.textRenderer, title,
x + 8,
renderY + (h / 2) - (mc.textRenderer.fontHeight / 2),
-1, true);
ctx.drawText(mc.textRenderer, extended ? "-" : "+",
x + w - mc.textRenderer.getWidth("+") - 8,
renderY + (h / 2) - (mc.textRenderer.fontHeight / 2),
-1, true);
List<SettingButton> visibleButtons = settingButtons.stream()
.filter(sb -> sb.getSetting().isVisible() && sb.getSetting().isSearchMatch())
.toList();
if (extended) {
int currentY = renderY + h + 3;
totalHeight = visibleButtons.size() * h;
ctx.fill(x, currentY - 2, x + w, currentY + totalHeight, Colors.frameBGColor.getRGB());
for (SettingButton sb : visibleButtons) {
sb.setX(x + 4);
sb.setY(currentY);
sb.setW(w - 8);
sb.setH(h - h / 4);
sb.render(ctx, mouseX, mouseY, delta);
sb.drawTooltip(ctx, mouseX, mouseY);
currentY += h;
}
} else totalHeight = 0;
}
@Override
public void mouseClicked(double mouseX, double mouseY, int button) {
if (isHovered(mouseX, mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
if (button == 0) {
dragging = true;
dragX = (int) (mouseX - x);
dragY = (int) (mouseY - y);
} else if (button == 1) {
extended = !extended;
CameraTweaks.EVENT_BUS.post(new GUISettingsFrameEvent.Extend());
}
}
if (!extended) return; // solo dejar clicar en los módulos si el marco está extendido
for (SettingButton settingButton : settingButtons)
settingButton.mouseClicked(mouseX, mouseY, button);
}
@Override
public void mouseReleased(double mouseX, double mouseY, int button) {
ClickGUI.INSTANCE.unselect(this);
if (button == 0 && dragging)
CameraTweaks.EVENT_BUS.post(new GUISettingsFrameEvent.Move());
super.mouseReleased(mouseX, mouseY, button);
}
@Override
public void drawTooltips(DrawContext ctx, double mouseX, double mouseY) {
if (!extended) return;
super.drawTooltips(ctx, mouseX, mouseY);
}
}
@@ -1,263 +0,0 @@
package me.retucio.camtweaks.ui.frames;
import me.retucio.camtweaks.CameraTweaks;
import me.retucio.camtweaks.event.events.camtweaks.SettingsFrameEvent;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.*;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import me.retucio.camtweaks.ui.buttons.*;
import me.retucio.camtweaks.ui.buttons.SliderButton;
import me.retucio.camtweaks.ui.buttons.TextButton;
import me.retucio.camtweaks.ui.buttons.ToggleButton;
import me.retucio.camtweaks.util.Colors;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
// marco para los botones de los ajustes de cada módulo
public class SettingsFrame {
final String title;
public Module module;
final List<SettingButton> settingButtons = new ArrayList<>();
public List<SettingButton> visibleButtons = new ArrayList<>();
public int x, y, w, h;
public int renderY;
int dragX, dragY;
boolean dragging;
public int totalHeight = 0;
public final MinecraftClient mc = MinecraftClient.getInstance();
@SuppressWarnings({"rawtypes", "unchecked"})
public SettingsFrame(Module module, int x, int y, int w, int h) {
this.module = module;
// asegurarse de que no se sale de la pantalla
if (mc.getWindow() != null && x + w > mc.getWindow().getScaledWidth())
this.x = mc.getWindow().getScaledWidth() - w;
else
this.x = x;
this.y = y;
this.w = w;
this.h = h;
// añadir el respectivo tipo de botón de cada ajuste a la lista de botones
int offset = h;
for (Setting setting : module.getSettings()) {
switch (setting) {
case BooleanSetting b -> {
addButton(new ToggleButton(b, this, offset));
offset += 18;
} case NumberSetting n -> {
addButton(new SliderButton(n, this, offset));
offset += 18;
} case EnumSetting e -> {
addButton(new CycleButton<>(e, this, offset));
offset += 18;
} case KeySetting k -> {
addButton(new BindButton(k, this, offset));
offset += 18;
} case StringSetting s -> {
addButton(new TextButton(s, this, offset));
offset += 18;
} case ListSetting l -> {
addButton(new ListButton<>(l, this, offset));
offset += 18;
} case ColorSetting c -> {
addButton(new ColorButton(c, this, offset));
offset += 18;
} case OptionSetting o -> {
addButton(new ChooseButton<>(o, this, offset));
offset += 18;
}
default -> {}
}
}
title = "ajustes de " + module.getName();
visibleButtons = settingButtons.stream()
.filter(sb -> sb.getSetting().isVisible())
.toList();
}
public void addButton(SettingButton button) {
settingButtons.add(button);
updateWidth(); // actualizar anchura del frame tras cada iteración
}
public void render(DrawContext ctx, int mouseX, int mouseY, float delta) {
updateWidth();
// cabezal
int centerX = x + w / 2;
int centerY = renderY + h / 2;
int titleX = x + 8;
int titleY = centerY - mc.textRenderer.fontHeight / 2;
int headerColor = module.isEnabled()
? Colors.enabledToggleButtonColor.getRGB()
: Colors.disabledToggleButtonColor.getRGB();
int closeButtonColor = isCloseButtonHovered(mouseX, mouseY)
? Color.RED.getRGB()
: -1;
if (!module.shouldSaveSettings()) headerColor = (int) module.getSettings().stream().filter(s -> ((BooleanSetting) s).isEnabled()).count() > 0
? Colors.enabledToggleButtonColor.getRGB()
: Colors.disabledToggleButtonColor.getRGB();
ctx.fill(x, renderY, x + w, renderY + h, headerColor);
ctx.drawText(mc.textRenderer, title, titleX, titleY, -1, true);
ctx.drawText(mc.textRenderer, "×", x + w - mc.textRenderer.getWidth("×") - 8, titleY, closeButtonColor, true);
visibleButtons = settingButtons.stream()
.filter(sb -> sb.getSetting().isVisible() && sb.getSetting().isSearchMatch())
.toList();
// descripción
List<String> descLines = wrapDescription(module.getDescription(), w - 8);
int lineSpacing = 2;
int descHeight = descLines.size() * mc.textRenderer.fontHeight + (descLines.size() - 1) * lineSpacing;
int descBoxTop = renderY + h + 5;
int descBoxBottom = descBoxTop + descHeight + 8;
totalHeight = descHeight + 8 + h * visibleButtons.size() + 4;
ctx.fill(x, descBoxTop - 4, x + w, descBoxTop + totalHeight, Colors.frameBGColor.getRGB());
ctx.fill(x + 4, descBoxTop, x + w - 4, descBoxBottom, Colors.buttonColor.getRGB());
int firstLineY = descBoxTop + ((descBoxBottom - descBoxTop) - descHeight) / 2;
for (int i = 0; i < descLines.size(); i++) {
String line = descLines.get(i);
int lineX = centerX - mc.textRenderer.getWidth(line) / 2;
int lineY = firstLineY + i * (mc.textRenderer.fontHeight + lineSpacing);
ctx.drawText(mc.textRenderer, line, lineX, lineY, -1, true);
}
int startButtonY = firstLineY - descBoxTop + descBoxBottom;
for (SettingButton sb : visibleButtons) {
sb.setX(x + 4);
sb.setY(startButtonY);
sb.setW(w - 8);
sb.setH(h - h / 4);
sb.render(ctx, mouseX, mouseY, delta);
startButtonY += h;
}
}
public void drawTooltips(DrawContext ctx, double mouseX, double mouseY) {
for (SettingButton sb : visibleButtons)
sb.drawTooltip(ctx, mouseX, mouseY);
}
public void mouseClicked(double mouseX, double mouseY, int button) {
if (isHovered(mouseX, mouseY) && ClickGUI.INSTANCE.trySelect(this)) {
if (isCloseButtonHovered(mouseX, mouseY)) {
ClickGUI.INSTANCE.closeSettingsFrame(this.module);
return;
} if (button == 0) {
dragging = true;
dragX = (int) (mouseX - x);
dragY = (int) (mouseY - y);
} else if (button == 1) {
ClickGUI.INSTANCE.closeSettingsFrame(module);
}
}
for (SettingButton sb : visibleButtons)
sb.mouseClicked(mouseX, mouseY, button);
}
public void mouseReleased(double mouseX, double mouseY, int button) {
ClickGUI.INSTANCE.unselect(this);
if (button == 0) {
dragging = false;
CameraTweaks.EVENT_BUS.post(new SettingsFrameEvent.Move(this));
}
for (SettingButton sb : visibleButtons)
sb.mouseReleased(mouseX, mouseY, button);
}
public void mouseDragged(double mouseX, double mouseY) {
for (SettingButton sb : visibleButtons)
sb.mouseDragged(mouseX, mouseY);
}
public void updatePosition(double mouseX, double mouseY) {
if (dragging) {
x = (int) (mouseX - dragX);
y = (int) (mouseY - dragY);
}
}
public boolean isHovered(double mouseX, double mouseY) {
return mouseX > x && mouseX < x + w &&
mouseY > renderY && mouseY < renderY + h;
}
public boolean isCloseButtonHovered(double mouseX, double mouseY) {
return mouseX > x + w - mc.textRenderer.getWidth("×") - 12 && mouseX < x + w - 4
&& mouseY > renderY + 4 && mouseY < renderY + h - 4;
}
@SuppressWarnings("rawtypes")
void updateWidth() {
// asegurarse de que todos los botones caben en el marco, haciendo que la anchura se ajuste al texto más largo
if (mc.textRenderer == null) return;
int maxWidth = mc.textRenderer.getWidth(title);
for (SettingButton button : settingButtons) {
String text = button.getSetting().getName();
switch (button) {
case SliderButton sliderButton -> text += ": " + sliderButton.df.format((sliderButton.getSetting()).getValue());
case CycleButton cycleButton -> text += ": " + cycleButton.getSetting().getValue();
case BindButton bindButton -> text += ": " + bindButton.getSetting().getKeyName();
case TextButton textButton -> text += ": " + textButton.getSetting().getValue();
default -> {}
}
int textWidth = mc.textRenderer.getWidth(text);
maxWidth = Math.max(maxWidth, textWidth);
}
this.w = maxWidth + 30;
}
private List<String> wrapDescription(String text, int maxWidth) {
List<String> lines = new ArrayList<>();
if (mc.textRenderer == null) return lines;
String[] words = text.split(" ");
StringBuilder line = new StringBuilder();
for (String word : words) {
String testLine = line.isEmpty() ? word : line + " " + word;
if (mc.textRenderer.getWidth(testLine) > maxWidth - 8) { // padding of 4 each side
if (!line.isEmpty()) lines.add(line.toString());
line = new StringBuilder(word);
} else {
line = new StringBuilder(testLine);
}
}
if (!line.isEmpty()) lines.add(line.toString());
return lines;
}
public List<SettingButton> getButtons() {
return settingButtons;
}
public void updateRenderY(int scrollOffset) {
renderY = y - scrollOffset;
}
}
@@ -1,91 +0,0 @@
package me.retucio.camtweaks.ui.hud;
import me.retucio.camtweaks.module.modules.HUD;
import me.retucio.camtweaks.util.Colors;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
import java.util.List;
public abstract class HudElement {
protected static final MinecraftClient mc = MinecraftClient.getInstance();
private final String id;
protected boolean visible;
protected int x, y;
protected final int defaultX, defaultY;
protected int width = 85, height = 14;
public HudElement(String id, int defaultX, int defaultY) {
this.id = id;
this.defaultX = defaultX;
this.defaultY = defaultY;
this.visible = true;
}
public abstract String getText(float delta, HUD hud);
public abstract String getPreviewText();
public void renderInGame(DrawContext ctx, float delta, HUD hud) {
String text = getText(delta, hud);
int color = hud != null ? HudRenderer.getColor(hud).getRGB() : -1;
boolean shadow = hud != null && hud.shadow.isEnabled();
HudRenderer.drawSnappedText(ctx, text, x, y, color, shadow);
}
public void renderInEditor(DrawContext ctx, HUD hud) {
String previewText = getPreviewText();
width = mc.textRenderer.getWidth(previewText);
height = mc.textRenderer.fontHeight;
drawEditorBackground(ctx);
int color = hud != null ? HudRenderer.getColor(hud).getRGB() : -1;
boolean shadow = hud != null && hud.shadow.isEnabled();
HudRenderer.drawSnappedText(ctx, previewText, x, y, color, shadow);
}
public abstract List<Text> getTooltip();
private void drawEditorBackground(DrawContext ctx) {
int bg = visible ? Colors.visibleHudElementColor.getRGB() : Colors.disabledHudElementColor.getRGB();
int outline = HudEditorScreen.INSTANCE != null && HudEditorScreen.INSTANCE.isSelected(this)
? Colors.selectedHudElementOutlineColor.getRGB()
: Colors.unselectedHudElementOutlineColor.getRGB();
// fondo
ctx.fill(x - 1, y - 1, x + width + 1, y + height + 1, bg);
// contorno
ctx.fill(x - 1, y - 1, x + width + 1, y, outline);
ctx.fill(x - 1, y + height, x + width + 1, y + height + 1, outline);
ctx.fill(x - 1, y, x, y + height, outline);
ctx.fill(x + width, y, x + width + 1, y + height, outline);
}
public boolean isHovered(int mouseX, int mouseY) {
return mouseX >= x && mouseX <= x + width
&& mouseY >= y && mouseY <= y + height;
}
// Getters and setters
public String getId() { return id; }
public int getX() { return x; }
public int getY() { return y; }
public int getWidth() { return width; }
public int getHeight() { return height; }
public boolean isVisible() { return visible; }
public void setVisible(boolean visible) { this.visible = visible; }
public void resetPosition() {
this.x = defaultX;
this.y = defaultY;
}
public void setPosition(int x, int y) {
this.x = x;
this.y = y;
}
}
@@ -1,36 +0,0 @@
package me.retucio.camtweaks.ui.widgets;
import me.retucio.camtweaks.module.settings.Setting;
import me.retucio.camtweaks.ui.frames.SettingsFrame;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
public abstract class Button {
protected Frame parent;
protected int offset;
protected int x, y, w, h;
public Button(Frame parent, int offset) {
this.parent = parent;
this.offset = offset;
}
public abstract void render(DrawContext ctx, int mouseX, int mouseY, float delta);
public abstract void mouseClicked(int mouseX, int mouseY, int button);
public abstract void mouseDragged(int mouseX, int mouseY);
public void mouseReleased(int mouseX, int mouseY, int button) {
ClickGUI.INSTANCE.unselect(this);
}
public abstract void drawTooltip(DrawContext ctx, double mouseX, double 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;
}
}
@@ -1,63 +0,0 @@
package me.retucio.camtweaks.ui.widgets;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import java.util.ArrayList;
import java.util.List;
public abstract class Frame {
private final MinecraftClient mc = MinecraftClient.getInstance();
public final String title;
private final List<Button> buttons = new ArrayList<>();
private List<Button> visibleButtons = new ArrayList<>();
private int x, y, w, h;
private int renderY;
private int dragX, dragY;
private boolean dragging;
public int totalHeight = 0;
public Frame(String title, int x, int y, int w, int h) {
this.title = title;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
public abstract void render(DrawContext ctx, int mouseX, int mouseY, float delta);
public void drawTooltips(DrawContext ctx, int mouseX, int mouseY) {
for (Button button : visibleButtons) button.drawTooltip(ctx, mouseX, mouseY);
}
public abstract void mouseClicked(int mouseX, int mouseY, int button);
public abstract void mouseDragged(int mouseX, int mouseY);
public void mouseReleased(int mouseX, int mouseY, int button) {
ClickGUI.INSTANCE.unselect(this);
}
public abstract void updateWidth();
public List<Button> getButtons() {
return buttons;
}
public List<Button> getVisibleButtons() {
return visibleButtons;
}
public boolean isHovered(double mouseX, double mouseY) {
return mouseX > x && mouseX < x + w && mouseY > renderY && mouseY < renderY + h;
}
public void updateRenderY(int scrollOffset) {
renderY = y - scrollOffset;
}
}
@@ -1,89 +0,0 @@
package me.retucio.camtweaks.util;
import me.retucio.camtweaks.CameraTweaks;
import me.retucio.camtweaks.mixin.accessor.KeyBindingAccessor;
import net.minecraft.client.option.KeyBinding;
import org.lwjgl.glfw.GLFW;
// cosas útiles relacionadas a las teclas
public class KeyUtil {
public static boolean isKeyDown(int key) {
return GLFW.glfwGetKey(
CameraTweaks.mc.getWindow().getHandle(),
key) != GLFW.GLFW_RELEASE;
}
public static boolean isKeyDown(KeyBinding key) {
return GLFW.glfwGetKey(
CameraTweaks.mc.getWindow().getHandle(),
((KeyBindingAccessor) key).getBoundKey().getCode()
) != GLFW.GLFW_RELEASE;
}
public static boolean isShiftDown() {
return isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)
|| isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT);
}
public static String getKeyName(int key) {
if (key == GLFW.GLFW_KEY_UNKNOWN) return "ninguna";
String name = GLFW.glfwGetKeyName(key, 0);
if (name != null) return name.toUpperCase();
// para teclas especiales
return switch (key) {
case GLFW.GLFW_KEY_SPACE -> "espacio";
case GLFW.GLFW_KEY_LEFT_SHIFT -> "shift izquierdo";
case GLFW.GLFW_KEY_RIGHT_SHIFT -> "shift derecho";
case GLFW.GLFW_KEY_LEFT_CONTROL -> "ctrl izquierdo";
case GLFW.GLFW_KEY_RIGHT_CONTROL -> "ctrl derecho";
case GLFW.GLFW_KEY_LEFT_ALT -> "alt izquierdo";
case GLFW.GLFW_KEY_RIGHT_ALT -> "alt gr";
case GLFW.GLFW_KEY_TAB -> "tab";
case GLFW.GLFW_KEY_ENTER -> "enter";
case GLFW.GLFW_KEY_BACKSPACE -> "borrar";
case GLFW.GLFW_KEY_DELETE -> "suprimir";
case GLFW.GLFW_KEY_UP -> "arriba";
case GLFW.GLFW_KEY_DOWN -> "abajo";
case GLFW.GLFW_KEY_LEFT -> "izquierda";
case GLFW.GLFW_KEY_RIGHT -> "derecha";
case GLFW.GLFW_KEY_PAGE_UP -> "pág. arriba";
case GLFW.GLFW_KEY_PAGE_DOWN -> "pág. abajo";
default -> {
if (key >= GLFW.GLFW_KEY_F1 && key <= GLFW.GLFW_KEY_F25)
yield "F" + (key - GLFW.GLFW_KEY_F1 + 1); // F1–F25
yield "tecla " + key; // fallback
}
};
}
// quizás debería de añadir layouts...
public static String shiftKey(String c) {
return switch (c) {
case "`" -> "~";
case "1" -> "!";
case "2" -> "@";
case "3" -> "#";
case "4" -> "$";
case "5" -> "%";
case "6" -> "^";
case "7" -> "&";
case "8" -> "*";
case "9" -> "(";
case "0" -> ")";
case "-" -> "_";
case "=" -> "+";
case "[" -> "{";
case "]" -> "}";
case "\\" -> "|";
case ";" -> ":";
case "'" -> "\"";
case "," -> "<";
case "." -> ">";
case "/" -> "?";
default -> c.toUpperCase();
};
}
}
@@ -1,13 +0,0 @@
package me.retucio.camtweaks.util.interfaces;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.text.Text;
import java.util.List;
public interface IChatHud {
void smegma$add(Text message, int id);
List<ChatHudLine.Visible> smegma$getVisibleMessages();
}
@@ -1,14 +0,0 @@
package me.retucio.camtweaks.util.interfaces;
import com.mojang.authlib.GameProfile;
public interface IChatHudLine {
String smegma$getText();
int smegma$getId();
void smegma$setId(int id);
GameProfile smegma$getSender();
void smegma$setSender(GameProfile profile);
}
@@ -1,7 +0,0 @@
package me.retucio.camtweaks.util.interfaces;
public interface IChatHudLineVisible extends IChatHudLine {
boolean smegma$isStartOfEntry();
void smegma$setStartOfEntry(boolean start);
}
@@ -1,6 +0,0 @@
package me.retucio.camtweaks.util.interfaces;
public interface IConfirmScreen {
void smegma$setBypassAction(Runnable action);
}
@@ -1,8 +0,0 @@
package me.retucio.camtweaks.util.interfaces;
import com.mojang.authlib.GameProfile;
public interface IMessageHandler {
GameProfile smegma$getSender();
}
@@ -1,14 +0,0 @@
package me.retucio.camtweaks.util.interfaces;
import net.minecraft.util.math.Vec3i;
import org.joml.Vector3d;
public interface IVec3d {
void smegma$set(double x, double y, double z);
default void smegma$set(Vec3i vec) { smegma$set(vec.getX(), vec.getY(), vec.getZ()); }
default void semgma$set(Vector3d vec) { smegma$set(vec.x, vec.y, vec.z); }
void smegma$setXZ(double x, double z);
void smegma$setY(double y);
}
@@ -1,122 +0,0 @@
package me.retucio.camtweaks.util.render;
import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.vertex.VertexFormat;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import me.retucio.camtweaks.CameraTweaks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gl.RenderPipelines;
import net.minecraft.client.render.BuiltBuffer;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderPhase;
import net.minecraft.client.util.BufferAllocator;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
/** clase modificada de RenderLayer para modificar el color del destello de encantamientos
* @see me.retucio.camtweaks.module.modules.GlintPlus
* yoinkeado de: https://github.com/Pepperoni-Jabroni/NoMorePurple/blob/main/src/main/java/pepjebs/no_more_purple/client/GlintRenderLayer.java
* (y actualizado)
*/
public class GlintRenderLayer extends RenderLayer {
public static List<RenderLayer> glintColor = newRenderList(GlintRenderLayer::buildGlintRenderLayer);
public static List<RenderLayer> entityGlintColor = newRenderList(GlintRenderLayer::buildEntityGlintRenderLayer);
public static List<RenderLayer> armorGlintColor = newRenderList(GlintRenderLayer::buildArmorGlintRenderLayer);
public static List<RenderLayer> armorEntityGlintColor = newRenderList(GlintRenderLayer::buildArmorEntityGlintRenderLayer);
public static void addGlintTypes(Object2ObjectLinkedOpenHashMap<RenderLayer, BufferAllocator> map) {
addGlintTypes(map, glintColor);
addGlintTypes(map, entityGlintColor);
addGlintTypes(map, armorGlintColor);
addGlintTypes(map, armorEntityGlintColor);
}
public GlintRenderLayer(String name, VertexFormat vertexFormat, VertexFormat.DrawMode drawMode, int expectedBufferSize, boolean hasCrumbling, boolean translucent, Runnable startAction, Runnable endAction) {
super(name, expectedBufferSize, hasCrumbling, translucent, startAction, endAction);
}
private static List<RenderLayer> newRenderList(Function<String, RenderLayer> func) {
ArrayList<RenderLayer> list = new ArrayList<>(DyeColor.values().length);
for (DyeColor color : DyeColor.values())
list.add(func.apply(color.name()));
list.add(func.apply("rainbow"));
list.add(func.apply("none"));
return list;
}
public static void addGlintTypes(Object2ObjectLinkedOpenHashMap<RenderLayer, BufferAllocator> map, List<RenderLayer> typeList) {
for(RenderLayer renderType : typeList)
if (!map.containsKey(renderType))
map.put(renderType, new BufferAllocator(renderType.getExpectedBufferSize()));
}
private static RenderLayer buildGlintRenderLayer(String name) {
final Identifier res = Identifier.of(CameraTweaks.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png");
return RenderLayer.of("glint_" + name, 256, RenderPipelines.GLINT, MultiPhaseParameters.builder()
.texturing(RenderPhase.GLINT_TEXTURING)
.texture(new Texture(res, false))
.texturing(GLINT_TEXTURING)
.build(false));
}
private static RenderLayer buildEntityGlintRenderLayer(String name) {
final Identifier res = Identifier.of(CameraTweaks.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png");
return RenderLayer.of("entity_glint_" + name, 256, RenderPipelines.GLINT, MultiPhaseParameters.builder()
.texturing(RenderPhase.ENTITY_GLINT_TEXTURING)
.texture(new Texture(res, false))
.target(ITEM_ENTITY_TARGET)
.texturing(ENTITY_GLINT_TEXTURING)
.build(false));
}
private static RenderLayer buildArmorGlintRenderLayer(String name) {
final Identifier res = Identifier.of(CameraTweaks.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png");
return RenderLayer.of("armor_glint_" + name, 256, RenderPipelines.GLINT, MultiPhaseParameters.builder()
.texturing(RenderPhase.ARMOR_ENTITY_GLINT_TEXTURING)
.texture(new Texture(res, false))
.texturing(GLINT_TEXTURING)
.layering(VIEW_OFFSET_Z_LAYERING)
.build(false));
}
private static RenderLayer buildArmorEntityGlintRenderLayer(String name) {
final Identifier res = Identifier.of(CameraTweaks.MOD_ID, "textures/misc/glint_" + name.toLowerCase() + ".png");
return RenderLayer.of("armor_entity_glint_" + name, 256, RenderPipelines.GLINT, MultiPhaseParameters.builder()
.texturing(RenderPhase.ARMOR_ENTITY_GLINT_TEXTURING)
.texture(new Texture(res, false))
.texturing(ENTITY_GLINT_TEXTURING)
.layering(VIEW_OFFSET_Z_LAYERING)
.build(false));
}
@Override
public void draw(BuiltBuffer buffer) {}
@Override
public VertexFormat getVertexFormat() { return VertexFormat.builder().build(); }
@Override
public VertexFormat.DrawMode getDrawMode() {
return null;
}
@Override
public RenderPipeline getRenderPipeline() {
return null;
}
}
@@ -1,42 +0,0 @@
package me.retucio.camtweaks.util.render;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderPhase;
import net.minecraft.util.Util;
import java.util.OptionalDouble;
import java.util.function.Function;
import static me.retucio.camtweaks.util.render.Pipelines.GLOBAL_LINES_PIPELINE;
import static me.retucio.camtweaks.util.render.Pipelines.GLOBAL_QUADS_PIPELINE;
public class Layers {
private static final RenderLayer GLOBAL_QUADS;
private static final Function<Double, RenderLayer> GLOBAL_LINES;
public static RenderLayer getGlobalLines(double width) {
return GLOBAL_LINES.apply(width);
}
public static RenderLayer getGlobalQuads() {
return GLOBAL_QUADS;
}
private static RenderLayer.MultiPhaseParameters.Builder builder() {
return RenderLayer.MultiPhaseParameters.builder();
}
private static RenderLayer.MultiPhaseParameters empty() {
return builder().build(false);
}
static {
GLOBAL_QUADS = RenderLayer.of("global_fill", 156, GLOBAL_QUADS_PIPELINE, empty());
GLOBAL_LINES = Util.memoize(l -> {
RenderPhase.LineWidth width = new RenderPhase.LineWidth(OptionalDouble.of(l));
return RenderLayer.of("global_lines", 156, GLOBAL_LINES_PIPELINE, builder().lineWidth(width).build(false));
});
}
}
@@ -1,52 +0,0 @@
package me.retucio.camtweaks.util.render;
import com.mojang.blaze3d.pipeline.BlendFunction;
import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.platform.DepthTestFunction;
import com.mojang.blaze3d.vertex.VertexFormat;
import me.retucio.camtweaks.CameraTweaks;
import net.minecraft.client.gl.RenderPipelines;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderPhase;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import java.util.OptionalDouble;
import java.util.function.Function;
public class Pipelines {
static final RenderPipeline GLOBAL_LINES_PIPELINE = RenderPipeline.builder(RenderPipelines.RENDERTYPE_LINES_SNIPPET)
.withLocation(Identifier.of(CameraTweaks.MOD_ID, "pipeline/global_lines"))
.withVertexFormat(VertexFormats.POSITION_COLOR_NORMAL, VertexFormat.DrawMode.LINES)
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
.withDepthWrite(false)
.withCull(false)
.build();
static final RenderPipeline GLOBAL_QUADS_PIPELINE = RenderPipeline.builder(RenderPipelines.POSITION_COLOR_SNIPPET)
.withLocation("pipeline/global_fill_pipeline")
.withVertexFormat(VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.QUADS)
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
.withBlend(BlendFunction.TRANSLUCENT)
.withDepthWrite(false)
.withCull(false)
.build();
static final Function<Double, RenderLayer> GLOBAL_LINES_LAYER = Util.memoize(lineWidth -> {
RenderPhase.LineWidth lineState = new RenderPhase.LineWidth(OptionalDouble.of(lineWidth));
RenderLayer.MultiPhaseParameters compositeState = RenderLayer.MultiPhaseParameters.builder()
.lineWidth(lineState)
.build(false);
return RenderLayer.of("global_lines", RenderLayer.DEFAULT_BUFFER_SIZE, GLOBAL_LINES_PIPELINE, compositeState);
});
public static RenderLayer getGlobalLinesLayer(double lineWidth) {
return GLOBAL_LINES_LAYER.apply(lineWidth);
}
}
@@ -1,283 +0,0 @@
package me.retucio.camtweaks.util.render;
import com.mojang.blaze3d.vertex.VertexFormat;
import me.retucio.camtweaks.util.ChatUtil;
import net.minecraft.SharedConstants;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.*;
import net.minecraft.client.render.state.OutlineRenderState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.*;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import java.awt.*;
// literalmente robado de https://github.com/mioclient/oyvey-ported/ (perdón)
public class RenderUtil {
private static final MinecraftClient mc = MinecraftClient.getInstance();
private static final Tessellator tesselator = Tessellator.getInstance();
// líneas
public static void drawHorizontalLine(MatrixStack matrices, float x1, float x2, float y, Color color) {
if (x2 < x1) {
float i = x1;
x1 = x2;
x2 = i;
}
drawFilledRect(matrices, x1, y, x2 + 1, y + 1, color);
}
public static void drawVerticalLine(MatrixStack matrices, float x, float y1, float y2, Color color) {
if (y2 < y1) {
float i = y1;
y1 = y2;
y2 = i;
}
drawFilledRect(matrices, x, y1 + 1, x + 1, y2, color);
}
public static void drawHorizontalLine(MatrixStack matrices, float x1, float x2, float y, Color color, float width) {
if (x2 < x1) {
float i = x1;
x1 = x2;
x2 = i;
}
drawFilledRect(matrices, x1, y, x2 + width, y + width, color);
}
public static void drawVerticalLine(MatrixStack matrices, float x, float y1, float y2, Color color, float width) {
if (y2 < y1) {
float i = y1;
y1 = y2;
y2 = i;
}
drawFilledRect(matrices, x, y1 + width, x + width, y2, color);
}
// caras
public static void drawFilledRect(MatrixStack matrices, float x, float y, float width, float height, Color color) {
float r = color.getRed() / 255f;
float g = color.getGreen() / 255f;
float b = color.getBlue() / 255f;
float a = color.getAlpha() / 255f;
matrices.push();
matrices.translate(0, 0, 0);
BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
buffer.vertex(matrices.peek().getPositionMatrix(), x, y + height, 0).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), x + width, y + height, 0).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), x + width, y, 0).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), x, y, 0).color(r, g, b, a);
Layers.getGlobalQuads().draw(buffer.end());
matrices.pop();
}
public static void drawRectOutlines(MatrixStack stack, float x1, float y1, float x2, float y2, Color color, float width) {
drawHorizontalLine(stack, x1, x2, y1, color, width);
drawVerticalLine(stack, x2, y1, y2, color, width);
drawHorizontalLine(stack, x1, x2, y2, color, width);
drawVerticalLine(stack, x1, y1, y2, color, width);
}
// expand es para evitar z-fighting
public static void drawBlockFaceFilled(MatrixStack matrices, BlockPos pos, Direction face, Color color, float expand) {
Vec3d cameraPos = mc.gameRenderer.getCamera().getPos();
float minX = (float) (pos.getX() - cameraPos.x);
float minY = (float) (pos.getY() - cameraPos.y);
float minZ = (float) (pos.getZ() - cameraPos.z);
float maxX = minX + 1;
float maxY = minY + 1;
float maxZ = minZ + 1;
float r = color.getRed() / 255f;
float g = color.getGreen() / 255f;
float b = color.getBlue() / 255f;
float a = color.getAlpha() / 255f;
if (expand != 0) {
switch (face) {
case DOWN: minY -= expand; maxY = minY + 0.001f; break;
case UP: minY = maxY; maxY += expand; break;
case NORTH: minZ -= expand; maxZ = minZ + 0.001f; break;
case SOUTH: minZ = maxZ; maxZ += expand; break;
case WEST: minX -= expand; maxX = minX + 0.001f; break;
case EAST: minX = maxX; maxX += expand; break;
}
}
BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
switch (face) {
case DOWN:
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(r, g, b, a);
break;
case UP:
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(r, g, b, a);
break;
case NORTH:
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(r, g, b, a);
break;
case SOUTH:
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(r, g, b, a);
break;
case WEST:
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(r, g, b, a);
break;
case EAST:
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(r, g, b, a);
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(r, g, b, a);
break;
}
Layers.getGlobalQuads().draw(buffer.end());
}
// cajas
public static void drawOutlineBox(MatrixStack matrices, Box box, Color color, float lineWidth) {
float r = color.getRed() / 255f;
float g = color.getGreen() / 255f;
float b = color.getBlue() / 255f;
float a = color.getAlpha() / 255f;
Vec3d cameraPos = mc.gameRenderer.getCamera().getPos();
float minX = (float) (box.minX - cameraPos.x);
float minY = (float) (box.minY - cameraPos.y);
float minZ = (float) (box.minZ - cameraPos.z);
float maxX = (float) (box.maxX - cameraPos.x);
float maxY = (float) (box.maxY - cameraPos.y);
float maxZ = (float) (box.maxZ - cameraPos.z);
BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL);
VertexRendering.drawBox(matrices.peek(), buffer, minX, minY, minZ, maxX, maxY, maxZ, r, g, b, a);
Layers.getGlobalLines(lineWidth).draw(buffer.end());
}
public static void drawFilledBox(MatrixStack matrices, Box box, Color color) {
Vec3d cameraPos = mc.gameRenderer.getCamera().getPos();
float minX = (float) (box.minX - cameraPos.x);
float minY = (float) (box.minY - cameraPos.y);
float minZ = (float) (box.minZ - cameraPos.z);
float maxX = (float) (box.maxX - cameraPos.x);
float maxY = (float) (box.maxY - cameraPos.y);
float maxZ = (float) (box.maxZ - cameraPos.z);
BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), maxX, maxY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, maxZ).color(color.getRGB());
buffer.vertex(matrices.peek().getPositionMatrix(), minX, maxY, minZ).color(color.getRGB());
Layers.getGlobalQuads().draw(buffer.end());
}
// formas custom
public static void drawVoxelShapeOutline(MatrixStack matrices, VoxelShape voxelShape, BlockPos pos, Color color, float lineWidth) {
if (voxelShape.isEmpty()) return;
voxelShape.forEachBox((minX, minY, minZ, maxX, maxY, maxZ) -> {
Box box = new Box(
pos.getX() + minX, pos.getY() + minY, pos.getZ() + minZ,
pos.getX() + maxX, pos.getY() + maxY, pos.getZ() + maxZ
);
drawOutlineBox(matrices, box, color, lineWidth);
});
}
public static void drawVoxelShapeFilled(MatrixStack matrices, VoxelShape voxelShape, BlockPos pos, Color color) {
if (voxelShape.isEmpty()) return;
voxelShape.forEachBox((minX, minY, minZ, maxX, maxY, maxZ) -> {
Box box = new Box(
pos.getX() + minX, pos.getY() + minY, pos.getZ() + minZ,
pos.getX() + maxX, pos.getY() + maxY, pos.getZ() + maxZ
);
drawFilledBox(matrices, box, color);
});
}
// bloques
public static void drawBlockOutline(MatrixStack matrices, BlockPos pos, Color color, float lineWidth) {
Box box = new Box(pos.getX(), pos.getY(), pos.getZ(),
pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
drawOutlineBox(matrices, box, color, lineWidth);
}
public static void drawBlockFilled(MatrixStack matrices, BlockPos pos, Color color) {
Box box = new Box(pos.getX(), pos.getY(), pos.getZ(),
pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
drawFilledBox(matrices, box, color);
}
}
@@ -1,44 +1,45 @@
package me.retucio.camtweaks;
package me.retucio.sputnik;
import me.retucio.camtweaks.command.CommandManager;
import me.retucio.camtweaks.command.commands.BindCommand;
import me.retucio.sputnik.cape.CapeManager;
import me.retucio.sputnik.command.CommandManager;
import me.retucio.sputnik.command.commands.BindCommand;
import me.retucio.camtweaks.config.ConfigManager;
import me.retucio.sputnik.config.ConfigManager;
import me.retucio.camtweaks.event.EventBus;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.ShutdownEvent;
import me.retucio.sputnik.event.EventBus;
import me.retucio.sputnik.event.SubscribeEvent;
import me.retucio.sputnik.event.events.ShutdownEvent;
import me.retucio.sputnik.event.events.sputnik.LoadCapeManagerEvent;
import me.retucio.sputnik.event.events.sputnik.LoadClickGUIEvent;
import me.retucio.sputnik.event.events.sputnik.LoadCommandManagerEvent;
import me.retucio.sputnik.event.events.sputnik.LoadModuleManagerEvent;
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.sputnik.module.Module;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.client.HUD;
import me.retucio.camtweaks.module.modules.HUD;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import me.retucio.camtweaks.ui.hud.HudEditorScreen;
import me.retucio.camtweaks.ui.hud.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.ClientSettingsFrame;
import me.retucio.camtweaks.ui.frames.SettingsFrame;
import me.retucio.sputnik.ui.screen.ClickGUI;
import me.retucio.sputnik.ui.hud.HudEditorScreen;
import me.retucio.sputnik.ui.widgets.buttons.settings.BindButton;
import me.retucio.sputnik.ui.widgets.buttons.SettingButton;
import me.retucio.sputnik.ui.widgets.buttons.settings.TextButton;
import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame;
import me.retucio.sputnik.ui.widgets.frames.SettingsFrame;
import me.retucio.sputnik.ui.widgets.Button;
import me.retucio.camtweaks.util.*;
import me.retucio.sputnik.util.*;
import me.retucio.sputnik.util.KeyUtil;
import me.retucio.sputnik.util.render.DrawUtil;
import me.retucio.sputnik.util.render.RenderUtil;
import me.retucio.camtweaks.util.render.DrawUtil;
import me.retucio.camtweaks.util.render.RenderUtil;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.SharedConstants;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.AbstractCommandBlockScreen;
import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen;
import net.minecraft.client.gui.screen.ingame.AnvilScreen;
@@ -49,43 +50,38 @@ import org.lwjgl.glfw.GLFW;
public class CameraTweaks implements ClientModInitializer {
public class Sputnik implements ClientModInitializer {
// cosas necesarias
public static final CameraTweaks INSTANCE = new CameraTweaks();
public static final Sputnik INSTANCE = new Sputnik();
public static final EventBus EVENT_BUS = new EventBus();
public static final Logger LOGGER = LogManager.getLogger(CameraTweaks.class);
public static final Logger LOGGER = LogManager.getLogger(Sputnik.class);
public static MinecraftClient mc;
// id y versión
public static final String MOD_ID = "camtweaks";
public static final String MOD_VERSION;
static {
MOD_VERSION = FabricLoader.getInstance().getModContainer(MOD_ID)
public static final String MOD_ID = "sputnik";
public static final String MOD_VERSION = FabricLoader.getInstance()
.getModContainer(MOD_ID)
.orElseThrow()
.getMetadata()
.getVersion()
.getFriendlyString();
}
private Screen prevScreen;
public static boolean settingsApplied = false;
static {
// puta vida
System.setProperty("java.awt.headless", "false");
}
@Override
public void onInitializeClient() {
// 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();
ConfigManager.load();
EVENT_BUS.register(this);
EVENT_BUS.register(new HudRenderer());
EVENT_BUS.register(ChatUtil.class);
EVENT_BUS.register(DrawUtil.class);
EVENT_BUS.register(EntityUtil.class);
@@ -96,6 +92,9 @@ public class CameraTweaks implements ClientModInitializer {
Lists.init();
CapeManager.INSTANCE = new CapeManager();
EVENT_BUS.post(new LoadCapeManagerEvent());
ModuleManager.INSTANCE = new ModuleManager();
EVENT_BUS.post(new LoadModuleManagerEvent());
@@ -107,7 +106,6 @@ public class CameraTweaks implements ClientModInitializer {
EVENT_BUS.post(new LoadClickGUIEvent());
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
ConfigManager.save();
EVENT_BUS.post(new ShutdownEvent());
}));
}
@@ -126,9 +124,8 @@ public class CameraTweaks implements ClientModInitializer {
// se ejecuta cada vez que se presiona una tecla
public void onKeyPress(int key, int action) {
public void onKey(int key, int action) {
if (key == GLFW.GLFW_KEY_F3) return; // prevenir activación de módulos al usar combinaciones de F3
ModuleManager.INSTANCE.getEnabledModules().forEach(module -> module.onKey(key, action));
boolean anyFocused = isAnySettingButtonFocused() || ClickGUI.INSTANCE.getSearchBar().isFocused();
ClickGUI.INSTANCE.setAnyFocused(anyFocused);
@@ -149,7 +146,7 @@ public class CameraTweaks implements ClientModInitializer {
// verifica si algún botón de ajustes está escuchando
private boolean isAnySettingButtonFocused() {
for (SettingsFrame sf : ClickGUI.INSTANCE.getSettingsFrames())
for (SettingButton sb : sf.getButtons())
for (Button sb : sf.getButtons())
if ((sb instanceof BindButton b && b.isFocused()) || (sb instanceof TextButton t && t.isFocused()))
return true;
return false;
@@ -172,9 +169,9 @@ public class CameraTweaks implements ClientModInitializer {
// se ocupa de hacer los botones de ajustes que lo necesiten escuchar teclas
private void handleSettingButtonsKey(int key, int action) {
for (SettingsFrame sf : ClickGUI.INSTANCE.getSettingsFrames()) {
for (SettingButton sb : sf.getButtons()) {
if (sb instanceof BindButton b) b.onKey(key, action);
else if (sb instanceof TextButton t) t.onKey(key, action);
for (SettingButton<?> sb : sf.getButtons()) {
if (sb instanceof BindButton bb) bb.onKey(key, action);
if (sb instanceof TextButton tb) tb.onKey(key, action);
}
}
}
@@ -0,0 +1,61 @@
package me.retucio.sputnik.cape;
import me.retucio.sputnik.Sputnik;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.util.Identifier;
import java.io.IOException;
import java.io.InputStream;
public class Cape {
private final MinecraftClient mc = MinecraftClient.getInstance();
private final String name;
private final Identifier id;
private NativeImage img;
private NativeImageBackedTexture texture;
public Cape(String name) {
this.name = name;
this.id = Identifier.of(Sputnik.MOD_ID, "textures/capes/" + name + ".png");
}
public void load() {
this.img = loadTexture(this.id);
}
public NativeImage loadTexture(Identifier id) {
try (InputStream inputStream = mc.getResourceManager().getResource(id).get().getInputStream()) {
return NativeImage.read(inputStream);
} catch (IOException e) {
Sputnik.LOGGER.error("ups: {}", e.getMessage());
return null;
}
}
public void register() {
texture = new NativeImageBackedTexture(null, img);
mc.getTextureManager().registerTexture(id, texture);
img = null;
}
public String getName() {
return name;
}
public Identifier getId() {
return id;
}
public NativeImageBackedTexture getTexture() {
return texture;
}
@Override
public String toString() {
return name.replace('-', ' ');
}
}
@@ -0,0 +1,87 @@
package me.retucio.sputnik.cape;
import java.util.ArrayList;
import java.util.List;
import static me.retucio.sputnik.Sputnik.mc;
public class CapeManager {
public static CapeManager INSTANCE;
private final List<Cape> capes = new ArrayList<>();
public CapeManager() {
addCapes();
}
public void addCapes() {
addCape("sputnik");
addCape("half-life");
addCape("hollow-knight");
addCape("cherry-blossom");
addCape("migrator");
addCape("minecraft");
addCape("pancakes");
addCape("vanilla");
addCape("tiktok");
addCape("twitch");
addCape("mojang");
addCape("mojang-old");
addCape("mojang-old-old");
addCape("minecon-2011");
addCape("minecon-2012");
addCape("minecon-2013");
addCape("minecon-2015");
addCape("minecon-2016");
addCape("experience-2025");
addCape("15th-anniversary");
addCape("bedrock");
addCape("birthday");
addCape("copper");
addCape("eye-blossom");
addCape("mcc-15");
addCape("prismarine");
addCape("turtle");
addCape("valentine");
addCape("chinese-translator");
addCape("cobalt");
addCape("mojira-mod");
addCape("millionth-customer");
addCape("realms-mapmaker");
addCape("scrolls-champion");
addCape("translator");
addCape("cheapsh0t");
addCape("dannybstyle");
addCape("julianclark");
addCape("mrmessiah");
for (Cape cape : capes) {
mc.execute(cape::load);
mc.execute(cape::register);
}
}
private void addCape(String name) {
capes.add(new Cape(name));
}
public Cape getCape(String name) {
for (Cape cape : capes)
if (cape.getName().equalsIgnoreCase(name))
return cape;
return null;
}
public List<Cape> getCapes() {
return capes;
}
}
@@ -1,4 +1,4 @@
package me.retucio.camtweaks.command;
package me.retucio.sputnik.command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.ArgumentType;
@@ -65,7 +65,7 @@ public abstract class Command {
}
public String toString() {
return me.retucio.camtweaks.command.CommandManager.INSTANCE.getPrefix() + name;
return me.retucio.sputnik.command.CommandManager.INSTANCE.getPrefix() + name;
}
public String toString(String... args) {
@@ -1,11 +1,10 @@
package me.retucio.camtweaks.command;
package me.retucio.sputnik.command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import me.retucio.camtweaks.CameraTweaks;
import me.retucio.camtweaks.command.commands.*;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.module.Module;
import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.command.commands.*;
import me.retucio.sputnik.event.SubscribeEvent;
import net.minecraft.client.MinecraftClient;
import net.minecraft.command.CommandSource;
@@ -33,6 +32,7 @@ public class CommandManager {
public static void registerCommands() {
addCommand(new BindCommand());
addCommand(new ConfigCommand());
addCommand(new CopyScreenshotCommand());
addCommand(new EnderChestCommand());
addCommand(new GarbageCleanerCommand());
@@ -49,7 +49,7 @@ public class CommandManager {
for (Command command : commands) {
for (Method method : command.getClass().getDeclaredMethods()) {
if (method.isAnnotationPresent(SubscribeEvent.class)) {
CameraTweaks.EVENT_BUS.register(command);
Sputnik.EVENT_BUS.register(command);
break;
}
}
@@ -1,4 +1,4 @@
package me.retucio.camtweaks.command.args;
package me.retucio.sputnik.command.args;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.arguments.ArgumentType;
@@ -8,19 +8,19 @@ import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import me.retucio.camtweaks.util.EntityUtil;
import me.retucio.sputnik.util.EntityUtil;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import javax.swing.*;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern;
// para autocompletar entidades
import static me.retucio.camtweaks.CameraTweaks.mc;
import static me.retucio.sputnik.Sputnik.mc;
// para autocompletar entidades
public class EntityArgumentType implements ArgumentType<Entity> {
public static final EntityArgumentType INSTANCE = new EntityArgumentType();
@@ -1,4 +1,4 @@
package me.retucio.camtweaks.command.args;
package me.retucio.sputnik.command.args;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.arguments.ArgumentType;
@@ -7,8 +7,9 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.ModuleManager;
import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.util.MiscUtil;
import net.minecraft.command.CommandSource;
import net.minecraft.text.Text;
@@ -19,6 +20,7 @@ import java.util.concurrent.CompletableFuture;
public class ModuleArgumentType implements ArgumentType<Module> {
public static final ModuleArgumentType INSTANCE = new ModuleArgumentType();
private static final DynamicCommandExceptionType UNKNOWN_MODULE = new DynamicCommandExceptionType(
name -> Text.literal("módulo \"" + name + "\" no encontrado"));
@@ -35,7 +37,8 @@ public class ModuleArgumentType implements ArgumentType<Module> {
@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestMatching(ModuleManager.INSTANCE.getModules().stream().map(module -> module.getName().replace(" ", "_")), builder);
return CommandSource.suggestMatching(ModuleManager.INSTANCE.getModules()
.stream().map(module -> MiscUtil.removeAccentMarks(module.getName().replace(" ", "_"))), builder);
}
@Override
@@ -1,4 +1,4 @@
package me.retucio.camtweaks.command.args;
package me.retucio.sputnik.command.args;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.arguments.ArgumentType;
@@ -15,7 +15,7 @@ import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import static me.retucio.camtweaks.CameraTweaks.mc;
import static me.retucio.sputnik.Sputnik.mc;
// para autocompletar nombres de jugadores
public class PlayerArgumentType implements ArgumentType<PlayerEntity> {
@@ -1,12 +1,12 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.command.args.ModuleArgumentType;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.settings.KeySetting;
import me.retucio.camtweaks.util.ChatUtil;
import me.retucio.camtweaks.util.KeyUtil;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.ModuleArgumentType;
import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.setting.settings.KeySetting;
import me.retucio.sputnik.util.ChatUtil;
import me.retucio.sputnik.util.KeyUtil;
import net.minecraft.command.CommandSource;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -0,0 +1,67 @@
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.ModuleArgumentType;
import me.retucio.sputnik.module.setting.Setting;
import me.retucio.sputnik.ui.screen.ClickGUI;
import me.retucio.sputnik.ui.widgets.frames.SettingsFrame;
import net.minecraft.command.CommandSource;
import me.retucio.sputnik.module.Module;
public class ConfigCommand extends Command {
public ConfigCommand() {
super("config", "abre el marco de ajustes de un módulo", "ajustes", "settings");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder
.then(argument("módulo", ModuleArgumentType.INSTANCE)
.executes(ctx -> {
mc.execute(() -> openSf(ctx));
return SUCCESS;
})
.then(argument("x", IntegerArgumentType.integer())
.then(argument("y", IntegerArgumentType.integer())
.executes(ctx -> {
mc.execute(() -> openSfWithPos(ctx,
ctx.getArgument("x", Integer.class),
ctx.getArgument("y", Integer.class)));
return SUCCESS;
})
)
)
);
}
private void openSf(CommandContext<CommandSource> ctx) {
Module module = ctx.getArgument("módulo", Module.class);
mc.setScreen(ClickGUI.INSTANCE);
if (ClickGUI.INSTANCE.isSettingsFrameOpen(module)) return;
SettingsFrame sf = ClickGUI.INSTANCE.getSfOfModule(module);
int x = mc.getWindow().getScaledWidth() / 2 - sf.getW() / 2;
int y = 67;
ClickGUI.INSTANCE.openSettingsFrame(module, x, y);
}
private void openSfWithPos(CommandContext<CommandSource> ctx, int x, int y) {
Module module = ctx.getArgument("módulo", Module.class);
mc.setScreen(ClickGUI.INSTANCE);
if (ClickGUI.INSTANCE.isSettingsFrameOpen(module)) {
SettingsFrame sf = ClickGUI.INSTANCE.getSfOfModule(module);
sf.setX(x);
sf.setY(y);
}
ClickGUI.INSTANCE.openSettingsFrame(module, x, y);
}
}
@@ -1,9 +1,9 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.module.ModuleManager;
import me.retucio.camtweaks.module.modules.ScreenshotPlus;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
import net.minecraft.command.CommandSource;
// se usa principalmente para el módulo ScreenshotPlus, pero también se puede usar sin él supongo
@@ -1,13 +1,12 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.CameraTweaks;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.TickEvent;
import me.retucio.camtweaks.ui.screen.PreviewScreen;
import me.retucio.camtweaks.util.ChatUtil;
import me.retucio.camtweaks.util.InventoryUtil;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.event.SubscribeEvent;
import me.retucio.sputnik.event.events.TickEvent;
import me.retucio.sputnik.ui.screen.PreviewScreen;
import me.retucio.sputnik.util.ChatUtil;
import me.retucio.sputnik.util.InventoryUtil;
import net.minecraft.command.CommandSource;
// accede a los contenidos de tu enderchest
@@ -1,8 +1,8 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.util.ChatUtil;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.command.CommandSource;
import net.minecraft.text.Text;
@@ -1,9 +1,9 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.command.args.PlayerArgumentType;
import me.retucio.camtweaks.util.MiscUtil;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.PlayerArgumentType;
import me.retucio.sputnik.util.MiscUtil;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.command.CommandSource;
@@ -1,10 +1,10 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
import me.retucio.camtweaks.util.ChatUtil;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame;
import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.command.CommandSource;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -1,9 +1,9 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.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 me.retucio.sputnik.command.Command;
import me.retucio.sputnik.util.interfaces.IChatHud;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.command.CommandSource;
@@ -31,7 +31,7 @@ public class PurgeCommand extends Command {
ChatHud chatHud = mc.inGameHud.getChatHud();
synchronized (chatHud) {
List<ChatHudLine.Visible> visibleMessages = ((IChatHud) chatHud).smegma$getVisibleMessages();
List<ChatHudLine.Visible> visibleMessages = ((IChatHud) chatHud).sputnik$getVisibleMessages();
int toRemove = Math.min(amount, visibleMessages.size());
for (int i = 0; i < toRemove; i++)
visibleMessages.removeFirst();
@@ -1,10 +1,10 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.module.ModuleManager;
import me.retucio.camtweaks.module.modules.ScreenshotPlus;
import me.retucio.camtweaks.util.ChatUtil;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.command.CommandSource;
import java.io.IOException;
@@ -1,9 +1,9 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.mixin.accessor.ClientPlayNetworkHandlerAccessor;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.mixin.accessor.ClientPlayNetworkHandlerAccessor;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.command.CommandSource;
import net.minecraft.network.encryption.NetworkEncryptionUtils;
@@ -11,7 +11,6 @@ import net.minecraft.network.message.LastSeenMessagesCollector;
import net.minecraft.network.message.MessageBody;
import net.minecraft.network.message.MessageSignatureData;
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
import net.minecraft.text.Text;
import java.time.Instant;
@@ -1,12 +1,11 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.command.args.EntityArgumentType;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.KeyEvent;
import me.retucio.camtweaks.util.EntityUtil;
import me.retucio.camtweaks.util.MiscUtil;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.EntityArgumentType;
import me.retucio.sputnik.event.SubscribeEvent;
import me.retucio.sputnik.event.events.KeyEvent;
import me.retucio.sputnik.util.EntityUtil;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
import org.lwjgl.glfw.GLFW;
@@ -1,10 +1,10 @@
package me.retucio.camtweaks.command.commands;
package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.camtweaks.command.Command;
import me.retucio.camtweaks.command.args.ModuleArgumentType;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.ModuleManager;
import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.ModuleArgumentType;
import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.ModuleManager;
import net.minecraft.command.CommandSource;
// porque usar el ratón es más lento que escribir, a menos que tengas toque con el teclado como yo
@@ -0,0 +1,357 @@
package me.retucio.sputnik.config;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class BinarySerializer {
private static final int MAGIC_NUMBER = 0x53505554; // "SPUT"
private static final int VERSION = 1;
private static final byte TYPE_NULL = 0;
private static final byte TYPE_BOOLEAN = 1;
private static final byte TYPE_INT = 2;
private static final byte TYPE_DOUBLE = 3;
private static final byte TYPE_STRING = 4;
private static final byte TYPE_MAP = 5;
private static final byte TYPE_INT_ARRAY = 6;
private static final byte TYPE_FRAME_DATA = 7;
public static void writeConfig(ClientConfig config, File file)
throws IOException {
try (DataOutputStream out = new DataOutputStream(
new BufferedOutputStream(new FileOutputStream(file)))) {
// cabezal
out.writeInt(MAGIC_NUMBER);
out.writeInt(VERSION);
// mapas
writeStringBooleanMap(out, config.moduleStates);
writeSettingsMap(out, config.settings);
writeStringIntArrayMap(out, config.settingsFrames);
writeExtendableFrames(out, config.extendableFrames);
writeStringIntArrayMap(out, config.hudPositions);
writeStringBooleanMap(out, config.hudVisibilities);
writeStringStringMap(out, config.hudImagePaths);
// posición de la barra de búsqueda
if (config.searchBarPosition != null) {
out.writeBoolean(true);
out.writeInt(config.searchBarPosition[0]);
out.writeInt(config.searchBarPosition[1]);
} else {
out.writeBoolean(false);
}
}
}
public static ClientConfig readConfig(File file)
throws IOException {
if (!file.exists() || file.length() == 0) {
throw new IOException("archivo de config. vacío o inexistente");
}
try (DataInputStream in = new DataInputStream(
new BufferedInputStream(new FileInputStream(file)))) {
if (file.length() < 8) {
throw new IOException("archivo demasiado pequeño para ser válido");
}
// verificar cabezal
int magic = in.readInt();
if (magic != MAGIC_NUMBER) {
throw new IOException("formato de archivo inválido: " + magic);
}
int version = in.readInt();
if (version != VERSION) {
throw new IOException("versión inválida: " + version);
}
ClientConfig config = new ClientConfig();
// leer mapas
config.moduleStates = readStringBooleanMap(in);
config.settings = readSettingsMap(in);
config.settingsFrames = readStringIntArrayMap(in);
config.extendableFrames = readExtendableFrames(in);
config.hudPositions = readStringIntArrayMap(in);
config.hudVisibilities = readStringBooleanMap(in);
config.hudImagePaths = readStringStringMap(in);
// leer pos. de la barra de búsqueda
if (in.readBoolean()) {
config.searchBarPosition = new int[]{in.readInt(), in.readInt()};
}
return config;
}
}
private static void writeStringBooleanMap(DataOutputStream out, Map<String, Boolean> map)
throws IOException {
if (map == null) {
out.writeInt(0);
return;
}
out.writeInt(map.size());
for (Map.Entry<String, Boolean> entry : map.entrySet()) {
writeString(out, entry.getKey());
out.writeBoolean(entry.getValue());
}
}
private static Map<String, Boolean> readStringBooleanMap(DataInputStream in)
throws IOException {
int size = in.readInt();
Map<String, Boolean> map = new HashMap<>(size);
for (int i = 0; i < size; i++) {
String key = readString(in);
boolean value = in.readBoolean();
map.put(key, value);
}
return map;
}
private static void writeSettingsMap(DataOutputStream out, Map<String, Object> map)
throws IOException {
if (map == null) {
out.writeInt(0);
return;
}
out.writeInt(map.size());
for (Map.Entry<String, Object> entry : map.entrySet()) {
writeString(out, entry.getKey());
writeSettingValue(out, entry.getValue());
}
}
private static Map<String, Object> readSettingsMap(DataInputStream in)
throws IOException {
int size = in.readInt();
Map<String, Object> map = new HashMap<>(size);
for (int i = 0; i < size; i++) {
String key = readString(in);
Object value = readSettingValue(in);
map.put(key, value);
}
return map;
}
private static void writeSettingValue(DataOutputStream out, Object value)
throws IOException {
switch (value) {
case Boolean b -> {
out.writeByte(TYPE_BOOLEAN);
out.writeBoolean(b);
}
case Integer i -> {
out.writeByte(TYPE_INT);
out.writeInt(i);
}
case Double v -> {
out.writeByte(TYPE_DOUBLE);
out.writeDouble(v);
}
case String s -> {
out.writeByte(TYPE_STRING);
writeString(out, s);
}
case Map<?, ?> map -> {
out.writeByte(TYPE_MAP);
writeGenericMap(out, map);
} // fallback
case null, default -> out.writeByte(TYPE_NULL);
}
}
private static Object readSettingValue(DataInputStream in) throws IOException {
byte type = in.readByte();
return switch (type) {
case TYPE_BOOLEAN -> in.readBoolean();
case TYPE_INT -> in.readInt();
case TYPE_DOUBLE -> in.readDouble();
case TYPE_STRING -> readString(in);
case TYPE_MAP -> readGenericMap(in);
default -> null;
};
}
private static void writeGenericMap(DataOutputStream out, Map<?, ?> map)
throws IOException {
if (map == null) {
out.writeInt(0);
return;
}
out.writeInt(map.size());
for (Map.Entry<?, ?> entry : map.entrySet()) {
writeObject(out, entry.getKey());
writeObject(out, entry.getValue());
}
}
private static Map<Object, Object> readGenericMap(DataInputStream in)
throws IOException {
int size = in.readInt();
Map<Object, Object> map = new HashMap<>(size);
for (int i = 0; i < size; i++) {
Object key = readObject(in);
Object value = readObject(in);
map.put(key, value);
}
return map;
}
private static void writeObject(DataOutputStream out, Object obj)
throws IOException {
switch (obj) {
case String s -> {
out.writeByte(TYPE_STRING);
writeString(out, s);
}
case Boolean b -> {
out.writeByte(TYPE_BOOLEAN);
out.writeBoolean(b);
}
case Number number -> {
if (obj instanceof Integer) {
out.writeByte(TYPE_INT);
out.writeInt((Integer) obj);
} else if (obj instanceof Double) {
out.writeByte(TYPE_DOUBLE);
out.writeDouble((Double) obj);
}
}
default -> {
out.writeByte(TYPE_STRING);
writeString(out, obj.toString());
}
}
}
private static Object readObject(DataInputStream in) throws IOException {
byte type = in.readByte();
return switch (type) {
case TYPE_STRING -> readString(in);
case TYPE_BOOLEAN -> in.readBoolean();
case TYPE_INT -> in.readInt();
case TYPE_DOUBLE -> in.readDouble();
default -> null;
};
}
private static void writeStringIntArrayMap(DataOutputStream out, Map<String, int[]> map)
throws IOException {
if (map == null) {
out.writeInt(0);
return;
}
out.writeInt(map.size());
for (Map.Entry<String, int[]> entry : map.entrySet()) {
writeString(out, entry.getKey());
int[] array = entry.getValue();
if (array == null) {
out.writeInt(0);
} else {
out.writeInt(array.length);
for (int value : array) {
out.writeInt(value);
}
}
}
}
private static Map<String, int[]> readStringIntArrayMap(DataInputStream in)
throws IOException {
int size = in.readInt();
Map<String, int[]> map = new HashMap<>(size);
for (int i = 0; i < size; i++) {
String key = readString(in);
int arraySize = in.readInt();
int[] array = new int[arraySize];
for (int j = 0; j < arraySize; j++) {
array[j] = in.readInt();
}
map.put(key, array);
}
return map;
}
private static void writeExtendableFrames(DataOutputStream out, Map<String, ClientConfig.FrameData> map)
throws IOException {
if (map == null) {
out.writeInt(0);
return;
}
out.writeInt(map.size());
for (Map.Entry<String, ClientConfig.FrameData> entry : map.entrySet()) {
writeString(out, entry.getKey());
ClientConfig.FrameData data = entry.getValue();
out.writeInt(data.x());
out.writeInt(data.y());
out.writeBoolean(data.extended());
}
}
private static Map<String, ClientConfig.FrameData> readExtendableFrames(DataInputStream in)
throws IOException {
int size = in.readInt();
Map<String, ClientConfig.FrameData> map = new HashMap<>(size);
for (int i = 0; i < size; i++) {
String key = readString(in);
int x = in.readInt();
int y = in.readInt();
boolean extended = in.readBoolean();
map.put(key, new ClientConfig.FrameData(x, y, extended));
}
return map;
}
private static void writeStringStringMap(DataOutputStream out, Map<String, String> map)
throws IOException {
if (map == null) {
out.writeInt(0);
return;
}
out.writeInt(map.size());
for (Map.Entry<String, String> entry : map.entrySet()) {
writeString(out, entry.getKey());
writeString(out, entry.getValue());
}
}
private static Map<String, String> readStringStringMap(DataInputStream in)
throws IOException {
int size = in.readInt();
Map<String, String> map = new HashMap<>(size);
for (int i = 0; i < size; i++) {
String key = readString(in);
String value = readString(in);
map.put(key, value);
}
return map;
}
// Optimized string writing (UTF-8 with length prefix)
private static void writeString(DataOutputStream out, String str) throws IOException {
if (str == null) {
out.writeInt(-1);
return;
}
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
out.writeInt(bytes.length);
out.write(bytes);
}
private static String readString(DataInputStream in) throws IOException {
int length = in.readInt();
if (length == -1) return null;
byte[] bytes = new byte[length];
in.readFully(bytes);
return new String(bytes, "UTF-8");
}
}
@@ -1,15 +1,17 @@
package me.retucio.camtweaks.config;
package me.retucio.sputnik.config;
import me.retucio.camtweaks.event.SubscribeEvent;
import me.retucio.camtweaks.event.events.camtweaks.*;
import me.retucio.camtweaks.module.settings.*;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import me.retucio.sputnik.event.SubscribeEvent;
import me.retucio.sputnik.event.events.sputnik.*;
import me.retucio.sputnik.module.setting.settings.*;
import me.retucio.sputnik.ui.screen.ClickGUI;
import java.io.Serial;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
import static me.retucio.camtweaks.CameraTweaks.mc;
import static me.retucio.sputnik.Sputnik.EVENT_BUS;
import static me.retucio.sputnik.Sputnik.mc;
// clase donde se guardan las configuraciones temporalmente hasta escribirlas en camera_tweaks.json
public class ClientConfig {
@@ -32,6 +34,9 @@ public class ClientConfig {
// id del elemento del hud -> true: visible / false: no visible
public Map<String, Boolean> hudVisibilities = new HashMap<>();
// id del elemento del hud -> ruta de la imagen (NEW)
public Map<String, String> hudImagePaths = new HashMap<>();
// posición de la barra de búsqueda (x, y)
public int[] searchBarPosition = new int[]{340, 16};
@@ -59,7 +64,7 @@ public class ClientConfig {
case StringSetting s: value = s.getValue(); break;
case ListSetting l: value = l.getConfigValues(); break;
case ColorSetting c: value = c.getConfigValue(); break;
case OptionSetting o: value = o.getIndex(); break;
case OptionSetting o: value = o.getDisplayName(); break;
default: break;
}
@@ -68,53 +73,54 @@ public class ClientConfig {
@SubscribeEvent
public void onOpenSettingsFrame(SettingsFrameEvent.Open event) {
if (settingsFrames.containsKey(event.getFrame().module.getName())) return;
ConfigManager.setFramePosition(event.getFrame());
}
@SubscribeEvent
public void onCloseSettingsFrame(SettingsFrameEvent.Close event) {
settingsFrames.remove(event.getFrame().module.getName());
settingsFrames.remove(event.getFrame().getModule().getName());
ConfigManager.save();
}
@SubscribeEvent
public void onMoveSettingsFrame(SettingsFrameEvent.Move event) {
settingsFrames.replace(event.getFrame().module.getName(), new int[]{event.getFrame().x, event.getFrame().y});
settingsFrames.replace(event.getFrame().getModule().getName(), new int[]{event.getFrame().getX(), event.getFrame().getY()});
ConfigManager.save();
}
@SubscribeEvent
public void onExtendModuleFrame(ModuleFrameEvent.Extend event) {
extendableFrames.put("M", new FrameData(
ClickGUI.INSTANCE.getModulesFrame().x,
ClickGUI.INSTANCE.getModulesFrame().y,
ClickGUI.INSTANCE.getModulesFrame().getX(),
ClickGUI.INSTANCE.getModulesFrame().getY(),
ClickGUI.INSTANCE.getModulesFrame().extended));
}
@SubscribeEvent
public void onMoveModuleFrame(ModuleFrameEvent.Move event) {
extendableFrames.replace("M", new FrameData(
ClickGUI.INSTANCE.getModulesFrame().x,
ClickGUI.INSTANCE.getModulesFrame().y,
ClickGUI.INSTANCE.getModulesFrame().getX(),
ClickGUI.INSTANCE.getModulesFrame().getY(),
ClickGUI.INSTANCE.getModulesFrame().extended));
}
@SubscribeEvent
public void onExtendGUISettingsFrame(GUISettingsFrameEvent.Extend event) {
extendableFrames.put("S", new FrameData(
ClickGUI.INSTANCE.getGuiSettingsFrame().x,
ClickGUI.INSTANCE.getGuiSettingsFrame().y,
ClickGUI.INSTANCE.getGuiSettingsFrame().getX(),
ClickGUI.INSTANCE.getGuiSettingsFrame().getY(),
ClickGUI.INSTANCE.getGuiSettingsFrame().extended));
}
@SubscribeEvent
public void onMoveGUISettingsFrame(GUISettingsFrameEvent.Move event) {
extendableFrames.replace("S", new FrameData(
ClickGUI.INSTANCE.getGuiSettingsFrame().x,
ClickGUI.INSTANCE.getGuiSettingsFrame().y,
ClickGUI.INSTANCE.getGuiSettingsFrame().getX(),
ClickGUI.INSTANCE.getGuiSettingsFrame().getY(),
ClickGUI.INSTANCE.getGuiSettingsFrame().extended));
}
public record FrameData(int x, int y, boolean extended) {}
public record FrameData(int x, int y, boolean extended) implements Serializable {
@Serial private static final long serialVersionUID = 1L;
}
}
@@ -1,29 +1,30 @@
package me.retucio.camtweaks.config;
package me.retucio.sputnik.config;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import me.retucio.camtweaks.CameraTweaks;
import me.retucio.camtweaks.module.Module;
import me.retucio.camtweaks.module.ModuleManager;
import me.retucio.camtweaks.module.settings.*;
import me.retucio.camtweaks.ui.frames.ModuleFrame;
import me.retucio.camtweaks.ui.screen.ClickGUI;
import me.retucio.camtweaks.ui.frames.ClientSettingsFrame;
import me.retucio.camtweaks.ui.frames.SettingsFrame;
import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.setting.*;
import me.retucio.sputnik.module.setting.settings.*;
import me.retucio.sputnik.ui.widgets.Frame;
import me.retucio.sputnik.ui.widgets.frames.ModuleFrame;
import me.retucio.sputnik.ui.screen.ClickGUI;
import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame;
import me.retucio.sputnik.ui.widgets.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;
import java.util.function.Consumer;
// se ocupa de guardar, cargar y aplicar ajustes
// pues no me ha dado dolores de cabeza el coso este con los NPE de los cojones...
public class ConfigManager {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private static final File CONFIG_FILE = new File("camera_tweaks.json");
private static final File CONFIG_FILE = new File("sputnik.dat");
private static final File LEGACY_JSON_FILE = new File("sputnik.json");
private static boolean loaded = false;
private static ClientConfig config = null;
@@ -33,33 +34,47 @@ public class ConfigManager {
// guardar configuraciones
public static void save() {
if (!loaded) return;
ensureConfig();
try (FileWriter writer = new FileWriter(CONFIG_FILE)) {
GSON.toJson(config, writer);
CameraTweaks.LOGGER.info("ajustes guardados");
try {
BinarySerializer.writeConfig(config, CONFIG_FILE);
Sputnik.LOGGER.info("ajustes guardados");
} catch (IOException e) {
CameraTweaks.LOGGER.error("error al guardar ajustes", e);
Sputnik.LOGGER.error("error al guardar ajustes", e);
}
}
// cargar configuraciones
public static void load() {
CameraTweaks.LOGGER.info("cargando ajustes...");
Sputnik.LOGGER.info("cargando ajustes...");
if (!CONFIG_FILE.exists()) {
ensureConfig();
save();
return;
if (CONFIG_FILE.exists()) {
try {
config = BinarySerializer.readConfig(CONFIG_FILE);
Sputnik.LOGGER.info("ajustes cargados");
return;
} catch (IOException e) {
Sputnik.LOGGER.error("error cargando ajustes, intentando json", e);
}
}
try (FileReader reader = new FileReader(CONFIG_FILE)) {
config = GSON.fromJson(reader, ClientConfig.class);
CameraTweaks.LOGGER.info("ajustes cargados");
} catch (IOException e) {
CameraTweaks.LOGGER.error("no se pudieron cargar los ajustes, usando ajustes por defecto", e);
ensureConfig();
// Fallback to legacy JSON
if (LEGACY_JSON_FILE.exists()) {
try (FileReader reader = new FileReader(LEGACY_JSON_FILE)) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
config = gson.fromJson(reader, ClientConfig.class);
Sputnik.LOGGER.info("ajustes json cargados (migración)");
save();
return;
} catch (IOException e) {
Sputnik.LOGGER.error("error cargando json, usando defaults", e);
}
}
// crear nuevo config
ensureConfig();
save();
}
// aplicar configuraciones cargadas
@@ -74,7 +89,7 @@ public class ConfigManager {
applyExtendableFrames();
loaded = true;
CameraTweaks.LOGGER.info("ajustes aplicados");
Sputnik.LOGGER.info("ajustes aplicados");
}
// obtener configuración actual
@@ -100,7 +115,10 @@ public class ConfigManager {
public static void setFramePosition(SettingsFrame frame) {
ensureConfig();
config.settingsFrames.put(frame.module.getName(), new int[] {frame.x, frame.y});
if (!config.settingsFrames.containsKey(frame.getModule().getName()))
config.settingsFrames.put(frame.getModule().getName(), new int[] {frame.getX(), frame.getY()});
else
config.settingsFrames.replace(frame.getModule().getName(), new int[] {frame.getX(), frame.getY()});
save();
}
@@ -148,7 +166,7 @@ public class ConfigManager {
case ListSetting listSetting -> applyListSetting(listSetting, value);
case ColorSetting colorSetting -> applyColorSetting(colorSetting, value);
case OptionSetting optionSetting -> applyOptionSetting(optionSetting, value);
default -> CameraTweaks.LOGGER.warn("watafac queseso: {}", setting.getClass().getSimpleName());
default -> Sputnik.LOGGER.warn("watafac queseso: {}", setting.getClass().getSimpleName());
}
}
@@ -158,22 +176,29 @@ public class ConfigManager {
module.setEnabled(config.moduleStates.get(module.getName()));
}
});
CameraTweaks.LOGGER.info("estados de módulos aplicados");
Sputnik.LOGGER.info("estados de módulos aplicados");
}
private static void applyModuleSettings() {
ModuleManager.INSTANCE.getModules().forEach(module -> {
module.getSettings().forEach(setting -> applySetting(module, setting));
});
CameraTweaks.LOGGER.info("ajustes de módulos aplicados");
Sputnik.LOGGER.info("ajustes de módulos aplicados");
}
private static void applySettingsFrames() {
config.settingsFrames.forEach((moduleName, position) -> {
Module module = ModuleManager.INSTANCE.getModuleByName(moduleName);
if (module == null) {
Sputnik.LOGGER.warn("\"null\" como módulo (\"{}\")", moduleName);
return;
}
ClickGUI.INSTANCE.openSettingsFrame(module, position[0], position[1]);
});
CameraTweaks.LOGGER.info("estados de marcos de ajustes aplicados");
Sputnik.LOGGER.info("estados de marcos de ajustes aplicados");
}
private static void applySearchBarPosition() {
@@ -181,7 +206,7 @@ public class ConfigManager {
ClickGUI.INSTANCE.getSearchBar().setX(config.searchBarPosition[0]);
ClickGUI.INSTANCE.getSearchBar().setY(config.searchBarPosition[1]);
}
CameraTweaks.LOGGER.info("posición de la barra de búsqueda aplicada");
Sputnik.LOGGER.info("posición de la barra de búsqueda aplicada");
}
private static void applyGuiSettings() {
@@ -189,34 +214,36 @@ public class ConfigManager {
ClientSettingsFrame.guiSettings.getSettings().forEach(setting -> {
applySetting(ClientSettingsFrame.guiSettings, setting);
});
CameraTweaks.LOGGER.info("ajustes del cliente aplicados");
Sputnik.LOGGER.info("ajustes del cliente aplicados");
}
private static void applyExtendableFrames() {
applyExtendableFrame(ClickGUI.INSTANCE.getModulesFrame());
applyExtendableFrame(ClickGUI.INSTANCE.getGuiSettingsFrame());
CameraTweaks.LOGGER.info("posiciones de marcos extendibles aplicadasa");
Sputnik.LOGGER.info("posiciones de marcos extendibles aplicadas");
ClickGUI.INSTANCE.refreshListButtons();
}
private static void applyExtendableFrame(ModuleFrame frame) {
ClientConfig.FrameData frameData = config.extendableFrames.get("M");
private static void applyExtendableFrame(Frame<?> frame) {
ClientConfig.FrameData frameData = null;
if (frame instanceof ModuleFrame)
frameData = config.extendableFrames.get("M");
if (frame instanceof ClientSettingsFrame)
frameData = config.extendableFrames.get("S");
if (frameData != null) {
frame.x = frameData.x();
frame.y = frameData.y();
frame.extended = frameData.extended();
frame.setX(frameData.x());
frame.setY(frameData.y());
if (frame instanceof ModuleFrame mFrame)
mFrame.extended = frameData.extended();
if (frame instanceof ClientSettingsFrame sFrame)
sFrame.extended = frameData.extended();
}
}
private static void applyExtendableFrame(ClientSettingsFrame frame) {
ClientConfig.FrameData frameData = config.extendableFrames.get("S");
if (frameData != null) {
frame.x = frameData.x();
frame.y = frameData.y();
frame.extended = frameData.extended();
}
}
// ajustes de módulos
@@ -276,8 +303,14 @@ public class ConfigManager {
Number b = (Number) map.get("b");
Number a = (Number) map.get("a");
if (r != null && g != null && b != null && a != null)
setting.setRGB(r.intValue(), g.intValue(), b.intValue(), a.intValue());
if (r != null && g != null && b != null && a != null) {
setting.setRGB(
r.intValue(),
g.intValue(),
b.intValue(),
a.intValue()
);
}
applyOptionalProperty(map, "rb", Boolean.class, setting::setRainbow);
applyOptionalProperty(map, "rs", Number.class, val -> setting.setRainbowSpeed(val.intValue()));
@@ -286,13 +319,12 @@ public class ConfigManager {
}
private static <T> void applyOptionSetting(OptionSetting<T> setting, Object value) {
if (value instanceof Double) {
int index = ((Double) value).intValue();
setting.setValue(setting.getOption(index));
if (value instanceof String name) {
setting.setValueByName(name);
}
}
private static <T> void applyOptionalProperty(Map<?, ?> map, String key, Class<T> type, java.util.function.Consumer<T> setter) {
private static <T> void applyOptionalProperty(Map<?, ?> map, String key, Class<T> type, Consumer<T> setter) {
Object value = map.get(key);
if (type.isInstance(value)) {
setter.accept(type.cast(value));
@@ -303,19 +335,18 @@ public class ConfigManager {
// ------------------ MÉTODOS DE AYUDA ------------------
private static boolean shouldApply() {
return CameraTweaks.mc != null && ModuleManager.INSTANCE != null && config != null;
return Sputnik.mc != null && ModuleManager.INSTANCE != null && config != null;
}
private static void ensureConfig() {
if (config == null) config = new ClientConfig();
}
private static String getSettingKey(Setting setting) {
return setting.getModule().getName() + ":" + setting.getName();
return setting.getSg().getModule().getName() + ":" + setting.getName();
}
public static boolean hasLoaded() {
return loaded;
}
}
}
@@ -1,4 +1,4 @@
package me.retucio.camtweaks.event;
package me.retucio.sputnik.event;
// evento base, cancelable (usado en mixins)
public class Event {
@@ -1,4 +1,4 @@
package me.retucio.camtweaks.event;
package me.retucio.sputnik.event;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -1,4 +1,4 @@
package me.retucio.camtweaks.event;
package me.retucio.sputnik.event;
public enum Stage {
PRE, // antes de que haya sucedido
@@ -1,4 +1,4 @@
package me.retucio.camtweaks.event;
package me.retucio.sputnik.event;
import java.lang.annotation.*;
@@ -1,11 +1,11 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.entity.Entity;
/**
* @see me.retucio.camtweaks.mixin.ClientWorldMixin#onAddEntity
* @see me.retucio.sputnik.mixin.ClientWorldMixin#onAddEntity
*/
public class AddEntityEvent extends Event {
@@ -1,11 +1,11 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.entity.Entity;
/**
* @see me.retucio.camtweaks.mixin.ClientPlayerInteractionManagerMixin#onAttackEntity
* @see me.retucio.sputnik.mixin.ClientPlayerInteractionManagerMixin#onAttackEntity
*/
public class AttackEntityEvent extends Event {
@@ -1,11 +1,11 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.util.math.BlockPos;
/**
* @see me.retucio.camtweaks.mixin.ClientPlayerInteractionManagerMixin#onBlockBreak
* @see me.retucio.sputnik.mixin.ClientPlayerInteractionManagerMixin#onBlockBreak
*/
public class BreakBlockEvent extends Event {
@@ -1,12 +1,12 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
/**
* @see me.retucio.camtweaks.mixin.EntityMixin#onRotation
* @see me.retucio.camtweaks.mixin.EntityMixin#onChangeYaw
* @see me.retucio.camtweaks.mixin.EntityMixin#onChangePitch
* @see me.retucio.sputnik.mixin.EntityMixin#onRotation
* @see me.retucio.sputnik.mixin.EntityMixin#onChangeYaw
* @see me.retucio.sputnik.mixin.EntityMixin#onChangePitch
*/
public class ChangeRotationEvent extends Event {
@@ -0,0 +1,9 @@
package me.retucio.sputnik.event.events;
import me.retucio.sputnik.event.Event;
/**
* @see me.retucio.sputnik.mixin.ChunkOcclusionDataBuilderMixin#onChunkOcclusion
*/
public class ChunkOcclusionEvent extends Event {}
@@ -1,10 +1,11 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.sputnik.module.modules.misc.ChatPlus;
import net.minecraft.text.ClickEvent;
/** este evento es solo para asegurarse de que comandos del mod se puedan ejecutar solo desde el lado del cliente
* @see me.retucio.camtweaks.module.modules.ChatPlus#getSendButton
* @see ChatPlus#getSendButton
*/
public class ClientClickEvent implements ClickEvent {
@@ -0,0 +1,20 @@
package me.retucio.sputnik.event.events;
import me.retucio.sputnik.event.Event;
public class ClipAtLedgeEvent extends Event {
private boolean clipping;
public ClipAtLedgeEvent(boolean clipping) {
this.clipping = clipping;
}
public boolean isClipping() {
return clipping;
}
public void setClipping(boolean clipping) {
this.clipping = clipping;
}
}
@@ -1,11 +1,11 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.item.ItemStack;
/**
* @see me.retucio.camtweaks.mixin.ItemStackMixin#onDamage
* @see me.retucio.sputnik.mixin.ItemStackMixin#onDamage
*/
public class DamageItemEvent extends Event {
@@ -1,12 +1,12 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.network.DisconnectionInfo;
/**
* @see me.retucio.camtweaks.mixin.ClientConnectionMixin#onDisconnect
* @see me.retucio.sputnik.mixin.ClientConnectionMixin#onDisconnect
*/
public class DisconnectEvent extends Event {
@@ -1,10 +1,10 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
/**
* @see me.retucio.camtweaks.mixin.GameRendererMixin#modifyFov
* @see me.retucio.sputnik.mixin.GameRendererMixin#modifyFov
*/
public class GetFOVEvent extends Event {
@@ -1,12 +1,12 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.entity.Entity;
import net.minecraft.util.Hand;
/**
* @see me.retucio.camtweaks.mixin.ClientPlayerInteractionManagerMixin#onEntityInteract
* @see me.retucio.sputnik.mixin.ClientPlayerInteractionManagerMixin#onEntityInteract
*/
public class InteractEntityEvent extends Event {
@@ -1,11 +1,11 @@
package me.retucio.camtweaks.event;
package me.retucio.sputnik.event.events;
import me.retucio.sputnik.event.Event;
import net.minecraft.client.world.ClientWorld;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onJoinWorld
* @see me.retucio.sputnik.mixin.MinecraftClientMixin#onJoinWorld
*/
public class JoinWorldEvent extends Event {
@@ -1,10 +1,10 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
/**
* @see me.retucio.camtweaks.mixin.KeyboardMixin#onKeyPress
* @see me.retucio.sputnik.mixin.KeyboardMixin#onKeyPress
*/
public class KeyEvent extends Event {
@@ -1,10 +1,10 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
/**
* @see me.retucio.camtweaks.mixin.MouseMixin#onMouseButton
* @see me.retucio.sputnik.mixin.MouseMixin#onMouseButton
*/
public class MouseClickEvent extends Event {
@@ -1,10 +1,10 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
/**
* @see me.retucio.camtweaks.mixin.MouseMixin#onMouseScroll
* @see me.retucio.sputnik.mixin.MouseMixin#onMouseScroll
*/
public class MouseScrollEvent extends Event {
@@ -1,11 +1,11 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.client.gui.screen.Screen;
/**
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onOpenScreen
* @see me.retucio.sputnik.mixin.MinecraftClientMixin#onOpenScreen
*/
public class OpenScreenEvent extends Event {
@@ -1,16 +1,14 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import io.netty.channel.ChannelFutureListener;
import me.retucio.camtweaks.event.Event;
import me.retucio.camtweaks.event.Stage;
import me.retucio.sputnik.event.Event;
import me.retucio.sputnik.event.Stage;
import net.minecraft.network.packet.Packet;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
* @see me.retucio.camtweaks.mixin.ClientConnectionMixin#onSendPacketPre
* @see me.retucio.camtweaks.mixin.ClientConnectionMixin#onSendPacketPost
* @see me.retucio.camtweaks.mixin.ClientConnectionMixin#onReceivePacket
* @see me.retucio.sputnik.mixin.ClientConnectionMixin#onSendPacketPre
* @see me.retucio.sputnik.mixin.ClientConnectionMixin#onSendPacketPost
* @see me.retucio.sputnik.mixin.ClientConnectionMixin#onReceivePacket
*/
public class PacketEvent {
@@ -1,11 +1,11 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.client.option.Perspective;
/**
* @see me.retucio.camtweaks.mixin.GameOptionsMixin#changePerspective
* @see me.retucio.sputnik.mixin.GameOptionsMixin#changePerspective
*/
public class PerspectiveChangeEvent extends Event {
@@ -1,12 +1,12 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
/**
* @see me.retucio.camtweaks.mixin.ClientPlayerInteractionManagerMixin#onBlockPlace
* @see me.retucio.sputnik.mixin.ClientPlayerInteractionManagerMixin#onBlockPlace
*/
public class PlaceBlockEvent extends Event {
@@ -1,11 +1,11 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.client.gui.hud.MessageIndicator;
import net.minecraft.text.Text;
/**
* @see me.retucio.camtweaks.mixin.ChatHudMixin#onAddMessage
* @see me.retucio.sputnik.mixin.ChatHudMixin#onAddMessage
*/
public class ReceiveMessageEvent extends Event {
@@ -1,11 +1,11 @@
package me.retucio.camtweaks.event.events;
package me.retucio.sputnik.event.events;
import me.retucio.camtweaks.event.Event;
import me.retucio.sputnik.event.Event;
import net.minecraft.entity.Entity;
/**
* @see me.retucio.camtweaks.mixin.ClientWorldMixin#onRemoveEntity
* @see me.retucio.sputnik.mixin.ClientWorldMixin#onRemoveEntity
*/
public class RemoveEntityEvent extends Event {
Loaded 100 of 425 files, more files were not shown because too many files have changed in this diff. Show more