4.1 (broken)

This commit is contained in:
retuci0 committed 2026-04-27 21:55:51 +02:00
1 parent 05c5300cd8
commit 1d22ec5176
324 files changed
+5372 -5231

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
# jenny's mod 2 100% real # jenny's mod 2 100% real
mod para Minecraft Fabric 1.21.11 que añade algunas cosas QOL, mayormente relacionadas a la cámara. mod para Minecraft Fabric 26.1 que añade algunas cosas QOL, mayormente relacionadas a la cámara.
## instalación ## instalación
@@ -10,7 +10,7 @@ mod para Minecraft Fabric 1.21.11 que añade algunas cosas QOL, mayormente relac
3. descargar el .jar 3. descargar el .jar
4. moverlo a tu directorio de mods (probablemente `%appdata%/.minecraft/mods`) 4. moverlo a tu directorio de mods (probablemente `%appdata%/.minecraft/mods`)
asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `1.21.11`; Fabric `0.17.3`) asegúrate de tener una version de Minecraft y Fabric compatibles con el mod (MC `26.1`; Fabric `0.18.5`)
es posible que haya problemas al usarlo junto a otros mods, especialmente junto a otros clientes, pues pueden conflictar entre ellos. es posible que haya problemas al usarlo junto a otros mods, especialmente junto a otros clientes, pues pueden conflictar entre ellos.
### para frikis de 200 de iq ### para frikis de 200 de iq
+8 -11
View File
@@ -1,5 +1,5 @@
plugins { plugins {
id 'fabric-loom' version "${loom_version}" id "net.fabricmc.fabric-loom" version "${loom_version}"
id 'maven-publish' id 'maven-publish'
} }
@@ -23,18 +23,15 @@ dependencies {
// mc // mc
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
// mappings
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
// fabric & su api // fabric & su api
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" implementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
// sistema de eventos // sistema de eventos
include(modImplementation "com.github.retuci0:neutrino:${project.neutrino_version}") include(implementation "com.github.retuci0:neutrino:${project.neutrino_version}")
// rpc de discord // rpc de discord
include(modImplementation "dev.firstdark.discordrpc:discord-rpc:1.0.3") include(implementation "dev.firstdark.discordrpc:discord-rpc:1.0.3")
} }
loom { loom {
@@ -50,12 +47,12 @@ processResources {
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
it.options.release = 21 it.options.release = 25
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_21 sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_25
} }
jar { jar {
+5 -3
View File
@@ -1,16 +1,18 @@
# v4.0 # v4.1
## novedades ## novedades
- actualizado a 26.1
### adiciones ### adiciones
#### módulos nuevos: #### módulos nuevos:
- aura de cristales: hace cpvp por ti (muy mejorable, estoy en ello) - autopechera: equipa una pechera antes de atacar con el mazo
### arreglos / mejoras ### arreglos / mejoras
- `$echest` ya funciona y tal - arreglado el cálculo de anchura de los marcos de ajustes para tener en cuenta los botones de los ajustes de colores
## problemas reconocidos ## problemas reconocidos
+5 -6
View File
@@ -1,15 +1,14 @@
org.gradle.jvmargs=-Xmx2G org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true org.gradle.parallel=true
minecraft_version=1.21.11 minecraft_version=26.1.2
yarn_mappings=1.21.11+build.3 loader_version=0.19.2
loader_version=0.18.4 loom_version=1.16-SNAPSHOT
loom_version=1.13-SNAPSHOT
fabric_api_version=0.140.2+1.21.11 fabric_api_version=0.146.0+26.1.2
neutrino_version=1.1.0 neutrino_version=1.1.0
mod_version=4.0 mod_version=4.1
maven_group=me.retucio maven_group=me.retucio
archives_base_name=sputnik archives_base_name=sputnik
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
+32 -29
View File
@@ -32,6 +32,8 @@ import me.retucio.sputnik.ui.widgets.Button;
import me.retucio.sputnik.util.*; import me.retucio.sputnik.util.*;
import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.KeyUtil;
import me.retucio.sputnik.util.misc.BlockIterator;
import me.retucio.sputnik.util.misc.VersionChecker;
import me.retucio.sputnik.util.render.DrawUtil; import me.retucio.sputnik.util.render.DrawUtil;
import me.retucio.sputnik.util.render.RenderUtil; import me.retucio.sputnik.util.render.RenderUtil;
@@ -40,13 +42,13 @@ import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.client.gui.screens.ChatScreen;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screen.TitleScreen; import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.gui.screen.ingame.AbstractCommandBlockScreen; import net.minecraft.client.gui.screens.inventory.AbstractCommandBlockEditScreen;
import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen; import net.minecraft.client.gui.screens.inventory.AbstractSignEditScreen;
import net.minecraft.client.gui.screen.ingame.AnvilScreen; import net.minecraft.client.gui.screens.inventory.AnvilScreen;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@@ -60,7 +62,7 @@ public class Sputnik implements ClientModInitializer {
public static final EventBus EVENT_BUS = new EventBus(); public static final EventBus EVENT_BUS = new EventBus();
public static final Logger LOGGER = LogManager.getLogger(Sputnik.class); public static final Logger LOGGER = LogManager.getLogger(Sputnik.class);
public static final long LAUNCH_TIME = System.currentTimeMillis(); public static final long LAUNCH_TIME = System.currentTimeMillis();
public static MinecraftClient mc; public static Minecraft mc;
// id y versión // id y versión
public static final String MOD_ID = "sputnik"; public static final String MOD_ID = "sputnik";
@@ -81,7 +83,7 @@ public class Sputnik implements ClientModInitializer {
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
mc = MinecraftClient.getInstance(); mc = Minecraft.getInstance();
ConfigManager.load(); ConfigManager.load();
VersionChecker.check(); VersionChecker.check();
@@ -99,7 +101,6 @@ public class Sputnik implements ClientModInitializer {
EVENT_BUS.subscribe(BlockIterator.class); EVENT_BUS.subscribe(BlockIterator.class);
Lists.init(); Lists.init();
Textures.init();
CapeManager.INSTANCE = new CapeManager(); CapeManager.INSTANCE = new CapeManager();
EVENT_BUS.post(new LoadCapeManagerEvent()); EVENT_BUS.post(new LoadCapeManagerEvent());
@@ -110,11 +111,13 @@ public class Sputnik implements ClientModInitializer {
CommandManager.INSTANCE = new CommandManager(); CommandManager.INSTANCE = new CommandManager();
EVENT_BUS.post(new LoadCommandManagerEvent()); EVENT_BUS.post(new LoadCommandManagerEvent());
ClickGUI.INSTANCE = new ClickGUI(); mc.execute(() -> {
HudEditorScreen.INSTANCE = new HudEditorScreen(); Textures.init();
EVENT_BUS.post(new LoadClickGUIEvent()); ClickGUI.INSTANCE = new ClickGUI();
HudEditorScreen.INSTANCE = new HudEditorScreen();
mc.execute(HudRenderer::init); EVENT_BUS.post(new LoadClickGUIEvent());
HudRenderer.init();
});
Runtime.getRuntime().addShutdownHook(new Thread(() -> { Runtime.getRuntime().addShutdownHook(new Thread(() -> {
EVENT_BUS.post(new ShutdownEvent()); EVENT_BUS.post(new ShutdownEvent());
@@ -169,7 +172,7 @@ public class Sputnik implements ClientModInitializer {
// se ocupa de la lógica de encendido y apagado de los módulos // se ocupa de la lógica de encendido y apagado de los módulos
private void handleModuleToggle(int key, boolean anyFocused) { private void handleModuleToggle(int key, boolean anyFocused) {
if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return; if (mc.screen != null && mc.screen != ClickGUI.INSTANCE) return;
for (Module module : ModuleManager.INSTANCE.getModules()) { 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 (key != module.getKey() || anyFocused || KeyUtil.isKeyDown(GLFW.GLFW_KEY_F3)) continue; // evitar interrumpir combinaciones de teclas del F3
@@ -196,11 +199,11 @@ public class Sputnik implements ClientModInitializer {
if (key != ClientSettingsFrame.guiSettings.getKey() || anyFocused || isOnTypingScreen()) if (key != ClientSettingsFrame.guiSettings.getKey() || anyFocused || isOnTypingScreen())
return; return;
if (mc.currentScreen != ClickGUI.INSTANCE) { if (mc.screen != ClickGUI.INSTANCE) {
prevScreen = mc.currentScreen; prevScreen = mc.screen;
mc.setScreen(ClickGUI.INSTANCE); mc.setScreen(ClickGUI.INSTANCE);
} else { } else {
ClickGUI.INSTANCE.close(); ClickGUI.INSTANCE.onClose();
mc.setScreen(prevScreen); mc.setScreen(prevScreen);
} }
} }
@@ -210,22 +213,22 @@ public class Sputnik implements ClientModInitializer {
HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class); HUD hud = ModuleManager.INSTANCE.getModuleByClass(HUD.class);
if (key != hud.editorKey.getValue() || anyFocused || isOnTypingScreen()) return; if (key != hud.editorKey.getValue() || anyFocused || isOnTypingScreen()) return;
if (mc.currentScreen != HudEditorScreen.INSTANCE) { if (mc.screen != HudEditorScreen.INSTANCE) {
if (!hud.isEnabled()) { if (!hud.isEnabled()) {
ChatUtil.warn("HUD está desactivado, lumbreras"); ChatUtil.warn("HUD está desactivado, lumbreras");
return; return;
} }
prevScreen = mc.currentScreen; prevScreen = mc.screen;
mc.setScreen(HudEditorScreen.INSTANCE); mc.setScreen(HudEditorScreen.INSTANCE);
} else { } else {
HudEditorScreen.INSTANCE.close(); HudEditorScreen.INSTANCE.onClose();
mc.setScreen(prevScreen); mc.setScreen(prevScreen);
} }
} }
// se ocupa de apagar los módulos que tengan configurado hacerlo tras soltar su tecla // se ocupa de apagar los módulos que tengan configurado hacerlo tras soltar su tecla
private void handleModuleRelease(int key) { private void handleModuleRelease(int key) {
if (mc.currentScreen != null && mc.currentScreen != ClickGUI.INSTANCE) return; if (mc.screen != null && mc.screen != ClickGUI.INSTANCE) return;
for (Module module : ModuleManager.INSTANCE.getEnabledModules()) for (Module module : ModuleManager.INSTANCE.getEnabledModules())
if (module.shouldToggleOnBindRelease() && key == module.getKey()) if (module.shouldToggleOnBindRelease() && key == module.getKey())
@@ -233,10 +236,10 @@ public class Sputnik implements ClientModInitializer {
} }
private boolean isOnTypingScreen() { private boolean isOnTypingScreen() {
return mc.currentScreen instanceof ChatScreen return mc.screen instanceof ChatScreen
|| mc.currentScreen instanceof AnvilScreen || mc.screen instanceof AnvilScreen
|| mc.currentScreen instanceof AbstractSignEditScreen || mc.screen instanceof AbstractSignEditScreen
|| mc.currentScreen instanceof AbstractCommandBlockScreen; || mc.screen instanceof AbstractCommandBlockEditScreen;
} }
@EventListener @EventListener
@@ -245,7 +248,7 @@ public class Sputnik implements ClientModInitializer {
if (VersionChecker.shouldShowScreen && event.getScreen() instanceof TitleScreen) { if (VersionChecker.shouldShowScreen && event.getScreen() instanceof TitleScreen) {
event.cancel(); event.cancel();
VersionChecker.shouldShowScreen = false; VersionChecker.shouldShowScreen = false;
mc.execute(() -> mc.currentScreen = new UpdateScreen()); mc.execute(() -> mc.screen = new UpdateScreen());
} }
} }
@@ -255,6 +258,6 @@ public class Sputnik implements ClientModInitializer {
} }
public static String getVersionName() { public static String getVersionName() {
return MOD_ID + "_v" + MOD_VERSION + "_" + SharedConstants.getGameVersion().name(); return MOD_ID + "_v" + MOD_VERSION + "_" + SharedConstants.getCurrentVersion().name();
} }
} }
+12 -11
View File
@@ -1,26 +1,27 @@
package me.retucio.sputnik.cape; package me.retucio.sputnik.cape;
import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.Sputnik;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.client.texture.NativeImage; import com.mojang.blaze3d.platform.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.Identifier; import net.minecraft.client.renderer.texture.ReloadableTexture;
import net.minecraft.resources.Identifier;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class Cape { public class Cape {
private final MinecraftClient mc = MinecraftClient.getInstance(); private final Minecraft mc = Minecraft.getInstance();
private final String name; private final String name;
private final Identifier id; private final Identifier id;
private NativeImage img; private NativeImage img;
private NativeImageBackedTexture texture; private DynamicTexture texture;
public Cape(String name) { public Cape(String name) {
this.name = name; this.name = name;
this.id = Identifier.of(Sputnik.MOD_ID, "textures/capes/" + name + ".png"); this.id = Identifier.fromNamespaceAndPath(Sputnik.MOD_ID, "textures/capes/" + name + ".png");
} }
public void load() { public void load() {
@@ -28,7 +29,7 @@ public class Cape {
} }
public NativeImage loadTexture(Identifier id) { public NativeImage loadTexture(Identifier id) {
try (InputStream inputStream = mc.getResourceManager().getResource(id).get().getInputStream()) { try (InputStream inputStream = mc.getResourceManager().getResource(id).get().open()) {
return NativeImage.read(inputStream); return NativeImage.read(inputStream);
} catch (IOException e) { } catch (IOException e) {
Sputnik.LOGGER.error("ups: {}", e.getMessage()); Sputnik.LOGGER.error("ups: {}", e.getMessage());
@@ -37,8 +38,8 @@ public class Cape {
} }
public void register() { public void register() {
texture = new NativeImageBackedTexture(null, img); texture = new DynamicTexture(null, img);
mc.getTextureManager().registerTexture(id, texture); mc.getTextureManager().register(id, texture);
img = null; img = null;
} }
@@ -50,7 +51,7 @@ public class Cape {
return id; return id;
} }
public NativeImageBackedTexture getTexture() { public DynamicTexture getTexture() {
return texture; return texture;
} }
@@ -4,21 +4,21 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandRegistryAccess; import net.minecraft.commands.CommandBuildContext;
import net.minecraft.command.CommandSource; import net.minecraft.commands.Commands;
import net.minecraft.registry.BuiltinRegistries; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.server.command.CommandManager; import net.minecraft.data.registries.VanillaRegistries;
import java.util.List; import java.util.List;
public abstract class Command { public abstract class Command {
// utilizar los "registries" ya existentes de Brigadier para el autocompletado // utilizar los "registries" ya existentes de Brigadier para el autocompletado
protected static final CommandRegistryAccess REGISTRY_ACCESS = CommandManager.createRegistryAccess(BuiltinRegistries.createWrapperLookup()); protected static final CommandBuildContext REGISTRY_ACCESS = Commands.createValidationContext(VanillaRegistries.createLookup());
protected static final int SUCCESS = com.mojang.brigadier.Command.SINGLE_SUCCESS; protected static final int SUCCESS = com.mojang.brigadier.Command.SINGLE_SUCCESS;
protected static final MinecraftClient mc = MinecraftClient.getInstance(); protected static final Minecraft mc = Minecraft.getInstance();
private final String name, description; private final String name, description;
private final List<String> aliases; private final List<String> aliases;
@@ -30,27 +30,27 @@ public abstract class Command {
} }
// métodos "helper" para reducir el "boilerplate" // métodos "helper" para reducir el "boilerplate"
protected static <T> RequiredArgumentBuilder<CommandSource, T> argument(final String name, final ArgumentType<T> type) { protected static <T> RequiredArgumentBuilder<SharedSuggestionProvider, T> argument(final String name, final ArgumentType<T> type) {
return RequiredArgumentBuilder.argument(name, type); return RequiredArgumentBuilder.argument(name, type);
} }
protected static LiteralArgumentBuilder<CommandSource> literal(final String name) { protected static LiteralArgumentBuilder<SharedSuggestionProvider> literal(final String name) {
return LiteralArgumentBuilder.literal(name); return LiteralArgumentBuilder.literal(name);
} }
// para registrar comandos // para registrar comandos
public final void registerTo(CommandDispatcher<CommandSource> dispatcher) { public final void registerTo(CommandDispatcher<SharedSuggestionProvider> dispatcher) {
register(dispatcher, name); register(dispatcher, name);
for (String alias : aliases) register(dispatcher, alias); for (String alias : aliases) register(dispatcher, alias);
} }
public void register(CommandDispatcher<CommandSource> dispatcher, String name) { public void register(CommandDispatcher<SharedSuggestionProvider> dispatcher, String name) {
LiteralArgumentBuilder<CommandSource> builder = LiteralArgumentBuilder.literal(name); LiteralArgumentBuilder<SharedSuggestionProvider> builder = LiteralArgumentBuilder.literal(name);
build(builder); build(builder);
dispatcher.register(builder); dispatcher.register(builder);
} }
public abstract void build(LiteralArgumentBuilder<CommandSource> builder); public abstract void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder);
public String getName() { public String getName() {
return name; return name;
@@ -5,8 +5,8 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.command.commands.*; import me.retucio.sputnik.command.commands.*;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
@@ -22,9 +22,9 @@ public class CommandManager {
private String prefix = "$"; private String prefix = "$";
public static final List<Command> commands = new ArrayList<>(); public static final List<Command> commands = new ArrayList<>();
public static final CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<>(); public static final CommandDispatcher<SharedSuggestionProvider> dispatcher = new CommandDispatcher<>();
private static final MinecraftClient mc = MinecraftClient.getInstance(); private static final Minecraft mc = Minecraft.getInstance();
public CommandManager() { public CommandManager() {
registerCommands(); registerCommands();
@@ -68,7 +68,7 @@ public class CommandManager {
} }
public static void dispatch(String message) throws CommandSyntaxException { public static void dispatch(String message) throws CommandSyntaxException {
dispatcher.execute(message, Objects.requireNonNull(mc.getNetworkHandler()).getCommandSource()); dispatcher.execute(message, Objects.requireNonNull(mc.getConnection()).getSuggestionsProvider());
} }
public static Command getCommandByName(String name) { public static Command getCommandByName(String name) {
@@ -9,9 +9,9 @@ import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder; import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import me.retucio.sputnik.util.EntityUtil; import me.retucio.sputnik.util.EntityUtil;
import net.minecraft.entity.Entity; import net.minecraft.network.chat.Component;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.entity.Entity;
import net.minecraft.text.Text; import net.minecraft.world.entity.player.Player;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@@ -25,7 +25,7 @@ public class EntityArgumentType implements ArgumentType<Entity> {
public static final EntityArgumentType INSTANCE = new EntityArgumentType(); public static final EntityArgumentType INSTANCE = new EntityArgumentType();
private static final DynamicCommandExceptionType NO_SUCH_ENTITY = new DynamicCommandExceptionType( private static final DynamicCommandExceptionType NO_SUCH_ENTITY = new DynamicCommandExceptionType(
name -> Text.literal("Entidad \"" + name + "\" no encontrada")); name -> Component.literal("Entidad \"" + name + "\" no encontrada"));
private static final Collection<String> EXAMPLES = List.of( private static final Collection<String> EXAMPLES = List.of(
"AdlerHitdolf", "AdlerHitdolf",
@@ -42,7 +42,7 @@ public class EntityArgumentType implements ArgumentType<Entity> {
public Entity parse(StringReader reader) throws CommandSyntaxException { public Entity parse(StringReader reader) throws CommandSyntaxException {
String argument = reader.readString(); String argument = reader.readString();
if (mc.world == null) if (mc.level == null)
throw NO_SUCH_ENTITY.create(argument); throw NO_SUCH_ENTITY.create(argument);
if (argument.startsWith("@")) if (argument.startsWith("@"))
@@ -83,13 +83,13 @@ public class EntityArgumentType implements ArgumentType<Entity> {
} }
private Entity findNearestPlayer() throws CommandSyntaxException { private Entity findNearestPlayer() throws CommandSyntaxException {
PlayerEntity nearest = null; Player nearest = null;
double nearestDistance = Double.MAX_VALUE; double nearestDistance = Double.MAX_VALUE;
for (PlayerEntity player : mc.world.getPlayers()) { for (Player player : mc.level.players()) {
if (player == mc.player) continue; if (player == mc.player) continue;
double distance = mc.player.squaredDistanceTo(player); double distance = mc.player.distanceToSqr(player);
if (distance < nearestDistance) { if (distance < nearestDistance) {
nearestDistance = distance; nearestDistance = distance;
nearest = player; nearest = player;
@@ -103,7 +103,7 @@ public class EntityArgumentType implements ArgumentType<Entity> {
} }
private Entity findRandomPlayer() throws CommandSyntaxException { private Entity findRandomPlayer() throws CommandSyntaxException {
List<PlayerEntity> players = new ArrayList<>(mc.world.getPlayers()); List<Player> players = new ArrayList<>(mc.level.players());
if (players.isEmpty()) throw NO_SUCH_ENTITY.create("@r"); if (players.isEmpty()) throw NO_SUCH_ENTITY.create("@r");
players.remove(mc.player); players.remove(mc.player);
@@ -116,8 +116,8 @@ public class EntityArgumentType implements ArgumentType<Entity> {
private Entity parseEntitySelector(String selector) throws CommandSyntaxException { private Entity parseEntitySelector(String selector) throws CommandSyntaxException {
if (selector.equals("@e")) { if (selector.equals("@e")) {
List<Entity> entities = new ArrayList<>(); List<Entity> entities = new ArrayList<>();
for (Entity entity : mc.world.getEntities()) for (Entity entity : mc.level.getEntities().getAll())
if (!(entity instanceof PlayerEntity)) if (!(entity instanceof Player))
entities.add(entity); entities.add(entity);
if (entities.isEmpty()) throw NO_SUCH_ENTITY.create(selector); if (entities.isEmpty()) throw NO_SUCH_ENTITY.create(selector);
@@ -141,8 +141,8 @@ public class EntityArgumentType implements ArgumentType<Entity> {
private Entity findEntityByType(String type) throws CommandSyntaxException { private Entity findEntityByType(String type) throws CommandSyntaxException {
List<Entity> matchingEntities = new ArrayList<>(); List<Entity> matchingEntities = new ArrayList<>();
for (Entity entity : mc.world.getEntities()) { for (Entity entity : mc.level.getEntities().getAll()) {
String entityType = entity.getType().getTranslationKey(); String entityType = entity.getType().getDescriptionId();
if (entityType.contains(type.toLowerCase().replace("minecraft:", ""))) if (entityType.contains(type.toLowerCase().replace("minecraft:", "")))
matchingEntities.add(entity); matchingEntities.add(entity);
} }
@@ -153,7 +153,7 @@ public class EntityArgumentType implements ArgumentType<Entity> {
double nearestDistance = Double.MAX_VALUE; double nearestDistance = Double.MAX_VALUE;
for (Entity entity : matchingEntities) { for (Entity entity : matchingEntities) {
double distance = mc.player.squaredDistanceTo(entity); double distance = mc.player.distanceToSqr(entity);
if (distance < nearestDistance) { if (distance < nearestDistance) {
nearestDistance = distance; nearestDistance = distance;
nearest = entity; nearest = entity;
@@ -164,15 +164,15 @@ public class EntityArgumentType implements ArgumentType<Entity> {
} }
private Entity findEntityByUUID(UUID uuid) throws CommandSyntaxException { private Entity findEntityByUUID(UUID uuid) throws CommandSyntaxException {
for (Entity entity : mc.world.getEntities()) for (Entity entity : mc.level.getEntities().getAll())
if (entity.getUuid().equals(uuid)) if (entity.getUUID().equals(uuid))
return entity; return entity;
throw NO_SUCH_ENTITY.create(uuid.toString()); throw NO_SUCH_ENTITY.create(uuid.toString());
} }
private PlayerEntity findPlayerByName(String name) throws CommandSyntaxException { private Player findPlayerByName(String name) throws CommandSyntaxException {
for (PlayerEntity player : mc.world.getPlayers()) for (Player player : mc.level.players())
if (player.getName().getString().equalsIgnoreCase(name)) if (player.getName().getString().equalsIgnoreCase(name))
return player; return player;
@@ -181,8 +181,8 @@ public class EntityArgumentType implements ArgumentType<Entity> {
@Override @Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) { public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
if (mc.world != null) if (mc.level != null)
for (PlayerEntity player : mc.world.getPlayers()) for (Player player : mc.level.players())
builder.suggest(player.getName().getString()); builder.suggest(player.getName().getString());
@@ -192,7 +192,7 @@ public class EntityArgumentType implements ArgumentType<Entity> {
Entity lookingAt = EntityUtil.getEntityPlayerIsLookingAt(); Entity lookingAt = EntityUtil.getEntityPlayerIsLookingAt();
if (lookingAt != null) if (lookingAt != null)
builder.suggest(lookingAt.getUuid().toString()); builder.suggest(lookingAt.getUUID().toString());
return builder.buildFuture(); return builder.buildFuture();
} }
@@ -7,15 +7,15 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder; import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class EnumArgumentType<T extends Enum<T>> implements ArgumentType<T> { public class EnumArgumentType<T extends Enum<T>> implements ArgumentType<T> {
private static final DynamicCommandExceptionType NO_SUCH_TYPE = new DynamicCommandExceptionType((value) -> Text.of(" argumento inválido: " + value)); private static final DynamicCommandExceptionType NO_SUCH_TYPE = new DynamicCommandExceptionType((value) -> Component.nullToEmpty(" argumento inválido: " + value));
private final T[] values; private final T[] values;
@@ -41,6 +41,6 @@ public class EnumArgumentType<T extends Enum<T>> implements ArgumentType<T> {
} }
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) { public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestMatching(Arrays.stream(this.values).map(e -> e.toString().toLowerCase()), builder); return SharedSuggestionProvider.suggest(Arrays.stream(this.values).map(e -> e.toString().toLowerCase()), builder);
} }
} }
@@ -10,8 +10,8 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.MiscUtil;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
import java.util.Collection; import java.util.Collection;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@@ -22,7 +22,7 @@ public class ModuleArgumentType implements ArgumentType<Module> {
public static final ModuleArgumentType INSTANCE = new ModuleArgumentType(); public static final ModuleArgumentType INSTANCE = new ModuleArgumentType();
private static final DynamicCommandExceptionType UNKNOWN_MODULE = new DynamicCommandExceptionType( private static final DynamicCommandExceptionType UNKNOWN_MODULE = new DynamicCommandExceptionType(
name -> Text.literal("módulo \"" + name + "\" no encontrado")); name -> Component.literal("módulo \"" + name + "\" no encontrado"));
private static final Collection<String> examples = ModuleManager.INSTANCE.getModules() private static final Collection<String> examples = ModuleManager.INSTANCE.getModules()
.stream().limit(3).map(module -> module.getName().replace(" ", "_")).toList(); .stream().limit(3).map(module -> module.getName().replace(" ", "_")).toList();
@@ -37,7 +37,7 @@ public class ModuleArgumentType implements ArgumentType<Module> {
@Override @Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) { public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestMatching(ModuleManager.INSTANCE.getModules() return SharedSuggestionProvider.suggest(ModuleManager.INSTANCE.getModules()
.stream().map(module -> MiscUtil.removeAccentMarks(module.getName().replace(" ", "_"))), builder); .stream().map(module -> MiscUtil.removeAccentMarks(module.getName().replace(" ", "_"))), builder);
} }
@@ -46,7 +46,7 @@ public class ModuleArgumentType implements ArgumentType<Module> {
return examples; return examples;
} }
public static Module get(CommandContext<CommandSource> ctx) { public static Module get(CommandContext<SharedSuggestionProvider> ctx) {
return ctx.getArgument("módulo", Module.class); return ctx.getArgument("módulo", Module.class);
} }
} }
@@ -7,9 +7,9 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder; import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.chat.Component;
import net.minecraft.text.Text; import net.minecraft.world.entity.player.Player;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -18,21 +18,21 @@ import java.util.concurrent.CompletableFuture;
import static me.retucio.sputnik.Sputnik.mc; import static me.retucio.sputnik.Sputnik.mc;
// para autocompletar nombres de jugadores // para autocompletar nombres de jugadores
public class PlayerArgumentType implements ArgumentType<PlayerEntity> { public class PlayerArgumentType implements ArgumentType<Player> {
public static final PlayerArgumentType INSTANCE = new PlayerArgumentType(); public static final PlayerArgumentType INSTANCE = new PlayerArgumentType();
private static final DynamicCommandExceptionType NO_SUCH_PLAYER = new DynamicCommandExceptionType(name -> Text.literal("Player with name " + name + " doesn't exist.")); private static final DynamicCommandExceptionType NO_SUCH_PLAYER = new DynamicCommandExceptionType(name -> Component.literal("Player with name " + name + " doesn't exist."));
private static final Collection<String> EXAMPLES = List.of("retucio", "prepucio", "postpucio", "pucio", "adler hitdolf"); private static final Collection<String> EXAMPLES = List.of("retucio", "prepucio", "postpucio", "pucio", "adler hitdolf");
private PlayerArgumentType() {} private PlayerArgumentType() {}
@Override @Override
public PlayerEntity parse(StringReader reader) throws CommandSyntaxException { public Player parse(StringReader reader) throws CommandSyntaxException {
String argument = reader.readString(); String argument = reader.readString();
PlayerEntity playerEntity = null; Player playerEntity = null;
for (PlayerEntity p : mc.world.getPlayers()) for (Player p : mc.level.players())
if (p.getName().getString().equalsIgnoreCase(argument)) { if (p.getName().getString().equalsIgnoreCase(argument)) {
playerEntity = p; playerEntity = p;
break; break;
@@ -45,7 +45,7 @@ public class PlayerArgumentType implements ArgumentType<PlayerEntity> {
@Override @Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) { public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestMatching(mc.world.getPlayers().stream().map( return SharedSuggestionProvider.suggest(mc.level.players().stream().map(
abstractClientPlayerEntity -> abstractClientPlayerEntity.getName().getString()), builder); abstractClientPlayerEntity -> abstractClientPlayerEntity.getName().getString()), builder);
} }
@@ -54,8 +54,8 @@ public class PlayerArgumentType implements ArgumentType<PlayerEntity> {
return EXAMPLES; return EXAMPLES;
} }
public static PlayerEntity get(CommandContext<?> context) { public static Player get(CommandContext<?> context) {
return context.getArgument("jugador", PlayerEntity.class); return context.getArgument("jugador", Player.class);
} }
} }
@@ -8,14 +8,13 @@ import me.retucio.sputnik.module.setting.settings.KeySetting;
import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.KeyUtil;
import net.minecraft.client.input.KeyInput; import net.minecraft.ChatFormatting;
import net.minecraft.client.option.KeyBinding; import net.minecraft.client.KeyMapping;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.input.KeyEvent;
import net.minecraft.command.CommandSource; import net.minecraft.client.resources.language.I18n;
import net.minecraft.text.Text; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.util.Formatting; import net.minecraft.network.chat.Component;
import javax.swing.text.JTextComponent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -29,19 +28,20 @@ public class BindCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder builder
.then(argument("módulo", ModuleArgumentType.INSTANCE) .then(argument("módulo", ModuleArgumentType.INSTANCE)
.executes(ctx -> { .executes(ctx -> {
Module module = ctx.getArgument("módulo", Module.class); Module module = ctx.getArgument("módulo", Module.class);
listeningModule = module; listeningModule = module;
ChatUtil.info("presiona una tecla para asignarla al módulo " + Formatting.GREEN + module.getName()); ChatUtil.info("presiona una tecla para asignarla al módulo " + ChatFormatting.GREEN + module.getName());
return SUCCESS; return SUCCESS;
}) })
.then(literal("reset").executes(ctx -> { .then(literal("reset").executes(ctx -> {
Module module = ctx.getArgument("módulo", Module.class); Module module = ctx.getArgument("módulo", Module.class);
module.getBind().reset(); module.getBind().reset();
ChatUtil.info("tecla para el módulo " + Formatting.GREEN + module.getName() + " restablecida a " + Formatting.AQUA + KeyUtil.getKeyName(module.getKey())); ChatUtil.info("tecla para el módulo " + ChatFormatting.GREEN + module.getName()
+ " restablecida a " + ChatFormatting.AQUA + KeyUtil.getKeyName(module.getKey()));
return SUCCESS; return SUCCESS;
})) }))
); );
@@ -52,16 +52,16 @@ public class BindCommand extends Command {
KeySetting bind = listeningModule.getBind(); KeySetting bind = listeningModule.getBind();
if (ClientSettingsFrame.guiSettings.multipleKeybinds.getValue()) { if (ClientSettingsFrame.guiSettings.multipleKeybinds.getValue()) {
List<KeyBinding> keys = new ArrayList<>(List.of(mc.options.allKeys)); List<KeyMapping> keys = new ArrayList<>(List.of(mc.options.keyMappings));
keys.removeAll(List.of(mc.options.debugKeys)); keys.removeAll(List.of(mc.options.debugKeys));
for (KeyBinding kb : keys) { for (KeyMapping kb : keys) {
boolean keyAlreadyBound = kb.matchesKey(new KeyInput(key, 0, 0)); boolean keyAlreadyBound = kb.matches(new KeyEvent(key, 0, 0));
boolean allowMultiple = ClientSettingsFrame.guiSettings.multipleKeybinds.getValue(); boolean allowMultiple = ClientSettingsFrame.guiSettings.multipleKeybinds.getValue();
if (keyAlreadyBound && !allowMultiple) { if (keyAlreadyBound && !allowMultiple) {
ChatUtil.warn("esa tecla ya está cogida por " ChatUtil.warn("esa tecla ya está cogida por "
+ Formatting.GREEN + "\"" + I18n.translate(kb.getId()) + "\""); + ChatFormatting.GREEN + "\"" + I18n.get(kb.getName() + "\""));
listeningModule = null; listeningModule = null;
return true; return true;
} }
@@ -71,8 +71,8 @@ public class BindCommand extends Command {
if (bind != null) bind.setValue(key); if (bind != null) bind.setValue(key);
ChatUtil.info( ChatUtil.info(
Text.of("la tecla " + Formatting.AQUA + KeyUtil.getKeyName(key) + Formatting.RESET + Component.nullToEmpty("la tecla " + ChatFormatting.AQUA + KeyUtil.getKeyName(key) + ChatFormatting.RESET +
" ha sido asignada al módulo " + Formatting.GREEN + listeningModule.getName()) " ha sido asignada al módulo " + ChatFormatting.GREEN + listeningModule.getName())
); );
listeningModule = null; listeningModule = null;
@@ -4,10 +4,10 @@ import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.EnumArgumentType; import me.retucio.sputnik.command.args.EnumArgumentType;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; import net.minecraft.client.gui.screens.inventory.ContainerScreen;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.screen.slot.SlotActionType; import net.minecraft.world.inventory.ContainerInput;
// https://cdn.discordapp.com/attachments/1456079799045980400/1457154232737206375/dupersunited-public-addon-1.21.11-3.1.3.jar?ex=69735be1&is=69720a61&hm=77fb6faee49762e0a812661f0d98931e89cb725db711c45722249d0efe3b91e4& // https://cdn.discordapp.com/attachments/1456079799045980400/1457154232737206375/dupersunited-public-addon-1.21.11-3.1.3.jar?ex=69735be1&is=69720a61&hm=77fb6faee49762e0a812661f0d98931e89cb725db711c45722249d0efe3b91e4&
public class ClickSlotCommand extends Command { public class ClickSlotCommand extends Command {
@@ -16,16 +16,17 @@ public class ClickSlotCommand extends Command {
super("clickslot", "simula un clic a un slot"); super("clickslot", "simula un clic a un slot");
} }
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.then(argument("slot", IntegerArgumentType.integer()) builder.then(argument("slot", IntegerArgumentType.integer())
.then(argument("botón", IntegerArgumentType.integer()) .then(argument("botón", IntegerArgumentType.integer())
.then(argument("acción", EnumArgumentType.enumArgument(SlotActionType.SWAP)) .then(argument("acción", EnumArgumentType.enumArgument(ContainerInput.SWAP))
.executes(context -> { .executes(context -> {
int slot = context.getArgument("slot", Integer.class), button = context.getArgument("botón", Integer.class); int slot = context.getArgument("slot", Integer.class), button = context.getArgument("botón", Integer.class);
SlotActionType action = context.getArgument("acción", SlotActionType.class); ContainerInput action = context.getArgument("acción", ContainerInput.class);
Screen screen = mc.currentScreen; Screen screen = mc.screen;
int syncId = (screen instanceof GenericContainerScreen gcScreen) ? gcScreen.getScreenHandler().syncId : 0; int syncId = (screen instanceof ContainerScreen cScreen) ? cScreen.getMenu().containerId : 0;
mc.interactionManager.clickSlot(syncId, slot, button, action, mc.player); if (mc.gameMode == null) return 0;
mc.gameMode.handleContainerInput(syncId, slot, button, action, mc.player);
return SUCCESS; return SUCCESS;
}) })
) )
@@ -7,7 +7,7 @@ import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.ModuleArgumentType; import me.retucio.sputnik.command.args.ModuleArgumentType;
import me.retucio.sputnik.ui.screen.ClickGUI; import me.retucio.sputnik.ui.screen.ClickGUI;
import me.retucio.sputnik.ui.widgets.frames.SettingsFrame; import me.retucio.sputnik.ui.widgets.frames.SettingsFrame;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
public class ConfigCommand extends Command { public class ConfigCommand extends Command {
@@ -17,7 +17,7 @@ public class ConfigCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder builder
.then(argument("módulo", ModuleArgumentType.INSTANCE) .then(argument("módulo", ModuleArgumentType.INSTANCE)
.executes(ctx -> { .executes(ctx -> {
@@ -38,20 +38,20 @@ public class ConfigCommand extends Command {
} }
private void openSf(CommandContext<CommandSource> ctx) { private void openSf(CommandContext<SharedSuggestionProvider> ctx) {
Module module = ctx.getArgument("módulo", Module.class); Module module = ctx.getArgument("módulo", Module.class);
mc.setScreen(ClickGUI.INSTANCE); mc.setScreen(ClickGUI.INSTANCE);
if (ClickGUI.INSTANCE.isSettingsFrameOpen(module)) return; if (ClickGUI.INSTANCE.isSettingsFrameOpen(module)) return;
SettingsFrame sf = ClickGUI.INSTANCE.getSfOfModule(module); SettingsFrame sf = ClickGUI.INSTANCE.getSfOfModule(module);
int x = mc.getWindow().getScaledWidth() / 2 - sf.getW() / 2; int x = mc.getWindow().getGuiScaledWidth() / 2 - sf.getW() / 2;
int y = 67; int y = 67;
ClickGUI.INSTANCE.openSettingsFrame(module, x, y); ClickGUI.INSTANCE.openSettingsFrame(module, x, y);
} }
private void openSfWithPos(CommandContext<CommandSource> ctx, int x, int y) { private void openSfWithPos(CommandContext<SharedSuggestionProvider> ctx, int x, int y) {
Module module = ctx.getArgument("módulo", Module.class); Module module = ctx.getArgument("módulo", Module.class);
mc.setScreen(ClickGUI.INSTANCE); mc.setScreen(ClickGUI.INSTANCE);
@@ -4,7 +4,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus; import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
// se usa principalmente para el módulo ScreenshotPlus, pero también se puede usar sin él supongo // se usa principalmente para el módulo ScreenshotPlus, pero también se puede usar sin él supongo
public class CopyScreenshotCommand extends Command { public class CopyScreenshotCommand extends Command {
@@ -14,7 +14,7 @@ public class CopyScreenshotCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.executes(ctx -> { builder.executes(ctx -> {
ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class); ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class);
@@ -7,7 +7,7 @@ import me.retucio.sputnik.event.TickEvent;
import me.retucio.sputnik.ui.screen.PreviewScreen; import me.retucio.sputnik.ui.screen.PreviewScreen;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import me.retucio.sputnik.util.InventoryUtil; import me.retucio.sputnik.util.InventoryUtil;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
// accede a los contenidos de tu enderchest // accede a los contenidos de tu enderchest
public class EnderChestCommand extends Command { public class EnderChestCommand extends Command {
@@ -19,7 +19,7 @@ public class EnderChestCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.executes(ctx -> { builder.executes(ctx -> {
mc.execute(() -> { mc.execute(() -> {
if (mc.player == null) return; if (mc.player == null) return;
@@ -3,8 +3,8 @@ package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
public class GarbageCleanerCommand extends Command { public class GarbageCleanerCommand extends Command {
@@ -13,10 +13,10 @@ public class GarbageCleanerCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.executes(context -> { builder.executes(context -> {
System.gc(); System.gc();
ChatUtil.info(Text.of("basura recolectada")); ChatUtil.info(Component.nullToEmpty("basura recolectada"));
return SUCCESS; return SUCCESS;
}); });
} }
@@ -4,8 +4,8 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.PlayerArgumentType; import me.retucio.sputnik.command.args.PlayerArgumentType;
import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.MiscUtil;
import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
// comando que debería de mostrar el inventario de un jugador, pero por cómo funcionan los servers, solo te deja ver el ítem que tenga en la mano // comando que debería de mostrar el inventario de un jugador, pero por cómo funcionan los servers, solo te deja ver el ítem que tenga en la mano
public class PeekCommand extends Command { public class PeekCommand extends Command {
@@ -15,7 +15,7 @@ public class PeekCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder builder
.then(argument("jugador", PlayerArgumentType.INSTANCE) .then(argument("jugador", PlayerArgumentType.INSTANCE)
.executes(ctx -> { .executes(ctx -> {
@@ -9,10 +9,10 @@ import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.event.network.PacketEvent; import me.retucio.sputnik.event.network.PacketEvent;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.client.network.ClientCommandSource; import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.multiplayer.ClientSuggestionProvider;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket; import net.minecraft.network.protocol.game.ClientboundCommandsPacket;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -28,9 +28,9 @@ public class PluginsCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.executes(context -> { builder.executes(context -> {
if (mc.isIntegratedServerRunning()) { if (mc.hasSingleplayerServer()) {
ChatUtil.error("estás en un solo jugador"); ChatUtil.error("estás en un solo jugador");
return SUCCESS; return SUCCESS;
} }
@@ -51,12 +51,12 @@ public class PluginsCommand extends Command {
private void findNamespaces() { private void findNamespaces() {
try { try {
ClientPlayNetworkHandler networkHandler = mc.getNetworkHandler(); ClientPacketListener networkHandler = mc.getConnection();
if (networkHandler == null || networkHandler.getCommandDispatcher() == null) { if (networkHandler == null) {
return; return;
} }
RootCommandNode<ClientCommandSource> root = networkHandler.getCommandDispatcher().getRoot(); RootCommandNode<ClientSuggestionProvider> root = networkHandler.getCommands().getRoot();
root.getChildren().forEach(this::checkNodeForPlugins); root.getChildren().forEach(this::checkNodeForPlugins);
if (!plugins.isEmpty()) { if (!plugins.isEmpty()) {
@@ -73,7 +73,7 @@ public class PluginsCommand extends Command {
} }
} }
private void checkNodeForPlugins(CommandNode<ClientCommandSource> node) { private void checkNodeForPlugins(CommandNode<ClientSuggestionProvider> node) {
String name = node.getName(); String name = node.getName();
if (name.contains(":")) { if (name.contains(":")) {
@@ -92,7 +92,7 @@ public class PluginsCommand extends Command {
private void onPacketReceive(PacketEvent.Receive event) { private void onPacketReceive(PacketEvent.Receive event) {
if (!scanning) return; if (!scanning) return;
if (event.getPacket() instanceof CommandTreeS2CPacket) { if (event.getPacket() instanceof ClientboundCommandsPacket) {
findNamespaces(); findNamespaces();
} }
} }
@@ -5,9 +5,9 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.command.CommandSource; import net.minecraft.ChatFormatting;
import net.minecraft.text.Text; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.util.Formatting; import net.minecraft.network.chat.Component;
// también se puede hacer desde los ajustes de la interfaz // también se puede hacer desde los ajustes de la interfaz
public class PrefixCommand extends Command { public class PrefixCommand extends Command {
@@ -17,12 +17,12 @@ public class PrefixCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder builder
.then(argument("prefijo", StringArgumentType.word()).executes(ctx -> { .then(argument("prefijo", StringArgumentType.word()).executes(ctx -> {
String prefix = ctx.getArgument("prefijo", String.class); String prefix = ctx.getArgument("prefijo", String.class);
ClientSettingsFrame.guiSettings.commandPrefix.setValue(prefix); ClientSettingsFrame.guiSettings.commandPrefix.setValue(prefix);
ChatUtil.info(Text.literal("prefijo cambiado a " + Formatting.AQUA + prefix)); ChatUtil.info(Component.literal("prefijo cambiado a " + ChatFormatting.AQUA + prefix));
return SUCCESS; return SUCCESS;
})); }));
} }
@@ -3,10 +3,10 @@ package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.util.interfaces.IChatHud; import me.retucio.sputnik.util.interfaces.IChatComponent;
import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.components.ChatComponent;
import net.minecraft.client.gui.hud.ChatHudLine; import net.minecraft.client.multiplayer.chat.GuiMessage;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import java.util.List; import java.util.List;
@@ -17,7 +17,7 @@ public class PurgeCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.then(argument("cantidad", IntegerArgumentType.integer(1)) builder.then(argument("cantidad", IntegerArgumentType.integer(1))
.executes(context -> { .executes(context -> {
int amount = IntegerArgumentType.getInteger(context, "cantidad"); int amount = IntegerArgumentType.getInteger(context, "cantidad");
@@ -28,10 +28,10 @@ public class PurgeCommand extends Command {
} }
private void purgeMessages(int amount) { private void purgeMessages(int amount) {
ChatHud chatHud = mc.inGameHud.getChatHud(); ChatComponent chatHud = mc.gui.getChat();
synchronized (chatHud) { synchronized (chatHud) {
List<ChatHudLine.Visible> visibleMessages = ((IChatHud) chatHud).sputnik$getVisibleMessages(); List<GuiMessage.Line> visibleMessages = ((IChatComponent) chatHud).sputnik$getVisibleMessages();
int toRemove = Math.min(amount, visibleMessages.size()); int toRemove = Math.min(amount, visibleMessages.size());
for (int i = 0; i < toRemove; i++) for (int i = 0; i < toRemove; i++)
visibleMessages.removeFirst(); visibleMessages.removeFirst();
@@ -5,7 +5,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
public class RepeatCommand extends Command { public class RepeatCommand extends Command {
@@ -14,7 +14,7 @@ public class RepeatCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder builder
.then(argument("veces", IntegerArgumentType.integer(1)) .then(argument("veces", IntegerArgumentType.integer(1))
.then(argument("comando", StringArgumentType.greedyString()) .then(argument("comando", StringArgumentType.greedyString())
@@ -5,7 +5,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -17,7 +17,7 @@ public class RepeatWaitCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.then(argument("ms", IntegerArgumentType.integer(1)) builder.then(argument("ms", IntegerArgumentType.integer(1))
.then(argument("veces", IntegerArgumentType.integer(1)) .then(argument("veces", IntegerArgumentType.integer(1))
.then(argument("comando", StringArgumentType.greedyString()) .then(argument("comando", StringArgumentType.greedyString())
@@ -5,7 +5,7 @@ import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus; import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import java.io.IOException; import java.io.IOException;
@@ -17,7 +17,7 @@ public class SaveScreenshotCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.executes(ctx -> { builder.executes(ctx -> {
ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class); ScreenshotPlus screenshotPlus = ModuleManager.INSTANCE.getModuleByClass(ScreenshotPlus.class);
@@ -3,18 +3,18 @@ package me.retucio.sputnik.command.commands;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.mixin.accessors.ClientPlayNetworkHandlerAccessor; import me.retucio.sputnik.mixin.accessors.ClientPacketListenerAccessor;
import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.encryption.NetworkEncryptionUtils; import net.minecraft.network.chat.LastSeenMessagesTracker;
import net.minecraft.network.message.LastSeenMessagesCollector; import net.minecraft.network.chat.MessageSignature;
import net.minecraft.network.message.MessageBody; import net.minecraft.network.chat.SignedMessageBody;
import net.minecraft.network.message.MessageSignatureData; import net.minecraft.network.protocol.game.ServerboundChatPacket;
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket; import net.minecraft.util.Crypt;
import java.time.Instant; import java.time.Instant;
// uso principal: protección de coordenadas de ChatPlus, que ni siquiera funciona // uso principal: protección de coordenadas de ChatPlus
public class SendCommand extends Command { public class SendCommand extends Command {
public SendCommand() { public SendCommand() {
@@ -22,31 +22,35 @@ public class SendCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder.then(argument("message", StringArgumentType.greedyString()).executes(context -> { builder.then(argument("message", StringArgumentType.greedyString()).executes(context -> {
String message = context.getArgument("message", String.class); String message = context.getArgument("message", String.class);
if (message != null && !message.isEmpty()) { if (message != null && !message.isEmpty()) {
Instant instant = Instant.now(); Instant instant = Instant.now();
long salt = NetworkEncryptionUtils.SecureRandomUtil.nextLong(); long salt = Crypt.SaltSupplier.getLong();
ClientPlayNetworkHandler handler = mc.getNetworkHandler(); ClientPacketListener handler = mc.getConnection();
// obtener últimos mensajes vistos para la firma // obtener últimos mensajes vistos para la firma
LastSeenMessagesCollector.LastSeenMessages lastSeenMessages = ClientPacketListenerAccessor listener = ((ClientPacketListenerAccessor) handler);
((ClientPlayNetworkHandlerAccessor) handler).getLastSeenMessagesCollector().collect(); if (listener == null) return 0;
LastSeenMessagesTracker tracker = ((ClientPacketListenerAccessor) handler).getLastSeenMessagesTracker();
LastSeenMessagesTracker.Update lastSeenMessages = tracker.generateAndApplyUpdate();
// empacar firma para un chat seguro // empacar firma para un chat seguro
MessageSignatureData messageSignatureData = MessageSignature messageSignature = ((ClientPacketListenerAccessor) handler)
((ClientPlayNetworkHandlerAccessor) handler).getMessagePacker().pack( .getSignedMessageEncoder()
new MessageBody(message, instant, salt, lastSeenMessages.lastSeen()) .pack(new SignedMessageBody(
); message, instant, salt, lastSeenMessages.lastSeen()
)
);
// enviar paquete para enviar mensaje // enviar paquete para enviar mensaje
handler.sendPacket(new ChatMessageC2SPacket( handler.send(new ServerboundChatPacket(
message, message,
instant, instant,
salt, salt,
messageSignatureData, messageSignature,
lastSeenMessages.update() lastSeenMessages.update()
)); ));
} }
@@ -6,8 +6,8 @@ import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.EntityArgumentType; import me.retucio.sputnik.command.args.EntityArgumentType;
import me.retucio.sputnik.event.input.KeyEvent; import me.retucio.sputnik.event.input.KeyEvent;
import me.retucio.sputnik.util.EntityUtil; import me.retucio.sputnik.util.EntityUtil;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
public class SpectateCommand extends Command { public class SpectateCommand extends Command {
@@ -17,7 +17,7 @@ public class SpectateCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder builder
.executes(ctx -> { // If no argument, use the entity player is looking at .executes(ctx -> { // If no argument, use the entity player is looking at
mc.execute(() -> { mc.execute(() -> {
@@ -40,7 +40,7 @@ public class SpectateCommand extends Command {
@EventListener @EventListener
public void onKey(KeyEvent event) { public void onKey(KeyEvent event) {
if (mc.getCameraEntity() != mc.player && mc.currentScreen == null if (mc.getCameraEntity() != mc.player && mc.screen == null
&& event.getKey() == GLFW.GLFW_KEY_ESCAPE && event.getAction() != GLFW.GLFW_RELEASE ) { && event.getKey() == GLFW.GLFW_KEY_ESCAPE && event.getAction() != GLFW.GLFW_RELEASE ) {
event.cancel(); event.cancel();
mc.setCameraEntity(mc.player); mc.setCameraEntity(mc.player);
@@ -5,7 +5,7 @@ import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.args.ModuleArgumentType; import me.retucio.sputnik.command.args.ModuleArgumentType;
import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
// porque usar el ratón es más lento que escribir, a menos que tengas toque con el teclado como yo // porque usar el ratón es más lento que escribir, a menos que tengas toque con el teclado como yo
public class ToggleCommand extends Command { public class ToggleCommand extends Command {
@@ -15,7 +15,7 @@ public class ToggleCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder builder
.then(literal("todos") .then(literal("todos")
.then(literal("on") .then(literal("on")
@@ -8,7 +8,7 @@ import me.retucio.sputnik.command.Command;
import me.retucio.sputnik.command.CommandManager; import me.retucio.sputnik.command.CommandManager;
import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame; import me.retucio.sputnik.ui.widgets.frames.settings.ClientSettingsFrame;
import me.retucio.sputnik.util.ChatUtil; import me.retucio.sputnik.util.ChatUtil;
import net.minecraft.command.CommandSource; import net.minecraft.commands.SharedSuggestionProvider;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -23,18 +23,18 @@ public class WaitCommand extends Command {
} }
@Override @Override
public void build(LiteralArgumentBuilder<CommandSource> builder) { public void build(LiteralArgumentBuilder<SharedSuggestionProvider> builder) {
builder builder
.then(argument("delay", IntegerArgumentType.integer(0)) .then(argument("delay", IntegerArgumentType.integer(0))
.then(argument("comando", StringArgumentType.greedyString()) .then(argument("comando", StringArgumentType.greedyString())
.executes(ctx -> { .executes(ctx -> {
int delay = ctx.getArgument("delay", Integer.class); int delay = ctx.getArgument("delay", Integer.class);
String command = ctx.getArgument("comando", String.class); String command = ctx.getArgument("comando", String.class);
DELAYED_EXECUTOR.schedule(() -> ChatUtil.simulateChatMessage(command), delay, TimeUnit.MILLISECONDS); DELAYED_EXECUTOR.schedule(() -> ChatUtil.simulateChatMessage(command), delay, TimeUnit.MILLISECONDS);
return SUCCESS; return SUCCESS;
}) })
) )
); );
} }
} }
@@ -1,11 +1,11 @@
package me.retucio.sputnik.event; package me.retucio.sputnik.event;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin;
/** /**
* @see MinecraftClientMixin#onStop * @see MinecraftMixin#onStop
*/ */
public class ShutdownEvent extends Event { public class ShutdownEvent extends Event {
@@ -1,12 +1,12 @@
package me.retucio.sputnik.event; package me.retucio.sputnik.event;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin;
/** /**
* @see MinecraftClientMixin#onTickPre * @see MinecraftMixin#onTickPre
* @see MinecraftClientMixin#onTickPost * @see MinecraftMixin#onTickPost
*/ */
public class TickEvent { public class TickEvent {
@@ -1,12 +1,14 @@
package me.retucio.sputnik.event.input; package me.retucio.sputnik.event.input;
import me.retucio.sputnik.module.modules.misc.ChatPlus; import me.retucio.sputnik.module.modules.misc.ChatPlus;
import net.minecraft.text.ClickEvent; import net.minecraft.network.chat.ClickEvent;
import org.jspecify.annotations.NonNull;
/** este evento es solo para asegurarse de que comandos del mod se puedan ejecutar solo desde el lado del cliente /** este evento es solo para asegurarse de que comandos del mod se puedan ejecutar solo desde el lado del cliente
* @see ChatPlus#getSendButton * @see ChatPlus#getSendButton
*/ */
public class ClientClickEvent implements ClickEvent { public class ClientClickEvent implements ClickEvent {
private final String value; private final String value;
@@ -20,7 +22,7 @@ public class ClientClickEvent implements ClickEvent {
} }
@Override @Override
public Action getAction() { public @NonNull Action action() {
return Action.RUN_COMMAND; return Action.RUN_COMMAND;
} }
@@ -1,11 +1,11 @@
package me.retucio.sputnik.event.input; package me.retucio.sputnik.event.input;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.io.KeyboardMixin; import me.retucio.sputnik.mixin.mixins.io.KeyboardHandlerMixin;
/** /**
* @see KeyboardMixin#onKeyPress * @see KeyboardHandlerMixin#onKeyPress
*/ */
public class KeyEvent extends Event { public class KeyEvent extends Event {
@@ -1,11 +1,11 @@
package me.retucio.sputnik.event.input; package me.retucio.sputnik.event.input;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.io.MouseMixin; import me.retucio.sputnik.mixin.mixins.io.MouseHandlerMixin;
/** /**
* @see MouseMixin#onMouseButton * @see MouseHandlerMixin#onMouseButton
*/ */
public class MouseClickEvent extends Event { public class MouseClickEvent extends Event {
@@ -1,11 +1,11 @@
package me.retucio.sputnik.event.input; package me.retucio.sputnik.event.input;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.io.MouseMixin; import me.retucio.sputnik.mixin.mixins.io.MouseHandlerMixin;
/** /**
* @see MouseMixin#onMouseScroll * @see MouseHandlerMixin#onMouseScroll
*/ */
public class MouseScrollEvent extends Event { public class MouseScrollEvent extends Event {
@@ -1,8 +1,8 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import net.minecraft.util.math.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.core.Direction;
public class AttackBlockEvent extends Event { public class AttackBlockEvent extends Event {
@@ -1,13 +1,14 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.player.ClientPlayerInteractionManagerMixin; import me.retucio.sputnik.mixin.mixins.player.MultiPlayerGameModeMixin;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
/** /**
* @see ClientPlayerInteractionManagerMixin#onAttackEntity * @see MultiPlayerGameModeMixin#onAttackEntity
*/ */
public class AttackEntityEvent extends Event { public class AttackEntityEvent extends Event {
private final Entity entity; private final Entity entity;
@@ -1,9 +1,9 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import net.minecraft.block.BlockState; import net.minecraft.core.BlockPos;
import net.minecraft.util.math.BlockPos; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
public class BlockShapeEvent extends Event { public class BlockShapeEvent extends Event {
@@ -1,28 +1,28 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import net.minecraft.entity.vehicle.AbstractBoatEntity; import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
import net.minecraft.util.math.Vec3d; import net.minecraft.world.phys.Vec3;
public class BoatMoveEvent extends Event { public class BoatMoveEvent extends Event {
private final AbstractBoatEntity boat; private final AbstractBoat boat;
private Vec3d pos; private Vec3 pos;
public BoatMoveEvent(AbstractBoatEntity boat, Vec3d pos) { public BoatMoveEvent(AbstractBoat boat, Vec3 pos) {
this.boat = boat; this.boat = boat;
this.pos = pos; this.pos = pos;
} }
public AbstractBoatEntity getBoat() { public AbstractBoat getBoat() {
return boat; return boat;
} }
public Vec3d getPos() { public Vec3 getPos() {
return pos; return pos;
} }
public void setPos(Vec3d pos) { public void setPos(Vec3 pos) {
this.pos = pos; this.pos = pos;
} }
} }
@@ -1,13 +1,14 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.player.ClientPlayerInteractionManagerMixin; import me.retucio.sputnik.mixin.mixins.player.MultiPlayerGameModeMixin;
import net.minecraft.util.math.BlockPos; import net.minecraft.core.BlockPos;
/** /**
* @see ClientPlayerInteractionManagerMixin#onBlockBreak * @see MultiPlayerGameModeMixin#onBlockBreak
*/ */
public class BreakBlockEvent extends Event { public class BreakBlockEvent extends Event {
private BlockPos pos; private BlockPos pos;
@@ -2,7 +2,7 @@ package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.item.ItemStackMixin; import me.retucio.sputnik.mixin.mixins.item.ItemStackMixin;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
/** /**
@@ -1,20 +1,21 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.player.ClientPlayerInteractionManagerMixin; import me.retucio.sputnik.mixin.mixins.player.MultiPlayerGameModeMixin;
import net.minecraft.entity.Entity; import net.minecraft.world.InteractionHand;
import net.minecraft.util.Hand; import net.minecraft.world.entity.Entity;
/** /**
* @see ClientPlayerInteractionManagerMixin#onEntityInteract * @see MultiPlayerGameModeMixin#onEntityInteract
*/ */
public class InteractEntityEvent extends Event { public class InteractEntityEvent extends Event {
private final Entity entity; private final Entity entity;
private Hand hand; private InteractionHand hand;
public InteractEntityEvent(Entity entity, Hand hand) { public InteractEntityEvent(Entity entity, InteractionHand hand) {
this.entity = entity; this.entity = entity;
this.hand = hand; this.hand = hand;
} }
@@ -23,11 +24,11 @@ public class InteractEntityEvent extends Event {
return entity; return entity;
} }
public Hand getHand() { public InteractionHand getHand() {
return hand; return hand;
} }
public void setHand(Hand hand) { public void setHand(InteractionHand hand) {
this.hand = hand; this.hand = hand;
} }
} }
@@ -1,7 +1,7 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import net.minecraft.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
public class KnockbackEvent extends Event { public class KnockbackEvent extends Event {
@@ -1,12 +1,12 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screens.Screen;
/** /**
* @see MinecraftClientMixin#onOpenScreen * @see MinecraftMixin#onOpenScreen
*/ */
public class OpenScreenEvent extends Event { public class OpenScreenEvent extends Event {
@@ -1,29 +1,29 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.player.ClientPlayerInteractionManagerMixin; import me.retucio.sputnik.mixin.mixins.player.MultiPlayerGameModeMixin;
import net.minecraft.util.Hand; import net.minecraft.world.InteractionHand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
/** /**
* @see ClientPlayerInteractionManagerMixin#onBlockPlace * @see MultiPlayerGameModeMixin#onBlockPlace
*/ */
public class PlaceBlockEvent extends Event { public class PlaceBlockEvent extends Event {
private Hand hand; private InteractionHand hand;
private BlockHitResult result; private BlockHitResult result;
public PlaceBlockEvent(Hand hand, BlockHitResult result) { public PlaceBlockEvent(InteractionHand hand, BlockHitResult result) {
this.hand = hand; this.hand = hand;
this.result = result; this.result = result;
} }
public Hand getHand() { public InteractionHand getHand() {
return hand; return hand;
} }
public void setHand(Hand hand) { public void setHand(InteractionHand hand) {
this.hand = hand; this.hand = hand;
} }
@@ -1,20 +1,21 @@
package me.retucio.sputnik.event.interact; package me.retucio.sputnik.event.interact;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin;
import net.minecraft.item.ItemStack; import net.minecraft.world.InteractionHand;
import net.minecraft.util.Hand; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
/** /**
* @see MinecraftClientMixin#onUseItem * @see MinecraftMixin#onUseItem
*/ */
public class UseItemEvent extends Event { public class UseItemEvent extends Event {
private ItemStack stack; private ItemStack stack;
private Hand hand; private InteractionHand hand;
public UseItemEvent(ItemStack stack, Hand hand) { public UseItemEvent(ItemStack stack, InteractionHand hand) {
this.stack = stack; this.stack = stack;
this.hand = hand; this.hand = hand;
} }
@@ -27,11 +28,15 @@ public class UseItemEvent extends Event {
this.stack = stack; this.stack = stack;
} }
public Hand getHand() { public Item getItem() {
return stack.getItem();
}
public InteractionHand getHand() {
return hand; return hand;
} }
public void setHand(Hand hand) { public void setHand(InteractionHand hand) {
this.hand = hand; this.hand = hand;
} }
} }
@@ -1,12 +1,12 @@
package me.retucio.sputnik.event.network; package me.retucio.sputnik.event.network;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.world.ClientWorldMixin; import me.retucio.sputnik.mixin.mixins.world.ClientLevelMixin;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
/** /**
* @see ClientWorldMixin#onAddEntity * @see ClientLevelMixin#onAddEntity
*/ */
public class AddEntityEvent extends Event { public class AddEntityEvent extends Event {
@@ -1,10 +1,10 @@
package me.retucio.sputnik.event.network; package me.retucio.sputnik.event.network;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.world.ChunkOcclusionDataBuilderMixin; import me.retucio.sputnik.mixin.mixins.world.VisGraphMixin;
/** /**
* @see ChunkOcclusionDataBuilderMixin#onChunkOcclusion * @see VisGraphMixin#onChunkOcclusion
*/ */
public class ChunkOcclusionEvent extends Event {} public class ChunkOcclusionEvent extends Event {}
@@ -1,29 +1,29 @@
package me.retucio.sputnik.event.network; package me.retucio.sputnik.event.network;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.network.ClientConnectionMixin; import me.retucio.sputnik.mixin.mixins.network.ConnectionMixin;
import net.minecraft.client.network.ServerInfo; import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.network.DisconnectionInfo; import net.minecraft.network.DisconnectionDetails;
/** /**
* @see ClientConnectionMixin#onDisconnect * @see ConnectionMixin#onDisconnect
*/ */
public class DisconnectEvent extends Event { public class DisconnectEvent extends Event {
private final DisconnectionInfo info; private final DisconnectionDetails details;
private final ServerInfo server; private final ServerData server;
public DisconnectEvent(DisconnectionInfo info, ServerInfo server) { public DisconnectEvent(DisconnectionDetails details, ServerData server) {
this.info = info; this.details = details;
this.server = server; this.server = server;
} }
public DisconnectionInfo getInfo() { public DisconnectionDetails getDetails() {
return info; return details;
} }
public ServerInfo getServer() { public ServerData getServer() {
return server; return server;
} }
} }
@@ -1,22 +1,23 @@
package me.retucio.sputnik.event.network; package me.retucio.sputnik.event.network;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.misc.MinecraftClientMixin; import me.retucio.sputnik.mixin.mixins.misc.MinecraftMixin;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.multiplayer.ClientLevel;
/** /**
* @see MinecraftClientMixin#onJoinWorld * @see MinecraftMixin#onJoinWorld
*/ */
public class JoinWorldEvent extends Event { public class JoinWorldEvent extends Event {
private final ClientWorld world; private final ClientLevel world;
public JoinWorldEvent(ClientWorld world) { public JoinWorldEvent(ClientLevel world) {
this.world = world; this.world = world;
} }
public ClientWorld getWorld() { public ClientLevel getWorld() {
return world; return world;
} }
} }
@@ -1,14 +1,14 @@
package me.retucio.sputnik.event.network; package me.retucio.sputnik.event.network;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.network.ClientConnectionMixin; import me.retucio.sputnik.mixin.mixins.network.ConnectionMixin;
import net.minecraft.network.packet.Packet; import net.minecraft.network.protocol.Packet;
/** /**
* @see ClientConnectionMixin#onSendPacketPre * @see ConnectionMixin#onSendPacketPre
* @see ClientConnectionMixin#onSendPacketPost * @see ConnectionMixin#onSendPacketPost
* @see ClientConnectionMixin#onReceivePacket * @see ConnectionMixin#onReceivePacket
*/ */
public class PacketEvent { public class PacketEvent {
@@ -1,41 +1,43 @@
package me.retucio.sputnik.event.network; package me.retucio.sputnik.event.network;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.hud.ChatHudMixin; import me.retucio.sputnik.mixin.mixins.hud.ChatComponentMixin;
import net.minecraft.client.gui.hud.MessageIndicator; import net.minecraft.client.multiplayer.chat.GuiMessageTag;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
/** /**
* @see ChatHudMixin#onAddMessage * @see ChatComponentMixin#onAddMessage
*/ */
public class ReceiveMessageEvent extends Event { public class ReceiveMessageEvent extends Event {
private Text text; private Component text;
private MessageIndicator indicator; private GuiMessageTag tag;
private final int id; private final int id;
private boolean modified = false; private boolean modified = false;
public ReceiveMessageEvent(Text text, MessageIndicator indicator, int id) { public ReceiveMessageEvent(Component text, GuiMessageTag tag, int id) {
this.text = text; this.text = text;
this.indicator = indicator; this.tag = tag;
this.id = id; this.id = id;
} }
public Text getMessage() { public Component getMessage() {
return text; return text;
} }
public MessageIndicator getIndicator() { public GuiMessageTag getTag() {
return indicator; return tag;
} }
public void setMessage(Text message) { public void setMessage(Component message) {
this.text = message; this.text = message;
this.modified = true; this.modified = true;
} }
public void setIndicator(MessageIndicator indicator) { public void setTag(GuiMessageTag tag) {
this.indicator = indicator; this.tag = tag;
this.modified = true; this.modified = true;
} }
@@ -1,12 +1,12 @@
package me.retucio.sputnik.event.network; package me.retucio.sputnik.event.network;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.world.ClientWorldMixin; import me.retucio.sputnik.mixin.mixins.world.ClientLevelMixin;
import net.minecraft.entity.Entity; import net.minecraft.world.entity.Entity;
/** /**
* @see ClientWorldMixin#onRemoveEntity * @see ClientLevelMixin#onRemoveEntity
*/ */
public class RemoveEntityEvent extends Event { public class RemoveEntityEvent extends Event {
@@ -1,11 +1,11 @@
package me.retucio.sputnik.event.network; package me.retucio.sputnik.event.network;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.network.ClientPlayNetworkHandlerMixin; import me.retucio.sputnik.mixin.mixins.network.ClientPacketListenerMixin;
/** /**
* @see ClientPlayNetworkHandlerMixin#onSendMessage * @see ClientPacketListenerMixin#onSendMessage
*/ */
public class SendMessageEvent extends Event { public class SendMessageEvent extends Event {
@@ -1,26 +1,26 @@
package me.retucio.sputnik.event.render; package me.retucio.sputnik.event.render;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.misc.GameOptionsMixin; import me.retucio.sputnik.mixin.mixins.misc.OptionsMixin;
import net.minecraft.client.option.Perspective; import net.minecraft.client.CameraType;
/** /**
* @see GameOptionsMixin#changePerspective * @see OptionsMixin#changePerspective
*/ */
public class PerspectiveChangeEvent extends Event { public class PerspectiveChangeEvent extends Event {
private Perspective perspective; private CameraType perspective;
public PerspectiveChangeEvent(Perspective perspective) { public PerspectiveChangeEvent(CameraType perspective) {
this.perspective = perspective; this.perspective = perspective;
} }
public Perspective getPerspective() { public CameraType getPerspective() {
return perspective; return perspective;
} }
public void setPerspective(Perspective perspective) { public void setPerspective(CameraType perspective) {
this.perspective = perspective; this.perspective = perspective;
} }
} }
@@ -1,24 +1,26 @@
package me.retucio.sputnik.event.render; package me.retucio.sputnik.event.render;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.DeltaTracker;
import net.minecraft.client.gui.GuiGraphicsExtractor;
public class Render2DEvent extends Event { public class Render2DEvent extends Event {
private final DrawContext ctx; private final GuiGraphicsExtractor gui;
private final RenderTickCounter tc; private final DeltaTracker dt;
public Render2DEvent(DrawContext ctx, RenderTickCounter tc) { public Render2DEvent(GuiGraphicsExtractor gui, DeltaTracker dt) {
this.ctx = ctx; this.gui = gui;
this.tc = tc; this.dt = dt;
} }
public DrawContext getCtx() { public GuiGraphicsExtractor getGui() {
return ctx; return gui;
} }
public RenderTickCounter getTc() { public DeltaTracker getDt() {
return tc; return dt;
} }
} }
@@ -1,40 +1,42 @@
package me.retucio.sputnik.event.render; package me.retucio.sputnik.event.render;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.render.WorldRendererMixin; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.render.Camera; import me.retucio.sputnik.mixin.mixins.render.LevelRendererMixin;
import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.Camera;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.DeltaTracker;
import net.minecraft.client.renderer.state.level.CameraRenderState;
/** /**
* @see WorldRendererMixin#render * @see LevelRendererMixin#renderLevel
*/ */
public class Render3DEvent extends Event { public class Render3DEvent extends Event {
private final MatrixStack matrices; private final PoseStack matrices;
private final RenderTickCounter tc; private final DeltaTracker dt;
private final Camera camera; private final CameraRenderState cameraState;
public Render3DEvent(MatrixStack matrices, RenderTickCounter tc, Camera camera) { public Render3DEvent(PoseStack matrices, DeltaTracker dt, CameraRenderState cameraState) {
this.matrices = matrices; this.matrices = matrices;
this.tc = tc; this.dt = dt;
this.camera = camera; this.cameraState = cameraState;
} }
public MatrixStack getMatrices() { public PoseStack getMatrices() {
return matrices; return matrices;
} }
public RenderTickCounter getTickCounter() { public DeltaTracker getDeltaTracker() {
return tc; return dt;
} }
public Camera getCamera() { public CameraRenderState getCamera() {
return camera; return cameraState;
} }
public float getTickDelta() { public float getTickDelta() {
return tc.getDynamicDeltaTicks(); return dt.getGameTimeDeltaTicks();
} }
} }
@@ -1,37 +1,37 @@
package me.retucio.sputnik.event.render; package me.retucio.sputnik.event.render;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.render.HeldItemRendererMixin; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.util.math.MatrixStack; import me.retucio.sputnik.mixin.mixins.render.ItemInHandRendererMixin;
import net.minecraft.util.Hand; import net.minecraft.world.InteractionHand;
/** /**
* @see HeldItemRendererMixin#onRenderArm * @see ItemInHandRendererMixin#onRenderArm
*/ */
public class RenderArmEvent extends Event { public class RenderArmEvent extends Event {
private MatrixStack matrices; private PoseStack matrices;
private Hand hand; private InteractionHand hand;
public RenderArmEvent(MatrixStack matrices, Hand hand) { public RenderArmEvent(PoseStack matrices, InteractionHand hand) {
this.matrices = matrices; this.matrices = matrices;
this.hand = hand; this.hand = hand;
} }
public MatrixStack getMatrices() { public PoseStack getMatrices() {
return matrices; return matrices;
} }
public void setMatrices(MatrixStack matrices) { public void setMatrices(PoseStack matrices) {
this.matrices = matrices; this.matrices = matrices;
} }
public Hand getHand() { public InteractionHand getHand() {
return hand; return hand;
} }
public void setHand(Hand hand) { public void setHand(InteractionHand hand) {
this.hand = hand; this.hand = hand;
} }
} }
@@ -2,9 +2,10 @@ package me.retucio.sputnik.event.render;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.hud.BossBarHudMixin; import me.retucio.sputnik.mixin.mixins.hud.BossBarHudMixin;
import net.minecraft.client.gui.hud.ClientBossBar; import net.minecraft.client.gui.components.LerpingBossEvent;
import net.minecraft.text.Text; import net.minecraft.network.chat.MutableComponent;
import java.awt.*;
import java.util.Iterator; import java.util.Iterator;
@@ -17,27 +18,27 @@ public class RenderBossbarEvent {
public static class BossText extends Event { public static class BossText extends Event {
private ClientBossBar bossBar; private LerpingBossEvent bossBar;
private Text name; private MutableComponent name;
public BossText(ClientBossBar bossBar, Text name) { public BossText(LerpingBossEvent bossBar, MutableComponent name) {
this.bossBar = bossBar; this.bossBar = bossBar;
this.name = name; this.name = name;
} }
public ClientBossBar getBossBar() { public LerpingBossEvent getBossBar() {
return bossBar; return bossBar;
} }
public void setBossBar(ClientBossBar bossBar) { public void setBossBar(LerpingBossEvent bossBar) {
this.bossBar = bossBar; this.bossBar = bossBar;
} }
public Text getName() { public MutableComponent getName() {
return name; return name;
} }
public void setName(Text name) { public void setName(MutableComponent name) {
this.name = name; this.name = name;
} }
} }
@@ -61,17 +62,17 @@ public class RenderBossbarEvent {
public static class BossIterator extends Event { public static class BossIterator extends Event {
private Iterator<ClientBossBar> iterator; private Iterator<LerpingBossEvent> iterator;
public BossIterator(Iterator<ClientBossBar> iterator) { public BossIterator(Iterator<LerpingBossEvent> iterator) {
this.iterator = iterator; this.iterator = iterator;
} }
public Iterator<ClientBossBar> getIterator() { public Iterator<LerpingBossEvent> getIterator() {
return iterator; return iterator;
} }
public void setIterator(Iterator<ClientBossBar> iterator) { public void setIterator(Iterator<LerpingBossEvent> iterator) {
this.iterator = iterator; this.iterator = iterator;
} }
} }
@@ -1,37 +1,38 @@
package me.retucio.sputnik.event.render; package me.retucio.sputnik.event.render;
import com.github.retucio.neutrino.Event; import com.github.retucio.neutrino.Event;
import me.retucio.sputnik.mixin.mixins.render.HeldItemRendererMixin; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.util.math.MatrixStack; import me.retucio.sputnik.mixin.mixins.render.ItemInHandRendererMixin;
import net.minecraft.util.Hand; import net.minecraft.world.InteractionHand;
/** /**
* @see HeldItemRendererMixin#onRenderItem * @see ItemInHandRendererMixin#onRenderItem
*/ */
public class RenderHeldItemEvent extends Event { public class RenderHeldItemEvent extends Event {
private MatrixStack matrices; private PoseStack matrices;
private Hand hand; private InteractionHand hand;
public RenderHeldItemEvent(MatrixStack matrices, Hand hand) { public RenderHeldItemEvent(PoseStack matrices, InteractionHand hand) {
this.matrices = matrices; this.matrices = matrices;
this.hand = hand; this.hand = hand;
} }
public MatrixStack getMatrices() { public PoseStack getMatrices() {
return matrices; return matrices;
} }
public void setMatrices(MatrixStack matrices) { public void setMatrices(PoseStack matrices) {
this.matrices = matrices; this.matrices = matrices;
} }
public Hand getHand() { public InteractionHand getHand() {
return hand; return hand;
} }
public void setHand(Hand hand) { public void setHand(InteractionHand hand) {
this.hand = hand; this.hand = hand;
} }
} }
@@ -0,0 +1,16 @@
package me.retucio.sputnik.mixin.accessors;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.world.inventory.Slot;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(AbstractContainerScreen.class)
public interface AbstractContainerScreenAccessor {
@Accessor("hoveredSlot")
Slot getHoveredSlot();
@Accessor("doubleclick")
void setDoubleClicking(boolean doubleClicking);
}
@@ -1,13 +1,13 @@
package me.retucio.sputnik.mixin.accessors; package me.retucio.sputnik.mixin.accessors;
import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.gui.screens.inventory.AbstractSignEditScreen;
import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen; import net.minecraft.world.level.block.entity.SignBlockEntity;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(AbstractSignEditScreen.class) @Mixin(AbstractSignEditScreen.class)
public interface AbstractSignEditScreenAccessor { public interface AbstractSignEditScreenAccessor {
@Accessor("blockEntity") @Accessor("sign")
SignBlockEntity getBlockEntity(); SignBlockEntity getBlockEntity();
} }
@@ -1,16 +1,16 @@
package me.retucio.sputnik.mixin.accessors; package me.retucio.sputnik.mixin.accessors;
import net.minecraft.client.gui.screen.ingame.AnvilScreen; import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.gui.screens.inventory.AnvilScreen;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(AnvilScreen.class) @Mixin(AnvilScreen.class)
public interface AnvilScreenAccessor { public interface AnvilScreenAccessor {
@Accessor("nameField") @Accessor("name")
TextFieldWidget getNameField(); EditBox getNameField();
@Accessor("nameField") @Accessor("name")
void setNameField(TextFieldWidget nameField); void setNameField(EditBox nameField);
} }
@@ -1,13 +1,13 @@
package me.retucio.sputnik.mixin.accessors; package me.retucio.sputnik.mixin.accessors;
import net.minecraft.block.AbstractBlock; import net.minecraft.world.level.block.state.BlockBehaviour;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(AbstractBlock.class) @Mixin(BlockBehaviour.class)
public interface AbstractBlockAccessor { public interface BlockBehaviourAccessor {
@Mutable @Accessor("slipperiness") @Mutable @Accessor("friction")
void setSlipperiness(float slipperiness); void setSlipperiness(float slipperiness);
} }
@@ -0,0 +1,17 @@
package me.retucio.sputnik.mixin.accessors;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.chat.LastSeenMessagesTracker;
import net.minecraft.network.chat.SignedMessageChain;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ClientPacketListener.class)
public interface ClientPacketListenerAccessor {
@Accessor("lastSeenMessages")
LastSeenMessagesTracker getLastSeenMessagesTracker();
@Accessor("signedMessageEncoder")
SignedMessageChain.Encoder getSignedMessageEncoder();
}
@@ -1,17 +0,0 @@
package me.retucio.sputnik.mixin.accessors;
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();
}
@@ -1,16 +1,16 @@
package me.retucio.sputnik.mixin.accessors; package me.retucio.sputnik.mixin.accessors;
import net.minecraft.network.packet.s2c.play.ExplosionS2CPacket; import net.minecraft.network.protocol.game.ClientboundExplodePacket;
import net.minecraft.util.math.Vec3d; import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Optional; import java.util.Optional;
@Mixin(ExplosionS2CPacket.class) @Mixin(ClientboundExplodePacket.class)
public interface ExplosionS2CPacketAccessor { public interface ClientboundExplodePacketAccessor {
@Mutable @Accessor("playerKnockback") @Mutable @Accessor("playerKnockback")
void setKnockback(Optional<Vec3d> kb); void setKnockback(Optional<Vec3> kb);
} }
@@ -0,0 +1,15 @@
package me.retucio.sputnik.mixin.accessors;
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ClientboundSetEntityMotionPacket.class)
public interface ClientboundSetEntityMotionPacketAccessor {
@Mutable @Accessor("movement")
void setVelocity(Vec3 velocity);
}
@@ -1,18 +0,0 @@
package me.retucio.sputnik.mixin.accessors;
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,14 +0,0 @@
package me.retucio.sputnik.mixin.accessors;
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(EntityVelocityUpdateS2CPacket.class)
public interface EntityVelocityUpdateS2CPacketAccessor {
@Mutable @Accessor("velocity")
void setVelocity(Vec3d velocity);
}
@@ -1,15 +0,0 @@
package me.retucio.sputnik.mixin.accessors;
import net.minecraft.entity.projectile.FishingBobberEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(FishingBobberEntity.class)
public interface FishingBobberEntityAccessor {
@Accessor("caughtFish")
boolean caughtFish();
@Accessor("state")
FishingBobberEntity.State getState();
}
@@ -0,0 +1,16 @@
package me.retucio.sputnik.mixin.accessors;
import net.minecraft.world.entity.projectile.FishingHook;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(FishingHook.class)
public interface FishingHookAccessor {
@Accessor("biting")
boolean caughtFish();
@Accessor("currentState")
FishingHook.FishHookState getState();
}
@@ -1,16 +0,0 @@
package me.retucio.sputnik.mixin.accessors;
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,13 +1,13 @@
package me.retucio.sputnik.mixin.accessors; package me.retucio.sputnik.mixin.accessors;
import net.minecraft.client.option.KeyBinding; import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.util.InputUtil; import net.minecraft.client.KeyMapping;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(KeyBinding.class) @Mixin(KeyMapping.class)
public interface KeyBindingAccessor { public interface KeyBindingAccessor {
@Accessor("boundKey") @Accessor("key")
InputUtil.Key getBoundKey(); InputConstants.Key getKey();
} }
@@ -1,11 +1,12 @@
package me.retucio.sputnik.mixin.accessors; package me.retucio.sputnik.mixin.accessors;
import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(StatusEffectInstance.class)
public interface StatusEffectInstanceAccessor { @Mixin(MobEffectInstance.class)
public interface MobEffectInstanceAccessor {
@Accessor("duration") @Accessor("duration")
void setDuration(int duration); void setDuration(int duration);
@@ -1,7 +1,7 @@
package me.retucio.sputnik.mixin.accessors; package me.retucio.sputnik.mixin.accessors;
import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.client.renderer.texture.OverlayTexture;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;
@@ -10,5 +10,5 @@ import org.spongepowered.asm.mixin.gen.Accessor;
public interface OverlayTextureAccessor { public interface OverlayTextureAccessor {
@Mutable @Accessor("texture") @Mutable @Accessor("texture")
void setTexture(NativeImageBackedTexture texture); void setTexture(DynamicTexture texture);
} }
@@ -0,0 +1,19 @@
package me.retucio.sputnik.mixin.accessors;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
@Mixin(ClientCommonPacketListenerImpl.PackConfirmScreen.class)
public interface PackConfirmScreenAccessor {
@Accessor("parentScreen")
Screen getParentScreen();
@Accessor("requests")
List<? extends PendingRequestAccessor> getRequests();
}
@@ -1,13 +1,14 @@
package me.retucio.sputnik.mixin.accessors; package me.retucio.sputnik.mixin.accessors;
import net.minecraft.client.network.ClientCommonNetworkHandler; import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker; import org.spongepowered.asm.mixin.gen.Invoker;
import java.util.UUID; import java.util.UUID;
@Mixin(ClientCommonNetworkHandler.ConfirmServerResourcePackScreen.Pack.class)
public interface PackAccessor { @Mixin(ClientCommonPacketListenerImpl.PackConfirmScreen.PendingRequest.class)
public interface PendingRequestAccessor {
@Invoker @Invoker
UUID callId(); UUID callId();
@@ -4,25 +4,25 @@ import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.event.interact.BoatMoveEvent; import me.retucio.sputnik.event.interact.BoatMoveEvent;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.movement.BoatFly; import me.retucio.sputnik.module.modules.movement.BoatFly;
import net.minecraft.entity.MovementType; import net.minecraft.world.entity.MoverType;
import net.minecraft.entity.vehicle.AbstractBoatEntity; import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
import net.minecraft.util.math.Vec3d; import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(AbstractBoatEntity.class) @Mixin(AbstractBoat.class)
public abstract class AbstractBoatEntityMixin { public abstract class AbstractBoatMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/vehicle/AbstractBoatEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V")) @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/vehicle/boat/AbstractBoat;move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V"))
private void onMove(AbstractBoatEntity instance, MovementType movementType, Vec3d vec3d) { private void onMove(AbstractBoat instance, MoverType moverType, Vec3 vec3) {
BoatMoveEvent event = Sputnik.EVENT_BUS.post(new BoatMoveEvent(instance, vec3d)); BoatMoveEvent event = Sputnik.EVENT_BUS.post(new BoatMoveEvent(instance, vec3));
if(!event.isCancelled()) instance.move(movementType, event.getPos()); if (!event.isCancelled()) instance.move(moverType, event.getPos());
} }
@Inject(method = "updatePaddles", at = @At("HEAD"), cancellable = true) @Inject(method = "controlBoat", at = @At("HEAD"), cancellable = true)
private void onPaddle(CallbackInfo ci) { private void onPaddle(CallbackInfo ci) {
if (ModuleManager.INSTANCE.getModuleByClass(BoatFly.class).isEnabled()) { if (ModuleManager.INSTANCE.getModuleByClass(BoatFly.class).isEnabled()) {
ci.cancel(); ci.cancel();
@@ -1,8 +1,8 @@
package me.retucio.sputnik.mixin.mixins.entity; package me.retucio.sputnik.mixin.mixins.entity;
import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.event.render.ChangeRotationEvent; import me.retucio.sputnik.event.render.ChangeRotationEvent;
import me.retucio.sputnik.module.Module;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.camera.Freecam;
import me.retucio.sputnik.module.modules.camera.Freelook; import me.retucio.sputnik.module.modules.camera.Freelook;
@@ -11,35 +11,43 @@ import me.retucio.sputnik.module.modules.misc.AntiInvis;
import me.retucio.sputnik.module.modules.movement.BoatFly; import me.retucio.sputnik.module.modules.movement.BoatFly;
import me.retucio.sputnik.module.modules.movement.Velocity; import me.retucio.sputnik.module.modules.movement.Velocity;
import me.retucio.sputnik.module.modules.render.Nametags; import me.retucio.sputnik.module.modules.render.Nametags;
import net.minecraft.entity.*; import me.retucio.sputnik.util.interfaces.IVec3;
import net.minecraft.entity.passive.TameableEntity; import net.minecraft.ChatFormatting;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.client.Minecraft;
import net.minecraft.entity.projectile.PersistentProjectileEntity; import net.minecraft.network.chat.Component;
import net.minecraft.entity.vehicle.AbstractBoatEntity; import net.minecraft.world.entity.Entity;
import net.minecraft.text.Text; import net.minecraft.world.entity.EntityType;
import net.minecraft.util.Formatting; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.World; import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.arrow.AbstractArrow;
import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
import net.minecraft.world.phys.HitResult;
import org.joml.Vector3d;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import static me.retucio.sputnik.Sputnik.EVENT_BUS;
import static me.retucio.sputnik.Sputnik.mc;
@Mixin(Entity.class) @Mixin(Entity.class)
public abstract class EntityMixin { public abstract class EntityMixin {
@Shadow public abstract Text getName(); @Unique boolean freecamDone;
@Shadow public abstract Component getName();
@Shadow public abstract EntityType<?> getType(); @Shadow public abstract EntityType<?> getType();
@Shadow private float yaw; @Shadow private float yRot;
@Shadow private float pitch; @Shadow private float xRot;
@Shadow
public abstract HitResult pick(double range, float a, boolean withLiquids);
@Unique @Unique
Freecam freecam; Freecam freecam;
@@ -50,30 +58,74 @@ public abstract class EntityMixin {
@Unique @Unique
Rotations rotations; Rotations rotations;
@SuppressWarnings("rawtypes")
@Inject(method = "<init>", at = @At("TAIL")) @Inject(method = "<init>", at = @At("TAIL"))
private void getModules(EntityType type, World world, CallbackInfo ci) { private void getModules(CallbackInfo ci) {
freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
freelook = ModuleManager.INSTANCE.getModuleByClass(Freelook.class); freelook = ModuleManager.INSTANCE.getModuleByClass(Freelook.class);
nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class); nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
rotations = ModuleManager.INSTANCE.getModuleByClass(Rotations.class); rotations = ModuleManager.INSTANCE.getModuleByClass(Rotations.class);
} }
@Inject(method = "pick", at = @At("HEAD"), cancellable = true)
private void updateTargetedEntityInvoke(double range, float a, boolean withLiquids, CallbackInfoReturnable<HitResult> cir) {
Minecraft mc = Minecraft.getInstance();
if ((freecam.isEnabled()) && mc.getCameraEntity() != null && !freecamDone) {
cir.cancel();
Entity cameraEntity = mc.getCameraEntity();
Vector3d pos = freecam.getPos();
Vector3d prevPos = freecam.getPrevPos();
double x = cameraEntity.getX();
double y = cameraEntity.getY();
double z = cameraEntity.getZ();
double lastX = cameraEntity.xo;
double lastY = cameraEntity.yo;
double lastZ = cameraEntity.zo;
float yaw = cameraEntity.getYRot();
float pitch = cameraEntity.getXRot();
float lastYaw = cameraEntity.yRotO;
float lastPitch = cameraEntity.xRotO;
((IVec3) cameraEntity.position()).sputnik$set(pos.x, pos.y - cameraEntity.getEyeHeight(cameraEntity.getPose()), pos.z);
cameraEntity.xo = prevPos.x;
cameraEntity.yo = prevPos.y - cameraEntity.getEyeHeight(cameraEntity.getPose());
cameraEntity.zo = prevPos.z;
cameraEntity.setYRot(freecam.getYaw());
cameraEntity.setXRot(freecam.getPitch());
cameraEntity.yRotO = freecam.getPrevYaw();
cameraEntity.xRotO = freecam.getPrevPitch();
freecamDone = true;
pick(range, a, withLiquids);
freecamDone = false;
((IVec3) cameraEntity.position()).sputnik$set(x, y, z);
cameraEntity.xo = lastX;
cameraEntity.yo = lastY;
cameraEntity.zo = lastZ;
cameraEntity.setYRot(yaw);
cameraEntity.setXRot(pitch);
cameraEntity.yRotO = lastYaw;
cameraEntity.xRotO = lastPitch;
}
}
// cámara libre & perspectiva libre // cámara libre & perspectiva libre
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
@Inject(method = "changeLookDirection", at = @At("HEAD"), cancellable = true) @Inject(method = "turn", at = @At("HEAD"), cancellable = true)
private void onChangeLookDirection(double cursorDeltaX, double cursorDeltaY, CallbackInfo ci) { private void onChangeLookDirection(double xo, double yo, CallbackInfo ci) {
if ((Object) this != mc.player) return; if ((Object) this != Sputnik.mc.player) return;
if (freecam.isEnabled()) { if (freecam.isEnabled()) {
freecam.changeLookDirection(cursorDeltaX * 0.15, cursorDeltaY * 0.15); freecam.changeLookDirection(xo * 0.15, yo * 0.15);
ci.cancel(); ci.cancel();
} else if (freelook.isEnabled() && freelook.mode.is(Freelook.CameraMode.CAMERA)) { } else if (freelook.isEnabled() && freelook.mode.is(Freelook.CameraMode.CAMERA)) {
freelook.setYaw(freelook.getYaw() + (float) (cursorDeltaX * freelook.mouseSens.getFloatValue())); freelook.setYaw(freelook.getYaw() + (float) (xo * freelook.mouseSens.getFloatValue()));
freelook.setPitch(freelook.getPitch() + (float) (cursorDeltaY * freelook.mouseSens.getFloatValue())); freelook.setPitch(freelook.getPitch() + (float) (yo * freelook.mouseSens.getFloatValue()));
if (Math.abs(freelook.getPitch()) > 90) freelook.setPitch(freelook.getPitch() > 0 ? 90 : -90); if (Math.abs(freelook.getPitch()) > 90) freelook.setPitch(freelook.getPitch() > 0 ? 90 : -90);
ci.cancel(); ci.cancel();
@@ -87,39 +139,39 @@ public abstract class EntityMixin {
@ModifyReturnValue(method = "isCustomNameVisible", at = @At("RETURN")) @ModifyReturnValue(method = "isCustomNameVisible", at = @At("RETURN"))
private boolean renderEntityNametags(boolean original) { private boolean renderEntityNametags(boolean original) {
if (!nametags.isEnabled()) return original; if (!nametags.isEnabled()) return original;
if ((Object) this instanceof PersistentProjectileEntity p && p.isOnGround()) return false; if ((Object) this instanceof AbstractArrow p && p.onGround()) return false;
if ((Object) this instanceof ItemEntity i && !nametags.items.isEnabled(i.getStack().getItem())) return false; if ((Object) this instanceof ItemEntity i && !nametags.items.isEnabled(i.getItem().getItem())) return false;
return nametags.entities.isEnabled((this.getType())); return nametags.entities.isEnabled((this.getType()));
} }
@ModifyReturnValue(method = "getName", at = @At("RETURN")) @ModifyReturnValue(method = "getName", at = @At("RETURN"))
private Text showProjectileDamage(Text original) { private Component showProjectileDamage(Component original) {
if (!nametags.isEnabled() || !nametags.showProjectileDamage.getValue()) return original; if (!nametags.isEnabled() || !nametags.showProjectileDamage.getValue()) return original;
if ((Object) this instanceof PersistentProjectileEntity arrow) { // aunque lo llame "arrow", también cubre flechas espectrales y tridentes if ((Object) this instanceof AbstractArrow arrow) { // aunque se llame "arrow", también cubre flechas espectrales y tridentes
String damage = nametags.getArrowDamage(arrow); String damage = nametags.getArrowDamage(arrow);
if (!damage.equals("0")) return original.copy().append(Text.literal(" (" + damage + ")").formatted(Formatting.RED)); if (!damage.equals("0")) return original.copy().append(Component.literal(" (" + damage + ")").withStyle(ChatFormatting.RED));
} }
return original; return original;
} }
@ModifyReturnValue(method = "getName", at = @At("RETURN")) @ModifyReturnValue(method = "getName", at = @At("RETURN"))
private Text showTntPrimeTime(Text original) { private Component showTntPrimeTime(Component original) {
if (!nametags.isEnabled() || !nametags.tntPrime.getValue()) return original; if (!nametags.isEnabled() || !nametags.tntPrime.getValue()) return original;
if ((Object) this instanceof TntEntity tnt) { if ((Object) this instanceof PrimedTnt tnt) {
return Text.of(nametags.getTntPrimeTime(tnt)); return Component.nullToEmpty(nametags.getTntPrimeTime(tnt));
} }
return original; return original;
} }
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
@ModifyReturnValue(method = "getCustomName", at = @At("RETURN")) @ModifyReturnValue(method = "getCustomName", at = @At("RETURN"))
private Text displayEntityOwner(Text original) { private Component displayEntityOwner(Component original) {
if (!nametags.isEnabled() || !nametags.petOwner.getValue()) return original; if (!nametags.isEnabled() || !nametags.petOwner.getValue()) return original;
if ((Object) this instanceof TameableEntity entity && entity.getOwnerReference() != null) { if ((Object) this instanceof TamableAnimal entity && entity.getOwnerReference() != null) {
if (original != null) return original.copy().append(" (de " + nametags.getOwnerName(entity.getOwnerReference()) + ")"); if (original != null) return original.copy().append(" (de " + nametags.getOwnerName(entity.getOwnerReference()) + ")");
else return Text.of(nametags.getOwnerName(entity.getOwnerReference())); else return Component.nullToEmpty(nametags.getOwnerName(entity.getOwnerReference()));
} }
return original; return original;
} }
@@ -127,7 +179,7 @@ public abstract class EntityMixin {
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
@ModifyReturnValue(method = "getName", at = @At("RETURN")) @ModifyReturnValue(method = "getName", at = @At("RETURN"))
private Text showBabies(Text original) { private Component showBabies(Component original) {
if (!nametags.isEnabled() || !nametags.distinguishBabies.getValue()) return original; if (!nametags.isEnabled() || !nametags.distinguishBabies.getValue()) return original;
if ((Object) this instanceof LivingEntity entity && entity.isBaby()) return original.copy().append(" (baby)"); if ((Object) this instanceof LivingEntity entity && entity.isBaby()) return original.copy().append(" (baby)");
return original; return original;
@@ -136,24 +188,24 @@ public abstract class EntityMixin {
// rotaciones // rotaciones
@Inject(method = "setRotation", at = @At("HEAD"), cancellable = true) @Inject(method = "setRot", at = @At("HEAD"), cancellable = true)
private void onRotation(float yaw, float pitch, CallbackInfo ci) { private void onRotation(float yaw, float pitch, CallbackInfo ci) {
if ((Object) this != mc.player) return; if ((Object) this != Sputnik.mc.player) return;
ChangeRotationEvent event = EVENT_BUS.post(new ChangeRotationEvent(yaw, pitch)); ChangeRotationEvent event = Sputnik.EVENT_BUS.post(new ChangeRotationEvent(yaw, pitch));
if (event.isCancelled()) ci.cancel(); if (event.isCancelled()) ci.cancel();
} }
@Inject(method = "setYaw", at = @At("HEAD"), cancellable = true) @Inject(method = "setYRot", at = @At("HEAD"), cancellable = true)
private void onChangeYaw(float yaw, CallbackInfo ci) { private void onChangeYaw(float yaw, CallbackInfo ci) {
if ((Object) this != mc.player) return; if ((Object) this != Sputnik.mc.player) return;
ChangeRotationEvent event = EVENT_BUS.post(new ChangeRotationEvent(yaw, this.pitch)); ChangeRotationEvent event = Sputnik.EVENT_BUS.post(new ChangeRotationEvent(yaw, this.xRot));
if (event.isCancelled()) ci.cancel(); if (event.isCancelled()) ci.cancel();
} }
@Inject(method = "setPitch", at = @At("HEAD"), cancellable = true) @Inject(method = "setXRot", at = @At("HEAD"), cancellable = true)
private void onChangePitch(float pitch, CallbackInfo ci) { private void onChangePitch(float pitch, CallbackInfo ci) {
if ((Object) this != mc.player) return; if ((Object) this != Sputnik.mc.player) return;
ChangeRotationEvent event = EVENT_BUS.post(new ChangeRotationEvent(this.yaw, pitch)); ChangeRotationEvent event = Sputnik.EVENT_BUS.post(new ChangeRotationEvent(this.yRot, pitch));
if (event.isCancelled()) ci.cancel(); if (event.isCancelled()) ci.cancel();
} }
@@ -161,22 +213,23 @@ public abstract class EntityMixin {
// otros // otros
@Inject(method = "isInvisibleTo", at = @At("RETURN"), cancellable = true) @Inject(method = "isInvisibleTo", at = @At("RETURN"), cancellable = true)
private void renderInvisPlayers(PlayerEntity player, CallbackInfoReturnable<Boolean> cir) { private void renderInvisPlayers(Player player, CallbackInfoReturnable<Boolean> cir) {
if (ModuleManager.INSTANCE.getModuleByClass(AntiInvis.class).isEnabled()) cir.setReturnValue(false); if (ModuleManager.INSTANCE.getModuleByClass(AntiInvis.class).isEnabled()) cir.setReturnValue(false);
} }
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
@Inject(method = "getStepHeight", at = @At("RETURN"), cancellable = true) @Inject(method = "maxUpStep", at = @At("RETURN"), cancellable = true)
private void modifyBoatStepHeight(CallbackInfoReturnable<Float> cir) { private void modifyBoatStepHeight(CallbackInfoReturnable<Float> cir) {
BoatFly boatFly = ModuleManager.INSTANCE.getModuleByClass(BoatFly.class); BoatFly boatFly = ModuleManager.INSTANCE.getModuleByClass(BoatFly.class);
if (((Object) this) instanceof AbstractBoatEntity && boatFly.isEnabled()) { if (((Object) this) instanceof AbstractBoat && boatFly.isEnabled()) {
cir.setReturnValue(boatFly.stepHeight.getFloatValue()); cir.setReturnValue(boatFly.stepHeight.getFloatValue());
} }
} }
@Inject(method = "pushAwayFrom", at = @At("HEAD"), cancellable = true) @SuppressWarnings("ConstantConditions")
@Inject(method = "push(Lnet/minecraft/world/entity/Entity;)V", at = @At("HEAD"), cancellable = true)
private void onPushed(Entity entity, CallbackInfo ci) { private void onPushed(Entity entity, CallbackInfo ci) {
Velocity velocity = ModuleManager.INSTANCE.getModuleByClass(Velocity.class); Velocity velocity = ModuleManager.INSTANCE.getModuleByClass(Velocity.class);
if (velocity.isEnabled() && !velocity.push.getValue() && (Object) this == mc.player) ci.cancel(); if (velocity.isEnabled() && !velocity.push.getValue() && (Object) this == Sputnik.mc.player) ci.cancel();
} }
} }
@@ -4,15 +4,15 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.Local;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.render.EntityESP; import me.retucio.sputnik.module.modules.render.EntityESP;
import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.world.entity.Entity;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(EntityRenderer.class) @Mixin(EntityRenderer.class)
public abstract class EntityRendererMixin { public abstract class EntityRendererMixin {
@@ -20,16 +20,16 @@ public abstract class EntityRendererMixin {
private EntityESP esp; private EntityESP esp;
@Inject(method = "<init>", at = @At("TAIL")) @Inject(method = "<init>", at = @At("TAIL"))
private void getModules(EntityRendererFactory.Context context, CallbackInfo ci) { private void getModules(CallbackInfo ci) {
esp = ModuleManager.INSTANCE.getModuleByClass(EntityESP.class); esp = ModuleManager.INSTANCE.getModuleByClass(EntityESP.class);
} }
@ModifyExpressionValue(method = "updateRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;hasOutline(Lnet/minecraft/entity/Entity;)Z")) @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;shouldEntityAppearGlowing(Lnet/minecraft/world/entity/Entity;)Z"))
private boolean renderGlowESP(boolean original, @Local(argsOnly = true) Entity entity) { private boolean renderGlowESP(boolean original, @Local(argsOnly = true) Entity entity) {
return (esp.isEnabled() && esp.mode.is(EntityESP.ESPMode.GLOW) && esp.entities.isEnabled(entity.getType())) || original; return (esp.isEnabled() && esp.mode.is(EntityESP.ESPMode.GLOW) && esp.entities.isEnabled(entity.getType())) || original;
} }
@ModifyExpressionValue(method = "updateRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getTeamColorValue()I")) @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getTeamColor()I"))
private int setGlowESPColor(int original, @Local(argsOnly = true) Entity entity) { private int setGlowESPColor(int original, @Local(argsOnly = true) Entity entity) {
if (esp.isEnabled() && esp.mode.is(EntityESP.ESPMode.GLOW) && esp.entities.isEnabled(entity.getType())) return esp.glowColor.getRGB(); if (esp.isEnabled() && esp.mode.is(EntityESP.ESPMode.GLOW) && esp.entities.isEnabled(entity.getType())) return esp.glowColor.getRGB();
return original; return original;
@@ -3,11 +3,11 @@ package me.retucio.sputnik.mixin.mixins.entity;
import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.render.Nametags; import me.retucio.sputnik.module.modules.render.Nametags;
import net.minecraft.entity.ItemEntity; import net.minecraft.ChatFormatting;
import net.minecraft.item.ItemStack; import net.minecraft.network.chat.Component;
import net.minecraft.text.MutableText; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.text.Text; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.util.Formatting; import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@@ -16,17 +16,17 @@ import org.spongepowered.asm.mixin.injection.At;
public abstract class ItemEntityMixin { public abstract class ItemEntityMixin {
@Shadow @Shadow
public abstract ItemStack getStack(); public abstract ItemStack getItem();
@ModifyReturnValue(method = "getName", at = @At("RETURN")) @ModifyReturnValue(method = "getName", at = @At("RETURN"))
private Text showItemCount(Text original) { private Component showItemCount(Component original) {
Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class); Nametags nametags = ModuleManager.INSTANCE.getModuleByClass(Nametags.class);
if (!nametags.isEnabled()) return original; if (!nametags.isEnabled()) return original;
int count = this.getStack().getCount(); int count = this.getItem().getCount();
MutableText name = this.getStack().getCustomName() != null ? this.getStack().getCustomName().copyContentOnly() : original.copyContentOnly(); MutableComponent name = this.getItem().getCustomName() != null ? this.getItem().getCustomName().plainCopy() : original.plainCopy();
if (!name.equals(original)) name = name.formatted(Formatting.ITALIC); if (!name.equals(original)) name = name.withStyle(ChatFormatting.ITALIC);
if (nametags.countItems.getValue()) { if (nametags.countItems.getValue()) {
if (count > 1) return name.copy().append(" x" + count); if (count > 1) return name.copy().append(" x" + count);
@@ -5,12 +5,12 @@ import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.movement.ElytraBounce; import me.retucio.sputnik.module.modules.movement.ElytraBounce;
import me.retucio.sputnik.module.modules.movement.Step; import me.retucio.sputnik.module.modules.movement.Step;
import me.retucio.sputnik.module.modules.movement.Velocity; import me.retucio.sputnik.module.modules.movement.Velocity;
import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.entity.Entity; import net.minecraft.sounds.SoundEvents;
import net.minecraft.entity.LivingEntity; import net.minecraft.sounds.SoundSource;
import net.minecraft.sound.SoundCategory; import net.minecraft.world.entity.Entity;
import net.minecraft.sound.SoundEvents; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.util.math.Vec3d; import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
@@ -21,6 +21,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import static me.retucio.sputnik.Sputnik.mc; import static me.retucio.sputnik.Sputnik.mc;
@Mixin(LivingEntity.class) @Mixin(LivingEntity.class)
public abstract class LivingEntityMixin { public abstract class LivingEntityMixin {
@@ -28,50 +29,49 @@ public abstract class LivingEntityMixin {
@Unique private boolean awaitingElytra = false; @Unique private boolean awaitingElytra = false;
@Shadow @Shadow
public abstract boolean isGliding(); public abstract boolean isFallFlying();
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
@Inject(method = "tickMovement", at = @At("TAIL")) @Inject(method = "aiStep", at = @At("TAIL"))
private void recastIfLanded(CallbackInfo ci) { private void recastIfLanded(CallbackInfo ci) {
ElytraBounce bounce = ModuleManager.INSTANCE.getModuleByClass(ElytraBounce.class); ElytraBounce ebounce = ModuleManager.INSTANCE.getModuleByClass(ElytraBounce.class);
if (!((Object) this instanceof ClientPlayerEntity) if (!((Object) this instanceof LocalPlayer)
|| mc.player == null || mc.player == null
|| bounce == null) || ebounce == null)
return; return;
boolean elytra = isGliding(); boolean elytra = isFallFlying();
if (awaitingElytra) { if (awaitingElytra) {
if (elytra) awaitingElytra = false; if (elytra) awaitingElytra = false;
} else if (!elytra && prevElytra) { } else if (!elytra && prevElytra) {
mc.getSoundManager().stopSounds(SoundEvents.ITEM_ELYTRA_FLYING.id(), SoundCategory.PLAYERS); mc.getSoundManager().stop(SoundEvents.ELYTRA_FLYING.location(), SoundSource.PLAYERS); // armor equip elytra??
bounce.bounce(); ebounce.bounce();
awaitingElytra = bounce.canUseElytra(); awaitingElytra = ebounce.canUseElytra();
} }
prevElytra = elytra; prevElytra = elytra;
} }
@Inject(method = "getStepHeight", at = @At("RETURN"), cancellable = true) @Inject(method = "maxUpStep", at = @At("RETURN"), cancellable = true)
private void step(CallbackInfoReturnable<Float> cir) { private void step(CallbackInfoReturnable<Float> cir) {
Step step = ModuleManager.INSTANCE.getModuleByClass(Step.class); Step step = ModuleManager.INSTANCE.getModuleByClass(Step.class);
if (step.isEnabled()) cir.setReturnValue(step.height.getFloatValue()); if (step.isEnabled()) cir.setReturnValue(step.height.getFloatValue());
} }
@Inject(method = "takeKnockback", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;setVelocity(DDD)V"), cancellable = true) @Inject(method = "knockback", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;setDeltaMovement(DDD)V"), cancellable = true)
private void onTakeKb(double strength, double x, double z, CallbackInfo ci, @Local(ordinal = 0) Vec3d vec3d, @Local(ordinal = 1) Vec3d vec3d2) { private void onTakeKb(double strength, double x, double z, CallbackInfo ci, @Local(name = "deltaMovement") Vec3 dm, @Local(name = "deltaVector") Vec3 dv) {
Velocity velocity = ModuleManager.INSTANCE.getModuleByClass(Velocity.class); Velocity velocity = ModuleManager.INSTANCE.getModuleByClass(Velocity.class);
if (!velocity.isEnabled() || velocity.hits.getValue()) return; if (!velocity.isEnabled() || velocity.hits.getValue()) return;
boolean onGround = ((LivingEntity) (Object) this).isOnGround(); boolean onGround = ((LivingEntity) (Object) this).onGround();
double kbX = (velocity.xPercentage.getValue() / 100) * (vec3d.x / 2 - vec3d2.x); double kbX = (velocity.xPercentage.getValue() / 100) * (dm.x / 2 - dv.x);
double kbY = (velocity.yPercentage.getValue() / 100) * ((onGround ? Math.min(0.4, vec3d.y / 2 + strength) : vec3d.y)); double kbY = (velocity.yPercentage.getValue() / 100) * ((onGround ? Math.min(0.4, dm.y / 2 + strength) : dm.y));
double kbZ = (velocity.zPercentage.getValue() / 100) * (vec3d.z / 2 - vec3d2.z); double kbZ = (velocity.zPercentage.getValue() / 100) * (dm.z / 2 - dv.z);
ci.cancel(); ci.cancel();
((Entity) (Object) this).addVelocity(kbX, kbY, kbZ); ((Entity) (Object) this).addDeltaMovement(new Vec3(kbX, kbY, kbZ));
} }
} }
@@ -2,10 +2,12 @@ package me.retucio.sputnik.mixin.mixins.hud;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.Local;
import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.event.render.RenderBossbarEvent; import me.retucio.sputnik.event.render.RenderBossbarEvent;
import net.minecraft.client.gui.hud.BossBarHud; import net.minecraft.client.gui.components.BossHealthOverlay;
import net.minecraft.client.gui.hud.ClientBossBar; import net.minecraft.client.gui.components.LerpingBossEvent;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Constant;
@@ -13,28 +15,26 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
import java.util.Iterator; import java.util.Iterator;
import static me.retucio.sputnik.Sputnik.EVENT_BUS;
@Mixin(value = BossHealthOverlay.class)
@Mixin(value = BossBarHud.class)
public abstract class BossBarHudMixin { public abstract class BossBarHudMixin {
@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/Collection;iterator()Ljava/util/Iterator;")) @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Ljava/util/Collection;iterator()Ljava/util/Iterator;"))
public Iterator<ClientBossBar> modifyBossBarIterator(Iterator<ClientBossBar> original) { private Iterator<LerpingBossEvent> modifyBossBarIterator(Iterator<LerpingBossEvent> original) {
RenderBossbarEvent.BossIterator event = EVENT_BUS.post(new RenderBossbarEvent.BossIterator(original)); RenderBossbarEvent.BossIterator event = Sputnik.EVENT_BUS.post(new RenderBossbarEvent.BossIterator(original));
return event.getIterator(); return event.getIterator();
} }
@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ClientBossBar;getName()Lnet/minecraft/text/Text;")) @ModifyExpressionValue(method = "extractRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/LerpingBossEvent;getName()Lnet/minecraft/network/chat/Component;"))
public Text modifyBossBarName(Text original, @Local ClientBossBar clientBossBar) { private Component modifyBossBarName(Component original, @Local(name = "event") LerpingBossEvent clientBossBar) {
RenderBossbarEvent.BossText event = EVENT_BUS.post(new RenderBossbarEvent.BossText(clientBossBar, original)); RenderBossbarEvent.BossText event = Sputnik.EVENT_BUS.post(new RenderBossbarEvent.BossText(clientBossBar, (MutableComponent) original));
return event.getName(); return event.getName();
} }
// require = 0 para meteor // require = 0 para compat. con meteor
@ModifyConstant(method = "render", constant = @Constant(intValue = 9, ordinal = 1), require = 0) @ModifyConstant(method = "extractRenderState", constant = @Constant(intValue = 9, ordinal = 1), require = 0)
public int modifySpacingConstant(int constant) { private int modifySpacingConstant(int constant) {
RenderBossbarEvent.BossSpacing event = EVENT_BUS.post(new RenderBossbarEvent.BossSpacing(constant)); RenderBossbarEvent.BossSpacing event = Sputnik.EVENT_BUS.post(new RenderBossbarEvent.BossSpacing(constant));
return event.getSpacing(); return event.getSpacing();
} }
} }
@@ -2,17 +2,17 @@ package me.retucio.sputnik.mixin.mixins.hud;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ChatPlus; import me.retucio.sputnik.module.modules.misc.ChatPlus;
import net.minecraft.client.gui.hud.ChatHudLine; import net.minecraft.client.multiplayer.chat.GuiMessage;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(targets = "net.minecraft.client.gui.hud.ChatHud$1", remap = false) @Mixin(targets = "net.minecraft.client.gui.components.ChatComponent$1", remap = false)
public abstract class ChatHudLineConsumerMixin { public abstract class ChatComponentLineConsumerMixin {
@Inject(method = "accept", at = @At("HEAD")) @Inject(method = "accept", at = @At("HEAD"))
private void setLine(ChatHudLine.Visible line, int y, float opacity, CallbackInfo ci) { private void setLine(GuiMessage.Line line, int lineIndex, float alpha, CallbackInfo ci) {
ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class).line = line; ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class).line = line;
} }
} }
@@ -0,0 +1,187 @@
package me.retucio.sputnik.mixin.mixins.hud;
import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.event.network.ReceiveMessageEvent;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ChatPlus;
import me.retucio.sputnik.util.interfaces.IChatComponent;
import me.retucio.sputnik.util.interfaces.IGuiMessage;
import me.retucio.sputnik.util.interfaces.IGuiMessageLine;
import me.retucio.sputnik.util.interfaces.IChatListener;
import net.minecraft.client.gui.components.ChatComponent;
import net.minecraft.client.multiplayer.chat.GuiMessage;
import net.minecraft.client.multiplayer.chat.GuiMessageSource;
import net.minecraft.client.multiplayer.chat.GuiMessageTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MessageSignature;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.util.FormattedCharSequence;
import org.jspecify.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;
@Mixin(ChatComponent.class)
public abstract class ChatComponentMixin implements IChatComponent {
@Unique
private boolean skipOnAddMessage;
@Unique
private int nextId;
@Unique
ChatPlus chatPlus;
@Shadow @Final
private List<GuiMessage> allMessages;
@Shadow @Final
private List<GuiMessage.Line> trimmedMessages;
@Shadow
public abstract void addClientSystemMessage(Component message);
@Shadow
protected abstract void addMessage(final Component contents, final @Nullable MessageSignature signature, final GuiMessageSource source, final @Nullable GuiMessageTag tag);
@Inject(method = "<init>", at = @At("TAIL"))
private void getModules(CallbackInfo ci) {
chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class);
}
// métodos relacionados con las interfaces IChatHud, IChatHudLine, IChadHudLineVisible y IMessageHandler
@Override
public void sputnik$add(Component message, int id) {
nextId = id;
addClientSystemMessage(message);
nextId = 0;
}
@Inject(method = "addMessageToDisplayQueue", at = @At(value = "INVOKE", target = "Ljava/util/List;addFirst(Ljava/lang/Object;)V", shift = At.Shift.AFTER))
private void onAddMessageAfterNewChatHudLineVisible(GuiMessage message, CallbackInfo ci) {
((IGuiMessage) (Object) trimmedMessages.getFirst()).sputnik$setId(nextId);
}
@Inject(method = "addMessageToQueue", at = @At(value = "INVOKE", target = "Ljava/util/List;addFirst(Ljava/lang/Object;)V", shift = At.Shift.AFTER))
private void onAddMessageAfterNewChatHudLine(GuiMessage message, CallbackInfo ci) {
((IGuiMessage) (Object) allMessages.getFirst()).sputnik$setId(nextId);
}
@ModifyExpressionValue(method = "addMessageToDisplayQueue", at = @At(value = "NEW", target = "(Lnet/minecraft/client/multiplayer/chat/GuiMessage;Lnet/minecraft/util/FormattedCharSequence;Z)Lnet/minecraft/client/multiplayer/chat/GuiMessage$Line;"))
private GuiMessage.Line onAddMessage_modifyChatHudLineVisible(GuiMessage.Line line, @Local(name = "i") int i) {
IChatListener iListener = (IChatListener) Sputnik.mc.getChatListener();
IGuiMessageLine iLine = (IGuiMessageLine) (Object) line;
iLine.sputnik$setSender(iListener.sputnik$getSender());
iLine.sputnik$setStartOfEntry(i == 0);
return line;
}
@ModifyExpressionValue(method = "addMessage", at = @At(value = "NEW", target = "(ILnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/multiplayer/chat/GuiMessageSource;Lnet/minecraft/client/multiplayer/chat/GuiMessageTag;)Lnet/minecraft/client/multiplayer/chat/GuiMessage;"))
private GuiMessage onAddMessage_modifyChatHudLine(GuiMessage line) {
IChatListener iListener = (IChatListener) Sputnik.mc.getChatListener();
((IGuiMessage) (Object) line).sputnik$setSender(iListener.sputnik$getSender());
return line;
}
@Override
public List<GuiMessage.Line> sputnik$getVisibleMessages() {
return trimmedMessages;
}
// modificar contenido del mensaje
@Inject(at = @At("HEAD"), method = "addMessage", cancellable = true)
private void onAddMessage(Component contents, MessageSignature signature, GuiMessageSource source, GuiMessageTag tag, CallbackInfo ci) {
if (skipOnAddMessage) return;
ReceiveMessageEvent event = Sputnik.EVENT_BUS.post(new ReceiveMessageEvent(contents, tag, nextId));
if (event.isCancelled()) {
ci.cancel();
} else {
trimmedMessages.removeIf(msg -> ((IGuiMessage) (Object) msg).sputnik$getId() == nextId && nextId != 0);
for (int i = allMessages.size() - 1; i > -1; i--) {
if (((IGuiMessage) (Object) allMessages.get(i)).sputnik$getId() == nextId && nextId != 0) {
allMessages.remove(i);
chatPlus.removeLine(i);
}
}
if (event.wasModified()) {
ci.cancel();
skipOnAddMessage = true;
addMessage(event.getMessage(), signature, source, event.getTag());
skipOnAddMessage = false;
}
}
}
// cabezas
@ModifyExpressionValue(method = "extractRenderState(Lnet/minecraft/client/gui/components/ChatComponent$ChatGraphicsAccess;IILnet/minecraft/client/gui/components/ChatComponent$DisplayMode;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;ceil(F)I"))
private int onRender_modifyWidth(int width) {
return (chatPlus.isEnabled() && chatPlus.showHeads.getValue()) ? width + 10 : width;
}
// historial (registro) del chat
@ModifyExpressionValue(method = "addMessageToQueue", at = @At(value = "CONSTANT", args = "intValue=100"))
private int maxLength(int size) {
if (!chatPlus.isEnabled()) return size;
return size + chatPlus.chatHistoryExtraLength.getIntValue();
}
@ModifyExpressionValue(method = "addMessageToDisplayQueue", at = @At(value = "CONSTANT", args = "intValue=100"))
private int maxLengthVisible(int size) {
if (!chatPlus.isEnabled()) return size;
return size + chatPlus.chatHistoryExtraLength.getIntValue();
}
@Inject(method = "addMessageToDisplayQueue", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;isChatFocused()Z"))
private void onBreakChatMessageLines(GuiMessage message, CallbackInfo ci, @Local(name = "lines") List<FormattedCharSequence> lines) {
chatPlus.lines.addFirst(lines.size());
}
@Inject(method = "addMessageToDisplayQueue", at = @At(value = "INVOKE", target = "Ljava/util/List;removeLast()Ljava/lang/Object;"))
private void onRemoveMessage(GuiMessage message, CallbackInfo ci) {
int extra = chatPlus.chatHistoryExtraLength.getIntValue();
int size = chatPlus.lines.size();
while (size > 100 + extra) {
chatPlus.lines.removeLast();
size--;
}
}
@Inject(method = "clearMessages", at = @At("HEAD"))
private void onClear(boolean history, CallbackInfo ci) {
chatPlus.lines.clear();
}
@Inject(method = "refreshTrimmedMessages", at = @At("HEAD"))
private void onRefresh(CallbackInfo ci) {
chatPlus.lines.clear();
}
}
@@ -1,52 +0,0 @@
package me.retucio.sputnik.mixin.mixins.hud;
import com.llamalad7.mixinextras.injector.ModifyReceiver;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ChatPlus;
import net.minecraft.client.font.Alignment;
import net.minecraft.client.font.DrawnTextConsumer;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.text.OrderedText;
import net.minecraft.util.math.ColorHelper;
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ChatHud.Interactable.class)
public abstract class ChatHudInteractableMixin {
@Unique
private static ChatPlus chatPlus;
@Shadow @Final
private DrawContext context;
@Inject(method = "<init>", at = @At("TAIL"))
private void getModules(DrawContext context, TextRenderer textRenderer, int mouseX, int mouseY, boolean bl, CallbackInfo ci) {
chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class);
}
@ModifyReceiver(method = "text", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/DrawnTextConsumer;text(Lnet/minecraft/client/font/Alignment;IILnet/minecraft/client/font/DrawnTextConsumer$Transformation;Lnet/minecraft/text/OrderedText;)V"))
private DrawnTextConsumer onRender_beforeDrawTextWithShadow(DrawnTextConsumer instance, Alignment alignment, int x, int y, DrawnTextConsumer.Transformation transformation, OrderedText orderedText) {
chatPlus.beforeDrawMessage(context, y, ColorHelper.getWhite(transformation.opacity()));
return instance;
}
@ModifyArg(method = "text", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/DrawnTextConsumer;text(Lnet/minecraft/client/font/Alignment;IILnet/minecraft/client/font/DrawnTextConsumer$Transformation;Lnet/minecraft/text/OrderedText;)V"), index = 1)
private int modifyX(int x) {
return (chatPlus.isEnabled() && chatPlus.showHeads.getValue()) ? x + 10 : x;
}
@Inject(method = "text", at = @At("TAIL"))
private void onRender_afterDrawTextWithShadow(int y, float f, OrderedText text, CallbackInfoReturnable<Boolean> cir) {
chatPlus.afterDrawMessage();
}
}
@@ -1,189 +0,0 @@
package me.retucio.sputnik.mixin.mixins.hud;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
import me.retucio.sputnik.event.network.ReceiveMessageEvent;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ChatPlus;
import me.retucio.sputnik.util.interfaces.IChatHud;
import me.retucio.sputnik.util.interfaces.IChatHudLine;
import me.retucio.sputnik.util.interfaces.IChatHudLineVisible;
import me.retucio.sputnik.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.sputnik.Sputnik.*;
@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 sputnik$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()).sputnik$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()).sputnik$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.sputnik$setSender(handler.sputnik$getSender());
iLine.sputnik$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).sputnik$setSender(handler.sputnik$getSender());
return line;
}
@Override
public List<ChatHudLine.Visible> sputnik$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).sputnik$getId() == nextId && nextId != 0);
for (int i = messages.size() - 1; i > -1; i--) {
if (((IChatHudLine) (Object) messages.get(i)).sputnik$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.getValue()) ? 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();
}
}
@@ -0,0 +1,54 @@
package me.retucio.sputnik.mixin.mixins.hud;
import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ChatPlus;
import net.minecraft.client.gui.ActiveTextCollector;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.TextAlignment;
import net.minecraft.client.gui.components.ChatComponent;
import net.minecraft.util.ARGB;
import net.minecraft.util.FormattedCharSequence;
import com.llamalad7.mixinextras.injector.ModifyReceiver;
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ChatComponent.DrawingFocusedGraphicsAccess.class)
public abstract class DrawingFocusedGraphicsAccessMixin {
@Unique
private static ChatPlus chatPlus;
@Shadow @Final
private GuiGraphicsExtractor graphics;
@Inject(method = "<init>", at = @At("TAIL"))
private void getModules(CallbackInfo ci) {
chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class);
}
@ModifyReceiver(method = "handleMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ActiveTextCollector;accept(Lnet/minecraft/client/gui/TextAlignment;IILnet/minecraft/client/gui/ActiveTextCollector$Parameters;Lnet/minecraft/util/FormattedCharSequence;)V"))
private ActiveTextCollector onRender_beforeDrawTextWithShadow(ActiveTextCollector instance, TextAlignment textAlignment, int x, int y, ActiveTextCollector.Parameters parameters, FormattedCharSequence formattedCharSequence) {
chatPlus.beforeDrawMessage(graphics, y, ARGB.white(parameters.opacity()));
return instance;
}
@ModifyArg(method = "handleMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ActiveTextCollector;accept(Lnet/minecraft/client/gui/TextAlignment;IILnet/minecraft/client/gui/ActiveTextCollector$Parameters;Lnet/minecraft/util/FormattedCharSequence;)V"), index = 1)
private int modifyX(int x) {
return (chatPlus.isEnabled() && chatPlus.showHeads.getValue()) ? x + 10 : x;
}
@Inject(method = "handleMessage", at = @At("TAIL"))
private void onRender_afterDrawTextWithShadow(int textTop, float opacity, FormattedCharSequence message, CallbackInfoReturnable<Boolean> cir) {
chatPlus.afterDrawMessage();
}
}
@@ -1,19 +1,19 @@
package me.retucio.sputnik.mixin.mixins.hud; package me.retucio.sputnik.mixin.mixins.hud;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import me.retucio.sputnik.util.interfaces.IChatHudLineVisible; import me.retucio.sputnik.util.interfaces.IGuiMessageLine;
import net.minecraft.client.gui.hud.ChatHudLine; import net.minecraft.client.multiplayer.chat.GuiMessage;
import net.minecraft.text.OrderedText; import net.minecraft.util.FormattedCharSequence;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
@Mixin(ChatHudLine.Visible.class) @Mixin(GuiMessage.Line.class)
public class ChatHudLineVisibleMixin implements IChatHudLineVisible { public class GuiMessageLineMixin implements IGuiMessageLine {
@Shadow @Final @Shadow @Final
private OrderedText content; private FormattedCharSequence content;
@Unique @Unique
private int id; private int id;
@@ -1,19 +1,19 @@
package me.retucio.sputnik.mixin.mixins.hud; package me.retucio.sputnik.mixin.mixins.hud;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import me.retucio.sputnik.util.interfaces.IChatHudLine; import me.retucio.sputnik.util.interfaces.IGuiMessage;
import net.minecraft.client.gui.hud.ChatHudLine; import net.minecraft.client.multiplayer.chat.GuiMessage;
import net.minecraft.text.Text; import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
@Mixin(ChatHudLine.class) @Mixin(GuiMessage.class)
public class ChatHudLineMixin implements IChatHudLine { public class GuiMessageMixin implements IGuiMessage {
@Shadow @Final @Shadow @Final
private Text content; private Component content;
@Unique @Unique
private int id; private int id;
@@ -8,80 +8,79 @@ import me.retucio.sputnik.module.modules.misc.ChatPlus;
import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.camera.Freecam;
import me.retucio.sputnik.module.modules.render.NoRender; import me.retucio.sputnik.module.modules.render.NoRender;
import me.retucio.sputnik.ui.hud.HudRenderer; import me.retucio.sputnik.ui.hud.HudRenderer;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.DeltaTracker;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.render.RenderTickCounter; import net.minecraft.resources.Identifier;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(InGameHud.class) @Mixin(Gui.class)
public abstract class InGameHudMixin { public abstract class InGameHudMixin {
@Unique @Unique
NoRender noRender; NoRender noRender;
@Inject(method = "<init>", at = @At("TAIL")) @Inject(method = "<init>", at = @At("TAIL"))
private void getModules(MinecraftClient client, CallbackInfo ci) { private void getModules(CallbackInfo ci) {
noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class); noRender = ModuleManager.INSTANCE.getModuleByClass(NoRender.class);
} }
@Inject(method = "render", at = @At("TAIL")) @Inject(method = "extractRenderState", at = @At("TAIL"))
private void onRenderHud(DrawContext ctx, RenderTickCounter tc, CallbackInfo ci) { private void onRenderHud(GuiGraphicsExtractor gui, DeltaTracker dt, CallbackInfo ci) {
Sputnik.EVENT_BUS.post(new Render2DEvent(ctx, tc)); Sputnik.EVENT_BUS.post(new Render2DEvent(gui, dt));
} }
// norender // norender
@Inject(method = "renderScoreboardSidebar*", at = @At("HEAD"), cancellable = true) @Inject(method = "extractScoreboardSidebar", at = @At("HEAD"), cancellable = true)
private void noRenderScoreboard(CallbackInfo ci) { private void noRenderScoreboard(CallbackInfo ci) {
if (noRender.isEnabled() && !noRender.scoreboard.getValue()) ci.cancel(); if (noRender.isEnabled() && !noRender.scoreboard.getValue()) ci.cancel();
} }
@Inject(method = "renderTitleAndSubtitle", at = @At("HEAD"), cancellable = true) @Inject(method = "extractTitle", at = @At("HEAD"), cancellable = true)
private void noRenderTitles(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { private void noRenderTitles(GuiGraphicsExtractor graphics, DeltaTracker deltaTracker, CallbackInfo ci) {
if (noRender.isEnabled() && !noRender.titles.getValue()) ci.cancel(); if (noRender.isEnabled() && !noRender.titles.getValue()) ci.cancel();
} }
@Inject(method = "renderNauseaOverlay", at = @At("HEAD"), cancellable = true) @Inject(method = "extractConfusionOverlay", at = @At("HEAD"), cancellable = true)
private void noRenderNausea(DrawContext context, float nauseaStrength, CallbackInfo ci) { private void noRenderNausea(GuiGraphicsExtractor graphics, float strength, CallbackInfo ci) {
if (noRender.isEnabled() && !noRender.nauseaEffect.getValue()) ci.cancel(); if (noRender.isEnabled() && !noRender.nauseaEffect.getValue()) ci.cancel();
} }
@Inject(method = "renderSpyglassOverlay", at = @At("HEAD"), cancellable = true) @Inject(method = "extractSpyglassOverlay", at = @At("HEAD"), cancellable = true)
private void noRenderSpyglass(DrawContext context, float scale, CallbackInfo ci) { private void noRenderSpyglass(GuiGraphicsExtractor graphics, float scale, CallbackInfo ci) {
if (noRender.isEnabled() && !noRender.spyglassOverlay.getValue()) ci.cancel(); if (noRender.isEnabled() && !noRender.spyglassOverlay.getValue()) ci.cancel();
} }
@Inject(method = "renderPortalOverlay", at = @At("HEAD"), cancellable = true) @Inject(method = "extractPortalOverlay", at = @At("HEAD"), cancellable = true)
private void noRenderPortal(DrawContext context, float nauseaStrength, CallbackInfo ci) { private void noRenderPortal(GuiGraphicsExtractor graphics, float alpha, CallbackInfo ci) {
if (noRender.isEnabled() && !noRender.portalOverlay.getValue()) ci.cancel(); if (noRender.isEnabled() && !noRender.portalOverlay.getValue()) ci.cancel();
} }
@Inject(method = "renderOverlay", at = @At("HEAD"), cancellable = true) @Inject(method = "extractTextureOverlay", at = @At("HEAD"), cancellable = true)
private void noRenderPumpkinBlur(DrawContext context, Identifier texture, float opacity, CallbackInfo ci) { private void noRenderPumpkinBlur(GuiGraphicsExtractor graphics, Identifier texture, float alpha, CallbackInfo ci) {
if (noRender.isEnabled() && !noRender.pumpkinOverlay.getValue() && texture.getPath().equals("textures/misc/pumpkinblur.png")) ci.cancel(); if (noRender.isEnabled() && !noRender.pumpkinOverlay.getValue() && texture.getPath().equals("textures/misc/pumpkinblur.png")) ci.cancel();
} }
// otros // otros
@Inject(method = "render", at = @At("RETURN")) @Inject(method = "extractRenderState", at = @At("RETURN"))
private void renderHUD(DrawContext ctx, RenderTickCounter tc, CallbackInfo ci) { private void renderHUD(GuiGraphicsExtractor gui, DeltaTracker dt, CallbackInfo ci) {
HudRenderer.render(ctx, tc); HudRenderer.render(gui, dt);
} }
@ModifyExpressionValue(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/Perspective;isFirstPerson()Z")) @ModifyExpressionValue(method = "extractCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/CameraType;isFirstPerson()Z"))
private boolean alwaysRenderCrosshairInFreecam(boolean firstPerson) { private boolean alwaysRenderCrosshairInFreecam(boolean firstPerson) {
return ModuleManager.INSTANCE.getModuleByClass(Freecam.class).isEnabled() || 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) @Inject(method = "onDisconnected", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;clearMessages(Z)V"), cancellable = true)
private void onClear(CallbackInfo ci) { private void onClear(CallbackInfo ci) {
ChatPlus chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class); ChatPlus chatPlus = ModuleManager.INSTANCE.getModuleByClass(ChatPlus.class);
if (chatPlus.isEnabled() && chatPlus.keepHistory.getValue()) ci.cancel(); if (chatPlus.isEnabled() && chatPlus.keepHistory.getValue()) ci.cancel();
@@ -2,23 +2,21 @@ package me.retucio.sputnik.mixin.mixins.io;
import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.event.input.KeyEvent; import me.retucio.sputnik.event.input.KeyEvent;
import net.minecraft.client.Keyboard; import net.minecraft.client.KeyboardHandler;
import net.minecraft.client.input.KeyInput;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static me.retucio.sputnik.Sputnik.EVENT_BUS;
@Mixin(Keyboard.class) @Mixin(KeyboardHandler.class)
public abstract class KeyboardMixin { public abstract class KeyboardHandlerMixin {
@Inject(method = "onKey", at = @At("HEAD"), cancellable = true) @Inject(method = "keyPress", at = @At("HEAD"), cancellable = true)
private void onKeyPress(long window, int action, KeyInput input, CallbackInfo ci) { private void onKeyPress(long handle, int action, net.minecraft.client.input.KeyEvent input, CallbackInfo ci) {
if (input.key() == -1) return; if (input.key() == -1) return;
Sputnik.INSTANCE.onInput(input.key(), action); Sputnik.INSTANCE.onInput(input.key(), action);
KeyEvent event = EVENT_BUS.post(new KeyEvent(input.key(), input.scancode(), action)); KeyEvent event = Sputnik.EVENT_BUS.post(new KeyEvent(input.key(), input.scancode(), action));
if (event.isCancelled()) ci.cancel(); if (event.isCancelled()) ci.cancel();
} }
} }
@@ -2,27 +2,27 @@ package me.retucio.sputnik.mixin.mixins.io;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.camera.Freecam; import me.retucio.sputnik.module.modules.camera.Freecam;
import net.minecraft.client.input.Input; import net.minecraft.client.player.ClientInput;
import net.minecraft.client.input.KeyboardInput; import net.minecraft.client.player.KeyboardInput;
import net.minecraft.util.PlayerInput; import net.minecraft.world.entity.player.Input;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(KeyboardInput.class) @Mixin(KeyboardInput.class)
public abstract class KeyInputMixin extends Input { public abstract class KeyboardInputMixin extends ClientInput {
@Inject(method = "tick", at = @At("TAIL")) @Inject(method = "tick", at = @At("TAIL"))
private void isPressed(CallbackInfo ci) { private void isPressed(CallbackInfo ci) {
Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class); Freecam freecam = ModuleManager.INSTANCE.getModuleByClass(Freecam.class);
if (freecam.isEnabled() && freecam.stayCrouching.getValue() && freecam.isCrouching()) if (freecam.isEnabled() && freecam.stayCrouching.getValue() && freecam.isCrouching())
playerInput = new PlayerInput( keyPresses = new Input(
false, false, false, false,
false, false, false, false,
false, false,
true, // siempre agachado true, // siempre agachado
false false
); );
} }
} }
@@ -3,28 +3,27 @@ package me.retucio.sputnik.mixin.mixins.io;
import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.event.input.MouseClickEvent; import me.retucio.sputnik.event.input.MouseClickEvent;
import me.retucio.sputnik.event.input.MouseScrollEvent; import me.retucio.sputnik.event.input.MouseScrollEvent;
import net.minecraft.client.Mouse; import net.minecraft.client.MouseHandler;
import net.minecraft.client.input.MouseInput; import net.minecraft.client.input.MouseButtonInfo;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static me.retucio.sputnik.Sputnik.EVENT_BUS;
@Mixin(Mouse.class) @Mixin(MouseHandler.class)
public abstract class MouseMixin { public abstract class MouseHandlerMixin {
@Inject(method = "onMouseButton", at = @At("HEAD"), cancellable = true) @Inject(method = "onButton", at = @At("HEAD"), cancellable = true)
private void onMouseButton(long window, MouseInput input, int action, CallbackInfo ci) { private void onMouseButton(long handle, MouseButtonInfo input, int action, CallbackInfo ci) {
Sputnik.INSTANCE.onInput(input.button(), action); Sputnik.INSTANCE.onInput(input.button(), action);
MouseClickEvent event = EVENT_BUS.post(new MouseClickEvent(action, input.button())); MouseClickEvent event = Sputnik.EVENT_BUS.post(new MouseClickEvent(action, input.button()));
if (event.isCancelled()) ci.cancel(); if (event.isCancelled()) ci.cancel();
} }
@Inject(method = "onMouseScroll", at = @At("HEAD"), cancellable = true) @Inject(method = "onScroll", at = @At("HEAD"), cancellable = true)
private void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci) { private void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo ci) {
MouseScrollEvent event = EVENT_BUS.post(new MouseScrollEvent(horizontal, vertical)); MouseScrollEvent event = Sputnik.EVENT_BUS.post(new MouseScrollEvent(horizontal, vertical));
if (event.isCancelled()) ci.cancel(); if (event.isCancelled()) ci.cancel();
} }
} }
@@ -1,10 +1,10 @@
package me.retucio.sputnik.mixin.mixins.io; package me.retucio.sputnik.mixin.mixins.io;
import com.mojang.blaze3d.platform.NativeImage;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.misc.ScreenshotPlus; import me.retucio.sputnik.module.modules.misc.ScreenshotPlus;
import net.minecraft.client.texture.NativeImage; import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ScreenshotRecorder; import net.minecraft.client.Screenshot;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@@ -15,33 +15,31 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.function.Consumer; import java.util.function.Consumer;
import static me.retucio.sputnik.Sputnik.mc;
@Mixin(ScreenshotRecorder.class) @Mixin(Screenshot.class)
public abstract class ScreenshotRecorderMixin { public abstract class ScreenshotMixin {
// "method_22691" es la lambda de la función "saveScreenshot()" (por lo menos en 1.21.6) @Inject(method = "lambda$grab$1", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"), cancellable = true)
@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 image, File file, Consumer<?> callback, CallbackInfo ci) {
private static void sendActionsMessage(NativeImage nativeImage, File file, Consumer<Text> consumer, CallbackInfo ci) {
ScreenshotPlus screenshotPlus = getScreenshotPlus(); ScreenshotPlus screenshotPlus = getScreenshotPlus();
if (screenshotPlus.isEnabled()) ci.cancel(); 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) @Inject(method = "lambda$grab$1", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/NativeImage;writeToFile(Ljava/io/File;)V"), cancellable = true)
private static void interceptScreenshotFile(NativeImage nativeImage, File file, Consumer<Text> consumer, CallbackInfo ci) throws IOException { private static void interceptScreenshotFile(NativeImage image, File file, Consumer<?> callback, CallbackInfo ci) throws IOException {
ScreenshotPlus screenshotPlus = getScreenshotPlus(); ScreenshotPlus screenshotPlus = getScreenshotPlus();
// aunque el módulo esté apagado, pasar las referencias para poder usar los comandos para las capturas // aunque el módulo esté apagado, pasar las referencias para poder usar los comandos para las capturas
screenshotPlus.setScreenshot(nativeImage); screenshotPlus.setScreenshot(image);
screenshotPlus.setScreenshotFile(file); screenshotPlus.setScreenshotFile(file);
if (!screenshotPlus.isEnabled()) return; if (!screenshotPlus.isEnabled()) return;
// por los threads o lo que sea // por los threads o lo que sea
mc.execute(screenshotPlus::sendScreenshotMessage); Minecraft.getInstance().execute(screenshotPlus::sendScreenshotMessage);
switch (screenshotPlus.defaultAction.getValue()) { switch (screenshotPlus.defaultAction.getValue()) {
case COPY -> screenshotPlus.copyScreenshot(nativeImage); case COPY -> screenshotPlus.copyScreenshot(image);
case SAVE -> screenshotPlus.saveScreenshot(); case SAVE -> screenshotPlus.saveScreenshot();
case NONE -> ci.cancel(); case NONE -> ci.cancel();
} }
@@ -2,14 +2,14 @@ package me.retucio.sputnik.mixin.mixins.item;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.inventory.ShulkerPeek; import me.retucio.sputnik.module.modules.inventory.ShulkerPeek;
import net.minecraft.block.ShulkerBoxBlock; import net.minecraft.ChatFormatting;
import net.minecraft.component.type.TooltipDisplayComponent; import net.minecraft.network.chat.Component;
import net.minecraft.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType; import net.minecraft.world.item.TooltipFlag;
import net.minecraft.text.Text; import net.minecraft.world.item.component.TooltipDisplay;
import net.minecraft.util.Formatting; import net.minecraft.world.level.block.ShulkerBoxBlock;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@@ -20,21 +20,21 @@ import java.util.function.Consumer;
@Mixin(Item.class) @Mixin(Item.class)
public abstract class ItemMixin { public abstract class ItemMixin {
@Inject(method = "appendTooltip", at = @At("HEAD")) @Inject(method = "appendHoverText", at = @At("HEAD"))
private void onAppendTooltip(ItemStack stack, Item.TooltipContext context, TooltipDisplayComponent displayComponent, Consumer<Text> textConsumer, TooltipType type, CallbackInfo ci) { private void onAppendTooltip(ItemStack stack, Item.TooltipContext context, TooltipDisplay display, Consumer<Component> builder, TooltipFlag tooltipFlag, CallbackInfo ci) {
ShulkerPeek shulkerPeek = ModuleManager.INSTANCE.getModuleByClass(ShulkerPeek.class); ShulkerPeek shulkerPeek = ModuleManager.INSTANCE.getModuleByClass(ShulkerPeek.class);
if (!shulkerPeek.isEnabled() || !shulkerPeek.showTooltips.getValue()) return; if (!shulkerPeek.isEnabled() || !shulkerPeek.showTooltips.getValue()) return;
if (stack.getItem() instanceof BlockItem blockItem && blockItem.getBlock() instanceof ShulkerBoxBlock) { if (stack.getItem() instanceof BlockItem blockItem && blockItem.getBlock() instanceof ShulkerBoxBlock) {
if (ShulkerPeek.isShulkerEmpty(stack)) { if (ShulkerPeek.isShulkerEmpty(stack)) {
textConsumer.accept(Text.literal("vacío").formatted(Formatting.GRAY, Formatting.ITALIC)); builder.accept(Component.literal("vacío").withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC));
} else { } else {
textConsumer.accept( builder.accept(
Text.literal("mantén ") Component.literal("mantén ")
.append(Text.literal(shulkerPeek.previewKey.getKeyName()) .append(Component.literal(shulkerPeek.previewKey.getKeyName())
.formatted(Formatting.GOLD, Formatting.BOLD)) .withStyle(ChatFormatting.GOLD, ChatFormatting.BOLD))
.append(" para previsualizar") .append(" para previsualizar")
.formatted(Formatting.GRAY) .withStyle(ChatFormatting.GRAY)
); );
} }
} }
@@ -1,28 +1,28 @@
package me.retucio.sputnik.mixin.mixins.item; package me.retucio.sputnik.mixin.mixins.item;
import me.retucio.sputnik.Sputnik;
import me.retucio.sputnik.event.interact.DamageItemEvent; import me.retucio.sputnik.event.interact.DamageItemEvent;
import net.minecraft.item.Item; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.world.item.Item;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.world.item.ItemStack;
import org.jspecify.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.function.Consumer; import java.util.function.Consumer;
import static me.retucio.sputnik.Sputnik.EVENT_BUS;
@Mixin(ItemStack.class) @Mixin(ItemStack.class)
public abstract class ItemStackMixin { public abstract class ItemStackMixin {
@Shadow @Shadow
public abstract int getDamage(); public abstract int getDamageValue();
@Inject(method = "onDurabilityChange", at = @At("TAIL")) @Inject(method = "applyDamage", at = @At("TAIL"))
private void onDamage(int damage, ServerPlayerEntity player, Consumer<Item> breakCallback, CallbackInfo ci) { private void onDamage(int newDamage, @Nullable ServerPlayer player, Consumer<Item> onBreak, CallbackInfo ci) {
ItemStack stack = (ItemStack) (Object) this; ItemStack stack = (ItemStack) (Object) this;
EVENT_BUS.post(new DamageItemEvent(getDamage(), stack)); Sputnik.EVENT_BUS.post(new DamageItemEvent(getDamageValue(), stack));
} }
} }
@@ -3,16 +3,17 @@ package me.retucio.sputnik.mixin.mixins.item;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.ModuleManager;
import me.retucio.sputnik.module.modules.movement.TridentBoost; import me.retucio.sputnik.module.modules.movement.TridentBoost;
import net.minecraft.item.TridentItem; import net.minecraft.world.item.TridentItem;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs; import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args; import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
@Mixin(TridentItem.class) @Mixin(TridentItem.class)
public abstract class TridentItemMixin { public abstract class TridentItemMixin {
@ModifyArgs(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V")) @ModifyArgs(method = "releaseUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;push(DDD)V"))
private void modifyVelocity(Args args) { private void modifyVelocity(Args args) {
TridentBoost tridentBoost = ModuleManager.INSTANCE.getModuleByClass(TridentBoost.class); TridentBoost tridentBoost = ModuleManager.INSTANCE.getModuleByClass(TridentBoost.class);
if (!tridentBoost.isEnabled()) return; if (!tridentBoost.isEnabled()) return;
@@ -21,13 +22,13 @@ public abstract class TridentItemMixin {
args.set(2, (double) args.get(2) * tridentBoost.multiplier.getValue()); args.set(2, (double) args.get(2) * tridentBoost.multiplier.getValue());
} }
@ModifyExpressionValue(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isTouchingWaterOrRain()Z")) @ModifyExpressionValue(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;isInWaterOrRain()Z"))
private boolean allowUseOutOfWaterPre(boolean original) { private boolean allowUseOutOfWaterPre(boolean original) {
TridentBoost tridentBoost = ModuleManager.INSTANCE.getModuleByClass(TridentBoost.class); TridentBoost tridentBoost = ModuleManager.INSTANCE.getModuleByClass(TridentBoost.class);
return (tridentBoost.outOfWater.getValue() && tridentBoost.isEnabled()) || original; return (tridentBoost.outOfWater.getValue() && tridentBoost.isEnabled()) || original;
} }
@ModifyExpressionValue(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isTouchingWaterOrRain()Z")) @ModifyExpressionValue(method = "releaseUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;isInWaterOrRain()Z"))
private boolean allowUseOutOfWaterPost(boolean original) { private boolean allowUseOutOfWaterPost(boolean original) {
TridentBoost tridentBoost = ModuleManager.INSTANCE.getModuleByClass(TridentBoost.class); TridentBoost tridentBoost = ModuleManager.INSTANCE.getModuleByClass(TridentBoost.class);
return (tridentBoost.outOfWater.getValue() && tridentBoost.isEnabled()) || original; return (tridentBoost.outOfWater.getValue() && tridentBoost.isEnabled()) || original;
Loaded 100 of 324 files, more files were not shown because too many files have changed in this diff. Show more