diff --git a/cambios.md b/cambios.md index 54139cd..d4ac97c 100644 --- a/cambios.md +++ b/cambios.md @@ -1,21 +1,18 @@ -# v3.5 +# v3.7 ## novedades ### adiciones -#### comandos nuevos: - -- repesperar: combinación de \$repetir y \$esperar - #### módulos nuevos: -- andamios: coloca bloques a tus pies a medida que caminas -- cocaína: hace que todo vaya más rápido o más lento +- trazos: dibuja líneas apuntando a entidades cercanas ### arreglos / mejoras -- opción para no romper el pico en selección de minado +- la config. ya funciona de nuevo +- la escucha de eventos ha sido arreglada, arreglando cosas como la ruedita del zoom y algunos comandos +- selección de minado ya no crashea al no usar pico ## problemas reconocidos diff --git a/gradle.properties b/gradle.properties index 849fc88..7d83cec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,6 @@ fabric_api_version=0.140.2+1.21.11 neutrino_version=1.1.0 -mod_version=3.6 +mod_version=3.7 maven_group=me.retucio archives_base_name=sputnik \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/Sputnik.java b/src/main/java/me/retucio/sputnik/Sputnik.java index 4ead360..6253f97 100644 --- a/src/main/java/me/retucio/sputnik/Sputnik.java +++ b/src/main/java/me/retucio/sputnik/Sputnik.java @@ -1,6 +1,7 @@ package me.retucio.sputnik; import com.github.retucio.neutrino.EventBus; +import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.cape.CapeManager; import me.retucio.sputnik.command.CommandManager; import me.retucio.sputnik.command.commands.BindCommand; @@ -235,6 +236,7 @@ public class Sputnik implements ClientModInitializer { || mc.currentScreen instanceof AbstractCommandBlockScreen; } + @EventListener // notificar al usuario de que hay una actualización disponible, si la hay public void onSetScreen(OpenScreenEvent event) { if (VersionChecker.shouldShowScreen && event.getScreen() instanceof TitleScreen) { @@ -244,6 +246,7 @@ public class Sputnik implements ClientModInitializer { } } + @EventListener public void onStop(ShutdownEvent event) { ConfigManager.save(); } diff --git a/src/main/java/me/retucio/sputnik/command/commands/EnderChestCommand.java b/src/main/java/me/retucio/sputnik/command/commands/EnderChestCommand.java index 8db9f7f..6b23fbc 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/EnderChestCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/EnderChestCommand.java @@ -1,5 +1,6 @@ package me.retucio.sputnik.command.commands; +import com.github.retucio.neutrino.EventListener; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; import me.retucio.sputnik.event.TickEvent; @@ -34,6 +35,7 @@ public class EnderChestCommand extends Command { }); } + @EventListener public void onTick(TickEvent.Post event) { if (shouldOpenEchest) { shouldOpenEchest = false; diff --git a/src/main/java/me/retucio/sputnik/command/commands/SpectateCommand.java b/src/main/java/me/retucio/sputnik/command/commands/SpectateCommand.java index 869b669..95e0884 100644 --- a/src/main/java/me/retucio/sputnik/command/commands/SpectateCommand.java +++ b/src/main/java/me/retucio/sputnik/command/commands/SpectateCommand.java @@ -1,5 +1,6 @@ package me.retucio.sputnik.command.commands; +import com.github.retucio.neutrino.EventListener; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.retucio.sputnik.command.Command; import me.retucio.sputnik.command.args.EntityArgumentType; @@ -37,6 +38,7 @@ public class SpectateCommand extends Command { ); } + @EventListener public void onKey(KeyEvent event) { if (mc.getCameraEntity() != mc.player && mc.currentScreen == null && event.getKey() == GLFW.GLFW_KEY_ESCAPE && event.getAction() != GLFW.GLFW_RELEASE ) { diff --git a/src/main/java/me/retucio/sputnik/config/ClientConfig.java b/src/main/java/me/retucio/sputnik/config/ClientConfig.java index 0c180db..ff638e4 100644 --- a/src/main/java/me/retucio/sputnik/config/ClientConfig.java +++ b/src/main/java/me/retucio/sputnik/config/ClientConfig.java @@ -1,5 +1,6 @@ package me.retucio.sputnik.config; +import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.sputnik.*; import me.retucio.sputnik.module.setting.settings.*; import me.retucio.sputnik.ui.screen.ClickGUI; @@ -43,11 +44,13 @@ public class ClientConfig { EVENT_BUS.subscribe(this); } + @EventListener public void onToggleModule(ToggleModuleEvent event) { ConfigManager.setModuleState(event.getModule()); } @SuppressWarnings("rawtypes") + @EventListener public void onUpdateSetting(UpdateSettingEvent event) { if (mc == null || !event.shouldSave()) return; @@ -68,20 +71,24 @@ public class ClientConfig { ConfigManager.setSetting(event.getSetting(), value); } + @EventListener public void onOpenSettingsFrame(SettingsFrameEvent.Open event) { ConfigManager.setFramePosition(event.getFrame()); } + @EventListener public void onCloseSettingsFrame(SettingsFrameEvent.Close event) { settingsFrames.remove(event.getFrame().getModule().getName()); ConfigManager.save(); } + @EventListener public void onMoveSettingsFrame(SettingsFrameEvent.Move event) { settingsFrames.replace(event.getFrame().getModule().getName(), new int[]{event.getFrame().getX(), event.getFrame().getY()}); ConfigManager.save(); } + @EventListener public void onExtendModuleFrame(ModuleFrameEvent.Extend event) { extendableFrames.put("M", new FrameData( ClickGUI.INSTANCE.getModulesFrame().getX(), @@ -89,6 +96,7 @@ public class ClientConfig { ClickGUI.INSTANCE.getModulesFrame().extended)); } + @EventListener public void onMoveModuleFrame(ModuleFrameEvent.Move event) { extendableFrames.replace("M", new FrameData( ClickGUI.INSTANCE.getModulesFrame().getX(), @@ -96,6 +104,7 @@ public class ClientConfig { ClickGUI.INSTANCE.getModulesFrame().extended)); } + @EventListener public void onExtendGUISettingsFrame(GUISettingsFrameEvent.Extend event) { extendableFrames.put("S", new FrameData( ClickGUI.INSTANCE.getGuiSettingsFrame().getX(), @@ -103,6 +112,7 @@ public class ClientConfig { ClickGUI.INSTANCE.getGuiSettingsFrame().extended)); } + @EventListener public void onMoveGUISettingsFrame(GUISettingsFrameEvent.Move event) { extendableFrames.replace("S", new FrameData( ClickGUI.INSTANCE.getGuiSettingsFrame().getX(), diff --git a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeInventoryScreenMixin.java b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeInventoryScreenMixin.java index d94426d..1ef52b5 100644 --- a/src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeInventoryScreenMixin.java +++ b/src/main/java/me/retucio/sputnik/mixin/mixins/screen/CreativeInventoryScreenMixin.java @@ -2,9 +2,9 @@ package me.retucio.sputnik.mixin.mixins.screen; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; -import me.retucio.sputnik.mixin.accessors.KeyBindingAccessor; import me.retucio.sputnik.module.ModuleManager; import me.retucio.sputnik.module.modules.inventory.CreativeInventoryHotbarKeybinds; +import me.retucio.sputnik.util.KeyUtil; import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; import net.minecraft.client.input.KeyInput; import org.spongepowered.asm.mixin.Mixin; @@ -20,9 +20,7 @@ public abstract class CreativeInventoryScreenMixin { @ModifyExpressionValue(method = "keyPressed", at = @At(value = "INVOKE", target = "Ljava/util/OptionalInt;isPresent()Z")) private boolean makeHotkeysWork(boolean original, @Local(argsOnly = true) KeyInput input) { if (ModuleManager.INSTANCE.getModuleByClass(CreativeInventoryHotbarKeybinds.class).isEnabled()) - return Arrays.stream(mc.options.hotbarKeys).anyMatch( - keyBinding -> ((KeyBindingAccessor) keyBinding).getBoundKey().getCode() == input.getKeycode() - ); + return Arrays.stream(mc.options.hotbarKeys).anyMatch(keyBinding -> KeyUtil.getKey(keyBinding) == input.getKeycode()); return original; } } diff --git a/src/main/java/me/retucio/sputnik/module/ModuleManager.java b/src/main/java/me/retucio/sputnik/module/ModuleManager.java index 70f9790..fbf5433 100644 --- a/src/main/java/me/retucio/sputnik/module/ModuleManager.java +++ b/src/main/java/me/retucio/sputnik/module/ModuleManager.java @@ -159,6 +159,7 @@ public class ModuleManager { add(new Nametags()); add(new NoRender()); add(new Particles()); + add(new Tracers()); } private void addWorld() { diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Autism.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Autism.java index d11cd35..06eea54 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Autism.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Autism.java @@ -8,6 +8,11 @@ import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; + +/** + * @author retucio + */ + public class Autism extends Module { private final NumberSetting interval = sgGeneral.add(new NumberSetting( diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Freecam.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Freecam.java index 05b69e6..4904126 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Freecam.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Freecam.java @@ -47,6 +47,8 @@ import org.lwjgl.glfw.GLFW; * @see KeyInputMixin * @see LivingEntityRendererMixin * @see WorldRendererMixin + * + * @author retucio */ public class Freecam extends Module { diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Freelook.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Freelook.java index f4077d3..e3d79cb 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Freelook.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Freelook.java @@ -14,6 +14,8 @@ import org.lwjgl.glfw.GLFW; /** continúa en: * @see CameraMixin * @see EntityMixin + * + * @author retucio */ public class Freelook extends Module { diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Fullbright.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Fullbright.java index 6cc4d00..abc1870 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Fullbright.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Fullbright.java @@ -15,13 +15,24 @@ import java.awt.*; /** continúa en: * @see LightmapTextureManagerMixin + * + * @author retucio */ public class Fullbright extends Module { - public final EnumSetting mode = sgGeneral.add(new EnumSetting<>("modo", "qué modo de iluminación emplear (usar poción con shaders)", Modes.class, Modes.GAMMA)); + public final EnumSetting mode = sgGeneral.add(new EnumSetting<>( + "modo", + "qué modo de iluminación emplear (usar poción con shaders)", + Modes.class, Modes.GAMMA + )); - public final ColorSetting color = sgGeneral.add(new ColorSetting("filtro", "filtro de color", new Color(255, 255, 255, 255), false)); + public final ColorSetting color = sgGeneral.add(new ColorSetting( + "filtro", + "filtro de color", + new Color(255, 255, 255, 255), + false + )).visibility(() -> mode.is(Modes.GAMMA)); public Fullbright() { super("brilli brilli", @@ -32,7 +43,6 @@ public class Fullbright extends Module { mode.onUpdate(mode -> { if (mode != Modes.POTION) disableNightVision(); }); mode.onUpdate(mode -> { boolean v = mode.equals(Modes.GAMMA); - color.setVisible(v); if (v) disableNightVision(); }); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/PerspectivePlus.java b/src/main/java/me/retucio/sputnik/module/modules/camera/PerspectivePlus.java index 3f3eb76..4bbd7be 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/PerspectivePlus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/PerspectivePlus.java @@ -11,7 +11,13 @@ import me.retucio.sputnik.module.setting.settings.KeySetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import org.lwjgl.glfw.GLFW; -// continúa en CameraMixin + +/** continúa en: + * @see me.retucio.sputnik.mixin.mixins.render.CameraMixin + * + * @author retucio + */ + public class PerspectivePlus extends Module { // ajustes diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Rotations.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Rotations.java index aa7a229..df96397 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Rotations.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Rotations.java @@ -8,6 +8,10 @@ import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +/** + * @author retucio + */ + public class Rotations extends Module { private final NumberSetting yaw = sgGeneral.add(new NumberSetting("guiñada", "eje vertical - giro horizontal (yaw)", 0, -180, 180, 1)); diff --git a/src/main/java/me/retucio/sputnik/module/modules/camera/Zoom.java b/src/main/java/me/retucio/sputnik/module/modules/camera/Zoom.java index 0c79b79..fb68bdf 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/camera/Zoom.java +++ b/src/main/java/me/retucio/sputnik/module/modules/camera/Zoom.java @@ -11,7 +11,13 @@ import me.retucio.sputnik.module.setting.settings.KeySetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import org.lwjgl.glfw.GLFW; -// continúa en GameRendererMixin + +/** continúa en: + * @see me.retucio.sputnik.mixin.mixins.render.GameRendererMixin + * + * @author retucio + */ + public class Zoom extends Module { private final SettingGroup sgVisual = addSg(new SettingGroup("visual", true)); @@ -87,6 +93,7 @@ public class Zoom extends Module { mc.options.getMouseSensitivity().setValue(prevMouseSens * mouseSensMultiplier.getValue()); } + @EventListener private void onMouseScroll(MouseScrollEvent event) { boolean key = scrollKey.getValue() == GLFW.GLFW_KEY_UNKNOWN || scrollKey.isDown(); if (isEnabled() && scrollSens.getValue() > 0 && key) { diff --git a/src/main/java/me/retucio/sputnik/module/modules/client/DiscordRPC.java b/src/main/java/me/retucio/sputnik/module/modules/client/DiscordRPC.java index 23f615a..bd4976e 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/client/DiscordRPC.java +++ b/src/main/java/me/retucio/sputnik/module/modules/client/DiscordRPC.java @@ -17,6 +17,10 @@ import me.retucio.sputnik.module.setting.settings.StringSetting; import me.retucio.sputnik.util.ChatUtil; +/** + * @author retucio + */ + public class DiscordRPC extends Module { private final SettingGroup sgImage = addSg(new SettingGroup("imágenes", false)); diff --git a/src/main/java/me/retucio/sputnik/module/modules/client/GUI.java b/src/main/java/me/retucio/sputnik/module/modules/client/GUI.java index a000e71..89edf8a 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/client/GUI.java +++ b/src/main/java/me/retucio/sputnik/module/modules/client/GUI.java @@ -21,7 +21,11 @@ import org.lwjgl.glfw.GLFW; import java.awt.*; -// módulo no visible solo para los ajustes de la interfaz (y del cliente en general) + +/** módulo no visible solo para los ajustes del mod + * @author retucio + */ + public class GUI extends Module { private final SettingGroup sgWidgets = addSg(new SettingGroup("widgets", true)); @@ -62,7 +66,7 @@ public class GUI extends Module { "distinguir mayúsculas", "la búsqueda es sensible a mayúsculas y minúsculas", false - )); + )).visibility(searchBar::getValue); // ^^^ no sé de qué sirve porque está todo en minúsculas pero bueno public final BooleanSetting blur = sgUi.add(new BooleanSetting( @@ -112,9 +116,9 @@ public class GUI extends Module { GLFW.GLFW_KEY_RIGHT_SHIFT); Sputnik.EVENT_BUS.subscribe(this); - keyMode.setVisible(false); - notify.setVisible(false); - searchBar.onUpdate(v -> matchCase.setVisible(v)); + + keyMode.visibility(false); + notify.visibility(false); } @EventListener diff --git a/src/main/java/me/retucio/sputnik/module/modules/client/HUD.java b/src/main/java/me/retucio/sputnik/module/modules/client/HUD.java index 0cac29b..a481231 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/client/HUD.java +++ b/src/main/java/me/retucio/sputnik/module/modules/client/HUD.java @@ -12,10 +12,13 @@ import org.lwjgl.glfw.GLFW; import java.awt.*; + /** lógica del HUD manejada en: * @see HudRenderer * @see HudElement * @see HudEditorScreen + * + * @author retucio */ public class HUD extends Module { @@ -30,11 +33,13 @@ public class HUD extends Module { "tecla asignada al editor de elementos del hud", GLFW.GLFW_KEY_PAGE_UP )); + public BooleanSetting axialMovement = sgEditor.add(new BooleanSetting( "movimiento axial", "te permite mover los elementos sobre los ejes más fácilmente", true )); + public NumberSetting axisOffset = sgEditor.add(new NumberSetting( "offset de los ejes", "offset a tener en cuenta al usar el movimiento axial", @@ -42,12 +47,14 @@ public class HUD extends Module { 0, 50, 1 - )); + )).visibility(axialMovement::getValue); + public BooleanSetting arrowMovement = sgEditor.add(new BooleanSetting( "movimiento con flechas", "te permite mover el elemento seleccionado con las teclas de las flechas", true )); + public NumberSetting arrowOffset = sgEditor.add(new NumberSetting( "cuánto mover con las flechas", "cuántos píxeles mover el elemento seleccionado al usar las flechas", @@ -55,7 +62,7 @@ public class HUD extends Module { 1, 20, 1 - )); + )).visibility(arrowMovement::getValue); // renderizado public ColorSetting color = sgDisplay.add(new ColorSetting( @@ -63,16 +70,19 @@ public class HUD extends Module { "color del texto de los elementos del HUD", new Color(255, 255, 255, 255), false) ); + public BooleanSetting shadow = sgDisplay.add(new BooleanSetting( "sombra", "texto con sombra", true )); + public BooleanSetting showOnF3 = sgDisplay.add(new BooleanSetting( "mostrar en F3", "renderizar HUD en el menú de debug", false )); + public BooleanSetting showOnChat = sgDisplay.add(new BooleanSetting( "mostrar en chat", "renderizar HUD en la pantalla del chat", @@ -88,24 +98,28 @@ public class HUD extends Module { 6, 1 )); + public EnumSetting timeFormat = sgElements.add(new EnumSetting<>( "formato de la hora", "12h o 24h", TimeFormat.class, TimeFormat.TWENTY_FOUR_HOUR )); + public StringSetting customText = sgElements.add(new StringSetting( "texto custom", "marca de agua (dejar vacío para quitar)", "adolf jitler inshtagram feishbuc twiter", 40 )); + public EnumSetting coordsMode = sgElements.add(new EnumSetting<>( "modo de coordenadas", "qué coordenadas mostrar", CoordsMode.class, CoordsMode.OVERWORLD )); + public EnumSetting dyno = sgElements.add(new EnumSetting<>( "dinosaurio", "qué dinosaurio mostrar", @@ -119,9 +133,6 @@ public class HUD extends Module { GLFW.GLFW_KEY_F12 ); - axialMovement.onUpdate(v -> axisOffset.setVisible(v)); - arrowMovement.onUpdate(v -> arrowOffset.setVisible(v)); - dyno.onUpdate(v -> { DynoElement element = (DynoElement) HudRenderer.getElement(DynoElement.class); if (element != null) element.reloadTexture(); diff --git a/src/main/java/me/retucio/sputnik/module/modules/combat/AttributeSwapper.java b/src/main/java/me/retucio/sputnik/module/modules/combat/AttributeSwapper.java index 96cb45f..6a7eb13 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/combat/AttributeSwapper.java +++ b/src/main/java/me/retucio/sputnik/module/modules/combat/AttributeSwapper.java @@ -7,11 +7,30 @@ import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; + +/** + * @author retucio + */ + public class AttributeSwapper extends Module { - private final NumberSetting slot = sgGeneral.add(new NumberSetting("slot", "slot al que cambiar", 1, 1, 9, 1)); - private final BooleanSetting swap = sgGeneral.add(new BooleanSetting("cambiar de vuelta", "volver al slot inicial tras haber aplicado el swapping", true)); - private final NumberSetting swapDelay = sgGeneral.add(new NumberSetting("delay de cambio de vuelta", "tiempo que se tarda en volver al slot inicial", 1, 1, 20, 1)); + private final NumberSetting slot = sgGeneral.add(new NumberSetting( + "slot", + "slot al que cambiar", + 1, 1, 9, 1 + )); + + private final BooleanSetting swap = sgGeneral.add(new BooleanSetting( + "cambiar de vuelta", + "volver al slot inicial tras haber aplicado el swapping", + true + )); + + private final NumberSetting swapDelay = sgGeneral.add(new NumberSetting( + "delay de cambio de vuelta", + "tiempo que se tarda en volver al slot inicial", + 1, 1, 20, 1 + )); private int delay = 0; private int prevSlot = -1; diff --git a/src/main/java/me/retucio/sputnik/module/modules/combat/MaceKill.java b/src/main/java/me/retucio/sputnik/module/modules/combat/MaceKill.java index 295d78c..6af0cf9 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/combat/MaceKill.java +++ b/src/main/java/me/retucio/sputnik/module/modules/combat/MaceKill.java @@ -17,7 +17,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -// https://github.com/etianl/Trouser-Streak/blob/ce27abd30435ca2b43a5e5546f5b070c07c6291a/src/main/java/pwn/noobs/trouserstreak/modules/MaceKill.java +/** + * @link créditos a etianl + * + * @"author" retucio + */ + public class MaceKill extends Module { private final BooleanSetting max = sgGeneral.add(new BooleanSetting( @@ -33,7 +38,7 @@ public class MaceKill extends Module { 1, 170, 1 - )); + )).visibility(() -> !max.getValue()); private final BooleanSetting preventDeath = sgGeneral.add(new BooleanSetting( "prevenir muerte", @@ -43,11 +48,10 @@ public class MaceKill extends Module { public MaceKill() { super("estampaescrotos", "estampa escrotos ajenos", Category.COMBAT); - max.onUpdate(v -> height.setVisible(!v)); } - @SuppressWarnings("ConstantConditions") @EventListener + @SuppressWarnings("ConstantConditions") private void onPacketSend(PacketEvent.Send event) { if (mc.player == null) return; if (mc.player.getMainHandStack().getItem() == Items.MACE diff --git a/src/main/java/me/retucio/sputnik/module/modules/combat/ProjectileTrajectories.java b/src/main/java/me/retucio/sputnik/module/modules/combat/ProjectileTrajectories.java index d98e23c..f01c46e 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/combat/ProjectileTrajectories.java +++ b/src/main/java/me/retucio/sputnik/module/modules/combat/ProjectileTrajectories.java @@ -35,7 +35,12 @@ import java.util.List; import java.util.Optional; -// https://github.com/maDU59/ProjectilesTrajectoryPreview +/** + * @link créditos a maDU59 + * + * @"author" retucio + */ + public class ProjectileTrajectories extends Module { private final SettingGroup sgTrajectory = addSg(new SettingGroup("trayectoria", true)); @@ -114,10 +119,10 @@ public class ProjectileTrajectories extends Module { public ProjectileTrajectories() { super("trayectoria", "muestra la trayectoria de los proyectiles", Category.COMBAT); - fillingTargets.onUpdate(v -> fillingColor.setVisible(v != TrajectoryTargets.NONE)); + fillingTargets.onUpdate(v -> fillingColor.visibility(v != TrajectoryTargets.NONE)); outlineTargets.onUpdate(v -> { - outlineColor.setVisible(v != TrajectoryTargets.NONE); - outlineWidth.setVisible(v != TrajectoryTargets.NONE); + outlineColor.visibility(v != TrajectoryTargets.NONE); + outlineWidth.visibility(v != TrajectoryTargets.NONE); }); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/combat/SpearKill.java b/src/main/java/me/retucio/sputnik/module/modules/combat/SpearKill.java index 65d81c8..47d7b5b 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/combat/SpearKill.java +++ b/src/main/java/me/retucio/sputnik/module/modules/combat/SpearKill.java @@ -15,7 +15,13 @@ import net.minecraft.world.RaycastContext; import java.util.Comparator; import java.util.List; -// https://github.com/etianl/spearHax/blob/main/src/main/java/things/haxHandler.java + +/** + * @link créditos a etianl + * + * @"author" retucio + */ + public class SpearKill extends Module { private final BooleanSetting onlyPlayers = sgGeneral.add(new BooleanSetting( diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/CreativeInventoryHotbarKeybinds.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/CreativeInventoryHotbarKeybinds.java index f3fffef..723e000 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/CreativeInventoryHotbarKeybinds.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/CreativeInventoryHotbarKeybinds.java @@ -5,10 +5,12 @@ import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; -/** - * continúa en +/** continúa en * @see CreativeInventoryScreenMixin + * + * @author retucio */ + public class CreativeInventoryHotbarKeybinds extends Module { public CreativeInventoryHotbarKeybinds() { diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/InventoryPlus.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/InventoryPlus.java index db241e1..f4ba6ea 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/InventoryPlus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/InventoryPlus.java @@ -14,6 +14,10 @@ import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.screen.slot.Slot; import org.lwjgl.glfw.GLFW; +/** + * @author retucio + */ + public class InventoryPlus extends Module { private final KeySetting row1key = sgGeneral.add(new KeySetting("fila 1", "tecla para mover items a la primera fila", GLFW.GLFW_KEY_A)); diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/Offhand.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/Offhand.java index c3ef884..52acbc6 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/Offhand.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/Offhand.java @@ -14,6 +14,10 @@ import net.minecraft.screen.slot.SlotActionType; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +/** + * @author retucio + */ + public class Offhand extends Module { private final OptionSetting item = sgGeneral.add(new OptionSetting<>( diff --git a/src/main/java/me/retucio/sputnik/module/modules/inventory/UIMove.java b/src/main/java/me/retucio/sputnik/module/modules/inventory/UIMove.java index b046dee..a7d041e 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/inventory/UIMove.java +++ b/src/main/java/me/retucio/sputnik/module/modules/inventory/UIMove.java @@ -1,6 +1,5 @@ package me.retucio.sputnik.module.modules.inventory; -import me.retucio.sputnik.mixin.accessors.KeyBindingAccessor; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.ListSetting; @@ -78,8 +77,7 @@ public class UIMove extends Module { if (handler == null || !screens.isEnabled(handler)) return; for (KeyBinding kb : movementKeys) { - kb.setPressed(KeyUtil.isKeyDown(( - (KeyBindingAccessor) kb).getBoundKey().getCode())); + kb.setPressed(KeyUtil.isKeyDown(KeyUtil.getKey(kb))); } } diff --git a/src/main/java/me/retucio/sputnik/module/modules/misc/ChatPlus.java b/src/main/java/me/retucio/sputnik/module/modules/misc/ChatPlus.java index a921945..715104e 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/misc/ChatPlus.java +++ b/src/main/java/me/retucio/sputnik/module/modules/misc/ChatPlus.java @@ -67,7 +67,7 @@ public class ChatPlus extends Module { Category.MISC); updateDateFormat(); updateClientName(); - timestamps.onUpdate(v -> timestampSecs.setVisible(v)); + timestamps.onUpdate(v -> timestampSecs.visibility(v)); timestampSecs.onUpdate(x -> updateDateFormat()); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/movement/Scaffold.java b/src/main/java/me/retucio/sputnik/module/modules/movement/Scaffold.java index 5d0dd06..a58a283 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/movement/Scaffold.java +++ b/src/main/java/me/retucio/sputnik/module/modules/movement/Scaffold.java @@ -172,19 +172,19 @@ public class Scaffold extends Module { public Scaffold() { super("andamios", "pone bloques bajo tus pies de manera automática", Category.MOVEMENT); - extend.onUpdate(extendDistance::setVisible); + extend.onUpdate(extendDistance::visibility); tower.onUpdate(v -> { - towerSpeed.setVisible(v); - towerWhileMoving.setVisible(v); + towerSpeed.visibility(v); + towerWhileMoving.visibility(v); }); outlines.onUpdate(v -> { - outlineColor.setVisible(v); - lineWidth.setVisible(v); + outlineColor.visibility(v); + lineWidth.visibility(v); }); - fillings.onUpdate(fillingColor::setVisible); + fillings.onUpdate(fillingColor::visibility); } @@ -330,7 +330,7 @@ public class Scaffold extends Module { public enum ListMode { WHITELIST("lista blanca (incluir)"), - BLACKLIST("lista negra (excluir"); + BLACKLIST("lista negra (excluir)"); private final String name; ListMode(String name) { this.name = name; } diff --git a/src/main/java/me/retucio/sputnik/module/modules/network/LogoutSpots.java b/src/main/java/me/retucio/sputnik/module/modules/network/LogoutSpots.java index d51eafc..4130a6c 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/network/LogoutSpots.java +++ b/src/main/java/me/retucio/sputnik/module/modules/network/LogoutSpots.java @@ -60,13 +60,13 @@ public class LogoutSpots extends Module { Category.NETWORK); outlines.onUpdate(v -> { - outlineColor.setVisible(v); - fullHeight.setVisible(v || filling.getValue()); + outlineColor.visibility(v); + fullHeight.visibility(v || filling.getValue()); }); filling.onUpdate(v -> { - fillingColor.setVisible(v); - fullHeight.setVisible(v || outlines.getValue()); + fillingColor.visibility(v); + fullHeight.visibility(v || outlines.getValue()); }); dummy.onUpdate(v -> { diff --git a/src/main/java/me/retucio/sputnik/module/modules/network/PacketMine.java b/src/main/java/me/retucio/sputnik/module/modules/network/PacketMine.java index c7a2ca0..3e3f202 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/network/PacketMine.java +++ b/src/main/java/me/retucio/sputnik/module/modules/network/PacketMine.java @@ -1,6 +1,7 @@ package me.retucio.sputnik.module.modules.network; import com.github.retucio.neutrino.EventListener; +import it.unimi.dsi.fastutil.booleans.BooleanSet; import me.retucio.sputnik.event.interact.AttackBlockEvent; import me.retucio.sputnik.event.render.Render3DEvent; import me.retucio.sputnik.module.Category; @@ -11,10 +12,16 @@ import me.retucio.sputnik.module.setting.settings.ColorSetting; import me.retucio.sputnik.module.setting.settings.EnumSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.ChatUtil; +import me.retucio.sputnik.util.EntityUtil; +import me.retucio.sputnik.util.MiscUtil; import me.retucio.sputnik.util.render.RenderUtil; +import net.minecraft.command.argument.EntityAnchorArgumentType; +import net.minecraft.item.ItemStack; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; import java.awt.*; @@ -66,6 +73,12 @@ public class PacketMine extends Module { false )); + private final EnumSetting rotate = sgGeneral.add(new EnumSetting<>( + "rotar", + "rotar al minar bloques mediante el módulo", + RotateMode.class, RotateMode.NONE + )); + private final BooleanSetting render = sgRender.add(new BooleanSetting( "renderizar", "renderizar un contorno alrededor de los bloques que están siendo minados", @@ -89,7 +102,7 @@ public class PacketMine extends Module { )); private final BooleanSetting dontBreak = sgGeneral.add(new BooleanSetting( - "no romper", + "no romper pico", "evita romper el pico", true )); @@ -100,8 +113,8 @@ public class PacketMine extends Module { Category.NETWORK); render.onUpdate(v -> { - color.setVisible(v); - lineWidth.setVisible(v); + color.visibility(v); + lineWidth.visibility(v); }); } @@ -139,9 +152,7 @@ public class PacketMine extends Module { if (clickAction.is(ClickAction.ADD_PRIORITY)) { miningBlocks.sort(Comparator.comparingInt(block -> -block.clicks)); for (MiningBlock block : miningBlocks) { - if (processBlock(block)) { - break; - } + processBlock(block); } } else { if (inOrder.getValue()) { @@ -260,12 +271,16 @@ public class PacketMine extends Module { return false; } - if (dontBreak.getValue() && mc.player.getMainHandStack().getMaxDamage() - mc.player.getMainHandStack().getDamage() <= 1) { + if (dontBreak.getValue() + && mc.player.isHolding(ItemStack::isDamageable) + && mc.player.getMainHandStack().getMaxDamage() - mc.player.getMainHandStack().getDamage() <= 1) { ChatUtil.warn("pico por romperse"); toggle(); return false; } + rotate(); + mc.interactionManager.sendSequencedPacket(mc.world, sequence -> new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, dir, sequence)); mining = true; @@ -289,6 +304,15 @@ public class PacketMine extends Module { ); } + private void rotate() { + Vec3d pos = Vec3d.of(this.pos); + switch (rotate.getValue()) { + case CLIENT -> EntityUtil.lookAtClient(pos); + case SERVER -> EntityUtil.lookAtServer(pos); + case BOTH -> EntityUtil.lookAt(pos); + } + } + public boolean shouldRetry() { return mining && (System.currentTimeMillis() - startTime >= retryTime.getValue()); } @@ -303,4 +327,15 @@ public class PacketMine extends Module { ClickAction(String name) { this.name = name; } @Override public String toString() { return name; } } + + private enum RotateMode { + CLIENT("cámara"), + SERVER("mediante paquetes"), + BOTH("ambos"), + NONE("no"); + + private final String name; + RotateMode(String name) { this.name = name; } + @Override public String toString() { return name; } + } } \ No newline at end of file diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/AutoFish.java b/src/main/java/me/retucio/sputnik/module/modules/player/AutoFish.java index 240d8c0..70ef0e3 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/AutoFish.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/AutoFish.java @@ -67,12 +67,12 @@ public class AutoFish extends Module { public AutoFish() { super("auto pesca", "pesca por ti", Category.PLAYER); autoRecast.onUpdate(v -> { - recastDelay.setVisible(v); - onlyRecastIfLookingAtWater.setVisible(v); - recastRaycastDistance.setVisible(v); + recastDelay.visibility(v); + onlyRecastIfLookingAtWater.visibility(v); + recastRaycastDistance.visibility(v); }); - onlyRecastIfLookingAtWater.onUpdate(v -> recastRaycastDistance.setVisible(v)); + onlyRecastIfLookingAtWater.onUpdate(v -> recastRaycastDistance.visibility(v)); } @Override diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/FastUse.java b/src/main/java/me/retucio/sputnik/module/modules/player/FastUse.java index 4556524..8fce3a1 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/FastUse.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/FastUse.java @@ -61,8 +61,8 @@ public class FastUse extends Module { Category.PLAYER, GLFW.GLFW_KEY_F6); - items.onUpdate(v -> itemCooldown.setVisible(v)); - blocks.onUpdate(v -> blockCooldown.setVisible(v)); + items.onUpdate(v -> itemCooldown.visibility(v)); + blocks.onUpdate(v -> blockCooldown.visibility(v)); } public int getCooldown(ItemStack stack) { diff --git a/src/main/java/me/retucio/sputnik/module/modules/player/WarnLowDurability.java b/src/main/java/me/retucio/sputnik/module/modules/player/WarnLowDurability.java index c66dc0e..15a13c8 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/player/WarnLowDurability.java +++ b/src/main/java/me/retucio/sputnik/module/modules/player/WarnLowDurability.java @@ -45,9 +45,9 @@ public class WarnLowDurability extends Module { Category.PLAYER); playSound.onUpdate(v -> { - sound.setVisible(v); - volume.setVisible(v); - pitch.setVisible(v); + sound.visibility(v); + volume.visibility(v); + pitch.visibility(v); }); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/BlockESP.java b/src/main/java/me/retucio/sputnik/module/modules/render/BlockESP.java index 96f8e9f..119e43a 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/BlockESP.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/BlockESP.java @@ -111,12 +111,12 @@ public class BlockESP extends Module { ); outlines.onUpdate(v -> { - outlineColor.setVisible(v); - lineWidth.setVisible(v); + outlineColor.visibility(v); + lineWidth.visibility(v); }); fillings.onUpdate(v -> - fillingColor.setVisible(v) + fillingColor.visibility(v) ); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/EntityESP.java b/src/main/java/me/retucio/sputnik/module/modules/render/EntityESP.java index 03d2a35..a95a36e 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/EntityESP.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/EntityESP.java @@ -71,15 +71,15 @@ public class EntityESP extends Module { public EntityESP() { super("resaltado de entidades", "resalta el contorno de las entidades seleccionadas a través de bloques", Category.RENDER); mode.onUpdate(v -> { - glowColor.setVisible(v == ESPMode.GLOW); - outlines.setVisible(v == ESPMode.BOX); - filling.setVisible(v == ESPMode.BOX); - outlineColor.setVisible(outlines.isVisible()); - fillingColor.setVisible(filling.isVisible()); + glowColor.visibility(v == ESPMode.GLOW); + outlines.visibility(v == ESPMode.BOX); + filling.visibility(v == ESPMode.BOX); + outlineColor.visibility(outlines.isVisible()); + fillingColor.visibility(filling.isVisible()); }); - outlines.onUpdate(v -> outlineColor.setVisible(v)); - filling.onUpdate(v -> fillingColor.setVisible(v)); + outlines.onUpdate(v -> outlineColor.visibility(v)); + filling.onUpdate(v -> fillingColor.visibility(v)); } @EventListener diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/Nametags.java b/src/main/java/me/retucio/sputnik/module/modules/render/Nametags.java index a8e925b..fcc7442 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/render/Nametags.java +++ b/src/main/java/me/retucio/sputnik/module/modules/render/Nametags.java @@ -82,17 +82,17 @@ public class Nametags extends Module { defaultEntities.replace(EntityType.TNT, true); entities.setDefaultValue(defaultEntities); - health.onUpdate(v -> healthMode.setVisible(v)); + health.onUpdate(v -> healthMode.visibility(v)); entities.onUpdate(entities -> { - items.setVisible(entities.get(EntityType.ITEM)); + items.visibility(entities.get(EntityType.ITEM)); boolean anyProjectile = entities.get(EntityType.TRIDENT) || entities.get(EntityType.ARROW) || entities.get(EntityType.SPECTRAL_ARROW); - showProjectileDamage.setVisible(anyProjectile); + showProjectileDamage.visibility(anyProjectile); - tntPrime.setVisible(entities.get(EntityType.TNT)); + tntPrime.visibility(entities.get(EntityType.TNT)); }); } diff --git a/src/main/java/me/retucio/sputnik/module/modules/render/Tracers.java b/src/main/java/me/retucio/sputnik/module/modules/render/Tracers.java new file mode 100644 index 0000000..68d8649 --- /dev/null +++ b/src/main/java/me/retucio/sputnik/module/modules/render/Tracers.java @@ -0,0 +1,119 @@ +package me.retucio.sputnik.module.modules.render; + +import com.github.retucio.neutrino.EventListener; +import com.ibm.icu.impl.TimeZoneGenericNames; +import me.retucio.sputnik.event.render.Render3DEvent; +import me.retucio.sputnik.module.Category; +import me.retucio.sputnik.module.Module; +import me.retucio.sputnik.module.setting.SettingGroup; +import me.retucio.sputnik.module.setting.settings.BooleanSetting; +import me.retucio.sputnik.module.setting.settings.ColorSetting; +import me.retucio.sputnik.module.setting.settings.ListSetting; +import me.retucio.sputnik.module.setting.settings.NumberSetting; +import me.retucio.sputnik.util.Colors; +import me.retucio.sputnik.util.Lists; +import me.retucio.sputnik.util.render.RenderUtil; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; + +import java.awt.*; +import java.util.Map; + +public class Tracers extends Module { + + private final SettingGroup sgColors = addSg(new SettingGroup("colores", false)); + + private final Map, Boolean> defaultEntities = Lists.allFalse(Lists.entityList); + private final ListSetting> entities = sgGeneral.add(new ListSetting<>( + "entidades", + "entidades a las que apuntar", + Lists.entityList, + defaultEntities, + Lists.entityNames + )); + + private final NumberSetting lineWidth = sgGeneral.add(new NumberSetting( + "grosor de línea", + "grosor de las líneas", + 1.5, + 0.1, + 10, + 0.2 + )); + + private final BooleanSetting self = sgGeneral.add(new BooleanSetting( + "uno mismo", + "apuntarse a uno mismo en cámara libre o así", + true + )); + + private final ColorSetting playerColor= sgColors.add(new ColorSetting( + "jugadores", + "color para jugadores", + Colors.RED, false + )); + + private final ColorSetting animalsColor = sgColors.add(new ColorSetting( + "animales", + "color para animales pasivos", + Colors.YELLOW, false + )); + + private final ColorSetting monstersColor = sgColors.add(new ColorSetting( + "monstruos", + "color para monstruos", + Colors.BROWN, false + )); + + private final ColorSetting ambientColor = sgColors.add(new ColorSetting( + "ambiente", + "color para entidades ambiente", + Colors.SILVER, false + )); + + private final ColorSetting waterColor = sgColors.add(new ColorSetting( + "agua", + "color para bichos del agua", + Colors.BLUE, false + )); + + private final ColorSetting miscColor = sgColors.add(new ColorSetting( + "misc.", + "color para entidades misceláneas", + Colors.BROWN, false + )); + + public Tracers() { + super("trazos", "trazar líneas de la cámara a las entidades seleccionadas", Category.RENDER); + defaultEntities.replace(EntityType.PLAYER, true); + entities.setDefaultValue(defaultEntities); + } + + @EventListener + private void onRenderWorld(Render3DEvent event) { + for (Entity entity : mc.world.getEntities()) { + Color color = getColor(entity); + if (color == null) continue; + Vec3d interpolatedPos = entity.getLerpedPos(event.getTickDelta()); + RenderUtil.drawTracer(event.getMatrices(), interpolatedPos, color, lineWidth.getFloatValue()); + } + } + + private Color getColor(Entity entity) { + if (!entities.isEnabled(entity.getType())) return null; + if (!self.getValue() && mc.player == entity) return null; + if (entity instanceof PlayerEntity) return playerColor.getValue(); + + return switch (entity.getType().getSpawnGroup()) { + case CREATURE -> animalsColor.getValue().getAlpha() > 0 ? animalsColor.getValue() : null; + case MONSTER -> monstersColor.getValue().getAlpha() > 0 ? monstersColor.getValue() : null; + case AMBIENT, WATER_AMBIENT -> ambientColor.getValue().getAlpha() > 0 ? ambientColor.getValue() : null; + case WATER_CREATURE, UNDERGROUND_WATER_CREATURE -> waterColor.getValue().getAlpha() > 0 ? waterColor.getValue() : null; + case MISC -> miscColor.getValue().getAlpha() > 0 ? miscColor.getValue() : null; + default -> null; + }; + } +} diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/AutoTool.java b/src/main/java/me/retucio/sputnik/module/modules/world/AutoTool.java index b736aaa..7bd0b04 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/AutoTool.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/AutoTool.java @@ -3,12 +3,12 @@ package me.retucio.sputnik.module.modules.world; import com.github.retucio.neutrino.EventListener; import me.retucio.sputnik.event.input.KeyEvent; import me.retucio.sputnik.event.input.MouseClickEvent; -import me.retucio.sputnik.mixin.accessors.KeyBindingAccessor; import me.retucio.sputnik.module.Category; import me.retucio.sputnik.module.Module; import me.retucio.sputnik.module.setting.settings.BooleanSetting; import me.retucio.sputnik.module.setting.settings.NumberSetting; import me.retucio.sputnik.util.InventoryUtil; +import me.retucio.sputnik.util.KeyUtil; import me.retucio.sputnik.util.MiscUtil; import net.minecraft.block.BlockState; @@ -59,7 +59,7 @@ public class AutoTool extends Module { public AutoTool() { super("auto herramienta", "cambia a la herramienta adecuada automáticamente", Category.WORLD); - switchBack.onUpdate(v -> switchBackDelaySetting.setVisible(v)); + switchBack.onUpdate(v -> switchBackDelaySetting.visibility(v)); } @Override @@ -117,7 +117,7 @@ public class AutoTool extends Module { private void handle(int key, int action) { if (mc.player == null || mc.player.getInventory() == null) return; - if (key != ((KeyBindingAccessor) mc.options.attackKey).getBoundKey().getCode()) return; + if (key != KeyUtil.getKey(mc.options.attackKey)) return; if (action == GLFW.GLFW_PRESS) { onStartMining(); diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/LightOverlay.java b/src/main/java/me/retucio/sputnik/module/modules/world/LightOverlay.java index 89730cd..29c2c0a 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/LightOverlay.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/LightOverlay.java @@ -97,7 +97,7 @@ public class LightOverlay extends Module { "te muestra el nivel de luz en bloques, para prevenir mob spawns", Category.WORLD); - onWater.onUpdate(v -> dontCullWater.setVisible(v)); + onWater.onUpdate(v -> dontCullWater.visibility(v)); } @Override diff --git a/src/main/java/me/retucio/sputnik/module/modules/world/TimeChanger.java b/src/main/java/me/retucio/sputnik/module/modules/world/TimeChanger.java index 9117395..e9c2fbb 100644 --- a/src/main/java/me/retucio/sputnik/module/modules/world/TimeChanger.java +++ b/src/main/java/me/retucio/sputnik/module/modules/world/TimeChanger.java @@ -35,7 +35,7 @@ public class TimeChanger extends Module { "te deja cambiar visualmente el progreso del día, entre otras cosas", Category.WORLD); - renderMoon.onUpdate(v -> moonPhase.setVisible(v)); + renderMoon.onUpdate(v -> moonPhase.visibility(v)); } private long realTime; diff --git a/src/main/java/me/retucio/sputnik/module/setting/Setting.java b/src/main/java/me/retucio/sputnik/module/setting/Setting.java index f4d829f..5bbb990 100644 --- a/src/main/java/me/retucio/sputnik/module/setting/Setting.java +++ b/src/main/java/me/retucio/sputnik/module/setting/Setting.java @@ -4,6 +4,7 @@ import me.retucio.sputnik.Sputnik; import me.retucio.sputnik.event.sputnik.UpdateSettingEvent; import me.retucio.sputnik.module.Module; +import java.util.function.BooleanSupplier; import java.util.function.Consumer; // base para los tipos de ajustes @@ -17,6 +18,7 @@ public abstract class Setting { protected Consumer updateListener; + protected BooleanSupplier visibilityCondition = null; protected boolean visible = true; protected boolean searchMatch = true; @@ -30,11 +32,21 @@ public abstract class Setting { } public boolean isVisible() { + if (visibilityCondition != null) { + return visibilityCondition.getAsBoolean(); + } return visible; } - public void setVisible(boolean visible) { + public void visibility(boolean visible) { this.visible = visible; + this.visibilityCondition = null; + } + + @SuppressWarnings("unchecked") + public > S visibility(BooleanSupplier condition) { + this.visibilityCondition = condition; + return (S) this; } public boolean isSearchMatch() { diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ChooseButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ChooseButton.java index 5df3424..dcf9b1b 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ChooseButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ChooseButton.java @@ -32,9 +32,9 @@ public class ChooseButton extends SettingButton> { }; // ocultar cosas innecesarias - dummy.getSettings().get(0).setVisible(false); - dummy.getSettings().get(1).setVisible(false); - dummy.getSettings().get(2).setVisible(false); + dummy.getSettings().get(0).visibility(false); + dummy.getSettings().get(1).visibility(false); + dummy.getSettings().get(2).visibility(false); dummy.shouldSaveSettings(false); } diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ListButton.java b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ListButton.java index c693446..8145232 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ListButton.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/buttons/settings/ListButton.java @@ -33,9 +33,9 @@ public class ListButton extends SettingButton> { }; // ocultar cosas innecesarias - dummy.getSettings().get(0).setVisible(false); - dummy.getSettings().get(1).setVisible(false); - dummy.getSettings().get(2).setVisible(false); + dummy.getSettings().get(0).visibility(false); + dummy.getSettings().get(1).visibility(false); + dummy.getSettings().get(2).visibility(false); dummy.shouldSaveSettings(false); } diff --git a/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ColorPickerFrame.java b/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ColorPickerFrame.java index 5663c5b..52a9e72 100644 --- a/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ColorPickerFrame.java +++ b/src/main/java/me/retucio/sputnik/ui/widgets/frames/settings/ColorPickerFrame.java @@ -53,7 +53,7 @@ public class ColorPickerFrame extends SettingsFrame { }; // ocultar ajustes innecesarios - dummyModule.getSettings().forEach(s -> s.setVisible(false)); + dummyModule.getSettings().forEach(s -> s.visibility(false)); dummyModule.shouldSaveSettings(false); // ajustes de color @@ -80,12 +80,12 @@ public class ColorPickerFrame extends SettingsFrame { setting.onUpdate(v -> updateColorFromSettings()); rainbowSetting.onUpdate(v -> { updateColorFromSettings(); - redSetting.setVisible(!v); - greenSetting.setVisible(!v); - blueSetting.setVisible(!v); - rainbowSpeedSetting.setVisible(v); - saturationSetting.setVisible(v); - brightnessSetting.setVisible(v); + redSetting.visibility(!v); + greenSetting.visibility(!v); + blueSetting.visibility(!v); + rainbowSpeedSetting.visibility(v); + saturationSetting.visibility(v); + brightnessSetting.visibility(v); }); } diff --git a/src/main/java/me/retucio/sputnik/util/EntityUtil.java b/src/main/java/me/retucio/sputnik/util/EntityUtil.java index f32f5de..d777861 100644 --- a/src/main/java/me/retucio/sputnik/util/EntityUtil.java +++ b/src/main/java/me/retucio/sputnik/util/EntityUtil.java @@ -2,6 +2,7 @@ package me.retucio.sputnik.util; import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.ProjectileUtil; +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.Box; @@ -95,7 +96,26 @@ public class EntityUtil { return mc.player.getPitch() + MathHelper.wrapDegrees((float) -Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.getPitch()); } - public static enum Target { + public static void lookAt(Vec3d pos) { + lookAtClient(pos); + lookAtServer(pos); + } + + public static void lookAtClient(Vec3d pos) { + mc.player.setYaw((float) getYaw(pos)); + mc.player.setPitch((float) getPitch(pos)); + } + + public static void lookAtServer(Vec3d pos) { + mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround( + (float) getYaw(pos), + (float) getPitch(pos), + mc.player.isOnGround(), + mc.player.horizontalCollision + )); + } + + public enum Target { HEAD, BODY, FEET; diff --git a/src/main/java/me/retucio/sputnik/util/InventoryUtil.java b/src/main/java/me/retucio/sputnik/util/InventoryUtil.java index b2ebfc9..740a40c 100644 --- a/src/main/java/me/retucio/sputnik/util/InventoryUtil.java +++ b/src/main/java/me/retucio/sputnik/util/InventoryUtil.java @@ -2,7 +2,6 @@ package me.retucio.sputnik.util; import me.retucio.sputnik.event.network.DisconnectEvent; import me.retucio.sputnik.event.interact.OpenScreenEvent; -import me.retucio.sputnik.mixin.accessors.KeyBindingAccessor; import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.component.ComponentType; @@ -325,8 +324,11 @@ public class InventoryUtil { } public static int getSlotNumberFromKey(int key) { - for (int i = 0; i < 9; i++) - if (((KeyBindingAccessor) (mc.options.hotbarKeys[i])).getBoundKey().getCode() == key) return i; + for (int i = 0; i < 9; i++) { + if (KeyUtil.getKey(mc.options.hotbarKeys[i]) == key) { + return i; + } + } return -1; } diff --git a/src/main/java/me/retucio/sputnik/util/KeyUtil.java b/src/main/java/me/retucio/sputnik/util/KeyUtil.java index 76f2024..00da155 100644 --- a/src/main/java/me/retucio/sputnik/util/KeyUtil.java +++ b/src/main/java/me/retucio/sputnik/util/KeyUtil.java @@ -5,7 +5,6 @@ import net.minecraft.client.input.KeyInput; import net.minecraft.client.option.KeyBinding; import org.lwjgl.glfw.GLFW; -import java.util.List; import java.awt.*; import java.awt.event.KeyEvent; import java.awt.im.InputContext; @@ -20,24 +19,24 @@ public class KeyUtil { return GLFW.glfwGetKey(mc.getWindow().getHandle(), key); } + public static boolean isKeyDown(KeyBinding key) { + return isKeyDown(getKey(key)); + } + public static boolean isKeyDown(int key) { return GLFW.glfwGetKey( mc.getWindow().getHandle(), key) != GLFW.GLFW_RELEASE; } - public static boolean isKeyDown(KeyBinding key) { - return GLFW.glfwGetKey( - mc.getWindow().getHandle(), - ((KeyBindingAccessor) key).getBoundKey().getCode() - ) != GLFW.GLFW_RELEASE; - } - public static boolean isShiftDown() { return isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT) || isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT); } + public static int getKey(KeyBinding kb) { + return ((KeyBindingAccessor) kb).getBoundKey().getCode(); + } public static boolean isCapsLockOn() throws HeadlessException { return Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); diff --git a/src/main/java/me/retucio/sputnik/util/render/RenderUtil.java b/src/main/java/me/retucio/sputnik/util/render/RenderUtil.java index 17f9b9d..ea43fa3 100644 --- a/src/main/java/me/retucio/sputnik/util/render/RenderUtil.java +++ b/src/main/java/me/retucio/sputnik/util/render/RenderUtil.java @@ -14,69 +14,34 @@ import java.awt.*; public class RenderUtil { private static final MinecraftClient mc = MinecraftClient.getInstance(); - private static final Tessellator tesselator = Tessellator.getInstance(); + private static final Tessellator tessellator = Tessellator.getInstance(); - // líneas + /* líneas */ - public static void drawLine(MatrixStack matrices, Vec3d start, Vec3d end, Color color, float lineWidth) { - Camera camera = mc.gameRenderer.getCamera(); - Vec3d cameraPos = camera.getCameraPos(); + // https://github.com/TheF1xer/GateClient-1.12.2/blob/main/src/main/java/me/thef1xer/gateclient/util/RenderUtil.java + public static void drawTracer(MatrixStack matrices, Vec3d pos, Color color, float lineWidth) { + BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); + Camera cam = mc.gameRenderer.getCamera(); - float startX = (float) (start.x - cameraPos.x); - float startY = (float) (start.y - cameraPos.y); - float startZ = (float) (start.z - cameraPos.z); - float endX = (float) (end.x - cameraPos.x); - float endY = (float) (end.y - cameraPos.y); - float endZ = (float) (end.z - cameraPos.z); - - BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); - - float nx = -1.0f, ny = -1f, nz = -1.0f; - - buffer.vertex(matrices.peek().getPositionMatrix(), startX, startY, startZ) - .color(color.getRGB()) - .normal(nx, ny, nz) - .lineWidth(lineWidth); - buffer.vertex(matrices.peek().getPositionMatrix(), endX, endY, endZ) - .color(color.getRGB()) - .normal(nx, ny, nz) - .lineWidth(lineWidth); - - Layers.lines().draw(buffer.end()); - } - - public static void drawLine2D(MatrixStack matrices, float x1, float y1, float x2, float y2, Color color, float lineWidth) { - float r = color.getRed() / 255f; - float g = color.getGreen() / 255f; - float b = color.getBlue() / 255f; - float a = color.getAlpha() / 255f; - - BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); - float nx = 0, ny = 0, nz = 1; // normals not used - - buffer.vertex(matrices.peek().getPositionMatrix(), x1, y1, 0) - .color(r, g, b, a) - .normal(nx, ny, nz) - .lineWidth(lineWidth); - buffer.vertex(matrices.peek().getPositionMatrix(), x2, y2, 0) - .color(r, g, b, a) - .normal(nx, ny, nz) - .lineWidth(lineWidth); + Vector3f cameraVector = new Vector3f(0, 0, 1) + .rotateX((float) Math.toRadians(cam.getPitch())) + .rotateY((float) -Math.toRadians(cam.getYaw())); + buffer.vertex(matrices.peek(), cameraVector.x, cameraVector.y, cameraVector.z).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); + buffer.vertex(matrices.peek(), (float) (pos.x - cam.getCameraPos().x), (float) (pos.y - cam.getCameraPos().y), (float) (pos.z - cam.getCameraPos().z)).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); Layers.lines().draw(buffer.end()); } public static void drawVector(MatrixStack matrices, Vector3f start, Vec3d direction, Color c, float lineWidth) { - BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); - + BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); MatrixStack.Entry pose = matrices.peek(); int color = c.getRGB(); - float r = ((color >> 16) & 0xFF) / 255f; - float g = ((color >> 8) & 0xFF) / 255f; - float b = (color & 0xFF) / 255f; float a = ((color >> 24) & 0xFF) / 255f; + float r = ((color >> 16) & 0xFF) / 255f; + float g = ((color >> 8) & 0xFF) / 255f; + float b = ((color >> 0) & 0xFF) / 255f; float endX = start.x() + (float) direction.x; float endY = start.y() + (float) direction.y; @@ -107,7 +72,7 @@ public class RenderUtil { matrices.push(); matrices.translate(0, 0, 0); - BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); buffer.vertex(matrices.peek().getPositionMatrix(), x, y + height, 0).color(r, g, b, a); buffer.vertex(matrices.peek().getPositionMatrix(), x + width, y + height, 0).color(r, g, b, a); @@ -128,7 +93,7 @@ public class RenderUtil { float maxY = minY + 1; float maxZ = minZ + 1; - BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); + BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); switch (face) { case UP: @@ -253,7 +218,7 @@ public class RenderUtil { } } - BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); switch (face) { case DOWN: @@ -310,7 +275,7 @@ public class RenderUtil { float b = color.getBlue() / 255f; float a = color.getAlpha() / 255f; - BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR); + BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR); buffer.vertex(matrices.peek().getPositionMatrix(), x1, y1, 0).color(r, g, b, a); buffer.vertex(matrices.peek().getPositionMatrix(), x2, y2, 0).color(r, g, b, a); buffer.vertex(matrices.peek().getPositionMatrix(), x3, y3, 0).color(r, g, b, a); @@ -329,7 +294,7 @@ public class RenderUtil { float maxY = (float) (box.maxY - cameraPos.y); float maxZ = (float) (box.maxZ - cameraPos.z); - BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); + BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR_NORMAL_LINE_WIDTH); // parte inferior buffer.vertex(matrices.peek(), minX, minY, minZ).color(color.getRGB()).normal(-1, -1, -1).lineWidth(lineWidth); @@ -384,7 +349,7 @@ public class RenderUtil { float maxY = (float) (box.maxY - cameraPos.y); float maxZ = (float) (box.maxZ - cameraPos.z); - BufferBuilder buffer = tesselator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); buffer.vertex(matrices.peek().getPositionMatrix(), minX, minY, minZ).color(color.getRGB()); buffer.vertex(matrices.peek().getPositionMatrix(), maxX, minY, minZ).color(color.getRGB());