Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
629d03ff92 | ||
|
|
c1a03f3ddb |
No files matched your search
@@ -0,0 +1,82 @@
|
|||||||
|
<p align="center">
|
||||||
|
<a href="README.md"><img src="https://img.shields.io/badge/lang-Español-yellow.svg" alt="español"></a>
|
||||||
|
<a href="README.en.md"><img src="https://img.shields.io/badge/lang-English-blue.svg" alt="english"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
# jenny's mod 2 (100% real)
|
||||||
|
|
||||||
|
> Minecraft Fabric 26.2 mod that adds some "QOL" features, mostly related to the camera.
|
||||||
|
|
||||||
|
## installation
|
||||||
|
|
||||||
|
### for normal people:
|
||||||
|
1. go to [releases](https://codeberg.org/retucio/sputnik/releases)
|
||||||
|
2. choose the most recent version
|
||||||
|
3. download the .jar file
|
||||||
|
4. move it to your mods dir (prolly `%appdata%/.minecraft/mods`)
|
||||||
|
|
||||||
|
|
||||||
|
make sure to have a Minecraft and Fabric version compatible with the mod (MC `26.2`; Fabric `0.19.3`)
|
||||||
|
|
||||||
|
issues could arise when using it with other mods, especially other clients, since they could conflict
|
||||||
|
|
||||||
|
### for nerds
|
||||||
|
1. clone the repo (`git clone https://codeberg.org/retucio/sputnik`)
|
||||||
|
2. enter the repo dir (`cd sputnik`)
|
||||||
|
3. `gradlew build` for Windows (ew) or `chmod +x gradlew` + `./gradlew build` for Unix-likes (Linux & Mac)
|
||||||
|
4. the built .jar will be found in `/build/libs/sputnik-X.X.jar`
|
||||||
|
|
||||||
|
## usage
|
||||||
|
|
||||||
|
`rshift` by default to open the GUI
|
||||||
|
|
||||||
|
`insert` by default to open the HUD editor
|
||||||
|
|
||||||
|
`$` as prefix for commands (autocompleted)
|
||||||
|
|
||||||
|
some modules have keys assigned by default, assign them `ESC` to unbind them.
|
||||||
|
|
||||||
|
## ui
|
||||||
|
|
||||||
|
- left click to toggle modules
|
||||||
|
- right click to open its settings
|
||||||
|
- left click + drag to move a panel
|
||||||
|
- right click on a panel's header to expand/contract it, or to close it
|
||||||
|
- left click over settings to change them
|
||||||
|
- shift + right click on a setting to reset it to its default value
|
||||||
|
- place the mouse cursor over a module/setting to read its description
|
||||||
|
|
||||||
|
## screenshots
|
||||||
|
|
||||||
|
<img src="screenshots/automine.png" alt="auto mine">
|
||||||
|
<img src="screenshots/blockesp.png" alt="block ESP + light overlay">
|
||||||
|
<img src="screenshots/camtweaks.png" alt="perspective plus">
|
||||||
|
<img src="screenshots/chatplus.png" alt="chatplus + nametags + screenshots plus">
|
||||||
|
<img src="screenshots/clickgui.png" alt="click GUI">
|
||||||
|
<img src="screenshots/freecam.png" alt="freecam + tracers">
|
||||||
|
<img src="screenshots/hudeditor.png" alt="HUD editor">
|
||||||
|
<img src="screenshots/itemphysics.png" alt="item physics">
|
||||||
|
<img src="screenshots/lsd.png" alt="lsd module">
|
||||||
|
<img src="screenshots/macros.png" alt="macros tab">
|
||||||
|
<img src="screenshots/trajectories.png" alt="projectile trajectories">
|
||||||
|
|
||||||
|
|
||||||
|
## contribution
|
||||||
|
|
||||||
|
yes please (PRs are welcome)
|
||||||
|
|
||||||
|
## license
|
||||||
|
|
||||||
|
[CC0 license](LICENSE)
|
||||||
|
|
||||||
|
## disclaimer
|
||||||
|
|
||||||
|
i don't give a single fuck what happens to you when using this mod on servers where its features are bannable and such.
|
||||||
|
|
||||||
|
## deps
|
||||||
|
|
||||||
|
- [fabric api](https://modrinth.com/mod/fabric-api/)
|
||||||
|
|
||||||
|
## notes
|
||||||
|
|
||||||
|
this mod IS BUGGY. VERY BUGGY, i know. i started this project when i was 14 and the codebase is such a mess i refuse to fix it. i might rewrite it in a future, though.
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
|
<p align="center">
|
||||||
|
<a href="README.md"><img src="https://img.shields.io/badge/lang-Español-yellow.svg" alt="español"></a>
|
||||||
|
<a href="README.en.md"><img src="https://img.shields.io/badge/lang-English-blue.svg" alt="english"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
# jenny's mod 2 100% real
|
# jenny's mod 2 100% real
|
||||||
|
|
||||||
mod para Minecraft Fabric 26.2 que añade algunas cosas QOL, mayormente relacionadas a la cámara.
|
> mod para Minecraft Fabric 26.2 que añade algunas cosas "QOL", mayormente relacionadas a la cámara.
|
||||||
|
|
||||||
## instalación
|
## instalación
|
||||||
|
|
||||||
@@ -14,10 +19,10 @@ asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC
|
|||||||
es posible que haya problemas al usarlo junto a otros mods, especialmente junto a otros clientes, pues pueden conflictar entre ellos.
|
es posible que haya problemas al usarlo junto a otros mods, especialmente junto a otros clientes, pues pueden conflictar entre ellos.
|
||||||
|
|
||||||
### para frikis de 200 de iq
|
### para frikis de 200 de iq
|
||||||
1. clona el respositorio (`git clone https://github.com/retuci0/sputnik`)
|
1. clona el respositorio (`git clone https://codeberg.org/retucio/sputnik`)
|
||||||
2. entra al directorio del repositorio (`cd sputnik`)
|
2. entra al directorio del repositorio (`cd sputnik`)
|
||||||
3. `gradlew build` para Windows o `chmod +x gradlew` + `./gradlew build` para Linux (Mac es Linux)
|
3. `gradlew build` para Windows (ew) o `chmod +x gradlew` + `./gradlew build` para Unix-likes (Linux & Mac)
|
||||||
4. el resultado estará en `/build/libs/sputnik-X.X.jar` (el que no lleva "sources" en el nombre)
|
4. el resultado estará en `/build/libs/sputnik-X.X.jar`
|
||||||
|
|
||||||
## uso
|
## uso
|
||||||
|
|
||||||
@@ -33,28 +38,25 @@ algunos módulos tienen teclas asignadas por defecto, asígnales `ESC` para desa
|
|||||||
|
|
||||||
- clic izquierdo para activar / desactivar módulos
|
- clic izquierdo para activar / desactivar módulos
|
||||||
- clic derecho para abrir sus ajustes
|
- clic derecho para abrir sus ajustes
|
||||||
- clic izquierdo + arrastrar para mover marcos
|
- clic izquierdo + arrastrar para mover paneles
|
||||||
- clic derecho en la cabeza del marco para expandirlo / contraerlo o para cerrarlo
|
- clic derecho en la cabeza del marco para expandirlo / contraerlo o para cerrarlo
|
||||||
- clic izquierdo sobre ajustes para modificarlos
|
- clic izquierdo sobre ajustes para modificarlos
|
||||||
- shift + clic derecho sobre ajustes para restablecerlos
|
- shift + clic derecho sobre ajustes para restablecerlos
|
||||||
- posiciona el puntero del ratón sobre un módulo o ajuste para leer su descripción
|
- posiciona el puntero del ratón sobre un módulo o ajuste para leer su descripción
|
||||||
|
|
||||||
### protips
|
|
||||||
- shift mientras pasas el puntero por encima de un ajuste de modos para ver los modos disponibles
|
|
||||||
- clic derecho para ciclar hacia atrás en ajustes de modo
|
|
||||||
- usa la rueda del ratón para mover la interfaz verticalmente
|
|
||||||
- shift + rueda del ratón para mover todos los marcos a un rango visible en la pantalla
|
|
||||||
|
|
||||||
## capturas
|
## capturas
|
||||||
|
|
||||||
<img src="screenshots/ui.png" alt="interfaz">
|
<img src="screenshots/automine.png" alt="auto minado">
|
||||||
<img src="screenshots/nametags.png" alt="nametags mostrando daño de un tridente">
|
<img src="screenshots/blockesp.png" alt="resaltado de bloques + superposición de luz">
|
||||||
<img src="screenshots/chatplus.png" alt="chatplus y capturas en uso">
|
<img src="screenshots/camtweaks.png" alt="perspectiva plus">
|
||||||
<img src="screenshots/crits.png" alt="críticos">
|
<img src="screenshots/chatplus.png" alt="chatplus + nametags + capturas">
|
||||||
<img src="screenshots/fullbright.png" alt="fullbright en modo gamma cambiando el color de los shaders">
|
<img src="screenshots/clickgui.png" alt="interfaz">
|
||||||
<img src="screenshots/hud.png" alt="HUD">
|
<img src="screenshots/freecam.png" alt="cámara libre + trazos">
|
||||||
<img src="screenshots/hudeditor.png" alt="editor de HUD">
|
<img src="screenshots/hudeditor.png" alt="editor de HUD">
|
||||||
<img src="screenshots/colorpicker.png" alt="selector de colores">
|
<img src="screenshots/itemphysics.png" alt="físicas de items">
|
||||||
|
<img src="screenshots/lsd.png" alt="LSD">
|
||||||
|
<img src="screenshots/macros.png" alt="macros">
|
||||||
|
<img src="screenshots/trajectories.png" alt="trayectorias">
|
||||||
|
|
||||||
## contribuciones
|
## contribuciones
|
||||||
|
|
||||||
@@ -62,26 +64,16 @@ sí por favor
|
|||||||
|
|
||||||
## licencia
|
## licencia
|
||||||
|
|
||||||
no sé, haz lo que quieras con esto, es puta basura xd
|
[licencia CC0](LICENSE)
|
||||||
|
|
||||||
aunque estaría guay que acreditases
|
|
||||||
|
|
||||||
pero bueno
|
|
||||||
|
|
||||||
## descargo de responsabilidad
|
## descargo de responsabilidad
|
||||||
|
|
||||||
me importa una puta mierda lo que pase al usar este mod en servers donde es baneable y así.
|
me importa una puta mierda lo que pase al usar este mod en servers donde es baneable y así.
|
||||||
|
|
||||||
## mods recomendados
|
## dependencias
|
||||||
|
|
||||||
> mods que recomiendo usar junto a este:
|
- [fabric api](https://modrinth.com/mod/fabric-api/)
|
||||||
|
|
||||||
- [fabric api (necesario)](https://modrinth.com/mod/fabric-api/): necesario para el mod
|
## notas
|
||||||
- [sodium](https://modrinth.com/mod/sodium): mejora el rendimiento general del juego
|
|
||||||
- [viafabricplus](https://modrinth.com/mod/viafabricplus): te permite conectarte a servidores que tengan una versión distinta a la de tu cliente
|
este mod tiene MUCHOS bugs. empecé este proyecto cuando tenía 14 años y no sabía una mierda de programar. el código es un puto desastre y me niego a arreglarlo. puede que en un futuro reescriba el mod o algo. no sé.
|
||||||
- [xaero's world map](https://modrinth.com/mod/xaeros-world-map/) y [xaero's minimap](https://modrinth.com/mod/xaeros-minimap/): mapa chulo
|
|
||||||
- [mod menu](https://modrinth.com/mod/modmenu): lista de los mods instalados, y sus ajustes
|
|
||||||
- [iris](https://modrinth.com/mod/iris): shaders
|
|
||||||
- [lambdynamiclights](https://modrinth.com/mod/lambdynamiclights): iluminación dinámica
|
|
||||||
- [appleskin](https://modrinth.com/mod/appleskin/): información relacionada con la comida
|
|
||||||
- [baritone (desactualizado)](https://github.com/cabaletta/baritone): google maps para juego de cubos
|
|
||||||
@@ -1,22 +1,16 @@
|
|||||||
# v6.3
|
# v6.5
|
||||||
|
|
||||||
## novedades
|
## novedades
|
||||||
|
|
||||||
- actualizado a Gradle 9.7.1
|
|
||||||
|
|
||||||
### adiciones
|
### adiciones
|
||||||
|
|
||||||
#### módulos nuevos:
|
|
||||||
|
|
||||||
- autominado: mina automáticamente los bloques seleccionados, con distintos modos de selección
|
|
||||||
- estiloso: haz truquitos con el ítem que tienes en la mano
|
|
||||||
|
|
||||||
### arreglos / mejoras
|
### arreglos / mejoras
|
||||||
|
|
||||||
- mejoras varias a `puto gordo`
|
- opción para cancelar la animación original para `progreso de minado`
|
||||||
- ahora `trazos` con `uno mismo` solo te apunta en cámara libre
|
- ahora los amigos se muestran en una pestaña separada en la interfaz
|
||||||
- nuevo ajuste de distancia máxima de renderizado para `nametags`
|
|
||||||
|
|
||||||
## problemas reconocidos
|
## problemas reconocidos
|
||||||
|
|
||||||
- lo de siempre.
|
- `reponer` no funciona
|
||||||
|
- `copiar` tras sacar una captura con `capturas` no funciona correctamente
|
||||||
|
- \+ lo de siempre.
|
||||||
@@ -10,6 +10,6 @@ discord_rpc_version=1.0.3
|
|||||||
neutrino_version=1.1.0
|
neutrino_version=1.1.0
|
||||||
jdk_version=25
|
jdk_version=25
|
||||||
|
|
||||||
mod_version=6.3
|
mod_version=6.5
|
||||||
maven_group=me.retucio
|
maven_group=me.retucio
|
||||||
archives_base_name=sputnik
|
archives_base_name=sputnik
|
||||||
|
After Width: | Height: | Size: 2.2 MiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 3.4 MiB |
|
Before Width: | Height: | Size: 864 KiB After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 796 KiB |
|
Before Width: | Height: | Size: 915 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 566 KiB |
|
Before Width: | Height: | Size: 469 KiB |
|
Before Width: | Height: | Size: 243 KiB After Width: | Height: | Size: 700 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 506 KiB |
|
After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 691 KiB |
@@ -14,7 +14,7 @@ import java.util.Map;
|
|||||||
public class BinarySerializer {
|
public class BinarySerializer {
|
||||||
|
|
||||||
private static final int MAGIC_NUMBER = 0x53505554; // "SPUT"
|
private static final int MAGIC_NUMBER = 0x53505554; // "SPUT"
|
||||||
private static final int VERSION = 3;
|
private static final int VERSION = 4;
|
||||||
private static final int MIN_VERSION = 2;
|
private static final int MIN_VERSION = 2;
|
||||||
|
|
||||||
private static final byte TYPE_NULL = 0;
|
private static final byte TYPE_NULL = 0;
|
||||||
@@ -72,7 +72,7 @@ public class BinarySerializer {
|
|||||||
writeStringIntArrayMap(out, config.hudPositions);
|
writeStringIntArrayMap(out, config.hudPositions);
|
||||||
writeStringBooleanMap(out, config.hudVisibilities);
|
writeStringBooleanMap(out, config.hudVisibilities);
|
||||||
writeStringStringMap(out, config.hudImagePaths);
|
writeStringStringMap(out, config.hudImagePaths);
|
||||||
writeStringStringMap(out, config.friends);
|
writeFriendsMap(out, config.friends);
|
||||||
writeMacros(out, config.macros);
|
writeMacros(out, config.macros);
|
||||||
writeString(out, config.currentProfile);
|
writeString(out, config.currentProfile);
|
||||||
|
|
||||||
@@ -123,7 +123,9 @@ public class BinarySerializer {
|
|||||||
Map<String, int[]> hudPositions = readStringIntArrayMap(in);
|
Map<String, int[]> hudPositions = readStringIntArrayMap(in);
|
||||||
Map<String, Boolean> hudVisibilities = readStringBooleanMap(in);
|
Map<String, Boolean> hudVisibilities = readStringBooleanMap(in);
|
||||||
Map<String, String> hudImagePaths = readStringStringMap(in);
|
Map<String, String> hudImagePaths = readStringStringMap(in);
|
||||||
Map<String, String> friends = readStringStringMap(in);
|
Map<String, ClientConfig.FriendData> friends = version >= 4
|
||||||
|
? readFriendsMap(in)
|
||||||
|
: migrateFriendsMap(readStringStringMap(in));
|
||||||
|
|
||||||
List<ClientConfig.MacroData> macros = version >= 3 ? readMacros(in) : new ArrayList<>();
|
List<ClientConfig.MacroData> macros = version >= 3 ? readMacros(in) : new ArrayList<>();
|
||||||
String currentProfile = version >= 3 ? readString(in) : "";
|
String currentProfile = version >= 3 ? readString(in) : "";
|
||||||
@@ -422,6 +424,45 @@ public class BinarySerializer {
|
|||||||
return macros;
|
return macros;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void writeFriendsMap(DataOutputStream out, Map<String, ClientConfig.FriendData> map)
|
||||||
|
throws IOException {
|
||||||
|
if (map == null) {
|
||||||
|
out.writeInt(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
out.writeInt(map.size());
|
||||||
|
for (Map.Entry<String, ClientConfig.FriendData> entry : map.entrySet()) {
|
||||||
|
writeString(out, entry.getKey());
|
||||||
|
ClientConfig.FriendData data = entry.getValue();
|
||||||
|
writeString(out, data.name());
|
||||||
|
writeString(out, data.nick());
|
||||||
|
out.writeLong(data.befriendedAt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, ClientConfig.FriendData> readFriendsMap(DataInputStream in)
|
||||||
|
throws IOException {
|
||||||
|
int size = in.readInt();
|
||||||
|
Map<String, ClientConfig.FriendData> map = new HashMap<>(size);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
String uuid = readString(in);
|
||||||
|
String name = readString(in);
|
||||||
|
String nick = readString(in);
|
||||||
|
long befriendedAt = in.readLong();
|
||||||
|
map.put(uuid, new ClientConfig.FriendData(name, nick, befriendedAt));
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, ClientConfig.FriendData> migrateFriendsMap(Map<String, String> legacy) {
|
||||||
|
Map<String, ClientConfig.FriendData> map = new HashMap<>(legacy.size());
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
for (Map.Entry<String, String> entry : legacy.entrySet()) {
|
||||||
|
map.put(entry.getKey(), new ClientConfig.FriendData(entry.getValue(), entry.getValue(), now));
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
private static void writeString(DataOutputStream out, String str) throws IOException {
|
private static void writeString(DataOutputStream out, String str) throws IOException {
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
out.writeInt(-1);
|
out.writeInt(-1);
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import com.github.retucio.neutrino.EventListener;
|
|||||||
import me.retucio.sputnik.event.sputnik.*;
|
import me.retucio.sputnik.event.sputnik.*;
|
||||||
import me.retucio.sputnik.module.setting.settings.*;
|
import me.retucio.sputnik.module.setting.settings.*;
|
||||||
import me.retucio.sputnik.ui.screen.ClickGui;
|
import me.retucio.sputnik.ui.screen.ClickGui;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.FriendsPanel;
|
|
||||||
import me.retucio.sputnik.util.ChatUtil;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -44,8 +42,8 @@ public class ClientConfig {
|
|||||||
// posición de la barra de búsqueda (x, y)
|
// posición de la barra de búsqueda (x, y)
|
||||||
public int[] searchBarPosition = new int[] { 340, 16 };
|
public int[] searchBarPosition = new int[] { 340, 16 };
|
||||||
|
|
||||||
// amigos: uuid -> nombre
|
// amigos: uuid -> FriendData (nombre, apodo, fecha)
|
||||||
public Map<String, String> friends = new HashMap<>();
|
public Map<String, FriendData> friends = new HashMap<>();
|
||||||
|
|
||||||
public List<MacroData> macros = new ArrayList<>();
|
public List<MacroData> macros = new ArrayList<>();
|
||||||
|
|
||||||
@@ -146,31 +144,15 @@ public class ClientConfig {
|
|||||||
ConfigManager.INSTANCE.markDirty();
|
ConfigManager.INSTANCE.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener
|
|
||||||
public void onExtendFriendsPanel(FriendPanelEvent.Extend event) {
|
|
||||||
extendablePanels.put("amigos", new PanelData(
|
|
||||||
ClickGui.INSTANCE.getFriendsPanel().getX(),
|
|
||||||
ClickGui.INSTANCE.getFriendsPanel().getY(),
|
|
||||||
ClickGui.INSTANCE.getFriendsPanel().isExtended()));
|
|
||||||
ConfigManager.INSTANCE.markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventListener
|
|
||||||
public void onMoveFriendsPanel(FriendPanelEvent.Move event) {
|
|
||||||
extendablePanels.put("amigos", new PanelData(
|
|
||||||
ClickGui.INSTANCE.getFriendsPanel().getX(),
|
|
||||||
ClickGui.INSTANCE.getFriendsPanel().getY(),
|
|
||||||
ClickGui.INSTANCE.getFriendsPanel().isExtended()));
|
|
||||||
ConfigManager.INSTANCE.markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onAddFriend(FriendEvent.Add event) {
|
public void onAddFriend(FriendEvent.Add event) {
|
||||||
if (isApplying()) return;
|
if (isApplying()) return;
|
||||||
String uuid = event.getFriend().getUuid().toString();
|
String uuid = event.getFriend().getUuid().toString();
|
||||||
String name = event.getFriend().getName();
|
|
||||||
if (!friends.containsKey(uuid)) {
|
if (!friends.containsKey(uuid)) {
|
||||||
friends.put(uuid, name);
|
friends.put(uuid, new FriendData(
|
||||||
|
event.getFriend().getName(),
|
||||||
|
event.getFriend().getNick(),
|
||||||
|
event.getFriend().getBefriendedAt()));
|
||||||
}
|
}
|
||||||
ConfigManager.INSTANCE.markDirty();
|
ConfigManager.INSTANCE.markDirty();
|
||||||
}
|
}
|
||||||
@@ -182,10 +164,25 @@ public class ClientConfig {
|
|||||||
ConfigManager.INSTANCE.markDirty();
|
ConfigManager.INSTANCE.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
public void onRenameFriend(FriendEvent.Rename event) {
|
||||||
|
if (isApplying()) return;
|
||||||
|
String uuid = event.getFriend().getUuid().toString();
|
||||||
|
FriendData existing = friends.get(uuid);
|
||||||
|
if (existing == null) return; // no debería pasar, pero porsiaca
|
||||||
|
|
||||||
|
friends.put(uuid, new FriendData(existing.name(), event.getFriend().getNick(), existing.befriendedAt()));
|
||||||
|
ConfigManager.INSTANCE.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
public record PanelData(int x, int y, boolean extended) implements Serializable {
|
public record PanelData(int x, int y, boolean extended) implements Serializable {
|
||||||
@Serial private static final long serialVersionUID = 1L;
|
@Serial private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record FriendData(String name, String nick, long befriendedAt) implements Serializable {
|
||||||
|
@Serial private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
|
|
||||||
public record MacroData(String name, int key, List<String> lines) implements Serializable {
|
public record MacroData(String name, int key, List<String> lines) implements Serializable {
|
||||||
@Serial private static final long serialVersionUID = 1L;
|
@Serial private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,10 @@ import me.retucio.sputnik.ui.hud.HudElement;
|
|||||||
import me.retucio.sputnik.ui.hud.HudRenderer;
|
import me.retucio.sputnik.ui.hud.HudRenderer;
|
||||||
import me.retucio.sputnik.ui.widgets.Panel;
|
import me.retucio.sputnik.ui.widgets.Panel;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.ExtendablePanel;
|
import me.retucio.sputnik.ui.widgets.panels.ExtendablePanel;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.FriendsPanel;
|
|
||||||
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
||||||
import me.retucio.sputnik.ui.screen.ClickGui;
|
import me.retucio.sputnik.ui.screen.ClickGui;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.SettingsPanel;
|
import me.retucio.sputnik.ui.widgets.panels.SettingsPanel;
|
||||||
import me.retucio.sputnik.util.ChatUtil;
|
|
||||||
import me.retucio.sputnik.util.I18nUtil;
|
import me.retucio.sputnik.util.I18nUtil;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
@@ -316,15 +314,15 @@ public class ConfigManager {
|
|||||||
// ------------------ APLICAR AJUSTES ------------------
|
// ------------------ APLICAR AJUSTES ------------------
|
||||||
|
|
||||||
public void applyFriends() {
|
public void applyFriends() {
|
||||||
config.friends.forEach((uuid, name) -> {
|
config.friends.forEach((uuid, data) -> {
|
||||||
Friend friend = new Friend(UUID.fromString(uuid));
|
Friend friend = new Friend(UUID.fromString(uuid), data.befriendedAt());
|
||||||
friend.setName(name);
|
friend.setName(data.name());
|
||||||
|
friend.setNick(data.nick());
|
||||||
FriendManager.INSTANCE.add(friend);
|
FriendManager.INSTANCE.add(friend);
|
||||||
});
|
});
|
||||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.friends",
|
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.friends",
|
||||||
"amigos aplicados"));
|
"amigos aplicados"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyMacros() {
|
public void applyMacros() {
|
||||||
MacroManager.INSTANCE.setMacros(config.macros.stream()
|
MacroManager.INSTANCE.setMacros(config.macros.stream()
|
||||||
.map(data -> new Macro(data.name(), data.key(), data.lines()))
|
.map(data -> new Macro(data.name(), data.key(), data.lines()))
|
||||||
@@ -424,7 +422,6 @@ public class ConfigManager {
|
|||||||
applyExtendablePanel(panel);
|
applyExtendablePanel(panel);
|
||||||
}
|
}
|
||||||
applyExtendablePanel(ClickGui.INSTANCE.getClientSettingsPanel());
|
applyExtendablePanel(ClickGui.INSTANCE.getClientSettingsPanel());
|
||||||
applyExtendablePanel(ClickGui.INSTANCE.getFriendsPanel());
|
|
||||||
|
|
||||||
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.extendablepanels",
|
Sputnik.LOGGER.info(I18nUtil.fmt("sputnik.config.info.extendablepanels",
|
||||||
"posiciones de marcos extendibles aplicadas"));
|
"posiciones de marcos extendibles aplicadas"));
|
||||||
@@ -440,9 +437,6 @@ public class ConfigManager {
|
|||||||
if (panel instanceof ClientSettingsPanel) {
|
if (panel instanceof ClientSettingsPanel) {
|
||||||
panelData = config.extendablePanels.get("ajustes");
|
panelData = config.extendablePanels.get("ajustes");
|
||||||
}
|
}
|
||||||
if (panel instanceof FriendsPanel) {
|
|
||||||
panelData = config.extendablePanels.get("amigos");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (panelData != null) {
|
if (panelData != null) {
|
||||||
panel.setX(panelData.x());
|
panel.setX(panelData.x());
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ package me.retucio.sputnik.event.sputnik;
|
|||||||
import com.github.retucio.neutrino.Event;
|
import com.github.retucio.neutrino.Event;
|
||||||
import me.retucio.sputnik.friend.Friend;
|
import me.retucio.sputnik.friend.Friend;
|
||||||
|
|
||||||
// evento lanzado cuando se agrega o se elimina un amigo
|
|
||||||
|
// evento lanzado cuando se agrega, elimina o renombra un amigo
|
||||||
public class FriendEvent extends Event {
|
public class FriendEvent extends Event {
|
||||||
|
|
||||||
private final Friend friend;
|
private final Friend friend;
|
||||||
@@ -23,4 +24,8 @@ public class FriendEvent extends Event {
|
|||||||
public static class Remove extends FriendEvent {
|
public static class Remove extends FriendEvent {
|
||||||
public Remove(Friend friend) { super(friend); }
|
public Remove(Friend friend) { super(friend); }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static class Rename extends FriendEvent {
|
||||||
|
public Rename(Friend friend) { super(friend); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package me.retucio.sputnik.event.sputnik;
|
|
||||||
|
|
||||||
import com.github.retucio.neutrino.Event;
|
|
||||||
|
|
||||||
public class FriendPanelEvent {
|
|
||||||
|
|
||||||
public static class Extend extends Event {} // al extenderlo / contraerlo
|
|
||||||
public static class Move extends Event {} // al cambiarlo de posición
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package me.retucio.sputnik.friend;
|
package me.retucio.sputnik.friend;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -13,12 +14,20 @@ public class Friend {
|
|||||||
private static final Minecraft mc = Minecraft.getInstance();
|
private static final Minecraft mc = Minecraft.getInstance();
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
private String nick;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
private final long befriendedAt;
|
||||||
|
|
||||||
private boolean searchMatch;
|
private boolean searchMatch;
|
||||||
|
|
||||||
public Friend(UUID uuid) {
|
public Friend(UUID uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
|
this.befriendedAt = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Friend(UUID uuid, long befriendedAt) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.befriendedAt = befriendedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -29,10 +38,27 @@ public class Friend {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNick() {
|
||||||
|
return nick;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNick(String nick) {
|
||||||
|
this.nick = nick;
|
||||||
|
}
|
||||||
|
|
||||||
|
// apodo si existe, si no el nombre real
|
||||||
|
public String getDisplayName() {
|
||||||
|
return (nick == null || nick.isBlank()) ? name : nick;
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getBefriendedAt() {
|
||||||
|
return befriendedAt;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable Player getPlayer() {
|
public @Nullable Player getPlayer() {
|
||||||
if (mc.level == null) return null;
|
if (mc.level == null) return null;
|
||||||
Entity entity = mc.level.getEntity(uuid);
|
Entity entity = mc.level.getEntity(uuid);
|
||||||
@@ -40,6 +66,11 @@ public class Friend {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable PlayerInfo getPlayerInfo() {
|
||||||
|
if (mc.getConnection() == null) return null;
|
||||||
|
return mc.getConnection().getPlayerInfo(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSearchMatch() {
|
public boolean isSearchMatch() {
|
||||||
return searchMatch;
|
return searchMatch;
|
||||||
}
|
}
|
||||||
@@ -56,4 +87,4 @@ public class Friend {
|
|||||||
NOT_BEFRIENDED,
|
NOT_BEFRIENDED,
|
||||||
NO_FRIENDS; // :(
|
NO_FRIENDS; // :(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,6 +29,7 @@ public class FriendManager {
|
|||||||
public void add(UUID uuid) {
|
public void add(UUID uuid) {
|
||||||
Friend friend = new Friend(uuid);
|
Friend friend = new Friend(uuid);
|
||||||
friend.setName(friend.getPlayer().getName().getString());
|
friend.setName(friend.getPlayer().getName().getString());
|
||||||
|
friend.setNick(friend.getName());
|
||||||
add(friend);
|
add(friend);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +62,11 @@ public class FriendManager {
|
|||||||
return Friend.Status.SUCCESS;
|
return Friend.Status.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rename(Friend friend, String nick) {
|
||||||
|
friend.setNick(nick);
|
||||||
|
Sputnik.EVENT_BUS.post(new FriendEvent.Rename(friend));
|
||||||
|
}
|
||||||
|
|
||||||
public Friend get(UUID uuid) {
|
public Friend get(UUID uuid) {
|
||||||
for (Friend friend : friends) {
|
for (Friend friend : friends) {
|
||||||
if (friend.getUuid().equals(uuid)) {
|
if (friend.getUuid().equals(uuid)) {
|
||||||
|
|||||||
@@ -10,16 +10,25 @@ import me.retucio.sputnik.event.render.Render3DEvent;
|
|||||||
import me.retucio.sputnik.event.render.RenderBlockOutlineEvent;
|
import me.retucio.sputnik.event.render.RenderBlockOutlineEvent;
|
||||||
import me.retucio.sputnik.module.ModuleManager;
|
import me.retucio.sputnik.module.ModuleManager;
|
||||||
import me.retucio.sputnik.module.modules.camera.Freecam;
|
import me.retucio.sputnik.module.modules.camera.Freecam;
|
||||||
|
import me.retucio.sputnik.module.modules.render.BreakingProgress;
|
||||||
import me.retucio.sputnik.util.render.SputnikBuffers;
|
import me.retucio.sputnik.util.render.SputnikBuffers;
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
|
import net.minecraft.client.renderer.ShaderManager;
|
||||||
import net.minecraft.client.renderer.SubmitNodeCollector;
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
||||||
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||||
|
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||||
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
import net.minecraft.client.renderer.state.level.CameraRenderState;
|
||||||
import net.minecraft.client.renderer.state.level.LevelRenderState;
|
import net.minecraft.client.renderer.state.level.LevelRenderState;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.resources.model.ModelManager;
|
||||||
|
import net.minecraft.client.resources.model.sprite.AtlasManager;
|
||||||
import net.minecraft.util.profiling.ProfilerFiller;
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
import org.joml.Matrix4fc;
|
import org.joml.Matrix4fc;
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.*;
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||||
@@ -31,6 +40,14 @@ import static me.retucio.sputnik.Sputnik.mc;
|
|||||||
@Mixin(LevelRenderer.class)
|
@Mixin(LevelRenderer.class)
|
||||||
public abstract class LevelRendererMixin {
|
public abstract class LevelRendererMixin {
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private BreakingProgress bp;
|
||||||
|
|
||||||
|
@Inject(method = "<init>", at = @At("TAIL"))
|
||||||
|
private void getModules(EntityRenderDispatcher entityRenderDispatcher, BlockEntityRenderDispatcher blockEntityRenderDispatcher, ModelManager modelManager, TextureManager textureManager, AtlasManager atlasManager, ShaderManager shaderManager, GameRenderer gameRenderer, int width, int height, CallbackInfo ci) {
|
||||||
|
bp = ModuleManager.INSTANCE.getModuleByClass(BreakingProgress.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "render", at = @At("RETURN"))
|
@Inject(method = "render", at = @At("RETURN"))
|
||||||
private void render(GraphicsResourceAllocator resourceAllocator, DeltaTracker dt, boolean renderOutline, CameraRenderState cameraState, Matrix4fc modelViewMatrix, GpuBufferSlice terrainFog, Vector4f fogColor, boolean shouldRenderSky, CallbackInfo ci, @Local(name = "profiler") ProfilerFiller profiler) {
|
private void render(GraphicsResourceAllocator resourceAllocator, DeltaTracker dt, boolean renderOutline, CameraRenderState cameraState, Matrix4fc modelViewMatrix, GpuBufferSlice terrainFog, Vector4f fogColor, boolean shouldRenderSky, CallbackInfo ci, @Local(name = "profiler") ProfilerFiller profiler) {
|
||||||
if (mc == null || mc.level == null) return;
|
if (mc == null || mc.level == null) return;
|
||||||
@@ -55,13 +72,6 @@ public abstract class LevelRendererMixin {
|
|||||||
if (freecam.isEnabled() && !freecam.blockOutlines.getValue()) ci.cancel();
|
if (freecam.isEnabled() && !freecam.blockOutlines.getValue()) ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Inject(method = "hasBlindnessOrDarkness(Lnet/minecraft/client/extractRenderState/Camera;)Z", at = @At("HEAD"), cancellable = true)
|
|
||||||
// private void hasBlindnessOrDarkness(Camera camera, CallbackInfoReturnable<Boolean> cir) {
|
|
||||||
// NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
|
||||||
// if (!noRender.isEnabled()) return;
|
|
||||||
// if (!noRender.blindnessEffect.getValue() || !noRender.darknessEffect.getValue()) cir.setReturnValue(null);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// puto mojang con sus nombres confusos
|
// puto mojang con sus nombres confusos
|
||||||
@ModifyArgs(method = "submitBlockOutline", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;submitHitOutline(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/rendertype/RenderType;Lnet/minecraft/client/renderer/state/level/BlockOutlineRenderState;IFZ)V"))
|
@ModifyArgs(method = "submitBlockOutline", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;submitHitOutline(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/client/renderer/rendertype/RenderType;Lnet/minecraft/client/renderer/state/level/BlockOutlineRenderState;IFZ)V"))
|
||||||
private void modifyBlockOutline(Args args) {
|
private void modifyBlockOutline(Args args) {
|
||||||
@@ -72,4 +82,12 @@ public abstract class LevelRendererMixin {
|
|||||||
if (event.getLineWidth() != (float) args.get(5))
|
if (event.getLineWidth() != (float) args.get(5))
|
||||||
args.set(5, event.getLineWidth());
|
args.set(5, event.getLineWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "submitBlockDestroyAnimation", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void cancelBreakingAnim(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, LevelRenderState levelRenderState, CallbackInfo ci) {
|
||||||
|
if (!bp.isEnabled()) return;
|
||||||
|
if (bp.cancelAnim.getValue()) {
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,12 @@ public class BreakingProgress extends Module {
|
|||||||
private final EnumSetting<BreakMode> breakMode = sgGeneral.add(new EnumSetting<>("modo de minado", "elige si el cubo se encoge o se dilata",
|
private final EnumSetting<BreakMode> breakMode = sgGeneral.add(new EnumSetting<>("modo de minado", "elige si el cubo se encoge o se dilata",
|
||||||
BreakMode.class, BreakMode.INWARDS));
|
BreakMode.class, BreakMode.INWARDS));
|
||||||
|
|
||||||
|
public final BooleanSetting cancelAnim = sgGeneral.add(new BooleanSetting(
|
||||||
|
"cancelar animación",
|
||||||
|
"no renderizar la anim. original",
|
||||||
|
true
|
||||||
|
));
|
||||||
|
|
||||||
private final BooleanSetting outlines = sgOutlines.add(new BooleanSetting("contorno", "renderizar contorno", true));
|
private final BooleanSetting outlines = sgOutlines.add(new BooleanSetting("contorno", "renderizar contorno", true));
|
||||||
private final ColorSetting outlineColor = sgOutlines.add(new ColorSetting("color del contorno", "color del contorno",
|
private final ColorSetting outlineColor = sgOutlines.add(new ColorSetting("color del contorno", "color del contorno",
|
||||||
new Color(0, 255, 0, 200), false));
|
new Color(0, 255, 0, 200), false));
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package me.retucio.sputnik.module.modules.render;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import me.retucio.sputnik.Sputnik;
|
import me.retucio.sputnik.Sputnik;
|
||||||
|
import me.retucio.sputnik.config.ConfigManager;
|
||||||
import me.retucio.sputnik.mixin.mixins.entity.EntityMixin;
|
import me.retucio.sputnik.mixin.mixins.entity.EntityMixin;
|
||||||
import me.retucio.sputnik.mixin.mixins.entity.ItemEntityMixin;
|
import me.retucio.sputnik.mixin.mixins.entity.ItemEntityMixin;
|
||||||
import me.retucio.sputnik.mixin.mixins.player.PlayerMixin;
|
import me.retucio.sputnik.mixin.mixins.player.PlayerMixin;
|
||||||
@@ -90,7 +91,7 @@ public class Nametags extends Module {
|
|||||||
defaultEntities.replace(EntityTypes.TNT, true);
|
defaultEntities.replace(EntityTypes.TNT, true);
|
||||||
entities.setDefaultValue(defaultEntities);
|
entities.setDefaultValue(defaultEntities);
|
||||||
|
|
||||||
health.onUpdate(v -> healthMode.visibility(v));
|
health.onUpdate(healthMode::visibility);
|
||||||
|
|
||||||
entities.onUpdate(entities -> {
|
entities.onUpdate(entities -> {
|
||||||
items.visibility(entities.get(EntityTypes.ITEM));
|
items.visibility(entities.get(EntityTypes.ITEM));
|
||||||
@@ -131,7 +132,7 @@ public class Nametags extends Module {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public String getOwnerName(EntityReference<LivingEntity> owner) {
|
public String getOwnerName(EntityReference<LivingEntity> owner) {
|
||||||
// si el dueño está en línea (de manera segura)
|
// si el dueño está en línea (de manera segura)
|
||||||
if (mc.level instanceof UniquelyIdentifyable queriableWorld) { // UUIDLookup<?> ??
|
if (mc.level instanceof UniquelyIdentifyable queriableWorld) {
|
||||||
LivingEntity ownerEntity = owner.resolve(queriableWorld, LivingEntity.class);
|
LivingEntity ownerEntity = owner.resolve(queriableWorld, LivingEntity.class);
|
||||||
if (ownerEntity instanceof Player playerEntity) return playerEntity.getName().getString();
|
if (ownerEntity instanceof Player playerEntity) return playerEntity.getName().getString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ import me.retucio.sputnik.module.Category;
|
|||||||
import me.retucio.sputnik.module.Module;
|
import me.retucio.sputnik.module.Module;
|
||||||
import me.retucio.sputnik.module.setting.Setting;
|
import me.retucio.sputnik.module.setting.Setting;
|
||||||
import me.retucio.sputnik.module.setting.settings.ColorSetting;
|
import me.retucio.sputnik.module.setting.settings.ColorSetting;
|
||||||
import me.retucio.sputnik.ui.widgets.buttons.FriendButton;
|
import me.retucio.sputnik.ui.screen.tabs.FriendsTab;
|
||||||
import me.retucio.sputnik.ui.widgets.buttons.settings.ListButton;
|
import me.retucio.sputnik.ui.widgets.buttons.settings.ListButton;
|
||||||
import me.retucio.sputnik.ui.widgets.buttons.ModuleButton;
|
import me.retucio.sputnik.ui.widgets.buttons.ModuleButton;
|
||||||
import me.retucio.sputnik.ui.widgets.buttons.SettingButton;
|
import me.retucio.sputnik.ui.widgets.buttons.SettingButton;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.FriendsPanel;
|
|
||||||
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.settings.ColorPickerPanel;
|
import me.retucio.sputnik.ui.widgets.panels.settings.ColorPickerPanel;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
||||||
@@ -31,7 +30,6 @@ import me.retucio.sputnik.ui.widgets.misc.ScrollBarWidget;
|
|||||||
import me.retucio.sputnik.ui.widgets.misc.SearchBarWidget;
|
import me.retucio.sputnik.ui.widgets.misc.SearchBarWidget;
|
||||||
import me.retucio.sputnik.ui.widgets.misc.TabBarWidget;
|
import me.retucio.sputnik.ui.widgets.misc.TabBarWidget;
|
||||||
import me.retucio.sputnik.util.Colors;
|
import me.retucio.sputnik.util.Colors;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.settings.FriendSettingsPanel;
|
|
||||||
import me.retucio.sputnik.util.KeyUtil;
|
import me.retucio.sputnik.util.KeyUtil;
|
||||||
|
|
||||||
import me.retucio.sputnik.util.MiscUtil;
|
import me.retucio.sputnik.util.MiscUtil;
|
||||||
@@ -69,7 +67,6 @@ public class ClickGui extends Screen {
|
|||||||
private final List<ModulePanel> modulePanels = new ArrayList<>();
|
private final List<ModulePanel> modulePanels = new ArrayList<>();
|
||||||
private final List<SettingsPanel> settingsPanels = new ArrayList<>();
|
private final List<SettingsPanel> settingsPanels = new ArrayList<>();
|
||||||
private final ClientSettingsPanel clientSettingsPanel = new ClientSettingsPanel(620, 280, 100, 20);
|
private final ClientSettingsPanel clientSettingsPanel = new ClientSettingsPanel(620, 280, 100, 20);
|
||||||
private final FriendsPanel friendsPanel = new FriendsPanel(40, 280, 100, 20);
|
|
||||||
|
|
||||||
private final ScrollBarWidget scrollBar = new ScrollBarWidget();
|
private final ScrollBarWidget scrollBar = new ScrollBarWidget();
|
||||||
private final SearchBarWidget searchBar = new SearchBarWidget(320, 10, 320, 20);
|
private final SearchBarWidget searchBar = new SearchBarWidget(320, 10, 320, 20);
|
||||||
@@ -78,6 +75,9 @@ public class ClickGui extends Screen {
|
|||||||
private final TabBarWidget tabBar = new TabBarWidget(this::onTabLeft);
|
private final TabBarWidget tabBar = new TabBarWidget(this::onTabLeft);
|
||||||
private final ProfilesTab profilesTab = new ProfilesTab();
|
private final ProfilesTab profilesTab = new ProfilesTab();
|
||||||
private final MacrosTab macrosTab = new MacrosTab();
|
private final MacrosTab macrosTab = new MacrosTab();
|
||||||
|
private final FriendsTab friendsTab = new FriendsTab();
|
||||||
|
|
||||||
|
private static final int PLACEMENT_SEARCH_STEP = 8;
|
||||||
|
|
||||||
public ClickGui() {
|
public ClickGui() {
|
||||||
super(Component.translatable("sputnik.ui.clickgui.title"));
|
super(Component.translatable("sputnik.ui.clickgui.title"));
|
||||||
@@ -97,6 +97,7 @@ public class ClickGui extends Screen {
|
|||||||
case HUD -> renderHud(gui, mouseX, mouseY);
|
case HUD -> renderHud(gui, mouseX, mouseY);
|
||||||
case PROFILES -> profilesTab.render(gui, mouseX, mouseY, delta);
|
case PROFILES -> profilesTab.render(gui, mouseX, mouseY, delta);
|
||||||
case MACROS -> macrosTab.render(gui, mouseX, mouseY, delta);
|
case MACROS -> macrosTab.render(gui, mouseX, mouseY, delta);
|
||||||
|
case FRIENDS -> friendsTab.render(gui, mouseX, mouseY, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
tabBar.render(gui, mouseX, mouseY, delta);
|
tabBar.render(gui, mouseX, mouseY, delta);
|
||||||
@@ -124,7 +125,6 @@ public class ClickGui extends Screen {
|
|||||||
searchBar.updatePosition(mouseX, mouseY);
|
searchBar.updatePosition(mouseX, mouseY);
|
||||||
|
|
||||||
// actualizar la posición de renderizado vertical de los paneles cada tick
|
// actualizar la posición de renderizado vertical de los paneles cada tick
|
||||||
friendsPanel.updateRenderY(scrollOffset);
|
|
||||||
clientSettingsPanel.updateRenderY(scrollOffset);
|
clientSettingsPanel.updateRenderY(scrollOffset);
|
||||||
for (ModulePanel mp : modulePanels) {
|
for (ModulePanel mp : modulePanels) {
|
||||||
mp.updateRenderY(scrollOffset);
|
mp.updateRenderY(scrollOffset);
|
||||||
@@ -149,9 +149,6 @@ public class ClickGui extends Screen {
|
|||||||
sp.drawTooltips(gui, mouseX, mouseY);
|
sp.drawTooltips(gui, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
friendsPanel.render(gui, mouseX, mouseY, delta);
|
|
||||||
friendsPanel.updatePosition(mouseX, mouseY);
|
|
||||||
|
|
||||||
clientSettingsPanel.render(gui, mouseX, mouseY, delta);
|
clientSettingsPanel.render(gui, mouseX, mouseY, delta);
|
||||||
clientSettingsPanel.updatePosition(mouseX, mouseY);
|
clientSettingsPanel.updatePosition(mouseX, mouseY);
|
||||||
|
|
||||||
@@ -191,10 +188,6 @@ public class ClickGui extends Screen {
|
|||||||
bottom = Math.max(bottom, sp.getY() + sp.getH() + sp.getTotalHeight());
|
bottom = Math.max(bottom, sp.getY() + sp.getH() + sp.getTotalHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
int friendsBottom = friendsPanel.getY() + friendsPanel.getH()
|
|
||||||
+ (friendsPanel.isExtended() ? friendsPanel.getTotalHeight() : 0);
|
|
||||||
bottom = Math.max(bottom, friendsBottom);
|
|
||||||
|
|
||||||
int clientBottom = clientSettingsPanel.getY() + clientSettingsPanel.getH()
|
int clientBottom = clientSettingsPanel.getY() + clientSettingsPanel.getH()
|
||||||
+ (clientSettingsPanel.isExtended() ? clientSettingsPanel.getTotalHeight() : 0);
|
+ (clientSettingsPanel.isExtended() ? clientSettingsPanel.getTotalHeight() : 0);
|
||||||
bottom = Math.max(bottom, clientBottom);
|
bottom = Math.max(bottom, clientBottom);
|
||||||
@@ -202,6 +195,46 @@ public class ClickGui extends Screen {
|
|||||||
return bottom + 20; // padding
|
return bottom + 20; // padding
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int[] findEmptyPosition(int w, int h, int preferredX, int preferredY) {
|
||||||
|
int screenWidth = mc.getWindow().getGuiScaledWidth();
|
||||||
|
int maxX = Math.max(0, screenWidth - w);
|
||||||
|
int startX = Math.clamp(preferredX, 0, maxX);
|
||||||
|
int startY = Math.max(preferredY, 0);
|
||||||
|
|
||||||
|
int searchBottom = calculateContentHeight() + h;
|
||||||
|
|
||||||
|
for (int y = startY; y <= searchBottom; y += PLACEMENT_SEARCH_STEP) {
|
||||||
|
for (int candidateX = 0; candidateX <= maxX; candidateX += PLACEMENT_SEARCH_STEP) {
|
||||||
|
if (!overlapsAnything(candidateX, y, w, h)) {
|
||||||
|
return new int[]{candidateX, y};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no hay hueco: colocarlo debajo de todo lo demás, para llegar a él haciendo scroll
|
||||||
|
return new int[]{startX, calculateContentHeight()};
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean overlapsAnything(int x, int y, int w, int h) {
|
||||||
|
for (ModulePanel mp : modulePanels) {
|
||||||
|
int mpHeight = mp.getH() + (mp.isExtended() ? mp.getTotalHeight() : 0);
|
||||||
|
if (rectsOverlap(x, y, w, h, mp.getX(), mp.getY(), mp.getW(), mpHeight)) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SettingsPanel sp : settingsPanels) {
|
||||||
|
int spHeight = sp.getH() + sp.getTotalHeight();
|
||||||
|
if (rectsOverlap(x, y, w, h, sp.getX(), sp.getY(), sp.getW(), spHeight)) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int clientHeight = clientSettingsPanel.getH() + (clientSettingsPanel.isExtended() ? clientSettingsPanel.getTotalHeight() : 0);
|
||||||
|
return rectsOverlap(x, y, w, h, clientSettingsPanel.getX(), clientSettingsPanel.getY(), clientSettingsPanel.getW(), clientHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean rectsOverlap(int ax, int ay, int aw, int ah, int bx, int by, int bw, int bh) {
|
||||||
|
return ax < bx + bw && ax + aw > bx
|
||||||
|
&& ay < by + bh && ay + ah > by;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(MouseButtonEvent click, boolean doubled) {
|
public boolean mouseClicked(MouseButtonEvent click, boolean doubled) {
|
||||||
int x = (int) click.x();
|
int x = (int) click.x();
|
||||||
@@ -212,8 +245,6 @@ public class ClickGui extends Screen {
|
|||||||
switch (tabBar.getSelected()) {
|
switch (tabBar.getSelected()) {
|
||||||
case MODULES -> {
|
case MODULES -> {
|
||||||
miscWidgets.forEach(w -> w.mouseClicked(x, y, click.button()));
|
miscWidgets.forEach(w -> w.mouseClicked(x, y, click.button()));
|
||||||
|
|
||||||
friendsPanel.mouseClicked(x, y, click.button());
|
|
||||||
clientSettingsPanel.mouseClicked(x, y, click.button());
|
clientSettingsPanel.mouseClicked(x, y, click.button());
|
||||||
for (ModulePanel mp : modulePanels.reversed()) {
|
for (ModulePanel mp : modulePanels.reversed()) {
|
||||||
mp.mouseClicked(x, y, click.button());
|
mp.mouseClicked(x, y, click.button());
|
||||||
@@ -225,6 +256,7 @@ public class ClickGui extends Screen {
|
|||||||
case HUD -> HudEditor.INSTANCE.mouseClicked(x, y, click.button());
|
case HUD -> HudEditor.INSTANCE.mouseClicked(x, y, click.button());
|
||||||
case PROFILES -> profilesTab.mouseClicked(x, y, click.button());
|
case PROFILES -> profilesTab.mouseClicked(x, y, click.button());
|
||||||
case MACROS -> macrosTab.mouseClicked(x, y, click.button());
|
case MACROS -> macrosTab.mouseClicked(x, y, click.button());
|
||||||
|
case FRIENDS -> friendsTab.mouseClicked(x, y, click.button());
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.mouseClicked(click, doubled);
|
return super.mouseClicked(click, doubled);
|
||||||
@@ -246,7 +278,6 @@ public class ClickGui extends Screen {
|
|||||||
x, y, click.button()));
|
x, y, click.button()));
|
||||||
|
|
||||||
// registrar cuándo se suelta el clic, en cada panel respectivamente
|
// registrar cuándo se suelta el clic, en cada panel respectivamente
|
||||||
friendsPanel.mouseReleased(x, y, click.button());
|
|
||||||
clientSettingsPanel.mouseReleased(x, y, click.button());
|
clientSettingsPanel.mouseReleased(x, y, click.button());
|
||||||
for (ModulePanel mp : modulePanels.reversed()) {
|
for (ModulePanel mp : modulePanels.reversed()) {
|
||||||
mp.mouseReleased(x, y, click.button());
|
mp.mouseReleased(x, y, click.button());
|
||||||
@@ -290,6 +321,7 @@ public class ClickGui extends Screen {
|
|||||||
}
|
}
|
||||||
case PROFILES -> profilesTab.onKey(event.getKey(), event.getAction());
|
case PROFILES -> profilesTab.onKey(event.getKey(), event.getAction());
|
||||||
case MACROS -> macrosTab.onKey(event.getKey(), event.getAction());
|
case MACROS -> macrosTab.onKey(event.getKey(), event.getAction());
|
||||||
|
case FRIENDS -> friendsTab.onKey(event.getKey(), event.getAction());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +345,6 @@ public class ClickGui extends Screen {
|
|||||||
if (correction != 0) {
|
if (correction != 0) {
|
||||||
modulePanels.forEach(mp -> mp.setY(mp.getY() + correction));
|
modulePanels.forEach(mp -> mp.setY(mp.getY() + correction));
|
||||||
settingsPanels.forEach(sp -> sp.setY(sp.getY() + correction));
|
settingsPanels.forEach(sp -> sp.setY(sp.getY() + correction));
|
||||||
friendsPanel.setY(friendsPanel.getY() + correction);
|
|
||||||
clientSettingsPanel.setY(clientSettingsPanel.getY() + correction);
|
clientSettingsPanel.setY(clientSettingsPanel.getY() + correction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,26 +413,6 @@ public class ClickGui extends Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Button b : friendsPanel.getButtons()) {
|
|
||||||
if (!(b instanceof FriendButton fb)) continue;
|
|
||||||
Friend friend = fb.getFriend();
|
|
||||||
|
|
||||||
if (searchInput.isEmpty()) {
|
|
||||||
friend.setSearchMatch(true);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String name = MiscUtil.removeAccentMarks(friend.getName());
|
|
||||||
String uuid = MiscUtil.removeAccentMarks(friend.getUuid().toString());
|
|
||||||
|
|
||||||
if (!clientSettings.matchCase.getValue()) {
|
|
||||||
name = name.toLowerCase();
|
|
||||||
uuid = uuid.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
friend.setSearchMatch(name.contains(searchInput) || uuid.contains(searchInput));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Button b : clientSettingsPanel.getButtons()) {
|
for (Button b : clientSettingsPanel.getButtons()) {
|
||||||
if (!(b instanceof SettingButton<?> sb)) continue;
|
if (!(b instanceof SettingButton<?> sb)) continue;
|
||||||
Setting<?> setting = sb.getSetting();
|
Setting<?> setting = sb.getSetting();
|
||||||
@@ -433,12 +444,18 @@ public class ClickGui extends Screen {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// abrir un marco donde se encuentran los ajustes del módulo deseado
|
// abrir un marco donde se encuentran los ajustes del módulo deseado, buscando un
|
||||||
|
// hueco libre cerca de (x, y) para que no se solape con otros paneles ya abiertos
|
||||||
public void openSettingsPanel(Module module, int x, int y) {
|
public void openSettingsPanel(Module module, int x, int y) {
|
||||||
// asegurarse de que no se sale de la pantalla
|
SettingsPanel panel = new SettingsPanel(module, 0, 0, 100, 20);
|
||||||
x = Math.clamp(x, 0, mc.getWindow().getGuiScaledWidth() - 80);
|
panel.updateTotalHeight(); // altura real disponible ya tras el constructor
|
||||||
|
|
||||||
|
int panelHeight = panel.getH() + panel.getTotalHeight();
|
||||||
|
int[] position = findEmptyPosition(panel.getW(), panelHeight, x, y);
|
||||||
|
|
||||||
|
panel.setX(position[0]);
|
||||||
|
panel.setY(position[1]);
|
||||||
|
|
||||||
SettingsPanel panel = new SettingsPanel(module, x, y, 100, 20);
|
|
||||||
settingsPanels.add(panel);
|
settingsPanels.add(panel);
|
||||||
|
|
||||||
Sputnik.EVENT_BUS.post(new SettingsPanelEvent.Open(panel));
|
Sputnik.EVENT_BUS.post(new SettingsPanelEvent.Open(panel));
|
||||||
@@ -499,33 +516,6 @@ public class ClickGui extends Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFriendSettingsPanelOpen(Friend friend) {
|
|
||||||
for (SettingsPanel sp : getSettingsPanels()) {
|
|
||||||
if (sp instanceof FriendSettingsPanel fsp) {
|
|
||||||
if (fsp.getFriend().getUuid().equals(friend.getUuid())) return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openFriendSettingsPanel(Friend friend, int x, int y) {
|
|
||||||
FriendSettingsPanel panel = new FriendSettingsPanel(friend, x + 80, y + 5, 153, 20);
|
|
||||||
if (isFriendSettingsPanelOpen(friend)) {
|
|
||||||
closeFriendSettingsPanel(friend);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
settingsPanels.add(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeFriendSettingsPanel(Friend friend) {
|
|
||||||
for (SettingsPanel sp : getSettingsPanels()) {
|
|
||||||
if (sp instanceof FriendSettingsPanel fsp && fsp.getFriend().getUuid().equals(friend.getUuid())) {
|
|
||||||
settingsPanels.remove(fsp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refreshListButtons() {
|
public void refreshListButtons() {
|
||||||
for (SettingsPanel panel : settingsPanels)
|
for (SettingsPanel panel : settingsPanels)
|
||||||
for (Button button : panel.getButtons())
|
for (Button button : panel.getButtons())
|
||||||
@@ -546,7 +536,8 @@ public class ClickGui extends Screen {
|
|||||||
// lo miran Sputnik#onInput y el editor del hud para no tratar las teclas que se están
|
// lo miran Sputnik#onInput y el editor del hud para no tratar las teclas que se están
|
||||||
// escribiendo como atajos de módulos
|
// escribiendo como atajos de módulos
|
||||||
public boolean isCapturingInput() {
|
public boolean isCapturingInput() {
|
||||||
return searchBar.isFocused() || profilesTab.isCapturingInput() || macrosTab.isCapturingInput();
|
return searchBar.isFocused() || profilesTab.isCapturingInput()
|
||||||
|
|| macrosTab.isCapturingInput() || friendsTab.isCapturingInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOnHudTab() {
|
public boolean isOnHudTab() {
|
||||||
@@ -599,7 +590,6 @@ public class ClickGui extends Screen {
|
|||||||
public List<ModulePanel> getModulePanels() { return modulePanels; }
|
public List<ModulePanel> getModulePanels() { return modulePanels; }
|
||||||
public List<SettingsPanel> getSettingsPanels() { return settingsPanels; }
|
public List<SettingsPanel> getSettingsPanels() { return settingsPanels; }
|
||||||
public ClientSettingsPanel getClientSettingsPanel() { return clientSettingsPanel; }
|
public ClientSettingsPanel getClientSettingsPanel() { return clientSettingsPanel; }
|
||||||
public FriendsPanel getFriendsPanel() { return friendsPanel; }
|
|
||||||
public SearchBarWidget getSearchBar() { return searchBar; }
|
public SearchBarWidget getSearchBar() { return searchBar; }
|
||||||
public TabBarWidget getTabBar() { return tabBar; }
|
public TabBarWidget getTabBar() { return tabBar; }
|
||||||
public ScrollBarWidget getScrollBar() { return scrollBar; }
|
public ScrollBarWidget getScrollBar() { return scrollBar; }
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ public enum Tab {
|
|||||||
MODULES("módulos"),
|
MODULES("módulos"),
|
||||||
HUD("hud"),
|
HUD("hud"),
|
||||||
PROFILES("perfiles"),
|
PROFILES("perfiles"),
|
||||||
MACROS("macros");
|
MACROS("macros"),
|
||||||
|
FRIENDS("amigos");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package me.retucio.sputnik.ui.screen.tabs;
|
||||||
|
|
||||||
|
import me.retucio.sputnik.friend.Friend;
|
||||||
|
import me.retucio.sputnik.friend.FriendManager;
|
||||||
|
import me.retucio.sputnik.ui.hud.HudRenderer;
|
||||||
|
import me.retucio.sputnik.ui.widgets.misc.FriendWidget;
|
||||||
|
import me.retucio.sputnik.util.Colors;
|
||||||
|
import me.retucio.sputnik.util.I18nUtil;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
|
public class FriendsTab {
|
||||||
|
|
||||||
|
private static final Minecraft mc = Minecraft.getInstance();
|
||||||
|
|
||||||
|
private static final int COLUMNS = 3;
|
||||||
|
private static final int CARD_HEIGHT = 60;
|
||||||
|
private static final int MARGIN = 6;
|
||||||
|
private static final int TOP = 40;
|
||||||
|
|
||||||
|
// uno por amigo, persistente entre frames para no perder el foco del campo de apodo mientras se edita
|
||||||
|
private final Map<UUID, FriendWidget> widgets = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) {
|
||||||
|
List<Friend> friends = FriendManager.INSTANCE.getFriends();
|
||||||
|
syncWidgets(friends);
|
||||||
|
|
||||||
|
int screenWidth = mc.getWindow().getGuiScaledWidth();
|
||||||
|
int cardWidth = screenWidth / COLUMNS;
|
||||||
|
|
||||||
|
gui.centeredText(mc.font, Component.translatable("sputnik.ui.friends.title"),
|
||||||
|
screenWidth / 2, TOP - 14, Colors.mainColor.getRGB());
|
||||||
|
|
||||||
|
if (friends.isEmpty()) {
|
||||||
|
gui.centeredText(mc.font, Component.translatable("sputnik.ui.friends.empty"),
|
||||||
|
screenWidth / 2, TOP + 20, Colors.instructionsTextColor.getRGB());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int col = 0;
|
||||||
|
int row = 0;
|
||||||
|
for (Friend friend : friends) {
|
||||||
|
FriendWidget widget = widgets.get(friend.getUuid());
|
||||||
|
|
||||||
|
int cx = col * cardWidth + MARGIN;
|
||||||
|
int cy = TOP + row * (CARD_HEIGHT + MARGIN);
|
||||||
|
int cw = cardWidth - MARGIN * 2;
|
||||||
|
|
||||||
|
widget.updateBounds(cx, cy, cw, CARD_HEIGHT);
|
||||||
|
widget.render(gui, mouseX, mouseY, delta);
|
||||||
|
|
||||||
|
col++;
|
||||||
|
if (col >= COLUMNS) {
|
||||||
|
col = 0;
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// añade widgets para amigos nuevos y elimina los de quienes ya no lo son
|
||||||
|
private void syncWidgets(List<Friend> friends) {
|
||||||
|
widgets.keySet().removeIf(uuid -> friends.stream().noneMatch(f -> f.getUuid().equals(uuid)));
|
||||||
|
|
||||||
|
for (Friend friend : friends) {
|
||||||
|
widgets.computeIfAbsent(friend.getUuid(),
|
||||||
|
uuid -> new FriendWidget(friend, 0, 0, 0, CARD_HEIGHT, this::remove));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void remove(Friend friend) {
|
||||||
|
FriendManager.INSTANCE.remove(friend);
|
||||||
|
HudRenderer.INSTANCE.pushNotification(
|
||||||
|
I18nUtil.orElse("sputnik.ui.friends.title", "amigos"),
|
||||||
|
I18nUtil.orElse("sputnik.ui.friends.removed", "sputnik.ui.friends.removed", friend.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||||
|
for (FriendWidget widget : widgets.values()) {
|
||||||
|
if (widget.isHovered(mouseX, mouseY) || widget.isCapturingInput()) {
|
||||||
|
widget.mouseClicked(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onKey(int key, int action) {
|
||||||
|
for (FriendWidget widget : widgets.values()) {
|
||||||
|
if (widget.isCapturingInput()) widget.onKey(key, action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCapturingInput() {
|
||||||
|
return widgets.values().stream().anyMatch(FriendWidget::isCapturingInput);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,10 +9,6 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public abstract class Panel<B extends Button> extends Widget {
|
public abstract class Panel<B extends Button> extends Widget {
|
||||||
|
|
||||||
// el título se resuelve al pintarlo, no al construir el marco: los marcos se crean en
|
|
||||||
// la inicialización del mod, cuando el idioma todavía no ha cargado, así que guardar el
|
|
||||||
// texto ya traducido dejaba los títulos en español para siempre (y no cambiaban aunque
|
|
||||||
// se cambiara el idioma del juego en marcha)
|
|
||||||
private Supplier<String> title;
|
private Supplier<String> title;
|
||||||
|
|
||||||
protected final List<B> buttons = new ArrayList<>();
|
protected final List<B> buttons = new ArrayList<>();
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
package me.retucio.sputnik.ui.widgets.buttons;
|
|
||||||
|
|
||||||
import me.retucio.sputnik.friend.Friend;
|
|
||||||
import me.retucio.sputnik.module.Module;
|
|
||||||
import me.retucio.sputnik.ui.screen.ClickGui;
|
|
||||||
import me.retucio.sputnik.ui.widgets.panels.FriendsPanel;
|
|
||||||
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
|
||||||
import me.retucio.sputnik.ui.widgets.Button;
|
|
||||||
import me.retucio.sputnik.util.Colors;
|
|
||||||
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
|
|
||||||
|
|
||||||
// clase para el botón para cada módulo
|
|
||||||
public class FriendButton extends Button {
|
|
||||||
|
|
||||||
private final Friend friend;
|
|
||||||
public final int height = 18;
|
|
||||||
|
|
||||||
public FriendButton(Friend friend, FriendsPanel parent, int offset) {
|
|
||||||
super(parent, offset);
|
|
||||||
this.friend = friend;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) {
|
|
||||||
gui.fill( // dibujar el contorno del botón
|
|
||||||
parent.getX() + 2, parent.getRenderY() + offset + 3,
|
|
||||||
parent.getX() + parent.getW() - 2 , parent.getRenderY() + height + offset,
|
|
||||||
determineColor(mouseX, mouseY));
|
|
||||||
|
|
||||||
gui.text( // dibujar el nombre del amigo
|
|
||||||
mc.font, friend.getName(),
|
|
||||||
parent.getX() + 5, parent.getRenderY() + offset + (height / 2) - (mc.font.lineHeight / 2) + 2,
|
|
||||||
-1, true);
|
|
||||||
|
|
||||||
// dibujar "tooltips" (cajas de texto) al pasar el puntero encima del botón, para mostrar su UUID
|
|
||||||
if (isHovered(mouseX, mouseY)) {
|
|
||||||
drawTooltip(gui, mouseX, mouseY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawTooltip(GuiGraphicsExtractor gui, int mouseX, int mouseY) {
|
|
||||||
gui.setTooltipForNextFrame(Component.literal(friend.getUuid().toString()), mouseX, mouseY + 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
|
||||||
if (isHovered(mouseX, mouseY) && ClickGui.INSTANCE.trySelect(this)) {
|
|
||||||
ClickGui.INSTANCE.openFriendSettingsPanel(friend, mouseX, mouseY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// verifica si el puntero del ratón se encuentra sobre el botón
|
|
||||||
@Override
|
|
||||||
public boolean isHovered(int mouseX, int mouseY) {
|
|
||||||
return ClickGui.INSTANCE.canSelect(this)
|
|
||||||
&& mouseX > parent.getX()
|
|
||||||
&& mouseX < parent.getX() + parent.getW()
|
|
||||||
&& mouseY > parent.getRenderY() + offset
|
|
||||||
&& mouseY < parent.getRenderY() + height + offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int determineColor(double mouseX, double mouseY) {
|
|
||||||
// determina el color del botón, dependiendo de si está el puntero encima
|
|
||||||
return isHovered((int) mouseX, (int) mouseY)
|
|
||||||
? Colors.buttonColor.brighter().getRGB()
|
|
||||||
: Colors.buttonColor.getRGB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Friend getFriend() {
|
|
||||||
return friend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
package me.retucio.sputnik.ui.widgets.misc;
|
||||||
|
|
||||||
|
import me.retucio.sputnik.friend.Friend;
|
||||||
|
import me.retucio.sputnik.friend.FriendManager;
|
||||||
|
import me.retucio.sputnik.ui.widgets.Widget;
|
||||||
|
import me.retucio.sputnik.util.Colors;
|
||||||
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
|
import net.minecraft.client.gui.components.PlayerFaceExtractor;
|
||||||
|
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
|
public class FriendWidget extends Widget {
|
||||||
|
|
||||||
|
private static final int PADDING = 6;
|
||||||
|
private static final int HEAD_SIZE = 28;
|
||||||
|
private static final int REMOVE_SIZE = 14;
|
||||||
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
|
|
||||||
|
private final Friend friend;
|
||||||
|
private final Consumer<Friend> onRemove;
|
||||||
|
private final TextFieldWidget nickField;
|
||||||
|
|
||||||
|
public FriendWidget(Friend friend, int x, int y, int w, int h, Consumer<Friend> onRemove) {
|
||||||
|
super(x, y, w, h);
|
||||||
|
this.friend = friend;
|
||||||
|
this.onRemove = onRemove;
|
||||||
|
|
||||||
|
this.nickField = new TextFieldWidget(() -> "sputnik.ui.friends.nickplaceholder", 0, 0, 0, 14)
|
||||||
|
.maxLength(32)
|
||||||
|
.onSubmit(nick -> FriendManager.INSTANCE.rename(friend, nick));
|
||||||
|
}
|
||||||
|
|
||||||
|
// recalcula la posición/tamaño cada frame, para que la rejilla se adapte al ancho de pantalla
|
||||||
|
public void updateBounds(int x, int y, int w, int h) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.w = w;
|
||||||
|
this.h = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) {
|
||||||
|
boolean hovered = isHovered(mouseX, mouseY);
|
||||||
|
gui.fill(x, y, x + w, y + h, hovered ? Colors.buttonColor.brighter().getRGB() : Colors.buttonColor.getRGB());
|
||||||
|
|
||||||
|
int headX = x + PADDING;
|
||||||
|
int headY = y + (h - HEAD_SIZE) / 2;
|
||||||
|
drawHead(gui, headX, headY);
|
||||||
|
|
||||||
|
int textX = headX + HEAD_SIZE + 8;
|
||||||
|
int textW = x + w - REMOVE_SIZE - 10 - textX;
|
||||||
|
|
||||||
|
gui.text(mc.font, friend.getName(), textX, y + 6, -1, true);
|
||||||
|
|
||||||
|
int nickY = y + 6 + mc.font.lineHeight + 2;
|
||||||
|
if (nickField.isFocused()) {
|
||||||
|
nickField.setX(textX);
|
||||||
|
nickField.setY(nickY);
|
||||||
|
nickField.setW(textW);
|
||||||
|
nickField.render(gui, mouseX, mouseY, delta);
|
||||||
|
} else {
|
||||||
|
gui.text(mc.font, friend.getDisplayName(), textX, nickY, Colors.mainColor.getRGB(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
String date = DATE_FORMAT.format(new Date(friend.getBefriendedAt()));
|
||||||
|
gui.text(mc.font, Component.translatable("sputnik.ui.friends.befriendedon", date),
|
||||||
|
textX, y + h - mc.font.lineHeight - 5, Colors.instructionsTextColor.getRGB(), true
|
||||||
|
);
|
||||||
|
|
||||||
|
String uuid = friend.getUuid().toString();
|
||||||
|
gui.text(mc.font, Component.translatable("sputnik.ui.friends.uuid", uuid),
|
||||||
|
textX, y + 24 + mc.font.lineHeight, Colors.instructionsTextColor.getRGB(), true
|
||||||
|
);
|
||||||
|
|
||||||
|
drawRemoveButton(gui, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawHead(GuiGraphicsExtractor gui, int hx, int hy) {
|
||||||
|
PlayerInfo info = friend.getPlayerInfo();
|
||||||
|
if (info != null) {
|
||||||
|
PlayerFaceExtractor.extractRenderState(gui, info.getSkin(), hx, hy, HEAD_SIZE, -1);
|
||||||
|
} else {
|
||||||
|
// sin conexión al jugador (offline / no en el mismo server): placeholder gris
|
||||||
|
gui.fill(hx, hy, hx + HEAD_SIZE, hy + HEAD_SIZE, Colors.panelBgColor.getRGB());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawRemoveButton(GuiGraphicsExtractor gui, int mouseX, int mouseY) {
|
||||||
|
int rx = x + w - REMOVE_SIZE - 5;
|
||||||
|
int ry = y + 5;
|
||||||
|
boolean hovered = isRemoveHovered(mouseX, mouseY);
|
||||||
|
|
||||||
|
gui.fill(rx, ry, rx + REMOVE_SIZE, ry + REMOVE_SIZE,
|
||||||
|
hovered ? new Color(200, 60, 60).brighter().getRGB() : new Color(150, 40, 40).getRGB());
|
||||||
|
gui.text(mc.font, "x", rx + REMOVE_SIZE / 2 - 2, ry + REMOVE_SIZE / 2 - mc.font.lineHeight / 2, -1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||||
|
if (button == 0 && isRemoveHovered(mouseX, mouseY)) {
|
||||||
|
onRemove.accept(friend);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nickField.isFocused()) {
|
||||||
|
nickField.mouseClicked(mouseX, mouseY, button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button == 0 && isNickHovered(mouseX, mouseY)) {
|
||||||
|
nickField.setText(friend.getDisplayName());
|
||||||
|
nickField.setFocused(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(int mouseX, int mouseY, int button) {
|
||||||
|
nickField.mouseReleased(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onKey(int key, int action) {
|
||||||
|
if (nickField.isFocused()) nickField.onKey(key, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCapturingInput() {
|
||||||
|
return nickField.isFocused();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isNickHovered(int mouseX, int mouseY) {
|
||||||
|
int textX = x + PADDING + HEAD_SIZE + 8;
|
||||||
|
int nickY = y + 6 + mc.font.lineHeight + 2;
|
||||||
|
return mouseX >= textX && mouseX < x + w - REMOVE_SIZE - 10
|
||||||
|
&& mouseY >= nickY && mouseY < nickY + 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isRemoveHovered(int mouseX, int mouseY) {
|
||||||
|
int rx = x + w - REMOVE_SIZE - 5;
|
||||||
|
int ry = y + 5;
|
||||||
|
return mouseX >= rx && mouseX < rx + REMOVE_SIZE && mouseY >= ry && mouseY < ry + REMOVE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isHovered(int mouseX, int mouseY) {
|
||||||
|
return mouseX >= x && mouseX < x + w && mouseY >= y && mouseY < y + h;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Friend getFriend() {
|
||||||
|
return friend;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -111,6 +111,11 @@ public class TextFieldWidget extends Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getText() { return buffer.toString(); }
|
public String getText() { return buffer.toString(); }
|
||||||
|
public void setText(String text) {
|
||||||
|
buffer.setLength(0);
|
||||||
|
buffer.append(text.length() > maxLength ? text.substring(0, maxLength) : text);
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() { buffer.setLength(0); }
|
public void clear() { buffer.setLength(0); }
|
||||||
|
|
||||||
public boolean isFocused() { return focused; }
|
public boolean isFocused() { return focused; }
|
||||||
|
|||||||
@@ -1,143 +0,0 @@
|
|||||||
package me.retucio.sputnik.ui.widgets.panels;
|
|
||||||
|
|
||||||
import com.github.retucio.neutrino.EventListener;
|
|
||||||
import me.retucio.sputnik.Sputnik;
|
|
||||||
import me.retucio.sputnik.event.sputnik.FriendEvent;
|
|
||||||
import me.retucio.sputnik.event.sputnik.FriendPanelEvent;
|
|
||||||
import me.retucio.sputnik.friend.Friend;
|
|
||||||
import me.retucio.sputnik.friend.FriendManager;
|
|
||||||
import me.retucio.sputnik.ui.screen.ClickGui;
|
|
||||||
import me.retucio.sputnik.ui.widgets.buttons.FriendButton;
|
|
||||||
import me.retucio.sputnik.util.Colors;
|
|
||||||
import me.retucio.sputnik.util.I18nUtil;
|
|
||||||
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class FriendsPanel extends ExtendablePanel<FriendButton> {
|
|
||||||
|
|
||||||
private int offset;
|
|
||||||
|
|
||||||
public FriendsPanel(int x, int y, int w, int h) {
|
|
||||||
super(() -> I18nUtil.orElse("sputnik.ui.friends.title", "amigos"), x, y, w, h);
|
|
||||||
dragging = false;
|
|
||||||
|
|
||||||
Sputnik.EVENT_BUS.subscribe(this);
|
|
||||||
|
|
||||||
offset = h;
|
|
||||||
for (Friend friend : FriendManager.INSTANCE.getFriends()) {
|
|
||||||
buttons.add(new FriendButton(friend, this, offset));
|
|
||||||
offset += h;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateWidth() {
|
|
||||||
int maxWidth = mc.font.width(getTitle()) + mc.font.width(" +");
|
|
||||||
for (FriendButton button : buttons) {
|
|
||||||
int textWidth = mc.font.width(button.getFriend().getName());
|
|
||||||
maxWidth = Math.max(maxWidth, textWidth);
|
|
||||||
}
|
|
||||||
this.w = maxWidth + 22;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) {
|
|
||||||
updateWidth();
|
|
||||||
gui.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB());
|
|
||||||
|
|
||||||
gui.text(mc.font, Component.literal(getTitle()),
|
|
||||||
x + 8,
|
|
||||||
renderY + (h / 2) - (mc.font.lineHeight / 2),
|
|
||||||
-1, true);
|
|
||||||
|
|
||||||
drawExpandCollapse(gui, mouseX, mouseY);
|
|
||||||
|
|
||||||
List<FriendButton> visibleButtons = buttons.stream()
|
|
||||||
.filter(fb -> fb.getFriend().isSearchMatch())
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (extended) {
|
|
||||||
totalHeight = visibleButtons.size() * h + 3;
|
|
||||||
gui.fill(x, renderY + h + 1, x + w, renderY + h + totalHeight, Colors.panelBgColor.getRGB());
|
|
||||||
|
|
||||||
int buttonY = renderY + h + 1;
|
|
||||||
for (FriendButton friendButton : visibleButtons) {
|
|
||||||
friendButton.setOffset(buttonY - renderY);
|
|
||||||
friendButton.render(gui, mouseX, mouseY, delta);
|
|
||||||
buttonY += h;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
totalHeight = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
|
||||||
if (isHovered(mouseX, mouseY) && ClickGui.INSTANCE.trySelect(this)) {
|
|
||||||
if (button == 0) {
|
|
||||||
dragging = true;
|
|
||||||
dragX = mouseX - x;
|
|
||||||
dragY = mouseY - y;
|
|
||||||
} else if (button == 1) {
|
|
||||||
toggleExtended();
|
|
||||||
Sputnik.EVENT_BUS.post(new FriendPanelEvent.Extend());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!extended) return;
|
|
||||||
|
|
||||||
List<FriendButton> visibleFriendButtons = buttons.stream()
|
|
||||||
.filter(fb -> fb.getFriend().isSearchMatch())
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
for (FriendButton friendButton : visibleFriendButtons) {
|
|
||||||
friendButton.mouseClicked(mouseX, mouseY, button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(int mouseX, int mouseY, int button) {
|
|
||||||
ClickGui.INSTANCE.unselect(this);
|
|
||||||
if (button == 0 && dragging) dragging = false;
|
|
||||||
|
|
||||||
List<FriendButton> visibleFriendButtons = buttons.stream()
|
|
||||||
.filter(fb -> fb.getFriend().isSearchMatch())
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
for (FriendButton friendButton : visibleFriendButtons) {
|
|
||||||
if (friendButton.isHovered(mouseX, mouseY))
|
|
||||||
friendButton.mouseReleased(mouseX, mouseY, button);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isHovered(mouseX, mouseY))
|
|
||||||
Sputnik.EVENT_BUS.post(new FriendPanelEvent.Move());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updatePosition(double mouseX, double mouseY) {
|
|
||||||
if (dragging) {
|
|
||||||
x = (int) (mouseX - dragX);
|
|
||||||
y = (int) (mouseY - dragY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventListener
|
|
||||||
private void onAddFriend(FriendEvent.Add event) {
|
|
||||||
buttons.add(new FriendButton(event.getFriend(), this, offset));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventListener
|
|
||||||
private void onRemoveFriend(FriendEvent.Remove event) {
|
|
||||||
buttons.remove(getButtonOfFriend(event.getFriend()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public FriendButton getButtonOfFriend(Friend friend) {
|
|
||||||
for (FriendButton button : buttons) {
|
|
||||||
if (button.getFriend().getUuid().equals(friend.getUuid()))
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ import me.retucio.sputnik.module.setting.settings.*;
|
|||||||
import me.retucio.sputnik.ui.widgets.buttons.settings.*;
|
import me.retucio.sputnik.ui.widgets.buttons.settings.*;
|
||||||
import me.retucio.sputnik.ui.screen.ClickGui;
|
import me.retucio.sputnik.ui.screen.ClickGui;
|
||||||
import me.retucio.sputnik.ui.widgets.buttons.*;
|
import me.retucio.sputnik.ui.widgets.buttons.*;
|
||||||
import me.retucio.sputnik.ui.widgets.Panel;
|
|
||||||
import me.retucio.sputnik.util.Colors;
|
import me.retucio.sputnik.util.Colors;
|
||||||
import me.retucio.sputnik.util.I18nUtil;
|
import me.retucio.sputnik.util.I18nUtil;
|
||||||
|
|
||||||
@@ -43,6 +42,7 @@ public class SettingsPanel extends CloseablePanel<SettingButton<? extends Settin
|
|||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) {
|
public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) {
|
||||||
updateWidth();
|
updateWidth();
|
||||||
|
updateTotalHeight();
|
||||||
|
|
||||||
int centerX = x + w / 2;
|
int centerX = x + w / 2;
|
||||||
int centerY = renderY + h / 2;
|
int centerY = renderY + h / 2;
|
||||||
@@ -77,31 +77,8 @@ public class SettingsPanel extends CloseablePanel<SettingButton<? extends Settin
|
|||||||
int descBoxTop = renderY + h + PADDING;
|
int descBoxTop = renderY + h + PADDING;
|
||||||
int descBoxBottom = descBoxTop + descHeight + PADDING * 2;
|
int descBoxBottom = descBoxTop + descHeight + PADDING * 2;
|
||||||
|
|
||||||
totalHeight = descHeight + 3 * PADDING;
|
|
||||||
int currentY;
|
int currentY;
|
||||||
|
|
||||||
// obtener valores de altura y tal
|
|
||||||
for (SettingGroup group : settingGroups) {
|
|
||||||
if (hasVisibleSettingsInGroup(group)) {
|
|
||||||
totalHeight += h + PADDING;
|
|
||||||
|
|
||||||
if (group.isExtended()) {
|
|
||||||
List<SettingButton<?>> groupButtons = getButtonsForGroup(group);
|
|
||||||
for (int j = 0; j < groupButtons.size(); j++) {
|
|
||||||
SettingButton<?> sb = groupButtons.get(j);
|
|
||||||
if (sb.getSetting().isVisible() && sb.getSetting().isSearchMatch()) {
|
|
||||||
if (j < groupButtons.size() - 1) {
|
|
||||||
totalHeight += (h - h / 4) + PADDING;
|
|
||||||
} else {
|
|
||||||
totalHeight += (h - h / 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
totalHeight += PADDING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fondo del marco
|
// fondo del marco
|
||||||
gui.fill(x, descBoxTop - PADDING + 1, x + w, descBoxTop + totalHeight, Colors.panelBgColor.getRGB());
|
gui.fill(x, descBoxTop - PADDING + 1, x + w, descBoxTop + totalHeight, Colors.panelBgColor.getRGB());
|
||||||
|
|
||||||
@@ -112,10 +89,9 @@ public class SettingsPanel extends CloseablePanel<SettingButton<? extends Settin
|
|||||||
currentY = descBoxBottom + PADDING;
|
currentY = descBoxBottom + PADDING;
|
||||||
|
|
||||||
// dibujar botones y cabezales
|
// dibujar botones y cabezales
|
||||||
for (int i = 0; i < settingGroups.size(); i++) {
|
for (SettingGroup group : settingGroups) {
|
||||||
SettingGroup group = settingGroups.get(i);
|
|
||||||
if (hasVisibleSettingsInGroup(group)) {
|
if (hasVisibleSettingsInGroup(group)) {
|
||||||
int groupHeaderColor = isGroupHeaderHovered(mouseX, mouseY, i)
|
int groupHeaderColor = isGroupHeaderHovered(mouseX, mouseY, group)
|
||||||
? Colors.buttonColor.brighter().getRGB()
|
? Colors.buttonColor.brighter().getRGB()
|
||||||
: Colors.buttonColor.getRGB();
|
: Colors.buttonColor.getRGB();
|
||||||
|
|
||||||
@@ -176,9 +152,8 @@ public class SettingsPanel extends CloseablePanel<SettingButton<? extends Settin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < settingGroups.size(); i++) {
|
for (SettingGroup group : settingGroups) {
|
||||||
SettingGroup group = settingGroups.get(i);
|
if (hasVisibleSettingsInGroup(group) && isGroupHeaderHovered(mouseX, mouseY, group)) {
|
||||||
if (hasVisibleSettingsInGroup(group) && isGroupHeaderHovered(mouseX, mouseY, i)) {
|
|
||||||
group.setExtended(!group.isExtended());
|
group.setExtended(!group.isExtended());
|
||||||
updateVisibleButtonsForGroup(group);
|
updateVisibleButtonsForGroup(group);
|
||||||
return;
|
return;
|
||||||
@@ -239,6 +214,36 @@ public class SettingsPanel extends CloseablePanel<SettingButton<? extends Settin
|
|||||||
this.w = maxWidth + 30;
|
this.w = maxWidth + 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateTotalHeight() {
|
||||||
|
List<String> descLines = wrapDescription(module.getDisplayDescription(), w - 2 * PADDING);
|
||||||
|
int descHeight = descLines.size() * mc.font.lineHeight + (descLines.size() - 1) * 2;
|
||||||
|
|
||||||
|
int height = descHeight + 3 * PADDING;
|
||||||
|
|
||||||
|
for (SettingGroup group : settingGroups) {
|
||||||
|
if (!hasVisibleSettingsInGroup(group)) continue;
|
||||||
|
|
||||||
|
height += h + PADDING;
|
||||||
|
|
||||||
|
if (group.isExtended()) {
|
||||||
|
List<SettingButton<?>> groupButtons = getButtonsForGroup(group);
|
||||||
|
for (int j = 0; j < groupButtons.size(); j++) {
|
||||||
|
SettingButton<?> sb = groupButtons.get(j);
|
||||||
|
if (sb.getSetting().isVisible() && sb.getSetting().isSearchMatch()) {
|
||||||
|
if (j < groupButtons.size() - 1) {
|
||||||
|
height += (h - h / 4) + PADDING;
|
||||||
|
} else {
|
||||||
|
height += (h - h / 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
height += PADDING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
totalHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
public void updatePosition(double mouseX, double mouseY) {
|
public void updatePosition(double mouseX, double mouseY) {
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
x = (int) (mouseX - dragX);
|
x = (int) (mouseX - dragX);
|
||||||
@@ -246,44 +251,40 @@ public class SettingsPanel extends CloseablePanel<SettingButton<? extends Settin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGroupHeaderY(int groupIndex) {
|
public int getGroupHeaderY(SettingGroup targetGroup) {
|
||||||
int currentY = renderY + h + PADDING;
|
int currentY = renderY + h + PADDING;
|
||||||
List<String> descLines = wrapDescription(module.getDisplayDescription(), w - 2 * PADDING);
|
List<String> descLines = wrapDescription(module.getDisplayDescription(), w - 2 * PADDING);
|
||||||
int descHeight = descLines.size() * mc.font.lineHeight + (descLines.size() - 1) * 2;
|
int descHeight = descLines.size() * mc.font.lineHeight + (descLines.size() - 1) * 2;
|
||||||
currentY += descHeight + 3 * PADDING; // descBoxBottom + padding
|
currentY += descHeight + 3 * PADDING; // descBoxBottom + padding
|
||||||
|
|
||||||
// iterar hasta llegar al grupo deseado
|
|
||||||
int currentIndex = 0;
|
|
||||||
for (SettingGroup group : settingGroups) {
|
for (SettingGroup group : settingGroups) {
|
||||||
if (hasVisibleSettingsInGroup(group)) {
|
if (!hasVisibleSettingsInGroup(group)) continue;
|
||||||
if (currentIndex == groupIndex) {
|
if (group == targetGroup) {
|
||||||
return currentY;
|
return currentY;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentY += h + PADDING;
|
currentY += h + PADDING;
|
||||||
|
|
||||||
if (group.isExtended()) {
|
if (group.isExtended()) {
|
||||||
List<SettingButton<?>> groupButtons = getButtonsForGroup(group);
|
List<SettingButton<?>> groupButtons = getButtonsForGroup(group);
|
||||||
for (int j = 0; j < groupButtons.size(); j++) {
|
for (int j = 0; j < groupButtons.size(); j++) {
|
||||||
SettingButton<?> sb = groupButtons.get(j);
|
SettingButton<?> sb = groupButtons.get(j);
|
||||||
if (sb.getSetting().isVisible() && sb.getSetting().isSearchMatch()) {
|
if (sb.getSetting().isVisible() && sb.getSetting().isSearchMatch()) {
|
||||||
if (j < groupButtons.size() - 1) {
|
if (j < groupButtons.size() - 1) {
|
||||||
currentY += (h - h / 4) + PADDING;
|
currentY += (h - h / 4) + PADDING;
|
||||||
} else {
|
} else {
|
||||||
currentY += (h - h / 4);
|
currentY += (h - h / 4);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentY += PADDING;
|
|
||||||
}
|
}
|
||||||
currentIndex++;
|
currentY += PADDING;
|
||||||
}
|
}
|
||||||
} // fallback
|
} // fallback
|
||||||
return currentY;
|
return currentY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGroupHeaderHovered(int mouseX, int mouseY, int groupIndex) {
|
public boolean isGroupHeaderHovered(int mouseX, int mouseY, SettingGroup group) {
|
||||||
int headerY = getGroupHeaderY(groupIndex);
|
int headerY = getGroupHeaderY(group);
|
||||||
|
|
||||||
return mouseX > x + PADDING && mouseX < x + w - PADDING &&
|
return mouseX > x + PADDING && mouseX < x + w - PADDING &&
|
||||||
mouseY > headerY && mouseY < headerY + h;
|
mouseY > headerY && mouseY < headerY + h;
|
||||||
|
|||||||
@@ -1,102 +0,0 @@
|
|||||||
package me.retucio.sputnik.ui.widgets.panels.settings;
|
|
||||||
|
|
||||||
import me.retucio.sputnik.config.ConfigManager;
|
|
||||||
import me.retucio.sputnik.friend.Friend;
|
|
||||||
import me.retucio.sputnik.friend.FriendManager;
|
|
||||||
import me.retucio.sputnik.module.Category;
|
|
||||||
import me.retucio.sputnik.module.Module;
|
|
||||||
import me.retucio.sputnik.module.ModuleManager;
|
|
||||||
import me.retucio.sputnik.module.modules.client.Friends;
|
|
||||||
import me.retucio.sputnik.module.setting.settings.StringSetting;
|
|
||||||
import me.retucio.sputnik.ui.screen.ClickGui;
|
|
||||||
import me.retucio.sputnik.ui.widgets.buttons.settings.TextButton;
|
|
||||||
import me.retucio.sputnik.ui.widgets.panels.SettingsPanel;
|
|
||||||
import me.retucio.sputnik.util.Colors;
|
|
||||||
import me.retucio.sputnik.util.I18nUtil;
|
|
||||||
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
|
||||||
|
|
||||||
|
|
||||||
public class FriendSettingsPanel extends SettingsPanel {
|
|
||||||
|
|
||||||
private final Friend friend;
|
|
||||||
private final StringSetting nickname;
|
|
||||||
public final Module dummyModule;
|
|
||||||
|
|
||||||
private int removeButtonY;
|
|
||||||
|
|
||||||
public FriendSettingsPanel(Friend friend, int x, int y, int w, int h) {
|
|
||||||
super(ModuleManager.INSTANCE.getModuleByClass(Friends.class), x, y, w, h);
|
|
||||||
|
|
||||||
this.friend = friend;
|
|
||||||
|
|
||||||
dummyModule = new Module(friend.getName(),
|
|
||||||
I18nUtil.orElse("sputnik.ui.friend.manage", "gestiona a " + friend.getName(), friend.getName()),
|
|
||||||
Category.CLIENT) {
|
|
||||||
@Override public void onEnable() {}
|
|
||||||
@Override public void onDisable() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
dummyModule.getSettings().forEach(s -> s.visibility(false));
|
|
||||||
dummyModule.shouldSaveSettings(false);
|
|
||||||
|
|
||||||
setModule(dummyModule);
|
|
||||||
|
|
||||||
// clave a mano: el módulo es un dummy con el nombre del jugador, así que la clave
|
|
||||||
// derivada dependería de él y no existiría nunca en el lang
|
|
||||||
nickname = new StringSetting("nombre", "con qué nombre guardar al amigo", friend.getName(), 40)
|
|
||||||
.translationKey("sputnik.setting.friend.nickname");
|
|
||||||
dummyModule.getSgGeneral().add(nickname);
|
|
||||||
nickname.onUpdate(name -> {
|
|
||||||
friend.setName(name);
|
|
||||||
ConfigManager.INSTANCE.getConfig().friends.put(friend.getUuid().toString(), name);
|
|
||||||
ConfigManager.INSTANCE.save();
|
|
||||||
});
|
|
||||||
|
|
||||||
buttons.clear();
|
|
||||||
addButton(new TextButton(nickname, this, h));
|
|
||||||
|
|
||||||
setSettingGroups(dummyModule.getSgs());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(GuiGraphicsExtractor gui, int mx, int my, float delta) {
|
|
||||||
super.render(gui, mx, my, delta);
|
|
||||||
|
|
||||||
removeButtonY = renderY + h + totalHeight + PADDING;
|
|
||||||
int buttonH = h - h / 4;
|
|
||||||
|
|
||||||
gui.fill(x, removeButtonY, x + w, removeButtonY + buttonH + PADDING, Colors.panelBgColor.getRGB());
|
|
||||||
|
|
||||||
int color = isRemoveButtonHovered(mx, my)
|
|
||||||
? Colors.disabledToggleButtonColor.brighter().getRGB()
|
|
||||||
: Colors.disabledToggleButtonColor.getRGB();
|
|
||||||
|
|
||||||
gui.fill(x + PADDING, removeButtonY, x + w - PADDING, removeButtonY + buttonH, color);
|
|
||||||
|
|
||||||
String label = I18nUtil.orElse("sputnik.ui.friend.remove", "eliminar amigo");
|
|
||||||
gui.text(mc.font, label,
|
|
||||||
x + w / 2 - mc.font.width(label) / 2,
|
|
||||||
removeButtonY + (buttonH - mc.font.lineHeight) / 2,
|
|
||||||
-1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
|
||||||
super.mouseClicked(mouseX, mouseY, button);
|
|
||||||
|
|
||||||
if (button == 0 && isRemoveButtonHovered(mouseX, mouseY)) {
|
|
||||||
FriendManager.INSTANCE.remove(friend);
|
|
||||||
ClickGui.INSTANCE.closeSettingsPanel(dummyModule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isRemoveButtonHovered(int mouseX, int mouseY) {
|
|
||||||
int buttonH = h - h / 4;
|
|
||||||
return mouseX > x + PADDING && mouseX < x + w - PADDING
|
|
||||||
&& mouseY > removeButtonY && mouseY < removeButtonY + buttonH;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Friend getFriend() {
|
|
||||||
return friend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1665,5 +1665,10 @@
|
|||||||
"sputnik.version.info.dev": "mod in a development state: v%s",
|
"sputnik.version.info.dev": "mod in a development state: v%s",
|
||||||
"sputnik.version.info.uptodate": "the mod is up to date: v%s",
|
"sputnik.version.info.uptodate": "the mod is up to date: v%s",
|
||||||
"sputnik.version.warn.check": "could not check whether the mod is up to date: %s",
|
"sputnik.version.warn.check": "could not check whether the mod is up to date: %s",
|
||||||
"sputnik.version.warn.metadata": "could not build gradle.properties from the metadata"
|
"sputnik.version.warn.metadata": "could not build gradle.properties from the metadata",
|
||||||
|
"sputnik.ui.friends.nickplaceholder": "nickname...",
|
||||||
|
"sputnik.ui.friends.befriendedon": "friends since %s",
|
||||||
|
"sputnik.ui.friends.removed": "you now hate %s",
|
||||||
|
"sputnik.ui.friends.empty": "you don't have any friends loser",
|
||||||
|
"sputnik.ui.friends.uuid": "UUID: %s"
|
||||||
}
|
}
|
||||||
@@ -1665,5 +1665,10 @@
|
|||||||
"sputnik.version.info.dev": "mod en estado de desarrollo: v%s",
|
"sputnik.version.info.dev": "mod en estado de desarrollo: v%s",
|
||||||
"sputnik.version.info.uptodate": "el mod está al día: v%s",
|
"sputnik.version.info.uptodate": "el mod está al día: v%s",
|
||||||
"sputnik.version.warn.check": "no se pudo comprobar si el mod está actualizado: %s",
|
"sputnik.version.warn.check": "no se pudo comprobar si el mod está actualizado: %s",
|
||||||
"sputnik.version.warn.metadata": "no se pudo construir gradle.properties desde la metadata"
|
"sputnik.version.warn.metadata": "no se pudo construir gradle.properties desde la metadata",
|
||||||
|
"sputnik.ui.friends.nickplaceholder": "apodo...",
|
||||||
|
"sputnik.ui.friends.befriendedon": "amigos desde %s",
|
||||||
|
"sputnik.ui.friends.removed": "%s ya no es tu amigo",
|
||||||
|
"sputnik.ui.friends.empty": "no tienes amigos jajsjsjs",
|
||||||
|
"sputnik.ui.friends.uuid": "UUID: %s"
|
||||||
}
|
}
|
||||||