diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClient.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClient.java index d5fcedc78..efc67c2a9 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClient.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClient.java @@ -32,19 +32,16 @@ import io.github.axolotlclient.modules.auth.Auth; import io.github.axolotlclient.modules.blur.MenuBlur; import io.github.axolotlclient.modules.blur.MotionBlur; -import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hypixel.HypixelMods; import io.github.axolotlclient.modules.particles.Particles; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; -import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.modules.tablist.Tablist; -import io.github.axolotlclient.modules.tnttime.TntTime; import io.github.axolotlclient.modules.zoom.Zoom; import io.github.axolotlclient.util.FeatureDisabler; +import io.github.axolotlclient.util.FeatureDisablerCommon; import io.github.axolotlclient.util.Logger; import io.github.axolotlclient.util.LoggerImpl; import io.github.axolotlclient.util.notifications.Notifications; @@ -66,12 +63,9 @@ private void addBuiltinModules() { registerModule(MotionBlur.getInstance()); registerModule(MenuBlur.getInstance()); registerModule(ScrollableTooltips.getInstance()); - registerModule(DiscordRPC.getInstance()); - registerModule(Freelook.getInstance()); - registerModule(TntTime.getInstance()); + registerModule(Particles.getInstance()); registerModule(ScreenshotUtils.getInstance()); - registerModule(BeaconBeam.getInstance()); registerModule(Tablist.getInstance()); registerModule(Auth.getInstance()); registerModule(APIOptions.getInstance()); @@ -97,8 +91,8 @@ public void onInitializeClient() { } @Override - protected void initFeatureDisabler() { - FeatureDisabler.init(); + protected FeatureDisablerCommon getFeatureDisabler() { + return FeatureDisabler.getInstance(); } @Override diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java index 861d4e687..ef066fb22 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java @@ -51,6 +51,10 @@ public Identifier getFabricId() { return new Identifier("axolotlclient", "bridge/resource_listener"); } }); + + ClientPlayConnectionEvents.INIT.register((handler, client) -> + Events.BEGIN_JOIN_SERVER.invoker().accept(new Events.ServerJoinInfo(handler.getConnection().getAddress().toString()))); + ClientPlayConnectionEvents.JOIN.register((clientPlayNetworkHandler, sender, minecraftClient) -> Events.CONNECTION_PLAY_READY.invoker().run()); ClientPlayConnectionEvents.DISCONNECT.register((clientPlayNetworkHandler, minecraftClient) -> Events.DISCONNECT.invoker().run()); } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java index fbeca8d20..f2106d258 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java @@ -22,14 +22,17 @@ package io.github.axolotlclient.bridge.mixin; -import java.util.Collection; -import java.util.Optional; +import java.util.*; +import java.util.stream.Collectors; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import io.github.axolotlclient.bridge.AxoMinecraftClient; import io.github.axolotlclient.bridge.AxoPlayerListEntry; import io.github.axolotlclient.bridge.AxoSession; +import io.github.axolotlclient.bridge.entity.AxoEntity; import io.github.axolotlclient.bridge.entity.AxoPlayer; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; +import io.github.axolotlclient.bridge.AxoGameOptions; import io.github.axolotlclient.bridge.render.AxoFont; import io.github.axolotlclient.bridge.resource.AxoResourceManager; import io.github.axolotlclient.bridge.util.AxoText; @@ -41,9 +44,15 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ServerInfo; import net.minecraft.client.options.GameOptions; +import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.util.Session; import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; import net.minecraft.resource.ResourceManager; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; import net.minecraft.util.thread.ReentrantThreadExecutor; import org.jetbrains.annotations.Nullable; @@ -89,6 +98,14 @@ public abstract class MinecraftClientMixin extends ReentrantThreadExecutor x.address).orElse(null); } + @Override + public String br$getServerName() { + return Optional.ofNullable(getCurrentServerEntry()).map(x -> x.name).orElse(null); + } + @Override public Collection br$getOnlinePlayers() { return player.networkHandler.getPlayerList(); @@ -161,4 +183,54 @@ public MinecraftClientMixin(String string) { public Object br$getScreen() { return currentScreen; } + + @Override + public void br$notifyLevelRenderer() { + worldRenderer.scheduleTerrainUpdate(); + } + + @Override + public AxoEntity br$getCameraEntity() { + return cameraEntity; + } + + @Override + public List br$getSidebar() { + List lines = new ArrayList<>(); + MinecraftClient client = MinecraftClient.getInstance(); + if (client.world == null) + return lines; + + Scoreboard scoreboard = client.world.getScoreboard(); + if (scoreboard == null) + return lines; + ScoreboardObjective sidebar = scoreboard.getObjectiveForSlot(1); + if (sidebar == null) + return lines; + + Collection scores = scoreboard.getAllPlayerScores(sidebar); + List list = scores.stream().filter( + input -> input != null && input.getPlayerName() != null && !input.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + + if (list.size() > 15) { + scores = Lists.newArrayList(Iterables.skip(list, scores.size() - 15)); + } else { + scores = list; + } + + for (ScoreboardPlayerScore score : scores) { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + if (team == null) + return lines; + String text = team.getPrefix().getString() + team.getSuffix().getString(); + if (!text.trim().isEmpty()) + lines.add(text); + } + + lines.add(sidebar.getDisplayName().getString()); + Collections.reverse(lines); + + return lines; + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java index adec275ae..ca11aff60 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java @@ -22,16 +22,18 @@ package io.github.axolotlclient.bridge.mixin.key; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; +import io.github.axolotlclient.bridge.AxoGameOptions; +import io.github.axolotlclient.bridge.AxoPerspective; import io.github.axolotlclient.bridge.key.AxoKeybinding; import net.minecraft.client.options.GameOptions; import net.minecraft.client.options.KeyBinding; +import net.minecraft.client.options.Perspective; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @Mixin(GameOptions.class) -public abstract class GameOptionsMixin implements AxoClientKeybinds { +public abstract class GameOptionsMixin implements AxoGameOptions { @Shadow @Final public KeyBinding keyAttack; @@ -48,6 +50,12 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { @Final public KeyBinding keyUse; + @Shadow + public abstract Perspective getPerspective(); + + @Shadow + public abstract void method_31043(Perspective par1); + @Override public AxoKeybinding br$getSprintKeybind() { return keySprint; @@ -67,4 +75,22 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { public AxoKeybinding br$getUseKey() { return keyUse; } + + @Override + public AxoPerspective br$getCameraType() { + return switch (getPerspective()) { + case FIRST_PERSON -> AxoPerspective.FIRST_PERSON; + case THIRD_PERSON_BACK -> AxoPerspective.THIRD_PERSON_BACK; + case THIRD_PERSON_FRONT -> AxoPerspective.THIRD_PERSON_FRONT; + }; + } + + @Override + public void br$setCameraType(AxoPerspective perspective) { + method_31043(switch (perspective) { + case FIRST_PERSON -> Perspective.FIRST_PERSON; + case THIRD_PERSON_BACK -> Perspective.THIRD_PERSON_BACK; + case THIRD_PERSON_FRONT -> Perspective.THIRD_PERSON_FRONT; + }); + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 7b2883aeb..7ef856b89 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -50,22 +50,8 @@ import net.minecraft.client.texture.NativeImageBackedTexture; public class AxolotlClientConfig extends AxolotlClientConfigCommon { - - public final BooleanOption showOwnNametag = new BooleanOption("showOwnNametag", false); - public final BooleanOption useShadows = new BooleanOption("useShadows", false); - public final BooleanOption nametagBackground = new BooleanOption("nametagBackground", true); - - public final BooleanOption showBadges = new BooleanOption("showBadges", true); - public final BooleanOption customBadge = new BooleanOption("customBadge", false); - public final StringOption badgeText = new StringOption("badgeText", ""); - - public final ForceableBooleanOption timeChangerEnabled = new ForceableBooleanOption("enabled", false); - public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); - public final ForceableBooleanOption fullBright = new ForceableBooleanOption("fullBright", false); - public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); - public final ForceableBooleanOption lowFire = new ForceableBooleanOption("lowFire", false); + public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", new Color(255, 0, 0, 77), value -> { @@ -93,59 +79,26 @@ public class AxolotlClientConfig extends AxolotlClientConfigCommon { } catch (Exception ignored) { } }); - public final BooleanOption minimalViewBob = new BooleanOption("minimalViewBob", false); - public final BooleanOption noHurtCam = new BooleanOption("noHurtCam", false); + public final BooleanOption flatItems = new BooleanOption("flatItems", false); public final BooleanOption inventoryPotionEffectOffset = new BooleanOption("inventory.potion_effect_offset", true); public final ColorOption loadingScreenColor = new ColorOption("loadingBgColor", new Color(239, 50, 61, 255)); public final BooleanOption nightMode = new BooleanOption("nightMode", false); - public final BooleanOption customWindowTitle = new BooleanOption("customWindowTitle", true); - public final BooleanOption enableCustomOutlines = new BooleanOption("enabled", false); - public final ColorOption outlineColor = new ColorOption("color", Color.parse("#DD000000")); public final BooleanOption outlineChroma = new BooleanOption("chroma", false); - public final BooleanOption noRain = new BooleanOption("noRain", false); - public final GenericOption openCredits = new GenericOption("Credits", "Open Credits", () -> MinecraftClient.getInstance().openScreen(new CreditsScreen(MinecraftClient.getInstance().currentScreen)) ); - public final BooleanOption debugLogOutput = new BooleanOption("debugLogOutput", false); - public final BooleanOption creditsBGM = new BooleanOption("creditsBGM", true); - - public final OptionCategory general = OptionCategory.create("general"); - public final OptionCategory nametagOptions = OptionCategory.create("nametagOptions"); - public final OptionCategory rendering = OptionCategory.create("rendering"); - public final OptionCategory outlines = OptionCategory.create("blockOutlines"); - public final OptionCategory timeChanger = OptionCategory.create("timeChanger"); + @Getter private final List> options = new ArrayList<>(); public AxolotlClientConfig() { - config.add(general); - config.add(nametagOptions); - config.add(rendering); - - rendering.add(outlines); - - nametagOptions.add(showOwnNametag); - nametagOptions.add(useShadows); - nametagOptions.add(nametagBackground); - - nametagOptions.add(showBadges); - nametagOptions.add(customBadge); - nametagOptions.add(badgeText); - general.add(loadingScreenColor); general.add(nightMode); - general.add(customWindowTitle); general.add(openCredits); - general.add(debugLogOutput); - - general.add(datetimeFormat); - general.add(titleScreenOptionButtonMode); - general.add(gameMenuScreenOptionButtonMode); ConfigUI.getInstance().runWhenLoaded(() -> { general.getOptions().removeIf(o -> "configStyle".equals(o.getName())); @@ -169,29 +122,13 @@ public AxolotlClientConfig() { }); rendering.add(customSky, - dynamicFOV, - fullBright, - removeVignette, - lowFire, lowShield, hitColor, - minimalViewBob, flatItems, - noHurtCam, inventoryPotionEffectOffset); - timeChanger.add(timeChangerEnabled); - timeChanger.add(customTime); - rendering.add(timeChanger); - - outlines.add(enableCustomOutlines); - outlines.add(outlineColor); outlines.add(outlineChroma); - rendering.add(noRain); - - hidden.add(creditsBGM, someNiceBackground); - general.add(new GenericOption("profiles.title", "profiles.configure", () -> MinecraftClient.getInstance().openScreen(new ProfilesScreen(MinecraftClient.getInstance().currentScreen))), false); @@ -203,5 +140,4 @@ public AxolotlClientConfig() { } }); } - } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java index 19878b641..7842f849c 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java @@ -22,7 +22,7 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; +import io.github.axolotlclient.modules.render.BeaconBeam; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; import net.minecraft.client.util.math.MatrixStack; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java index c5b6eb89c..7524f9ac4 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java @@ -29,6 +29,7 @@ import net.minecraft.client.render.entity.TntEntityRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.TntEntity; +import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -45,7 +46,7 @@ protected TntEntityRendererMixin(EntityRenderDispatcher dispatcher) { public void axolotlclient$render(TntEntity entity, float yaw, float delta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, CallbackInfo ci) { if (TntTime.getInstance().enabled.get()) { - super.renderLabelIfPresent(entity, TntTime.getInstance().getFuseTime(entity.getFuse()), matrixStack, + super.renderLabelIfPresent(entity, (Text) TntTime.getInstance().getFuseTime(entity.getFuse()), matrixStack, vertexConsumerProvider, light); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java deleted file mode 100644 index d10594057..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.freelook; - -import java.util.ArrayDeque; -import java.util.Deque; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; -import io.github.axolotlclient.modules.AbstractCommonModule; -import io.github.axolotlclient.util.FeatureDisabler; -import io.github.axolotlclient.util.options.ForceableBooleanOption; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.options.KeyBinding; -import net.minecraft.client.options.Perspective; -import net.minecraft.entity.Entity; -import org.lwjgl.glfw.GLFW; - -public class Freelook extends AbstractCommonModule { - - private static final Freelook INSTANCE = new Freelook(); - private static final KeyBinding KEY = new KeyBinding("key.freelook", GLFW.GLFW_KEY_V, "category.axolotlclient"); - private static final KeyBinding KEY_ALT = new KeyBinding("key.freelook.alt", GLFW.GLFW_KEY_UNKNOWN, "category.axolotlclient"); - public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); - private final MinecraftClient client = MinecraftClient.getInstance(); - private final OptionCategory category = OptionCategory.create("freelook"); - private final StringArrayOption mode = new StringArrayOption("mode", - new String[]{"snap_perspective", "freelook"}, - "freelook", value -> FeatureDisabler.update()); - private final BooleanOption invert = new BooleanOption("invert", false); - private final EnumOption perspective = new EnumOption<>("perspective", Perspective.class, - Perspective.THIRD_PERSON_BACK); - private final BooleanOption toggle = new BooleanOption("toggle", "freelook.toggle.tooltip", false); - private final EnumOption perspectiveAlt = new EnumOption<>("perspective.alt", Perspective.class, - Perspective.THIRD_PERSON_FRONT); - private final BooleanOption toggleAlt = new BooleanOption("toggle.alt", false); - private final WrappedValue active = new WrappedValue(), activeAlt = new WrappedValue(); - private float yaw, pitch; - private final Deque previousPerspectives = new ArrayDeque<>(); - - public static Freelook getInstance() { - return INSTANCE; - } - - @Override - public void init() { - KeyBindingHelper.registerKeyBinding(KEY); - KeyBindingHelper.registerKeyBinding(KEY_ALT); - category.add(enabled, mode, perspective, invert, toggle); - category.add(perspectiveAlt, toggleAlt); - AxolotlClient.config().addCategory(category); - } - - @Override - public void tick() { - if (!enabled.get() || client.currentScreen != null) return; - tickSet(toggle, KEY, perspective, active); - tickSet(toggleAlt, KEY_ALT, perspectiveAlt, activeAlt); - } - - private void tickSet(BooleanOption toggle, KeyBinding key, EnumOption perspective, WrappedValue active) { - if (toggle.get()) { - if (key.wasPressed()) { - if (active.val) { - stop(active); - } else { - start(perspective.get(), active); - } - } - } else { - if (key.isPressed()) { - if (!active.val) { - start(perspective.get(), active); - } - } else if (active.val) { - stop(active); - } - } - } - - private void stop(WrappedValue active) { - active.val = false; - client.worldRenderer.scheduleTerrainUpdate(); - setPerspective(previousPerspectives.pop()); - } - - private void start(Perspective perspective, WrappedValue active) { - previousPerspectives.push(client.options.getPerspective()); - active.val = true; - setPerspective(perspective); - - Entity camera = client.getCameraEntity(); - - if (camera == null) - camera = client.player; - if (camera == null) - return; - - yaw = camera.getYaw(0); - pitch = camera.getPitch(0); - } - - private void setPerspective(Perspective perspective) { - MinecraftClient.getInstance().options.method_31043(perspective); - } - - public boolean consumeRotation(double dx, double dy) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return false; - - if (!invert.get()) - dy = -dy; - - if (MinecraftClient.getInstance().options.getPerspective().isFrontView() - || MinecraftClient.getInstance().options.getPerspective().isFirstPerson()) - dy *= -1; - - yaw += (float) (dx * 0.15F); - pitch += (float) (dy * 0.15F); - - if (pitch > 90) { - pitch = 90; - } else if (pitch < -90) { - pitch = -90; - } - - client.worldRenderer.scheduleTerrainUpdate(); - return true; - } - - public float yaw(float defaultValue) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return defaultValue; - - return yaw; - } - - public float pitch(float defaultValue) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return defaultValue; - - return pitch; - } - - public boolean needsDisabling() { - return mode.get().equals("freelook"); - } - - public boolean isActive() { - return active.val || activeAlt.val; - } - - private static class WrappedValue { - boolean val; - } -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java deleted file mode 100644 index 2901b01bb..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.renderOptions; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.modules.AbstractModule; -import lombok.Getter; - -public class BeaconBeam extends AbstractModule { - - @Getter - private final static BeaconBeam Instance = new BeaconBeam(); - - private final BooleanOption showBeaconBeams = new BooleanOption("showBeaconBeams", true); - private final BooleanOption showEndGatewayBeams = new BooleanOption("showEndGatewayBeams", true); - - private final OptionCategory beams = OptionCategory.create("beams"); - - @Override - public void init() { - beams.add(showBeaconBeams, showEndGatewayBeams); - - AxolotlClient.config().rendering.add(beams); - } - - public boolean showBeam(boolean endGateway) { - return endGateway ? showEndGatewayBeams.get() : showBeaconBeams.get(); - } -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java deleted file mode 100644 index ceeb8e649..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.rpc; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.util.Util; -import net.minecraft.client.MinecraftClient; - -public class DiscordRPC extends RPCCommon { - private static DiscordRPC Instance; - private String currentWorld = ""; - - public DiscordRPC() { - super(AxolotlClient.LOGGER); - } - - public static DiscordRPC getInstance() { - if (Instance == null) - Instance = new DiscordRPC(); - return Instance; - } - - public void setWorld(String world) { - currentWorld = world; - } - - @Override - protected void createRichPresence() { - - String state = switch (showServerNameMode.get()) { - case "showIp" -> MinecraftClient.getInstance().world == null ? "In the menu" - : (MinecraftClient.getInstance().getCurrentServerEntry() == null ? "Singleplayer" : MinecraftClient.getInstance().getCurrentServerEntry().address); - case "showName" -> MinecraftClient.getInstance().world == null ? "In the menu" - : (MinecraftClient.getInstance().getCurrentServerEntry() == null - ? (MinecraftClient.getInstance().getCurrentServerEntry() == null ? "Singleplayer" - : MinecraftClient.getInstance().getCurrentServerEntry().address) - : MinecraftClient.getInstance().getCurrentServerEntry().name); - default -> ""; - }; - - String details; - if (showActivity.get() && MinecraftClient.getInstance().getCurrentServerEntry() != null) { - details = (Util.getGame()); - } else if (showActivity.get() && !currentWorld.isEmpty()) { - details = (currentWorld); - currentWorld = ""; - } else { - details = ""; - } - - setRichPresence(createRichPresence(AxolotlClient.VERSION, state, details)); - } - - public void init() { - super.init(); - - AxolotlClient.config().addCategory(category); - } -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java deleted file mode 100644 index 9301cd01d..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.tnttime; - -import java.text.DecimalFormat; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.IntegerOption; -import io.github.axolotlclient.modules.AbstractModule; -import io.github.axolotlclient.util.options.ForceableBooleanOption; -import lombok.Getter; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; - -public class TntTime extends AbstractModule { - - @Getter - private static final TntTime Instance = new TntTime(); - public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); - private final OptionCategory category = OptionCategory.create("tnttime"); - private final IntegerOption decimalPlaces = new IntegerOption("decimalplaces", 2, 0, 6); - private DecimalFormat format; - private int decimals; - - @Override - public void init() { - category.add(enabled, decimalPlaces); - AxolotlClient.config().rendering.add(category); - } - - @Override - public void tick() { - if (decimalPlaces.get() != decimals || format == null) { - StringBuilder string = new StringBuilder("#0"); - if (decimalPlaces.get() > 0) { - string.append("."); - string.append("0".repeat(Math.max(0, decimalPlaces.get()))); - } - format = new DecimalFormat(string.toString()); - decimals = decimalPlaces.get(); - } - } - - public Text getFuseTime(int time) { - float secs = time / 20F; - return Text.of(String.valueOf(format.format(secs))).copy() - .setStyle(Style.EMPTY.withColor(getCurrentColor(secs))); - } - - private Formatting getCurrentColor(float seconds) { - if (seconds > 7d) { - return Formatting.DARK_AQUA; - } else if (seconds > 6d) { - return Formatting.AQUA; - } else if (seconds > 4d) { - return Formatting.DARK_GREEN; - } else if (seconds > 3d) { - return Formatting.GREEN; - } else if (seconds > 2d) { - return Formatting.GOLD; - } else if (seconds > 1d) { - return Formatting.RED; - } else if (seconds > 0d) { - return Formatting.DARK_RED; - } else { - return Formatting.WHITE; - } - } -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java index 19869cedf..d3cc57f5b 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java @@ -22,62 +22,27 @@ package io.github.axolotlclient.util; -import java.util.HashMap; -import java.util.Locale; -import java.util.Objects; -import java.util.function.Supplier; - import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.modules.freelook.Freelook; -import io.github.axolotlclient.modules.hud.HudManager; -import io.github.axolotlclient.modules.hud.gui.hud.simple.ToggleSprintHud; -import io.github.axolotlclient.util.options.ForceableBooleanOption; +import lombok.Getter; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.util.Identifier; -import net.minecraft.util.Util; - -public class FeatureDisabler { - - private static final HashMap disabledServers = new HashMap<>(); - private static final HashMap> conditions = new HashMap<>(); - - private static final Supplier NONE = () -> true; - private static final Identifier channelName = new Identifier("axolotlclient", "block_mods"); - // Features that can be disabled on the server's behalf - // If something should be added here, feel free to ping us via your favorite way. - private static final HashMap features = Util.make(() -> { - HashMap features = new HashMap<>(); - features.put("freelook", Freelook.getInstance().enabled); - features.put("timechanger", AxolotlClient.config().timeChangerEnabled); - features.put("lowfire", AxolotlClient.config().lowFire); - features.put("fullbright", AxolotlClient.config().fullBright); - return features; - }); - private static String currentAddress = ""; - public static void init() { - setServers(AxolotlClient.config().fullBright, NONE, "gommehd"); - setServers(AxolotlClient.config().lowFire, NONE, "gommehd"); - setServers(Freelook.getInstance().enabled, () -> Freelook.getInstance().needsDisabling(), "hypixel", "mineplex", "gommehd", "nucleoid"); - setServers(((ToggleSprintHud) HudManager.getInstance().get(ToggleSprintHud.ID)).toggleSneak, NONE, "hypixel"); - - ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { - if (handler.getConnection() != null) { - onServerJoin(Objects.requireNonNull(handler.getConnection()).getAddress().toString()); - } - }); - ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> clear()); +public class FeatureDisabler extends FeatureDisablerCommon { + @Getter + private static final FeatureDisablerCommon instance = new FeatureDisabler(); + @Override + protected void registerChannel() { ClientPlayConnectionEvents.INIT.register((handler0, client0) -> - ClientPlayNetworking.registerGlobalReceiver(channelName, (client, handler, buf, responseSender) -> { + ClientPlayNetworking.registerGlobalReceiver((Identifier) CHANNEL_NAME, (client, handler, buf, responseSender) -> { JsonArray array = new JsonParser().parse(buf.readString()).getAsJsonArray(); for (JsonElement element : array) { try { - features.get(element.getAsString()).setForceOff(true, "ban_reason"); + FEATURES.get(element.getAsString()).setForceOff(true, "ban_reason"); } catch (Exception e) { AxolotlClient.LOGGER.error("Failed to disable " + element.getAsString() + "!"); } @@ -85,37 +50,4 @@ public static void init() { }) ); } - - private static void setServers(ForceableBooleanOption option, Supplier condition, String... servers) { - disabledServers.put(option, servers); - conditions.put(option, condition); - } - - public static void onServerJoin(String address) { - currentAddress = address; - update(); - } - - public static void clear() { - disabledServers.keySet().forEach(option -> option.setForceOff(false, "")); - features.values().forEach(option -> option.setForceOff(false, "")); - } - - public static void update() { - disabledServers.forEach((option, strings) -> disableOption(option, strings, currentAddress)); - } - - private static void disableOption(ForceableBooleanOption option, String[] servers, String currentServer) { - boolean ban = false; - for (String s : servers) { - if (currentServer.toLowerCase(Locale.ROOT).contains(s.toLowerCase(Locale.ROOT))) { - ban = conditions.get(option).get(); - break; - } - } - - if (option.isForceOff() != ban) { - option.setForceOff(ban, "ban_reason"); - } - } } diff --git a/1.16_combat-6/src/main/resources/fabric.mod.json b/1.16_combat-6/src/main/resources/fabric.mod.json index 86d274171..04f040efa 100644 --- a/1.16_combat-6/src/main/resources/fabric.mod.json +++ b/1.16_combat-6/src/main/resources/fabric.mod.json @@ -74,7 +74,7 @@ "io/github/axolotlclient/bridge/key/AxoKeybinding" ], "net/minecraft/class_315": [ - "io/github/axolotlclient/bridge/key/AxoClientKeybinds" + "io/github/axolotlclient/bridge/AxoGameOptions" ], "net/minecraft/class_3675\u0024class_306": [ "io/github/axolotlclient/bridge/key/AxoKey" diff --git a/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java b/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java index c96b579ba..5a51179bb 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java @@ -32,19 +32,16 @@ import io.github.axolotlclient.modules.auth.Auth; import io.github.axolotlclient.modules.blur.MenuBlur; import io.github.axolotlclient.modules.blur.MotionBlur; -import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hypixel.HypixelMods; import io.github.axolotlclient.modules.particles.Particles; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; -import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.modules.tablist.Tablist; -import io.github.axolotlclient.modules.tnttime.TntTime; import io.github.axolotlclient.modules.zoom.Zoom; import io.github.axolotlclient.util.FeatureDisabler; +import io.github.axolotlclient.util.FeatureDisablerCommon; import io.github.axolotlclient.util.Logger; import io.github.axolotlclient.util.LoggerImpl; import io.github.axolotlclient.util.notifications.Notifications; @@ -66,12 +63,9 @@ private void addBuiltinModules() { registerModule(MotionBlur.getInstance()); registerModule(MenuBlur.getInstance()); registerModule(ScrollableTooltips.getInstance()); - registerModule(DiscordRPC.getInstance()); - registerModule(Freelook.getInstance()); - registerModule(TntTime.getInstance()); + registerModule(Particles.getInstance()); registerModule(ScreenshotUtils.getInstance()); - registerModule(BeaconBeam.getInstance()); registerModule(Tablist.getInstance()); registerModule(Auth.getInstance()); registerModule(APIOptions.getInstance()); @@ -96,8 +90,8 @@ public void onInitializeClient() { } @Override - protected void initFeatureDisabler() { - FeatureDisabler.init(); + protected FeatureDisablerCommon getFeatureDisabler() { + return FeatureDisabler.getInstance(); } @Override diff --git a/1.20/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java b/1.20/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java index 9117bab7a..21692c47c 100644 --- a/1.20/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java +++ b/1.20/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.bridge.impl; +import java.util.Objects; + import com.mojang.brigadier.CommandDispatcher; import io.github.axolotlclient.bridge.events.Events; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; @@ -52,6 +54,8 @@ public Identifier getFabricId() { return new Identifier("axolotlclient", "bridge/resource_listener"); } }); + ClientPlayConnectionEvents.INIT.register((handler, client) -> + Events.BEGIN_JOIN_SERVER.invoker().accept(new Events.ServerJoinInfo(Objects.requireNonNull(handler.getServerInfo()).address))); ClientPlayConnectionEvents.JOIN.register((clientPlayNetworkHandler, sender, minecraftClient) -> Events.CONNECTION_PLAY_READY.invoker().run()); ClientPlayConnectionEvents.DISCONNECT.register((clientPlayNetworkHandler, minecraftClient) -> Events.DISCONNECT.invoker().run()); diff --git a/1.20/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java b/1.20/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java index 14afe85a0..357fed6f5 100644 --- a/1.20/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java @@ -22,14 +22,17 @@ package io.github.axolotlclient.bridge.mixin; -import java.util.Collection; -import java.util.Optional; +import java.util.*; +import java.util.stream.Collectors; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import io.github.axolotlclient.bridge.AxoMinecraftClient; import io.github.axolotlclient.bridge.AxoPlayerListEntry; import io.github.axolotlclient.bridge.AxoSession; +import io.github.axolotlclient.bridge.entity.AxoEntity; import io.github.axolotlclient.bridge.entity.AxoPlayer; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; +import io.github.axolotlclient.bridge.AxoGameOptions; import io.github.axolotlclient.bridge.render.AxoFont; import io.github.axolotlclient.bridge.resource.AxoResourceManager; import io.github.axolotlclient.bridge.util.AxoText; @@ -41,9 +44,15 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ServerInfo; import net.minecraft.client.option.GameOptions; +import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.util.Session; import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; import net.minecraft.resource.ResourceManager; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; @@ -88,6 +97,14 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { @Shadow public abstract ResourceManager getResourceManager(); + @Shadow + @Final + public WorldRenderer worldRenderer; + + @Shadow + @Nullable + public Entity cameraEntity; + @Override public @Nullable AxoPlayer br$getPlayer() { return player; @@ -106,7 +123,7 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { @Override - public AxoClientKeybinds br$getKeybinds() { + public AxoGameOptions br$getGameOptions() { return options; } @@ -125,6 +142,11 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { return Optional.ofNullable(getCurrentServerEntry()).map(x -> x.address).orElse(null); } + @Override + public String br$getServerName() { + return Optional.ofNullable(getCurrentServerEntry()).map(x -> x.name).orElse(null); + } + @Override public Collection br$getOnlinePlayers() { return player.networkHandler.getPlayerList(); @@ -160,4 +182,54 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { public Object br$getScreen() { return currentScreen; } + + @Override + public void br$notifyLevelRenderer() { + worldRenderer.scheduleTerrainUpdate(); + } + + @Override + public AxoEntity br$getCameraEntity() { + return cameraEntity; + } + + @Override + public List br$getSidebar() { + List lines = new ArrayList<>(); + MinecraftClient client = MinecraftClient.getInstance(); + if (client.world == null) + return lines; + + Scoreboard scoreboard = client.world.getScoreboard(); + if (scoreboard == null) + return lines; + ScoreboardObjective sidebar = scoreboard.getObjectiveForSlot(Scoreboard.SIDEBAR_DISPLAY_SLOT_ID); + if (sidebar == null) + return lines; + + Collection scores = scoreboard.getAllPlayerScores(sidebar); + List list = scores.stream().filter( + input -> input != null && input.getPlayerName() != null && !input.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + + if (list.size() > 15) { + scores = Lists.newArrayList(Iterables.skip(list, scores.size() - 15)); + } else { + scores = list; + } + + for (ScoreboardPlayerScore score : scores) { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + if (team == null) + return lines; + String text = team.getPrefix().getString() + team.getSuffix().getString(); + if (!text.trim().isEmpty()) + lines.add(text); + } + + lines.add(sidebar.getDisplayName().getString()); + Collections.reverse(lines); + + return lines; + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java b/1.20/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java index 782cc5c68..4a3d07b85 100644 --- a/1.20/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java @@ -22,16 +22,18 @@ package io.github.axolotlclient.bridge.mixin.key; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; +import io.github.axolotlclient.bridge.AxoGameOptions; +import io.github.axolotlclient.bridge.AxoPerspective; import io.github.axolotlclient.bridge.key.AxoKeybinding; import net.minecraft.client.option.GameOptions; import net.minecraft.client.option.KeyBind; +import net.minecraft.client.option.Perspective; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @Mixin(GameOptions.class) -public abstract class GameOptionsMixin implements AxoClientKeybinds { +public abstract class GameOptionsMixin implements AxoGameOptions { @Shadow @Final public KeyBind sprintKey; @@ -48,6 +50,12 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { @Final public KeyBind useKey; + @Shadow + public abstract Perspective getPerspective(); + + @Shadow + public abstract void setPerspective(Perspective perspective); + @Override public AxoKeybinding br$getSprintKeybind() { return sprintKey; @@ -67,4 +75,22 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { public AxoKeybinding br$getUseKey() { return useKey; } + + @Override + public AxoPerspective br$getCameraType() { + return switch (getPerspective()) { + case FIRST_PERSON -> AxoPerspective.FIRST_PERSON; + case THIRD_PERSON_BACK -> AxoPerspective.THIRD_PERSON_BACK; + case THIRD_PERSON_FRONT -> AxoPerspective.THIRD_PERSON_FRONT; + }; + } + + @Override + public void br$setCameraType(AxoPerspective perspective) { + setPerspective(switch (perspective) { + case FIRST_PERSON -> Perspective.FIRST_PERSON; + case THIRD_PERSON_BACK -> Perspective.THIRD_PERSON_BACK; + case THIRD_PERSON_FRONT -> Perspective.THIRD_PERSON_FRONT; + }); + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 67032ba6f..9a8fc389a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -49,22 +49,8 @@ import net.minecraft.client.texture.NativeImageBackedTexture; public class AxolotlClientConfig extends AxolotlClientConfigCommon { - - public final BooleanOption showOwnNametag = new BooleanOption("showOwnNametag", false); - public final BooleanOption useShadows = new BooleanOption("useShadows", false); - public final BooleanOption nametagBackground = new BooleanOption("nametagBackground", true); - - public final BooleanOption showBadges = new BooleanOption("showBadges", true); - public final BooleanOption customBadge = new BooleanOption("customBadge", false); - public final StringOption badgeText = new StringOption("badgeText", ""); - - public final ForceableBooleanOption timeChangerEnabled = new ForceableBooleanOption("enabled", false); - public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); - public final ForceableBooleanOption fullBright = new ForceableBooleanOption("fullBright", false); - public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); - public final ForceableBooleanOption lowFire = new ForceableBooleanOption("lowFire", false); + public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", new Color(255, 0, 0, 77), value -> { @@ -90,59 +76,23 @@ public class AxolotlClientConfig extends AxolotlClientConfigCommon { RenderSystem.activeTexture(33984); } }); - public final BooleanOption minimalViewBob = new BooleanOption("minimalViewBob", false); - public final BooleanOption noHurtCam = new BooleanOption("noHurtCam", false); + public final BooleanOption flatItems = new BooleanOption("flatItems", false); public final ColorOption loadingScreenColor = new ColorOption("loadingBgColor", new Color(239, 50, 61, 255)); public final BooleanOption nightMode = new BooleanOption("nightMode", false); - public final BooleanOption customWindowTitle = new BooleanOption("customWindowTitle", true); - - public final BooleanOption enableCustomOutlines = new BooleanOption("enabled", false); - public final ColorOption outlineColor = new ColorOption("color", Color.parse("#DD000000")); - - public final BooleanOption noRain = new BooleanOption("noRain", false); public final GenericOption openCredits = new GenericOption("Credits", "Open Credits", () -> MinecraftClient.getInstance().setScreen(new CreditsScreen(MinecraftClient.getInstance().currentScreen)) ); - public final BooleanOption debugLogOutput = new BooleanOption("debugLogOutput", false); - public final BooleanOption creditsBGM = new BooleanOption("creditsBGM", true); - - public final OptionCategory general = OptionCategory.create("general"); - public final OptionCategory nametagOptions = OptionCategory.create("nametagOptions"); - public final OptionCategory rendering = OptionCategory.create("rendering"); - public final OptionCategory outlines = OptionCategory.create("blockOutlines"); - public final OptionCategory timeChanger = OptionCategory.create("timeChanger"); @Getter private final List> options = new ArrayList<>(); public AxolotlClientConfig() { - - config.add(general); - config.add(nametagOptions); - config.add(rendering); - - rendering.add(outlines); - - nametagOptions.add(showOwnNametag); - nametagOptions.add(useShadows); - nametagOptions.add(nametagBackground); - - nametagOptions.add(showBadges); - nametagOptions.add(customBadge); - nametagOptions.add(badgeText); - general.add(loadingScreenColor); general.add(nightMode); - general.add(customWindowTitle); general.add(openCredits); - general.add(debugLogOutput); - - general.add(datetimeFormat); - general.add(titleScreenOptionButtonMode); - general.add(gameMenuScreenOptionButtonMode); ConfigUI.getInstance().runWhenLoaded(() -> { general.getOptions().removeIf(o -> "configStyle".equals(o.getName())); @@ -166,26 +116,9 @@ public AxolotlClientConfig() { }); rendering.add(customSky, - dynamicFOV, - fullBright, - removeVignette, - lowFire, lowShield, hitColor, - minimalViewBob, - flatItems, - noHurtCam); - - timeChanger.add(timeChangerEnabled); - timeChanger.add(customTime); - rendering.add(timeChanger); - - outlines.add(enableCustomOutlines); - outlines.add(outlineColor); - - rendering.add(noRain); - - hidden.add(creditsBGM, someNiceBackground); + flatItems); general.add(new GenericOption("profiles.title", "profiles.configure", () -> MinecraftClient.getInstance().setScreen(new ProfilesScreen(MinecraftClient.getInstance().currentScreen))), false); diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java index d4b97dc82..62d4c2c70 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java @@ -22,7 +22,7 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; +import io.github.axolotlclient.modules.render.BeaconBeam; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; import net.minecraft.client.util.math.MatrixStack; diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/CameraMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/CameraMixin.java index bd46a2ca0..338837acb 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/CameraMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/CameraMixin.java @@ -48,10 +48,8 @@ public abstract class CameraMixin { @Inject(method = "update", at = @At(value = "INVOKE", target = "net/minecraft/client/render/Camera.moveBy(DDD)V", ordinal = 0)) private void axolotlclient$perspectiveUpdatePitchYaw(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) { - this.pitch = Freelook.getInstance().pitch(pitch) - ;//* (inverseView && Freelook.getInstance().enabled.get() && Freelook.getInstance().isActive() ? -1 : 1); - this.yaw = Freelook.getInstance().yaw(yaw) - ;//+ (inverseView && Freelook.getInstance().enabled.get() && Freelook.getInstance().isActive() ? 180 : 0); + this.pitch = Freelook.getInstance().pitch(pitch); + this.yaw = Freelook.getInstance().yaw(yaw); } @ModifyArgs(method = "update", at = @At(value = "INVOKE", target = "net/minecraft/client/render/Camera.setRotation(FF)V", ordinal = 0)) diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java index 9f181acf0..a36c148eb 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java @@ -29,6 +29,7 @@ import net.minecraft.client.render.entity.TntEntityRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.TntEntity; +import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -45,7 +46,7 @@ private TntEntityRendererMixin(EntityRendererFactory.Context context) { private void axolotlclient$render(TntEntity entity, float yaw, float delta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, CallbackInfo ci) { if (TntTime.getInstance().enabled.get()) { - super.renderLabelIfPresent(entity, TntTime.getInstance().getFuseTime(entity.getFuse()), matrixStack, + super.renderLabelIfPresent(entity, (Text) TntTime.getInstance().getFuseTime(entity.getFuse()), matrixStack, vertexConsumerProvider, light); } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java b/1.20/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java deleted file mode 100644 index 640c8238c..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.freelook; - -import java.util.ArrayDeque; -import java.util.Deque; - -import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; -import io.github.axolotlclient.modules.AbstractCommonModule; -import io.github.axolotlclient.util.FeatureDisabler; -import io.github.axolotlclient.util.keybinds.KeyBinds; -import io.github.axolotlclient.util.options.ForceableBooleanOption; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.option.KeyBind; -import net.minecraft.client.option.Perspective; -import net.minecraft.entity.Entity; - -public class Freelook extends AbstractCommonModule { - - private static final Freelook INSTANCE = new Freelook(); - private static final KeyBind KEY = KeyBinds.getInstance().register(new KeyBind("key.freelook", InputUtil.KEY_V_CODE, "category.axolotlclient")); - private static final KeyBind KEY_ALT = KeyBinds.getInstance().register(new KeyBind("key.freelook.alt", InputUtil.UNKNOWN_KEY.getKeyCode(), "category.axolotlclient")); - public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); - private final MinecraftClient client = MinecraftClient.getInstance(); - private final OptionCategory category = OptionCategory.create("freelook"); - private final StringArrayOption mode = new StringArrayOption("mode", - new String[]{"snap_perspective", "freelook"}, - "freelook", value -> FeatureDisabler.update()); - private final BooleanOption invert = new BooleanOption("invert", false); - private final EnumOption perspective = new EnumOption<>("perspective", Perspective.class, - Perspective.THIRD_PERSON_BACK); - private final BooleanOption toggle = new BooleanOption("toggle", "freelook.toggle.tooltip", false); - private final EnumOption perspectiveAlt = new EnumOption<>("perspective.alt", Perspective.class, - Perspective.THIRD_PERSON_FRONT); - private final BooleanOption toggleAlt = new BooleanOption("toggle.alt", false); - private final WrappedValue active = new WrappedValue(), activeAlt = new WrappedValue(); - private float yaw, pitch; - private final Deque previousPerspectives = new ArrayDeque<>(); - - public static Freelook getInstance() { - return INSTANCE; - } - - @Override - public void init() { - category.add(enabled, mode, perspective, invert, toggle); - category.add(perspectiveAlt, toggleAlt); - AxolotlClient.config().addCategory(category); - } - - @Override - public void tick() { - if (!enabled.get() || client.currentScreen != null) return; - tickSet(toggle, KEY, perspective, active); - tickSet(toggleAlt, KEY_ALT, perspectiveAlt, activeAlt); - } - - private void tickSet(BooleanOption toggle, KeyBind key, EnumOption perspective, WrappedValue active) { - if (toggle.get()) { - if (key.wasPressed()) { - if (active.val) { - stop(active); - } else { - start(perspective.get(), active); - } - } - } else { - if (key.isPressed()) { - if (!active.val) { - start(perspective.get(), active); - } - } else if (active.val) { - stop(active); - } - } - } - - private void stop(WrappedValue active) { - active.val = false; - client.worldRenderer.scheduleTerrainUpdate(); - setPerspective(previousPerspectives.pop()); - } - - private void start(Perspective perspective, WrappedValue active) { - previousPerspectives.push(client.options.getPerspective()); - active.val = true; - setPerspective(perspective); - - Entity camera = client.getCameraEntity(); - - if (camera == null) - camera = client.player; - if (camera == null) - return; - - yaw = camera.getYaw(); - pitch = camera.getPitch(); - } - - private void setPerspective(Perspective perspective) { - client.options.setPerspective(perspective); - } - - public boolean consumeRotation(double dx, double dy) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return false; - - if (!invert.get()) - dy = -dy; - - if (MinecraftClient.getInstance().options.getPerspective().isFrontView() - || MinecraftClient.getInstance().options.getPerspective().isFirstPerson()) - dy *= -1; - - yaw += (float) (dx * 0.15F); - pitch += (float) (dy * 0.15F); - - if (pitch > 90) { - pitch = 90; - } else if (pitch < -90) { - pitch = -90; - } - - client.worldRenderer.scheduleTerrainUpdate(); - return true; - } - - public float yaw(float defaultValue) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return defaultValue; - - return yaw; - } - - public float pitch(float defaultValue) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return defaultValue; - - return pitch; - } - - public boolean needsDisabling() { - return mode.get().equals("freelook"); - } - - public boolean isActive() { - return active.val || activeAlt.val; - } - - private static class WrappedValue { - boolean val; - } -} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.20/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java deleted file mode 100644 index 38a478992..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.rpc; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.util.Util; -import net.minecraft.client.MinecraftClient; - -public class DiscordRPC extends RPCCommon { - private static DiscordRPC Instance; - private String currentWorld = ""; - - private DiscordRPC() { - super(AxolotlClient.LOGGER); - } - - public static DiscordRPC getInstance() { - if (Instance == null) - Instance = new DiscordRPC(); - return Instance; - } - - public void setWorld(String world) { - currentWorld = world; - } - - @Override - protected void createRichPresence() { - - String state = switch (showServerNameMode.get()) { - case "showIp" -> MinecraftClient.getInstance().world == null ? "In the menu" - : (MinecraftClient.getInstance().getCurrentServerEntry() == null ? "Singleplayer" - : MinecraftClient.getInstance().getCurrentServerEntry().address); - case "showName" -> MinecraftClient.getInstance().world == null ? "In the menu" - : (MinecraftClient.getInstance().getCurrentServerEntry() == null ? "Singleplayer" - : MinecraftClient.getInstance().getCurrentServerEntry().name); - default -> ""; - }; - - String details; - if (showActivity.get() && MinecraftClient.getInstance().getCurrentServerEntry() != null) { - details = (Util.getGame()); - } else if (showActivity.get() && !currentWorld.isEmpty()) { - details = (currentWorld); - currentWorld = ""; - } else { - details = ""; - } - - setRichPresence(createRichPresence(AxolotlClient.VERSION, state, details)); - } - - public void init() { - super.init(); - - AxolotlClient.config().addCategory(category); - } -} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java b/1.20/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java deleted file mode 100644 index 9301cd01d..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.tnttime; - -import java.text.DecimalFormat; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.IntegerOption; -import io.github.axolotlclient.modules.AbstractModule; -import io.github.axolotlclient.util.options.ForceableBooleanOption; -import lombok.Getter; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; - -public class TntTime extends AbstractModule { - - @Getter - private static final TntTime Instance = new TntTime(); - public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); - private final OptionCategory category = OptionCategory.create("tnttime"); - private final IntegerOption decimalPlaces = new IntegerOption("decimalplaces", 2, 0, 6); - private DecimalFormat format; - private int decimals; - - @Override - public void init() { - category.add(enabled, decimalPlaces); - AxolotlClient.config().rendering.add(category); - } - - @Override - public void tick() { - if (decimalPlaces.get() != decimals || format == null) { - StringBuilder string = new StringBuilder("#0"); - if (decimalPlaces.get() > 0) { - string.append("."); - string.append("0".repeat(Math.max(0, decimalPlaces.get()))); - } - format = new DecimalFormat(string.toString()); - decimals = decimalPlaces.get(); - } - } - - public Text getFuseTime(int time) { - float secs = time / 20F; - return Text.of(String.valueOf(format.format(secs))).copy() - .setStyle(Style.EMPTY.withColor(getCurrentColor(secs))); - } - - private Formatting getCurrentColor(float seconds) { - if (seconds > 7d) { - return Formatting.DARK_AQUA; - } else if (seconds > 6d) { - return Formatting.AQUA; - } else if (seconds > 4d) { - return Formatting.DARK_GREEN; - } else if (seconds > 3d) { - return Formatting.GREEN; - } else if (seconds > 2d) { - return Formatting.GOLD; - } else if (seconds > 1d) { - return Formatting.RED; - } else if (seconds > 0d) { - return Formatting.DARK_RED; - } else { - return Formatting.WHITE; - } - } -} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java b/1.20/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java index 54a5ab0fe..ed6741d31 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java @@ -22,62 +22,27 @@ package io.github.axolotlclient.util; -import java.util.HashMap; -import java.util.Locale; -import java.util.Objects; -import java.util.function.Supplier; - import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.modules.freelook.Freelook; -import io.github.axolotlclient.modules.hud.HudManager; -import io.github.axolotlclient.modules.hud.gui.hud.simple.ToggleSprintHud; -import io.github.axolotlclient.util.options.ForceableBooleanOption; +import lombok.Getter; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.util.Identifier; -import net.minecraft.util.Util; - -public class FeatureDisabler { - - private static final HashMap disabledServers = new HashMap<>(); - private static final HashMap> conditions = new HashMap<>(); - - private static final Supplier NONE = () -> true; - private static final Identifier channelName = new Identifier("axolotlclient", "block_mods"); - // Features that can be disabled on the server's behalf - // If something should be added here, feel free to ping us via your favorite way. - private static final HashMap features = Util.make(() -> { - HashMap features = new HashMap<>(); - features.put("freelook", Freelook.getInstance().enabled); - features.put("timechanger", AxolotlClient.config().timeChangerEnabled); - features.put("lowfire", AxolotlClient.config().lowFire); - features.put("fullbright", AxolotlClient.config().fullBright); - return features; - }); - private static String currentAddress = ""; - public static void init() { - setServers(AxolotlClient.config().fullBright, NONE, "gommehd"); - setServers(AxolotlClient.config().lowFire, NONE, "gommehd"); - setServers(Freelook.getInstance().enabled, () -> Freelook.getInstance().needsDisabling(), "hypixel", "mineplex", "gommehd", "nucleoid", "mccisland"); - setServers(((ToggleSprintHud) HudManager.getInstance().get(ToggleSprintHud.ID)).toggleSneak, NONE, "hypixel"); - - ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { - if (handler.getServerInfo() != null) { - onServerJoin(Objects.requireNonNull(handler.getServerInfo()).address); - } - }); - ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> clear()); +public class FeatureDisabler extends FeatureDisablerCommon { + @Getter + private static final FeatureDisablerCommon instance = new FeatureDisabler(); + @Override + protected void registerChannel() { ClientPlayConnectionEvents.INIT.register((handler0, client0) -> - ClientPlayNetworking.registerGlobalReceiver(channelName, (client, handler, buf, responseSender) -> { + ClientPlayNetworking.registerGlobalReceiver((Identifier) CHANNEL_NAME, (client, handler, buf, responseSender) -> { JsonArray array = JsonParser.parseString(buf.readString()).getAsJsonArray(); for (JsonElement element : array) { try { - features.get(element.getAsString()).setForceOff(true, "ban_reason"); + FEATURES.get(element.getAsString()).setForceOff(true, "ban_reason"); } catch (Exception e) { AxolotlClient.LOGGER.error("Failed to disable " + element.getAsString() + "!"); } @@ -85,37 +50,4 @@ public static void init() { }) ); } - - private static void setServers(ForceableBooleanOption option, Supplier condition, String... servers) { - disabledServers.put(option, servers); - conditions.put(option, condition); - } - - public static void onServerJoin(String address) { - currentAddress = address; - update(); - } - - public static void clear() { - disabledServers.keySet().forEach(option -> option.setForceOff(false, "")); - features.values().forEach(option -> option.setForceOff(false, "")); - } - - public static void update() { - disabledServers.forEach((option, strings) -> disableOption(option, strings, currentAddress)); - } - - private static void disableOption(ForceableBooleanOption option, String[] servers, String currentServer) { - boolean ban = false; - for (String s : servers) { - if (currentServer.toLowerCase(Locale.ROOT).contains(s.toLowerCase(Locale.ROOT))) { - ban = conditions.get(option).get(); - break; - } - } - - if (option.isForceOff() != ban) { - option.setForceOff(ban, "ban_reason"); - } - } } diff --git a/1.20/src/main/resources/fabric.mod.json b/1.20/src/main/resources/fabric.mod.json index d49659ed1..cf25a4a24 100644 --- a/1.20/src/main/resources/fabric.mod.json +++ b/1.20/src/main/resources/fabric.mod.json @@ -75,7 +75,7 @@ "io/github/axolotlclient/bridge/key/AxoKeybinding" ], "net/minecraft/class_315": [ - "io/github/axolotlclient/bridge/key/AxoClientKeybinds" + "io/github/axolotlclient/bridge/AxoGameOptions" ], "net/minecraft/class_3675\u0024class_306": [ "io/github/axolotlclient/bridge/key/AxoKey" diff --git a/1.21/src/main/java/io/github/axolotlclient/AxolotlClient.java b/1.21/src/main/java/io/github/axolotlclient/AxolotlClient.java index 27a15a45d..36003f424 100644 --- a/1.21/src/main/java/io/github/axolotlclient/AxolotlClient.java +++ b/1.21/src/main/java/io/github/axolotlclient/AxolotlClient.java @@ -31,18 +31,15 @@ import io.github.axolotlclient.modules.ModuleLoader; import io.github.axolotlclient.modules.auth.Auth; import io.github.axolotlclient.modules.blur.MotionBlur; -import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hypixel.HypixelMods; import io.github.axolotlclient.modules.particles.Particles; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; -import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.tablist.Tablist; -import io.github.axolotlclient.modules.tnttime.TntTime; import io.github.axolotlclient.modules.zoom.Zoom; import io.github.axolotlclient.util.FeatureDisabler; +import io.github.axolotlclient.util.FeatureDisablerCommon; import io.github.axolotlclient.util.Logger; import io.github.axolotlclient.util.LoggerImpl; import io.github.axolotlclient.util.notifications.Notifications; @@ -62,12 +59,9 @@ private void addBuiltinModules() { registerModule(HypixelMods.getInstance()); registerModule(MotionBlur.getInstance()); registerModule(ScrollableTooltips.getInstance()); - registerModule(DiscordRPC.getInstance()); - registerModule(Freelook.getInstance()); - registerModule(TntTime.getInstance()); + registerModule(Particles.getInstance()); registerModule(ScreenshotUtils.getInstance()); - registerModule(BeaconBeam.getInstance()); registerModule(Tablist.getInstance()); registerModule(Auth.getInstance()); registerModule(APIOptions.getInstance()); @@ -92,8 +86,8 @@ public void onInitializeClient() { } @Override - protected void initFeatureDisabler() { - FeatureDisabler.init(); + protected FeatureDisablerCommon getFeatureDisabler() { + return new FeatureDisabler(); } @Override diff --git a/1.21/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java b/1.21/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java index 06d0f14ab..78e040f76 100644 --- a/1.21/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java +++ b/1.21/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.bridge.impl; +import java.util.Objects; + import com.mojang.brigadier.CommandDispatcher; import io.github.axolotlclient.bridge.events.Events; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; @@ -52,6 +54,9 @@ public Identifier getFabricId() { return Identifier.of("axolotlclient", "bridge/resource_listener"); } }); + + ClientPlayConnectionEvents.INIT.register((handler, client) -> + Events.BEGIN_JOIN_SERVER.invoker().accept(new Events.ServerJoinInfo(Objects.requireNonNull(handler.getServerInfo()).address))); ClientPlayConnectionEvents.JOIN.register((clientPlayNetworkHandler, sender, minecraftClient) -> Events.CONNECTION_PLAY_READY.invoker().run()); ClientPlayConnectionEvents.DISCONNECT.register((clientPlayNetworkHandler, minecraftClient) -> Events.DISCONNECT.invoker().run()); diff --git a/1.21/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java b/1.21/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java index 81920386b..4ac8d407d 100644 --- a/1.21/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java +++ b/1.21/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java @@ -22,14 +22,17 @@ package io.github.axolotlclient.bridge.mixin; -import java.util.Collection; -import java.util.Optional; +import java.util.*; +import java.util.stream.Collectors; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import io.github.axolotlclient.bridge.AxoMinecraftClient; import io.github.axolotlclient.bridge.AxoPlayerListEntry; import io.github.axolotlclient.bridge.AxoSession; +import io.github.axolotlclient.bridge.entity.AxoEntity; import io.github.axolotlclient.bridge.entity.AxoPlayer; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; +import io.github.axolotlclient.bridge.AxoGameOptions; import io.github.axolotlclient.bridge.render.AxoFont; import io.github.axolotlclient.bridge.resource.AxoResourceManager; import io.github.axolotlclient.bridge.util.AxoText; @@ -41,9 +44,12 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ServerInfo; import net.minecraft.client.option.GameOptions; +import net.minecraft.client.render.WorldRenderer; import net.minecraft.client.util.Session; import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; import net.minecraft.resource.ResourceManager; +import net.minecraft.scoreboard.*; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; @@ -88,6 +94,14 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { @Shadow public abstract ResourceManager getResourceManager(); + @Shadow + @Final + public WorldRenderer worldRenderer; + + @Shadow + @Nullable + public Entity cameraEntity; + @Override public @Nullable AxoPlayer br$getPlayer() { return player; @@ -105,7 +119,7 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { } @Override - public AxoClientKeybinds br$getKeybinds() { + public AxoGameOptions br$getGameOptions() { return options; } @@ -124,6 +138,11 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { return Optional.ofNullable(getCurrentServerEntry()).map(x -> x.address).orElse(null); } + @Override + public String br$getServerName() { + return Optional.ofNullable(getCurrentServerEntry()).map(x -> x.name).orElse(null); + } + @Override public Collection br$getOnlinePlayers() { return player.networkHandler.getPlayerList(); @@ -159,4 +178,55 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { public Object br$getScreen() { return currentScreen; } + + @Override + public void br$notifyLevelRenderer() { + worldRenderer.scheduleTerrainUpdate(); + } + + @Override + public AxoEntity br$getCameraEntity() { + return cameraEntity; + } + + @Override + public List br$getSidebar() { + List lines = new ArrayList<>(); + MinecraftClient client = MinecraftClient.getInstance(); + if (client.world == null) + return lines; + + Scoreboard scoreboard = client.world.getScoreboard(); + if (scoreboard == null) + return lines; + ScoreboardObjective sidebar = scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.SIDEBAR); + if (sidebar == null) + return lines; + + Collection scores = scoreboard.getEntriesForObjective(sidebar); + List list = scores.stream().filter( + input -> input != null && input.owner() != null && !input.isHidden()) + .collect(Collectors.toList()); + + if (list.size() > 15) { + scores = Lists.newArrayList(Iterables.skip(list, scores.size() - 15)); + } else { + scores = list; + } + + for (ScoreboardEntry score : scores) { + Team team = scoreboard.getPlayerTeam(score.owner()); + if (team == null) + return lines; + String text = team.getPrefix().getString() + team.getSuffix().getString(); + if (!text.trim().isEmpty()) + lines.add(text); + } + + lines.add(sidebar.getDisplayName().getString()); + Collections.reverse(lines); + + return lines; + } + } diff --git a/1.21/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java b/1.21/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java index 782cc5c68..4a3d07b85 100644 --- a/1.21/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java +++ b/1.21/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java @@ -22,16 +22,18 @@ package io.github.axolotlclient.bridge.mixin.key; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; +import io.github.axolotlclient.bridge.AxoGameOptions; +import io.github.axolotlclient.bridge.AxoPerspective; import io.github.axolotlclient.bridge.key.AxoKeybinding; import net.minecraft.client.option.GameOptions; import net.minecraft.client.option.KeyBind; +import net.minecraft.client.option.Perspective; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @Mixin(GameOptions.class) -public abstract class GameOptionsMixin implements AxoClientKeybinds { +public abstract class GameOptionsMixin implements AxoGameOptions { @Shadow @Final public KeyBind sprintKey; @@ -48,6 +50,12 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { @Final public KeyBind useKey; + @Shadow + public abstract Perspective getPerspective(); + + @Shadow + public abstract void setPerspective(Perspective perspective); + @Override public AxoKeybinding br$getSprintKeybind() { return sprintKey; @@ -67,4 +75,22 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { public AxoKeybinding br$getUseKey() { return useKey; } + + @Override + public AxoPerspective br$getCameraType() { + return switch (getPerspective()) { + case FIRST_PERSON -> AxoPerspective.FIRST_PERSON; + case THIRD_PERSON_BACK -> AxoPerspective.THIRD_PERSON_BACK; + case THIRD_PERSON_FRONT -> AxoPerspective.THIRD_PERSON_FRONT; + }; + } + + @Override + public void br$setCameraType(AxoPerspective perspective) { + setPerspective(switch (perspective) { + case FIRST_PERSON -> Perspective.FIRST_PERSON; + case THIRD_PERSON_BACK -> Perspective.THIRD_PERSON_BACK; + case THIRD_PERSON_FRONT -> Perspective.THIRD_PERSON_FRONT; + }); + } } diff --git a/1.21/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.21/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index ca8e6539f..9a8fc389a 100644 --- a/1.21/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.21/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -49,22 +49,8 @@ import net.minecraft.client.texture.NativeImageBackedTexture; public class AxolotlClientConfig extends AxolotlClientConfigCommon { - - public final BooleanOption showOwnNametag = new BooleanOption("showOwnNametag", false); - public final BooleanOption useShadows = new BooleanOption("useShadows", false); - public final BooleanOption nametagBackground = new BooleanOption("nametagBackground", true); - - public final BooleanOption showBadges = new BooleanOption("showBadges", true); - public final BooleanOption customBadge = new BooleanOption("customBadge", false); - public final StringOption badgeText = new StringOption("badgeText", ""); - - public final ForceableBooleanOption timeChangerEnabled = new ForceableBooleanOption("enabled", false); - public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); - public final ForceableBooleanOption fullBright = new ForceableBooleanOption("fullBright", false); - public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); - public final ForceableBooleanOption lowFire = new ForceableBooleanOption("lowFire", false); + public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", new Color(255, 0, 0, 77), value -> { @@ -90,58 +76,23 @@ public class AxolotlClientConfig extends AxolotlClientConfigCommon { RenderSystem.activeTexture(33984); } }); - public final BooleanOption minimalViewBob = new BooleanOption("minimalViewBob", false); - public final BooleanOption noHurtCam = new BooleanOption("noHurtCam", false); + public final BooleanOption flatItems = new BooleanOption("flatItems", false); public final ColorOption loadingScreenColor = new ColorOption("loadingBgColor", new Color(239, 50, 61, 255)); public final BooleanOption nightMode = new BooleanOption("nightMode", false); - public final BooleanOption customWindowTitle = new BooleanOption("customWindowTitle", true); - - public final BooleanOption enableCustomOutlines = new BooleanOption("enabled", false); - public final ColorOption outlineColor = new ColorOption("color", Color.parse("#DD000000")); - - public final BooleanOption noRain = new BooleanOption("noRain", false); public final GenericOption openCredits = new GenericOption("Credits", "Open Credits", () -> MinecraftClient.getInstance().setScreen(new CreditsScreen(MinecraftClient.getInstance().currentScreen)) ); - public final BooleanOption debugLogOutput = new BooleanOption("debugLogOutput", false); - public final BooleanOption creditsBGM = new BooleanOption("creditsBGM", true); - - public final OptionCategory general = OptionCategory.create("general"); - public final OptionCategory nametagOptions = OptionCategory.create("nametagOptions"); - public final OptionCategory rendering = OptionCategory.create("rendering"); - public final OptionCategory outlines = OptionCategory.create("blockOutlines"); - public final OptionCategory timeChanger = OptionCategory.create("timeChanger"); @Getter private final List> options = new ArrayList<>(); public AxolotlClientConfig() { - config.add(general); - config.add(nametagOptions); - config.add(rendering); - - rendering.add(outlines); - - nametagOptions.add(showOwnNametag); - nametagOptions.add(useShadows); - nametagOptions.add(nametagBackground); - - nametagOptions.add(showBadges); - nametagOptions.add(customBadge); - nametagOptions.add(badgeText); - general.add(loadingScreenColor); general.add(nightMode); - general.add(customWindowTitle); general.add(openCredits); - general.add(debugLogOutput); - - general.add(datetimeFormat); - general.add(titleScreenOptionButtonMode); - general.add(gameMenuScreenOptionButtonMode); ConfigUI.getInstance().runWhenLoaded(() -> { general.getOptions().removeIf(o -> "configStyle".equals(o.getName())); @@ -165,26 +116,9 @@ public AxolotlClientConfig() { }); rendering.add(customSky, - dynamicFOV, - fullBright, - removeVignette, - lowFire, lowShield, hitColor, - minimalViewBob, - flatItems, - noHurtCam); - - timeChanger.add(timeChangerEnabled); - timeChanger.add(customTime); - rendering.add(timeChanger); - - outlines.add(enableCustomOutlines); - outlines.add(outlineColor); - - rendering.add(noRain); - - hidden.add(creditsBGM, someNiceBackground); + flatItems); general.add(new GenericOption("profiles.title", "profiles.configure", () -> MinecraftClient.getInstance().setScreen(new ProfilesScreen(MinecraftClient.getInstance().currentScreen))), false); diff --git a/1.21/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java b/1.21/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java index e8824406a..f5744fef7 100644 --- a/1.21/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java +++ b/1.21/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java @@ -22,7 +22,7 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; +import io.github.axolotlclient.modules.render.BeaconBeam; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer; import net.minecraft.client.util.math.MatrixStack; diff --git a/1.21/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java b/1.21/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java index e765b1f82..4bb0a3ef7 100644 --- a/1.21/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java +++ b/1.21/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java @@ -29,6 +29,7 @@ import net.minecraft.client.render.entity.TntEntityRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.TntEntity; +import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -45,7 +46,7 @@ private TntEntityRendererMixin(EntityRendererFactory.Context context) { private void axolotlclient$render(TntEntity entity, float yaw, float delta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, CallbackInfo ci) { if (TntTime.getInstance().enabled.get()) { - super.renderLabelIfPresent(entity, TntTime.getInstance().getFuseTime(entity.getFuse()), matrixStack, + super.renderLabelIfPresent(entity, (Text) TntTime.getInstance().getFuseTime(entity.getFuse()), matrixStack, vertexConsumerProvider, light, 0); } } diff --git a/1.21/src/main/java/io/github/axolotlclient/mixin/WorldListWidgetEntryMixin.java b/1.21/src/main/java/io/github/axolotlclient/mixin/WorldListWidgetEntryMixin.java index 964bd0541..991a21d03 100644 --- a/1.21/src/main/java/io/github/axolotlclient/mixin/WorldListWidgetEntryMixin.java +++ b/1.21/src/main/java/io/github/axolotlclient/mixin/WorldListWidgetEntryMixin.java @@ -37,7 +37,7 @@ public abstract class WorldListWidgetEntryMixin { @Shadow @Final - private WorldSaveSummary summary; + WorldSaveSummary summary; @Inject(method = "play", at = @At("HEAD")) private void axolotlclient$onSPWorldJoin(CallbackInfo ci) { diff --git a/1.21/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java b/1.21/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java deleted file mode 100644 index 87b595682..000000000 --- a/1.21/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.freelook; - -import java.util.ArrayDeque; -import java.util.Deque; - -import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; -import io.github.axolotlclient.modules.AbstractModule; -import io.github.axolotlclient.util.FeatureDisabler; -import io.github.axolotlclient.util.keybinds.KeyBinds; -import io.github.axolotlclient.util.options.ForceableBooleanOption; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.option.KeyBind; -import net.minecraft.client.option.Perspective; -import net.minecraft.entity.Entity; - -public class Freelook extends AbstractModule { - - private static final Freelook INSTANCE = new Freelook(); - private static final KeyBind KEY = KeyBinds.getInstance().register(new KeyBind("key.freelook", InputUtil.KEY_V_CODE, "category.axolotlclient")); - private static final KeyBind KEY_ALT = KeyBinds.getInstance().register(new KeyBind("key.freelook.alt", InputUtil.UNKNOWN_KEY.getKeyCode(), "category.axolotlclient")); - public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); - private final MinecraftClient client = MinecraftClient.getInstance(); - private final OptionCategory category = OptionCategory.create("freelook"); - private final StringArrayOption mode = new StringArrayOption("mode", - new String[]{"snap_perspective", "freelook"}, - "freelook", value -> FeatureDisabler.update()); - private final BooleanOption invert = new BooleanOption("invert", false); - private final EnumOption perspective = new EnumOption<>("perspective", Perspective.class, - Perspective.THIRD_PERSON_BACK); - private final BooleanOption toggle = new BooleanOption("toggle", "freelook.toggle.tooltip", false); - private final EnumOption perspectiveAlt = new EnumOption<>("perspective.alt", Perspective.class, - Perspective.THIRD_PERSON_FRONT); - private final BooleanOption toggleAlt = new BooleanOption("toggle.alt", false); - private final WrappedValue active = new WrappedValue(), activeAlt = new WrappedValue(); - private float yaw, pitch; - private final Deque previousPerspectives = new ArrayDeque<>(); - - public static Freelook getInstance() { - return INSTANCE; - } - - @Override - public void init() { - category.add(enabled, mode, perspective, invert, toggle); - category.add(perspectiveAlt, toggleAlt); - AxolotlClient.config().addCategory(category); - } - - @Override - public void tick() { - if (!enabled.get() || client.currentScreen != null) return; - tickSet(toggle, KEY, perspective, active); - tickSet(toggleAlt, KEY_ALT, perspectiveAlt, activeAlt); - } - - private void tickSet(BooleanOption toggle, KeyBind key, EnumOption perspective, WrappedValue active) { - if (toggle.get()) { - if (key.wasPressed()) { - if (active.val) { - stop(active); - } else { - start(perspective.get(), active); - } - } - } else { - if (key.isPressed()) { - if (!active.val) { - start(perspective.get(), active); - } - } else if (active.val) { - stop(active); - } - } - } - - private void stop(WrappedValue active) { - active.val = false; - client.worldRenderer.scheduleTerrainUpdate(); - setPerspective(previousPerspectives.pop()); - } - - private void start(Perspective perspective, WrappedValue active) { - previousPerspectives.push(client.options.getPerspective()); - active.val = true; - setPerspective(perspective); - - Entity camera = client.getCameraEntity(); - - if (camera == null) - camera = client.player; - if (camera == null) - return; - - yaw = camera.getYaw(); - pitch = camera.getPitch(); - } - - private void setPerspective(Perspective perspective) { - MinecraftClient.getInstance().options.setPerspective(perspective); - } - - public boolean consumeRotation(double dx, double dy) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return false; - - if (!invert.get()) - dy = -dy; - - if (MinecraftClient.getInstance().options.getPerspective().isFrontView() - || MinecraftClient.getInstance().options.getPerspective().isFirstPerson()) - dy *= -1; - - yaw += (float) (dx * 0.15F); - pitch += (float) (dy * 0.15F); - - if (pitch > 90) { - pitch = 90; - } else if (pitch < -90) { - pitch = -90; - } - - client.worldRenderer.scheduleTerrainUpdate(); - return true; - } - - public float yaw(float defaultValue) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return defaultValue; - - return yaw; - } - - public float pitch(float defaultValue) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return defaultValue; - - return pitch; - } - - public boolean needsDisabling() { - return mode.get().equals("freelook"); - } - - public boolean isActive() { - return active.val || activeAlt.val; - } - - private static class WrappedValue { - boolean val; - } -} diff --git a/1.21/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java b/1.21/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java deleted file mode 100644 index 2901b01bb..000000000 --- a/1.21/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.renderOptions; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.modules.AbstractModule; -import lombok.Getter; - -public class BeaconBeam extends AbstractModule { - - @Getter - private final static BeaconBeam Instance = new BeaconBeam(); - - private final BooleanOption showBeaconBeams = new BooleanOption("showBeaconBeams", true); - private final BooleanOption showEndGatewayBeams = new BooleanOption("showEndGatewayBeams", true); - - private final OptionCategory beams = OptionCategory.create("beams"); - - @Override - public void init() { - beams.add(showBeaconBeams, showEndGatewayBeams); - - AxolotlClient.config().rendering.add(beams); - } - - public boolean showBeam(boolean endGateway) { - return endGateway ? showEndGatewayBeams.get() : showBeaconBeams.get(); - } -} diff --git a/1.21/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.21/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java deleted file mode 100644 index 38a478992..000000000 --- a/1.21/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.rpc; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.util.Util; -import net.minecraft.client.MinecraftClient; - -public class DiscordRPC extends RPCCommon { - private static DiscordRPC Instance; - private String currentWorld = ""; - - private DiscordRPC() { - super(AxolotlClient.LOGGER); - } - - public static DiscordRPC getInstance() { - if (Instance == null) - Instance = new DiscordRPC(); - return Instance; - } - - public void setWorld(String world) { - currentWorld = world; - } - - @Override - protected void createRichPresence() { - - String state = switch (showServerNameMode.get()) { - case "showIp" -> MinecraftClient.getInstance().world == null ? "In the menu" - : (MinecraftClient.getInstance().getCurrentServerEntry() == null ? "Singleplayer" - : MinecraftClient.getInstance().getCurrentServerEntry().address); - case "showName" -> MinecraftClient.getInstance().world == null ? "In the menu" - : (MinecraftClient.getInstance().getCurrentServerEntry() == null ? "Singleplayer" - : MinecraftClient.getInstance().getCurrentServerEntry().name); - default -> ""; - }; - - String details; - if (showActivity.get() && MinecraftClient.getInstance().getCurrentServerEntry() != null) { - details = (Util.getGame()); - } else if (showActivity.get() && !currentWorld.isEmpty()) { - details = (currentWorld); - currentWorld = ""; - } else { - details = ""; - } - - setRichPresence(createRichPresence(AxolotlClient.VERSION, state, details)); - } - - public void init() { - super.init(); - - AxolotlClient.config().addCategory(category); - } -} diff --git a/1.21/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java b/1.21/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java index 66c3279ab..b2e688c99 100644 --- a/1.21/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java +++ b/1.21/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java @@ -22,124 +22,52 @@ package io.github.axolotlclient.util; -import java.util.HashMap; import java.util.List; -import java.util.Locale; -import java.util.Objects; -import java.util.function.Supplier; import com.mojang.serialization.Codec; import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.modules.freelook.Freelook; -import io.github.axolotlclient.modules.hud.HudManager; -import io.github.axolotlclient.modules.hud.gui.hud.simple.ToggleSprintHud; import io.github.axolotlclient.util.options.ForceableBooleanOption; import io.netty.buffer.ByteBuf; +import lombok.Getter; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; -import net.minecraft.network.PacketByteBuf; import net.minecraft.network.codec.PacketCodec; import net.minecraft.network.codec.PacketCodecs; import net.minecraft.network.packet.payload.CustomPayload; import net.minecraft.util.Identifier; -import net.minecraft.util.Util; -public class FeatureDisabler { +public class FeatureDisabler extends FeatureDisablerCommon { + @Getter + private final static FeatureDisabler instance = new FeatureDisabler(); - private static final HashMap disabledServers = new HashMap<>(); - private static final HashMap> conditions = new HashMap<>(); + private static final CustomPayload.Id CHANNEL_ID = new CustomPayload.Id<>((Identifier) CHANNEL_NAME); - private static final Supplier NONE = () -> true; - private static final CustomPayload.Id channelId = new CustomPayload.Id<>(Identifier.of("axolotlclient", "block_mods")); - // Features that can be disabled on the server's behalf - // If something should be added here, feel free to ping us via your favorite way. - private static final HashMap features = Util.make(() -> { - HashMap features = new HashMap<>(); - features.put("freelook", Freelook.getInstance().enabled); - features.put("timechanger", AxolotlClient.config().timeChangerEnabled); - features.put("lowfire", AxolotlClient.config().lowFire); - features.put("fullbright", AxolotlClient.config().fullBright); - return features; - }); - private static String currentAddress = ""; - - public static void init() { - setServers(AxolotlClient.config().fullBright, NONE, "gommehd"); - setServers(AxolotlClient.config().lowFire, NONE, "gommehd"); - setServers(Freelook.getInstance().enabled, () -> Freelook.getInstance().needsDisabling(), "hypixel", "mineplex", "gommehd", "nucleoid", "mccisland"); - setServers(((ToggleSprintHud) HudManager.getInstance().get(ToggleSprintHud.ID)).toggleSneak, NONE, "hypixel"); - - ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { - if (handler.getServerInfo() != null) { - onServerJoin(Objects.requireNonNull(handler.getServerInfo()).address); - } - }); - ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> clear()); - - PayloadTypeRegistry.playS2C().register(channelId, FeaturePayload.CODEC); + @Override + protected void registerChannel() { + PayloadTypeRegistry.playS2C().register(CHANNEL_ID, FeaturePayload.CODEC); ClientPlayConnectionEvents.INIT.register((handler0, client0) -> { - ClientPlayNetworking.registerGlobalReceiver(channelId, (payload, ctx) -> { - for (String feature : payload.features) { - try { - ForceableBooleanOption e = features.get(feature); - e.setForceOff(true, "ban_reason"); - } catch (Exception e) { - AxolotlClient.LOGGER.error("Failed to disable " + feature + "!"); - } + ClientPlayNetworking.registerGlobalReceiver(CHANNEL_ID, (payload, ctx) -> { + for (String feature : payload.features) { + try { + ForceableBooleanOption e = FEATURES.get(feature); + e.setForceOff(true, "ban_reason"); + } catch (Exception e) { + AxolotlClient.LOGGER.error("Failed to disable " + feature + "!"); } - }); - } - ); - } - - private static void setServers(ForceableBooleanOption option, Supplier condition, String... servers) { - disabledServers.put(option, servers); - conditions.put(option, condition); - } - - public static void onServerJoin(String address) { - currentAddress = address; - update(); - } - - public static void clear() { - disabledServers.keySet().forEach(option -> option.setForceOff(false, "")); - features.values().forEach(option -> option.setForceOff(false, "")); - } - - public static void update() { - disabledServers.forEach((option, strings) -> disableOption(option, strings, currentAddress)); - } - - private static void disableOption(ForceableBooleanOption option, String[] servers, String currentServer) { - boolean ban = false; - for (String s : servers) { - if (currentServer.toLowerCase(Locale.ROOT).contains(s.toLowerCase(Locale.ROOT))) { - ban = conditions.get(option).get(); - break; - } - } - - if (option.isForceOff() != ban) { - option.setForceOff(ban, "ban_reason"); - } + } + }); + }); } private record FeaturePayload(List features) implements CustomPayload { - public static final PacketCodec CODEC = PacketCodecs.fromCodec(Codec.STRING.listOf().xmap(FeaturePayload::new, FeaturePayload::features)); - - private FeaturePayload(PacketByteBuf buf) { - this(buf.readList(PacketByteBuf::readString)); - } - - private void write(PacketByteBuf buf) { - buf.writeCollection(this.features, PacketByteBuf::writeString); - } + public static final PacketCodec CODEC = PacketCodecs.fromCodec( + Codec.STRING.listOf().xmap(FeaturePayload::new, FeaturePayload::features) + ); @Override public Id getId() { - return channelId; + return CHANNEL_ID; } } } diff --git a/1.21/src/main/resources/fabric.mod.json b/1.21/src/main/resources/fabric.mod.json index 64ffc50b6..b5d2bf5a0 100644 --- a/1.21/src/main/resources/fabric.mod.json +++ b/1.21/src/main/resources/fabric.mod.json @@ -78,7 +78,7 @@ "io/github/axolotlclient/bridge/key/AxoKeybinding" ], "net/minecraft/class_315": [ - "io/github/axolotlclient/bridge/key/AxoClientKeybinds" + "io/github/axolotlclient/bridge/AxoGameOptions" ], "net/minecraft/class_3675\u0024class_306": [ "io/github/axolotlclient/bridge/key/AxoKey" diff --git a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClient.java b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClient.java index 2e493f98a..6706f971e 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClient.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/AxolotlClient.java @@ -33,20 +33,17 @@ import io.github.axolotlclient.modules.auth.Auth; import io.github.axolotlclient.modules.blur.MenuBlur; import io.github.axolotlclient.modules.blur.MotionBlur; -import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hypixel.HypixelMods; import io.github.axolotlclient.modules.particles.Particles; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; -import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.modules.tablist.Tablist; -import io.github.axolotlclient.modules.tnttime.TntTime; import io.github.axolotlclient.modules.unfocusedFpsLimiter.UnfocusedFpsLimiter; import io.github.axolotlclient.modules.zoom.Zoom; import io.github.axolotlclient.util.FeatureDisabler; +import io.github.axolotlclient.util.FeatureDisablerCommon; import io.github.axolotlclient.util.Logger; import io.github.axolotlclient.util.LoggerImpl; import io.github.axolotlclient.util.notifications.Notifications; @@ -68,12 +65,9 @@ private void addBuiltinModules() { registerModule(MotionBlur.getInstance()); registerModule(MenuBlur.getInstance()); registerModule(ScrollableTooltips.getInstance()); - registerModule(DiscordRPC.getInstance()); - registerModule(Freelook.getInstance()); - registerModule(TntTime.getInstance()); + registerModule(Particles.getInstance()); registerModule(ScreenshotUtils.getInstance()); - registerModule(BeaconBeam.getInstance()); registerModule(UnfocusedFpsLimiter.getInstance()); registerModule(Tablist.getInstance()); registerModule(Auth.getInstance()); @@ -101,8 +95,8 @@ public void onInitializeClient() { } @Override - protected void initFeatureDisabler() { - FeatureDisabler.init(); + protected FeatureDisablerCommon getFeatureDisabler() { + return FeatureDisabler.getInstance(); } @Override diff --git a/1.8.9/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java index 01466aa16..89ae11715 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java @@ -22,17 +22,18 @@ package io.github.axolotlclient.bridge.mixin; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Optional; +import java.util.*; +import java.util.stream.Collectors; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; +import io.github.axolotlclient.bridge.AxoGameOptions; import io.github.axolotlclient.bridge.AxoMinecraftClient; import io.github.axolotlclient.bridge.AxoPlayerListEntry; import io.github.axolotlclient.bridge.AxoSession; +import io.github.axolotlclient.bridge.entity.AxoEntity; import io.github.axolotlclient.bridge.entity.AxoPlayer; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; import io.github.axolotlclient.bridge.render.AxoFont; import io.github.axolotlclient.bridge.resource.AxoResourceManager; import io.github.axolotlclient.bridge.util.AxoText; @@ -45,8 +46,14 @@ import net.minecraft.client.options.GameOptions; import net.minecraft.client.options.ServerListEntry; import net.minecraft.client.render.TextRenderer; +import net.minecraft.client.render.world.WorldRenderer; import net.minecraft.client.resource.manager.ResourceManager; import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; +import net.minecraft.scoreboard.ScoreboardScore; +import net.minecraft.scoreboard.team.Team; import net.minecraft.text.Text; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -90,6 +97,15 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { @Shadow public abstract ListenableFuture submit(Runnable runnable); + @Shadow + public WorldRenderer worldRenderer; + + @Shadow + private Entity camera; + + @Shadow + private String serverAddress; + @Override public @Nullable AxoPlayer br$getPlayer() { return player; @@ -107,7 +123,7 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { @Override - public AxoClientKeybinds br$getKeybinds() { + public AxoGameOptions br$getGameOptions() { return options; } @@ -123,7 +139,16 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { @Override public String br$getServerAddress() { - return Optional.ofNullable(getCurrentServerEntry()).map(x -> x.address).orElse(null); + return Optional.ofNullable(getCurrentServerEntry()) + .map(x -> x.address) + .orElse(serverAddress); + } + + @Override + public String br$getServerName() { + return Optional.ofNullable(getCurrentServerEntry()) + .map(x -> x.name) + .orElse(null); } @Override @@ -163,4 +188,54 @@ public void execute(@NotNull Runnable command) { public Object br$getScreen() { return screen; } + + @Override + public void br$notifyLevelRenderer() { + worldRenderer.onViewChanged(); + } + + @Override + public AxoEntity br$getCameraEntity() { + return camera; + } + + @Override + public List br$getSidebar() { + List lines = new ArrayList<>(); + Minecraft client = Minecraft.getInstance(); + if (client.world == null) + return lines; + + Scoreboard scoreboard = client.world.getScoreboard(); + if (scoreboard == null) + return lines; + ScoreboardObjective sidebar = scoreboard.getDisplayObjective(1); + if (sidebar == null) + return lines; + + Collection scores = scoreboard.getScores(sidebar); + List list = scores.stream().filter( + input -> input != null && input.getOwner() != null && !input.getOwner().startsWith("#")) + .collect(Collectors.toList()); + + if (list.size() > 15) { + scores = Lists.newArrayList(Iterables.skip(list, scores.size() - 15)); + } else { + scores = list; + } + + for (ScoreboardScore score : scores) { + Team team = scoreboard.getTeamOfMember(score.getOwner()); + if (team == null) + return lines; + String text = team.getPrefix() + team.getSuffix(); + if (!text.trim().isEmpty()) + lines.add(text); + } + + lines.add(sidebar.getDisplayName()); + Collections.reverse(lines); + + return lines; + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java index ea4aac579..82044e903 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java @@ -22,7 +22,8 @@ package io.github.axolotlclient.bridge.mixin.key; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; +import io.github.axolotlclient.bridge.AxoGameOptions; +import io.github.axolotlclient.bridge.AxoPerspective; import io.github.axolotlclient.bridge.key.AxoKeybinding; import net.minecraft.client.options.GameOptions; import net.minecraft.client.options.KeyBinding; @@ -30,7 +31,7 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(GameOptions.class) -public abstract class GameOptionsMixin implements AxoClientKeybinds { +public abstract class GameOptionsMixin implements AxoGameOptions { @Shadow public KeyBinding sprintKey; @@ -43,6 +44,9 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { @Shadow public KeyBinding useKey; + @Shadow + public int perspective; + @Override public AxoKeybinding br$getSprintKeybind() { return sprintKey; @@ -62,4 +66,14 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { public AxoKeybinding br$getUseKey() { return useKey; } + + @Override + public AxoPerspective br$getCameraType() { + return AxoPerspective.values()[perspective]; + } + + @Override + public void br$setCameraType(AxoPerspective perspective) { + this.perspective = perspective.ordinal(); + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 95700e45c..5967215ad 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -50,26 +50,11 @@ import net.ornithemc.osl.lifecycle.api.client.MinecraftClientEvents; public class AxolotlClientConfig extends AxolotlClientConfigCommon { - - public final BooleanOption showOwnNametag = new BooleanOption("showOwnNametag", false); - public final BooleanOption useShadows = new BooleanOption("useShadows", false); - public final BooleanOption nametagBackground = new BooleanOption("nametagBackground", true); - - public final BooleanOption showBadges = new BooleanOption("showBadges", true); - public final BooleanOption customBadge = new BooleanOption("customBadge", false); - public final StringOption badgeText = new StringOption("badgeText", ""); - - public final ForceableBooleanOption timeChangerEnabled = new ForceableBooleanOption("enabled", false); - public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); public final IntegerOption cloudHeight = new IntegerOption("cloudHeight", 128, 100, 512); - public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); - public final ForceableBooleanOption fullBright = new ForceableBooleanOption("fullBright", false); - public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); - public final ForceableBooleanOption lowFire = new ForceableBooleanOption("lowFire", false); + public final ColorOption hitColor = new ColorOption("hitColor", new Color(255, 0, 0, 77)); - public final BooleanOption minimalViewBob = new BooleanOption("minimalViewBob", false); - public final BooleanOption noHurtCam = new BooleanOption("noHurtCam", false); + public final BooleanOption flatItems = new BooleanOption("flatItems", false); public final BooleanOption inventoryPotionEffectOffset = new BooleanOption("inventory.potion_effect_offset", true); @@ -78,56 +63,25 @@ public class AxolotlClientConfig extends AxolotlClientConfigCommon { public final BooleanOption rawMouseInput = new BooleanOption("rawMouseInput", false, v -> WindowAccess.getInstance().setRawMouseMotion(v)); - public final BooleanOption enableCustomOutlines = new BooleanOption("enabled", false); - public final ColorOption outlineColor = new ColorOption("color", Color.parse("#DD000000")); public final IntegerOption outlineWidth = new IntegerOption("outlineWidth", 1, 1, 10); - public final BooleanOption noRain = new BooleanOption("noRain", false); - - public final BooleanOption debugLogOutput = new BooleanOption("debugLogOutput", false); public final GenericOption openCredits = new GenericOption("Credits", "Open Credits", () -> Minecraft.getInstance() .openScreen(new CreditsScreen(Minecraft.getInstance().screen))); - public final BooleanOption creditsBGM = new BooleanOption("creditsBGM", true); - public final BooleanOption customWindowTitle = new BooleanOption("customWindowTitle", true); public final BooleanOption scaleTitles = new BooleanOption("titles.scaling", false); public final IntegerOption titlePadding = new IntegerOption("titles.padding", 4, 1, 10); - public final OptionCategory general = OptionCategory.create("general"); - public final OptionCategory nametagOptions = OptionCategory.create("nametagOptions"); - public final OptionCategory rendering = OptionCategory.create("rendering"); - public final OptionCategory outlines = OptionCategory.create("blockOutlines"); - public final OptionCategory timeChanger = OptionCategory.create("timeChanger"); public final OptionCategory titles = OptionCategory.create("titles"); @Getter private final List> options = new ArrayList<>(); public AxolotlClientConfig() { - config.add(general); - config.add(nametagOptions); - config.add(rendering); - config.add(hidden); - - nametagOptions.add(showOwnNametag); - nametagOptions.add(useShadows); - nametagOptions.add(nametagBackground); - - nametagOptions.add(showBadges); - nametagOptions.add(customBadge); - nametagOptions.add(badgeText); - general.add(loadingScreenColor); general.add(nightMode); - general.add(customWindowTitle); general.add(rawMouseInput); general.add(openCredits); - general.add(debugLogOutput); - - general.add(datetimeFormat); - general.add(titleScreenOptionButtonMode); - general.add(gameMenuScreenOptionButtonMode); ConfigUI.getInstance().runWhenLoaded(() -> { general.getOptions().removeIf(o -> "configStyle".equals(o.getName())); @@ -152,31 +106,15 @@ public AxolotlClientConfig() { rendering.add(customSky, cloudHeight, - dynamicFOV, - fullBright, - removeVignette, - lowFire, hitColor, - minimalViewBob, flatItems, - noHurtCam, inventoryPotionEffectOffset); - timeChanger.add(timeChangerEnabled); - timeChanger.add(customTime); - rendering.add(timeChanger); - - outlines.add(enableCustomOutlines); - outlines.add(outlineColor); outlines.add(outlineWidth); - rendering.add(outlines); - rendering.add(noRain); titles.add(scaleTitles, titlePadding); rendering.add(titles); - hidden.add(creditsBGM, someNiceBackground); - AxolotlClient.getInstance().modules.add(new Module() { @Override public void lateInit() { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java index 0db49e1c1..67f9d91f4 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java @@ -22,7 +22,7 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; +import io.github.axolotlclient.modules.render.BeaconBeam; import net.minecraft.block.entity.BeaconBlockEntity; import net.minecraft.client.render.block.entity.BeaconRenderer; import org.spongepowered.asm.mixin.Mixin; @@ -35,7 +35,7 @@ public abstract class BeaconBlockEntityRendererMixin { @Inject(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;DDDFI)V", at = @At("HEAD"), cancellable = true) private void axolotlclient$cancelBeamRendering(BeaconBlockEntity beaconBlockEntity, double d, double e, double f, float g, int i, CallbackInfo ci) { - if (!BeaconBeam.getInstance().showBeam()) { + if (!BeaconBeam.getInstance().showBeam(false)) { ci.cancel(); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ConnectScreenMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ConnectScreenMixin.java index bd85185f7..9aa3765e1 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ConnectScreenMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ConnectScreenMixin.java @@ -22,7 +22,7 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.util.FeatureDisabler; +import io.github.axolotlclient.bridge.events.Events; import net.minecraft.client.gui.screen.ConnectScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -34,6 +34,7 @@ public abstract class ConnectScreenMixin { @Inject(method = "connect", at = @At("HEAD")) private void axolotlclient$onServerJoin(String address, int port, CallbackInfo ci) { - FeatureDisabler.onServerJoin(address); + // TODO: the semantics for this event isn't super clear + Events.BEGIN_JOIN_SERVER.invoker().accept(new Events.ServerJoinInfo(address)); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 6d5ad7024..558a78f62 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -29,7 +29,7 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.Tessellator; import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.modules.freelook.Perspective; +import io.github.axolotlclient.bridge.AxoPerspective; import io.github.axolotlclient.modules.hypixel.LevelHead; import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.util.BadgeRenderer; @@ -58,7 +58,7 @@ public abstract class EntityRendererMixin { @Inject(method = "renderNameTag(Lnet/minecraft/entity/Entity;Ljava/lang/String;DDDI)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;rotatef(FFFF)V", ordinal = 1)) private void axolotlclient$correctNameplateRotation(Entity entity, String string, double d, double e, double f, int i, CallbackInfo ci) { - if (Minecraft.getInstance().options.perspective == Perspective.THIRD_PERSON_FRONT.ordinal()) { + if (Minecraft.getInstance().options.perspective == AxoPerspective.THIRD_PERSON_FRONT.ordinal()) { GlStateManager.rotatef(-this.dispatcher.cameraPitch * 2, 1.0F, 0.0F, 0.0F); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java index 68a623227..145795421 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java @@ -32,7 +32,7 @@ import io.github.axolotlclient.modules.hud.HudEditScreen; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; import io.github.axolotlclient.modules.hypixel.HypixelMods; -import io.github.axolotlclient.util.FeatureDisabler; +import io.github.axolotlclient.util.FeatureDisablerCommon; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.gui.screen.GameMenuScreen; import net.minecraft.client.gui.screen.Screen; @@ -103,7 +103,7 @@ public abstract class GameMenuScreenMixin extends Screen { if (button.id == 20 && !axolotlclient$hasModMenu()) { minecraft.openScreen(new HudEditScreen(this)); } else if (button.id == 1) { - FeatureDisabler.clear(); + FeatureDisablerCommon.getInstance().clear(); if (HypixelMods.getInstance().cacheMode.get() != null && Objects.equals(HypixelMods.getInstance().cacheMode.get(), HypixelMods.HypixelApiCacheMode.ON_CLIENT_DISCONNECT.toString())) { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/LivingEntityRendererMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/LivingEntityRendererMixin.java index b0a9d93e1..0ea798f71 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/LivingEntityRendererMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/LivingEntityRendererMixin.java @@ -26,7 +26,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.blaze3d.platform.GlStateManager; import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.modules.freelook.Perspective; +import io.github.axolotlclient.bridge.AxoPerspective; import io.github.axolotlclient.modules.hud.gui.hud.PlayerHud; import io.github.axolotlclient.modules.hypixel.NickHider; import net.minecraft.client.Minecraft; @@ -53,7 +53,7 @@ protected LivingEntityRendererMixin(EntityRenderDispatcher entityRenderDispatche @Inject(method = "renderNameTag(Lnet/minecraft/entity/living/LivingEntity;DDD)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;rotatef(FFFF)V", ordinal = 1)) private void axolotlclient$correctNameplateRotation(LivingEntity livingEntity, double d, double e, double f, CallbackInfo ci) { - if (Minecraft.getInstance().options.perspective == Perspective.THIRD_PERSON_FRONT.ordinal()) { + if (Minecraft.getInstance().options.perspective == AxoPerspective.THIRD_PERSON_FRONT.ordinal()) { GlStateManager.rotatef(-this.dispatcher.cameraPitch * 2, 1.0F, 0.0F, 0.0F); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java index 04b218711..7ba8f06b4 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java @@ -27,6 +27,7 @@ import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.TntRenderer; import net.minecraft.entity.PrimedTntEntity; +import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -42,8 +43,11 @@ protected TntEntityRendererMixin(EntityRenderDispatcher dispatcher) { @Inject(method = "render(Lnet/minecraft/entity/PrimedTntEntity;DDDFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderer;render(Lnet/minecraft/entity/Entity;DDDFF)V"), cancellable = true) public void axolotlclient$render(PrimedTntEntity entity, double x, double y, double z, float g, float h, CallbackInfo ci) { if (TntTime.getInstance().enabled.get()) { - super.renderNameTag(entity, TntTime.getInstance().getFuseTime(entity.fuseTimer).getFormattedString(), - x, y, z, 64); + super.renderNameTag( + entity, + ((Text) TntTime.getInstance().getFuseTime(entity.fuseTimer)).getFormattedString(), + x, y, z, 64 + ); ci.cancel(); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java deleted file mode 100644 index a7e79e947..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.freelook; - -import java.util.ArrayDeque; -import java.util.Deque; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; -import io.github.axolotlclient.modules.AbstractModule; -import io.github.axolotlclient.util.FeatureDisabler; -import io.github.axolotlclient.util.options.ForceableBooleanOption; -import net.minecraft.client.Minecraft; -import net.minecraft.client.options.KeyBinding; -import net.minecraft.entity.Entity; -import net.ornithemc.osl.keybinds.api.KeyBindingEvents; -import org.lwjgl.input.Keyboard; - -public class Freelook extends AbstractModule { - - private static final Freelook INSTANCE = new Freelook(); - private static final KeyBinding KEY = new KeyBinding("key.freelook", Keyboard.KEY_V, - "category.axolotlclient"); - private static final KeyBinding KEY_ALT = new KeyBinding("key.freelook.alt", Keyboard.KEY_NONE, - "category.axolotlclient"); - public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); - private final Minecraft client = Minecraft.getInstance(); - private final OptionCategory category = OptionCategory.create("freelook"); - private final StringArrayOption mode = new StringArrayOption("mode", - new String[]{"snap_perspective", "freelook"}, - "freelook", value -> FeatureDisabler.update()); - private final BooleanOption invert = new BooleanOption("invert", false); - private final EnumOption perspective = new EnumOption<>("perspective", Perspective.class, - Perspective.THIRD_PERSON_BACK); - private final BooleanOption toggle = new BooleanOption("toggle", "freelook.toggle.tooltip", false); - private final EnumOption perspectiveAlt = new EnumOption<>("perspective.alt", Perspective.class, - Perspective.THIRD_PERSON_FRONT); - private final BooleanOption toggleAlt = new BooleanOption("toggle.alt", false); - private float yaw, pitch; - private final WrappedValue active = new WrappedValue(), activeAlt = new WrappedValue(); - private final Deque previousPerspectives = new ArrayDeque<>(); - - public static Freelook getInstance() { - return INSTANCE; - } - - @Override - public void init() { - KeyBindingEvents.REGISTER_KEYBINDS.register(r -> { - r.register(KEY); - r.register(KEY_ALT); - }); - category.add(enabled, mode, invert, perspective, toggle); - category.add(perspectiveAlt, toggleAlt); - AxolotlClient.config().addCategory(category); - } - - @Override - public void tick() { - if (!enabled.get() || client.screen != null) return; - tickSet(toggle, KEY, perspective, active); - tickSet(toggleAlt, KEY_ALT, perspectiveAlt, activeAlt); - } - - private void tickSet(BooleanOption toggle, KeyBinding key, EnumOption perspective, WrappedValue active) { - if (toggle.get()) { - if (key.consumeClick()) { - if (active.val) { - stop(active); - } else { - start(perspective.get(), active); - } - } - } else { - if (key.isPressed()) { - if (!active.val) { - start(perspective.get(), active); - } - } else if (active.val) { - stop(active); - } - } - } - - private void stop(WrappedValue active) { - active.val = false; - client.worldRenderer.onViewChanged(); - client.gameRenderer.updateShader(client.getCamera()); - client.options.perspective = previousPerspectives.pop(); - } - - private void start(Perspective perspective, WrappedValue active) { - previousPerspectives.push(client.options.perspective); - active.val = true; - client.options.perspective = perspective.ordinal(); - - Entity camera = client.getCamera(); - - if (camera == null) - camera = client.player; - if (camera == null) - return; - - yaw = camera.yaw; - pitch = camera.pitch; - } - - public boolean consumeRotation(float dx, float dy) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return false; - - if (!invert.get()) - dy = -dy; - - yaw += dx * 0.15F; - pitch += dy * 0.15F; - - if (pitch > 90) { - pitch = 90; - } else if (pitch < -90) { - pitch = -90; - } - - client.worldRenderer.onViewChanged(); - return true; - } - - public float yaw(float defaultValue) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return defaultValue; - - return yaw; - } - - public float pitch(float defaultValue) { - if (!(active.val || activeAlt.val) || !enabled.get() || !mode.get().equals("freelook")) - return defaultValue; - - return pitch; - } - - public boolean needsDisabling() { - return mode.get().equals("freelook"); - } - - public boolean isActive() { - return active.val || activeAlt.val; - } - - private static class WrappedValue { - boolean val; - } -} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java deleted file mode 100644 index 4267c809f..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.renderOptions; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.modules.AbstractModule; -import lombok.Getter; - -public class BeaconBeam extends AbstractModule { - - @Getter - private final static BeaconBeam Instance = new BeaconBeam(); - - private final BooleanOption showBeaconBeams = new BooleanOption("showBeaconBeams", true); - - private final OptionCategory beams = OptionCategory.create("beams"); - - @Override - public void init() { - beams.add(showBeaconBeams); - - AxolotlClient.config().rendering.add(beams); - } - - public boolean showBeam() { - return showBeaconBeams.get(); - } -} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java deleted file mode 100644 index a7611c6cf..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.rpc; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.util.Util; -import net.minecraft.client.Minecraft; - - -public class DiscordRPC extends RPCCommon { - private static DiscordRPC Instance; - private String currentWorld = ""; - - public DiscordRPC() { - super(AxolotlClient.LOGGER); - } - - public static DiscordRPC getInstance() { - if (Instance == null) - Instance = new DiscordRPC(); - return Instance; - } - - public void setWorld(String world) { - currentWorld = world; - } - - @Override - protected void createRichPresence() { - - String state = switch (showServerNameMode.get()) { - case "showIp" -> Minecraft.getInstance().world == null ? "In the menu" - : (Util.getCurrentServerAddress() == null ? "Singleplayer" : Util.getCurrentServerAddress()); - case "showName" -> Minecraft.getInstance().world == null ? "In the menu" - : (Minecraft.getInstance().getCurrentServerEntry() == null - ? (Util.getCurrentServerAddress() == null ? "Singleplayer" - : Util.getCurrentServerAddress()) - : Minecraft.getInstance().getCurrentServerEntry().name); - default -> ""; - }; - - String details; - if (showActivity.get() && Minecraft.getInstance().getCurrentServerEntry() != null) { - details = (Util.getGame()); - } else if (showActivity.get() && !currentWorld.isEmpty()) { - details = (currentWorld); - currentWorld = ""; - } else { - details = ""; - } - - setRichPresence(createRichPresence(AxolotlClient.VERSION, state, details)); - } - - public void init() { - super.init(); - - AxolotlClient.config().addCategory(category); - } -} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java deleted file mode 100644 index 2798ae233..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.tnttime; - -import java.text.DecimalFormat; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.IntegerOption; -import io.github.axolotlclient.modules.AbstractModule; -import io.github.axolotlclient.util.options.ForceableBooleanOption; -import lombok.Getter; -import net.minecraft.text.Formatting; -import net.minecraft.text.LiteralText; -import net.minecraft.text.Style; -import net.minecraft.text.Text; - -public class TntTime extends AbstractModule { - - @Getter - private static final TntTime Instance = new TntTime(); - public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); - private final OptionCategory category = OptionCategory.create("tnttime"); - private final IntegerOption decimalPlaces = new IntegerOption("decimalplaces", 2, 0, 6); - private DecimalFormat format = new DecimalFormat("##"); - private int decimals; - - @Override - public void init() { - category.add(enabled, decimalPlaces); - AxolotlClient.config().rendering.add(category); - } - - @Override - public void tick() { - if (decimalPlaces.get() != decimals) { - StringBuilder string = new StringBuilder("#0"); - if (decimalPlaces.get() > 0) { - string.append("."); - for (int i = 0; i < decimalPlaces.get(); i++) { - string.append("0"); - } - } - format = new DecimalFormat(string.toString()); - decimals = decimalPlaces.get(); - } - } - - public Text getFuseTime(int time) { - float secs = time / 20F; - return new LiteralText(format.format(secs)).copy().setStyle(new Style().setColor(getCurrentColor(secs))); - } - - private Formatting getCurrentColor(float seconds) { - if (seconds > 7d) { - return Formatting.DARK_AQUA; - } else if (seconds > 6d) { - return Formatting.AQUA; - } else if (seconds > 4d) { - return Formatting.DARK_GREEN; - } else if (seconds > 3d) { - return Formatting.GREEN; - } else if (seconds > 2d) { - return Formatting.GOLD; - } else if (seconds > 1d) { - return Formatting.RED; - } else if (seconds > 0d) { - return Formatting.DARK_RED; - } else { - return Formatting.WHITE; - } - } -} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java b/1.8.9/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java index 6a60fa0b1..3e8572feb 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java @@ -22,50 +22,25 @@ package io.github.axolotlclient.util; -import java.util.HashMap; import java.util.List; -import java.util.Locale; -import java.util.function.Supplier; import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.modules.freelook.Freelook; -import io.github.axolotlclient.modules.hud.HudManager; -import io.github.axolotlclient.modules.hud.gui.hud.simple.ToggleSprintHud; -import io.github.axolotlclient.util.options.ForceableBooleanOption; -import net.minecraft.client.resource.language.I18n; +import lombok.Getter; import net.ornithemc.osl.networking.api.client.ClientPlayNetworking; -public class FeatureDisabler { +public class FeatureDisabler extends FeatureDisablerCommon { + @Getter + private static final FeatureDisablerCommon instance = new FeatureDisabler(); - private static final HashMap disabledServers = new HashMap<>(); - private static final HashMap> conditions = new HashMap<>(); + private static final String CHANNEL_NAME = "AXO|block_mods"; - private static final Supplier NONE = () -> true; - private static final String channelName = "AXO|block_mods"; - // Features that can be disabled on the server's behalf - // If something should be added here, feel free to ping us via your favorite way. - private static final HashMap features = Util.make(() -> { - HashMap features = new HashMap<>(); - features.put("freelook", Freelook.getInstance().enabled); - features.put("timechanger", AxolotlClient.config().timeChangerEnabled); - features.put("fullbright", AxolotlClient.config().fullBright); - features.put("lowfire", AxolotlClient.config().lowFire); - return features; - }); - private static String currentAddress = ""; - - @SuppressWarnings("unchecked") - public static void init() { - setServers(AxolotlClient.config().lowFire, NONE, "gommehd"); - setServers(AxolotlClient.config().timeChangerEnabled, NONE, "gommehd"); - setServers(Freelook.getInstance().enabled, () -> Freelook.getInstance().needsDisabling(), "hypixel", "mineplex", "gommehd", "nucleoid"); - setServers(((ToggleSprintHud) HudManager.getInstance().get(ToggleSprintHud.ID)).toggleSneak, NONE, "hypixel"); - - ClientPlayNetworking.registerListener(channelName, (client, handler, buf) -> { + @Override + protected void registerChannel() { + ClientPlayNetworking.registerListener(CHANNEL_NAME, (client, handler, buf) -> { List array = (List) GsonHelper.read(buf.readString(32767)); for (String element : array) { try { - features.get(element).setForceOff(true, "ban_reason"); + FEATURES.get(element).setForceOff(true, "ban_reason"); } catch (Exception e) { AxolotlClient.LOGGER.error("Failed to disable " + element + "!"); } @@ -73,37 +48,4 @@ public static void init() { return true; }); } - - private static void setServers(ForceableBooleanOption option, Supplier condition, String... servers) { - disabledServers.put(option, servers); - conditions.put(option, condition); - } - - public static void onServerJoin(String address) { - currentAddress = address; - update(); - } - - public static void update() { - disabledServers.forEach((option, strings) -> disableOption(option, strings, currentAddress)); - } - - private static void disableOption(ForceableBooleanOption option, String[] servers, String currentServer) { - boolean ban = false; - for (String s : servers) { - if (currentServer.toLowerCase(Locale.ROOT).contains(s.toLowerCase(Locale.ROOT))) { - ban = conditions.get(option).get(); - break; - } - } - - if (option.isForceOff() != ban) { - option.setForceOff(ban, I18n.translate("ban_reason")); - } - } - - public static void clear() { - disabledServers.keySet().forEach(option -> option.setForceOff(false, "")); - features.values().forEach(option -> option.setForceOff(false, "")); - } } diff --git a/1.8.9/src/main/resources/fabric.mod.json b/1.8.9/src/main/resources/fabric.mod.json index d07fd43a4..44d9d29b9 100644 --- a/1.8.9/src/main/resources/fabric.mod.json +++ b/1.8.9/src/main/resources/fabric.mod.json @@ -75,7 +75,7 @@ "io/github/axolotlclient/bridge/key/AxoKeybinding" ], "net/minecraft/unmapped/C_1331819": [ - "io/github/axolotlclient/bridge/key/AxoClientKeybinds" + "io/github/axolotlclient/bridge/AxoGameOptions" ], "net/minecraft/unmapped/C_9550253": [ "io/github/axolotlclient/bridge/util/AxoText\u0024Mutable" diff --git a/1.latest/src/main/java/io/github/axolotlclient/AxolotlClient.java b/1.latest/src/main/java/io/github/axolotlclient/AxolotlClient.java index 3c4cb2a0e..bddff6198 100644 --- a/1.latest/src/main/java/io/github/axolotlclient/AxolotlClient.java +++ b/1.latest/src/main/java/io/github/axolotlclient/AxolotlClient.java @@ -30,18 +30,15 @@ import io.github.axolotlclient.bridge.impl.Bridge; import io.github.axolotlclient.modules.ModuleLoader; import io.github.axolotlclient.modules.auth.Auth; -import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hypixel.HypixelMods; import io.github.axolotlclient.modules.particles.Particles; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; -import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.tablist.Tablist; -import io.github.axolotlclient.modules.tnttime.TntTime; import io.github.axolotlclient.modules.zoom.Zoom; import io.github.axolotlclient.util.FeatureDisabler; +import io.github.axolotlclient.util.FeatureDisablerCommon; import io.github.axolotlclient.util.Logger; import io.github.axolotlclient.util.LoggerImpl; import io.github.axolotlclient.util.notifications.Notifications; @@ -61,12 +58,8 @@ private void addBuiltinModules() { registerModule(HypixelMods.getInstance()); //registerModule(MotionBlur.getInstance()); // TODO this is broken since 1.21.2 registerModule(ScrollableTooltips.getInstance()); - registerModule(DiscordRPC.getInstance()); - registerModule(Freelook.getInstance()); - registerModule(TntTime.getInstance()); registerModule(Particles.getInstance()); registerModule(ScreenshotUtils.getInstance()); - registerModule(BeaconBeam.getInstance()); registerModule(Tablist.getInstance()); registerModule(Auth.getInstance()); registerModule(APIOptions.getInstance()); @@ -91,8 +84,8 @@ public void onInitializeClient() { } @Override - protected void initFeatureDisabler() { - FeatureDisabler.init(); + protected FeatureDisablerCommon getFeatureDisabler() { + return FeatureDisabler.getInstance(); } @Override diff --git a/1.latest/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java b/1.latest/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java index 6f1453976..99321df00 100644 --- a/1.latest/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java +++ b/1.latest/src/main/java/io/github/axolotlclient/bridge/impl/Bridge.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.bridge.impl; +import java.util.Objects; + import com.mojang.brigadier.CommandDispatcher; import io.github.axolotlclient.bridge.events.Events; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; @@ -41,6 +43,9 @@ public static void init() { ClientTickEvents.END_CLIENT_TICK.register(minecraft -> Events.TICK.invoker().run()); ResourceLoader.get(PackType.CLIENT_RESOURCES).registerReloader(ResourceLocation.fromNamespaceAndPath("axolotlclient", "bridge/resource_listener"), (ResourceManagerReloadListener) resourceManager -> Events.END_RESOURCE_RELOAD.invoker().run()); + + ClientPlayConnectionEvents.INIT.register((handler, client) -> + Events.BEGIN_JOIN_SERVER.invoker().accept(new Events.ServerJoinInfo(Objects.requireNonNull(handler.getServerData()).ip))); ClientPlayConnectionEvents.JOIN.register((clientPlayNetworkHandler, sender, minecraftClient) -> Events.CONNECTION_PLAY_READY.invoker().run()); ClientPlayConnectionEvents.DISCONNECT.register((clientPlayNetworkHandler, minecraftClient) -> Events.DISCONNECT.invoker().run()); diff --git a/1.latest/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java b/1.latest/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java index 9efdb2e42..499a24023 100644 --- a/1.latest/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java +++ b/1.latest/src/main/java/io/github/axolotlclient/bridge/mixin/MinecraftClientMixin.java @@ -22,14 +22,17 @@ package io.github.axolotlclient.bridge.mixin; -import java.util.Collection; -import java.util.Optional; +import java.util.*; +import java.util.stream.Collectors; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import io.github.axolotlclient.bridge.AxoGameOptions; import io.github.axolotlclient.bridge.AxoMinecraftClient; import io.github.axolotlclient.bridge.AxoPlayerListEntry; import io.github.axolotlclient.bridge.AxoSession; +import io.github.axolotlclient.bridge.entity.AxoEntity; import io.github.axolotlclient.bridge.entity.AxoPlayer; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; import io.github.axolotlclient.bridge.render.AxoFont; import io.github.axolotlclient.bridge.resource.AxoResourceManager; import io.github.axolotlclient.bridge.util.AxoText; @@ -43,8 +46,11 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.network.chat.Component; import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.scores.*; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -86,6 +92,13 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { @Shadow public abstract ResourceManager getResourceManager(); + @Shadow + @Final + public LevelRenderer levelRenderer; + + @Shadow + private Entity cameraEntity; + @Override public @Nullable AxoPlayer br$getPlayer() { return player; @@ -104,7 +117,7 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { @Override - public AxoClientKeybinds br$getKeybinds() { + public AxoGameOptions br$getGameOptions() { return options; } @@ -118,6 +131,11 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { return Optional.ofNullable(getCurrentServer()).map(x -> x.ip).orElse(null); } + @Override + public String br$getServerName() { + return Optional.ofNullable(getCurrentServer()).map(x -> x.name).orElse(null); + } + @Override public Collection br$getOnlinePlayers() { return player.connection.getOnlinePlayers(); @@ -159,4 +177,52 @@ public abstract class MinecraftClientMixin implements AxoMinecraftClient { public Object br$getScreen() { return screen; } + + @Override + public void br$notifyLevelRenderer() { + levelRenderer.needsUpdate(); + } + + @Override + public AxoEntity br$getCameraEntity() { + return cameraEntity; + } + + @Override + public List br$getSidebar() { + List lines = new ArrayList<>(); + Minecraft client = Minecraft.getInstance(); + if (client.level == null) + return lines; + + Scoreboard scoreboard = client.level.getScoreboard(); + Objective sidebar = scoreboard.getDisplayObjective(DisplaySlot.SIDEBAR); + if (sidebar == null) + return lines; + + Collection scores = scoreboard.listPlayerScores(sidebar); + List list = scores.stream().filter( + input -> input != null && !input.isHidden()) + .collect(Collectors.toList()); + + if (list.size() > 15) { + scores = Lists.newArrayList(Iterables.skip(list, scores.size() - 15)); + } else { + scores = list; + } + + for (PlayerScoreEntry score : scores) { + PlayerTeam team = scoreboard.getPlayerTeam(score.owner()); + if (team == null) + return lines; + String text = team.getPlayerPrefix().getString() + team.getPlayerSuffix().getString(); + if (!text.trim().isEmpty()) + lines.add(text); + } + + lines.add(sidebar.getDisplayName().getString()); + Collections.reverse(lines); + + return lines; + } } diff --git a/1.latest/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java b/1.latest/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java index 0d6d950be..8e5a09e62 100644 --- a/1.latest/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java +++ b/1.latest/src/main/java/io/github/axolotlclient/bridge/mixin/key/GameOptionsMixin.java @@ -22,8 +22,10 @@ package io.github.axolotlclient.bridge.mixin.key; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; +import io.github.axolotlclient.bridge.AxoGameOptions; +import io.github.axolotlclient.bridge.AxoPerspective; import io.github.axolotlclient.bridge.key.AxoKeybinding; +import net.minecraft.client.CameraType; import net.minecraft.client.KeyMapping; import net.minecraft.client.Options; import org.spongepowered.asm.mixin.Final; @@ -31,7 +33,7 @@ import org.spongepowered.asm.mixin.Shadow; @Mixin(Options.class) -public abstract class GameOptionsMixin implements AxoClientKeybinds { +public abstract class GameOptionsMixin implements AxoGameOptions { @Shadow @Final public KeyMapping keySprint; @@ -48,6 +50,12 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { @Final public KeyMapping keyUse; + @Shadow + public abstract CameraType getCameraType(); + + @Shadow + public abstract void setCameraType(CameraType pointOfView); + @Override public AxoKeybinding br$getSprintKeybind() { return keySprint; @@ -67,4 +75,22 @@ public abstract class GameOptionsMixin implements AxoClientKeybinds { public AxoKeybinding br$getUseKey() { return keyUse; } + + @Override + public AxoPerspective br$getCameraType() { + return switch (getCameraType()) { + case FIRST_PERSON -> AxoPerspective.FIRST_PERSON; + case THIRD_PERSON_BACK -> AxoPerspective.THIRD_PERSON_BACK; + case THIRD_PERSON_FRONT -> AxoPerspective.THIRD_PERSON_FRONT; + }; + } + + @Override + public void br$setCameraType(AxoPerspective perspective) { + setCameraType(switch (perspective) { + case FIRST_PERSON -> CameraType.FIRST_PERSON; + case THIRD_PERSON_BACK -> CameraType.THIRD_PERSON_BACK; + case THIRD_PERSON_FRONT -> CameraType.THIRD_PERSON_FRONT; + }); + } } diff --git a/1.latest/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.latest/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 7aa0a4200..e1304c3ad 100644 --- a/1.latest/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.latest/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -48,21 +48,6 @@ import net.minecraft.client.renderer.texture.DynamicTexture; public class AxolotlClientConfig extends AxolotlClientConfigCommon { - - public final BooleanOption showOwnNametag = new BooleanOption("showOwnNametag", false); - public final BooleanOption useShadows = new BooleanOption("useShadows", false); - public final BooleanOption nametagBackground = new BooleanOption("nametagBackground", true); - - public final BooleanOption showBadges = new BooleanOption("showBadges", true); - public final BooleanOption customBadge = new BooleanOption("customBadge", false); - public final StringOption badgeText = new StringOption("badgeText", ""); - - public final ForceableBooleanOption timeChangerEnabled = new ForceableBooleanOption("enabled", false); - public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); - public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); - public final ForceableBooleanOption fullBright = new ForceableBooleanOption("fullBright", false); - public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); - public final ForceableBooleanOption lowFire = new ForceableBooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", new Color(255, 0, 0, 77), value -> { @@ -83,54 +68,19 @@ public class AxolotlClientConfig extends AxolotlClientConfigCommon { texture.upload(); } }); - public final BooleanOption minimalViewBob = new BooleanOption("minimalViewBob", false); - public final BooleanOption noHurtCam = new BooleanOption("noHurtCam", false); public final ColorOption loadingScreenColor = new ColorOption("loadingBgColor", new Color(239, 50, 61, 255)); - public final BooleanOption customWindowTitle = new BooleanOption("customWindowTitle", true); - - public final BooleanOption enableCustomOutlines = new BooleanOption("enabled", false); - public final ColorOption outlineColor = new ColorOption("color", Color.parse("#DD000000")); - - public final BooleanOption noRain = new BooleanOption("noRain", false); public final GenericOption openCredits = new GenericOption("Credits", "Open Credits", () -> Minecraft.getInstance().setScreen(new CreditsScreen(Minecraft.getInstance().screen)) ); - public final BooleanOption debugLogOutput = new BooleanOption("debugLogOutput", false); - public final BooleanOption creditsBGM = new BooleanOption("creditsBGM", true); - - public final OptionCategory general = OptionCategory.create("general"); - public final OptionCategory nametagOptions = OptionCategory.create("nametagOptions"); - public final OptionCategory rendering = OptionCategory.create("rendering"); - public final OptionCategory outlines = OptionCategory.create("blockOutlines"); - public final OptionCategory timeChanger = OptionCategory.create("timeChanger"); @Getter private final List> options = new ArrayList<>(); public AxolotlClientConfig() { - config.add(general); - config.add(nametagOptions); - config.add(rendering); - - rendering.add(outlines); - - nametagOptions.add(showOwnNametag); - nametagOptions.add(useShadows); - nametagOptions.add(nametagBackground); - - nametagOptions.add(showBadges); - nametagOptions.add(customBadge); - nametagOptions.add(badgeText); - general.add(loadingScreenColor); - general.add(customWindowTitle); general.add(openCredits); - general.add(debugLogOutput); - general.add(datetimeFormat); - general.add(titleScreenOptionButtonMode); - general.add(gameMenuScreenOptionButtonMode); ConfigUI.getInstance().runWhenLoaded(() -> { general.getOptions().removeIf(o -> "configStyle".equals(o.getName())); @@ -154,26 +104,7 @@ public AxolotlClientConfig() { } }); - rendering.add( - dynamicFOV, - fullBright, - removeVignette, - lowFire, - lowShield, - hitColor, - minimalViewBob, - noHurtCam); - - timeChanger.add(timeChangerEnabled); - timeChanger.add(customTime); - rendering.add(timeChanger); - - outlines.add(enableCustomOutlines); - outlines.add(outlineColor); - - rendering.add(noRain); - - hidden.add(creditsBGM, someNiceBackground); + rendering.add(lowShield, hitColor); general.add(new GenericOption("profiles.title", "profiles.configure", () -> Minecraft.getInstance().setScreen(new ProfilesScreen(Minecraft.getInstance().screen))), false); diff --git a/1.latest/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java b/1.latest/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java index cb3333038..6f81a024d 100644 --- a/1.latest/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java +++ b/1.latest/src/main/java/io/github/axolotlclient/mixin/BeaconBlockEntityRendererMixin.java @@ -23,7 +23,7 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.vertex.PoseStack; -import io.github.axolotlclient.modules.renderOptions.BeaconBeam; +import io.github.axolotlclient.modules.render.BeaconBeam; import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.blockentity.BeaconRenderer; import net.minecraft.resources.ResourceLocation; diff --git a/1.latest/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java b/1.latest/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java index 37906e8ff..33cac5140 100644 --- a/1.latest/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java +++ b/1.latest/src/main/java/io/github/axolotlclient/mixin/TntEntityRendererMixin.java @@ -30,6 +30,7 @@ import net.minecraft.client.renderer.entity.TntRenderer; import net.minecraft.client.renderer.entity.state.TntRenderState; import net.minecraft.client.renderer.state.CameraRenderState; +import net.minecraft.network.chat.Component; import net.minecraft.world.entity.item.PrimedTnt; import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; @@ -61,7 +62,7 @@ protected TntEntityRendererMixin(EntityRendererProvider.Context ctx) { poseStack, tntRenderState.nameTagAttachment, 0, - TntTime.getInstance().getFuseTime(tntRenderState.fuseRemainingInTicks), + (Component) TntTime.getInstance().getFuseTime(tntRenderState.fuseRemainingInTicks), !tntRenderState.isDiscrete, tntRenderState.lightCoords, tntRenderState.distanceToCameraSq, diff --git a/1.latest/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java b/1.latest/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java deleted file mode 100644 index 2901b01bb..000000000 --- a/1.latest/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.renderOptions; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.modules.AbstractModule; -import lombok.Getter; - -public class BeaconBeam extends AbstractModule { - - @Getter - private final static BeaconBeam Instance = new BeaconBeam(); - - private final BooleanOption showBeaconBeams = new BooleanOption("showBeaconBeams", true); - private final BooleanOption showEndGatewayBeams = new BooleanOption("showEndGatewayBeams", true); - - private final OptionCategory beams = OptionCategory.create("beams"); - - @Override - public void init() { - beams.add(showBeaconBeams, showEndGatewayBeams); - - AxolotlClient.config().rendering.add(beams); - } - - public boolean showBeam(boolean endGateway) { - return endGateway ? showEndGatewayBeams.get() : showBeaconBeams.get(); - } -} diff --git a/1.latest/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.latest/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java deleted file mode 100644 index 6055a6c2b..000000000 --- a/1.latest/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.rpc; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.util.Util; -import net.minecraft.client.Minecraft; - -public class DiscordRPC extends RPCCommon { - private static DiscordRPC Instance; - private String currentWorld = ""; - - private DiscordRPC() { - super(AxolotlClient.LOGGER); - } - - public static DiscordRPC getInstance() { - if (Instance == null) Instance = new DiscordRPC(); - return Instance; - } - - public void setWorld(String world) { - currentWorld = world; - } - - @Override - protected void createRichPresence() { - - String state = switch (showServerNameMode.get()) { - case "showIp" -> Minecraft.getInstance().level == null ? "In the menu" - : (Minecraft.getInstance().getCurrentServer() == null - ? "Singleplayer" - : Minecraft.getInstance().getCurrentServer().ip); - case "showName" -> Minecraft.getInstance().level == null ? "In the menu" : ( - Minecraft.getInstance().getCurrentServer() == null ? "Singleplayer" - : Minecraft.getInstance().getCurrentServer().name); - default -> ""; - }; - - String details; - if (showActivity.get() && Minecraft.getInstance().getCurrentServer() != null) { - details = (Util.getGame()); - } else if (showActivity.get() && !currentWorld.isEmpty()) { - details = (currentWorld); - currentWorld = ""; - } else { - details = ""; - } - - setRichPresence(createRichPresence(AxolotlClient.VERSION, state, details)); - } - - public void init() { - super.init(); - - AxolotlClient.config().addCategory(category); - } -} diff --git a/1.latest/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java b/1.latest/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java deleted file mode 100644 index f744dabc4..000000000 --- a/1.latest/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright © 2024 moehreag & Contributors - * - * This file is part of AxolotlClient. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * For more information, see the LICENSE file. - */ - -package io.github.axolotlclient.modules.tnttime; - -import java.text.DecimalFormat; - -import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.IntegerOption; -import io.github.axolotlclient.modules.AbstractModule; -import io.github.axolotlclient.util.options.ForceableBooleanOption; -import lombok.Getter; -import net.minecraft.ChatFormatting; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.Style; - -public class TntTime extends AbstractModule { - - @Getter - private static final TntTime Instance = new TntTime(); - public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); - private final OptionCategory category = OptionCategory.create("tnttime"); - private final IntegerOption decimalPlaces = new IntegerOption("decimalplaces", 2, 0, 6); - private DecimalFormat format; - private int decimals; - - @Override - public void init() { - category.add(enabled, decimalPlaces); - AxolotlClient.config().rendering.add(category); - } - - @Override - public void tick() { - if (decimalPlaces.get() != decimals || format == null) { - StringBuilder string = new StringBuilder("#0"); - if (decimalPlaces.get() > 0) { - string.append("."); - string.append("0".repeat(Math.max(0, decimalPlaces.get()))); - } - format = new DecimalFormat(string.toString()); - decimals = decimalPlaces.get(); - } - } - - public Component getFuseTime(float time) { - float secs = time / 20F; - return Component.literal(String.valueOf(format.format(secs))).copy() - .setStyle(Style.EMPTY.withColor(getCurrentColor(secs))); - } - - private ChatFormatting getCurrentColor(float seconds) { - if (seconds > 7d) { - return ChatFormatting.DARK_AQUA; - } else if (seconds > 6d) { - return ChatFormatting.AQUA; - } else if (seconds > 4d) { - return ChatFormatting.DARK_GREEN; - } else if (seconds > 3d) { - return ChatFormatting.GREEN; - } else if (seconds > 2d) { - return ChatFormatting.GOLD; - } else if (seconds > 1d) { - return ChatFormatting.RED; - } else if (seconds > 0d) { - return ChatFormatting.DARK_RED; - } else { - return ChatFormatting.WHITE; - } - } -} diff --git a/1.latest/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java b/1.latest/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java index 4a1922b53..16f5cb490 100644 --- a/1.latest/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java +++ b/1.latest/src/main/java/io/github/axolotlclient/util/FeatureDisabler.java @@ -22,73 +22,37 @@ package io.github.axolotlclient.util; -import java.util.HashMap; import java.util.List; -import java.util.Locale; -import java.util.Objects; -import java.util.function.Supplier; import com.mojang.serialization.Codec; import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.modules.freelook.Freelook; -import io.github.axolotlclient.modules.hud.HudManager; -import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; -import io.github.axolotlclient.modules.hud.gui.hud.simple.ToggleSprintHud; -import io.github.axolotlclient.modules.tnttime.TntTime; import io.github.axolotlclient.util.options.ForceableBooleanOption; import io.netty.buffer.ByteBuf; +import lombok.Getter; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; -import net.minecraft.Util; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; -public class FeatureDisabler { +public class FeatureDisabler extends FeatureDisablerCommon { + @Getter + private static final FeatureDisablerCommon instance = new FeatureDisabler(); - private static final HashMap disabledServers = new HashMap<>(); - private static final HashMap> conditions = new HashMap<>(); + private static final CustomPacketPayload.Type CHANNEL_ID = + new CustomPacketPayload.Type<>((ResourceLocation) CHANNEL_NAME); - private static final Supplier NONE = () -> true; - private static final CustomPacketPayload.Type channelId = - new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath("axolotlclient", "block_mods")); - // Features that can be disabled on the server's behalf - // If something should be added here, feel free to ping us via your favorite way. - private static final HashMap features = Util.make(() -> { - HashMap features = new HashMap<>(); - features.put("freelook", Freelook.getInstance().enabled); - features.put("timechanger", AxolotlClient.config().timeChangerEnabled); - features.put("lowfire", AxolotlClient.config().lowFire); - features.put("fullbright", AxolotlClient.config().fullBright); - return features; - }); - private static String currentAddress = ""; - - public static void init() { - setServers(AxolotlClient.config().fullBright, NONE, "gommehd"); - setServers(AxolotlClient.config().lowFire, NONE, "gommehd"); - setServers(Freelook.getInstance().enabled, () -> Freelook.getInstance().needsDisabling(), "hypixel", "mineplex", - "gommehd", "nucleoid", "mccisland" - ); - setServers(((ToggleSprintHud) HudManager.getInstance().get(ToggleSprintHud.ID)).toggleSneak, NONE, "hypixel"); - setServers(((ReachHud) HudManager.getInstance().get(ReachHud.ID)).getEnabled(), NONE, "mccisland"); - setServers(TntTime.getInstance().enabled, NONE, "mccisland"); - - ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { - if (handler.getServerData() != null) { - onServerJoin(Objects.requireNonNull(handler.getServerData()).ip); - } - }); - ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> clear()); - - PayloadTypeRegistry.playS2C().register(channelId, FeaturePayload.CODEC); + @Override + protected void registerChannel() { + PayloadTypeRegistry.playS2C().register(CHANNEL_ID, FeaturePayload.CODEC); ClientPlayConnectionEvents.INIT.register((handler0, client0) -> { - ClientPlayNetworking.registerGlobalReceiver(channelId, (payload, ctx) -> { + ClientPlayNetworking.registerGlobalReceiver(CHANNEL_ID, (payload, ctx) -> { for (String feature : payload.features) { try { - ForceableBooleanOption e = features.get(feature); + ForceableBooleanOption e = FEATURES.get(feature); e.setForceOff(true, "ban_reason"); } catch (Exception e) { AxolotlClient.LOGGER.error("Failed to disable " + feature + "!"); @@ -98,46 +62,13 @@ public static void init() { }); } - private static void setServers(ForceableBooleanOption option, Supplier condition, String... servers) { - disabledServers.put(option, servers); - conditions.put(option, condition); - } - - public static void onServerJoin(String address) { - currentAddress = address; - update(); - } - - public static void clear() { - disabledServers.keySet().forEach(option -> option.setForceOff(false, "")); - features.values().forEach(option -> option.setForceOff(false, "")); - } - - public static void update() { - disabledServers.forEach((option, strings) -> disableOption(option, strings, currentAddress)); - } - - private static void disableOption(ForceableBooleanOption option, String[] servers, String currentServer) { - boolean ban = false; - for (String s : servers) { - if (currentServer.toLowerCase(Locale.ROOT).contains(s.toLowerCase(Locale.ROOT))) { - ban = conditions.get(option).get(); - break; - } - } - - if (option.isForceOff() != ban) { - option.setForceOff(ban, "ban_reason"); - } - } - private record FeaturePayload(List features) implements CustomPacketPayload { public static final StreamCodec CODEC = ByteBufCodecs.fromCodec(Codec.STRING.listOf().xmap(FeaturePayload::new, FeaturePayload::features)); @Override - public Type type() { - return channelId; + public @NotNull Type type() { + return CHANNEL_ID; } } } diff --git a/1.latest/src/main/resources/fabric.mod.json b/1.latest/src/main/resources/fabric.mod.json index 2c066970e..9b573a2e5 100644 --- a/1.latest/src/main/resources/fabric.mod.json +++ b/1.latest/src/main/resources/fabric.mod.json @@ -78,7 +78,7 @@ "io/github/axolotlclient/bridge/key/AxoKeybinding" ], "net/minecraft/class_315": [ - "io/github/axolotlclient/bridge/key/AxoClientKeybinds" + "io/github/axolotlclient/bridge/AxoGameOptions" ], "net/minecraft/class_3675\u0024class_306": [ "io/github/axolotlclient/bridge/key/AxoKey" diff --git a/common/src/main/java/io/github/axolotlclient/AxolotlClientCommon.java b/common/src/main/java/io/github/axolotlclient/AxolotlClientCommon.java index bb7c6d20e..cfb1e6d6e 100644 --- a/common/src/main/java/io/github/axolotlclient/AxolotlClientCommon.java +++ b/common/src/main/java/io/github/axolotlclient/AxolotlClientCommon.java @@ -44,7 +44,12 @@ import io.github.axolotlclient.config.profiles.ProfileAware; import io.github.axolotlclient.config.profiles.Profiles; import io.github.axolotlclient.modules.Module; +import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hud.ClickInputTracker; +import io.github.axolotlclient.modules.render.BeaconBeam; +import io.github.axolotlclient.modules.rpc.DiscordRPC; +import io.github.axolotlclient.modules.tnttime.TntTime; +import io.github.axolotlclient.util.FeatureDisablerCommon; import io.github.axolotlclient.util.Logger; import io.github.axolotlclient.util.OSUtil; import io.github.axolotlclient.util.notifications.NotificationProvider; @@ -121,6 +126,10 @@ public static AxolotlClientCommon getInstance() { private void addBuiltinCommonModules() { registerModule(ClickInputTracker.getInstance()); + registerModule(BeaconBeam.getInstance()); + registerModule(Freelook.getInstance()); + registerModule(TntTime.getInstance()); + registerModule(DiscordRPC.getInstance()); } // init logic @@ -246,7 +255,8 @@ protected final void init(Logger logger, NotificationProvider provider) { modules.forEach(Module::tick); AxoProfiler.get().br$pop(); }); - initFeatureDisabler(); + + getFeatureDisabler().init(); // register events @@ -258,7 +268,7 @@ protected final void registerModule(Module module) { modules.add(module); } - protected abstract void initFeatureDisabler(); + protected abstract FeatureDisablerCommon getFeatureDisabler(); protected abstract AxolotlClientConfigCommon createConfig(); diff --git a/common/src/main/java/io/github/axolotlclient/AxolotlClientConfigCommon.java b/common/src/main/java/io/github/axolotlclient/AxolotlClientConfigCommon.java index 454061ccc..a2608b362 100644 --- a/common/src/main/java/io/github/axolotlclient/AxolotlClientConfigCommon.java +++ b/common/src/main/java/io/github/axolotlclient/AxolotlClientConfigCommon.java @@ -27,15 +27,15 @@ import io.github.axolotlclient.AxolotlClientConfig.api.options.Option; import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; -import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringOption; +import io.github.axolotlclient.AxolotlClientConfig.api.util.Color; +import io.github.axolotlclient.AxolotlClientConfig.impl.options.*; +import io.github.axolotlclient.util.options.ForceableBooleanOption; import net.fabricmc.loader.api.FabricLoader; public abstract class AxolotlClientConfigCommon { public enum MenuButtonMode { DISABLED, - MODMENU () { + MODMENU() { @Override public boolean showButton() { return !(FabricLoader.getInstance().isModLoaded("modmenu") && !FabricLoader.getInstance().isModLoaded("axolotlclient-modmenu")); @@ -46,12 +46,11 @@ public boolean showButton() { public boolean showButton() { return true; } - } - ; + }; @Override public String toString() { - return "menu_button_mode."+super.toString().toLowerCase(Locale.ROOT); + return "menu_button_mode." + super.toString().toLowerCase(Locale.ROOT); } public boolean showButton() { @@ -60,6 +59,42 @@ public boolean showButton() { } // options + + public final BooleanOption showOwnNametag = new BooleanOption("showOwnNametag", false); + public final BooleanOption useShadows = new BooleanOption("useShadows", false); + public final BooleanOption nametagBackground = new BooleanOption("nametagBackground", true); + + public final BooleanOption showBadges = new BooleanOption("showBadges", true); + public final BooleanOption customBadge = new BooleanOption("customBadge", false); + public final StringOption badgeText = new StringOption("badgeText", ""); + + public final ForceableBooleanOption timeChangerEnabled = new ForceableBooleanOption("enabled", false); + public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); + + public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); + public final ForceableBooleanOption fullBright = new ForceableBooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); + public final ForceableBooleanOption lowFire = new ForceableBooleanOption("lowFire", false); + + public final BooleanOption minimalViewBob = new BooleanOption("minimalViewBob", false); + public final BooleanOption noHurtCam = new BooleanOption("noHurtCam", false); + + public final BooleanOption enableCustomOutlines = new BooleanOption("enabled", false); + public final ColorOption outlineColor = new ColorOption("color", Color.parse("#DD000000")); + + public final BooleanOption customWindowTitle = new BooleanOption("customWindowTitle", true); + + public final OptionCategory general = OptionCategory.create("general"); + public final OptionCategory nametagOptions = OptionCategory.create("nametagOptions"); + public final OptionCategory rendering = OptionCategory.create("rendering"); + public final OptionCategory outlines = OptionCategory.create("blockOutlines"); + public final OptionCategory timeChanger = OptionCategory.create("timeChanger"); + + public final BooleanOption creditsBGM = new BooleanOption("creditsBGM", true); + public final BooleanOption debugLogOutput = new BooleanOption("debugLogOutput", false); + + public final BooleanOption noRain = new BooleanOption("noRain", false); + public final OptionCategory config = OptionCategory.create("config"); public final OptionCategory hidden = OptionCategory.create("storedOptions"); public final BooleanOption someNiceBackground = new BooleanOption("defNoSecret", false); @@ -67,10 +102,54 @@ public boolean showButton() { public final EnumOption titleScreenOptionButtonMode = new EnumOption<>("title_screen_button_mode", MenuButtonMode.class, MenuButtonMode.MODMENU); public final EnumOption gameMenuScreenOptionButtonMode = new EnumOption<>("game_menu_screen_button_mode", MenuButtonMode.class, MenuButtonMode.MODMENU); - private DateTimeFormatter dateTimeFormatter; + public DateTimeFormatter dateTimeFormatter; + + public AxolotlClientConfigCommon() { + config.add(general); + config.add(nametagOptions); + config.add(rendering); + config.add(hidden); + + rendering.add(outlines); + + nametagOptions.add(showOwnNametag); + nametagOptions.add(useShadows); + nametagOptions.add(nametagBackground); + + nametagOptions.add(showBadges); + nametagOptions.add(customBadge); + nametagOptions.add(badgeText); + + general.add(customWindowTitle); + general.add(debugLogOutput); + + general.add(datetimeFormat); + general.add(titleScreenOptionButtonMode); + general.add(gameMenuScreenOptionButtonMode); + + timeChanger.add(timeChangerEnabled); + timeChanger.add(customTime); + + outlines.add(enableCustomOutlines); + outlines.add(outlineColor); + + rendering.add(timeChanger); + + rendering.add( + dynamicFOV, + fullBright, + removeVignette, + lowFire, + minimalViewBob, + noHurtCam, + noRain + ); + + hidden.add(creditsBGM, someNiceBackground); + } public DateTimeFormatter getDateTimeFormatter() { - if(dateTimeFormatter == null) { + if (dateTimeFormatter == null) { dateTimeFormatter = DateTimeFormatter.ofPattern(datetimeFormat.get()); } diff --git a/common/src/main/java/io/github/axolotlclient/bridge/key/AxoClientKeybinds.java b/common/src/main/java/io/github/axolotlclient/bridge/AxoGameOptions.java similarity index 80% rename from common/src/main/java/io/github/axolotlclient/bridge/key/AxoClientKeybinds.java rename to common/src/main/java/io/github/axolotlclient/bridge/AxoGameOptions.java index c301af592..c14d606e9 100644 --- a/common/src/main/java/io/github/axolotlclient/bridge/key/AxoClientKeybinds.java +++ b/common/src/main/java/io/github/axolotlclient/bridge/AxoGameOptions.java @@ -20,12 +20,13 @@ * For more information, see the LICENSE file. */ -package io.github.axolotlclient.bridge.key; +package io.github.axolotlclient.bridge; import io.github.axolotlclient.bridge.internal.BridgeUtil; import io.github.axolotlclient.bridge.internal.RequiresImpl; +import io.github.axolotlclient.bridge.key.AxoKeybinding; -public interface AxoClientKeybinds { +public interface AxoGameOptions { @RequiresImpl default AxoKeybinding br$getSprintKeybind() { throw BridgeUtil.noImpl(); @@ -45,4 +46,14 @@ public interface AxoClientKeybinds { default AxoKeybinding br$getUseKey() { throw BridgeUtil.noImpl(); } + + @RequiresImpl + default AxoPerspective br$getCameraType() { + throw BridgeUtil.noImpl(); + } + + @RequiresImpl + default void br$setCameraType(AxoPerspective perspective) { + throw BridgeUtil.noImpl(); + } } diff --git a/common/src/main/java/io/github/axolotlclient/bridge/AxoMinecraftClient.java b/common/src/main/java/io/github/axolotlclient/bridge/AxoMinecraftClient.java index a7e35d50d..5be247402 100644 --- a/common/src/main/java/io/github/axolotlclient/bridge/AxoMinecraftClient.java +++ b/common/src/main/java/io/github/axolotlclient/bridge/AxoMinecraftClient.java @@ -23,13 +23,14 @@ package io.github.axolotlclient.bridge; import java.util.Collection; +import java.util.List; import java.util.concurrent.Executor; +import io.github.axolotlclient.bridge.entity.AxoEntity; import io.github.axolotlclient.bridge.entity.AxoPlayer; import io.github.axolotlclient.bridge.internal.BridgeUtil; import io.github.axolotlclient.bridge.internal.PlatformImplInternal; import io.github.axolotlclient.bridge.internal.RequiresImpl; -import io.github.axolotlclient.bridge.key.AxoClientKeybinds; import io.github.axolotlclient.bridge.render.AxoFont; import io.github.axolotlclient.bridge.resource.AxoResourceManager; import io.github.axolotlclient.bridge.util.AxoText; @@ -64,7 +65,7 @@ static int getCurrentFps() { } @RequiresImpl - default AxoClientKeybinds br$getKeybinds() { + default AxoGameOptions br$getGameOptions() { throw BridgeUtil.noImpl(); } @@ -78,6 +79,11 @@ static int getCurrentFps() { throw BridgeUtil.noImpl(); } + @RequiresImpl + default String br$getServerName() { + throw BridgeUtil.noImpl(); + } + @RequiresImpl default boolean br$isLocalServer() { throw BridgeUtil.noImpl(); @@ -128,4 +134,19 @@ static int getCurrentFps() { default Object br$getScreen() { throw BridgeUtil.noImpl(); } + + @RequiresImpl + default AxoEntity br$getCameraEntity() { + throw BridgeUtil.noImpl(); + } + + @RequiresImpl + default void br$notifyLevelRenderer() { + throw BridgeUtil.noImpl(); + } + + @RequiresImpl + default List br$getSidebar() { + throw BridgeUtil.noImpl(); + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/freelook/Perspective.java b/common/src/main/java/io/github/axolotlclient/bridge/AxoPerspective.java similarity index 64% rename from 1.8.9/src/main/java/io/github/axolotlclient/modules/freelook/Perspective.java rename to common/src/main/java/io/github/axolotlclient/bridge/AxoPerspective.java index 65fad7d50..31c10572e 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/freelook/Perspective.java +++ b/common/src/main/java/io/github/axolotlclient/bridge/AxoPerspective.java @@ -1,5 +1,5 @@ /* - * Copyright © 2023 moehreag & Contributors + * Copyright © 2025 moehreag & Contributors * * This file is part of AxolotlClient. * @@ -20,8 +20,21 @@ * For more information, see the LICENSE file. */ -package io.github.axolotlclient.modules.freelook; +package io.github.axolotlclient.bridge; -public enum Perspective { - FIRST_PERSON, THIRD_PERSON_BACK, THIRD_PERSON_FRONT +import lombok.Getter; + +@Getter +public enum AxoPerspective { + FIRST_PERSON(true, false), + THIRD_PERSON_BACK(false, false), + THIRD_PERSON_FRONT(false, true); + + private final boolean firstPerson; + private final boolean mirrored; + + AxoPerspective(final boolean firstPerson, final boolean mirrored) { + this.firstPerson = firstPerson; + this.mirrored = mirrored; + } } diff --git a/common/src/main/java/io/github/axolotlclient/bridge/events/Events.java b/common/src/main/java/io/github/axolotlclient/bridge/events/Events.java index a68f6155b..aff0745af 100644 --- a/common/src/main/java/io/github/axolotlclient/bridge/events/Events.java +++ b/common/src/main/java/io/github/axolotlclient/bridge/events/Events.java @@ -52,6 +52,11 @@ public class Events { public static final EventBus TICK = EventBus.broadcast0(); public static final EventBus END_RESOURCE_RELOAD = EventBus.broadcast0(); public static final EventBus CONNECTION_PLAY_READY = EventBus.broadcast0(); + + public record ServerJoinInfo(@Nullable String address) { + } + + public static final EventBus> BEGIN_JOIN_SERVER = EventBus.broadcast1(); public static final EventBus DISCONNECT = EventBus.broadcast0(); public static final EventBus> RECEIVE_CHAT_MESSAGE = EventBus.broadcast1(); diff --git a/common/src/main/java/io/github/axolotlclient/bridge/key/AxoKeys.java b/common/src/main/java/io/github/axolotlclient/bridge/key/AxoKeys.java index 03af02bf9..bc561fbe1 100644 --- a/common/src/main/java/io/github/axolotlclient/bridge/key/AxoKeys.java +++ b/common/src/main/java/io/github/axolotlclient/bridge/key/AxoKeys.java @@ -28,6 +28,7 @@ public class AxoKeys { public static final AxoKey KEY_UNKNOWN = BridgeUtil.noImplValue(); public static final AxoKey KEY_K = BridgeUtil.noImplValue(); public static final AxoKey KEY_I = BridgeUtil.noImplValue(); + public static final AxoKey KEY_V = BridgeUtil.noImplValue(); public static final AxoKey MOUSE_LEFT = BridgeUtil.noImplValue(); public static final AxoKey MOUSE_RIGHT = BridgeUtil.noImplValue(); public static final AxoKey KEY_RSHIFT = BridgeUtil.noImplValue(); diff --git a/1.latest/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java b/common/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java similarity index 59% rename from 1.latest/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java rename to common/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java index 573e8d5a0..830cff3be 100644 --- a/1.latest/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java +++ b/common/src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java @@ -25,43 +25,39 @@ import java.util.ArrayDeque; import java.util.Deque; -import com.mojang.blaze3d.platform.InputConstants; -import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientCommon; import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.impl.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; -import io.github.axolotlclient.modules.AbstractModule; -import io.github.axolotlclient.util.FeatureDisabler; -import io.github.axolotlclient.util.keybinds.KeyBinds; +import io.github.axolotlclient.bridge.AxoPerspective; +import io.github.axolotlclient.bridge.entity.AxoEntity; +import io.github.axolotlclient.bridge.key.AxoKeybinding; +import io.github.axolotlclient.bridge.key.AxoKeys; +import io.github.axolotlclient.modules.AbstractCommonModule; +import io.github.axolotlclient.util.FeatureDisablerCommon; import io.github.axolotlclient.util.options.ForceableBooleanOption; -import net.minecraft.client.CameraType; -import net.minecraft.client.KeyMapping; -import net.minecraft.client.Minecraft; -import net.minecraft.world.entity.Entity; - -public class Freelook extends AbstractModule { +public class Freelook extends AbstractCommonModule { private static final Freelook INSTANCE = new Freelook(); - private static final KeyMapping KEY = KeyBinds.getInstance().register(new KeyMapping("key.freelook", InputConstants.KEY_V, KeyBinds.CATEGORY_AXOLOTLCLIENT)); - private static final KeyMapping KEY_ALT = KeyBinds.getInstance().register(new KeyMapping("key.freelook.alt", InputConstants.UNKNOWN.getValue(), KeyBinds.CATEGORY_AXOLOTLCLIENT)); + private static final AxoKeybinding KEY = AxoKeybinding.create(AxoKeys.KEY_V, "key.freelook"); + private static final AxoKeybinding KEY_ALT = AxoKeybinding.create(null, "key.freelook.alt"); public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); - private final Minecraft client = Minecraft.getInstance(); private final OptionCategory category = OptionCategory.create("freelook"); private final StringArrayOption mode = - new StringArrayOption("mode", new String[]{"snap_perspective", "freelook"}, "freelook", - value -> FeatureDisabler.update() + new StringArrayOption("mode", new String[]{"snap_AxoPerspective", "freelook"}, "freelook", + value -> FeatureDisablerCommon.getInstance().update() ); private final BooleanOption invert = new BooleanOption("invert", false); - private final EnumOption perspective = - new EnumOption<>("perspective", CameraType.class, CameraType.THIRD_PERSON_BACK); + private final EnumOption perspective = + new EnumOption<>("AxoPerspective", AxoPerspective.class, AxoPerspective.THIRD_PERSON_BACK); private final BooleanOption toggle = new BooleanOption("toggle", "freelook.toggle.tooltip", false); - private final EnumOption perspectiveAlt = new EnumOption<>("perspective.alt", CameraType.class, - CameraType.THIRD_PERSON_FRONT); + private final EnumOption AxoPerspectiveAlt = new EnumOption<>("AxoPerspective.alt", AxoPerspective.class, + AxoPerspective.THIRD_PERSON_FRONT); private final BooleanOption toggleAlt = new BooleanOption("toggle.alt", false); private final WrappedValue active = new WrappedValue(), activeAlt = new WrappedValue(); private float yaw, pitch; - private final Deque previousPerspectives = new ArrayDeque<>(); + private final Deque previousAxoPerspectives = new ArrayDeque<>(); public static Freelook getInstance() { return INSTANCE; @@ -70,20 +66,20 @@ public static Freelook getInstance() { @Override public void init() { category.add(enabled, mode, perspective, invert, toggle); - category.add(perspectiveAlt, toggleAlt); - AxolotlClient.config().addCategory(category); + category.add(AxoPerspectiveAlt, toggleAlt); + AxolotlClientCommon.getInstance().getConfig().addCategory(category); } @Override public void tick() { - if (!enabled.get() || client.screen != null) return; + if (!enabled.get() || client.br$getScreen() != null) return; tickSet(toggle, KEY, perspective, active); - tickSet(toggleAlt, KEY_ALT, perspectiveAlt, activeAlt); + tickSet(toggleAlt, KEY_ALT, AxoPerspectiveAlt, activeAlt); } - private void tickSet(BooleanOption toggle, KeyMapping key, EnumOption perspective, WrappedValue active) { + private void tickSet(BooleanOption toggle, AxoKeybinding key, EnumOption perspective, WrappedValue active) { if (toggle.get()) { - if (key.consumeClick()) { + if (key.br$consumeClick()) { if (active.val) { stop(active); } else { @@ -91,7 +87,7 @@ private void tickSet(BooleanOption toggle, KeyMapping key, EnumOption { - if (key.equals(client.br$getKeybinds().br$getAttackKey().br$getBoundKey())) { + if (key.equals(client.br$getGameOptions().br$getAttackKey().br$getBoundKey())) { leftBind.click(); - } else if (key.equals(client.br$getKeybinds().br$getUseKey().br$getBoundKey())) { + } else if (key.equals(client.br$getGameOptions().br$getUseKey().br$getBoundKey())) { rightBind.click(); } diff --git a/common/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java b/common/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java index 0484a2fdd..055cfd3f8 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java @@ -105,11 +105,11 @@ public List> getConfigurationOptions() { @Override public String getValue() { - if (client.br$getKeybinds().br$getSneakKeybind().br$isPressed()) { + if (client.br$getGameOptions().br$getSneakKeybind().br$isPressed()) { return AxoI18n.translate("sneaking_pressed"); } - if (client.br$getKeybinds().br$getSprintKeybind().br$isPressed()) { + if (client.br$getGameOptions().br$getSprintKeybind().br$isPressed()) { return AxoI18n.translate("sprinting_pressed"); } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java b/common/src/main/java/io/github/axolotlclient/modules/render/BeaconBeam.java similarity index 77% rename from 1.20/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java rename to common/src/main/java/io/github/axolotlclient/modules/render/BeaconBeam.java index 2901b01bb..6600bb47c 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/renderOptions/BeaconBeam.java +++ b/common/src/main/java/io/github/axolotlclient/modules/render/BeaconBeam.java @@ -20,15 +20,16 @@ * For more information, see the LICENSE file. */ -package io.github.axolotlclient.modules.renderOptions; +package io.github.axolotlclient.modules.render; -import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientCommon; import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; -import io.github.axolotlclient.modules.AbstractModule; +import io.github.axolotlclient.bridge.BridgeVersion; +import io.github.axolotlclient.modules.AbstractCommonModule; import lombok.Getter; -public class BeaconBeam extends AbstractModule { +public class BeaconBeam extends AbstractCommonModule { @Getter private final static BeaconBeam Instance = new BeaconBeam(); @@ -40,9 +41,13 @@ public class BeaconBeam extends AbstractModule { @Override public void init() { - beams.add(showBeaconBeams, showEndGatewayBeams); + beams.add(showBeaconBeams); - AxolotlClient.config().rendering.add(beams); + if(!BridgeVersion.V1_8.isCurrent()) { + beams.add(showEndGatewayBeams); + } + + AxolotlClientCommon.getInstance().getConfig().rendering.add(beams); } public boolean showBeam(boolean endGateway) { diff --git a/common/src/main/java/io/github/axolotlclient/modules/rpc/RPCCommon.java b/common/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java similarity index 61% rename from common/src/main/java/io/github/axolotlclient/modules/rpc/RPCCommon.java rename to common/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index ba7da0758..44b99d20d 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/rpc/RPCCommon.java +++ b/common/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -31,52 +31,60 @@ import com.jagrosh.discordipc.entities.Packet; import com.jagrosh.discordipc.entities.RichPresence; import com.jagrosh.discordipc.entities.User; +import io.github.axolotlclient.AxolotlClientCommon; import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.impl.options.StringArrayOption; -import io.github.axolotlclient.modules.Module; +import io.github.axolotlclient.modules.AbstractCommonModule; +import io.github.axolotlclient.util.CommonUtil; import io.github.axolotlclient.util.Logger; import io.github.axolotlclient.util.OSUtil; import io.github.axolotlclient.util.ThreadExecuter; import io.github.axolotlclient.util.options.ForceableBooleanOption; -public abstract class RPCCommon implements Module { - +public class DiscordRPC extends AbstractCommonModule { private static final long CLIENT_ID = 875835666729152573L; private static boolean running; - public final OptionCategory category = OptionCategory.create("rpc"); - public final BooleanOption showActivity = new BooleanOption("showActivity", true); - public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false, value -> { + private static DiscordRPC Instance; + private final OptionCategory category = OptionCategory.create("rpc"); + private final BooleanOption showActivity = new BooleanOption("showActivity", true); + private final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false, value -> { if (value) { ThreadExecuter.scheduleTask(this::initRPC); } else { ThreadExecuter.scheduleTask(this::shutdown); } }); - public final StringArrayOption showServerNameMode = new StringArrayOption("showServerNameMode", + private final StringArrayOption showServerNameMode = new StringArrayOption("showServerNameMode", new String[]{"showIp", "showName", "off"}, "off"); - public final BooleanOption showTime = new BooleanOption("showTime", true); + private final BooleanOption showTime = new BooleanOption("showTime", true); private final Instant time = Instant.now(); - private final Logger logger; - private IPCClient client; + private final Logger logger = AxolotlClientCommon.getInstance().getLogger(); + private IPCClient ipcClient; + private String currentWorld = ""; + + public static DiscordRPC getInstance() { + if (Instance == null) + Instance = new DiscordRPC(); + return Instance; + } - public RPCCommon(Logger logger) { - this.logger = logger; + public void setWorld(String world) { + currentWorld = world; } public void init() { category.add(enabled, showTime, showActivity, showServerNameMode); - if (OSUtil.getOS() == OSUtil.OperatingSystem.OTHER) { enabled.setForceOff(true, "crash"); } + AxolotlClientCommon.getInstance().getConfig().addCategory(category); } public void tick() { if (!running && enabled.get()) { ThreadExecuter.scheduleTask(this::initRPC); } - if (running) { ThreadExecuter.scheduleTask(this::updateRPC); } @@ -84,28 +92,50 @@ public void tick() { public void shutdown() { if (running) { - client.close(); + ipcClient.close(); running = false; } } - protected RichPresence createRichPresence(String gameVersion, String state, String details) { + private RichPresence createRichPresence(String gameVersion, String state, String details) { RichPresence.Builder builder = new RichPresence.Builder(); builder.setLargeImage("icon", "AxolotlClient " + gameVersion); if (showTime.get()) { builder.setStartTimestamp(time.getEpochSecond()); } - builder.setState(state) - .setDetails(details); + builder.setState(state).setDetails(details); builder.setActivityType(ActivityType.Playing); return builder.build(); } - protected abstract void createRichPresence(); + private void createRichPresence() { + String state = switch (showServerNameMode.get()) { + case "showIp" -> client.br$getWorld() == null ? "In the menu" + : (CommonUtil.getCurrentServerAddress() == null ? "Singleplayer" : CommonUtil.getCurrentServerAddress()); + case "showName" -> client.br$getWorld() == null ? "In the menu" + : (client.br$getServerAddress() == null + ? (CommonUtil.getCurrentServerAddress() == null ? "Singleplayer" + : CommonUtil.getCurrentServerAddress()) + : client.br$getServerName()); + default -> ""; + }; + + String details; + if (showActivity.get() && !client.br$isLocalServer()) { + details = CommonUtil.getGame(); + } else if (showActivity.get() && !currentWorld.isEmpty()) { + details = currentWorld; + currentWorld = ""; + } else { + details = ""; + } + + setRichPresence(createRichPresence(AxolotlClientCommon.VERSION, state, details)); + } - protected void setRichPresence(RichPresence presence) { - if (running && client != null) { - client.sendRichPresence(presence); + private void setRichPresence(RichPresence presence) { + if (running && ipcClient != null) { + ipcClient.sendRichPresence(presence); } } @@ -113,11 +143,11 @@ private void updateRPC() { createRichPresence(); } - public void initRPC() { + private void initRPC() { if (enabled.get()) { - if (client == null) { - client = new IPCClient(CLIENT_ID); - client.setListener(new IPCListener() { + if (ipcClient == null) { + ipcClient = new IPCClient(CLIENT_ID); + ipcClient.setListener(new IPCListener() { @Override public void onPacketSent(IPCClient client, Packet packet) { @@ -161,7 +191,7 @@ public void onDisconnect(IPCClient client, Throwable t) { }); } try { - client.connect(); + ipcClient.connect(); logger.info("Started RPC"); running = true; } catch (Exception e) { @@ -169,6 +199,4 @@ public void onDisconnect(IPCClient client, Throwable t) { } } } - - } diff --git a/1.21/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java b/common/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java similarity index 73% rename from 1.21/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java rename to common/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java index 9301cd01d..137cad223 100644 --- a/1.21/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java +++ b/common/src/main/java/io/github/axolotlclient/modules/tnttime/TntTime.java @@ -24,20 +24,18 @@ import java.text.DecimalFormat; -import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientCommon; import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.impl.options.IntegerOption; -import io.github.axolotlclient.modules.AbstractModule; +import io.github.axolotlclient.bridge.util.AxoText; +import io.github.axolotlclient.modules.AbstractCommonModule; import io.github.axolotlclient.util.options.ForceableBooleanOption; import lombok.Getter; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; - -public class TntTime extends AbstractModule { +public class TntTime extends AbstractCommonModule { @Getter - private static final TntTime Instance = new TntTime(); + private static final TntTime instance = new TntTime(); + public final ForceableBooleanOption enabled = new ForceableBooleanOption("enabled", false); private final OptionCategory category = OptionCategory.create("tnttime"); private final IntegerOption decimalPlaces = new IntegerOption("decimalplaces", 2, 0, 6); @@ -47,7 +45,7 @@ public class TntTime extends AbstractModule { @Override public void init() { category.add(enabled, decimalPlaces); - AxolotlClient.config().rendering.add(category); + AxolotlClientCommon.getInstance().getConfig().rendering.add(category); } @Override @@ -63,29 +61,29 @@ public void tick() { } } - public Text getFuseTime(int time) { + public AxoText getFuseTime(float time) { float secs = time / 20F; - return Text.of(String.valueOf(format.format(secs))).copy() - .setStyle(Style.EMPTY.withColor(getCurrentColor(secs))); + return AxoText.literal(String.valueOf(format.format(secs))) + .br$color(getCurrentColor(secs)); } - private Formatting getCurrentColor(float seconds) { + private AxoText.Color getCurrentColor(float seconds) { if (seconds > 7d) { - return Formatting.DARK_AQUA; + return AxoText.Color.DARK_AQUA; } else if (seconds > 6d) { - return Formatting.AQUA; + return AxoText.Color.AQUA; } else if (seconds > 4d) { - return Formatting.DARK_GREEN; + return AxoText.Color.DARK_GREEN; } else if (seconds > 3d) { - return Formatting.GREEN; + return AxoText.Color.GREEN; } else if (seconds > 2d) { - return Formatting.GOLD; + return AxoText.Color.GOLD; } else if (seconds > 1d) { - return Formatting.RED; + return AxoText.Color.RED; } else if (seconds > 0d) { - return Formatting.DARK_RED; + return AxoText.Color.DARK_RED; } else { - return Formatting.WHITE; + return AxoText.Color.WHITE; } } } diff --git a/common/src/main/java/io/github/axolotlclient/util/CommonUtil.java b/common/src/main/java/io/github/axolotlclient/util/CommonUtil.java index 3df56453c..67ca7ae91 100644 --- a/common/src/main/java/io/github/axolotlclient/util/CommonUtil.java +++ b/common/src/main/java/io/github/axolotlclient/util/CommonUtil.java @@ -22,6 +22,14 @@ package io.github.axolotlclient.util; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.function.Consumer; +import java.util.function.Supplier; + +import io.github.axolotlclient.bridge.AxoMinecraftClient; + public class CommonUtil { public static String toRoman(int number) { if (number > 0) { @@ -32,4 +40,60 @@ public static String toRoman(int number) { } return ""; } + + public static T make(Supplier factory) { + return factory.get(); + } + + public static T make(T object, Consumer initializer) { + initializer.accept(object); + return object; + } + + public static String getCurrentServerAddress() { + final var minecraft = AxoMinecraftClient.getInstance(); + + if (minecraft.br$isLocalServer()) { + return null; + } + + return minecraft.br$getServerAddress(); + } + + public static String lastgame; + public static String game; + + public static String getGame() { + List sidebar = AxoMinecraftClient.getInstance().br$getSidebar(); + + final var address = AxoMinecraftClient.getInstance().br$getServerAddress(); + + if (sidebar.isEmpty()) { + game = ""; + } else if (address != null && address.toLowerCase().contains(sidebar.get(0).toLowerCase())) { + if (sidebar.get(sidebar.size() - 1).toLowerCase(Locale.ROOT).contains(address.toLowerCase(Locale.ROOT)) + || sidebar.get(sidebar.size() - 1).contains("Playtime")) { + game = "In Lobby"; + } else { + if (sidebar.get(sidebar.size() - 1).contains("--------")) { + game = "Playing Bridge Practice"; + } else { + game = "Playing " + sidebar.get(sidebar.size() - 1); + } + } + } else { + game = "Playing " + sidebar.get(0); + } + + if (!Objects.equals(lastgame, game) && game.isEmpty()) + game = lastgame; + else + lastgame = game; + + if (game == null) { + game = ""; + } + + return game; + } } diff --git a/common/src/main/java/io/github/axolotlclient/util/FeatureDisablerCommon.java b/common/src/main/java/io/github/axolotlclient/util/FeatureDisablerCommon.java new file mode 100644 index 000000000..1d3bd0539 --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/util/FeatureDisablerCommon.java @@ -0,0 +1,116 @@ +/* + * Copyright © 2024 moehreag & Contributors + * + * This file is part of AxolotlClient. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + +package io.github.axolotlclient.util; + +import java.util.HashMap; +import java.util.Locale; +import java.util.function.Supplier; + +import com.google.common.base.Preconditions; +import io.github.axolotlclient.AxolotlClientCommon; +import io.github.axolotlclient.bridge.events.Events; +import io.github.axolotlclient.bridge.util.AxoIdentifier; +import io.github.axolotlclient.modules.freelook.Freelook; +import io.github.axolotlclient.modules.hud.HudManagerCommon; +import io.github.axolotlclient.modules.hud.gui.hud.simple.ToggleSprintHud; +import io.github.axolotlclient.util.options.ForceableBooleanOption; +import lombok.Getter; + +public abstract class FeatureDisablerCommon { + @Getter + private static FeatureDisablerCommon instance; + + private static final Supplier NONE = () -> true; + protected static final AxoIdentifier CHANNEL_NAME = AxoIdentifier.of("axolotlclient", "block_mods"); + // Features that can be disabled on the server's behalf + // If something should be added here, feel free to ping us via your favorite way. + protected static final HashMap FEATURES = CommonUtil.make(() -> { + HashMap features = new HashMap<>(); + features.put("freelook", Freelook.getInstance().enabled); + features.put("timechanger", AxolotlClientCommon.getInstance().getConfig().timeChangerEnabled); + features.put("lowfire", AxolotlClientCommon.getInstance().getConfig().lowFire); + features.put("fullbright", AxolotlClientCommon.getInstance().getConfig().fullBright); + return features; + }); + + private final HashMap disabledServers = new HashMap<>(); + private final HashMap> conditions = new HashMap<>(); + private String currentAddress = ""; + + protected FeatureDisablerCommon() { + Preconditions.checkState(instance == null, "singleton already initialized"); + instance = this; + } + + public void init() { + setServers(AxolotlClientCommon.getInstance().getConfig().fullBright, NONE, "gommehd"); + setServers(AxolotlClientCommon.getInstance().getConfig().lowFire, NONE, "gommehd"); + setServers(Freelook.getInstance().enabled, () -> Freelook.getInstance().needsDisabling(), "hypixel", "mineplex", "gommehd", "nucleoid", "mccisland"); + setServers(((ToggleSprintHud) HudManagerCommon.getInstance().get(ToggleSprintHud.ID)).toggleSneak, NONE, "hypixel"); + + Events.BEGIN_JOIN_SERVER.register(info -> { + if (info.address() != null) { + onServerJoin(info.address()); + } + }); + + Events.DISCONNECT.register(this::clear); + + registerChannel(); + } + + protected abstract void registerChannel(); + + private void setServers(ForceableBooleanOption option, Supplier condition, String... servers) { + disabledServers.put(option, servers); + conditions.put(option, condition); + } + + public void onServerJoin(String address) { + currentAddress = address; + update(); + } + + public void clear() { + disabledServers.keySet().forEach(option -> option.setForceOff(false, "")); + FEATURES.values().forEach(option -> option.setForceOff(false, "")); + } + + public void update() { + disabledServers.forEach((option, strings) -> disableOption(option, strings, currentAddress)); + } + + private void disableOption(ForceableBooleanOption option, String[] servers, String currentServer) { + boolean ban = false; + for (String s : servers) { + if (currentServer.toLowerCase(Locale.ROOT).contains(s.toLowerCase(Locale.ROOT))) { + ban = conditions.get(option).get(); + break; + } + } + + if (option.isForceOff() != ban) { + option.setForceOff(ban, "ban_reason"); + } + } +}