Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac7de7a07a | ||
|
|
0bd31971a0 | ||
|
|
3010b164ab | ||
|
|
6cb4656365 | ||
|
|
272c1059ef | ||
|
|
e0f8523809 | ||
|
|
81fc25c33d | ||
|
|
81b043270b | ||
|
|
3913b31374 | ||
|
|
aeadfb28b1 | ||
|
|
957fab15aa | ||
|
|
321505657c | ||
|
|
b2bc2b36ab | ||
|
|
09ed268576 | ||
|
|
531c3ef9aa | ||
|
|
67cc34a08c | ||
|
|
c7b8e96d68 | ||
|
|
65afbf6ae6 | ||
|
|
8933565e07 | ||
|
|
47ad2c67c5 | ||
|
|
e84382367e | ||
|
|
ac99a609a0 | ||
|
|
1d22ec5176 | ||
|
|
05c5300cd8 | ||
|
|
a879458b4a | ||
|
|
bab752c589 | ||
|
|
4d30a16a6a | ||
|
|
412fe93a89 | ||
|
|
acecda3c0d | ||
|
|
ad0349aa29 | ||
|
|
f1eed6f957 | ||
|
|
c993d4fdac | ||
|
|
a9fd8da7f5 | ||
|
|
9b6d037b6c | ||
|
|
86594f1ca3 | ||
|
|
f074f05c51 | ||
|
|
436b79fd2b | ||
|
|
9afaa4e0c8 | ||
|
|
f794457538 | ||
|
|
ec3e633cec | ||
|
|
8f17bd8e67 |
No files matched your search
@@ -17,7 +17,7 @@ jobs:
|
||||
- name: setup jdk
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
java-version: '25'
|
||||
distribution: 'microsoft'
|
||||
- name: make gradle wrapper executable
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
+2
-1
@@ -43,4 +43,5 @@ replay_*.log
|
||||
|
||||
todo.txt
|
||||
cambios.md
|
||||
remappedSrc/
|
||||
remappedSrc/
|
||||
.claude/
|
||||
@@ -1,29 +1,29 @@
|
||||
# jenny's mod 2 100% real
|
||||
|
||||
mod para Minecraft Fabric 1.21.10 que añade algunas cosas QOL, mayormente relacionadas a la cámara.
|
||||
mod para Minecraft Fabric 26.2 que añade algunas cosas QOL, mayormente relacionadas a la cámara.
|
||||
|
||||
## instalación
|
||||
|
||||
### para gente normal:
|
||||
1. ir a [lanzamientos](https://github.com/retuci0/camera-tweaks/releases)
|
||||
1. ir a [lanzamientos](https://codeberg.org/retucio/sputnik/releases)
|
||||
2. selecionar la versión más reciente
|
||||
3. descargar el .jar
|
||||
4. moverlo a tu directorio de mods (probablemente `%appdata%/.minecraft/mods`)
|
||||
|
||||
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `1.21.10`; Fabric `0.138.3`)
|
||||
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `26.2`; Fabric `0.19.3`)
|
||||
es posible que haya problemas al usarlo junto a otros mods, especialmente junto a otros clientes, pues pueden conflictar entre ellos.
|
||||
|
||||
### para frikis de 200 de iq
|
||||
1. clona el respositorio (`git clone https://github.com/retuci0/camera-tweaks`)
|
||||
2. entra al directorio del repositorio (`cd camera-tweaks`)
|
||||
1. clona el respositorio (`git clone https://github.com/retuci0/sputnik`)
|
||||
2. entra al directorio del repositorio (`cd sputnik`)
|
||||
3. `gradlew build` para Windows o `chmod +x gradlew` + `./gradlew build` para Linux (Mac es Linux)
|
||||
4. el resultado estará en `/build/libs/camtweaks-X.X.jar` (el que no lleva "sources" en el nombre)
|
||||
4. el resultado estará en `/build/libs/sputnik-X.X.jar` (el que no lleva "sources" en el nombre)
|
||||
|
||||
## uso
|
||||
|
||||
`shift derecho` por defecto para abrir la interfaz
|
||||
|
||||
`pág. arriba` por defecto para abrir el editor del hud
|
||||
`insertar` por defecto para abrir el editor del hud
|
||||
|
||||
`$` como prefijo por defecto para comandos (se autocompletan)
|
||||
|
||||
@@ -56,7 +56,7 @@ algunos módulos tienen teclas asignadas por defecto, asígnales `ESC` para desa
|
||||
<img src="screenshots/hudeditor.png" alt="editor de HUD">
|
||||
<img src="screenshots/colorpicker.png" alt="selector de colores">
|
||||
|
||||
## contibuciones
|
||||
## contribuciones
|
||||
|
||||
sí por favor
|
||||
|
||||
|
||||
+49
-45
@@ -1,81 +1,85 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version "${loom_version}"
|
||||
id 'maven-publish'
|
||||
id "net.fabricmc.fabric-loom" version "${loom_version}"
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven {
|
||||
name = "FDD Maven"
|
||||
url = "https://maven.firstdark.dev/releases"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// To change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
// mc
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
|
||||
// fabric & su api
|
||||
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
||||
|
||||
// sistema de eventos
|
||||
include(implementation "com.github.retuci0:neutrino:${project.neutrino_version}")
|
||||
|
||||
// rpc de discord
|
||||
include(implementation "dev.firstdark.discordrpc:discord-rpc:${project.discord_rpc_version}")
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/camtweaks.accesswidener")
|
||||
accessWidenerPath = file("src/main/resources/sputnik.accesswidener")
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
inputs.property "version", project.version
|
||||
inputs.property "loader_version", project.loader_version
|
||||
inputs.property "minecraft_version", project.minecraft_version
|
||||
inputs.property "jdk_version", project.jdk_version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": inputs.properties.version
|
||||
}
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand(
|
||||
"version": project.version,
|
||||
"loader_version": project.loader_version,
|
||||
"minecraft_version": project.minecraft_version,
|
||||
"jdk_version": project.jdk_version
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.release = 21
|
||||
it.options.release = jdk_version.toInteger()
|
||||
}
|
||||
|
||||
java {
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
sourceCompatibility = JavaVersion.toVersion(jdk_version)
|
||||
targetCompatibility = JavaVersion.toVersion(jdk_version)
|
||||
}
|
||||
|
||||
jar {
|
||||
inputs.property "archivesName", project.base.archivesName
|
||||
inputs.property "archivesName", project.base.archivesName
|
||||
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${inputs.properties.archivesName}"}
|
||||
}
|
||||
from("LICENSE") {
|
||||
rename {
|
||||
"${it}_${inputs.properties.archivesName}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
create("mavenJava", MavenPublication) {
|
||||
artifactId = project.archives_base_name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
publications {
|
||||
create("mavenJava", MavenPublication) {
|
||||
artifactId = project.archives_base_name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
// Notice: This block does NOT have the same function as the block in the top level.
|
||||
// The repositories here will be used for publishing your artifact, not for
|
||||
// retrieving dependencies.
|
||||
}
|
||||
repositories {}
|
||||
}
|
||||
+10
-13
@@ -1,26 +1,23 @@
|
||||
# v2.2
|
||||
# v6.1
|
||||
|
||||
## novedades
|
||||
|
||||
- elementos del hud con imágenes
|
||||
|
||||
### adiciones
|
||||
|
||||
- elementos del hud de dinosaurios (autismaxxing), echest (items del echest) y totems (totems restantes en el inventario)
|
||||
|
||||
#### módulos nuevos:
|
||||
|
||||
- conejo: haz el elytra-bounce más fácilmente
|
||||
- físicas de items: aplica físicas "realistas" a los items del suelo
|
||||
|
||||
#### elementos del HUD nuevos:
|
||||
|
||||
- velocidad: velocidad del jugador
|
||||
|
||||
### arreglos / mejoras
|
||||
|
||||
- ya no te puedes mover con una interfaz abierta en modo cámara libre
|
||||
- minar sin interrupción ya va
|
||||
- destello de enchants ya funciona
|
||||
- ahora no siempre se verá a traves de paredes al renderizar (ej.: superposición de luz)
|
||||
- el renderizado de líneas ya se adapta bien a la posición de la cámara
|
||||
- la superposición de daño ya funciona
|
||||
- killaura ya no te echa por exceder el límite de paquetes
|
||||
- el mj bridge de andamios ya funciona correctamente al no usarse en el aire
|
||||
- ahora no hace falta volver a clicar cada vez que quieras cambiar de herramienta en `auto herramienta`, con el modo `cada tick`
|
||||
|
||||
## problemas reconocidos
|
||||
|
||||
- muchos, pero repórtalos en la página de problemas si quieres para que queden bien registrados
|
||||
- lo de siempre.
|
||||
+7
-2
@@ -1,4 +1,4 @@
|
||||
Meteor Client: https://github.com/MeteorDevelopment/meteor-client | https://meteorclient.com
|
||||
Meteor Client: https://github.com/MeteorDevelopment/meteor-client | https://meteorclient.com
|
||||
OyVey Port: https://github.com/mioclient/oyvey-ported/
|
||||
Lenny Boi: https://www.youtube.com/@lennyboi7195
|
||||
Shotify: https://modrinth.com/mod/shotify
|
||||
@@ -7,6 +7,11 @@ Trouser Streak: https://github.com/etianl/Trouser-Streak
|
||||
No More Purple: https://github.com/Pepperoni-Jabroni/NoMorePurple/
|
||||
bypass-resource-pack: https://github.com/emilyy-dev/bypass-resource-pack
|
||||
elytra-recast: https://github.com/InLieuOfLuna/elytra-recast/
|
||||
SpearHax: https://github.com/etianl/spearHax/
|
||||
ProjectileTrajectoryPreview: https://github.com/maDU59/ProjectilesTrajectoryPreview
|
||||
DupersUnited public addon: https://discord.gg/dupes | https://dupers.wtf
|
||||
Stardust: https://github.com/0xTas/stardust/
|
||||
|
||||
probablemente más pero como tengo demencia se me olvida
|
||||
si quieres que te acredite o quite tu código de mi mod, mándame un mensaje en discord (username: retucio) y sin problemas :)
|
||||
si quieres que te acredite o quite tu código de mi mod, mándame un mensaje en discord (username: retucio) y sin problemas :)
|
||||
también es probable que haya créditos sueltos en forma de comentarios donde haya usado código ajeno
|
||||
+10
-8
@@ -1,13 +1,15 @@
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
|
||||
minecraft_version=1.21.11
|
||||
yarn_mappings=1.21.11+build.3
|
||||
loader_version=0.18.4
|
||||
loom_version=1.13-SNAPSHOT
|
||||
minecraft_version=26.2
|
||||
loader_version=0.19.3
|
||||
loom_version=1.17-SNAPSHOT
|
||||
|
||||
fabric_api_version=0.140.2+1.21.11
|
||||
fabric_api_version=0.154.0+26.2
|
||||
discord_rpc_version=1.0.3
|
||||
neutrino_version=1.1.0
|
||||
jdk_version=25
|
||||
|
||||
mod_version=2.2
|
||||
mod_version=6.1
|
||||
maven_group=me.retucio
|
||||
archives_base_name=camtweaks
|
||||
archives_base_name=sputnik
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
Whitespace-only changes.
@@ -1,241 +0,0 @@
|
||||
package me.retucio.camtweaks;
|
||||
|
||||
|
||||
import me.retucio.camtweaks.command.CommandManager;
|
||||
import me.retucio.camtweaks.command.commands.BindCommand;
|
||||
|
||||
import me.retucio.camtweaks.config.ConfigManager;
|
||||
|
||||
import me.retucio.camtweaks.event.EventBus;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.ShutdownEvent;
|
||||
|
||||
import me.retucio.camtweaks.event.events.camtweaks.LoadClickGUIEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.LoadCommandManagerEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.LoadModuleManagerEvent;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
|
||||
import me.retucio.camtweaks.module.modules.client.HUD;
|
||||
import me.retucio.camtweaks.ui.screen.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.hud.HudEditorScreen;
|
||||
import me.retucio.camtweaks.ui.hud.HudRenderer;
|
||||
import me.retucio.camtweaks.ui.widgets.buttons.settings.BindButton;
|
||||
import me.retucio.camtweaks.ui.widgets.buttons.SettingButton;
|
||||
import me.retucio.camtweaks.ui.widgets.buttons.settings.TextButton;
|
||||
import me.retucio.camtweaks.ui.widgets.frames.settings.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.ui.widgets.frames.SettingsFrame;
|
||||
|
||||
import me.retucio.camtweaks.ui.widgets.Button;
|
||||
import me.retucio.camtweaks.util.*;
|
||||
|
||||
|
||||
import me.retucio.camtweaks.util.render.DrawUtil;
|
||||
import me.retucio.camtweaks.util.render.RenderUtil;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ChatScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.AbstractCommandBlockScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.AnvilScreen;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
|
||||
|
||||
public class CameraTweaks implements ClientModInitializer {
|
||||
|
||||
// cosas necesarias
|
||||
public static final CameraTweaks INSTANCE = new CameraTweaks();
|
||||
public static final EventBus EVENT_BUS = new EventBus();
|
||||
public static final Logger LOGGER = LogManager.getLogger(CameraTweaks.class);
|
||||
public static MinecraftClient mc;
|
||||
|
||||
// id y versión
|
||||
public static final String MOD_ID = "camtweaks";
|
||||
public static final String MOD_VERSION;
|
||||
|
||||
static {
|
||||
MOD_VERSION = FabricLoader.getInstance().getModContainer(MOD_ID)
|
||||
.orElseThrow()
|
||||
.getMetadata()
|
||||
.getVersion()
|
||||
.getFriendlyString();
|
||||
}
|
||||
|
||||
|
||||
private Screen prevScreen;
|
||||
public static boolean settingsApplied = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// por algún motivo aunque lo añada a los args de la JVM sigue siendo true a menos que haga esto??? puta vida
|
||||
System.setProperty("java.awt.headless", "false");
|
||||
|
||||
mc = MinecraftClient.getInstance();
|
||||
ConfigManager.load();
|
||||
|
||||
EVENT_BUS.register(this);
|
||||
|
||||
EVENT_BUS.register(HudRenderer.class);
|
||||
|
||||
EVENT_BUS.register(ChatUtil.class);
|
||||
EVENT_BUS.register(DrawUtil.class);
|
||||
EVENT_BUS.register(EntityUtil.class);
|
||||
EVENT_BUS.register(InventoryUtil.class);
|
||||
EVENT_BUS.register(MiscUtil.class);
|
||||
EVENT_BUS.register(NetworkUtil.class);
|
||||
EVENT_BUS.register(RenderUtil.class);
|
||||
|
||||
Lists.init();
|
||||
|
||||
ModuleManager.INSTANCE = new ModuleManager();
|
||||
EVENT_BUS.post(new LoadModuleManagerEvent());
|
||||
|
||||
CommandManager.INSTANCE = new CommandManager();
|
||||
EVENT_BUS.post(new LoadCommandManagerEvent());
|
||||
|
||||
ClickGUI.INSTANCE = new ClickGUI();
|
||||
HudEditorScreen.INSTANCE = new HudEditorScreen();
|
||||
EVENT_BUS.post(new LoadClickGUIEvent());
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
ConfigManager.save();
|
||||
EVENT_BUS.post(new ShutdownEvent());
|
||||
}));
|
||||
}
|
||||
|
||||
// se ejecuta cada tick, es decir, 20 veces por segundo
|
||||
public void onTick() {
|
||||
if (!settingsApplied
|
||||
&& ConfigManager.getConfig() != null
|
||||
&& !ConfigManager.hasLoaded()) {
|
||||
ConfigManager.applyConfig();
|
||||
settingsApplied = true;
|
||||
}
|
||||
|
||||
ModuleManager.INSTANCE.getEnabledModules().forEach(Module::onTick);
|
||||
}
|
||||
|
||||
|
||||
// se ejecuta cada vez que se presiona una tecla
|
||||
public void onKeyPress(int key, int action) {
|
||||
if (key == GLFW.GLFW_KEY_F3) return; // prevenir activación de módulos al usar combinaciones de F3
|
||||
ModuleManager.INSTANCE.getEnabledModules().forEach(module -> module.onKey(key, action));
|
||||
|
||||
boolean anyFocused = isAnySettingButtonFocused() || ClickGUI.INSTANCE.getSearchBar().isFocused();
|
||||
ClickGUI.INSTANCE.setAnyFocused(anyFocused);
|
||||
|
||||
if (action != GLFW.GLFW_RELEASE) {
|
||||
if (BindCommand.onKeyPress(key)) return;
|
||||
if (action == GLFW.GLFW_PRESS) {
|
||||
handleModuleToggle(key, anyFocused);
|
||||
handleClickGUIKey(key, anyFocused);
|
||||
handleHudEditorKey(key, anyFocused);
|
||||
}
|
||||
handleSettingButtonsKey(key, action);
|
||||
} else if (!anyFocused) {
|
||||
handleModuleRelease(key);
|
||||
}
|
||||
}
|
||||
|
||||
// verifica si algún botón de ajustes está escuchando
|
||||
private boolean isAnySettingButtonFocused() {
|
||||
for (SettingsFrame sf : ClickGUI.INSTANCE.getSettingsFrames())
|
||||
for (Button sb : sf.getButtons())
|
||||
if ((sb instanceof BindButton b && b.isFocused()) || (sb instanceof TextButton t && t.isFocused()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// se ocupa de la lógica de encendido y apagado de los módulos
|
||||
private void handleModuleToggle(int key, boolean anyFocused) {
|
||||
if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return;
|
||||
|
||||
for (Module module : ModuleManager.INSTANCE.getModules()) {
|
||||
if (key != module.getKey() || anyFocused || KeyUtil.isKeyDown(GLFW.GLFW_KEY_F3)) continue; // evitar interrumpir combinaciones de teclas del F3
|
||||
|
||||
if (module.shouldToggleOnBindRelease() && !module.isEnabled())
|
||||
module.setEnabled(true);
|
||||
else if (!module.shouldToggleOnBindRelease())
|
||||
module.toggle();
|
||||
}
|
||||
}
|
||||
|
||||
// se ocupa de hacer los botones de ajustes que lo necesiten escuchar teclas
|
||||
private void handleSettingButtonsKey(int key, int action) {
|
||||
for (SettingsFrame sf : ClickGUI.INSTANCE.getSettingsFrames()) {
|
||||
for (SettingButton sb : sf.getButtons()) {
|
||||
if (sb instanceof BindButton bb) bb.onKey(key, action);
|
||||
if (sb instanceof TextButton tb) tb.onKey(key, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// maneja la lógica de apertura de la interfaz
|
||||
private void handleClickGUIKey(int key, boolean anyFocused) {
|
||||
if (key != ClientSettingsFrame.guiSettings.getKey() || anyFocused || isOnTypingScreen())
|
||||
return;
|
||||
|
||||
// al parecer esto hace que con la tecla de la interfaz puedas ir cambiando de splash text en la pantalla del título
|
||||
// pero me ha hecho gracia así que así se queda
|
||||
if (mc.currentScreen != ClickGUI.INSTANCE) {
|
||||
prevScreen = mc.currentScreen;
|
||||
mc.setScreen(ClickGUI.INSTANCE);
|
||||
} else {
|
||||
ClickGUI.INSTANCE.close();
|
||||
mc.setScreen(prevScreen);
|
||||
}
|
||||
}
|
||||
|
||||
// manejar la lógica de apertura del editor de elementos del hud, con la misma lógica que handleClickGUIKey()
|
||||
private void handleHudEditorKey(int key, boolean anyFocused) {
|
||||
HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class);
|
||||
if (key != hud.editorKey.getKey() || anyFocused || isOnTypingScreen()) return;
|
||||
|
||||
if (mc.currentScreen != HudEditorScreen.INSTANCE) {
|
||||
if (!hud.isEnabled()) {
|
||||
ChatUtil.warn("HUD está desactivado, lumbreras");
|
||||
return;
|
||||
}
|
||||
prevScreen = mc.currentScreen;
|
||||
mc.setScreen(HudEditorScreen.INSTANCE);
|
||||
} else {
|
||||
HudEditorScreen.INSTANCE.close();
|
||||
mc.setScreen(prevScreen);
|
||||
}
|
||||
}
|
||||
|
||||
// se ocupa de apagar los módulos que tengan configurado hacerlo tras soltar su tecla
|
||||
private void handleModuleRelease(int key) {
|
||||
if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return;
|
||||
|
||||
for (Module module : ModuleManager.INSTANCE.getEnabledModules())
|
||||
if (module.shouldToggleOnBindRelease() && key == module.getKey())
|
||||
module.setEnabled(false);
|
||||
}
|
||||
|
||||
private boolean isOnTypingScreen() {
|
||||
return mc.currentScreen instanceof ChatScreen
|
||||
|| mc.currentScreen instanceof AnvilScreen
|
||||
|| mc.currentScreen instanceof AbstractSignEditScreen
|
||||
|| mc.currentScreen instanceof AbstractCommandBlockScreen;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onStop(ShutdownEvent event) {
|
||||
ConfigManager.save();
|
||||
}
|
||||
|
||||
public static String getVersionName() {
|
||||
return MOD_ID + "_v" + MOD_VERSION + "_" + SharedConstants.getGameVersion().name();
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package me.retucio.camtweaks.command;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.registry.BuiltinRegistries;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Command {
|
||||
|
||||
// utilizar los "registries" ya existentes de Brigadier para el autocompletado
|
||||
protected static final CommandRegistryAccess REGISTRY_ACCESS = CommandManager.createRegistryAccess(BuiltinRegistries.createWrapperLookup());
|
||||
protected static final int SUCCESS = com.mojang.brigadier.Command.SINGLE_SUCCESS;
|
||||
|
||||
protected static final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
private final String name, description;
|
||||
private final List<String> aliases;
|
||||
|
||||
public Command(String name, String description, String... aliases) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.aliases = List.of(aliases);
|
||||
}
|
||||
|
||||
// métodos "helper" para reducir el "boilerplate"
|
||||
protected static <T> RequiredArgumentBuilder<CommandSource, T> argument(final String name, final ArgumentType<T> type) {
|
||||
return RequiredArgumentBuilder.argument(name, type);
|
||||
}
|
||||
|
||||
protected static LiteralArgumentBuilder<CommandSource> literal(final String name) {
|
||||
return LiteralArgumentBuilder.literal(name);
|
||||
}
|
||||
|
||||
// para registrar comandos
|
||||
public final void registerTo(CommandDispatcher<CommandSource> dispatcher) {
|
||||
register(dispatcher, name);
|
||||
for (String alias : aliases) register(dispatcher, alias);
|
||||
}
|
||||
|
||||
public void register(CommandDispatcher<CommandSource> dispatcher, String name) {
|
||||
LiteralArgumentBuilder<CommandSource> builder = LiteralArgumentBuilder.literal(name);
|
||||
build(builder);
|
||||
dispatcher.register(builder);
|
||||
}
|
||||
|
||||
public abstract void build(LiteralArgumentBuilder<CommandSource> builder);
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return me.retucio.camtweaks.command.CommandManager.INSTANCE.getPrefix() + name;
|
||||
}
|
||||
|
||||
public String toString(String... args) {
|
||||
StringBuilder sb = new StringBuilder(toString());
|
||||
for (String arg : args) sb.append(" ").append(arg);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.command.args.ModuleArgumentType;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.settings.KeySetting;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.KeyUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
// asignar una tecla a un módulo, lógica similar a BindButton
|
||||
public class BindCommand extends Command {
|
||||
|
||||
private static Module listeningModule = null;
|
||||
|
||||
public BindCommand() {
|
||||
super("bind", "asigna una tecla a un módulo", "keybind");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder
|
||||
.then(argument("módulo", ModuleArgumentType.INSTANCE)
|
||||
.executes(ctx -> {
|
||||
Module module = ctx.getArgument("módulo", Module.class);
|
||||
listeningModule = module;
|
||||
ChatUtil.info("presiona una tecla para asignarla al módulo " + Formatting.GREEN + module.getName());
|
||||
return SUCCESS;
|
||||
})
|
||||
.then(literal("reset").executes(ctx -> {
|
||||
Module module = ctx.getArgument("módulo", Module.class);
|
||||
module.getBind().reset();
|
||||
ChatUtil.info("tecla para el módulo " + Formatting.GREEN + module.getName() + " restablecida a " + Formatting.AQUA + KeyUtil.getKeyName(module.getKey()));
|
||||
return SUCCESS;
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean onKeyPress(int key) {
|
||||
if (listeningModule == null) return false;
|
||||
KeySetting bind = listeningModule.getBind();
|
||||
if (bind != null) bind.setKey(key);
|
||||
|
||||
ChatUtil.info(
|
||||
Text.of("la tecla " + Formatting.AQUA + KeyUtil.getKeyName(key) + Formatting.RESET +
|
||||
" ha sido asignada al módulo " + Formatting.GREEN + listeningModule.getName())
|
||||
);
|
||||
|
||||
listeningModule = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.TickEvent;
|
||||
import me.retucio.camtweaks.ui.screen.PreviewScreen;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import me.retucio.camtweaks.util.InventoryUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
|
||||
// accede a los contenidos de tu enderchest
|
||||
public class EnderChestCommand extends Command {
|
||||
|
||||
private boolean shouldOpenEchest = false;
|
||||
|
||||
public EnderChestCommand() {
|
||||
super("echest", "muestra el contenido de tu enderchest (solo de ver)", "ec", "enderchest");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(ctx -> {
|
||||
mc.execute(() -> {
|
||||
if (mc.player == null) return;
|
||||
if (InventoryUtil.getEchestInv() == null) {
|
||||
ChatUtil.warn("necesitas abrir un enderchest una vez primero");
|
||||
return;
|
||||
}
|
||||
|
||||
shouldOpenEchest = true;
|
||||
});
|
||||
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.Post event) {
|
||||
if (shouldOpenEchest) {
|
||||
shouldOpenEchest = false;
|
||||
if (InventoryUtil.getEchestInv() != null)
|
||||
mc.setScreen(new PreviewScreen(InventoryUtil.getEchestInv(), null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class GarbageCleanerCommand extends Command {
|
||||
|
||||
public GarbageCleanerCommand() {
|
||||
super("gc", "limpia la ram mediante el recolector de basura (gc)", "garbagecollect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.executes(context -> {
|
||||
System.gc();
|
||||
ChatUtil.info(Text.of("basura recolectada"));
|
||||
return SUCCESS;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.ui.widgets.frames.settings.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
// también se puede hacer desde los ajustes de la interfaz
|
||||
public class PrefixCommand extends Command {
|
||||
|
||||
public PrefixCommand() {
|
||||
super("prefijo", "cambia el prefijo de los comandos", "prefix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder
|
||||
.then(argument("prefijo", StringArgumentType.word()).executes(ctx -> {
|
||||
String prefix = ctx.getArgument("prefijo", String.class);
|
||||
ClientSettingsFrame.guiSettings.commandPrefix.setValue(prefix);
|
||||
ChatUtil.info(Text.literal("prefijo cambiado a " + Formatting.AQUA + prefix));
|
||||
return SUCCESS;
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package me.retucio.camtweaks.command.commands;
|
||||
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import me.retucio.camtweaks.command.Command;
|
||||
import me.retucio.camtweaks.mixin.accessor.ClientPlayNetworkHandlerAccessor;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.network.encryption.NetworkEncryptionUtils;
|
||||
import net.minecraft.network.message.LastSeenMessagesCollector;
|
||||
import net.minecraft.network.message.MessageBody;
|
||||
import net.minecraft.network.message.MessageSignatureData;
|
||||
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
// uso principal: protección de coordenadas de ChatPlus, que ni siquiera funciona
|
||||
public class SendCommand extends Command {
|
||||
|
||||
public SendCommand() {
|
||||
super("enviar", "manda un mensaje en el chat", "send");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.then(argument("message", StringArgumentType.greedyString()).executes(context -> {
|
||||
String message = context.getArgument("message", String.class);
|
||||
|
||||
if (message != null && !message.isEmpty()) {
|
||||
Instant instant = Instant.now();
|
||||
long salt = NetworkEncryptionUtils.SecureRandomUtil.nextLong();
|
||||
ClientPlayNetworkHandler handler = mc.getNetworkHandler();
|
||||
|
||||
// obtener últimos mensajes vistos para la firma
|
||||
LastSeenMessagesCollector.LastSeenMessages lastSeenMessages =
|
||||
((ClientPlayNetworkHandlerAccessor) handler).getLastSeenMessagesCollector().collect();
|
||||
|
||||
// empacar firma para un chat seguro
|
||||
MessageSignatureData messageSignatureData =
|
||||
((ClientPlayNetworkHandlerAccessor) handler).getMessagePacker().pack(
|
||||
new MessageBody(message, instant, salt, lastSeenMessages.lastSeen())
|
||||
);
|
||||
|
||||
// enviar paquete para enviar mensaje
|
||||
handler.sendPacket(new ChatMessageC2SPacket(
|
||||
message,
|
||||
instant,
|
||||
salt,
|
||||
messageSignatureData,
|
||||
lastSeenMessages.update()
|
||||
));
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package me.retucio.camtweaks.config;
|
||||
|
||||
import me.retucio.camtweaks.event.SubscribeEvent;
|
||||
import me.retucio.camtweaks.event.events.camtweaks.*;
|
||||
import me.retucio.camtweaks.module.settings.*;
|
||||
import me.retucio.camtweaks.ui.screen.ClickGUI;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
// clase donde se guardan las configuraciones temporalmente hasta escribirlas en camera_tweaks.json
|
||||
public class ClientConfig {
|
||||
|
||||
// nombre del módulo -> estado del módulo
|
||||
public Map<String, Boolean> moduleStates = new HashMap<>();
|
||||
|
||||
// nombre del ajuste -> valor
|
||||
public Map<String, Object> settings = new HashMap<>();
|
||||
|
||||
// nombre del módulo -> posición (x, y)
|
||||
public Map<String, int[]> settingsFrames = new HashMap<>();
|
||||
|
||||
// nombre del frame -> FrameData (que contiene extended, x & y)
|
||||
public Map<String, FrameData> extendableFrames = new HashMap<>();
|
||||
|
||||
// id del elemento del hud -> posición (x, y)
|
||||
public Map<String, int[]> hudPositions = new HashMap<>();
|
||||
|
||||
// id del elemento del hud -> true: visible / false: no visible
|
||||
public Map<String, Boolean> hudVisibilities = new HashMap<>();
|
||||
|
||||
// id del elemento del hud -> ruta de la imagen (NEW)
|
||||
public Map<String, String> hudImagePaths = new HashMap<>();
|
||||
|
||||
// posición de la barra de búsqueda (x, y)
|
||||
public int[] searchBarPosition = new int[]{340, 16};
|
||||
|
||||
public ClientConfig() {
|
||||
EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onToggleModule(ToggleModuleEvent event) {
|
||||
ConfigManager.setModuleState(event.getModule());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SubscribeEvent
|
||||
public void onUpdateSetting(UpdateSettingEvent event) {
|
||||
if (mc == null || !event.shouldSave()) return;
|
||||
|
||||
// guardar ajustes con su respectivo tipo de valor, en formato "nombreMódulo:nombreAjuste"
|
||||
Object value = null;
|
||||
switch (event.getSetting()) {
|
||||
case BooleanSetting b: value = b.isEnabled(); break;
|
||||
case EnumSetting e: value = e.getIndex(); break;
|
||||
case KeySetting k: value = k.getKey(); break;
|
||||
case NumberSetting n: value = n.getValue(); break;
|
||||
case StringSetting s: value = s.getValue(); break;
|
||||
case ListSetting l: value = l.getConfigValues(); break;
|
||||
case ColorSetting c: value = c.getConfigValue(); break;
|
||||
case OptionSetting o: value = o.getIndex(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
ConfigManager.setSetting(event.getSetting(), value);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onOpenSettingsFrame(SettingsFrameEvent.Open event) {
|
||||
if (settingsFrames.containsKey(event.getFrame().module.getName())) return;
|
||||
ConfigManager.setFramePosition(event.getFrame());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCloseSettingsFrame(SettingsFrameEvent.Close event) {
|
||||
settingsFrames.remove(event.getFrame().module.getName());
|
||||
ConfigManager.save();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMoveSettingsFrame(SettingsFrameEvent.Move event) {
|
||||
settingsFrames.replace(event.getFrame().module.getName(), new int[]{event.getFrame().getX(), event.getFrame().getY()});
|
||||
ConfigManager.save();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onExtendModuleFrame(ModuleFrameEvent.Extend event) {
|
||||
extendableFrames.put("M", new FrameData(
|
||||
ClickGUI.INSTANCE.getModulesFrame().getX(),
|
||||
ClickGUI.INSTANCE.getModulesFrame().getY(),
|
||||
ClickGUI.INSTANCE.getModulesFrame().extended));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMoveModuleFrame(ModuleFrameEvent.Move event) {
|
||||
extendableFrames.replace("M", new FrameData(
|
||||
ClickGUI.INSTANCE.getModulesFrame().getX(),
|
||||
ClickGUI.INSTANCE.getModulesFrame().getY(),
|
||||
ClickGUI.INSTANCE.getModulesFrame().extended));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onExtendGUISettingsFrame(GUISettingsFrameEvent.Extend event) {
|
||||
extendableFrames.put("S", new FrameData(
|
||||
ClickGUI.INSTANCE.getGuiSettingsFrame().getX(),
|
||||
ClickGUI.INSTANCE.getGuiSettingsFrame().getY(),
|
||||
ClickGUI.INSTANCE.getGuiSettingsFrame().extended));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMoveGUISettingsFrame(GUISettingsFrameEvent.Move event) {
|
||||
extendableFrames.replace("S", new FrameData(
|
||||
ClickGUI.INSTANCE.getGuiSettingsFrame().getX(),
|
||||
ClickGUI.INSTANCE.getGuiSettingsFrame().getY(),
|
||||
ClickGUI.INSTANCE.getGuiSettingsFrame().extended));
|
||||
}
|
||||
|
||||
public record FrameData(int x, int y, boolean extended) {}
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
package me.retucio.camtweaks.config;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.module.Module;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.settings.*;
|
||||
import me.retucio.camtweaks.ui.widgets.frames.ModuleFrame;
|
||||
import me.retucio.camtweaks.ui.screen.ClickGUI;
|
||||
import me.retucio.camtweaks.ui.widgets.frames.settings.ClientSettingsFrame;
|
||||
import me.retucio.camtweaks.ui.widgets.frames.SettingsFrame;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// se ocupa de guardar, cargar y aplicar ajustes
|
||||
// pues no me ha dado dolores de cabeza el coso este con los NPE de los cojones...
|
||||
public class ConfigManager {
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final File CONFIG_FILE = new File("camera_tweaks.json");
|
||||
|
||||
private static boolean loaded = false;
|
||||
private static ClientConfig config = null;
|
||||
|
||||
|
||||
// ------------------ MÉTODOS PRINCIPALES ------------------
|
||||
|
||||
// guardar configuraciones
|
||||
public static void save() {
|
||||
ensureConfig();
|
||||
|
||||
try (FileWriter writer = new FileWriter(CONFIG_FILE)) {
|
||||
GSON.toJson(config, writer);
|
||||
CameraTweaks.LOGGER.info("ajustes guardados");
|
||||
} catch (IOException e) {
|
||||
CameraTweaks.LOGGER.error("error al guardar ajustes", e);
|
||||
}
|
||||
}
|
||||
|
||||
// cargar configuraciones
|
||||
public static void load() {
|
||||
CameraTweaks.LOGGER.info("cargando ajustes...");
|
||||
|
||||
if (!CONFIG_FILE.exists()) {
|
||||
ensureConfig();
|
||||
save();
|
||||
return;
|
||||
}
|
||||
|
||||
try (FileReader reader = new FileReader(CONFIG_FILE)) {
|
||||
config = GSON.fromJson(reader, ClientConfig.class);
|
||||
CameraTweaks.LOGGER.info("ajustes cargados");
|
||||
} catch (IOException e) {
|
||||
CameraTweaks.LOGGER.error("no se pudieron cargar los ajustes, usando ajustes por defecto", e);
|
||||
ensureConfig();
|
||||
}
|
||||
}
|
||||
|
||||
// aplicar configuraciones cargadas
|
||||
public static void applyConfig() {
|
||||
if (!shouldApply()) return;
|
||||
|
||||
applyModuleStates();
|
||||
applyModuleSettings();
|
||||
applySettingsFrames();
|
||||
applySearchBarPosition();
|
||||
applyGuiSettings();
|
||||
applyExtendableFrames();
|
||||
|
||||
loaded = true;
|
||||
CameraTweaks.LOGGER.info("ajustes aplicados");
|
||||
}
|
||||
|
||||
// obtener configuración actual
|
||||
public static ClientConfig getConfig() {
|
||||
ensureConfig();
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
// ------------------ GUARDAR VALORES INDIVIDUALES EN LA CONFIG. ------------------
|
||||
|
||||
public static void setModuleState(Module module) {
|
||||
ensureConfig();
|
||||
config.moduleStates.put(module.getName(), module.isEnabled());
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setSetting(Setting setting, Object value) {
|
||||
ensureConfig();
|
||||
config.settings.put(getSettingKey(setting), value);
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setFramePosition(SettingsFrame frame) {
|
||||
ensureConfig();
|
||||
config.settingsFrames.put(frame.module.getName(), new int[] {frame.getX(), frame.getY()});
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setExtendableFrame(String key, ClientConfig.FrameData data) {
|
||||
ensureConfig();
|
||||
config.extendableFrames.put(key, data);
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setHudPosition(String id, int x, int y) {
|
||||
ensureConfig();
|
||||
config.hudPositions.put(id, new int[] {x, y});
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setHudVisibility(String id, Boolean visible) {
|
||||
ensureConfig();
|
||||
config.hudVisibilities.put(id, visible);
|
||||
save();
|
||||
}
|
||||
|
||||
public static void setHudImagePath(String id, String imagePath) {
|
||||
ensureConfig();
|
||||
config.hudImagePaths.put(id, imagePath);
|
||||
save();
|
||||
}
|
||||
|
||||
public static String getHudImagePath(String id) {
|
||||
ensureConfig();
|
||||
return config.hudImagePaths.getOrDefault(id, "");
|
||||
}
|
||||
|
||||
public static void setSearchBarPosition(int x, int y) {
|
||||
ensureConfig();
|
||||
config.searchBarPosition = new int[] {x, y};
|
||||
save();
|
||||
}
|
||||
|
||||
|
||||
// ------------------ APLICAR AJUSTES ------------------
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public static void applySetting(Module parent, Setting setting) {
|
||||
String key = getSettingKey(setting);
|
||||
|
||||
if (!config.settings.containsKey(key)) return;
|
||||
|
||||
Object value = config.settings.get(key);
|
||||
|
||||
switch (setting) {
|
||||
case BooleanSetting booleanSetting -> applyBooleanSetting(booleanSetting, value);
|
||||
case EnumSetting enumSetting -> applyEnumSetting(enumSetting, value);
|
||||
case NumberSetting numberSetting -> applyNumberSetting(numberSetting, value);
|
||||
case StringSetting stringSetting -> applyStringSetting(stringSetting, value);
|
||||
case KeySetting keySetting -> applyKeySetting(keySetting, value);
|
||||
case ListSetting listSetting -> applyListSetting(listSetting, value);
|
||||
case ColorSetting colorSetting -> applyColorSetting(colorSetting, value);
|
||||
case OptionSetting optionSetting -> applyOptionSetting(optionSetting, value);
|
||||
default -> CameraTweaks.LOGGER.warn("watafac queseso: {}", setting.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyModuleStates() {
|
||||
ModuleManager.INSTANCE.getModules().forEach(module -> {
|
||||
if (config.moduleStates.containsKey(module.getName())) {
|
||||
module.setEnabled(config.moduleStates.get(module.getName()));
|
||||
}
|
||||
});
|
||||
CameraTweaks.LOGGER.info("estados de módulos aplicados");
|
||||
}
|
||||
|
||||
private static void applyModuleSettings() {
|
||||
ModuleManager.INSTANCE.getModules().forEach(module -> {
|
||||
module.getSettings().forEach(setting -> applySetting(module, setting));
|
||||
});
|
||||
CameraTweaks.LOGGER.info("ajustes de módulos aplicados");
|
||||
}
|
||||
|
||||
private static void applySettingsFrames() {
|
||||
config.settingsFrames.forEach((moduleName, position) -> {
|
||||
Module module = ModuleManager.INSTANCE.getModuleByName(moduleName);
|
||||
ClickGUI.INSTANCE.openSettingsFrame(module, position[0], position[1]);
|
||||
});
|
||||
CameraTweaks.LOGGER.info("estados de marcos de ajustes aplicados");
|
||||
}
|
||||
|
||||
private static void applySearchBarPosition() {
|
||||
if (config.searchBarPosition != null && config.searchBarPosition.length == 2) {
|
||||
ClickGUI.INSTANCE.getSearchBar().setX(config.searchBarPosition[0]);
|
||||
ClickGUI.INSTANCE.getSearchBar().setY(config.searchBarPosition[1]);
|
||||
}
|
||||
CameraTweaks.LOGGER.info("posición de la barra de búsqueda aplicada");
|
||||
}
|
||||
|
||||
private static void applyGuiSettings() {
|
||||
ClientSettingsFrame.guiSettings.setEnabled(true);
|
||||
ClientSettingsFrame.guiSettings.getSettings().forEach(setting -> {
|
||||
applySetting(ClientSettingsFrame.guiSettings, setting);
|
||||
});
|
||||
CameraTweaks.LOGGER.info("ajustes del cliente aplicados");
|
||||
}
|
||||
|
||||
private static void applyExtendableFrames() {
|
||||
applyExtendableFrame(ClickGUI.INSTANCE.getModulesFrame());
|
||||
applyExtendableFrame(ClickGUI.INSTANCE.getGuiSettingsFrame());
|
||||
|
||||
CameraTweaks.LOGGER.info("posiciones de marcos extendibles aplicadasa");
|
||||
ClickGUI.INSTANCE.refreshListButtons();
|
||||
}
|
||||
|
||||
private static void applyExtendableFrame(ModuleFrame frame) {
|
||||
ClientConfig.FrameData frameData = config.extendableFrames.get("M");
|
||||
if (frameData != null) {
|
||||
frame.setX(frameData.x());
|
||||
frame.setY(frameData.y());
|
||||
frame.extended = frameData.extended();
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyExtendableFrame(ClientSettingsFrame frame) {
|
||||
ClientConfig.FrameData frameData = config.extendableFrames.get("S");
|
||||
if (frameData != null) {
|
||||
frame.setX(frameData.x());
|
||||
frame.setY(frameData.y());
|
||||
frame.extended = frameData.extended();
|
||||
}
|
||||
}
|
||||
|
||||
// ajustes de módulos
|
||||
|
||||
private static void applyBooleanSetting(BooleanSetting setting, Object value) {
|
||||
if (value instanceof Boolean) {
|
||||
setting.setEnabled((Boolean) value);
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends Enum<T>> void applyEnumSetting(EnumSetting<T> setting, Object value) {
|
||||
if (value instanceof Double) {
|
||||
setting.setIndex(((Double) value).intValue());
|
||||
} else if (value instanceof Integer) {
|
||||
setting.setIndex((Integer) value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyNumberSetting(NumberSetting setting, Object value) {
|
||||
if (value instanceof Double) {
|
||||
setting.setValue((Double) value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyStringSetting(StringSetting setting, Object value) {
|
||||
if (value instanceof String) {
|
||||
setting.setValue((String) value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyKeySetting(KeySetting setting, Object value) {
|
||||
if (value instanceof Double) {
|
||||
setting.setKey(((Double) value).intValue());
|
||||
} else if (value instanceof Integer) {
|
||||
setting.setKey((Integer) value);
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> void applyListSetting(ListSetting<T> setting, Object value) {
|
||||
if (value instanceof Map<?, ?> map) {
|
||||
Map<T, Boolean> convertedValues = new HashMap<>();
|
||||
|
||||
for (T option : setting.getOptions()) {
|
||||
String key = setting.getDisplayName(option);
|
||||
Object booleanValue = map.get(key);
|
||||
convertedValues.put(option, booleanValue instanceof Boolean && (Boolean) booleanValue);
|
||||
}
|
||||
|
||||
setting.setValues(convertedValues);
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyColorSetting(ColorSetting setting, Object value) {
|
||||
if (!(value instanceof Map<?, ?> map)) return;
|
||||
|
||||
Number r = (Number) map.get("r");
|
||||
Number g = (Number) map.get("g");
|
||||
Number b = (Number) map.get("b");
|
||||
Number a = (Number) map.get("a");
|
||||
|
||||
if (r != null && g != null && b != null && a != null)
|
||||
setting.setRGB(r.intValue(), g.intValue(), b.intValue(), a.intValue());
|
||||
|
||||
applyOptionalProperty(map, "rb", Boolean.class, setting::setRainbow);
|
||||
applyOptionalProperty(map, "rs", Number.class, val -> setting.setRainbowSpeed(val.intValue()));
|
||||
applyOptionalProperty(map, "sat", Number.class, val -> setting.setSaturation(val.floatValue()));
|
||||
applyOptionalProperty(map, "bri", Number.class, val -> setting.setBrightness(val.floatValue()));
|
||||
}
|
||||
|
||||
private static <T> void applyOptionSetting(OptionSetting<T> setting, Object value) {
|
||||
if (value instanceof Double) {
|
||||
int index = ((Double) value).intValue();
|
||||
setting.setValue(setting.getOption(index));
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> void applyOptionalProperty(Map<?, ?> map, String key, Class<T> type, java.util.function.Consumer<T> setter) {
|
||||
Object value = map.get(key);
|
||||
if (type.isInstance(value)) {
|
||||
setter.accept(type.cast(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------ MÉTODOS DE AYUDA ------------------
|
||||
|
||||
private static boolean shouldApply() {
|
||||
return CameraTweaks.mc != null && ModuleManager.INSTANCE != null && config != null;
|
||||
}
|
||||
|
||||
|
||||
private static void ensureConfig() {
|
||||
if (config == null) config = new ClientConfig();
|
||||
}
|
||||
|
||||
private static String getSettingKey(Setting setting) {
|
||||
return setting.getModule().getName() + ":" + setting.getName();
|
||||
}
|
||||
|
||||
public static boolean hasLoaded() {
|
||||
return loaded;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package me.retucio.camtweaks.event;
|
||||
|
||||
// evento base, cancelable (usado en mixins)
|
||||
public class Event {
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
cancelled = true;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package me.retucio.camtweaks.event;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
|
||||
// al llamar un evento, se guarda en el bus de eventos, de donde luego se puede detectar si ese evento ha sucedido
|
||||
public class EventBus {
|
||||
|
||||
private final Map<Class<?>, List<ListenerMethod>> listeners = new HashMap<>();
|
||||
|
||||
private record ListenerMethod(Object instance, Method method) {}
|
||||
|
||||
public void register(Object listener) {
|
||||
Class<?> targetClass;
|
||||
|
||||
if (listener instanceof Class<?> clazz) {
|
||||
targetClass = clazz; // "listeners" estáticos
|
||||
listener = null;
|
||||
} else {
|
||||
targetClass = listener.getClass();
|
||||
}
|
||||
|
||||
for (Method method : targetClass.getDeclaredMethods()) {
|
||||
if (!method.isAnnotationPresent(SubscribeEvent.class)) continue;
|
||||
if (method.getParameterCount() != 1) continue;
|
||||
|
||||
Class<?> eventType = method.getParameterTypes()[0];
|
||||
method.setAccessible(true);
|
||||
|
||||
if (listener == null && !Modifier.isStatic(method.getModifiers())) continue;
|
||||
|
||||
listeners.computeIfAbsent(eventType, k -> new ArrayList<>())
|
||||
.add(new ListenerMethod(listener, method));
|
||||
}
|
||||
}
|
||||
|
||||
public void subscribe(Object listener) { register(listener); }
|
||||
|
||||
public void unregister(Object listener) {
|
||||
for (List<ListenerMethod> list : listeners.values()) {
|
||||
list.removeIf(lm -> lm.instance == listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void unsubscribe(Object listener) { unregister(listener); }
|
||||
|
||||
public <T extends Event> T post(T event) {
|
||||
List<ListenerMethod> list = listeners.get(event.getClass());
|
||||
if (list != null) {
|
||||
for (ListenerMethod lm : new ArrayList<>(list)) { // copiar para evitar CME
|
||||
try {
|
||||
lm.method.invoke(lm.instance, event);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
public boolean isRegistered(Object listener) {
|
||||
for (List<ListenerMethod> list : listeners.values()) {
|
||||
for (ListenerMethod lm : list) {
|
||||
if (lm.instance == listener) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package me.retucio.camtweaks.event;
|
||||
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onJoinWorld
|
||||
*/
|
||||
public class JoinWorldEvent extends Event {
|
||||
|
||||
private final ClientWorld world;
|
||||
|
||||
public JoinWorldEvent(ClientWorld world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public ClientWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package me.retucio.camtweaks.event;
|
||||
|
||||
public enum Stage {
|
||||
PRE, // antes de que haya sucedido
|
||||
POST; // después de que haya sucedido
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package me.retucio.camtweaks.event;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
// anotación para registar un "listener", que escucha cuando se llama un evento
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SubscribeEvent {}
|
||||
@@ -1,21 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.ClientPlayerInteractionManagerMixin#onAttackEntity
|
||||
*/
|
||||
public class AttackEntityEvent extends Event {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public AttackEntityEvent(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.ChunkOcclusionDataBuilderMixin#onChunkOcclusion
|
||||
*/
|
||||
public class ChunkOcclusionEvent extends Event {}
|
||||
@@ -1,28 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.network.DisconnectionInfo;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.ClientConnectionMixin#onDisconnect
|
||||
*/
|
||||
public class DisconnectEvent extends Event {
|
||||
|
||||
private final DisconnectionInfo info;
|
||||
private final ServerInfo server;
|
||||
|
||||
public DisconnectEvent(DisconnectionInfo info, ServerInfo server) {
|
||||
this.info = info;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public DisconnectionInfo getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public ServerInfo getServer() {
|
||||
return server;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.ClientPlayerInteractionManagerMixin#onEntityInteract
|
||||
*/
|
||||
public class InteractEntityEvent extends Event {
|
||||
|
||||
private final Entity entity;
|
||||
private Hand hand;
|
||||
|
||||
public InteractEntityEvent(Entity entity, Hand hand) {
|
||||
this.entity = entity;
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Hand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public void setHand(Hand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import me.retucio.camtweaks.event.Stage;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.ClientConnectionMixin#onSendPacketPre
|
||||
* @see me.retucio.camtweaks.mixin.ClientConnectionMixin#onSendPacketPost
|
||||
* @see me.retucio.camtweaks.mixin.ClientConnectionMixin#onReceivePacket
|
||||
*/
|
||||
public class PacketEvent {
|
||||
|
||||
public static class Send extends Event {
|
||||
|
||||
private final Packet<?> packet;
|
||||
private final Stage stage;
|
||||
|
||||
public Send(Packet<?> packet, Stage stage) {
|
||||
this.packet = packet;
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
public Packet<?> getPacket() {
|
||||
return packet;
|
||||
}
|
||||
|
||||
public Stage getStage() {
|
||||
return stage;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Receive extends Event {
|
||||
|
||||
private final Packet<?> packet;
|
||||
|
||||
public Receive(Packet<?> packet) {
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
public Packet<?> getPacket() {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.client.option.Perspective;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.GameOptionsMixin#changePerspective
|
||||
*/
|
||||
public class PerspectiveChangeEvent extends Event {
|
||||
|
||||
private Perspective perspective;
|
||||
|
||||
public PerspectiveChangeEvent(Perspective perspective) {
|
||||
this.perspective = perspective;
|
||||
}
|
||||
|
||||
public Perspective getPerspective() {
|
||||
return perspective;
|
||||
}
|
||||
|
||||
public void setPerspective(Perspective perspective) {
|
||||
this.perspective = perspective;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.ClientPlayerInteractionManagerMixin#onBlockPlace
|
||||
*/
|
||||
public class PlaceBlockEvent extends Event {
|
||||
|
||||
private Hand hand;
|
||||
private BlockHitResult result;
|
||||
|
||||
public PlaceBlockEvent(Hand hand, BlockHitResult result) {
|
||||
this.hand = hand;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public Hand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public void setHand(Hand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public BlockHitResult getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(BlockHitResult result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.ChatHudMixin#onAddMessage
|
||||
*/
|
||||
public class ReceiveMessageEvent extends Event {
|
||||
|
||||
private Text text;
|
||||
private MessageIndicator indicator;
|
||||
private int id;
|
||||
private boolean modified = false;
|
||||
|
||||
public ReceiveMessageEvent(Text text, MessageIndicator indicator, int id) {
|
||||
this.text = text;
|
||||
this.indicator = indicator;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Text getMessage() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public MessageIndicator getIndicator() {
|
||||
return indicator;
|
||||
}
|
||||
|
||||
public void setMessage(Text message) {
|
||||
this.text = message;
|
||||
this.modified = true;
|
||||
}
|
||||
|
||||
public void setIndicator(MessageIndicator indicator) {
|
||||
this.indicator = indicator;
|
||||
this.modified = true;
|
||||
}
|
||||
|
||||
public boolean wasModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.HeldItemRendererMixin#onRenderArm
|
||||
*/
|
||||
public class RenderArmEvent extends Event {
|
||||
|
||||
private MatrixStack matrices;
|
||||
private Hand hand;
|
||||
|
||||
public RenderArmEvent(MatrixStack matrices, Hand hand) {
|
||||
this.matrices = matrices;
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public MatrixStack getMatrices() {
|
||||
return matrices;
|
||||
}
|
||||
|
||||
public void setMatrices(MatrixStack matrices) {
|
||||
this.matrices = matrices;
|
||||
}
|
||||
|
||||
public Hand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public void setHand(Hand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.client.gui.hud.ClientBossBar;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.BossBarHudMixin#modifyBossBarIterator
|
||||
* @see me.retucio.camtweaks.mixin.BossBarHudMixin#modifyBossBarName
|
||||
* @see me.retucio.camtweaks.mixin.BossBarHudMixin#modifySpacingConstant
|
||||
*/
|
||||
public class RenderBossbarEvent {
|
||||
|
||||
public static class BossText extends Event {
|
||||
|
||||
private ClientBossBar bossBar;
|
||||
private Text name;
|
||||
|
||||
public BossText(ClientBossBar bossBar, Text name) {
|
||||
this.bossBar = bossBar;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ClientBossBar getBossBar() {
|
||||
return bossBar;
|
||||
}
|
||||
|
||||
public void setBossBar(ClientBossBar bossBar) {
|
||||
this.bossBar = bossBar;
|
||||
}
|
||||
|
||||
public Text getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(Text name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BossSpacing extends Event {
|
||||
|
||||
private int spacing;
|
||||
|
||||
public BossSpacing(int spacing) {
|
||||
this.spacing = spacing;
|
||||
}
|
||||
|
||||
public int getSpacing() {
|
||||
return spacing;
|
||||
}
|
||||
|
||||
public void setSpacing(int spacing) {
|
||||
this.spacing = spacing;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BossIterator extends Event {
|
||||
|
||||
private Iterator<ClientBossBar> iterator;
|
||||
|
||||
public BossIterator(Iterator<ClientBossBar> iterator) {
|
||||
this.iterator = iterator;
|
||||
}
|
||||
|
||||
public Iterator<ClientBossBar> getIterator() {
|
||||
return iterator;
|
||||
}
|
||||
|
||||
public void setIterator(Iterator<ClientBossBar> iterator) {
|
||||
this.iterator = iterator;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.HeldItemRendererMixin#onRenderItem
|
||||
*/
|
||||
public class RenderHeldItemEvent extends Event {
|
||||
|
||||
private MatrixStack matrices;
|
||||
private Hand hand;
|
||||
|
||||
public RenderHeldItemEvent(MatrixStack matrices, Hand hand) {
|
||||
this.matrices = matrices;
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public MatrixStack getMatrices() {
|
||||
return matrices;
|
||||
}
|
||||
|
||||
public void setMatrices(MatrixStack matrices) {
|
||||
this.matrices = matrices;
|
||||
}
|
||||
|
||||
public Hand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public void setHand(Hand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.WorldRendererMixin#render
|
||||
*/
|
||||
public class RenderWorldEvent extends Event {
|
||||
|
||||
private final MatrixStack matrices;
|
||||
private final RenderTickCounter tc;
|
||||
private final Camera camera;
|
||||
|
||||
public RenderWorldEvent(MatrixStack matrices, RenderTickCounter tc, Camera camera) {
|
||||
this.matrices = matrices;
|
||||
this.tc = tc;
|
||||
this.camera = camera;
|
||||
}
|
||||
|
||||
public MatrixStack getMatrices() {
|
||||
return matrices;
|
||||
}
|
||||
|
||||
public RenderTickCounter getTickCounter() {
|
||||
return tc;
|
||||
}
|
||||
|
||||
public Camera getCamera() {
|
||||
return camera;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onStop
|
||||
*/
|
||||
public class ShutdownEvent extends Event {
|
||||
|
||||
public ShutdownEvent() {}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onTickPre
|
||||
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onTickPost
|
||||
*/
|
||||
public class TickEvent {
|
||||
|
||||
public static class Pre extends Event {}
|
||||
public static class Post extends Event {}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
|
||||
/**
|
||||
* @see me.retucio.camtweaks.mixin.MinecraftClientMixin#onUseItem
|
||||
*/
|
||||
public class UseItemEvent extends Event {
|
||||
|
||||
private ItemStack stack;
|
||||
private Hand hand;
|
||||
|
||||
public UseItemEvent(ItemStack stack, Hand hand) {
|
||||
this.stack = stack;
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void setStack(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public Hand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public void setHand(Hand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events.camtweaks;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
// se genera cuando carga la interfaz del mod
|
||||
public class LoadClickGUIEvent extends Event {}
|
||||
@@ -1,10 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events.camtweaks;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
|
||||
// se genera cada que se interactúa con el marco de módulos
|
||||
public class ModuleFrameEvent {
|
||||
|
||||
public static class Extend extends Event {} // al extenderlo / contraerlo
|
||||
public static class Move extends Event {} // al cambiarlo de posición
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package me.retucio.camtweaks.event.events.camtweaks;
|
||||
|
||||
import me.retucio.camtweaks.event.Event;
|
||||
import me.retucio.camtweaks.ui.widgets.frames.SettingsFrame;
|
||||
|
||||
// se genera cada que se interactúa con un marco de ajustes de un módulo
|
||||
public class SettingsFrameEvent {
|
||||
|
||||
public static class Open extends Event { // al abrirlo
|
||||
private final SettingsFrame frame;
|
||||
public Open(SettingsFrame frame) { this.frame = frame; }
|
||||
public SettingsFrame getFrame() { return frame; }
|
||||
}
|
||||
|
||||
public static class Close extends Event { // al cerrarlo
|
||||
private final SettingsFrame frame;
|
||||
public Close(SettingsFrame frame) { this.frame = frame; }
|
||||
public SettingsFrame getFrame() { return frame; }
|
||||
}
|
||||
|
||||
public static class Move extends Event { // al cambiarlo de posición
|
||||
private final SettingsFrame frame;
|
||||
public Move(SettingsFrame frame) { this.frame = frame; }
|
||||
public SettingsFrame getFrame() { return frame; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import me.retucio.camtweaks.event.events.RenderBossbarEvent;
|
||||
import net.minecraft.client.gui.hud.BossBarHud;
|
||||
import net.minecraft.client.gui.hud.ClientBossBar;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@Mixin(BossBarHud.class)
|
||||
public abstract class BossBarHudMixin {
|
||||
|
||||
@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/Collection;iterator()Ljava/util/Iterator;"))
|
||||
public Iterator<ClientBossBar> modifyBossBarIterator(Iterator<ClientBossBar> original) {
|
||||
RenderBossbarEvent.BossIterator event = EVENT_BUS.post(new RenderBossbarEvent.BossIterator(original));
|
||||
return event.getIterator();
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ClientBossBar;getName()Lnet/minecraft/text/Text;"))
|
||||
public Text modifyBossBarName(Text original, @Local ClientBossBar clientBossBar) {
|
||||
RenderBossbarEvent.BossText event = EVENT_BUS.post(new RenderBossbarEvent.BossText(clientBossBar, original));
|
||||
return event.getName();
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "render", constant = @Constant(intValue = 9, ordinal = 1))
|
||||
public int modifySpacingConstant(int constant) {
|
||||
RenderBossbarEvent.BossSpacing event = EVENT_BUS.post(new RenderBossbarEvent.BossSpacing(constant));
|
||||
return event.getSpacing();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import me.retucio.camtweaks.util.render.GlintRenderLayer;
|
||||
import net.minecraft.client.render.BufferBuilderStorage;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.util.BufferAllocator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(BufferBuilderStorage.class)
|
||||
public abstract class BufferStorageMixin {
|
||||
|
||||
@Inject(method = "assignBufferBuilder", at = @At("HEAD"))
|
||||
private static void addGlintTypes(Object2ObjectLinkedOpenHashMap<RenderLayer, BufferAllocator> builderStorage, RenderLayer layer, CallbackInfo ci) {
|
||||
GlintRenderLayer.addGlintTypes(builderStorage);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import me.retucio.camtweaks.util.interfaces.IChatHudLine;
|
||||
import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ChatHudLine.class)
|
||||
public class ChatHudLineMixin implements IChatHudLine {
|
||||
|
||||
@Shadow @Final
|
||||
private Text content;
|
||||
|
||||
@Unique
|
||||
private int id;
|
||||
|
||||
@Unique
|
||||
private GameProfile sender;
|
||||
|
||||
@Override
|
||||
public String smegma$getText() { return content.toString(); }
|
||||
|
||||
@Override
|
||||
public int smegma$getId() { return id; }
|
||||
|
||||
@Override
|
||||
public void smegma$setId(int id) { this.id = id; }
|
||||
|
||||
@Override
|
||||
public GameProfile smegma$getSender() { return sender; }
|
||||
|
||||
@Override
|
||||
public void smegma$setSender(GameProfile profile) { this.sender = profile; }
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import me.retucio.camtweaks.util.interfaces.IChatHudLineVisible;
|
||||
import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.text.OrderedText;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ChatHudLine.Visible.class)
|
||||
public class ChatHudLineVisibleMixin implements IChatHudLineVisible {
|
||||
|
||||
@Shadow @Final
|
||||
private OrderedText content;
|
||||
|
||||
@Unique
|
||||
private int id;
|
||||
|
||||
@Unique
|
||||
private GameProfile sender;
|
||||
|
||||
@Unique
|
||||
private boolean startOfEntry;
|
||||
|
||||
@Override
|
||||
public String smegma$getText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
content.accept((index, style, codePoint) -> {
|
||||
sb.appendCodePoint(codePoint);
|
||||
return true;
|
||||
});
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int smegma$getId() { return id; }
|
||||
|
||||
@Override
|
||||
public void smegma$setId(int id) { this.id = id; }
|
||||
|
||||
@Override
|
||||
public GameProfile smegma$getSender() { return sender; }
|
||||
|
||||
@Override
|
||||
public void smegma$setSender(GameProfile profile) { this.sender = profile; }
|
||||
|
||||
@Override
|
||||
public boolean smegma$isStartOfEntry() { return startOfEntry; }
|
||||
|
||||
@Override
|
||||
public void smegma$setStartOfEntry(boolean start) { this.startOfEntry = start; }
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import me.retucio.camtweaks.event.events.ReceiveMessageEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.misc.ChatPlus;
|
||||
import me.retucio.camtweaks.util.interfaces.IChatHud;
|
||||
import me.retucio.camtweaks.util.interfaces.IChatHudLine;
|
||||
import me.retucio.camtweaks.util.interfaces.IChatHudLineVisible;
|
||||
import me.retucio.camtweaks.util.interfaces.IMessageHandler;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.ChatHud;
|
||||
import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
||||
import net.minecraft.network.message.MessageSignatureData;
|
||||
import net.minecraft.text.OrderedText;
|
||||
import net.minecraft.text.Text;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.*;
|
||||
|
||||
@Mixin(ChatHud.class)
|
||||
public abstract class ChatHudMixin implements IChatHud {
|
||||
|
||||
@Unique
|
||||
private boolean skipOnAddMessage;
|
||||
|
||||
@Unique
|
||||
private int nextId;
|
||||
|
||||
@Unique
|
||||
ChatPlus chatPlus;
|
||||
|
||||
@Shadow @Final
|
||||
private List<ChatHudLine> messages;
|
||||
|
||||
@Shadow @Final
|
||||
private List<ChatHudLine.Visible> visibleMessages;
|
||||
|
||||
@Shadow
|
||||
public abstract void addMessage(Text message);
|
||||
|
||||
@Shadow
|
||||
public abstract void addMessage(Text message, @Nullable MessageSignatureData signatureData, @Nullable MessageIndicator indicator);
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, CallbackInfo ci) {
|
||||
chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class);
|
||||
}
|
||||
|
||||
|
||||
// métodos relacionados a las interfaces IChatHud, IChatHudLine, IChadHudLineVisible y IMessageHandler
|
||||
|
||||
@Override
|
||||
public void smegma$add(Text message, int id) {
|
||||
nextId = id;
|
||||
addMessage(message);
|
||||
nextId = 0;
|
||||
}
|
||||
|
||||
@Inject(method = "addVisibleMessage", at = @At(value = "INVOKE", target = "Ljava/util/List;addFirst(Ljava/lang/Object;)V", shift = At.Shift.AFTER))
|
||||
private void onAddMessageAfterNewChatHudLineVisible(ChatHudLine message, CallbackInfo ci) {
|
||||
((IChatHudLine) (Object) visibleMessages.getFirst()).smegma$setId(nextId);
|
||||
}
|
||||
|
||||
@Inject(method = "addMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V", at = @At(value = "INVOKE", target = "Ljava/util/List;addFirst(Ljava/lang/Object;)V", shift = At.Shift.AFTER))
|
||||
private void onAddMessageAfterNewChatHudLine(ChatHudLine message, CallbackInfo ci) {
|
||||
((IChatHudLine) (Object) messages.getFirst()).smegma$setId(nextId);
|
||||
}
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@ModifyExpressionValue(method = "addVisibleMessage", at = @At(value = "NEW", target = "(ILnet/minecraft/text/OrderedText;Lnet/minecraft/client/gui/hud/MessageIndicator;Z)Lnet/minecraft/client/gui/hud/ChatHudLine$Visible;"))
|
||||
private ChatHudLine.Visible onAddMessage_modifyChatHudLineVisible(ChatHudLine.Visible line, @Local(ordinal = 1) int j) {
|
||||
IMessageHandler handler = (IMessageHandler) mc.getMessageHandler();
|
||||
if (handler == null) return line;
|
||||
|
||||
IChatHudLineVisible iLine = (IChatHudLineVisible) (Object) line;
|
||||
|
||||
iLine.smegma$setSender(handler.smegma$getSender());
|
||||
iLine.smegma$setStartOfEntry(j == 0);
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At(value = "NEW", target = "(ILnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)Lnet/minecraft/client/gui/hud/ChatHudLine;"))
|
||||
private ChatHudLine onAddMessage_modifyChatHudLine(ChatHudLine line) {
|
||||
IMessageHandler handler = (IMessageHandler) mc.getMessageHandler();
|
||||
if (handler == null) return line;
|
||||
|
||||
((IChatHudLine) (Object) line).smegma$setSender(handler.smegma$getSender());
|
||||
return line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChatHudLine.Visible> smegma$getVisibleMessages() {
|
||||
return visibleMessages;
|
||||
}
|
||||
|
||||
|
||||
// modificar contenido del mensaje
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", cancellable = true)
|
||||
private void onAddMessage(Text message, MessageSignatureData signatureData, MessageIndicator indicator, CallbackInfo ci) {
|
||||
if (skipOnAddMessage) return;
|
||||
|
||||
ReceiveMessageEvent event = EVENT_BUS.post(new ReceiveMessageEvent(message, indicator, nextId));
|
||||
|
||||
if (event.isCancelled()) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
visibleMessages.removeIf(msg -> ((IChatHudLine) (Object) msg).smegma$getId() == nextId && nextId != 0);
|
||||
|
||||
for (int i = messages.size() - 1; i > -1; i--) {
|
||||
if (((IChatHudLine) (Object) messages.get(i)).smegma$getId() == nextId && nextId != 0) {
|
||||
messages.remove(i);
|
||||
chatPlus.removeLine(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.wasModified()) {
|
||||
ci.cancel();
|
||||
|
||||
skipOnAddMessage = true;
|
||||
addMessage(event.getMessage(), signatureData, event.getIndicator());
|
||||
skipOnAddMessage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// cabezas
|
||||
|
||||
@ModifyExpressionValue(method = "render(Lnet/minecraft/client/gui/hud/ChatHud$Backend;IIZ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;ceil(F)I"))
|
||||
private int onRender_modifyWidth(int width) {
|
||||
return (chatPlus.isEnabled() && chatPlus.showHeads.isEnabled()) ? width + 10 : width;
|
||||
}
|
||||
|
||||
|
||||
// historial (registro) del chat
|
||||
|
||||
@ModifyExpressionValue(method = "addMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V", at = @At(value = "CONSTANT", args = "intValue=100"))
|
||||
private int maxLength(int size) {
|
||||
if (!chatPlus.isEnabled()) return size;
|
||||
return size + chatPlus.chatHistoryExtraLength.getIntValue();
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "addVisibleMessage", at = @At(value = "CONSTANT", args = "intValue=100"))
|
||||
private int maxLengthVisible(int size) {
|
||||
if (!chatPlus.isEnabled()) return size;
|
||||
return size + chatPlus.chatHistoryExtraLength.getIntValue();
|
||||
}
|
||||
|
||||
@Inject(method = "addVisibleMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"))
|
||||
private void onBreakChatMessageLines(ChatHudLine message, CallbackInfo ci, @Local List<OrderedText> list) {
|
||||
chatPlus.lines.addFirst(list.size());
|
||||
}
|
||||
|
||||
@Inject(method = "addMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V", at = @At(value = "INVOKE", target = "Ljava/util/List;removeLast()Ljava/lang/Object;"))
|
||||
private void onRemoveMessage(ChatHudLine message, CallbackInfo ci) {
|
||||
int extra = chatPlus.chatHistoryExtraLength.getIntValue();
|
||||
int size = chatPlus.lines.size();
|
||||
|
||||
while (size > 100 + extra) {
|
||||
chatPlus.lines.removeLast();
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "clear", at = @At("HEAD"))
|
||||
private void onClear(boolean clearHistory, CallbackInfo ci) {
|
||||
chatPlus.lines.clear();
|
||||
}
|
||||
|
||||
@Inject(method = "refresh", at = @At("HEAD"))
|
||||
private void onRefresh(CallbackInfo ci) {
|
||||
chatPlus.lines.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.brigadier.ParseResults;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import me.retucio.camtweaks.command.CommandManager;
|
||||
import net.minecraft.client.gui.screen.ChatInputSuggestor;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(ChatInputSuggestor.class)
|
||||
public abstract class ChatInputSuggestorMixin {
|
||||
|
||||
@Shadow
|
||||
private ParseResults<CommandSource> parse;
|
||||
|
||||
@Shadow @Final
|
||||
TextFieldWidget textField;
|
||||
|
||||
@Shadow
|
||||
private ChatInputSuggestor.SuggestionWindow window;
|
||||
|
||||
@Shadow
|
||||
boolean completingSuggestions;
|
||||
|
||||
@Shadow
|
||||
private CompletableFuture<Suggestions> pendingSuggestions;
|
||||
|
||||
@Shadow protected abstract void showCommandSuggestions();
|
||||
|
||||
@Inject(method = "refresh", at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/StringReader;canRead()Z", remap = false), cancellable = true)
|
||||
private void onRefresh(CallbackInfo ci, @Local StringReader reader) {
|
||||
String prefix = CommandManager.INSTANCE.getPrefix();
|
||||
int length = prefix.length();
|
||||
|
||||
if (reader.canRead(length) && reader.getString().startsWith(prefix, reader.getCursor())) {
|
||||
reader.setCursor(reader.getCursor() + length);
|
||||
|
||||
if (parse == null) this.parse = CommandManager.dispatcher.parse(reader, mc.getNetworkHandler().getCommandSource());
|
||||
|
||||
int cursor = textField.getCursor();
|
||||
if (cursor >= length && (window == null || !completingSuggestions)) {
|
||||
pendingSuggestions = CommandManager.dispatcher.getCompletionSuggestions(parse, cursor);
|
||||
pendingSuggestions.thenRun(() -> {
|
||||
if (pendingSuggestions.isDone()) showCommandSuggestions();
|
||||
});
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freecam;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.debug.ChunkBorderDebugRenderer;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(ChunkBorderDebugRenderer.class)
|
||||
public abstract class ChunkBorderDebugRendererMixin {
|
||||
|
||||
@Shadow @Final
|
||||
private MinecraftClient client;
|
||||
|
||||
@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/ChunkSectionPos;from(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/util/math/ChunkSectionPos;"))
|
||||
private ChunkSectionPos getChunkPos(ChunkSectionPos chunkPos) {
|
||||
Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
if (!freecam.isEnabled()) return chunkPos;
|
||||
|
||||
float delta = client.getRenderTickCounter().getTickProgress(true);
|
||||
return ChunkSectionPos.from(
|
||||
ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getX(delta))),
|
||||
ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getY(delta))),
|
||||
ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getZ(delta)))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.event.events.ChunkOcclusionEvent;
|
||||
import net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@Mixin(ChunkOcclusionDataBuilder.class)
|
||||
public abstract class ChunkOcclusionDataBuilderMixin {
|
||||
|
||||
@Inject(method = "markClosed", at = @At("HEAD"), cancellable = true)
|
||||
private void onChunkOcclusion(BlockPos pos, CallbackInfo ci) {
|
||||
ChunkOcclusionEvent event = EVENT_BUS.post(new ChunkOcclusionEvent());
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.mixin.accessor.ConfirmServerResourcePackScreenAccessor;
|
||||
import me.retucio.camtweaks.mixin.accessor.PackAccessor;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.network.RPackBypass;
|
||||
import me.retucio.camtweaks.util.interfaces.IConfirmScreen;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.network.ClientCommonNetworkHandler;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.client.option.ServerList;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@Mixin(ClientCommonNetworkHandler.class)
|
||||
public abstract class ClientCommonNetworkHandlerMixin {
|
||||
|
||||
@Shadow @Final protected MinecraftClient client;
|
||||
@Shadow @Final protected ServerInfo serverInfo;
|
||||
@Shadow @Final protected ClientConnection connection;
|
||||
|
||||
@Unique // tardar 3 segundos porque algunos servers detectar el tiempo entre que se acepta y se carga el pack
|
||||
private final Executor DELAYED_EXECUTOR = CompletableFuture.delayedExecutor(3L, TimeUnit.SECONDS);
|
||||
|
||||
@Inject(method = "createConfirmServerResourcePackScreen", at = @At("TAIL"))
|
||||
private void setScreenBypassAction(UUID id, URL url, String hash, boolean required, Text prompt, CallbackInfoReturnable<Screen> cir) {
|
||||
RPackBypass bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class);
|
||||
if (!bypassPack.isEnabled()) return;
|
||||
|
||||
final Screen screen = cir.getReturnValue();
|
||||
((IConfirmScreen) screen).smegma$setBypassAction(() -> {
|
||||
client.setScreen(((ConfirmServerResourcePackScreenAccessor) screen).getParentScreen());
|
||||
if (this.serverInfo != null) {
|
||||
this.serverInfo.setResourcePackPolicy(bypassPack.getPolicy());
|
||||
this.client.getServerResourcePackProvider().acceptAll();
|
||||
ServerList.updateServerListEntry(this.serverInfo);
|
||||
}
|
||||
bypass(((ConfirmServerResourcePackScreenAccessor) screen).getRequests().stream().map(PackAccessor::callId).toList());
|
||||
});
|
||||
}
|
||||
|
||||
@Unique
|
||||
public void bypass(List<UUID> ids) {
|
||||
ids.forEach(id -> connection.send(new ResourcePackStatusC2SPacket(id, ResourcePackStatusC2SPacket.Status.ACCEPTED)));
|
||||
ids.forEach(id -> connection.send(new ResourcePackStatusC2SPacket(id, ResourcePackStatusC2SPacket.Status.DOWNLOADED)));
|
||||
DELAYED_EXECUTOR.execute(() ->
|
||||
ids.forEach(id -> connection.send(new ResourcePackStatusC2SPacket(id, ResourcePackStatusC2SPacket.Status.SUCCESSFULLY_LOADED)))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import me.retucio.camtweaks.event.Stage;
|
||||
import me.retucio.camtweaks.event.events.DisconnectEvent;
|
||||
import me.retucio.camtweaks.event.events.PacketEvent;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.DisconnectionInfo;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public abstract class ClientConnectionMixin {
|
||||
|
||||
// mandar paquetes
|
||||
|
||||
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;Lio/netty/channel/ChannelFutureListener;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSendPacketPre(Packet<?> packet, ChannelFutureListener channelFutureListener, CallbackInfo ci) {
|
||||
PacketEvent.Send event = EVENT_BUS.post(new PacketEvent.Send(packet, Stage.PRE));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;Lio/netty/channel/ChannelFutureListener;)V", at = @At("TAIL"), cancellable = true)
|
||||
private void onSendPacketPost(Packet<?> packet, ChannelFutureListener channelFutureListener, CallbackInfo ci) {
|
||||
PacketEvent.Send event = EVENT_BUS.post(new PacketEvent.Send(packet, Stage.POST));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
|
||||
// recibir paquetes
|
||||
|
||||
@Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onReceivePacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
||||
PacketEvent.Receive event = EVENT_BUS.post(new PacketEvent.Receive(packet));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
|
||||
// otros
|
||||
|
||||
@Inject(method = "disconnect(Lnet/minecraft/network/DisconnectionInfo;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onDisconnect(DisconnectionInfo disconnectionInfo, CallbackInfo ci) {
|
||||
DisconnectEvent event = EVENT_BUS.post(new DisconnectEvent(disconnectionInfo, mc.getCurrentServerEntry()));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import me.retucio.camtweaks.command.CommandManager;
|
||||
import me.retucio.camtweaks.event.events.SendMessageEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.*;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
public abstract class ClientPlayNetworkHandlerMixin {
|
||||
|
||||
@Unique
|
||||
private boolean ignoreChatMessage;
|
||||
|
||||
@Shadow
|
||||
public abstract void sendChatMessage(String content);
|
||||
|
||||
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
|
||||
private void onSendMessage(String message, CallbackInfo ci) {
|
||||
if (ignoreChatMessage) return;
|
||||
if (!message.startsWith(CommandManager.INSTANCE.getPrefix())) {
|
||||
SendMessageEvent event = EVENT_BUS.post(new SendMessageEvent(message));
|
||||
if (!event.isCancelled()) {
|
||||
ignoreChatMessage = true;
|
||||
sendChatMessage(event.getMessage());
|
||||
ignoreChatMessage = false;
|
||||
}
|
||||
ci.cancel();
|
||||
return;
|
||||
};
|
||||
|
||||
try {
|
||||
CommandManager.dispatch(message.substring(CommandManager.INSTANCE.getPrefix().length()));
|
||||
} catch (CommandSyntaxException e) {
|
||||
ChatUtil.error(e.getMessage());
|
||||
}
|
||||
|
||||
mc.inGameHud.getChatHud().addToMessageHistory(message);
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Redirect(method = "onEntityStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;showFloatingItem(Lnet/minecraft/item/ItemStack;)V"))
|
||||
private void noRenderTotemPop(GameRenderer instance, ItemStack floatingItem) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (!noRender.isEnabled() || noRender.totemPop.isEnabled())
|
||||
mc.gameRenderer.showFloatingItem(floatingItem);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.world.NoMiningInterruptions;
|
||||
import me.retucio.camtweaks.module.modules.player.PortalGUI;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public abstract class ClientPlayerEntityMixin {
|
||||
|
||||
@Shadow
|
||||
private static HitResult checkCrosshairTargetRange(HitResult hitResult, Vec3d cameraPos, double range) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "tickNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", opcode = Opcodes.GETFIELD))
|
||||
private Screen allowScreensInPortals(Screen original) {
|
||||
if (ModuleManager.INSTANCE.getModuleByClass(PortalGUI.class).isEnabled()) return null;
|
||||
return original;
|
||||
}
|
||||
|
||||
// no va??
|
||||
@ModifyReturnValue(method = "getCrosshairTarget(Lnet/minecraft/entity/Entity;DDF)Lnet/minecraft/util/hit/HitResult;", at = @At("RETURN"))
|
||||
private static HitResult onUpdateTargetedEntity(HitResult original, @Local HitResult hitResult, @Local(ordinal = 0) Vec3d vec3d) {
|
||||
NoMiningInterruptions nmi = ModuleManager.INSTANCE.getModuleByClass(NoMiningInterruptions.class);
|
||||
|
||||
if (!(original instanceof EntityHitResult ehr)) return original;
|
||||
if (!nmi.shouldIgnoreEntity((ehr.getEntity()))) return original;
|
||||
|
||||
return checkCrosshairTargetRange(hitResult, vec3d, mc.player.getEntityInteractionRange());
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.event.events.AttackEntityEvent;
|
||||
import me.retucio.camtweaks.event.events.BreakBlockEvent;
|
||||
import me.retucio.camtweaks.event.events.InteractEntityEvent;
|
||||
import me.retucio.camtweaks.event.events.PlaceBlockEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freecam;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(ClientPlayerInteractionManager.class)
|
||||
public abstract class ClientPlayerInteractionManagerMixin {
|
||||
|
||||
@Shadow @Final
|
||||
private MinecraftClient client;
|
||||
|
||||
@Unique
|
||||
Freecam freecam;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, ClientPlayNetworkHandler networkHandler, CallbackInfo ci) {
|
||||
freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "breakBlock", at = @At("HEAD"), cancellable = true)
|
||||
private void onBlockBreak(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
BreakBlockEvent event = EVENT_BUS.post(new BreakBlockEvent(pos));
|
||||
if (event.isCancelled()) cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "interactBlock", at = @At("HEAD"), cancellable = true)
|
||||
private void onBlockPlace(ClientPlayerEntity player, Hand hand, BlockHitResult result, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (mc.player != player) return;
|
||||
PlaceBlockEvent event = EVENT_BUS.post(new PlaceBlockEvent(hand, result));
|
||||
if (event.isCancelled()) cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "interactEntity", at = @At("HEAD"), cancellable = true)
|
||||
private void onEntityInteract(PlayerEntity player, Entity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
|
||||
if (mc.player != player) return;
|
||||
InteractEntityEvent event = EVENT_BUS.post(new InteractEntityEvent(entity, hand));
|
||||
if (event.isCancelled()) cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "attackEntity", at = @At("HEAD"), cancellable = true)
|
||||
private void onAttackEntity(PlayerEntity player, Entity target, CallbackInfo ci) {
|
||||
if (mc.player != player) return;
|
||||
AttackEntityEvent event = EVENT_BUS.post(new AttackEntityEvent(target));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.event.events.AddEntityEvent;
|
||||
import me.retucio.camtweaks.event.events.RemoveEntityEvent;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@Mixin(ClientWorld.class)
|
||||
public abstract class ClientWorldMixin {
|
||||
|
||||
@Shadow @Nullable
|
||||
public abstract Entity getEntityById(int id);
|
||||
|
||||
@Inject(method = "addEntity", at = @At("HEAD"))
|
||||
private void onAddEntity(Entity entity, CallbackInfo ci) {
|
||||
if (entity != null) EVENT_BUS.post(new AddEntityEvent(entity));
|
||||
}
|
||||
|
||||
@Inject(method = "removeEntity", at = @At("HEAD"))
|
||||
private void onRemoveEntity(int entityId, Entity.RemovalReason removalReason, CallbackInfo ci) {
|
||||
Entity entity = getEntityById(entityId);
|
||||
if (entity != null) EVENT_BUS.post(new RemoveEntityEvent(entity));
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.network.RPackBypass;
|
||||
import me.retucio.camtweaks.util.interfaces.IConfirmScreen;
|
||||
import net.minecraft.client.gui.screen.ConfirmScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.DirectionalLayoutWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ConfirmScreen.class)
|
||||
public abstract class ConfirmScreenMixin extends Screen implements IConfirmScreen {
|
||||
|
||||
@Shadow protected DirectionalLayoutWidget layout;
|
||||
@Unique private Runnable bypassAction = null;
|
||||
|
||||
protected ConfirmScreenMixin(final Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ConfirmScreen;addButtons(Lnet/minecraft/client/gui/widget/DirectionalLayoutWidget;)V", shift = At.Shift.AFTER))
|
||||
protected void addBypassButton(CallbackInfo ci) {
|
||||
RPackBypass bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class);
|
||||
if (this.bypassAction != null && bypassPack.isEnabled())
|
||||
this.layout.add(ButtonWidget.builder(bypassPack.BYPASS_TEXT, $ -> this.bypassAction.run()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void smegma$setBypassAction(Runnable bypass) {
|
||||
this.bypassAction = bypass;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.CritsPlus;
|
||||
import net.minecraft.client.particle.BillboardParticle;
|
||||
import net.minecraft.client.particle.DamageParticle;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(DamageParticle.class)
|
||||
public abstract class DamageParticleMixin {
|
||||
|
||||
@ModifyReturnValue(method = "getRenderType", at = @At("RETURN"))
|
||||
private BillboardParticle.RenderType makeCritsTranslucent(BillboardParticle.RenderType original) {
|
||||
if (ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class).isEnabled()) return BillboardParticle.RenderType.PARTICLE_ATLAS_TRANSLUCENT;
|
||||
return original;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Mixin(DamageParticle.Factory.class)
|
||||
abstract class DamageParticleFactoryMixin {
|
||||
|
||||
@ModifyVariable(method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDDLnet/minecraft/util/math/random/Random;)Lnet/minecraft/client/particle/Particle;", at = @At(value = "STORE"))
|
||||
private DamageParticle modifyCritColor(DamageParticle original) {
|
||||
CritsPlus crits = ModuleManager.INSTANCE.getModuleByClass(CritsPlus.class);
|
||||
if (!crits.isEnabled()) return original;
|
||||
|
||||
original.setColor(
|
||||
crits.color.getR() / 255f,
|
||||
crits.color.getG() / 255f,
|
||||
crits.color.getB() / 255f
|
||||
);
|
||||
|
||||
original.alpha = crits.color.getA() / 255f;
|
||||
original.scale *= crits.scale.getFloatValue();
|
||||
original.velocityMultiplier *= crits.velocityMultipler.getFloatValue();
|
||||
original.gravityStrength *= crits.gravity.getFloatValue();
|
||||
original.setMaxAge(crits.maxAge.getIntValue());
|
||||
original.collidesWithWorld = crits.collide.isEnabled();
|
||||
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.event.events.ChangeRotationEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freelook;
|
||||
import me.retucio.camtweaks.module.modules.camera.Rotations;
|
||||
import me.retucio.camtweaks.module.modules.misc.AntiInvis;
|
||||
import me.retucio.camtweaks.module.modules.render.Nametags;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.passive.TameableEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.PersistentProjectileEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public abstract class EntityMixin {
|
||||
|
||||
@Shadow public abstract Text getName();
|
||||
@Shadow public abstract EntityType<?> getType();
|
||||
|
||||
@Shadow private float yaw;
|
||||
@Shadow private float pitch;
|
||||
|
||||
@Unique
|
||||
Freecam freecam;
|
||||
@Unique
|
||||
Freelook freelook;
|
||||
@Unique
|
||||
Nametags nametags;
|
||||
@Unique
|
||||
Rotations rotations;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(EntityType type, World world, CallbackInfo ci) {
|
||||
freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
freelook = ModuleManager.INSTANCE.getModuleByClass(Freelook.class);
|
||||
nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
rotations = ModuleManager.INSTANCE.getModuleByClass(Rotations.class);
|
||||
}
|
||||
|
||||
|
||||
// cámara libre & perspectiva libre
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Inject(method = "changeLookDirection", at = @At("HEAD"), cancellable = true)
|
||||
private void onChangeLookDirection(double cursorDeltaX, double cursorDeltaY, CallbackInfo ci) {
|
||||
if ((Object) this != mc.player) return;
|
||||
|
||||
if (freecam.isEnabled()) {
|
||||
freecam.changeLookDirection(cursorDeltaX * 0.15, cursorDeltaY * 0.15);
|
||||
ci.cancel();
|
||||
|
||||
} else if (freelook.isEnabled() && freelook.mode.is(Freelook.CameraMode.CAMERA)) {
|
||||
freelook.setYaw(freelook.getYaw() + (float) (cursorDeltaX * freelook.mouseSens.getFloatValue()));
|
||||
freelook.setPitch(freelook.getPitch() + (float) (cursorDeltaY * freelook.mouseSens.getFloatValue()));
|
||||
|
||||
if (Math.abs(freelook.getPitch()) > 90) freelook.setPitch(freelook.getPitch() > 0 ? 90 : -90);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// nametags
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@ModifyReturnValue(method = "isCustomNameVisible", at = @At("RETURN"))
|
||||
private boolean renderEntityNametags(boolean original) {
|
||||
if (!nametags.isEnabled()) return original;
|
||||
if ((Object) this instanceof PersistentProjectileEntity p && p.isOnGround()) return false;
|
||||
if ((Object) this instanceof ItemEntity i && !nametags.items.isEnabled(i.getStack().getItem())) return false;
|
||||
return nametags.entities.isEnabled((this.getType()));
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getName", at = @At("RETURN"))
|
||||
private Text showProjectileDamage(Text original) {
|
||||
if (!nametags.isEnabled() || !nametags.showProjectileDamage.isEnabled()) return original;
|
||||
|
||||
if ((Object) this instanceof PersistentProjectileEntity arrow) { // aunque lo llame "arrow", también cubre flechas espectrales y tridentes
|
||||
String damage = nametags.getArrowDamage(arrow);
|
||||
if (!damage.equals("0")) return original.copy().append(Text.literal(" (" + damage + ")").formatted(Formatting.RED));
|
||||
}
|
||||
|
||||
return original;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@ModifyReturnValue(method = "getCustomName", at = @At("RETURN"))
|
||||
private Text displayEntityOwner(Text original) {
|
||||
if (!nametags.isEnabled() || !nametags.petOwner.isEnabled()) return original;
|
||||
if ((Object) this instanceof TameableEntity entity && entity.getOwnerReference() != null) {
|
||||
if (original != null) return original.copy().append(" (de " + nametags.getOwnerName(entity.getOwnerReference()) + ")");
|
||||
else return Text.of(nametags.getOwnerName(entity.getOwnerReference()));
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@ModifyReturnValue(method = "getName", at = @At("RETURN"))
|
||||
private Text showBabies(Text original) {
|
||||
if (!nametags.isEnabled() || !nametags.distinguishBabies.isEnabled()) return original;
|
||||
if ((Object) this instanceof LivingEntity entity && entity.isBaby()) return original.copy().append(" (baby)");
|
||||
return original;
|
||||
}
|
||||
|
||||
|
||||
// rotaciones
|
||||
|
||||
@Inject(method = "setRotation", at = @At("HEAD"), cancellable = true)
|
||||
private void onRotation(float yaw, float pitch, CallbackInfo ci) {
|
||||
if ((Object) this != mc.player) return;
|
||||
ChangeRotationEvent event = EVENT_BUS.post(new ChangeRotationEvent(yaw, pitch));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "setYaw", at = @At("HEAD"), cancellable = true)
|
||||
private void onChangeYaw(float yaw, CallbackInfo ci) {
|
||||
if ((Object) this != mc.player) return;
|
||||
ChangeRotationEvent event = EVENT_BUS.post(new ChangeRotationEvent(yaw, this.pitch));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "setPitch", at = @At("HEAD"), cancellable = true)
|
||||
private void onChangePitch(float pitch, CallbackInfo ci) {
|
||||
if ((Object) this != mc.player) return;
|
||||
ChangeRotationEvent event = EVENT_BUS.post(new ChangeRotationEvent(this.yaw, pitch));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
|
||||
// otros
|
||||
|
||||
@Inject(method = "isInvisibleTo", at = @At("RETURN"), cancellable = true)
|
||||
public void renderInvisPlayers(PlayerEntity player, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ModuleManager.INSTANCE.getModuleByClass(AntiInvis.class).isEnabled()) cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.GlintPlus;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.entity.equipment.EquipmentRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(EquipmentRenderer.class)
|
||||
public abstract class EquipmentRendererMixin {
|
||||
|
||||
@Redirect(method = "render(Lnet/minecraft/client/render/entity/equipment/EquipmentModel$LayerType;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/client/model/Model;Ljava/lang/Object;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/util/Identifier;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayers;armorEntityGlint()Lnet/minecraft/client/render/RenderLayer;"))
|
||||
private RenderLayer redirectArmorEntityGlint() {
|
||||
GlintPlus glintPlus = ModuleManager.INSTANCE.getModuleByClass(GlintPlus.class);
|
||||
return glintPlus.getArmorEntityGlint();
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import net.minecraft.block.enums.CameraSubmersionType;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.fog.FogModifier;
|
||||
import net.minecraft.client.render.fog.FogRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.joml.Vector4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(FogRenderer.class)
|
||||
public abstract class FogRendererMixin {
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@Redirect(method = "applyFog(Lnet/minecraft/client/render/Camera;ILnet/minecraft/client/render/RenderTickCounter;FLnet/minecraft/client/world/ClientWorld;)Lorg/joml/Vector4f;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/fog/FogModifier;shouldApply(Lnet/minecraft/block/enums/CameraSubmersionType;Lnet/minecraft/entity/Entity;)Z"))
|
||||
private boolean noRenderFogs(FogModifier instance, CameraSubmersionType cameraSubmersionType, Entity entity) {
|
||||
if (!noRender.isEnabled()) return instance.shouldApply(cameraSubmersionType, entity);
|
||||
String className = instance.getClass().getSimpleName();
|
||||
|
||||
if ((className.equals("BlindnessEffectFogModifier") && !noRender.blindnessEffect.isEnabled())
|
||||
|| (className.equals("DarknessEffectFogModifier") && !noRender.darknessEffect.isEnabled())
|
||||
|| ((className.equals("LavaFogModifier") || className.equals("WaterFogModifier")
|
||||
|| className.equals("PowederSnowFogModifier")) && !noRender.fluidOverlay.isEnabled()))
|
||||
return false;
|
||||
|
||||
return instance.shouldApply(cameraSubmersionType, entity);
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getFogColor", at = @At("RETURN"))
|
||||
private Vector4f modifyLavaFog(Vector4f original, Camera camera) {
|
||||
if (noRender.isEnabled() && !noRender.fluidOverlay.isEnabled() &&
|
||||
(camera.getSubmersionType() == CameraSubmersionType.LAVA
|
||||
|| camera.getSubmersionType() == CameraSubmersionType.WATER))
|
||||
return new Vector4f(original.x, original.y, original.z, 0f);
|
||||
|
||||
return original;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "getFogColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getUnderwaterVisibility()F"))
|
||||
private float noRenderUnderwaterFog(float original) {
|
||||
return (noRender.isEnabled() && !noRender.fluidOverlay.isEnabled()) ? 0 : original;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.event.events.PerspectiveChangeEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freecam;
|
||||
import net.minecraft.client.option.GameOptions;
|
||||
import net.minecraft.client.option.Perspective;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@Mixin(GameOptions.class)
|
||||
public abstract class GameOptionsMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract Perspective getPerspective();
|
||||
|
||||
@Inject(method = "setPerspective", at = @At("HEAD"), cancellable = true)
|
||||
private void changePerspective(Perspective perspective, CallbackInfo ci) {
|
||||
if (getPerspective() == null) return;
|
||||
if (ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled()) ci.cancel();
|
||||
PerspectiveChangeEvent event = EVENT_BUS.post(new PerspectiveChangeEvent(perspective));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
|
||||
import me.retucio.camtweaks.event.events.GetFOVEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import me.retucio.camtweaks.module.modules.camera.Zoom;
|
||||
import me.retucio.camtweaks.util.interfaces.IVec3d;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.BufferBuilderStorage;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.render.block.BlockRenderManager;
|
||||
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public abstract class GameRendererMixin {
|
||||
|
||||
@Unique
|
||||
boolean freecamDone;
|
||||
|
||||
@Unique
|
||||
Zoom zoom;
|
||||
|
||||
@Unique
|
||||
Freecam freecam;
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Shadow @Final
|
||||
private MinecraftClient client;
|
||||
|
||||
@Shadow
|
||||
public abstract void updateCrosshairTarget(float tickDelta);
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, HeldItemRenderer firstPersonHeldItemRenderer, BufferBuilderStorage buffers, BlockRenderManager blockRenderManager, CallbackInfo ci) {
|
||||
zoom = ModuleManager.INSTANCE.getModuleByClass(Zoom.class);;
|
||||
freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getFov", at = @At("RETURN"))
|
||||
private float modifyFov(float original) {
|
||||
return EVENT_BUS.post(new GetFOVEvent(original)).getFov();
|
||||
}
|
||||
|
||||
@Inject(method = "updateCrosshairTarget", at = @At("HEAD"), cancellable = true)
|
||||
private void updateTargetedEntityInvoke(float tickDelta, CallbackInfo ci) {
|
||||
if ((freecam.isEnabled()) && client.getCameraEntity() != null && !freecamDone) {
|
||||
ci.cancel();
|
||||
|
||||
Entity cameraEntity = client.getCameraEntity();
|
||||
Vector3d pos = freecam.getPos();
|
||||
Vector3d prevPos = freecam.getPrevPos();
|
||||
|
||||
double x = cameraEntity.getX();
|
||||
double y = cameraEntity.getY();
|
||||
double z = cameraEntity.getZ();
|
||||
double lastX = cameraEntity.lastX;
|
||||
double lastY = cameraEntity.lastY;
|
||||
double lastZ = cameraEntity.lastZ;
|
||||
float yaw = cameraEntity.getYaw();
|
||||
float pitch = cameraEntity.getPitch();
|
||||
float lastYaw = cameraEntity.lastYaw;
|
||||
float lastPitch = cameraEntity.lastPitch;
|
||||
|
||||
((IVec3d) cameraEntity.getEntityPos()).smegma$set(pos.x, pos.y - cameraEntity.getEyeHeight(cameraEntity.getPose()), pos.z);
|
||||
cameraEntity.lastX = prevPos.x;
|
||||
cameraEntity.lastY = prevPos.y - cameraEntity.getEyeHeight(cameraEntity.getPose());
|
||||
cameraEntity.lastZ = prevPos.z;
|
||||
cameraEntity.setYaw(freecam.getYaw());
|
||||
cameraEntity.setPitch(freecam.getPitch());
|
||||
cameraEntity.lastYaw = freecam.getPrevYaw();
|
||||
cameraEntity.lastPitch = freecam.getPrevPitch();
|
||||
|
||||
freecamDone = true;
|
||||
updateCrosshairTarget(tickDelta);
|
||||
freecamDone = false;
|
||||
|
||||
((IVec3d) cameraEntity.getEntityPos()).smegma$set(x, y, z);
|
||||
cameraEntity.lastX = lastX;
|
||||
cameraEntity.lastY = lastY;
|
||||
cameraEntity.lastZ = lastZ;
|
||||
cameraEntity.setYaw(yaw);
|
||||
cameraEntity.setPitch(pitch);
|
||||
cameraEntity.lastYaw = lastYaw;
|
||||
cameraEntity.lastPitch = lastPitch;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderHand", at = @At("HEAD"), cancellable = true)
|
||||
private void renderHand(float tickProgress, boolean sleeping, Matrix4f positionMatrix, CallbackInfo ci) {
|
||||
if ((zoom.isEnabled() && !zoom.showHands.isEnabled())
|
||||
|| (freecam.isEnabled() && !freecam.renderHands.isEnabled()))
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "renderWorld", ordinal = 6, at = @At(value = "STORE"))
|
||||
private float noRenderNauseaDistortion(float scaledNauseaEffectFactor) {
|
||||
return (noRender.isEnabled() && !noRender.nauseaEffect.isEnabled()) ? 0 : scaledNauseaEffectFactor;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.event.events.RenderHeldItemEvent;
|
||||
import me.retucio.camtweaks.event.events.RenderArmEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.player.HandView;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.item.ItemModelManager;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.render.command.OrderedRenderCommandQueue;
|
||||
import net.minecraft.client.render.entity.EntityRenderManager;
|
||||
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Hand;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.*;
|
||||
|
||||
@Mixin(HeldItemRenderer.class)
|
||||
public abstract class HeldItemRendererMixin {
|
||||
|
||||
@Unique
|
||||
HandView handView;
|
||||
|
||||
@Shadow
|
||||
private float equipProgressMainHand;
|
||||
|
||||
@Shadow
|
||||
private float equipProgressOffHand;
|
||||
|
||||
@Shadow
|
||||
private ItemStack mainHand;
|
||||
|
||||
@Shadow
|
||||
private ItemStack offHand;
|
||||
|
||||
@Shadow
|
||||
protected abstract boolean shouldSkipHandAnimationOnSwap(ItemStack from, ItemStack to);
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, EntityRenderManager entityRenderDispatcher, ItemModelManager itemModelManager, CallbackInfo ci) {
|
||||
handView = ModuleManager.INSTANCE.getModuleByClass(HandView.class);
|
||||
}
|
||||
|
||||
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemDisplayContext;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;I)V", shift = At.Shift.BEFORE))
|
||||
private void onRenderItem(AbstractClientPlayerEntity player, float tickProgress, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, OrderedRenderCommandQueue orderedRenderCommandQueue, int light, CallbackInfo ci) {
|
||||
EVENT_BUS.post(new RenderHeldItemEvent(matrices, hand));
|
||||
}
|
||||
|
||||
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderArmHoldingItem(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;IFFLnet/minecraft/util/Arm;)V"))
|
||||
private void onRenderArm(AbstractClientPlayerEntity player, float tickProgress, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, OrderedRenderCommandQueue orderedRenderCommandQueue, int light, CallbackInfo ci) {
|
||||
EVENT_BUS.post(new RenderArmEvent(matrices, hand));
|
||||
}
|
||||
|
||||
|
||||
@ModifyReturnValue(method = "shouldSkipHandAnimationOnSwap", at = @At("RETURN"))
|
||||
private boolean modifySkipSwapAnimation(boolean original) {
|
||||
return original || (handView.isEnabled() && handView.skipSwapping.isEnabled());
|
||||
}
|
||||
|
||||
@Inject(method = "applyEatOrDrinkTransformation", at = @At(value = "INVOKE", target = "Ljava/lang/Math;pow(DD)D", shift = At.Shift.BEFORE), cancellable = true)
|
||||
private void cancelTransformations(MatrixStack matrices, float tickDelta, Arm arm, ItemStack stack, PlayerEntity player, CallbackInfo ci) {
|
||||
if (handView.isEnabled() && handView.noFood.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@ModifyArg(method = "updateHeldItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F", ordinal = 2), index = 0)
|
||||
private float modifyEquipProgressMainhand(float value) {
|
||||
if (mc.player == null) return value;
|
||||
float progress = mc.player.getAttackCooldownProgress(1);
|
||||
float modified = handView.isEnabled() && handView.oldAnimations.isEnabled() ? 1 : (float) Math.pow(progress, 3);
|
||||
|
||||
return (shouldSkipHandAnimationOnSwap(mainHand, mc.player.getMainHandStack()) ? modified : 0) - equipProgressMainHand;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "updateHeldItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F", ordinal = 3), index = 0)
|
||||
private float modifyEquipProgressOffhand(float value) {
|
||||
if (mc.player == null) return value;
|
||||
return (shouldSkipHandAnimationOnSwap(offHand, mc.player.getOffHandStack()) ? 1 : 0) - equipProgressOffHand;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.misc.ChatPlus;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import me.retucio.camtweaks.ui.hud.HudRenderer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(InGameHud.class)
|
||||
public abstract class InGameHudMixin {
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
|
||||
// norender
|
||||
|
||||
@Inject(method = "renderScoreboardSidebar*", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderScoreboard(CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.scoreboard.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderTitleAndSubtitle", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderTitles(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.titles.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderNauseaOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderNausea(DrawContext context, float nauseaStrength, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.nauseaEffect.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderSpyglassOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderSpyglass(DrawContext context, float scale, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.spyglassOverlay.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderPortalOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderPortal(DrawContext context, float nauseaStrength, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.portalOverlay.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderPumpkinBlur(DrawContext context, Identifier texture, float opacity, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.pumpkinOverlay.isEnabled() && texture.getPath().equals("textures/misc/pumpkinblur.png")) ci.cancel();
|
||||
}
|
||||
|
||||
|
||||
// otros
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
private void renderHUD(DrawContext ctx, RenderTickCounter tc, CallbackInfo ci) {
|
||||
HudRenderer.render(ctx, tc);
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z"))
|
||||
private boolean alwaysRenderCrosshairInFreecam(boolean firstPerson) {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || firstPerson;
|
||||
}
|
||||
|
||||
@Inject(method = "clear", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;clear(Z)V"), cancellable = true)
|
||||
private void onClear(CallbackInfo ci) {
|
||||
ChatPlus chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class);
|
||||
if (chatPlus.isEnabled() && chatPlus.keepHistory.isEnabled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.InGameOverlayRenderer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.texture.SpriteHolder;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(InGameOverlayRenderer.class)
|
||||
public abstract class InGameOverlayRendererMixin {
|
||||
|
||||
@Unique
|
||||
private static NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(MinecraftClient client, SpriteHolder spriteHolder, VertexConsumerProvider vertexConsumers, CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@Inject(method = "renderFireOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private static void noRenderFireOverlay(MatrixStack matrices, VertexConsumerProvider vertexConsumers, Sprite sprite, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.fireOverlay.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderUnderwaterOverlay", at = @At("HEAD"), cancellable = true)
|
||||
private static void noRenderUnderwaterOverlay(MinecraftClient client, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.fluidOverlay.isEnabled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.Nametags;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(ItemEntity.class)
|
||||
public abstract class ItemEntityMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract ItemStack getStack();
|
||||
|
||||
@ModifyReturnValue(method = "getName", at = @At("RETURN"))
|
||||
private Text showItemCount(Text original) {
|
||||
Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
if (!nametags.isEnabled()) return original;
|
||||
|
||||
int count = this.getStack().getCount();
|
||||
MutableText name = this.getStack().getCustomName() != null ? this.getStack().getCustomName().copyContentOnly() : original.copyContentOnly();
|
||||
|
||||
if (!name.equals(original)) name = name.formatted(Formatting.ITALIC);
|
||||
|
||||
if (nametags.countItems.isEnabled()) {
|
||||
if (count > 1) return name.copy().append(" x" + count);
|
||||
return name;
|
||||
}
|
||||
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.misc.ShulkerPeek;
|
||||
import net.minecraft.block.ShulkerBoxBlock;
|
||||
import net.minecraft.component.type.TooltipDisplayComponent;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.tooltip.TooltipType;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(Item.class)
|
||||
public abstract class ItemMixin {
|
||||
|
||||
@Inject(method = "appendTooltip", at = @At("HEAD"))
|
||||
private void onAppendTooltip(ItemStack stack, Item.TooltipContext context, TooltipDisplayComponent displayComponent, Consumer<Text> textConsumer, TooltipType type, CallbackInfo ci) {
|
||||
ShulkerPeek shulkerPeek = ModuleManager.INSTANCE.getModuleByClass(ShulkerPeek.class);
|
||||
if (!shulkerPeek.isEnabled() || !shulkerPeek.showTooltips.isEnabled()) return;
|
||||
|
||||
if (stack.getItem() instanceof BlockItem blockItem && blockItem.getBlock() instanceof ShulkerBoxBlock) {
|
||||
if (ShulkerPeek.isShulkerEmpty(stack)) {
|
||||
textConsumer.accept(Text.literal("vacío").formatted(Formatting.GRAY, Formatting.ITALIC));
|
||||
} else {
|
||||
textConsumer.accept(
|
||||
Text.literal("mantén ")
|
||||
.append(Text.literal(shulkerPeek.previewKey.getKeyName())
|
||||
.formatted(Formatting.GOLD, Formatting.BOLD))
|
||||
.append(" para previsualizar")
|
||||
.formatted(Formatting.GRAY)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.GlintPlus;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ItemRenderer.class)
|
||||
public abstract class ItemRendererMixin {
|
||||
|
||||
@Unique
|
||||
private static GlintPlus glintPlus;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(CallbackInfo ci) {
|
||||
glintPlus = ModuleManager.INSTANCE.getModuleByClass(GlintPlus.class);
|
||||
}
|
||||
|
||||
@Redirect(method = "getItemGlintConsumer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayers;glint()Lnet/minecraft/client/render/RenderLayer;"))
|
||||
private static RenderLayer getGlint() {
|
||||
return glintPlus.getGlint();
|
||||
}
|
||||
|
||||
@Redirect(method = "getItemGlintConsumer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayers;entityGlint()Lnet/minecraft/client/render/RenderLayer;"))
|
||||
private static RenderLayer getEntityGlint() {
|
||||
return glintPlus.getEntityGlint();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.event.events.DamageItemEvent;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@Mixin(ItemStack.class)
|
||||
public abstract class ItemStackMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract int getDamage();
|
||||
|
||||
@Inject(method = "onDurabilityChange", at = @At("TAIL"))
|
||||
private void onDamage(int damage, ServerPlayerEntity player, Consumer<Item> breakCallback, CallbackInfo ci) {
|
||||
ItemStack stack = (ItemStack) (Object) this;
|
||||
EVENT_BUS.post(new DamageItemEvent(getDamage(), stack));
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freecam;
|
||||
import net.minecraft.client.input.Input;
|
||||
import net.minecraft.client.input.KeyboardInput;
|
||||
import net.minecraft.util.PlayerInput;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(KeyboardInput.class)
|
||||
public abstract class KeyInputMixin extends Input {
|
||||
|
||||
@Inject(method = "tick", at = @At("TAIL"))
|
||||
private void isPressed(CallbackInfo ci) {
|
||||
Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
if (freecam.isEnabled() && freecam.stayCrouching.isEnabled() && freecam.isCrouching())
|
||||
playerInput = new PlayerInput(
|
||||
false, false,
|
||||
false, false,
|
||||
false,
|
||||
true, // siempre agachado
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.KeyEvent;
|
||||
import me.retucio.camtweaks.util.ChatUtil;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.input.KeyInput;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
public abstract class KeyboardMixin {
|
||||
|
||||
@Inject(method = "onKey", at = @At("HEAD"), cancellable = true)
|
||||
private void onKeyPress(long window, int action, KeyInput input, CallbackInfo ci) {
|
||||
if (input.key() == -1) return;
|
||||
CameraTweaks.INSTANCE.onKeyPress(input.key(), action);
|
||||
KeyEvent event = EVENT_BUS.post(new KeyEvent(input.key(), input.scancode(), action));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.textures.GpuTexture;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.camera.Fullbright;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.render.LightmapTextureManager;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LightmapTextureManager.class)
|
||||
public abstract class LightmapTextureManagerMixin {
|
||||
|
||||
@Unique
|
||||
Fullbright fullbright;
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Shadow @Final
|
||||
private GpuTexture glTexture;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(GameRenderer renderer, MinecraftClient client, CallbackInfo ci) {
|
||||
fullbright = ModuleManager.INSTANCE.getModuleByClass(Fullbright.class);
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V", shift = At.Shift.AFTER), cancellable = true)
|
||||
private void update(float tickProgress, CallbackInfo ci, @Local Profiler profiler) {
|
||||
if (fullbright.isEnabled() && fullbright.mode.is(Fullbright.Modes.GAMMA)) {
|
||||
RenderSystem.getDevice().createCommandEncoder().clearColorTexture(glTexture, ColorHelper.getArgb(
|
||||
fullbright.color.getA(),
|
||||
fullbright.color.getR(),
|
||||
fullbright.color.getG(),
|
||||
fullbright.color.getB()
|
||||
));
|
||||
profiler.pop();
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getDarkness", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderDarkness(LivingEntity entity, float factor, float tickProgress, CallbackInfoReturnable<Float> cir) {
|
||||
if (noRender.isEnabled() && !noRender.darknessEffect.isEnabled()) cir.setReturnValue(0f);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.player.ElytraBounce;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class LivingEntityMixin {
|
||||
|
||||
@Unique private boolean prevElytra = false;
|
||||
@Unique private boolean awaitingElytra = false;
|
||||
|
||||
@Shadow
|
||||
public abstract boolean isGliding();
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Inject(method = "tickMovement", at = @At("TAIL"))
|
||||
public void recastIfLanded(CallbackInfo ci) {
|
||||
ElytraBounce bounce = ModuleManager.INSTANCE.getModuleByClass(ElytraBounce.class);
|
||||
|
||||
if (!((Object) this instanceof ClientPlayerEntity)
|
||||
|| mc.player == null
|
||||
|| bounce == null)
|
||||
return;
|
||||
|
||||
boolean elytra = isGliding();
|
||||
|
||||
if (awaitingElytra) {
|
||||
if (elytra) awaitingElytra = false;
|
||||
|
||||
} else if (!elytra && prevElytra) {
|
||||
mc.getSoundManager().stopSounds(SoundEvents.ITEM_ELYTRA_FLYING.id(), SoundCategory.PLAYERS);
|
||||
bounce.bounce();
|
||||
awaitingElytra = bounce.canUseElytra();
|
||||
}
|
||||
|
||||
prevElytra = elytra;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.render.Nametags;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(LivingEntityRenderer.class)
|
||||
public abstract class LivingEntityRendererMixin<T extends LivingEntity> {
|
||||
|
||||
@Unique
|
||||
Nametags nametags;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(EntityRendererFactory.Context ctx, EntityModel<?> model, float shadowRadius, CallbackInfo ci) {
|
||||
nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getCameraEntity()Lnet/minecraft/entity/Entity;"))
|
||||
private Entity hasLabelGetCameraEntityProxy(Entity cameraEntity) {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() ? null : cameraEntity;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSneaky()Z"))
|
||||
private boolean renderSneakingPlayerNametags(boolean original) {
|
||||
return (nametags.isEnabled() && nametags.alwaysVisible.isEnabled()) || original;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isInvisibleTo(Lnet/minecraft/entity/player/PlayerEntity;)Z"))
|
||||
private boolean renderInvisPlayerNametags(boolean original) {
|
||||
if (nametags.isEnabled() && nametags.alwaysVisible.isEnabled()) return false;
|
||||
else return original;
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At("RETURN"))
|
||||
private boolean shouldRenderPlayerNametag(boolean original, @Local(argsOnly = true) T livingEntity) {
|
||||
if (nametags.isEnabled() && livingEntity instanceof PlayerEntity) return nametags.entities.isEnabled(EntityType.PLAYER) && original;
|
||||
return original;
|
||||
}
|
||||
|
||||
@Inject(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At("RETURN"), cancellable = true)
|
||||
private void renderSelfNametag(T livingEntity, double d, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (livingEntity instanceof PlayerEntity player) {
|
||||
if (player == mc.player && nametags.showSelf.isEnabled()) {
|
||||
cir.setReturnValue(true);
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import me.retucio.camtweaks.util.interfaces.IMessageHandler;
|
||||
import net.minecraft.client.network.message.MessageHandler;
|
||||
import net.minecraft.network.message.MessageType;
|
||||
import net.minecraft.network.message.SignedMessage;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@Mixin(MessageHandler.class)
|
||||
public abstract class MessageHandlerMixin implements IMessageHandler {
|
||||
|
||||
@Unique
|
||||
private GameProfile sender;
|
||||
|
||||
@Inject(method = "processChatMessageInternal", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", shift = At.Shift.BEFORE))
|
||||
private void onProcessChatMessageInternal_beforeAddMessage(MessageType.Parameters params, SignedMessage message, Text decorated, GameProfile sender, boolean onlyShowSecureChat, Instant receptionTimestamp, CallbackInfoReturnable<Boolean> info) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Inject(method = "processChatMessageInternal", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", shift = At.Shift.AFTER))
|
||||
private void onProcessChatMessageInternal_afterAddMessage(MessageType.Parameters params, SignedMessage message, Text decorated, GameProfile sender, boolean onlyShowSecureChat, Instant receptionTimestamp, CallbackInfoReturnable<Boolean> info) {
|
||||
this.sender = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile smegma$getSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.JoinWorldEvent;
|
||||
import me.retucio.camtweaks.event.events.OpenScreenEvent;
|
||||
import me.retucio.camtweaks.event.events.ShutdownEvent;
|
||||
import me.retucio.camtweaks.event.events.TickEvent;
|
||||
import me.retucio.camtweaks.event.events.UseItemEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.player.FastUse;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public abstract class MinecraftClientMixin {
|
||||
|
||||
@Shadow
|
||||
private int itemUseCooldown;
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void onTickPre(CallbackInfo ci) {
|
||||
CameraTweaks.INSTANCE.onTick();
|
||||
EVENT_BUS.post(new TickEvent.Pre());
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("TAIL"))
|
||||
private void onTickPost(CallbackInfo ci) {
|
||||
EVENT_BUS.post(new TickEvent.Post());
|
||||
}
|
||||
|
||||
@Inject(method = "stop", at = @At("HEAD"))
|
||||
private void onStop(CallbackInfo ci) {
|
||||
EVENT_BUS.post(new ShutdownEvent());
|
||||
}
|
||||
|
||||
@Inject(method = "setScreen", at = @At("HEAD"), cancellable = true)
|
||||
private void onOpenScreen(Screen screen, CallbackInfo ci) {
|
||||
OpenScreenEvent event = EVENT_BUS.post(new OpenScreenEvent(screen));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "isTelemetryEnabledByApi", at = @At("RETURN"), cancellable = true)
|
||||
private void disableMicropenisTelemetryShi(CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
|
||||
@Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getStackInHand(Lnet/minecraft/util/Hand;)Lnet/minecraft/item/ItemStack;"), cancellable = true)
|
||||
private void onUseItem(CallbackInfo ci, @Local Hand hand) {
|
||||
if (mc.player == null) return;
|
||||
UseItemEvent event = EVENT_BUS.post(new UseItemEvent(mc.player.getStackInHand(hand), hand));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isItemEnabled(Lnet/minecraft/resource/featuretoggle/FeatureSet;)Z"))
|
||||
private void modifyItemUseCooldown(CallbackInfo ci, @Local ItemStack stack) {
|
||||
FastUse fastUse = ModuleManager.INSTANCE.getModuleByClass(FastUse.class);
|
||||
if (!fastUse.isEnabled()) return;
|
||||
itemUseCooldown = fastUse.getCooldown(stack);
|
||||
}
|
||||
|
||||
@Inject(method = "joinWorld", at = @At("HEAD"), cancellable = true)
|
||||
private void onJoinWorld(ClientWorld world, CallbackInfo ci) {
|
||||
JoinWorldEvent event = EVENT_BUS.post(new JoinWorldEvent(world));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.MouseClickEvent;
|
||||
import me.retucio.camtweaks.event.events.MouseScrollEvent;
|
||||
import net.minecraft.client.Mouse;
|
||||
import net.minecraft.client.input.MouseInput;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
|
||||
@Mixin(Mouse.class)
|
||||
public abstract class MouseMixin {
|
||||
|
||||
@Inject(method = "onMouseButton", at = @At("HEAD"), cancellable = true)
|
||||
private void onMouseButton(long window, MouseInput input, int action, CallbackInfo ci) {
|
||||
MouseClickEvent event = EVENT_BUS.post(new MouseClickEvent(action, input.button()));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "onMouseScroll", at = @At("HEAD"), cancellable = true)
|
||||
private void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci) {
|
||||
MouseScrollEvent event = EVENT_BUS.post(new MouseScrollEvent(horizontal, vertical));
|
||||
if (event.isCancelled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ParticleManager.class)
|
||||
public abstract class ParticleManagerMixin {
|
||||
|
||||
@Inject(method = "addParticle(Lnet/minecraft/particle/ParticleEffect;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderParticles(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ, CallbackInfoReturnable<Particle> cir) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (!noRender.isEnabled()) return;
|
||||
if (!noRender.particles.isEnabled(parameters.getType())) cir.setReturnValue(null);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.ClipAtLedgeEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.Nametags;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
public abstract class PlayerEntityMixin extends LivingEntity {
|
||||
|
||||
protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = "getDisplayName", at = @At("RETURN"))
|
||||
private Text addHealthIndicator(Text original) {
|
||||
Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
|
||||
if (!nametags.isEnabled() || !nametags.health.isEnabled()) return original;
|
||||
|
||||
float health = getHealth();
|
||||
float absorption = getAbsorptionAmount();
|
||||
Formatting color;
|
||||
|
||||
if (health < 5) color = Formatting.RED;
|
||||
else if (health < 10) color = Formatting.YELLOW;
|
||||
else if (health < 15) color = Formatting.GREEN;
|
||||
else color = Formatting.DARK_GREEN;
|
||||
|
||||
// me gustaría también añadir un modo en el que se renderizan los corazones directamente en la nametag, pero no sé cómo hacer para las imágenes :'(
|
||||
// ahora que lo pienso en la snapshot más reciente han metido iconos que se pueden usar en texto, y uno de ellos es un corazón :D
|
||||
String text = " [" + color +
|
||||
(nametags.healthMode.is(Nametags.HealthMode.HEARTS)
|
||||
? String.format("%.2f", health / 2) // redondear a dos decimales
|
||||
: (int) health) +
|
||||
(absorption > 0 // tener absorción en cuenta
|
||||
? Formatting.RESET + " + " + Formatting.GOLD +
|
||||
(nametags.healthMode.is(Nametags.HealthMode.HEARTS)
|
||||
? String.format("%.2f", absorption / 2)
|
||||
: Integer.toString((int) absorption))
|
||||
: "") +
|
||||
Formatting.RESET + "]";
|
||||
|
||||
return original.copy().append(text);
|
||||
}
|
||||
|
||||
@Inject(method = "clipAtLedge", at = @At("HEAD"), cancellable = true)
|
||||
private void clipAtLedge(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!getEntityWorld().isClient()) return;
|
||||
ClipAtLedgeEvent event = CameraTweaks.EVENT_BUS.post(new ClipAtLedgeEvent(isSneaking()));
|
||||
cir.setReturnValue(event.isClipping());
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import me.retucio.camtweaks.command.CommandManager;
|
||||
import me.retucio.camtweaks.config.ConfigManager;
|
||||
import me.retucio.camtweaks.event.events.ClientClickEvent;
|
||||
import me.retucio.camtweaks.ui.widgets.frames.settings.ClientSettingsFrame;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(Screen.class)
|
||||
public class ScreenMixin {
|
||||
|
||||
@Inject(method = "handleBasicClickEvent", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
|
||||
private static void handleClientClickEvents(ClickEvent clickEvent, MinecraftClient client, Screen screen, CallbackInfo ci) throws CommandSyntaxException {
|
||||
if (clickEvent instanceof ClientClickEvent event && event.getValue().startsWith(CommandManager.INSTANCE.getPrefix()))
|
||||
CommandManager.dispatch(event.getValue().substring(CommandManager.INSTANCE.getPrefix().length()));
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
private void renderWatermark(DrawContext context, int mouseX, int mouseY, float deltaTicks, CallbackInfo ci) {
|
||||
if (!ConfigManager.hasLoaded()) return; // para evitar dibujar la marca de agua por defecto
|
||||
String watermark = ClientSettingsFrame.guiSettings.watermark.getValue();
|
||||
if (watermark == null || watermark.isEmpty()) return;
|
||||
context.drawText(mc.textRenderer, watermark,
|
||||
mc.getWindow().getScaledWidth() - mc.textRenderer.getWidth(watermark) - 2, 2,
|
||||
ClientSettingsFrame.guiSettings.color.getRGB(), false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.misc.ScreenshotPlus;
|
||||
import net.minecraft.client.texture.NativeImage;
|
||||
import net.minecraft.client.util.ScreenshotRecorder;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(ScreenshotRecorder.class)
|
||||
public abstract class ScreenshotRecorderMixin {
|
||||
|
||||
// "method_22691" es la lambda de la función "saveScreenshot()" (por lo menos en 1.21.6)
|
||||
@Inject(method = "method_22691", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"), cancellable = true)
|
||||
private static void sendActionsMessage(NativeImage nativeImage, File file, Consumer<Text> consumer, CallbackInfo ci) {
|
||||
ScreenshotPlus screenshotPlus = getScreenshotPlus();
|
||||
if (screenshotPlus.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "method_22691", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/NativeImage;writeTo(Ljava/io/File;)V"), cancellable = true)
|
||||
private static void interceptScreenshotFile(NativeImage nativeImage, File file, Consumer<Text> consumer, CallbackInfo ci) throws IOException {
|
||||
ScreenshotPlus screenshotPlus = getScreenshotPlus();
|
||||
|
||||
// aunque el módulo esté apagado, pasar las referencias para poder usar los comandos para las capturas
|
||||
screenshotPlus.setScreenshot(nativeImage);
|
||||
screenshotPlus.setScreenshotFile(file);
|
||||
|
||||
if (!screenshotPlus.isEnabled()) return;
|
||||
|
||||
// por los threads o lo que sea
|
||||
mc.execute(screenshotPlus::sendScreenshotMessage);
|
||||
|
||||
switch (screenshotPlus.defaultAction.getValue()) {
|
||||
case COPY -> screenshotPlus.copyScreenshot(nativeImage);
|
||||
case SAVE -> screenshotPlus.saveScreenshot();
|
||||
case NONE -> ci.cancel();
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static ScreenshotPlus getScreenshotPlus() {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.network.RPackBypass;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.client.resource.server.ServerResourcePackManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.multiplayer.ConnectScreen$1")
|
||||
public abstract class ServerConnectorMixin {
|
||||
|
||||
@Inject(method = "toAcceptanceStatus", at = @At("HEAD"), cancellable = true)
|
||||
private static void guardSwitchCase(ServerInfo.ResourcePackPolicy policy, CallbackInfoReturnable<ServerResourcePackManager.AcceptanceStatus> cir) {
|
||||
RPackBypass bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class);
|
||||
if (!bypassPack.isEnabled()) return;
|
||||
if (policy == bypassPack.getPolicy())
|
||||
cir.setReturnValue(ServerResourcePackManager.AcceptanceStatus.ALLOWED);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.network.RPackBypass;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public abstract class ServerInfoMixin {
|
||||
|
||||
@Shadow private ServerInfo.ResourcePackPolicy resourcePackPolicy;
|
||||
@Unique private boolean isBypassStatus;
|
||||
|
||||
@Unique
|
||||
private static RPackBypass bypassPack;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(String name, String address, ServerInfo.ServerType serverType, CallbackInfo ci) {
|
||||
bypassPack = ModuleManager.INSTANCE.getModuleByClass(RPackBypass.class);
|
||||
}
|
||||
|
||||
@Inject(method = "fromNbt", at = @At("TAIL"))
|
||||
private static void addToRead(NbtCompound root, CallbackInfoReturnable<ServerInfo> cir) {
|
||||
if (!bypassPack.isEnabled()) return;
|
||||
if (root.getBoolean(bypassPack.TAG_NAME, false))
|
||||
cir.getReturnValue().setResourcePackPolicy(bypassPack.getPolicy());
|
||||
}
|
||||
|
||||
@Inject(method = "toNbt", at = @At("HEAD"))
|
||||
private void preWrite(CallbackInfoReturnable<NbtCompound> cir) {
|
||||
if (!bypassPack.isEnabled()) return;
|
||||
if (this.resourcePackPolicy == bypassPack.getPolicy()) {
|
||||
this.isBypassStatus = true;
|
||||
this.resourcePackPolicy = ServerInfo.ResourcePackPolicy.PROMPT;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "toNbt", at = @At("TAIL"))
|
||||
private void addToWrite(CallbackInfoReturnable<NbtCompound> cir) {
|
||||
if (!bypassPack.isEnabled()) return;
|
||||
if (this.isBypassStatus) {
|
||||
cir.getReturnValue().putBoolean(bypassPack.TAG_NAME, true);
|
||||
this.resourcePackPolicy = bypassPack.getPolicy();
|
||||
this.isBypassStatus = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import me.retucio.camtweaks.module.modules.world.TimeChanger;
|
||||
import net.minecraft.client.render.SkyRendering;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.world.MoonPhase;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(SkyRendering.class)
|
||||
public abstract class SkyRendererMixin {
|
||||
|
||||
@Unique
|
||||
TimeChanger timeChanger;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void getModules(CallbackInfo ci) {
|
||||
timeChanger = ModuleManager.INSTANCE.getModuleByClass(TimeChanger.class);
|
||||
}
|
||||
|
||||
@Inject(method = "renderSun", at = @At("HEAD"), cancellable = true)
|
||||
private void onRenderSun(float alpha, MatrixStack matrices, CallbackInfo ci) {
|
||||
if (timeChanger.isEnabled() && !timeChanger.renderSun.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderMoon", at = @At("HEAD"), cancellable = true)
|
||||
private void onRenderMoon(MoonPhase moonPhase, float alpha, MatrixStack matrices, CallbackInfo ci) {
|
||||
if (!timeChanger.isEnabled()) return;
|
||||
if (!timeChanger.renderMoon.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@ModifyArg(method = "renderCelestialBodies", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/SkyRendering;renderMoon(Lnet/minecraft/world/MoonPhase;FLnet/minecraft/client/util/math/MatrixStack;)V"))
|
||||
private MoonPhase timeChangerMoonPhase(MoonPhase original) {
|
||||
if (!timeChanger.isEnabled() || timeChanger.moonPhase.is(TimeChanger.MoonPhases.DEFAULT)) return original;
|
||||
int phase = timeChanger.moonPhase.getIndex();
|
||||
if (timeChanger.moonPhase.is(TimeChanger.MoonPhases.DEFAULT)) phase = original.getIndex();
|
||||
return MoonPhase.values()[phase];
|
||||
}
|
||||
|
||||
@Inject(method = "renderStars", at = @At("HEAD"), cancellable = true)
|
||||
private void onRenderStars(float brightness, MatrixStack matrices, CallbackInfo ci) {
|
||||
if (timeChanger.isEnabled() && !timeChanger.renderStars.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "drawEndLightFlash", at = @At("HEAD"), cancellable = true)
|
||||
private void onEndFlash(MatrixStack matrixStack, float f, float skyFactor, float pitch, CallbackInfo ci) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (noRender.isEnabled() && !noRender.endFlashes.isEnabled()) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import net.minecraft.client.render.fog.StatusEffectFogModifier;
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(StatusEffectFogModifier.class)
|
||||
public abstract class StatusEffectFogModifierMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract RegistryEntry<StatusEffect> getStatusEffect();
|
||||
|
||||
@ModifyReturnValue(method = "shouldApply", at = @At("RETURN"))
|
||||
public boolean noRenderBadEffects(boolean original) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (!noRender.isEnabled()) return original;
|
||||
if (getStatusEffect() == StatusEffects.BLINDNESS && !noRender.blindnessEffect.isEnabled()) return false;
|
||||
if (getStatusEffect() == StatusEffects.DARKNESS && !noRender.darknessEffect.isEnabled()) return false;
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.misc.ChatPlus;
|
||||
import net.minecraft.util.StringHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(StringHelper.class)
|
||||
public abstract class StringHelperMixin {
|
||||
|
||||
@ModifyArg(method = "truncateChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringHelper;truncate(Ljava/lang/String;IZ)Ljava/lang/String;"), index = 1)
|
||||
private static int onTruncate(int maxLength) {
|
||||
ChatPlus chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class);
|
||||
return ((chatPlus.isEnabled() && chatPlus.noCharLimit.isEnabled()) ? Integer.MAX_VALUE : maxLength);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(StuckArrowsFeatureRenderer.class)
|
||||
public abstract class StuckArrowsFeatureRendererMixin {
|
||||
|
||||
@ModifyReturnValue(method = "getObjectCount", at = @At("RETURN"))
|
||||
private int noRenderStuckArrows(int original) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (noRender.isEnabled() && !noRender.stuckArrows.isEnabled()) return 0;
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import net.minecraft.client.session.telemetry.TelemetryManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Coerce;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(TelemetryManager.class)
|
||||
public class TelemetryManagerMixin {
|
||||
|
||||
@Redirect(method = "computeSender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;isTelemetryEnabledByApi()Z"))
|
||||
private boolean disableTelemetry(@Coerce Object minecraftClient) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.TextColor;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
// falta italics pero no sé dónde se comprueba eso, no es aquí :P
|
||||
@Mixin(TextRenderer.Drawer.class)
|
||||
public abstract class TextRendererDrawerMixin {
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/client/font/TextRenderer;FFIIZZ)V", at = @At("TAIL"))
|
||||
private void getModules(TextRenderer textRenderer, float x, float y, int color, int backgroundColor, boolean shadow, boolean trackEmpty, CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@Redirect(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isBold()Z"))
|
||||
private boolean noRenderBold(Style style) {
|
||||
return !(noRender.isEnabled() && !noRender.bold.isEnabled()) && style.isBold();
|
||||
}
|
||||
|
||||
@Redirect(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isUnderlined()Z"))
|
||||
private boolean noRenderUnderlined(Style style) {
|
||||
return !(noRender.isEnabled() && !noRender.underlined.isEnabled()) && style.isUnderlined();
|
||||
}
|
||||
|
||||
@Redirect(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Style;isStrikethrough()Z"))
|
||||
private boolean noRenderStrikethrough(Style style) {
|
||||
return !(noRender.isEnabled() && !noRender.strikethrough.isEnabled()) && style.isStrikethrough();
|
||||
}
|
||||
|
||||
@ModifyArg(method = "accept(ILnet/minecraft/text/Style;Lnet/minecraft/client/font/BakedGlyph;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer$Drawer;getRenderColor(Lnet/minecraft/text/TextColor;)I"))
|
||||
private TextColor noRenderColor(TextColor original) {
|
||||
return !noRender.color.is(NoRender.Colors.DEFAULT) ? TextColor.fromFormatting(noRender.color.getValue().toFormatting()) : original;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.WeatherRendering;
|
||||
import net.minecraft.client.render.state.WeatherRenderState;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.ParticlesMode;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
|
||||
@Mixin(WeatherRendering.class)
|
||||
public abstract class WeatherRenderingMixin {
|
||||
|
||||
@Unique
|
||||
NoRender noRender;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
public void getModules(CallbackInfo ci) {
|
||||
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
}
|
||||
|
||||
@Inject(method = "addParticlesAndSound", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;addParticleClient(Lnet/minecraft/particle/ParticleEffect;DDDDDD)V"), cancellable = true)
|
||||
private void noRainParticles(ClientWorld world, Camera camera, int ticks, ParticlesMode particlesMode, int weatherRadius, CallbackInfo ci) {
|
||||
if (noRender.isEnabled() && !noRender.rain.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "renderPrecipitation", at = @At("HEAD"))
|
||||
private void noRenderRainAndSnow(VertexConsumerProvider vertexConsumers, Vec3d pos, WeatherRenderState weatherRenderState, CallbackInfo ci) {
|
||||
if (noRender.isEnabled()) {
|
||||
if (!noRender.rain.isEnabled()) weatherRenderState.rainPieces.clear();
|
||||
if (!noRender.snow.isEnabled()) weatherRenderState.snowPieces.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||
import me.retucio.camtweaks.CameraTweaks;
|
||||
import me.retucio.camtweaks.event.events.RenderWorldEvent;
|
||||
import me.retucio.camtweaks.module.ModuleManager;
|
||||
import me.retucio.camtweaks.module.modules.render.BlockOutline;
|
||||
import me.retucio.camtweaks.module.modules.camera.Freecam;
|
||||
import me.retucio.camtweaks.module.modules.render.NoRender;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.state.WorldRenderState;
|
||||
import net.minecraft.client.util.ObjectAllocator;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static me.retucio.camtweaks.CameraTweaks.EVENT_BUS;
|
||||
import static me.retucio.camtweaks.CameraTweaks.mc;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public abstract class WorldRendererMixin {
|
||||
|
||||
@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;updateCamera(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;Z)V"), index = 2)
|
||||
private boolean renderSetupTerrainModifyArg(boolean spectator) {
|
||||
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || spectator;
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
private void render(ObjectAllocator allocator, RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, Matrix4f positionMatrix, Matrix4f matrix4f, Matrix4f projectionMatrix, GpuBufferSlice fogBuffer, Vector4f fogColor, boolean renderSky, CallbackInfo ci, @Local Profiler profiler) {
|
||||
if (mc == null || mc.world == null) return;
|
||||
|
||||
MatrixStack matrices = new MatrixStack();
|
||||
matrices.push();
|
||||
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch()));
|
||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180f));
|
||||
|
||||
profiler.push(CameraTweaks.MOD_ID + "-3d");
|
||||
EVENT_BUS.post(new RenderWorldEvent(matrices, tickCounter, camera));
|
||||
|
||||
profiler.pop();
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
@Inject(method = "renderTargetBlockOutline", at = @At("HEAD"), cancellable = true)
|
||||
private void noRenderBlockOutlinesFreecam(VertexConsumerProvider.Immediate immediate, MatrixStack matrices, boolean renderBlockOutline, WorldRenderState renderStates, CallbackInfo ci) {
|
||||
Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
|
||||
if (freecam.isEnabled() && !freecam.blockOutlines.isEnabled()) ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "hasBlindnessOrDarkness(Lnet/minecraft/client/render/Camera;)Z", at = @At("HEAD"), cancellable = true)
|
||||
private void hasBlindnessOrDarkness(Camera camera, CallbackInfoReturnable<Boolean> cir) {
|
||||
NoRender noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
|
||||
if (!noRender.isEnabled()) return;
|
||||
if (!noRender.blindnessEffect.isEnabled() || !noRender.darknessEffect.isEnabled()) cir.setReturnValue(null);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderTargetBlockOutline", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/ColorHelper;toAlpha(I)I"))
|
||||
private int modifyBlockOutlineColor(int alpha) {
|
||||
BlockOutline outline = ModuleManager.INSTANCE.getModuleByClass(BlockOutline.class);
|
||||
if (!outline.isEnabled()) return ColorHelper.toAlpha(alpha);
|
||||
|
||||
return outline.color.getRGB();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.AnvilScreen;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(AnvilScreen.class)
|
||||
public interface AnvilScreenAccessor {
|
||||
|
||||
@Accessor("nameField")
|
||||
TextFieldWidget getNameField();
|
||||
|
||||
@Accessor("nameField")
|
||||
void setNameField(TextFieldWidget nameField);
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.message.LastSeenMessagesCollector;
|
||||
import net.minecraft.network.message.MessageChain;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
public interface ClientPlayNetworkHandlerAccessor {
|
||||
|
||||
@Accessor("lastSeenMessagesCollector")
|
||||
LastSeenMessagesCollector getLastSeenMessagesCollector();
|
||||
|
||||
@Accessor("messagePacker")
|
||||
MessageChain.Packer getMessagePacker();
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.network.ClientCommonNetworkHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ClientCommonNetworkHandler.ConfirmServerResourcePackScreen.class)
|
||||
public interface ConfirmServerResourcePackScreenAccessor {
|
||||
|
||||
@Accessor("parent")
|
||||
Screen getParentScreen();
|
||||
|
||||
@Accessor("packs")
|
||||
List<? extends PackAccessor> getRequests();
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(HandledScreen.class)
|
||||
public interface HandledScreenAccessor {
|
||||
|
||||
@Accessor("focusedSlot")
|
||||
Slot getFocusedSlot();
|
||||
|
||||
@Accessor("doubleClicking")
|
||||
void setDoubleClicking(boolean doubleClicking);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(KeyBinding.class)
|
||||
public interface KeyBindingAccessor {
|
||||
|
||||
@Accessor("boundKey")
|
||||
InputUtil.Key getBoundKey();
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin.accessor;
|
||||
|
||||
import net.minecraft.client.network.ClientCommonNetworkHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(ClientCommonNetworkHandler.ConfirmServerResourcePackScreen.Pack.class)
|
||||
public interface PackAccessor {
|
||||
|
||||
@Invoker
|
||||
UUID callId();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package me.retucio.camtweaks.mixin.accessor;
|
||||
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(StatusEffectInstance.class)
|
||||
public interface StatusEffectInstanceAccessor {
|
||||
|
||||
@Accessor("duration")
|
||||
void setDuration(int duration);
|
||||
}
|
||||
Loaded 100 of 702 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user