From 6d41f7153bb97a66dcd1c7dd0d0fba74d98de39d Mon Sep 17 00:00:00 2001 From: Connor Slade Date: Fri, 28 Jun 2024 23:08:51 -0400 Subject: [PATCH] Final fixups --- .../connorcode/sigmautils/commands/Map.java | 27 +++---------------- .../sigmautils/misc/Components.java | 1 + .../sigmautils/mixin/EntityMixin.java | 10 +++---- .../mixin/MinecraftClientMixin.java | 12 +++------ .../modules/misc/CameraDistance.java | 1 + 5 files changed, 13 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/connorcode/sigmautils/commands/Map.java b/src/main/java/com/connorcode/sigmautils/commands/Map.java index 40dbb34..bf763a7 100644 --- a/src/main/java/com/connorcode/sigmautils/commands/Map.java +++ b/src/main/java/com/connorcode/sigmautils/commands/Map.java @@ -12,7 +12,6 @@ import net.minecraft.item.Items; import net.minecraft.item.map.MapState; import net.minecraft.text.ClickEvent; -import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Pair; @@ -41,7 +40,7 @@ private static int save(CommandContext context) { e.printStackTrace(); } - client.player.sendMessage(Text.literal(String.format("Σ] Saved Map #%d", mapId)) + client.player.sendMessage(Text.literal(String.format("[SigmaUtils::Map] Saved Map #%d", mapId.id())) .formatted(Formatting.UNDERLINE) .styled(style -> style.withClickEvent( new ClickEvent(ClickEvent.Action.OPEN_FILE, mapFile.getAbsolutePath())))); @@ -54,29 +53,9 @@ private static int info(CommandContext context) { var mapId = rawMap.get().getLeft(); MapState mapState = rawMap.get().getRight(); - MutableText out = Text.empty() - // Id - .append(Text.literal("\nΣ] Id: ") - .formatted(Formatting.BOLD)) - .append(Text.literal(String.valueOf(mapId)) - .formatted(Formatting.RESET)) - - // Scale - .append(Text.literal("\nΣ] Scale: ") - .formatted(Formatting.BOLD)) - .append(Text.literal(String.format("1:%d", (int) Math.pow(2, mapState.scale))) - .formatted(Formatting.RESET)) - - // Locked - .append(Text.literal("\nΣ] Locked: ") - .formatted(Formatting.BOLD)) - .append(Text.literal(String.valueOf(mapState.locked)) - .formatted(Formatting.RESET)); - - + var out = String.format("[SigmaUtils::Map] { ID: %d, Scale: 1:%d, Locked: %b }", mapId.id(), (int) Math.pow(2, mapState.scale), mapState.locked); context.getSource() - .getPlayer() - .sendMessage(out); + .getPlayer().sendMessage(Text.of(out)); return 0; } diff --git a/src/main/java/com/connorcode/sigmautils/misc/Components.java b/src/main/java/com/connorcode/sigmautils/misc/Components.java index 96446c2..dbc7495 100644 --- a/src/main/java/com/connorcode/sigmautils/misc/Components.java +++ b/src/main/java/com/connorcode/sigmautils/misc/Components.java @@ -29,6 +29,7 @@ public static void addToggleButton(Screen screen, Module module, int x, int y, i Util.addChild(screen, new MultiClickButton(x, y, width, 20, Text.of(String.format("%s█§r%s", module.enabled ? "§a" : "§c", mini ? "" : String.format(" %s", module.name))), button -> { + System.out.println(button.click); if (button.click == 1) { if (Config.moduleSettings.get(module.getClass()).size() <= 1) return; diff --git a/src/main/java/com/connorcode/sigmautils/mixin/EntityMixin.java b/src/main/java/com/connorcode/sigmautils/mixin/EntityMixin.java index e20118c..5941532 100644 --- a/src/main/java/com/connorcode/sigmautils/mixin/EntityMixin.java +++ b/src/main/java/com/connorcode/sigmautils/mixin/EntityMixin.java @@ -13,15 +13,13 @@ public class EntityMixin { @Inject(method = "isInvisible", at = @At("HEAD"), cancellable = true) void isInvisible(CallbackInfoReturnable cir) { - if (!Config.getEnabled(ShowInvisibleEntities.class) || ShowInvisibleEntities.isVisible((Entity) (Object) this)) - return; - cir.setReturnValue(false); + if (Config.getEnabled(ShowInvisibleEntities.class) && ShowInvisibleEntities.isVisible((Entity) (Object) this)) + cir.setReturnValue(false); } @Inject(method = "isInvisibleTo", at = @At("HEAD"), cancellable = true) void isInvisibleTo(PlayerEntity player, CallbackInfoReturnable cir) { - if (!Config.getEnabled(ShowInvisibleEntities.class) || ShowInvisibleEntities.isVisible((Entity) (Object) this)) - return; - cir.setReturnValue(false); + if (Config.getEnabled(ShowInvisibleEntities.class) && ShowInvisibleEntities.isVisible((Entity) (Object) this)) + cir.setReturnValue(false); } } diff --git a/src/main/java/com/connorcode/sigmautils/mixin/MinecraftClientMixin.java b/src/main/java/com/connorcode/sigmautils/mixin/MinecraftClientMixin.java index d36f22f..da12d8c 100644 --- a/src/main/java/com/connorcode/sigmautils/mixin/MinecraftClientMixin.java +++ b/src/main/java/com/connorcode/sigmautils/mixin/MinecraftClientMixin.java @@ -22,7 +22,6 @@ import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; -import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -120,13 +119,10 @@ void onGetStackInHand(CallbackInfo ci) { // } // For no_pause - @Redirect(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;paused:Z", opcode = Opcodes.GETFIELD)) - boolean isPaused(MinecraftClient instance) { - if (!Config.getEnabled(NoPause.class)) - return this.paused; - return this.isIntegratedServerRunning() && (this.currentScreen != null && this.currentScreen.shouldPause() || - this.overlay != null && this.overlay.pausesGame()) && !Objects.requireNonNull(this.server) - .isRemote(); + @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;isIntegratedServerRunning()Z")) + boolean isIntegratedServerRunning(MinecraftClient instance) { + if (Config.getEnabled(NoPause.class)) return false; + else return instance.isIntegratedServerRunning(); } // For window_title diff --git a/src/main/java/com/connorcode/sigmautils/modules/misc/CameraDistance.java b/src/main/java/com/connorcode/sigmautils/modules/misc/CameraDistance.java index 0fb8894..9524279 100644 --- a/src/main/java/com/connorcode/sigmautils/modules/misc/CameraDistance.java +++ b/src/main/java/com/connorcode/sigmautils/modules/misc/CameraDistance.java @@ -49,6 +49,7 @@ public void drawInterface(MinecraftClient client, Screen screen, int x, int y) { @Override public void disable() { + super.disable(); distanceMod = 0; } }