Skip to content

Commit

Permalink
Final fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
connorslade committed Jun 29, 2024
1 parent dc2beec commit 6d41f71
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
27 changes: 3 additions & 24 deletions src/main/java/com/connorcode/sigmautils/commands/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -41,7 +40,7 @@ private static int save(CommandContext<FabricClientCommandSource> 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()))));
Expand All @@ -54,29 +53,9 @@ private static int info(CommandContext<FabricClientCommandSource> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/connorcode/sigmautils/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
public class EntityMixin {
@Inject(method = "isInvisible", at = @At("HEAD"), cancellable = true)
void isInvisible(CallbackInfoReturnable<Boolean> 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<Boolean> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void drawInterface(MinecraftClient client, Screen screen, int x, int y) {

@Override
public void disable() {
super.disable();
distanceMod = 0;
}
}

0 comments on commit 6d41f71

Please sign in to comment.