diff --git a/1.16.5/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.16.5/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index dffc5a5f0..fad983405 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 7bb9bbadd..bfc168488 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -167,11 +167,11 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f4a36a2c1..967b301c2 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,31 +22,40 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; 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; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true) - public void axolotlclient$autoThings(Text message, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + @Inject(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;IIZ)V"), cancellable = true) + public void axolotlclient$autoThings(Text message, int messageId, CallbackInfo ci) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;I)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index cc07df4d9..f5efca90f 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 4ba4aa7e0..8a2b52100 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, false, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..64aa00f06 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,26 +22,28 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +91,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +191,40 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), + ordinal = 18 + ) + public int axolotlclient$displayHardcoreHearts(int offset) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 5 : offset; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 20 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index c36ecc90b..34f3a2cdf 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -22,7 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; import org.spongepowered.asm.mixin.Mixin; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBinding) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBinding) ((Object) this))); } } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 4afc08eac..dd3e7539f 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -26,11 +26,14 @@ import io.github.axolotlclient.modules.blur.MenuBlur; import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -83,4 +86,9 @@ public abstract class MinecraftClientMixin { private void axolotlclient$noModdedSigns(CallbackInfoReturnable cir) { cir.setReturnValue(false); } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 02e659956..0d35dc75b 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;setKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 0465c0aae..03c2a4a79 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,15 +22,24 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.render.entity.PlayerModelPart; import net.minecraft.client.util.math.MatrixStack; @@ -42,14 +51,14 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -75,6 +84,10 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry par1, MutableText par2); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { profile = playerEntry.getProfile(); @@ -115,7 +128,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -150,4 +165,133 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$alwaysShowHeadLayer(PlayerEntity instance, PlayerModelPart modelPart) { return Tablist.getInstance().alwaysShowHeadLayer.get() || instance.isPartVisible(modelPart); } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, CallbackInfo ci, + ClientPlayNetworkHandler clientPlayNetworkHandler, List list, int i, int j, int l, int m, int k, + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 + ) { + if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I", + ordinal = 1 + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, + PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null) { + return; + } + + game.renderCustomScoreboardObjective(matrices, playerEntry.getProfile().getName(), objective, y, endX); + ci.cancel(); + + + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null || !game.isStarted()) { + return; + } + BedwarsPlayer player = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + if (player == null) { + return; + } + cir.setReturnValue(player.getTabListDisplay()); + } + + @ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/google/common/collect/Ordering;sortedCopy(Ljava/lang/Iterable;)Ljava/util/List;", remap = false)) + public List axolotlclient$overrideSortedPlayers(List original) { + if (!BedwarsMod.getInstance().inGame()) { + return original; + } + List players = BedwarsMod.getInstance().getGame().get().getTabPlayerList(original); + if (players == null) { + return original; + } + return players; + } + + @Inject(method = "setHeader", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 42bb33d65..b09c77a74 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -38,6 +38,7 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.math.MatrixStack; @@ -57,6 +58,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); @@ -100,6 +102,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index de12acbff..ff2c1b0b4 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -35,7 +35,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); @@ -232,11 +233,6 @@ public void renderPlaceholderComponent(MatrixStack matrices, float delta) { renderComponent(matrices, delta); } - @Override - public boolean movable() { - return true; - } - @Override public boolean tickable() { return true; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 1c1f569e5..3d0cbfc84 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -29,7 +29,8 @@ import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -65,11 +66,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index e05125d6f..442dc2cf6 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -28,7 +28,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register((event) -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.keyAttack)) { + if (event.getKey().equals(client.options.keyAttack)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.keyUse)) { + } else if (event.getKey().equals(client.options.keyUse)) { ClickList.RIGHT.click(); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..dffcc153d 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -33,6 +33,7 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 2cb1c7255..4bcf3761d 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,8 +26,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; // Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java public class AutoBoop implements AbstractHypixelMod { @@ -41,6 +42,8 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -48,10 +51,11 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.getString().contains("Friend >") && message.getString().contains("joined.")) { - String player = message.getString().substring(message.getString().indexOf(">"), - message.getString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); + if (enabled.get() && message.contains("Friend >") && message.contains("joined.")) { + String player = message.substring(message.indexOf(">"), + message.lastIndexOf(" ")); Util.sendChatMessage("/boop " + player); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index f9c18e6aa..242f04c78 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -32,9 +32,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -88,6 +89,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -158,28 +161,28 @@ private List addToList(String... strings) { return Arrays.stream(strings).collect(Collectors.toList()); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { if (gf.get()) { - processChat(message, gfStrings.get(s), gfString.get()); + processChat(event.getOriginalMessage(), gfStrings.get(s), gfString.get()); } if (gg.get()) { - processChat(message, ggStrings.get(s), ggString.get()); + processChat(event.getOriginalMessage(), ggStrings.get(s), ggString.get()); } if (glhf.get()) { - processChat(message, glhfStrings.get(s), glhfString.get()); + processChat(event.getOriginalMessage(), glhfStrings.get(s), glhfString.get()); } } }); } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.getString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 23c9956e7..0ac749b0e 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -28,9 +28,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; public class AutoTip implements AbstractHypixelMod { @@ -52,6 +53,8 @@ public class AutoTip implements AbstractHypixelMod { @Override public void init() { category.add(enabled, hideMessages); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); init = true; } @@ -80,8 +83,8 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && (messagePattern.matcher(text.getString()).matches() - || tippedPattern.matcher(text.getString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && (messagePattern.matcher(event.getOriginalMessage()).matches() + || tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..9550fc1f7 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,473 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +public class BedwarsGame { + private BedwarsTeam won = null; + private int wonTick = -1; + private int seconds = 0; + private Text topBarText = new LiteralText(""); + private Text bottomBarText = new LiteralText(""); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + teamPlayers.compute(team, (t, entries) -> { + if (entries == null) { + List players = new ArrayList<>(); + players.add(player); + return players; + } + entries.add(player); + return entries; + }); + } + for (Map.Entry> teamPlayerList : teamPlayers.entrySet()) { + teamPlayerList.getValue().sort(Comparator.comparing(p -> p.getProfile().getName())); + List value = teamPlayerList.getValue(); + for (int i = 0; i < value.size(); i++) { + PlayerListEntry e = value.get(i); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + public Text getBottomBarText() { + return bottomBarText; + } + + private String calculateTopBarText() { + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); + } + + private String calculateBottomBarText() { + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) + .collect(Collectors.joining("\n"));*/ + } + + public String getFormattedTime() { + int minute = seconds / 60; + int second = seconds % 60; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + return time; + } + + public Optional getPlayer(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + + public Optional getPlayer(String name) { + return Optional.ofNullable(players.getOrDefault(name, null)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(new LiteralText("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDeath(player, killer, type, finalDeath))); + } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = killer; + } + } + + private String formatDisconnect(BedwarsPlayer disconnected) { + String playerFormatted = getPlayerFormatted(disconnected); + return playerFormatted + " §7§o/disconnected/"; + } + + private String formatReconnect(BedwarsPlayer reconnected) { + String playerFormatted = getPlayerFormatted(reconnected); + return playerFormatted + " §7§o/reconnected/"; + } + + private String formatEliminated(BedwarsTeam team) { + StringBuilder message = new StringBuilder( + "§6§l§oTEAM ELIMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "); + for (BedwarsPlayer p : players.values().stream() + .filter(b -> b.getTeam() == team) + .sorted(Comparator.comparingInt(BedwarsPlayer::getNumber)) + .collect(Collectors.toList())) { + BedwarsPlayerStats stats = p.getStats(); + if (stats == null) { + continue; + } + message.append("\n") + .append("§b") + .append(stats.getStars()) + .append(" ") + .append(p.getColoredName()) + .append("§7 Beds: §f") + .append(stats.getBedsBroken()) + .append("§7 Finals: §f") + .append(stats.getFinalKills()) + .append("§7 FKDR: §f") + .append(String.format("%.2f", stats.getFKDR())) + .append("§7 BBLR: §f") + .append(String.format("%.2f", stats.getBBLR())); + } + return message.toString(); + } + + private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { + String playerFormatted = getPlayerFormatted(breaker); + return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted + + (breaker.getStats() == null || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner().get(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + if (BedwarsDeathType.getDeath(rawMessage, (type, m) -> { + died(m, rawMessage, event, type); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.BED_DESTROY, rawMessage, m -> { + BedwarsPlayer player = BedwarsMessages.matched(BedwarsMessages.BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); + BedwarsTeam team = BedwarsTeam.fromName(m.group(1)).orElse(me.getTeam()); + bedDestroyed(event, team, player); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> disconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> reconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.GAME_END, rawMessage, m -> { + BedwarsTeam win = players.values().stream().filter(p -> !p.isFinalKilled()).findFirst().map(BedwarsPlayer::getTeam).orElse(null); + this.won = win; + this.wonTick = mc.inGameHud.getTicks() + 10; + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + private void died(Matcher m, String rawMessage, ReceiveChatMessageEvent event, BedwarsDeathType type) { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + BedwarsPlayer killer = null; + if (type != BedwarsDeathType.SELF_UNKNOWN && type != BedwarsDeathType.SELF_VOID) { + killer = getPlayer(m.group(2)).orElse(null); + } + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(event, killed, killer, type, BedwarsMessages.matched(BedwarsMessages.FINAL_KILL, rawMessage).isPresent()); + } + + private void gameEnd(BedwarsTeam win) { + if (me == null) { + BedwarsMod.getInstance().gameEnd(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + new LiteralText("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + new LiteralText( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { + // Make sure everyone is dead, just in case + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { + b.setBed(false); + b.died(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatEliminated(team))); + } + } + + private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + if (breaker != null && breaker.getStats() != null) { + breaker.getStats().addBed(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + Collections.reverse(filteredScores); + if (filteredScores.size() < 3) { + return; + } + ScoreboardPlayerScore score = filteredScores.get(2); + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String timer = Team.decorateName(team, new LiteralText(score.getPlayerName())).getString(); + if (!timer.contains(":")) { + return; + } + int seconds; + try { + seconds = Integer.parseInt(timer.split(":")[1].substring(0, 2)); + } catch (Exception e) { + e.printStackTrace(); + return; + } + int target = (60 - seconds) % 60; + if (this.seconds % 60 != target) { + // Update seconds + while (this.seconds % 60 != target) { + updateClock(); + } + topBarText = new LiteralText(calculateTopBarText()); + bottomBarText = new LiteralText(calculateBottomBarText()); + } + } + + private void updateClock() { + this.seconds++; + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + public void updateEntries(List entries) { + // Update latencies and other information for entries + entries.forEach(entry -> + getPlayer(entry.getProfile().getName()).ifPresent(player -> player.updateListEntry(entry)) + ); + } + + public List getTabPlayerList(List original) { + updateEntries(original); + return players.values().stream().filter(b -> !b.isFinalKilled()).sorted((b1, b2) -> { + if (b1.getTeam() == b2.getTeam()) { + return Integer.compare(b1.getNumber(), b2.getNumber()); + } + return Integer.compare(b1.getTeam().ordinal(), b2.getTeam().ordinal()); + }).map(BedwarsPlayer::getProfile).collect(Collectors.toList()); + } + + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); + } + + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX){ + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..2238e880d --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,228 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.LiteralText; +import net.minecraft.util.Formatting; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + private final static Pattern[] GAME_START = { + Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(new LiteralText(time).append(event.getNewMessage())); + } else { + event.setNewMessage(new LiteralText(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, new LiteralText(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..07bce84e3 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + private boolean disconnected = false; + private boolean bed = true; + private final int number; + private BedwarsPlayerStats stats = null; + private boolean triedStats = false; + private int tickAlive = -1; + + public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { + this.team = team; + this.profile = profile; + this.number = number; + } + + public String getColoredTeamNumber(String format) { + return getTeam().getColorSection() + format + getTeam().getPrefix() + getNumber(); + } + + public String getColoredTeamNumber() { + return getTeam().getColorSection() + getTeam().getPrefix() + getNumber(); + } + + public String getName() { + return profile.getProfile().getName(); + } + + public String getColoredName() { + return team.getColorSection() + getName(); + } + + public String getTabListDisplay() { + if (alive) { + if (bed) { + return team.getColorSection() + "§l" + team.getPrefix() + number + " " + getColoredName(); + } + return team.getColorSection() + "§l" + team.getPrefix() + number + team.getColorSection() + "§o " + getName(); + } + if (disconnected) { + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §o§n" + getName(); + } + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §m" + getName(); + } + + public void updateListEntry(PlayerListEntry entry) { + this.profile = entry; + } + + public boolean isFinalKilled() { + return tickAlive < 0 && !bed && !alive || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + public void died() { + if (!alive) { + if (!bed) { + tickAlive = -1; + } + return; + } + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + alive = false; + if (!bed) { + tickAlive = -1; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 10; // 10 second respawn + } + + public void killed(boolean finalKill) { + if (stats != null) { + if (finalKill) { + stats.addFinalKill(); + } + stats.addKill(); + } + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..f150b14c3 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,140 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.List; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableAlphaTest(); + RenderSystem.enableBlend(); + RenderSystem.color4f(1, 1, 1, 1); + boolean normalUpgrades = false; + if (upgrades != null) { + for (TeamUpgrade u : upgrades.upgrades) { + if (!u.isPurchased()) { + continue; + } + if (u instanceof TrapUpgrade) { + continue; + } + TextureInfo texture; + texture = u.getTexture()[0]; + RenderSystem.color4f(texture.getColor().getAlpha(), texture.getColor().getRed(), texture.getColor().getBlue(), texture.getColor().getGreen()); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.color4f(1, 1, 1, 1); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.color4f(texture.getColor().getAlpha(), texture.getColor().getRed(), texture.getColor().getBlue(), texture.getColor().getGreen()); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.color4f(1, 1, 1, 1); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), false); + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..b93109e79 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +public class BedwarsTeamUpgrades { + + public final TrapUpgrade trap = new TrapUpgrade(); + + public final TeamUpgrade sharpness = new BinaryUpgrade( + "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,3}\\s*$"), + new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,3}\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + public final TeamUpgrade forge = new TieredUpgrade( + "forge", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (?:Iron|Golden|Emerald|Molten) Forge\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; + + public BedwarsTeamUpgrades() { + + } + + public void onMessage(String rawMessage) { + for (TeamUpgrade upgrade : upgrades) { + if (upgrade.match(rawMessage)) { + return; + } + } + } + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..71de40a58 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,128 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +public class TrapUpgrade extends TeamUpgrade { + + private final static Pattern[] REGEX = { + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), + Pattern.compile("Trap was set (off)!"), + }; + + private final List traps = new ArrayList<>(3); + + public TrapUpgrade() { + super("trap", REGEX); + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + if (matcher.group(1).equals("off")) { + // Trap went off + traps.remove(0); + return; + } + traps.add(TrapType.getFuzzy(matcher.group(1))); + } + + public boolean canPurchase() { + return traps.size() < 3; + } + + @Override + public int getPrice(BedwarsMode mode) { + switch (traps.size()) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 4; + } + ; + return 0; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + public static TrapType getFuzzy(String s) { + s = s.toLowerCase(Locale.ROOT); + if (s.contains("miner")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index 0b90f79dd..ba5d9490e 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { @@ -206,6 +207,4 @@ public void initRPC() { } - - } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index 067fa5c07..ea0cd5cef 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index e0ca4926e..2b5c4d7c5 100644 --- a/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.16.5/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -78,14 +78,14 @@ public void reload(ResourceManager manager) { } for (Identifier entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.endsWith(".properties"))) { + .findResources("mcpatcher/sky", this::isMCPSky)) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry); loadMCPSky("mcpatcher", entry, manager.getResource(entry)); AxolotlClient.LOGGER.debug("Loaded MCP sky from " + entry); } for (Identifier entry : manager - .findResources("optifine/sky", identifier -> identifier.endsWith(".properties"))) { + .findResources("optifine/sky", this::isMCPSky)) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry); loadMCPSky("optifine", entry, manager.getResource(entry)); AxolotlClient.LOGGER.debug("Loaded OF sky from " + entry); @@ -97,6 +97,10 @@ public void reload(ResourceManager manager) { } } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private void loadMCPSky(String loader, Identifier id, Resource resource) { BufferedReader reader = new BufferedReader( new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)); diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.16.5/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index 44f025fce..000000000 --- a/1.16.5/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright © 2021-2023 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 net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = EventFactory.createArrayBacked(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = EventFactory.createArrayBacked(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = EventFactory.createArrayBacked(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = EventFactory - .createArrayBacked(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBinding binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..ceaab12d7 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2021-2023 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.events; + +import java.util.Arrays; + +import io.github.axolotlclient.util.events.impl.*; +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent() { + return EventFactory + .createArrayBacked(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..b8f450ddc --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.util.InputUtil; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..c7518b5b8 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBinding; + +@Data +public class KeyPressEvent { + + private final KeyBinding key; +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..1217f4d0d --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..460f7b4b2 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..2b813be85 --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final ScoreboardObjective objective; +} diff --git a/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.16.5/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} 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 dffc5a5f0..fad983405 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 @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 7bb9bbadd..bfc168488 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -167,11 +167,11 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f4a36a2c1..967b301c2 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,31 +22,40 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; 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; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true) - public void axolotlclient$autoThings(Text message, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + @Inject(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;IIZ)V"), cancellable = true) + public void axolotlclient$autoThings(Text message, int messageId, CallbackInfo ci) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;I)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index cc07df4d9..f5efca90f 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 4ba4aa7e0..8a2b52100 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, false, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..64aa00f06 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,26 +22,28 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +91,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +191,40 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), + ordinal = 18 + ) + public int axolotlclient$displayHardcoreHearts(int offset) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 5 : offset; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 20 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index 1e5103a9b..a51a7996b 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -22,7 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.options.KeyBinding; import net.minecraft.client.util.InputUtil; import org.spongepowered.asm.mixin.Mixin; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBinding) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBinding) (Object) this)); } } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 4afc08eac..dd3e7539f 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -26,11 +26,14 @@ import io.github.axolotlclient.modules.blur.MenuBlur; import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -83,4 +86,9 @@ public abstract class MinecraftClientMixin { private void axolotlclient$noModdedSigns(CallbackInfoReturnable cir) { cir.setReturnValue(false); } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index d76331887..1a70efe47 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/options/KeyBinding;setKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index e60d70c11..718bec32c 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,15 +22,24 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.render.entity.PlayerModelPart; import net.minecraft.client.util.math.MatrixStack; @@ -42,14 +51,15 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -59,7 +69,8 @@ public abstract class PlayerListHudMixin { @Shadow private Text footer; - private GameProfile profile; + @Unique + private GameProfile axolotlclient$profile; @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) public void axolotlclient$nickHider(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { @@ -76,22 +87,26 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text method_27538(PlayerListEntry par1, MutableText par2); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { - profile = playerEntry.getProfile(); + axolotlclient$profile = playerEntry.getProfile(); return playerEntry; } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;getWidth(Lnet/minecraft/text/StringVisitable;)I")) public int axolotlclient$moveName(TextRenderer instance, StringVisitable text) { - if (profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(profile.getId())) + if (axolotlclient$profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$profile.getId())) return instance.getWidth(text) + 10; return instance.getWidth(text); } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/text/Text;FFI)I")) public int axolotlclient$moveName2(TextRenderer instance, MatrixStack matrices, Text text, float x, float y, int color) { - if (profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(profile.getId())) { + if (axolotlclient$profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$profile.getId())) { MinecraftClient.getInstance().getTextureManager().bindTexture(AxolotlClient.badgeIcon); RenderSystem.color4f(1, 1, 1, 1); @@ -99,7 +114,7 @@ public abstract class PlayerListHudMixin { x += 9; } - profile = null; + axolotlclient$profile = null; return instance.drawWithShadow(matrices, text, x, y, color); } @@ -116,7 +131,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -151,4 +168,132 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$alwaysShowHeadLayer(PlayerEntity instance, PlayerModelPart modelPart) { return Tablist.getInstance().alwaysShowHeadLayer.get() || instance.isPartVisible(modelPart); } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, CallbackInfo ci, + ClientPlayNetworkHandler clientPlayNetworkHandler, List list, int i, int j, int l, int m, int k, + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 + ) { + if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I", + ordinal = 1 + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, + PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null) { + return; + } + + game.renderCustomScoreboardObjective(matrices, playerEntry.getProfile().getName(), objective, y, endX); + + ci.cancel(); + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null || !game.isStarted()) { + return; + } + BedwarsPlayer player = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + if (player == null) { + return; + } + cir.setReturnValue(player.getTabListDisplay()); + } + + @ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/google/common/collect/Ordering;sortedCopy(Ljava/lang/Iterable;)Ljava/util/List;", remap = false)) + public List axolotlclient$overrideSortedPlayers(List original) { + if (!BedwarsMod.getInstance().inGame()) { + return original; + } + List players = BedwarsMod.getInstance().getGame().get().getTabPlayerList(original); + if (players == null) { + return original; + } + return players; + } + + @Inject(method = "setHeader", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 5a80ea675..cca9c19fa 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -38,6 +38,7 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.options.KeyBinding; import net.minecraft.client.util.math.MatrixStack; @@ -57,6 +58,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); @@ -100,6 +102,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 655ab83fc..f253f820f 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -35,7 +35,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.options.KeyBinding; import net.minecraft.client.util.InputUtil; @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index c5a6e890a..08fc39080 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -29,7 +29,8 @@ import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -65,11 +66,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index e05125d6f..442dc2cf6 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -28,7 +28,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register((event) -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.keyAttack)) { + if (event.getKey().equals(client.options.keyAttack)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.keyUse)) { + } else if (event.getKey().equals(client.options.keyUse)) { ClickList.RIGHT.click(); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..dffcc153d 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -33,6 +33,7 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 2cb1c7255..a500fa8f7 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,8 +26,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; // Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java public class AutoBoop implements AbstractHypixelMod { @@ -41,6 +42,7 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -48,10 +50,11 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.getString().contains("Friend >") && message.getString().contains("joined.")) { - String player = message.getString().substring(message.getString().indexOf(">"), - message.getString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); + if (enabled.get() && message.contains("Friend >") && message.contains("joined.")) { + String player = message.substring(message.indexOf(">"), + message.lastIndexOf(" ")); Util.sendChatMessage("/boop " + player); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index f9c18e6aa..242f04c78 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -32,9 +32,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -88,6 +89,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -158,28 +161,28 @@ private List addToList(String... strings) { return Arrays.stream(strings).collect(Collectors.toList()); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { if (gf.get()) { - processChat(message, gfStrings.get(s), gfString.get()); + processChat(event.getOriginalMessage(), gfStrings.get(s), gfString.get()); } if (gg.get()) { - processChat(message, ggStrings.get(s), ggString.get()); + processChat(event.getOriginalMessage(), ggStrings.get(s), ggString.get()); } if (glhf.get()) { - processChat(message, glhfStrings.get(s), glhfString.get()); + processChat(event.getOriginalMessage(), glhfStrings.get(s), glhfString.get()); } } }); } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.getString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 23c9956e7..6c24e6511 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -28,9 +28,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; public class AutoTip implements AbstractHypixelMod { @@ -53,6 +54,8 @@ public class AutoTip implements AbstractHypixelMod { public void init() { category.add(enabled, hideMessages); init = true; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); } @Override @@ -65,7 +68,7 @@ public void tick() { if (init) { if (System.currentTimeMillis() - lastTime > 1200000 && MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel") + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") && enabled.get()) { if (MinecraftClient.getInstance().player != null) { Util.sendChatMessage("/tip all"); @@ -80,8 +83,8 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && (messagePattern.matcher(text.getString()).matches() - || tippedPattern.matcher(text.getString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && (messagePattern.matcher(event.getOriginalMessage()).matches() + || tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..eff0ee94c --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,473 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +public class BedwarsGame { + private BedwarsTeam won = null; + private int wonTick = -1; + private int seconds = 0; + private Text topBarText = new LiteralText(""); + private Text bottomBarText = new LiteralText(""); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + teamPlayers.compute(team, (t, entries) -> { + if (entries == null) { + List players = new ArrayList<>(); + players.add(player); + return players; + } + entries.add(player); + return entries; + }); + } + for (Map.Entry> teamPlayerList : teamPlayers.entrySet()) { + teamPlayerList.getValue().sort(Comparator.comparing(p -> p.getProfile().getName())); + List value = teamPlayerList.getValue(); + for (int i = 0; i < value.size(); i++) { + PlayerListEntry e = value.get(i); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + public Text getBottomBarText() { + return bottomBarText; + } + + private String calculateTopBarText() { + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); + } + + private String calculateBottomBarText() { + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) + .collect(Collectors.joining("\n"));*/ + } + + public String getFormattedTime() { + int minute = seconds / 60; + int second = seconds % 60; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + return time; + } + + public Optional getPlayer(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + + public Optional getPlayer(String name) { + return Optional.ofNullable(players.getOrDefault(name, null)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(new LiteralText("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDeath(player, killer, type, finalDeath))); + } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = killer; + } + } + + private String formatDisconnect(BedwarsPlayer disconnected) { + String playerFormatted = getPlayerFormatted(disconnected); + return playerFormatted + " §7§o/disconnected/"; + } + + private String formatReconnect(BedwarsPlayer reconnected) { + String playerFormatted = getPlayerFormatted(reconnected); + return playerFormatted + " §7§o/reconnected/"; + } + + private String formatEliminated(BedwarsTeam team) { + StringBuilder message = new StringBuilder( + "§6§l§oTEAM ELIMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "); + for (BedwarsPlayer p : players.values().stream() + .filter(b -> b.getTeam() == team) + .sorted(Comparator.comparingInt(BedwarsPlayer::getNumber)) + .collect(Collectors.toList())) { + BedwarsPlayerStats stats = p.getStats(); + if (stats == null) { + continue; + } + message.append("\n") + .append("§b") + .append(stats.getStars()) + .append(" ") + .append(p.getColoredName()) + .append("§7 Beds: §f") + .append(stats.getBedsBroken()) + .append("§7 Finals: §f") + .append(stats.getFinalKills()) + .append("§7 FKDR: §f") + .append(String.format("%.2f", stats.getFKDR())) + .append("§7 BBLR: §f") + .append(String.format("%.2f", stats.getBBLR())); + } + return message.toString(); + } + + private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { + String playerFormatted = getPlayerFormatted(breaker); + return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted + + (breaker.getStats() == null || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner().get(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + if (BedwarsDeathType.getDeath(rawMessage, (type, m) -> { + died(m, rawMessage, event, type); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.BED_DESTROY, rawMessage, m -> { + BedwarsPlayer player = BedwarsMessages.matched(BedwarsMessages.BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); + BedwarsTeam team = BedwarsTeam.fromName(m.group(1)).orElse(me.getTeam()); + bedDestroyed(event, team, player); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> disconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> reconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.GAME_END, rawMessage, m -> { + BedwarsTeam win = players.values().stream().filter(p -> !p.isFinalKilled()).findFirst().map(BedwarsPlayer::getTeam).orElse(null); + this.won = win; + this.wonTick = mc.inGameHud.getTicks() + 10; + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + private void died(Matcher m, String rawMessage, ReceiveChatMessageEvent event, BedwarsDeathType type) { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + BedwarsPlayer killer = null; + if (type != BedwarsDeathType.SELF_UNKNOWN && type != BedwarsDeathType.SELF_VOID) { + killer = getPlayer(m.group(2)).orElse(null); + } + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(event, killed, killer, type, BedwarsMessages.matched(BedwarsMessages.FINAL_KILL, rawMessage).isPresent()); + } + + private void gameEnd(BedwarsTeam win) { + if (me == null) { + BedwarsMod.getInstance().gameEnd(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + new LiteralText("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + new LiteralText( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { + // Make sure everyone is dead, just in case + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { + b.setBed(false); + b.died(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatEliminated(team))); + } + } + + private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + if (breaker != null && breaker.getStats() != null) { + breaker.getStats().addBed(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + Collections.reverse(filteredScores); + if (filteredScores.size() < 3) { + return; + } + ScoreboardPlayerScore score = filteredScores.get(2); + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String timer = Team.modifyText(team, new LiteralText(score.getPlayerName())).getString(); + if (!timer.contains(":")) { + return; + } + int seconds; + try { + seconds = Integer.parseInt(timer.split(":")[1].substring(0, 2)); + } catch (Exception e) { + e.printStackTrace(); + return; + } + int target = (60 - seconds) % 60; + if (this.seconds % 60 != target) { + // Update seconds + while (this.seconds % 60 != target) { + updateClock(); + } + topBarText = new LiteralText(calculateTopBarText()); + bottomBarText = new LiteralText(calculateBottomBarText()); + } + } + + private void updateClock() { + this.seconds++; + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + public void updateEntries(List entries) { + // Update latencies and other information for entries + entries.forEach(entry -> + getPlayer(entry.getProfile().getName()).ifPresent(player -> player.updateListEntry(entry)) + ); + } + + public List getTabPlayerList(List original) { + updateEntries(original); + return players.values().stream().filter(b -> !b.isFinalKilled()).sorted((b1, b2) -> { + if (b1.getTeam() == b2.getTeam()) { + return Integer.compare(b1.getNumber(), b2.getNumber()); + } + return Integer.compare(b1.getTeam().ordinal(), b2.getTeam().ordinal()); + }).map(BedwarsPlayer::getProfile).collect(Collectors.toList()); + } + + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); + } + + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX){ + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..995aeda4b --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,229 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.LiteralText; +import net.minecraft.util.Formatting; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + private final static Pattern[] GAME_START = { + Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(new LiteralText(time).append(event.getNewMessage())); + } else { + event.setNewMessage(new LiteralText(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListWidget().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListWidget().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.modifyText(team, new LiteralText(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..07bce84e3 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + private boolean disconnected = false; + private boolean bed = true; + private final int number; + private BedwarsPlayerStats stats = null; + private boolean triedStats = false; + private int tickAlive = -1; + + public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { + this.team = team; + this.profile = profile; + this.number = number; + } + + public String getColoredTeamNumber(String format) { + return getTeam().getColorSection() + format + getTeam().getPrefix() + getNumber(); + } + + public String getColoredTeamNumber() { + return getTeam().getColorSection() + getTeam().getPrefix() + getNumber(); + } + + public String getName() { + return profile.getProfile().getName(); + } + + public String getColoredName() { + return team.getColorSection() + getName(); + } + + public String getTabListDisplay() { + if (alive) { + if (bed) { + return team.getColorSection() + "§l" + team.getPrefix() + number + " " + getColoredName(); + } + return team.getColorSection() + "§l" + team.getPrefix() + number + team.getColorSection() + "§o " + getName(); + } + if (disconnected) { + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §o§n" + getName(); + } + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §m" + getName(); + } + + public void updateListEntry(PlayerListEntry entry) { + this.profile = entry; + } + + public boolean isFinalKilled() { + return tickAlive < 0 && !bed && !alive || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + public void died() { + if (!alive) { + if (!bed) { + tickAlive = -1; + } + return; + } + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + alive = false; + if (!bed) { + tickAlive = -1; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 10; // 10 second respawn + } + + public void killed(boolean finalKill) { + if (stats != null) { + if (finalKill) { + stats.addFinalKill(); + } + stats.addKill(); + } + } +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..f150b14c3 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,140 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.List; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableAlphaTest(); + RenderSystem.enableBlend(); + RenderSystem.color4f(1, 1, 1, 1); + boolean normalUpgrades = false; + if (upgrades != null) { + for (TeamUpgrade u : upgrades.upgrades) { + if (!u.isPurchased()) { + continue; + } + if (u instanceof TrapUpgrade) { + continue; + } + TextureInfo texture; + texture = u.getTexture()[0]; + RenderSystem.color4f(texture.getColor().getAlpha(), texture.getColor().getRed(), texture.getColor().getBlue(), texture.getColor().getGreen()); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.color4f(1, 1, 1, 1); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.color4f(texture.getColor().getAlpha(), texture.getColor().getRed(), texture.getColor().getBlue(), texture.getColor().getGreen()); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.color4f(1, 1, 1, 1); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), false); + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..b93109e79 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +public class BedwarsTeamUpgrades { + + public final TrapUpgrade trap = new TrapUpgrade(); + + public final TeamUpgrade sharpness = new BinaryUpgrade( + "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,3}\\s*$"), + new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,3}\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + public final TeamUpgrade forge = new TieredUpgrade( + "forge", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (?:Iron|Golden|Emerald|Molten) Forge\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; + + public BedwarsTeamUpgrades() { + + } + + public void onMessage(String rawMessage) { + for (TeamUpgrade upgrade : upgrades) { + if (upgrade.match(rawMessage)) { + return; + } + } + } + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..71de40a58 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,128 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +public class TrapUpgrade extends TeamUpgrade { + + private final static Pattern[] REGEX = { + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), + Pattern.compile("Trap was set (off)!"), + }; + + private final List traps = new ArrayList<>(3); + + public TrapUpgrade() { + super("trap", REGEX); + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + if (matcher.group(1).equals("off")) { + // Trap went off + traps.remove(0); + return; + } + traps.add(TrapType.getFuzzy(matcher.group(1))); + } + + public boolean canPurchase() { + return traps.size() < 3; + } + + @Override + public int getPrice(BedwarsMode mode) { + switch (traps.size()) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 4; + } + ; + return 0; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + public static TrapType getFuzzy(String s) { + s = s.toLowerCase(Locale.ROOT); + if (s.contains("miner")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} 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 index 0b90f79dd..ba5d9490e 100644 --- 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 @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { @@ -206,6 +207,4 @@ public void initRPC() { } - - } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index 9e6d2e2c1..e4549ff12 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 83c6c373d..17926a810 100644 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -78,14 +78,14 @@ public void apply(ResourceManager manager) { } for (Identifier entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.endsWith(".properties"))) { + .findResources("mcpatcher/sky", this::isMCPSky)) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry); loadMCPSky("mcpatcher", entry, manager.getResource(entry)); AxolotlClient.LOGGER.debug("Loaded MCP sky from " + entry); } for (Identifier entry : manager - .findResources("optifine/sky", identifier -> identifier.endsWith(".properties"))) { + .findResources("optifine/sky", this::isMCPSky)) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry); loadMCPSky("optifine", entry, manager.getResource(entry)); AxolotlClient.LOGGER.debug("Loaded OF sky from " + entry); @@ -97,6 +97,10 @@ public void apply(ResourceManager manager) { } } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private void loadMCPSky(String loader, Identifier id, Resource resource) { BufferedReader reader = new BufferedReader( new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)); diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index 52e90af02..000000000 --- a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright © 2021-2023 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 net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.minecraft.client.options.KeyBinding; -import net.minecraft.client.util.InputUtil; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = EventFactory.createArrayBacked(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = EventFactory.createArrayBacked(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = EventFactory.createArrayBacked(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = EventFactory - .createArrayBacked(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBinding binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..ceaab12d7 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2021-2023 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.events; + +import java.util.Arrays; + +import io.github.axolotlclient.util.events.impl.*; +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent() { + return EventFactory + .createArrayBacked(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..b8f450ddc --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.util.InputUtil; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..b36c489c9 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.options.KeyBinding; + +@Data +public class KeyPressEvent { + + private final KeyBinding key; +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..1217f4d0d --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..460f7b4b2 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..2b813be85 --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final ScoreboardObjective objective; +} diff --git a/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.16_combat-6/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.19.2/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 65391d00d..2f0c3f79a 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 8403295f0..bdb02b38c 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -163,11 +163,11 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index df6ce02af..6995afe20 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,10 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatMessageTag; import net.minecraft.network.chat.MessageSignature; @@ -34,21 +33,31 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), cancellable = true) public void axolotlclient$autoThings(Text message, MessageSignature signature, ChatMessageTag tag, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/chat/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index ee7520b6e..e13f9b3f0 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 4ba4aa7e0..8a2b52100 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, false, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..b5e0655c6 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,26 +22,28 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +91,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +191,40 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderHealthBar", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$displayHardcoreHearts(int v) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return (hardcore ? 9 * 5 : v); + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 15 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index bae9a75ca..16bbd5622 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -23,7 +23,9 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBind; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBind) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBind) ((Object) this))); } } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 9f53f46fa..be9243592 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,10 +27,13 @@ import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import net.minecraft.resource.ResourceType; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.qsl.resource.loader.api.ResourceLoader; @@ -82,4 +85,9 @@ public abstract class MinecraftClientMixin { MenuBlur.getInstance().onScreenOpen(); } } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 49c1cc4bb..8b962b876 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBind;setKeyPressed(Lcom/mojang/blaze3d/platform/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 0f3d70692..9e290e75e 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,15 +22,24 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.ClientConnection; @@ -39,14 +48,14 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -72,6 +81,10 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry entry, MutableText name); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { profile = playerEntry.getProfile(); @@ -112,7 +125,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -147,4 +162,132 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$renderHatLayer(boolean drawHat) { return Tablist.getInstance().alwaysShowHeadLayer.get() || drawHat; } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, CallbackInfo ci, + ClientPlayNetworkHandler clientPlayNetworkHandler, List list, int i, int j, int l, int m, int k, + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 + ) { + if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I", + ordinal = 1 + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, + PlayerListEntry playerEntry, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null) { + return; + } + + game.renderCustomScoreboardObjective(matrices, playerEntry.getProfile().getName(), objective, y, endX); + + ci.cancel(); + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null || !game.isStarted()) { + return; + } + BedwarsPlayer player = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + if (player == null) { + return; + } + cir.setReturnValue(player.getTabListDisplay()); + } + + @ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/google/common/collect/Ordering;sortedCopy(Ljava/lang/Iterable;)Ljava/util/List;", remap = false)) + public List axolotlclient$overrideSortedPlayers(List original) { + if (!BedwarsMod.getInstance().inGame()) { + return original; + } + List players = BedwarsMod.getInstance().getGame().get().getTabPlayerList(original); + if (players == null) { + return original; + } + return players; + } + + @Inject(method = "setHeader", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 37b523884..7f0484b6a 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -39,6 +39,7 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBind; import net.minecraft.client.util.math.MatrixStack; @@ -57,6 +58,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); @@ -100,6 +102,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 332f2e0d6..52de2bd98 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -36,7 +36,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBind; import net.minecraft.client.util.math.MatrixStack; @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index bd36207a0..a124dfa08 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -30,7 +30,8 @@ import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -65,11 +66,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 19bcca2d6..b9f702184 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -28,7 +28,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.attackKey)) { + if (event.getKey().equals(client.options.attackKey)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.useKey)) { + } else if (event.getKey().equals(client.options.useKey)) { ClickList.RIGHT.click(); } } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java index a8916d1f5..ffc01fb5f 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -45,8 +47,6 @@ import net.minecraft.util.math.Vec3f; import net.minecraft.world.World; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java index c304e0737..9a757a3b4 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.function.Supplier; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -31,8 +33,6 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.Matrix4f; -import java.util.function.Supplier; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..dffcc153d 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -33,6 +33,7 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..8131a1957 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,473 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; +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.Formatting; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +public class BedwarsGame { + + private BedwarsTeam won = null; + private int wonTick = -1; + private int seconds = 0; + private Text topBarText = Text.empty(); + private Text bottomBarText = Text.empty(); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + teamPlayers.compute(team, (t, entries) -> { + if (entries == null) { + List players = new ArrayList<>(); + players.add(player); + return players; + } + entries.add(player); + return entries; + }); + } + for (Map.Entry> teamPlayerList : teamPlayers.entrySet()) { + teamPlayerList.getValue().sort(Comparator.comparing(p -> p.getProfile().getName())); + List value = teamPlayerList.getValue(); + for (int i = 0; i < value.size(); i++) { + PlayerListEntry e = value.get(i); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + public Text getBottomBarText() { + return bottomBarText; + } + + private String calculateTopBarText() { + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); + } + + private String calculateBottomBarText() { + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) + .collect(Collectors.joining("\n"));*/ + } + + public String getFormattedTime() { + int minute = seconds / 60; + int second = seconds % 60; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + return time; + } + + public Optional getPlayer(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + + public Optional getPlayer(String name) { + return Optional.ofNullable(players.getOrDefault(name, null)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDeath(player, killer, type, finalDeath))); + } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = killer; + } + } + + private String formatDisconnect(BedwarsPlayer disconnected) { + String playerFormatted = getPlayerFormatted(disconnected); + return playerFormatted + " §7§o/disconnected/"; + } + + private String formatReconnect(BedwarsPlayer reconnected) { + String playerFormatted = getPlayerFormatted(reconnected); + return playerFormatted + " §7§o/reconnected/"; + } + + private String formatEliminated(BedwarsTeam team) { + StringBuilder message = new StringBuilder( + "§6§l§oTEAM ELIMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "); + for (BedwarsPlayer p : players.values().stream() + .filter(b -> b.getTeam() == team) + .sorted(Comparator.comparingInt(BedwarsPlayer::getNumber)) + .toList()) { + BedwarsPlayerStats stats = p.getStats(); + if (stats == null) { + continue; + } + message.append("\n") + .append("§b") + .append(stats.getStars()) + .append(" ") + .append(p.getColoredName()) + .append("§7 Beds: §f") + .append(stats.getBedsBroken()) + .append("§7 Finals: §f") + .append(stats.getFinalKills()) + .append("§7 FKDR: §f") + .append(String.format("%.2f", stats.getFKDR())) + .append("§7 BBLR: §f") + .append(String.format("%.2f", stats.getBBLR())); + } + return message.toString(); + } + + private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { + String playerFormatted = getPlayerFormatted(breaker); + return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted + + (breaker.getStats() == null || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner().get(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + if (BedwarsDeathType.getDeath(rawMessage, (type, m) -> { + died(m, rawMessage, event, type); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.BED_DESTROY, rawMessage, m -> { + BedwarsPlayer player = BedwarsMessages.matched(BedwarsMessages.BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); + BedwarsTeam team = BedwarsTeam.fromName(m.group(1)).orElse(me.getTeam()); + bedDestroyed(event, team, player); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> disconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> reconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.GAME_END, rawMessage, m -> { + BedwarsTeam win = players.values().stream().filter(p -> !p.isFinalKilled()).findFirst().map(BedwarsPlayer::getTeam).orElse(null); + this.won = win; + this.wonTick = mc.inGameHud.getTicks() + 10; + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + private void died(Matcher m, String rawMessage, ReceiveChatMessageEvent event, BedwarsDeathType type) { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + BedwarsPlayer killer = null; + if (type != BedwarsDeathType.SELF_UNKNOWN && type != BedwarsDeathType.SELF_VOID) { + killer = getPlayer(m.group(2)).orElse(null); + } + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(event, killed, killer, type, BedwarsMessages.matched(BedwarsMessages.FINAL_KILL, rawMessage).isPresent()); + } + + private void gameEnd(BedwarsTeam win) { + if (me == null) { + BedwarsMod.getInstance().gameEnd(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + Text.literal("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + Text.literal( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { + // Make sure everyone is dead, just in case + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { + b.setBed(false); + b.died(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatEliminated(team))); + } + } + + private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + if (breaker != null && breaker.getStats() != null) { + breaker.getStats().addBed(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + Collections.reverse(filteredScores); + if (filteredScores.size() < 3) { + return; + } + ScoreboardPlayerScore score = filteredScores.get(2); + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String timer = Team.decorateName(team, Text.literal(score.getPlayerName())).getString(); + if (!timer.contains(":")) { + return; + } + int seconds; + try { + seconds = Integer.parseInt(timer.split(":")[1].substring(0, 2)); + } catch (Exception e) { + e.printStackTrace(); + return; + } + int target = (60 - seconds) % 60; + if (this.seconds % 60 != target) { + // Update seconds + while (this.seconds % 60 != target) { + updateClock(); + } + topBarText = Text.literal(calculateTopBarText()); + bottomBarText = Text.literal(calculateBottomBarText()); + } + } + + private void updateClock() { + this.seconds++; + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + public void updateEntries(List entries) { + // Update latencies and other information for entries + entries.forEach(entry -> + getPlayer(entry.getProfile().getName()).ifPresent(player -> player.updateListEntry(entry)) + ); + } + + public List getTabPlayerList(List original) { + updateEntries(original); + return players.values().stream().filter(b -> !b.isFinalKilled()).sorted((b1, b2) -> { + if (b1.getTeam() == b2.getTeam()) { + return Integer.compare(b1.getNumber(), b2.getNumber()); + } + return Integer.compare(b1.getTeam().ordinal(), b2.getTeam().ordinal()); + }).map(BedwarsPlayer::getProfile).collect(Collectors.toList()); + } + + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); + } + + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX) { + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..70e09404a --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,227 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + private final static Pattern[] GAME_START = { + Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(Text.literal(time).append(event.getNewMessage())); + } else { + event.setNewMessage(Text.literal(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .toList(); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, Text.literal(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..07bce84e3 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + private boolean disconnected = false; + private boolean bed = true; + private final int number; + private BedwarsPlayerStats stats = null; + private boolean triedStats = false; + private int tickAlive = -1; + + public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { + this.team = team; + this.profile = profile; + this.number = number; + } + + public String getColoredTeamNumber(String format) { + return getTeam().getColorSection() + format + getTeam().getPrefix() + getNumber(); + } + + public String getColoredTeamNumber() { + return getTeam().getColorSection() + getTeam().getPrefix() + getNumber(); + } + + public String getName() { + return profile.getProfile().getName(); + } + + public String getColoredName() { + return team.getColorSection() + getName(); + } + + public String getTabListDisplay() { + if (alive) { + if (bed) { + return team.getColorSection() + "§l" + team.getPrefix() + number + " " + getColoredName(); + } + return team.getColorSection() + "§l" + team.getPrefix() + number + team.getColorSection() + "§o " + getName(); + } + if (disconnected) { + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §o§n" + getName(); + } + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §m" + getName(); + } + + public void updateListEntry(PlayerListEntry entry) { + this.profile = entry; + } + + public boolean isFinalKilled() { + return tickAlive < 0 && !bed && !alive || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + public void died() { + if (!alive) { + if (!bed) { + tickAlive = -1; + } + return; + } + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + alive = false; + if (!bed) { + tickAlive = -1; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 10; // 10 second respawn + } + + public void killed(boolean finalKill) { + if (stats != null) { + if (finalKill) { + stats.addFinalKill(); + } + stats.addKill(); + } + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..a1b76928e --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,139 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.List; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableBlend(); + RenderSystem.setShaderColor(1, 1, 1, 1); + boolean normalUpgrades = false; + if (upgrades != null) { + for (TeamUpgrade u : upgrades.upgrades) { + if (!u.isPurchased()) { + continue; + } + if (u instanceof TrapUpgrade) { + continue; + } + TextureInfo texture; + texture = u.getTexture()[0]; + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), false); + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..b93109e79 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +public class BedwarsTeamUpgrades { + + public final TrapUpgrade trap = new TrapUpgrade(); + + public final TeamUpgrade sharpness = new BinaryUpgrade( + "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,3}\\s*$"), + new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,3}\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + public final TeamUpgrade forge = new TieredUpgrade( + "forge", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (?:Iron|Golden|Emerald|Molten) Forge\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; + + public BedwarsTeamUpgrades() { + + } + + public void onMessage(String rawMessage) { + for (TeamUpgrade upgrade : upgrades) { + if (upgrade.match(rawMessage)) { + return; + } + } + } + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..71de40a58 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,128 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +public class TrapUpgrade extends TeamUpgrade { + + private final static Pattern[] REGEX = { + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), + Pattern.compile("Trap was set (off)!"), + }; + + private final List traps = new ArrayList<>(3); + + public TrapUpgrade() { + super("trap", REGEX); + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + if (matcher.group(1).equals("off")) { + // Trap went off + traps.remove(0); + return; + } + traps.add(TrapType.getFuzzy(matcher.group(1))); + } + + public boolean canPurchase() { + return traps.size() < 3; + } + + @Override + public int getPrice(BedwarsMode mode) { + switch (traps.size()) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 4; + } + ; + return 0; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + public static TrapType getFuzzy(String s) { + s = s.toLowerCase(Locale.ROOT); + if (s.contains("miner")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index abdcda05c..0ef205bc3 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { @@ -197,6 +198,4 @@ public void initRPC() { } - - } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index 8ef6214f8..e77bfa8cc 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 795795901..faf901207 100644 --- a/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.19.2/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -81,7 +81,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry.getKey()); SkyboxManager.getInstance() @@ -90,7 +90,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("optifine/sky", identifier -> identifier.getPath().endsWith(".properties")).entrySet()) { + .findResources("optifine/sky", identifier -> isMCPSky(identifier.getPath())).entrySet()) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry.getKey()); SkyboxManager.getInstance() .addSkybox(new MCPSkyboxInstance(loadMCPSky("optifine", entry.getKey(), entry.getValue()))); @@ -100,6 +100,10 @@ public void reload(ResourceManager manager) { AxolotlClient.LOGGER.debug("Finished Loading Custom Skies!"); } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private static JsonObject loadMCPSky(String loader, Identifier id, Resource resource) { JsonObject object = new JsonObject(); String line; diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.19.2/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index b35c4ab5d..000000000 --- a/1.19.2/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 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 com.mojang.blaze3d.platform.InputUtil; -import net.minecraft.client.option.KeyBind; -import org.quiltmc.qsl.base.api.event.Event; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = Event.create(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = Event.create(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = Event.create(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = Event - .create(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBind binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..65717aca9 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2021-2023 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.events; + +import java.util.Arrays; + +import io.github.axolotlclient.util.events.impl.*; +import org.quiltmc.qsl.base.api.event.Event; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent() { + return Event + .create(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..72214c8aa --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import com.mojang.blaze3d.platform.InputUtil; +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..62ad3314d --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBind; + +@Data +public class KeyPressEvent { + + private final KeyBind key; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..1217f4d0d --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..460f7b4b2 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..2b813be85 --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final ScoreboardObjective objective; +} diff --git a/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.19.2/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.19.3/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 0893875f6..3409983b9 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index a19f93005..b7d6cb511 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -161,11 +161,11 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f75f75615..098118c15 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,10 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatMessageTag; import net.minecraft.network.message.MessageSignature; @@ -34,21 +33,31 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), cancellable = true) public void axolotlclient$autoThings(Text message, MessageSignature signature, ChatMessageTag tag, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index ee7520b6e..e13f9b3f0 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 1d5bf7103..89c0f641b 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, false, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..100ed7239 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,26 +22,28 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +91,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +191,40 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderHealthBar", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$displayHardcoreHearts(int v) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 9 * 5 : v; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 15 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index bae9a75ca..16bbd5622 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -23,7 +23,9 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBind; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBind) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBind) ((Object) this))); } } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 9f53f46fa..be9243592 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,10 +27,13 @@ import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import net.minecraft.resource.ResourceType; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.qsl.resource.loader.api.ResourceLoader; @@ -82,4 +85,9 @@ public abstract class MinecraftClientMixin { MenuBlur.getInstance().onScreenOpen(); } } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 49c1cc4bb..8b962b876 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBind;setKeyPressed(Lcom/mojang/blaze3d/platform/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 0f3d70692..5134a77b9 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,15 +22,25 @@ package io.github.axolotlclient.mixin; +import java.util.List; +import java.util.UUID; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.ClientConnection; @@ -39,14 +49,14 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -72,6 +82,10 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry entry, MutableText name); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { profile = playerEntry.getProfile(); @@ -112,7 +126,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -147,4 +163,130 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$renderHatLayer(boolean drawHat) { return Tablist.getInstance().alwaysShowHeadLayer.get() || drawHat; } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, CallbackInfo ci, + ClientPlayNetworkHandler clientPlayNetworkHandler, List list, int i, int j, int l, int m, int k, + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 + ) { + if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I" + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, UUID uuid, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null) { + return; + } + + game.renderCustomScoreboardObjective(matrices, player, objective, y, endX); + + ci.cancel(); + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null || !game.isStarted()) { + return; + } + BedwarsPlayer player = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + if (player == null) { + return; + } + cir.setReturnValue(player.getTabListDisplay()); + } + + @ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/stream/Stream;toList()Ljava/util/List;", remap = false)) + public List axolotlclient$overrideSortedPlayers(List original) { + if (!BedwarsMod.getInstance().inGame()) { + return original; + } + List players = BedwarsMod.getInstance().getGame().get().getTabPlayerList(original); + if (players == null) { + return original; + } + return players; + } + + @Inject(method = "setHeader", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 8c6e755f1..977bf9eca 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -39,6 +39,7 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; @@ -56,6 +57,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); @@ -98,6 +100,8 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); + entries.values().forEach(HudEntry::init); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 332f2e0d6..52de2bd98 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -36,7 +36,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBind; import net.minecraft.client.util.math.MatrixStack; @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index b1f15db8b..8d119806a 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -30,7 +30,8 @@ import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -66,11 +67,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 19bcca2d6..b9f702184 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -28,7 +28,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.attackKey)) { + if (event.getKey().equals(client.options.attackKey)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.useKey)) { + } else if (event.getKey().equals(client.options.useKey)) { ClickList.RIGHT.click(); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java index b10c932e8..dbf59a2e8 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -45,8 +47,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java index 6a48d7964..7f1d07786 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.function.Supplier; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -31,8 +33,6 @@ import net.minecraft.client.util.math.MatrixStack; import org.joml.Matrix4f; -import java.util.function.Supplier; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..dffcc153d 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -33,6 +33,7 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 2cb1c7255..a500fa8f7 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,8 +26,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; // Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java public class AutoBoop implements AbstractHypixelMod { @@ -41,6 +42,7 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -48,10 +50,11 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.getString().contains("Friend >") && message.getString().contains("joined.")) { - String player = message.getString().substring(message.getString().indexOf(">"), - message.getString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); + if (enabled.get() && message.contains("Friend >") && message.contains("joined.")) { + String player = message.substring(message.indexOf(">"), + message.lastIndexOf(" ")); Util.sendChatMessage("/boop " + player); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index b5d93e47f..9aab4985b 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -31,9 +31,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -87,6 +88,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -157,28 +160,28 @@ private List addToList(String... strings) { return Arrays.stream(strings).toList(); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { if (gf.get()) { - processChat(message, gfStrings.get(s), gfString.get()); + processChat(event.getOriginalMessage(), gfStrings.get(s), gfString.get()); } if (gg.get()) { - processChat(message, ggStrings.get(s), ggString.get()); + processChat(event.getOriginalMessage(), ggStrings.get(s), ggString.get()); } if (glhf.get()) { - processChat(message, glhfStrings.get(s), glhfString.get()); + processChat(event.getOriginalMessage(), glhfStrings.get(s), glhfString.get()); } } }); } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.getString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 23c9956e7..72debfad4 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -28,9 +28,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; public class AutoTip implements AbstractHypixelMod { @@ -52,6 +53,9 @@ public class AutoTip implements AbstractHypixelMod { @Override public void init() { category.add(enabled, hideMessages); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); + init = true; } @@ -80,8 +84,8 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && (messagePattern.matcher(text.getString()).matches() - || tippedPattern.matcher(text.getString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && (messagePattern.matcher(event.getOriginalMessage()).matches() + || tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..8131a1957 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,473 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; +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.Formatting; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +public class BedwarsGame { + + private BedwarsTeam won = null; + private int wonTick = -1; + private int seconds = 0; + private Text topBarText = Text.empty(); + private Text bottomBarText = Text.empty(); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + teamPlayers.compute(team, (t, entries) -> { + if (entries == null) { + List players = new ArrayList<>(); + players.add(player); + return players; + } + entries.add(player); + return entries; + }); + } + for (Map.Entry> teamPlayerList : teamPlayers.entrySet()) { + teamPlayerList.getValue().sort(Comparator.comparing(p -> p.getProfile().getName())); + List value = teamPlayerList.getValue(); + for (int i = 0; i < value.size(); i++) { + PlayerListEntry e = value.get(i); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + public Text getBottomBarText() { + return bottomBarText; + } + + private String calculateTopBarText() { + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); + } + + private String calculateBottomBarText() { + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) + .collect(Collectors.joining("\n"));*/ + } + + public String getFormattedTime() { + int minute = seconds / 60; + int second = seconds % 60; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + return time; + } + + public Optional getPlayer(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + + public Optional getPlayer(String name) { + return Optional.ofNullable(players.getOrDefault(name, null)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDeath(player, killer, type, finalDeath))); + } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = killer; + } + } + + private String formatDisconnect(BedwarsPlayer disconnected) { + String playerFormatted = getPlayerFormatted(disconnected); + return playerFormatted + " §7§o/disconnected/"; + } + + private String formatReconnect(BedwarsPlayer reconnected) { + String playerFormatted = getPlayerFormatted(reconnected); + return playerFormatted + " §7§o/reconnected/"; + } + + private String formatEliminated(BedwarsTeam team) { + StringBuilder message = new StringBuilder( + "§6§l§oTEAM ELIMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "); + for (BedwarsPlayer p : players.values().stream() + .filter(b -> b.getTeam() == team) + .sorted(Comparator.comparingInt(BedwarsPlayer::getNumber)) + .toList()) { + BedwarsPlayerStats stats = p.getStats(); + if (stats == null) { + continue; + } + message.append("\n") + .append("§b") + .append(stats.getStars()) + .append(" ") + .append(p.getColoredName()) + .append("§7 Beds: §f") + .append(stats.getBedsBroken()) + .append("§7 Finals: §f") + .append(stats.getFinalKills()) + .append("§7 FKDR: §f") + .append(String.format("%.2f", stats.getFKDR())) + .append("§7 BBLR: §f") + .append(String.format("%.2f", stats.getBBLR())); + } + return message.toString(); + } + + private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { + String playerFormatted = getPlayerFormatted(breaker); + return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted + + (breaker.getStats() == null || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner().get(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + if (BedwarsDeathType.getDeath(rawMessage, (type, m) -> { + died(m, rawMessage, event, type); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.BED_DESTROY, rawMessage, m -> { + BedwarsPlayer player = BedwarsMessages.matched(BedwarsMessages.BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); + BedwarsTeam team = BedwarsTeam.fromName(m.group(1)).orElse(me.getTeam()); + bedDestroyed(event, team, player); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> disconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> reconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.GAME_END, rawMessage, m -> { + BedwarsTeam win = players.values().stream().filter(p -> !p.isFinalKilled()).findFirst().map(BedwarsPlayer::getTeam).orElse(null); + this.won = win; + this.wonTick = mc.inGameHud.getTicks() + 10; + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + private void died(Matcher m, String rawMessage, ReceiveChatMessageEvent event, BedwarsDeathType type) { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + BedwarsPlayer killer = null; + if (type != BedwarsDeathType.SELF_UNKNOWN && type != BedwarsDeathType.SELF_VOID) { + killer = getPlayer(m.group(2)).orElse(null); + } + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(event, killed, killer, type, BedwarsMessages.matched(BedwarsMessages.FINAL_KILL, rawMessage).isPresent()); + } + + private void gameEnd(BedwarsTeam win) { + if (me == null) { + BedwarsMod.getInstance().gameEnd(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + Text.literal("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + Text.literal( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { + // Make sure everyone is dead, just in case + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { + b.setBed(false); + b.died(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatEliminated(team))); + } + } + + private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + if (breaker != null && breaker.getStats() != null) { + breaker.getStats().addBed(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + Collections.reverse(filteredScores); + if (filteredScores.size() < 3) { + return; + } + ScoreboardPlayerScore score = filteredScores.get(2); + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String timer = Team.decorateName(team, Text.literal(score.getPlayerName())).getString(); + if (!timer.contains(":")) { + return; + } + int seconds; + try { + seconds = Integer.parseInt(timer.split(":")[1].substring(0, 2)); + } catch (Exception e) { + e.printStackTrace(); + return; + } + int target = (60 - seconds) % 60; + if (this.seconds % 60 != target) { + // Update seconds + while (this.seconds % 60 != target) { + updateClock(); + } + topBarText = Text.literal(calculateTopBarText()); + bottomBarText = Text.literal(calculateBottomBarText()); + } + } + + private void updateClock() { + this.seconds++; + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + public void updateEntries(List entries) { + // Update latencies and other information for entries + entries.forEach(entry -> + getPlayer(entry.getProfile().getName()).ifPresent(player -> player.updateListEntry(entry)) + ); + } + + public List getTabPlayerList(List original) { + updateEntries(original); + return players.values().stream().filter(b -> !b.isFinalKilled()).sorted((b1, b2) -> { + if (b1.getTeam() == b2.getTeam()) { + return Integer.compare(b1.getNumber(), b2.getNumber()); + } + return Integer.compare(b1.getTeam().ordinal(), b2.getTeam().ordinal()); + }).map(BedwarsPlayer::getProfile).collect(Collectors.toList()); + } + + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); + } + + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX) { + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..70e09404a --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,227 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + private final static Pattern[] GAME_START = { + Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(Text.literal(time).append(event.getNewMessage())); + } else { + event.setNewMessage(Text.literal(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .toList(); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, Text.literal(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..07bce84e3 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + private boolean disconnected = false; + private boolean bed = true; + private final int number; + private BedwarsPlayerStats stats = null; + private boolean triedStats = false; + private int tickAlive = -1; + + public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { + this.team = team; + this.profile = profile; + this.number = number; + } + + public String getColoredTeamNumber(String format) { + return getTeam().getColorSection() + format + getTeam().getPrefix() + getNumber(); + } + + public String getColoredTeamNumber() { + return getTeam().getColorSection() + getTeam().getPrefix() + getNumber(); + } + + public String getName() { + return profile.getProfile().getName(); + } + + public String getColoredName() { + return team.getColorSection() + getName(); + } + + public String getTabListDisplay() { + if (alive) { + if (bed) { + return team.getColorSection() + "§l" + team.getPrefix() + number + " " + getColoredName(); + } + return team.getColorSection() + "§l" + team.getPrefix() + number + team.getColorSection() + "§o " + getName(); + } + if (disconnected) { + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §o§n" + getName(); + } + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §m" + getName(); + } + + public void updateListEntry(PlayerListEntry entry) { + this.profile = entry; + } + + public boolean isFinalKilled() { + return tickAlive < 0 && !bed && !alive || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + public void died() { + if (!alive) { + if (!bed) { + tickAlive = -1; + } + return; + } + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + alive = false; + if (!bed) { + tickAlive = -1; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 10; // 10 second respawn + } + + public void killed(boolean finalKill) { + if (stats != null) { + if (finalKill) { + stats.addFinalKill(); + } + stats.addKill(); + } + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..d06f0280f --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,136 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.List; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableBlend(); + RenderSystem.setShaderColor(1, 1, 1, 1); + boolean normalUpgrades = false; + if (upgrades != null) { + for (TeamUpgrade u : upgrades.upgrades) { + if (!u.isPurchased()) { + continue; + } + if (u instanceof TrapUpgrade) { + continue; + } + TextureInfo texture; + texture = u.getTexture()[0]; + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), false); + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..b93109e79 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +public class BedwarsTeamUpgrades { + + public final TrapUpgrade trap = new TrapUpgrade(); + + public final TeamUpgrade sharpness = new BinaryUpgrade( + "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,3}\\s*$"), + new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,3}\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + public final TeamUpgrade forge = new TieredUpgrade( + "forge", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (?:Iron|Golden|Emerald|Molten) Forge\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; + + public BedwarsTeamUpgrades() { + + } + + public void onMessage(String rawMessage) { + for (TeamUpgrade upgrade : upgrades) { + if (upgrade.match(rawMessage)) { + return; + } + } + } + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..71de40a58 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,128 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +public class TrapUpgrade extends TeamUpgrade { + + private final static Pattern[] REGEX = { + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), + Pattern.compile("Trap was set (off)!"), + }; + + private final List traps = new ArrayList<>(3); + + public TrapUpgrade() { + super("trap", REGEX); + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + if (matcher.group(1).equals("off")) { + // Trap went off + traps.remove(0); + return; + } + traps.add(TrapType.getFuzzy(matcher.group(1))); + } + + public boolean canPurchase() { + return traps.size() < 3; + } + + @Override + public int getPrice(BedwarsMode mode) { + switch (traps.size()) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 4; + } + ; + return 0; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + public static TrapType getFuzzy(String s) { + s = s.toLowerCase(Locale.ROOT); + if (s.contains("miner")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index c1513f7c5..0ef205bc3 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index 198d62349..c1e169f04 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 795795901..faf901207 100644 --- a/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.19.3/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -81,7 +81,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry.getKey()); SkyboxManager.getInstance() @@ -90,7 +90,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("optifine/sky", identifier -> identifier.getPath().endsWith(".properties")).entrySet()) { + .findResources("optifine/sky", identifier -> isMCPSky(identifier.getPath())).entrySet()) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry.getKey()); SkyboxManager.getInstance() .addSkybox(new MCPSkyboxInstance(loadMCPSky("optifine", entry.getKey(), entry.getValue()))); @@ -100,6 +100,10 @@ public void reload(ResourceManager manager) { AxolotlClient.LOGGER.debug("Finished Loading Custom Skies!"); } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private static JsonObject loadMCPSky(String loader, Identifier id, Resource resource) { JsonObject object = new JsonObject(); String line; diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.19.3/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index b35c4ab5d..000000000 --- a/1.19.3/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 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 com.mojang.blaze3d.platform.InputUtil; -import net.minecraft.client.option.KeyBind; -import org.quiltmc.qsl.base.api.event.Event; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = Event.create(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = Event.create(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = Event.create(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = Event - .create(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBind binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..65717aca9 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2021-2023 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.events; + +import java.util.Arrays; + +import io.github.axolotlclient.util.events.impl.*; +import org.quiltmc.qsl.base.api.event.Event; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent() { + return Event + .create(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..72214c8aa --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import com.mojang.blaze3d.platform.InputUtil; +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..62ad3314d --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBind; + +@Data +public class KeyPressEvent { + + private final KeyBind key; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..1217f4d0d --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..460f7b4b2 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..2b813be85 --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final ScoreboardObjective objective; +} diff --git a/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.19.3/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java b/1.19.4/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java index 0893875f6..3409983b9 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java @@ -60,9 +60,9 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption timeChangerEnabled = new BooleanOption("enabled", false); public final IntegerOption customTime = new IntegerOption("time", 0, 0, 24000); public final BooleanOption customSky = new BooleanOption("customSky", true); - public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -176,10 +176,10 @@ public void init() { general.addSubCategory(searchFilters); rendering.add(customSky, - showSunMoon, AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 8d8975673..b684d53be 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -162,11 +162,11 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f75f75615..098118c15 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,10 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatMessageTag; import net.minecraft.network.message.MessageSignature; @@ -34,21 +33,31 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), cancellable = true) public void axolotlclient$autoThings(Text message, MessageSignature signature, ChatMessageTag tag, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index ee7520b6e..e13f9b3f0 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 00c3a054a..bba7200e1 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, TextRenderer.TextLayerType.NORMAL, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 9af2bd244..20733dbbb 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,26 +22,28 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +91,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(MatrixStack matrices, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +191,40 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderHealthBar", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$displayHardcoreHearts(int v) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 9 * 5 : v; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 15 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(MatrixStack matrices, Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index bae9a75ca..16bbd5622 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -23,7 +23,9 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBind; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBind) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBind) ((Object) this))); } } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 9f53f46fa..be9243592 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,10 +27,13 @@ import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import net.minecraft.resource.ResourceType; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.qsl.resource.loader.api.ResourceLoader; @@ -82,4 +85,9 @@ public abstract class MinecraftClientMixin { MenuBlur.getInstance().onScreenOpen(); } } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 49c1cc4bb..8b962b876 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBind;setKeyPressed(Lcom/mojang/blaze3d/platform/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..930b26d3b 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,10 +25,12 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +42,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } @@ -84,4 +86,12 @@ public PlayerEntityMixin(EntityType entityType, World world) { comboHud.onEntityDamage(this); } } + + @Override + public int getArmor() { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return super.getArmor(); + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 0f3d70692..ccedd519a 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,15 +22,25 @@ package io.github.axolotlclient.mixin; +import java.util.List; +import java.util.UUID; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.ClientConnection; @@ -39,14 +49,14 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -72,6 +82,10 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry entry, MutableText name); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { profile = playerEntry.getProfile(); @@ -112,7 +126,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)) { ci.cancel(); } } @@ -147,4 +163,131 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$renderHatLayer(boolean drawHat) { return Tablist.getInstance().alwaysShowHeadLayer.get() || drawHat; } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + MatrixStack matrixStack, int argY, Scoreboard scoreboard, ScoreboardObjective scoreboardObjective, CallbackInfo ci, + List list, int i, int j, int l, int m, int k, + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 + ) { + if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.client.textRenderer.drawWithShadow(matrixStack, + render, + (float) (endX - this.client.textRenderer.getWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Ljava/lang/String;FFI)I" + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, + UUID uuid, MatrixStack matrices, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null) { + return; + } + + game.renderCustomScoreboardObjective(matrices, player, objective, y, endX); + + ci.cancel(); + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null || !game.isStarted()) { + return; + } + BedwarsPlayer player = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + if (player == null) { + return; + } + cir.setReturnValue(player.getTabListDisplay()); + } + + @ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 1) + public List axolotlclient$overrideSortedPlayers(List original) { + if (!BedwarsMod.getInstance().inGame()) { + return original; + } + List players = BedwarsMod.getInstance().getGame().get().getTabPlayerList(original); + if (players == null) { + return original; + } + return players; + } + + @Inject(method = "setHeader", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index c051d28b4..a125b7bbc 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -39,6 +39,7 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; @@ -56,6 +57,7 @@ public class HudManager extends AbstractModule { private final OptionCategory hudCategory = new OptionCategory("hud", false); private final Map entries; private final MinecraftClient client; + private HudManager() { this.entries = new LinkedHashMap<>(); client = MinecraftClient.getInstance(); @@ -98,6 +100,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index 332f2e0d6..52de2bd98 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -36,7 +36,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBind; import net.minecraft.client.util.math.MatrixStack; @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index b1f15db8b..8d119806a 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -30,7 +30,8 @@ import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -66,11 +67,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 19bcca2d6..b9f702184 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -28,7 +28,7 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { if (fromKeybindings.get()) { - if (key.equals(client.options.attackKey)) { + if (event.getKey().equals(client.options.attackKey)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.useKey)) { + } else if (event.getKey().equals(client.options.useKey)) { ClickList.RIGHT.click(); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java index b10c932e8..dbf59a2e8 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -45,8 +47,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java index 646f049f4..3d681a33a 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.function.Supplier; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -31,8 +33,6 @@ import net.minecraft.client.util.math.MatrixStack; import org.joml.Matrix4f; -import java.util.function.Supplier; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 660692581..dffcc153d 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -33,6 +33,7 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 2cb1c7255..a500fa8f7 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -26,8 +26,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; // Based on https://github.com/VeryHolyCheeeese/AutoBoop/blob/main/src/main/java/autoboop/AutoBoop.java public class AutoBoop implements AbstractHypixelMod { @@ -41,6 +42,7 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -48,10 +50,11 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.getString().contains("Friend >") && message.getString().contains("joined.")) { - String player = message.getString().substring(message.getString().indexOf(">"), - message.getString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); + if (enabled.get() && message.contains("Friend >") && message.contains("joined.")) { + String player = message.substring(message.indexOf(">"), + message.lastIndexOf(" ")); Util.sendChatMessage("/boop " + player); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index b5d93e47f..9aab4985b 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -31,9 +31,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -87,6 +88,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -157,28 +160,28 @@ private List addToList(String... strings) { return Arrays.stream(strings).toList(); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { if (gf.get()) { - processChat(message, gfStrings.get(s), gfString.get()); + processChat(event.getOriginalMessage(), gfStrings.get(s), gfString.get()); } if (gg.get()) { - processChat(message, ggStrings.get(s), ggString.get()); + processChat(event.getOriginalMessage(), ggStrings.get(s), ggString.get()); } if (glhf.get()) { - processChat(message, glhfStrings.get(s), glhfString.get()); + processChat(event.getOriginalMessage(), glhfStrings.get(s), glhfString.get()); } } }); } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.getString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 23c9956e7..345575912 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -28,9 +28,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; public class AutoTip implements AbstractHypixelMod { @@ -52,6 +53,7 @@ public class AutoTip implements AbstractHypixelMod { @Override public void init() { category.add(enabled, hideMessages); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); init = true; } @@ -80,8 +82,8 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && (messagePattern.matcher(text.getString()).matches() - || tippedPattern.matcher(text.getString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && (messagePattern.matcher(event.getOriginalMessage()).matches() + || tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..9e9f32e9c --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,472 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; +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.Formatting; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +public class BedwarsGame { + private BedwarsTeam won = null; + private int wonTick = -1; + private int seconds = 0; + private Text topBarText = Text.empty(); + private Text bottomBarText = Text.empty(); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + teamPlayers.compute(team, (t, entries) -> { + if (entries == null) { + List players = new ArrayList<>(); + players.add(player); + return players; + } + entries.add(player); + return entries; + }); + } + for (Map.Entry> teamPlayerList : teamPlayers.entrySet()) { + teamPlayerList.getValue().sort(Comparator.comparing(p -> p.getProfile().getName())); + List value = teamPlayerList.getValue(); + for (int i = 0; i < value.size(); i++) { + PlayerListEntry e = value.get(i); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + public Text getBottomBarText() { + return bottomBarText; + } + + private String calculateTopBarText() { + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); + } + + private String calculateBottomBarText() { + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) + .collect(Collectors.joining("\n"));*/ + } + + public String getFormattedTime() { + int minute = seconds / 60; + int second = seconds % 60; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + return time; + } + + public Optional getPlayer(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + + public Optional getPlayer(String name) { + return Optional.ofNullable(players.getOrDefault(name, null)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDeath(player, killer, type, finalDeath))); + } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = killer; + } + } + + private String formatDisconnect(BedwarsPlayer disconnected) { + String playerFormatted = getPlayerFormatted(disconnected); + return playerFormatted + " §7§o/disconnected/"; + } + + private String formatReconnect(BedwarsPlayer reconnected) { + String playerFormatted = getPlayerFormatted(reconnected); + return playerFormatted + " §7§o/reconnected/"; + } + + private String formatEliminated(BedwarsTeam team) { + StringBuilder message = new StringBuilder( + "§6§l§oTEAM ELIMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "); + for (BedwarsPlayer p : players.values().stream() + .filter(b -> b.getTeam() == team) + .sorted(Comparator.comparingInt(BedwarsPlayer::getNumber)) + .toList()) { + BedwarsPlayerStats stats = p.getStats(); + if (stats == null) { + continue; + } + message.append("\n") + .append("§b") + .append(stats.getStars()) + .append(" ") + .append(p.getColoredName()) + .append("§7 Beds: §f") + .append(stats.getBedsBroken()) + .append("§7 Finals: §f") + .append(stats.getFinalKills()) + .append("§7 FKDR: §f") + .append(String.format("%.2f", stats.getFKDR())) + .append("§7 BBLR: §f") + .append(String.format("%.2f", stats.getBBLR())); + } + return message.toString(); + } + + private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { + String playerFormatted = getPlayerFormatted(breaker); + return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted + + (breaker.getStats() == null || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner().get(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + if (BedwarsDeathType.getDeath(rawMessage, (type, m) -> { + died(m, rawMessage, event, type); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.BED_DESTROY, rawMessage, m -> { + BedwarsPlayer player = BedwarsMessages.matched(BedwarsMessages.BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); + BedwarsTeam team = BedwarsTeam.fromName(m.group(1)).orElse(me.getTeam()); + bedDestroyed(event, team, player); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> disconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> reconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.GAME_END, rawMessage, m -> { + BedwarsTeam win = players.values().stream().filter(p -> !p.isFinalKilled()).findFirst().map(BedwarsPlayer::getTeam).orElse(null); + this.won = win; + this.wonTick = mc.inGameHud.getTicks() + 10; + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + private void died(Matcher m, String rawMessage, ReceiveChatMessageEvent event, BedwarsDeathType type) { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + BedwarsPlayer killer = null; + if (type != BedwarsDeathType.SELF_UNKNOWN && type != BedwarsDeathType.SELF_VOID) { + killer = getPlayer(m.group(2)).orElse(null); + } + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(event, killed, killer, type, BedwarsMessages.matched(BedwarsMessages.FINAL_KILL, rawMessage).isPresent()); + } + + private void gameEnd(BedwarsTeam win) { + if (me == null) { + BedwarsMod.getInstance().gameEnd(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + Text.literal("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + Text.literal( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { + // Make sure everyone is dead, just in case + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { + b.setBed(false); + b.died(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatEliminated(team))); + } + } + + private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + if (breaker != null && breaker.getStats() != null) { + breaker.getStats().addBed(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + Collections.reverse(filteredScores); + if (filteredScores.size() < 3) { + return; + } + ScoreboardPlayerScore score = filteredScores.get(2); + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String timer = Team.decorateName(team, Text.literal(score.getPlayerName())).getString(); + if (!timer.contains(":")) { + return; + } + int seconds; + try { + seconds = Integer.parseInt(timer.split(":")[1].substring(0, 2)); + } catch (Exception e) { + e.printStackTrace(); + return; + } + int target = (60 - seconds) % 60; + if (this.seconds % 60 != target) { + // Update seconds + while (this.seconds % 60 != target) { + updateClock(); + } + topBarText = Text.literal(calculateTopBarText()); + bottomBarText = Text.literal(calculateBottomBarText()); + } + } + + private void updateClock() { + this.seconds++; + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + public void updateEntries(List entries) { + // Update latencies and other information for entries + entries.forEach(entry -> + getPlayer(entry.getProfile().getName()).ifPresent(player -> player.updateListEntry(entry)) + ); + } + + public List getTabPlayerList(List original) { + updateEntries(original); + return players.values().stream().filter(b -> !b.isFinalKilled()).sorted((b1, b2) -> { + if (b1.getTeam() == b2.getTeam()) { + return Integer.compare(b1.getNumber(), b2.getNumber()); + } + return Integer.compare(b1.getTeam().ordinal(), b2.getTeam().ordinal()); + }).map(BedwarsPlayer::getProfile).collect(Collectors.toList()); + } + + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); + } + + public void renderCustomScoreboardObjective(MatrixStack matrices, String playerName, ScoreboardObjective objective, int y, int endX) { + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow(matrices, + render, + (float) (endX - mc.textRenderer.getWidth(render)), + (float) y, + color + ); + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..70e09404a --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,227 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + private final static Pattern[] GAME_START = { + Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(Text.literal(time).append(event.getNewMessage())); + } else { + event.setNewMessage(Text.literal(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .toList(); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, Text.literal(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..07bce84e3 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + private boolean disconnected = false; + private boolean bed = true; + private final int number; + private BedwarsPlayerStats stats = null; + private boolean triedStats = false; + private int tickAlive = -1; + + public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { + this.team = team; + this.profile = profile; + this.number = number; + } + + public String getColoredTeamNumber(String format) { + return getTeam().getColorSection() + format + getTeam().getPrefix() + getNumber(); + } + + public String getColoredTeamNumber() { + return getTeam().getColorSection() + getTeam().getPrefix() + getNumber(); + } + + public String getName() { + return profile.getProfile().getName(); + } + + public String getColoredName() { + return team.getColorSection() + getName(); + } + + public String getTabListDisplay() { + if (alive) { + if (bed) { + return team.getColorSection() + "§l" + team.getPrefix() + number + " " + getColoredName(); + } + return team.getColorSection() + "§l" + team.getPrefix() + number + team.getColorSection() + "§o " + getName(); + } + if (disconnected) { + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §o§n" + getName(); + } + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §m" + getName(); + } + + public void updateListEntry(PlayerListEntry entry) { + this.profile = entry; + } + + public boolean isFinalKilled() { + return tickAlive < 0 && !bed && !alive || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + public void died() { + if (!alive) { + if (!bed) { + tickAlive = -1; + } + return; + } + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + alive = false; + if (!bed) { + tickAlive = -1; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 10; // 10 second respawn + } + + public void killed(boolean finalKill) { + if (stats != null) { + if (finalKill) { + stats.addFinalKill(); + } + stats.addKill(); + } + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..d06f0280f --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,136 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.List; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + @Override + public void render(MatrixStack matrices, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(matrices, delta); + } + } + + public void drawOverlay(MatrixStack stack, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableBlend(); + RenderSystem.setShaderColor(1, 1, 1, 1); + boolean normalUpgrades = false; + if (upgrades != null) { + for (TeamUpgrade u : upgrades.upgrades) { + if (!u.isPurchased()) { + continue; + } + if (u instanceof TrapUpgrade) { + continue; + } + TextureInfo texture; + texture = u.getTexture()[0]; + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + RenderSystem.setShaderTexture(0, new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(stack, x, y, 16, 16, texture.getU(), texture.getV(), texture.getRegionWidth(), texture.getRegionHeight(), texture.getWidth(), texture.getHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); + x += 17; + } + } + + @Override + public void renderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), false); + } + + @Override + public void renderPlaceholderComponent(MatrixStack stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..b93109e79 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +public class BedwarsTeamUpgrades { + + public final TrapUpgrade trap = new TrapUpgrade(); + + public final TeamUpgrade sharpness = new BinaryUpgrade( + "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,3}\\s*$"), + new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,3}\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + public final TeamUpgrade forge = new TieredUpgrade( + "forge", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (?:Iron|Golden|Emerald|Molten) Forge\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; + + public BedwarsTeamUpgrades() { + + } + + public void onMessage(String rawMessage) { + for (TeamUpgrade upgrade : upgrades) { + if (upgrade.match(rawMessage)) { + return; + } + } + } + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..71de40a58 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,128 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +public class TrapUpgrade extends TeamUpgrade { + + private final static Pattern[] REGEX = { + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), + Pattern.compile("Trap was set (off)!"), + }; + + private final List traps = new ArrayList<>(3); + + public TrapUpgrade() { + super("trap", REGEX); + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + if (matcher.group(1).equals("off")) { + // Trap went off + traps.remove(0); + return; + } + traps.add(TrapType.getFuzzy(matcher.group(1))); + } + + public boolean canPurchase() { + return traps.size() < 3; + } + + @Override + public int getPrice(BedwarsMode mode) { + switch (traps.size()) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 4; + } + ; + return 0; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + public static TrapType getFuzzy(String s) { + s = s.toLowerCase(Locale.ROOT); + if (s.contains("miner")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java index c1513f7c5..0ef205bc3 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/rpc/DiscordRPC.java @@ -51,7 +51,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static boolean running; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static boolean running; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index aec4442c5..848eadec7 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 795795901..faf901207 100644 --- a/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.19.4/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -81,7 +81,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry.getKey()); SkyboxManager.getInstance() @@ -90,7 +90,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("optifine/sky", identifier -> identifier.getPath().endsWith(".properties")).entrySet()) { + .findResources("optifine/sky", identifier -> isMCPSky(identifier.getPath())).entrySet()) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry.getKey()); SkyboxManager.getInstance() .addSkybox(new MCPSkyboxInstance(loadMCPSky("optifine", entry.getKey(), entry.getValue()))); @@ -100,6 +100,10 @@ public void reload(ResourceManager manager) { AxolotlClient.LOGGER.debug("Finished Loading Custom Skies!"); } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private static JsonObject loadMCPSky(String loader, Identifier id, Resource resource) { JsonObject object = new JsonObject(); String line; diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.19.4/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index b35c4ab5d..000000000 --- a/1.19.4/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 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 com.mojang.blaze3d.platform.InputUtil; -import net.minecraft.client.option.KeyBind; -import org.quiltmc.qsl.base.api.event.Event; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = Event.create(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = Event.create(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = Event.create(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = Event - .create(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBind binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..65717aca9 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2021-2023 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.events; + +import java.util.Arrays; + +import io.github.axolotlclient.util.events.impl.*; +import org.quiltmc.qsl.base.api.event.Event; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent() { + return Event + .create(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..72214c8aa --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import com.mojang.blaze3d.platform.InputUtil; +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..62ad3314d --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBind; + +@Data +public class KeyPressEvent { + + private final KeyBind key; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..1217f4d0d --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..460f7b4b2 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..2b813be85 --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final ScoreboardObjective objective; +} diff --git a/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.19.4/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} 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 e40a06cbf..15ed76b02 100644 --- a/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java +++ b/1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java @@ -22,6 +22,11 @@ package io.github.axolotlclient; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.AxolotlClientConfigManager; @@ -68,11 +73,6 @@ import org.quiltmc.qsl.resource.loader.api.ResourceLoader; import org.quiltmc.qsl.resource.loader.api.ResourcePackActivationType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; - public class AxolotlClient implements ClientModInitializer { public static final Identifier badgeIcon = new Identifier("axolotlclient", "textures/badge.png"); 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 95c751da7..fa092bdfd 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 @@ -22,6 +22,9 @@ package io.github.axolotlclient.config; +import java.util.ArrayList; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.texture.NativeImage; import io.github.axolotlclient.AxolotlClient; @@ -38,9 +41,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.texture.NativeImageBackedTexture; -import java.util.ArrayList; -import java.util.List; - public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption showOwnNametag = new BooleanOption("showOwnNametag", false); @@ -63,6 +63,7 @@ public class AxolotlClientConfig extends ConfigHolder { public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final BooleanOption lowShield = new BooleanOption("lowShield", false); public final ColorOption hitColor = new ColorOption("hitColor", @@ -180,6 +181,7 @@ public void init() { AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, lowShield, hitColor, diff --git a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index 18f8c3074..93210e2ac 100644 --- a/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.config.screen; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + import com.mojang.blaze3d.glfw.Window; import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; @@ -51,10 +55,6 @@ import org.jetbrains.annotations.Nullable; import org.lwjgl.opengl.GL11; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - public class CreditsScreen extends Screen { public static final HashMap externalModuleCredits = new HashMap<>(); @@ -161,11 +161,11 @@ private void initCredits() { credits.add(new Credit("YakisikliBaran", "Turkish Translation")); credits.add(new Credit("TheKodeToad", "Contributor", "Motion Blur", "Freelook", "Zoom")); credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { @@ -270,14 +270,7 @@ public Credit(String name, String... things) { public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { if (hovered || c.isFocused()) { - RenderUtil.drawVerticalLine(graphics, x - 100, y, y + 20, - Color.ERROR.getAsInt()); - RenderUtil.drawVerticalLine(graphics, x + 100, y, y + 20, - Color.ERROR.getAsInt()); - RenderUtil.drawHorizontalLine(graphics, x - 100, y + 20, x + 100, - Color.ERROR.getAsInt()); - RenderUtil.drawHorizontalLine(graphics, x - 100, y, x + 100, - Color.ERROR.getAsInt()); + RenderUtil.drawOutline(graphics, x-100, y, 200, 20, Color.ERROR.getAsInt()); } this.hovered = hovered; DrawUtil.drawCenteredString(graphics, MinecraftClient.getInstance().textRenderer, name, x, y + 5, diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/BossBarHudAccessor.java b/1.20/src/main/java/io/github/axolotlclient/mixin/BossBarHudAccessor.java index 33e308987..3404b43f8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/BossBarHudAccessor.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/BossBarHudAccessor.java @@ -22,14 +22,14 @@ package io.github.axolotlclient.mixin; +import java.util.Map; +import java.util.UUID; + import net.minecraft.client.gui.hud.BossBarHud; import net.minecraft.client.gui.hud.ClientBossBar; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; -import java.util.UUID; - @Mixin(BossBarHud.class) public interface BossBarHudAccessor { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index f75f75615..098118c15 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -22,10 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatMessageTag; import net.minecraft.network.message.MessageSignature; @@ -34,21 +33,31 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ChatHud.class) public abstract class ChatHudMixin { - @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), cancellable = true) public void axolotlclient$autoThings(Text message, MessageSignature signature, ChatMessageTag tag, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.getString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;Lnet/minecraft/client/gui/hud/ChatMessageTag;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignature;ILnet/minecraft/client/gui/hud/ChatMessageTag;Z)V"), index = 0) public Text axolotlclient$editChat(Text message) { return NickHider.getInstance().editMessage(message); diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index ee7520b6e..e13f9b3f0 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -24,7 +24,8 @@ import io.github.axolotlclient.modules.freelook.Freelook; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -54,7 +55,7 @@ public abstract class EntityMixin { float pitch = prevPitch + (float) (mouseDeltaY * .15); float yaw = prevYaw + (float) (mouseDeltaX * .15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } @Shadow diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java index 57809e3ec..8acec63f5 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/EntityRendererMixin.java @@ -24,6 +24,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -69,10 +70,24 @@ public abstract class EntityRendererMixin { CallbackInfo ci) { if (entity instanceof AbstractClientPlayerEntity) { if (MinecraftClient.getInstance().getCurrentServerEntry() != null - && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.getString().contains(entity.getName().getString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + && MinecraftClient.getInstance().getCurrentServerEntry().address.contains("hypixel.net") + && string.getString().contains(entity.getName().getString())) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String text = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (text != null) { + float x = -textRenderer.getWidth(text) / 2F; + float y = string.getString().contains("deadmau5") ? -20 : -10; + + Matrix4f matrix4f = matrices.peek().getModel(); + MinecraftClient.getInstance().textRenderer.draw(text, x, y, + LevelHead.getInstance().textColor.get().getAsInt(), AxolotlClient.CONFIG.useShadows.get(), + matrix4f, vertexConsumers, TextRenderer.TextLayerType.NORMAL, LevelHead.getInstance().background.get() ? 127 : 0, + light); + } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); float x = -textRenderer.getWidth(text) / 2F; diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java index fc446f116..9923a30d2 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/GameMenuScreenMixin.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.mixin; +import java.util.Objects; +import java.util.function.Supplier; + import io.github.axolotlclient.modules.hud.HudEditScreen; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; import io.github.axolotlclient.modules.hypixel.HypixelMods; @@ -36,9 +39,6 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; -import java.util.Objects; -import java.util.function.Supplier; - @Mixin(GameMenuScreen.class) public abstract class GameMenuScreenMixin { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index 4617f87de..d168e0c5d 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -22,26 +22,28 @@ package io.github.axolotlclient.mixin; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PotionsHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ActionBarHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.CrosshairHud; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.HotbarHUD; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.ScoreboardHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -89,7 +91,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardSidebar", at = @At("HEAD"), cancellable = true) public void axolotlclient$renderScoreboard(GuiGraphics graphics, ScoreboardObjective objective, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud != null && hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -187,4 +191,48 @@ public abstract class InGameHudMixin { } return scaledWidth; } + + @ModifyVariable( + method = "renderHealthBar", + at = @At( + value = "STORE" + ), + ordinal = 13 + ) + public int axolotlclient$displayHardcoreHearts(int v) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 9 * 5 : v; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), ordinal = 15 + ) + public int axolotlclient$dontHunger(int heartCount) { + if (heartCount == 0 && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return 3; + } + return heartCount; + } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(GuiGraphics graphics, Entity entity, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } + + @ModifyVariable(method = "renderStatusBars", at = @At("STORE"), ordinal = 12) + private int axolotlclient$dontShowArmor(int armorValue){ + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + return 0; + } + return armorValue; + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java index bae9a75ca..16bbd5622 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/KeyBindMixin.java @@ -23,7 +23,9 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.InputUtil; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.option.KeyBind; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -35,13 +37,13 @@ public abstract class KeyBindMixin { @Inject(method = "setBoundKey", at = @At("RETURN")) public void axolotlclient$boundKeySet(InputUtil.Key key, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(key); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(key)); } @Inject(method = "setPressed", at = @At("RETURN")) public void axolotlclient$onPress(boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress((KeyBind) ((Object) this)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent((KeyBind) ((Object) this))); } } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index 9f53f46fa..be9243592 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,10 +27,13 @@ import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.sky.SkyResourceManager; import io.github.axolotlclient.util.NetworkHelper; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import net.minecraft.resource.ResourceType; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.qsl.resource.loader.api.ResourceLoader; @@ -82,4 +85,9 @@ public abstract class MinecraftClientMixin { MenuBlur.getInstance().onScreenOpen(); } } + + @Inject(method = "joinWorld", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld world, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(world)); + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java index 49c1cc4bb..8b962b876 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/MouseMixin.java @@ -25,7 +25,8 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; import net.minecraft.client.Mouse; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,7 +40,7 @@ public abstract class MouseMixin { @Inject(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBind;setKeyPressed(Lcom/mojang/blaze3d/platform/InputUtil$Key;Z)V")) private void axolotlclient$onMouseButton(long window, int button, int action, int mods, CallbackInfo ci) { if (action == 1) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(window, button, action, mods); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(window, button, action, mods)); } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ParticleManagerMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ParticleManagerMixin.java index 30ffb20d0..cb012d35f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ParticleManagerMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ParticleManagerMixin.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.mixin; +import java.util.Collection; +import java.util.Iterator; +import java.util.Queue; + import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.Tessellator; import io.github.axolotlclient.modules.particles.Particles; @@ -43,10 +47,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.util.Collection; -import java.util.Iterator; -import java.util.Queue; - @Mixin(ParticleManager.class) public abstract class ParticleManagerMixin { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 52aad23dc..42c729666 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -29,6 +29,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; @@ -40,9 +41,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) -public abstract class PlayerEntityMixin extends Entity { +public abstract class PlayerEntityMixin extends LivingEntity { - public PlayerEntityMixin(EntityType entityType, World world) { + protected PlayerEntityMixin(EntityType entityType, World world) { super(entityType, world); } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 06d88edbf..32147684f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,9 +22,17 @@ package io.github.axolotlclient.mixin; +import java.util.List; +import java.util.UUID; + import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; @@ -38,14 +46,16 @@ import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { @@ -54,7 +64,8 @@ public abstract class PlayerListHudMixin { private Text header; @Shadow private Text footer; - private GameProfile profile; + @Unique + private GameProfile axolotlclient$profile; @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) public void axolotlclient$nickHider(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { @@ -71,29 +82,33 @@ public abstract class PlayerListHudMixin { @Shadow protected abstract Text applyGameModeFormatting(PlayerListEntry entry, MutableText name); + @Shadow + @Final + private MinecraftClient client; + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Lnet/minecraft/text/Text;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { - profile = playerEntry.getProfile(); + axolotlclient$profile = playerEntry.getProfile(); return playerEntry; } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;getWidth(Lnet/minecraft/text/StringVisitable;)I")) public int axolotlclient$moveName(TextRenderer instance, StringVisitable text) { - if (profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(profile.getId())) + if (axolotlclient$profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$profile.getId())) return instance.getWidth(text) + 10; return instance.getWidth(text); } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawShadowedText(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)I")) public int axolotlclient$moveName2(GuiGraphics instance, TextRenderer renderer, Text text, int x, int y, int color) { - if (profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(profile.getId())) { + if (axolotlclient$profile != null && AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$profile.getId())) { RenderSystem.setShaderColor(1, 1, 1, 1); instance.drawTexture(AxolotlClient.badgeIcon, x, y, 8, 8, 0, 0, 8, 8, 8, 8); x += 9; } - profile = null; + axolotlclient$profile = null; return instance.drawShadowedText(renderer, text, x, y, color); } @@ -110,7 +125,9 @@ public abstract class PlayerListHudMixin { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(GuiGraphics graphics, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(graphics, width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(graphics, width, x, y, entry)) { ci.cancel(); } } @@ -145,4 +162,130 @@ public abstract class PlayerListHudMixin { private boolean axolotlclient$renderHatLayer(boolean drawHat) { return Tablist.getInstance().alwaysShowHeadLayer.get() || drawHat; } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(Lnet/minecraft/client/gui/GuiGraphics;IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + GuiGraphics graphics, int scaledWindowWidth, Scoreboard scoreboard, @Nullable ScoreboardObjective objective, CallbackInfo ci, + List list, int i, int j, int l, int m, int k, + boolean bl, int n, int o, int p, int q, int r, List list2, int t, int u, int s, int v, int y, int z, PlayerListEntry playerListEntry2 + ) { + if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + graphics.drawShadowedText(client.textRenderer, + render, + (endX - this.client.textRenderer.getWidth(render)) + 20, + y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/GuiGraphics;drawShadowedText(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)I" + ), + cancellable = true + ) + private void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, UUID uuid, GuiGraphics graphics, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null) { + return; + } + + game.renderCustomScoreboardObjective(graphics, player, objective, y, endX); + + ci.cancel(); + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null || !game.isStarted()) { + return; + } + BedwarsPlayer player = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + if (player == null) { + return; + } + cir.setReturnValue(player.getTabListDisplay()); + } + + @ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 0) + public List axolotlclient$overrideSortedPlayers(List original) { + if (!BedwarsMod.getInstance().inGame()) { + return original; + } + List players = BedwarsMod.getInstance().getGame().get().getTabPlayerList(original); + if (players == null) { + return original; + } + return players; + } + + @Inject(method = "setHeader", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ReloadableResourceManagerMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ReloadableResourceManagerMixin.java index 3a30e06cf..a031c6830 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ReloadableResourceManagerMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ReloadableResourceManagerMixin.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.mixin; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.PackDisplayHud; @@ -37,11 +42,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; - @Mixin(ReloadableResourceManager.class) public abstract class ReloadableResourceManagerMixin { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ScreenshotRecorderMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ScreenshotRecorderMixin.java index f11ffa3a5..6c7caa4ea 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ScreenshotRecorderMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ScreenshotRecorderMixin.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.mixin; +import java.io.File; +import java.util.function.Consumer; + import com.mojang.blaze3d.framebuffer.Framebuffer; import com.mojang.blaze3d.texture.NativeImage; import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils; @@ -40,9 +43,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.io.File; -import java.util.function.Consumer; - @Mixin(ScreenshotRecorder.class) public abstract class ScreenshotRecorderMixin { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/ShaderEffectAccessor.java b/1.20/src/main/java/io/github/axolotlclient/mixin/ShaderEffectAccessor.java index fcc3cd917..8d9afae49 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/ShaderEffectAccessor.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/ShaderEffectAccessor.java @@ -22,13 +22,13 @@ package io.github.axolotlclient.mixin; +import java.util.List; + import net.minecraft.client.gl.PostProcessShader; import net.minecraft.client.gl.ShaderEffect; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; - @Mixin(ShaderEffect.class) public interface ShaderEffectAccessor { diff --git a/1.20/src/main/java/io/github/axolotlclient/mixin/SplashOverlayMixin.java b/1.20/src/main/java/io/github/axolotlclient/mixin/SplashOverlayMixin.java index 6915e363b..408dcb5dd 100644 --- a/1.20/src/main/java/io/github/axolotlclient/mixin/SplashOverlayMixin.java +++ b/1.20/src/main/java/io/github/axolotlclient/mixin/SplashOverlayMixin.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.mixin; +import java.util.function.IntSupplier; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.Color; import net.minecraft.client.gui.screen.SplashOverlay; @@ -35,8 +37,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.function.IntSupplier; - @Mixin(value = SplashOverlay.class, priority = 1100) public abstract class SplashOverlayMixin { @Mutable diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/ModuleLoader.java b/1.20/src/main/java/io/github/axolotlclient/modules/ModuleLoader.java index b23467cb9..e89a01fb8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/ModuleLoader.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/ModuleLoader.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.config.screen.CreditsScreen; import org.quiltmc.loader.api.ModContributor; import org.quiltmc.loader.api.ModMetadata; import org.quiltmc.loader.api.QuiltLoader; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - public class ModuleLoader { public static List loadExternalModules() { diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/auth/AccountsListWidget.java b/1.20/src/main/java/io/github/axolotlclient/modules/auth/AccountsListWidget.java index ae5c42550..370c0cddf 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/auth/AccountsListWidget.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/auth/AccountsListWidget.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.auth; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; @@ -31,8 +33,6 @@ import net.minecraft.util.Util; import org.quiltmc.loader.api.minecraft.ClientOnly; -import java.util.List; - public class AccountsListWidget extends AlwaysSelectedEntryListWidget { private final AccountsScreen screen; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/auth/AddOfflineScreen.java b/1.20/src/main/java/io/github/axolotlclient/modules/auth/AddOfflineScreen.java index ea2b5d3b4..bfb8c53b1 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/auth/AddOfflineScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/auth/AddOfflineScreen.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.auth; +import java.util.UUID; + import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; @@ -29,8 +31,6 @@ import net.minecraft.text.CommonTexts; import net.minecraft.text.Text; -import java.util.UUID; - public class AddOfflineScreen extends Screen { private final Screen parent; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/auth/Auth.java b/1.20/src/main/java/io/github/axolotlclient/modules/auth/Auth.java index 3b77534fd..932a29e35 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/auth/Auth.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/auth/Auth.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.auth; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Optional; + import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.minecraft.UserApiService; import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; @@ -46,11 +51,6 @@ import net.minecraft.util.Identifier; import org.quiltmc.loader.api.QuiltLoader; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Optional; - public class Auth extends Accounts implements Module { @Getter diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/blur/MenuBlur.java b/1.20/src/main/java/io/github/axolotlclient/modules/blur/MenuBlur.java index 3cd5d39b3..f6ca8b728 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/blur/MenuBlur.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/blur/MenuBlur.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.blur; +import java.io.IOException; + import com.mojang.blaze3d.shader.GlUniform; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -40,8 +42,6 @@ import net.minecraft.util.Identifier; import org.apache.commons.io.IOUtils; -import java.io.IOException; - /** * Totally not stolen from Sol. * License: GPL-3.0 diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/blur/MotionBlur.java b/1.20/src/main/java/io/github/axolotlclient/modules/blur/MotionBlur.java index 09b8e34e8..4fbc4891a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/blur/MotionBlur.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/blur/MotionBlur.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.blur; +import java.io.IOException; + import com.google.gson.JsonSyntaxException; import com.mojang.blaze3d.shader.GlUniform; import io.github.axolotlclient.AxolotlClient; @@ -36,8 +38,6 @@ import net.minecraft.util.Identifier; import org.apache.commons.io.IOUtils; -import java.io.IOException; - public class MotionBlur extends AbstractModule { private static final MotionBlur Instance = new MotionBlur(); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudEditScreen.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudEditScreen.java index 177633d8a..a348be06a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudEditScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudEditScreen.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud; +import java.awt.*; +import java.util.List; +import java.util.Optional; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -37,10 +41,6 @@ import net.minecraft.text.CommonTexts; import net.minecraft.text.Text; -import java.awt.*; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 16ccbcea9..fc282797a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud; +import java.util.*; +import java.util.stream.Collectors; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -36,13 +39,11 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.util.Identifier; -import java.util.*; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -99,6 +100,7 @@ public void init() { add(new TPSHud()); add(new ComboHud()); add(new PlayerHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java index 51707d2a3..ef41114a5 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; @@ -39,9 +42,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/component/Configurable.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/component/Configurable.java index b82e1ec1d..639bc52a7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/component/Configurable.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/component/Configurable.java @@ -22,11 +22,11 @@ package io.github.axolotlclient.modules.hud.gui.component; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/BoxHudEntry.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/BoxHudEntry.java index 397318fd2..f179a412a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/BoxHudEntry.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/BoxHudEntry.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.entry; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; @@ -29,8 +31,6 @@ import io.github.axolotlclient.modules.hud.gui.AbstractHudEntry; import net.minecraft.client.gui.GuiGraphics; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/SimpleTextHudEntry.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/SimpleTextHudEntry.java index 0e7588257..ee1116626 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/SimpleTextHudEntry.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/SimpleTextHudEntry.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.entry; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -35,8 +37,6 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import net.minecraft.client.gui.GuiGraphics; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/TextHudEntry.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/TextHudEntry.java index 28e8231fb..f8fc6362c 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/TextHudEntry.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/entry/TextHudEntry.java @@ -22,13 +22,13 @@ package io.github.axolotlclient.modules.hud.gui.entry; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CompassHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CompassHud.java index fcfa9abed..b88bd2de8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CompassHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CompassHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -37,8 +39,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java index 3773fa4f6..4951ec535 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/CoordsHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.*; import io.github.axolotlclient.modules.hud.gui.component.DynamicallyPositionable; @@ -32,10 +36,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.util.Identifier; -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index ae8e75bb0..e1f842da5 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -32,7 +36,8 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.option.KeyBind; @@ -41,10 +46,6 @@ import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -92,8 +93,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); this.client = MinecraftClient.getInstance(); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -134,12 +135,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/MemoryHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/MemoryHud.java index 78b81b5c8..92290580f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/MemoryHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/MemoryHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption; @@ -38,8 +40,6 @@ import net.minecraft.client.resource.language.I18n; import net.minecraft.util.Identifier; -import java.util.List; - public class MemoryHud extends TextHudEntry implements DynamicallyPositionable { public static final Identifier ID = new Identifier("axolotlclient", "memoryhud"); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PackDisplayHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PackDisplayHud.java index 0be46d04e..8b1920ddb 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PackDisplayHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PackDisplayHud.java @@ -22,6 +22,12 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.texture.NativeImage; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; @@ -37,12 +43,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - public class PackDisplayHud extends TextHudEntry { public static final Identifier ID = new Identifier("axolotlclient", "packdisplayhud"); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 0c84e10e6..a58b2654a 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -22,13 +22,16 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.List; + import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; @@ -42,8 +45,6 @@ import org.joml.Quaternionf; import org.joml.Vector3f; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -67,11 +68,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PotionsHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PotionsHud.java index 798ac3115..e04a636e6 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PotionsHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PotionsHud.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud; +import java.util.ArrayList; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; @@ -40,9 +43,6 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.util.Identifier; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java index 6d85ed30f..655ca12a1 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArmorHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.item; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry; @@ -34,8 +36,6 @@ import net.minecraft.nbt.NbtList; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -86,10 +86,12 @@ public void renderMainItem(GuiGraphics graphics, ItemStack stack, int x, int y) if (total.equals("1")) { total = null; } + graphics.drawItem(stack, x, y); graphics.drawItemInSlot(client.textRenderer, stack, x, y, total); } public void renderItem(GuiGraphics graphics, ItemStack stack, int x, int y) { + graphics.drawItem(stack, x, y); graphics.drawItemInSlot(client.textRenderer, stack, x, y); } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java index da1fbb41c..1be344b51 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ArrowHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.item; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry; @@ -35,8 +37,6 @@ import net.minecraft.util.Hand; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -75,7 +75,7 @@ public void renderComponent(GuiGraphics graphics, float delta) { DrawPosition pos = getPos(); drawCenteredString(graphics, client.textRenderer, String.valueOf(arrows), pos.x() + getWidth() / 2, pos.y() + getHeight() - 10, textColor.get(), shadow.get()); - ItemUtil.renderGuiItemModel(getScale(), currentArrow, pos.x() + 2, pos.y() + 2); + graphics.drawItem(currentArrow, pos.x() + 2, pos.y() + 2); } @Override diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ItemUpdateHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ItemUpdateHud.java index c9cd774e4..5520a1599 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ItemUpdateHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/item/ItemUpdateHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud.item; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; @@ -40,10 +44,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Language; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index adadc0844..e5f40bbf3 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.util.ArrayList; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. @@ -48,20 +48,20 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register((window, button, action, mods) -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register(event -> { if (fromKeybindings.get()) { - if (key.equals(client.options.attackKey)) { + if (event.getKey().equals(client.options.attackKey)) { ClickList.LEFT.click(); - } else if (key.equals(client.options.useKey)) { + } else if (event.getKey().equals(client.options.useKey)) { ClickList.RIGHT.click(); } } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/IRLTimeHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/IRLTimeHud.java index bb8d51f22..04b575b8b 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/IRLTimeHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/IRLTimeHud.java @@ -22,16 +22,16 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import io.github.axolotlclient.AxolotlClientConfig.options.Option; -import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; -import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import net.minecraft.util.Identifier; - import java.time.LocalDateTime; import java.time.Month; import java.time.format.DateTimeFormatter; import java.util.List; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; +import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; +import net.minecraft.util.Identifier; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/PingHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/PingHud.java index a1827ab7b..8264a9efd 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/PingHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/PingHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -42,8 +44,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java index 58def8e0c..1d9045ebd 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.List; + import com.google.common.util.concurrent.AtomicDouble; import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; @@ -35,10 +39,6 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/SpeedHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/SpeedHud.java index 2556344a5..201a53ffa 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/SpeedHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/SpeedHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -29,10 +33,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3d; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/TPSHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/TPSHud.java index 0552e1aa9..4c97b05e8 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/TPSHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/TPSHud.java @@ -22,12 +22,12 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; -import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import net.minecraft.util.Identifier; - import java.text.DecimalFormat; import java.text.NumberFormat; +import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; +import net.minecraft.util.Identifier; + /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java index 7f164e4af..da037c236 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ToggleSprintHud.java @@ -22,6 +22,14 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Random; + import com.mojang.blaze3d.platform.InputUtil; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.KeyBindOption; @@ -35,14 +43,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Random; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ActionBarHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ActionBarHud.java index 76700b7d2..b7c2fd761 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ActionBarHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ActionBarHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; @@ -32,8 +34,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/BossBarHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/BossBarHud.java index a6e720984..378e3a910 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/BossBarHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/BossBarHud.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; @@ -39,11 +44,6 @@ import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java index e7834d0db..7d054cb82 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/CrosshairHud.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.List; + import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -45,8 +47,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.List; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java index 109a9094c..fba27b18e 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.ArrayList; +import java.util.List; + import com.mojang.blaze3d.systems.RenderSystem; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry; @@ -34,9 +37,6 @@ import net.minecraft.util.Arm; import net.minecraft.util.Identifier; -import java.util.ArrayList; -import java.util.List; - public class HotbarHUD extends TextHudEntry { public static final Identifier ID = new Identifier("axolotlclient", "hotbarhud"); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ScoreboardHud.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ScoreboardHud.java index f1dffadc2..ca28ff94e 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ScoreboardHud.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/ScoreboardHud.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.hud.gui.hud.vanilla; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.mojang.datafixers.util.Pair; @@ -38,11 +43,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/snapping/SnappingHelper.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/snapping/SnappingHelper.java index 3a3f13cd8..68c19e4b1 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/snapping/SnappingHelper.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/snapping/SnappingHelper.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.snapping; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.glfw.Window; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.modules.hud.util.DrawUtil; @@ -30,10 +34,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.GuiGraphics; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/ItemUtil.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/ItemUtil.java index 4f07e2d9a..d37f0dff7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/ItemUtil.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/ItemUtil.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import com.mojang.blaze3d.lighting.DiffuseLighting; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; @@ -37,10 +41,6 @@ import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.util.Util; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java b/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java index 15caf802c..b6da409b7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hud/util/RenderUtil.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hud.util; +import java.util.function.Supplier; + import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import io.github.axolotlclient.AxolotlClientConfig.Color; @@ -31,8 +33,6 @@ import net.minecraft.client.render.ShaderProgram; import org.joml.Matrix4f; -import java.util.function.Supplier; - /** * This implementation of Hud modules is based on KronHUD. * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 18623adbb..dffcc153d 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.hypixel; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; @@ -30,13 +33,11 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; -import java.util.ArrayList; -import java.util.List; - public class HypixelMods extends AbstractModule { private static final HypixelMods INSTANCE = new HypixelMods(); @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index fcf8bb044..b5d93e47f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hypixel.autogg; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; @@ -31,10 +35,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - /** * Based on DragonEggBedrockBreaking's AutoGG Mod * diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index e33ff9645..23c9956e7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.hypixel.autotip; +import java.util.regex.Pattern; + import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; @@ -30,8 +32,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; -import java.util.regex.Pattern; - public class AutoTip implements AbstractHypixelMod { @Getter diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..f38d654d8 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,473 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; +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.Formatting; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +public class BedwarsGame { + private BedwarsTeam won = null; + private int wonTick = -1; + private int seconds = 0; + private Text topBarText = Text.empty(); + private Text bottomBarText = Text.empty(); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + teamPlayers.compute(team, (t, entries) -> { + if (entries == null) { + List players = new ArrayList<>(); + players.add(player); + return players; + } + entries.add(player); + return entries; + }); + } + for (Map.Entry> teamPlayerList : teamPlayers.entrySet()) { + teamPlayerList.getValue().sort(Comparator.comparing(p -> p.getProfile().getName())); + List value = teamPlayerList.getValue(); + for (int i = 0; i < value.size(); i++) { + PlayerListEntry e = value.get(i); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + public Text getBottomBarText() { + return bottomBarText; + } + + private String calculateTopBarText() { + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); + } + + private String calculateBottomBarText() { + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) + .collect(Collectors.joining("\n"));*/ + } + + public String getFormattedTime() { + int minute = seconds / 60; + int second = seconds % 60; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + return time; + } + + public Optional getPlayer(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + + public Optional getPlayer(String name) { + return Optional.ofNullable(players.getOrDefault(name, null)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(Text.literal("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDeath(player, killer, type, finalDeath))); + } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = killer; + } + } + + private String formatDisconnect(BedwarsPlayer disconnected) { + String playerFormatted = getPlayerFormatted(disconnected); + return playerFormatted + " §7§o/disconnected/"; + } + + private String formatReconnect(BedwarsPlayer reconnected) { + String playerFormatted = getPlayerFormatted(reconnected); + return playerFormatted + " §7§o/reconnected/"; + } + + private String formatEliminated(BedwarsTeam team) { + StringBuilder message = new StringBuilder( + "§6§l§oTEAM ELIMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "); + for (BedwarsPlayer p : players.values().stream() + .filter(b -> b.getTeam() == team) + .sorted(Comparator.comparingInt(BedwarsPlayer::getNumber)) + .toList()) { + BedwarsPlayerStats stats = p.getStats(); + if (stats == null) { + continue; + } + message.append("\n") + .append("§b") + .append(stats.getStars()) + .append(" ") + .append(p.getColoredName()) + .append("§7 Beds: §f") + .append(stats.getBedsBroken()) + .append("§7 Finals: §f") + .append(stats.getFinalKills()) + .append("§7 FKDR: §f") + .append(String.format("%.2f", stats.getFKDR())) + .append("§7 BBLR: §f") + .append(String.format("%.2f", stats.getBBLR())); + } + return message.toString(); + } + + private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { + String playerFormatted = getPlayerFormatted(breaker); + return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted + + (breaker.getStats() == null || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner().get(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + if (BedwarsDeathType.getDeath(rawMessage, (type, m) -> { + died(m, rawMessage, event, type); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.BED_DESTROY, rawMessage, m -> { + BedwarsPlayer player = BedwarsMessages.matched(BedwarsMessages.BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); + BedwarsTeam team = BedwarsTeam.fromName(m.group(1)).orElse(me.getTeam()); + bedDestroyed(event, team, player); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> disconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> reconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.GAME_END, rawMessage, m -> { + BedwarsTeam win = players.values().stream().filter(p -> !p.isFinalKilled()).findFirst().map(BedwarsPlayer::getTeam).orElse(null); + this.won = win; + this.wonTick = mc.inGameHud.getTicks() + 10; + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + private void died(Matcher m, String rawMessage, ReceiveChatMessageEvent event, BedwarsDeathType type) { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + BedwarsPlayer killer = null; + if (type != BedwarsDeathType.SELF_UNKNOWN && type != BedwarsDeathType.SELF_VOID) { + killer = getPlayer(m.group(2)).orElse(null); + } + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(event, killed, killer, type, BedwarsMessages.matched(BedwarsMessages.FINAL_KILL, rawMessage).isPresent()); + } + + private void gameEnd(BedwarsTeam win) { + if (me == null) { + BedwarsMod.getInstance().gameEnd(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + Text.literal("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + Text.literal( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { + // Make sure everyone is dead, just in case + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { + b.setBed(false); + b.died(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatEliminated(team))); + } + } + + private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + if (breaker != null && breaker.getStats() != null) { + breaker.getStats().addBed(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(Text.literal(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + Collections.reverse(filteredScores); + if (filteredScores.size() < 3) { + return; + } + ScoreboardPlayerScore score = filteredScores.get(2); + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String timer = Team.decorateName(team, Text.literal(score.getPlayerName())).getString(); + if (!timer.contains(":")) { + return; + } + int seconds; + try { + seconds = Integer.parseInt(timer.split(":")[1].substring(0, 2)); + } catch (Exception e) { + e.printStackTrace(); + return; + } + int target = (60 - seconds) % 60; + if (this.seconds % 60 != target) { + // Update seconds + while (this.seconds % 60 != target) { + updateClock(); + } + topBarText = Text.literal(calculateTopBarText()); + bottomBarText = Text.literal(calculateBottomBarText()); + } + } + + private void updateClock() { + this.seconds++; + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + public void updateEntries(List entries) { + // Update latencies and other information for entries + entries.forEach(entry -> + getPlayer(entry.getProfile().getName()).ifPresent(player -> player.updateListEntry(entry)) + ); + } + + public List getTabPlayerList(List original) { + updateEntries(original); + return players.values().stream().filter(b -> !b.isFinalKilled()).sorted((b1, b2) -> { + if (b1.getTeam() == b2.getTeam()) { + return Integer.compare(b1.getNumber(), b2.getNumber()); + } + return Integer.compare(b1.getTeam().ordinal(), b2.getTeam().ordinal()); + }).map(BedwarsPlayer::getProfile).collect(Collectors.toList()); + } + + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); + } + + public void renderCustomScoreboardObjective(GuiGraphics graphics, String playerName, ScoreboardObjective objective, int y, int endX) { + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + graphics.drawShadowedText(mc.textRenderer, + render, + (endX - mc.textRenderer.getWidth(render)), + y, + color + ); + + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..a43a7a9eb --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,228 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + private final static Pattern[] GAME_START = { + Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().getString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(Text.literal(time).append(event.getNewMessage())); + } else { + event.setNewMessage(Text.literal(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListHud().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListHud().getPlayerName(player).getString().replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName().getString()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .toList(); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, Text.literal(score.getPlayerName())).getString()).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..07bce84e3 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + private boolean disconnected = false; + private boolean bed = true; + private final int number; + private BedwarsPlayerStats stats = null; + private boolean triedStats = false; + private int tickAlive = -1; + + public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { + this.team = team; + this.profile = profile; + this.number = number; + } + + public String getColoredTeamNumber(String format) { + return getTeam().getColorSection() + format + getTeam().getPrefix() + getNumber(); + } + + public String getColoredTeamNumber() { + return getTeam().getColorSection() + getTeam().getPrefix() + getNumber(); + } + + public String getName() { + return profile.getProfile().getName(); + } + + public String getColoredName() { + return team.getColorSection() + getName(); + } + + public String getTabListDisplay() { + if (alive) { + if (bed) { + return team.getColorSection() + "§l" + team.getPrefix() + number + " " + getColoredName(); + } + return team.getColorSection() + "§l" + team.getPrefix() + number + team.getColorSection() + "§o " + getName(); + } + if (disconnected) { + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §o§n" + getName(); + } + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §m" + getName(); + } + + public void updateListEntry(PlayerListEntry entry) { + this.profile = entry; + } + + public boolean isFinalKilled() { + return tickAlive < 0 && !bed && !alive || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + public void died() { + if (!alive) { + if (!bed) { + tickAlive = -1; + } + return; + } + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + alive = false; + if (!bed) { + tickAlive = -1; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 10; // 10 second respawn + } + + public void killed(boolean finalKill) { + if (stats != null) { + if (finalKill) { + stats.addFinalKill(); + } + stats.addKill(); + } + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..0537b7297 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,136 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.List; + +import com.mojang.blaze3d.systems.RenderSystem; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + @Override + public void render(GuiGraphics graphics, float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(graphics, delta); + } + } + + public void drawOverlay(GuiGraphics graphics, DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + RenderSystem.enableBlend(); + RenderSystem.setShaderColor(1, 1, 1, 1); + boolean normalUpgrades = false; + if (upgrades != null) { + for (TeamUpgrade u : upgrades.upgrades) { + if (!u.isPurchased()) { + continue; + } + if (u instanceof TrapUpgrade) { + continue; + } + TextureInfo texture; + texture = u.getTexture()[0]; + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + graphics.drawTexture(new Identifier("minecraft", texture.getTexture()), x, y, 16, 16, texture.getU(), texture.getV(), texture.getWidth(), texture.getHeight(), texture.getRegionWidth(), texture.getRegionHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + RenderSystem.setShaderColor(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + graphics.drawTexture(new Identifier("minecraft", texture.getTexture()), x, y, 16, 16, texture.getU(), texture.getV(), texture.getWidth(), texture.getHeight(), texture.getRegionWidth(), texture.getRegionHeight()); + RenderSystem.setShaderColor(1, 1, 1, 1); + x += 17; + } + } + + @Override + public void renderComponent(GuiGraphics stack, float delta) { + drawOverlay(stack, getPos(), false); + } + + @Override + public void renderPlaceholderComponent(GuiGraphics stack, float delta) { + drawOverlay(stack, getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..b93109e79 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +public class BedwarsTeamUpgrades { + + public final TrapUpgrade trap = new TrapUpgrade(); + + public final TeamUpgrade sharpness = new BinaryUpgrade( + "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords"), + 8, 4, new TextureInfo("textures/item/stone_sword.png"), new TextureInfo("textures/item/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/item/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/item/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/health_boost.png", 0, 0, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,3}\\s*$"), + new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/mob_effect/resistance.png", 0, 0, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,3}\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18, Color.GRAY), + new TextureInfo("textures/mob_effect/haste.png", 0, 0, 18, 18), + } + ); + + public final TeamUpgrade forge = new TieredUpgrade( + "forge", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (?:Iron|Golden|Emerald|Molten) Forge\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/block/furnace_front.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/block/furnace_front_on.png", 198 + 18, 6*18, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; + + public BedwarsTeamUpgrades() { + + } + + public void onMessage(String rawMessage) { + for (TeamUpgrade upgrade : upgrades) { + if (upgrade.match(rawMessage)) { + return; + } + } + } + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..a4b43b345 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,130 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +public class TrapUpgrade extends TeamUpgrade { + + private final static Pattern[] REGEX = { + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), + Pattern.compile("Trap was set (off)!"), + }; + + private final List traps = new ArrayList<>(3); + + public TrapUpgrade() { + super("trap", REGEX); + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + if (matcher.group(1).equals("off")) { + // Trap went off + traps.remove(0); + return; + } + traps.add(TrapType.getFuzzy(matcher.group(1))); + } + + public boolean canPurchase() { + return traps.size() < 3; + } + + @Override + public int getPrice(BedwarsMode mode) { + switch (traps.size()) { + case 0 -> { + return 1; + } + case 1 -> { + return 2; + } + case 2 -> { + return 4; + } + } + return 0; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/mob_effect/blindness.png", 0, 0, 18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/mob_effect/speed.png", 0, 0, 18, 18)), + ALARM(new TextureInfo("textures/item/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/mob_effect/mining_fatigue.png", 0, 0, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + public static TrapType getFuzzy(String s) { + s = s.toLowerCase(Locale.ROOT); + if (s.contains("miner")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/particles/Particles.java b/1.20/src/main/java/io/github/axolotlclient/modules/particles/Particles.java index 67f41030b..b8eabb7e6 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/particles/Particles.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/particles/Particles.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.particles; +import java.util.*; +import java.util.stream.Collectors; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.Color; import io.github.axolotlclient.AxolotlClientConfig.options.*; @@ -33,9 +36,6 @@ import net.minecraft.registry.Registries; import org.apache.commons.lang3.StringUtils; -import java.util.*; -import java.util.stream.Collectors; - public class Particles extends AbstractModule { private static final Particles Instance = new Particles(); 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 index a8a45eb9b..0ef205bc3 100644 --- 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 @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.rpc; +import java.time.Instant; + import de.jcm.discordgamesdk.Core; import de.jcm.discordgamesdk.CreateParams; import de.jcm.discordgamesdk.DiscordEventAdapter; @@ -37,8 +39,6 @@ import io.github.axolotlclient.util.Util; import net.minecraft.client.MinecraftClient; -import java.time.Instant; - /** * This DiscordRPC module is derived from HyCord. * diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java index d4721833b..131fcab32 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageShare.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.screenshotUtils; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.nio.file.Files; +import java.util.Base64; + import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.blaze3d.texture.NativeImage; @@ -38,11 +43,6 @@ import org.apache.http.impl.client.HttpClients; import org.quiltmc.loader.api.QuiltLoader; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.nio.file.Files; -import java.util.Base64; - public class ImageShare { @Getter diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageViewerScreen.java b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageViewerScreen.java index 4be10eace..44fea3f92 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageViewerScreen.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageViewerScreen.java @@ -22,6 +22,19 @@ package io.github.axolotlclient.modules.screenshotUtils; +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.Locale; +import java.util.Objects; +import java.util.function.Supplier; + import com.google.common.hash.Hashing; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.texture.NativeImage; @@ -41,19 +54,6 @@ import org.jetbrains.annotations.NotNull; import org.quiltmc.loader.api.QuiltLoader; -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.URI; -import java.nio.file.Files; -import java.util.HashMap; -import java.util.Locale; -import java.util.Objects; -import java.util.function.Supplier; - public class ImageViewerScreen extends Screen { // Icon from https://lucide.dev, "arrow-right" diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ScreenshotUtils.java b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ScreenshotUtils.java index df81cb924..47b803b68 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ScreenshotUtils.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ScreenshotUtils.java @@ -22,6 +22,14 @@ package io.github.axolotlclient.modules.screenshotUtils; +import java.awt.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.io.File; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.*; import io.github.axolotlclient.modules.AbstractModule; @@ -33,14 +41,6 @@ import net.minecraft.util.Util; import org.jetbrains.annotations.Nullable; -import java.awt.*; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.io.File; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; - public class ScreenshotUtils extends AbstractModule { private static final ScreenshotUtils Instance = new ScreenshotUtils(); diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.20/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index aec4442c5..848eadec7 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -62,7 +62,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 1d9570704..faf901207 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.modules.sky; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.Map; +import java.util.stream.Collectors; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; @@ -33,11 +38,6 @@ import org.jetbrains.annotations.NotNull; import org.quiltmc.qsl.resource.loader.api.reloader.SimpleSynchronousResourceReloader; -import java.io.BufferedReader; -import java.io.IOException; -import java.util.Map; -import java.util.stream.Collectors; - /** * This implementation of custom skies is based on the FabricSkyBoxes mod by AMereBagatelle * Github Link. @@ -81,7 +81,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loading MCP sky from " + entry.getKey()); SkyboxManager.getInstance() @@ -90,7 +90,7 @@ public void reload(ResourceManager manager) { } for (Map.Entry entry : manager - .findResources("optifine/sky", identifier -> identifier.getPath().endsWith(".properties")).entrySet()) { + .findResources("optifine/sky", identifier -> isMCPSky(identifier.getPath())).entrySet()) { AxolotlClient.LOGGER.debug("Loading OF sky from " + entry.getKey()); SkyboxManager.getInstance() .addSkybox(new MCPSkyboxInstance(loadMCPSky("optifine", entry.getKey(), entry.getValue()))); @@ -100,6 +100,10 @@ public void reload(ResourceManager manager) { AxolotlClient.LOGGER.debug("Finished Loading Custom Skies!"); } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private static JsonObject loadMCPSky(String loader, Identifier id, Resource resource) { JsonObject object = new JsonObject(); String line; diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxInstance.java b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxInstance.java index 9de86cea2..4640dab95 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxInstance.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxInstance.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.modules.sky; +import java.util.Locale; +import java.util.Objects; + import com.google.gson.JsonObject; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; @@ -39,9 +42,6 @@ import org.joml.Matrix4f; import org.lwjgl.opengl.GL14; -import java.util.Locale; -import java.util.Objects; - /** * This implementation of custom skies is based on the FabricSkyBoxes mod by AMereBagatelle * Github Link. diff --git a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxManager.java b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxManager.java index 2331b406f..513775809 100644 --- a/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxManager.java +++ b/1.20/src/main/java/io/github/axolotlclient/modules/sky/SkyboxManager.java @@ -22,13 +22,13 @@ package io.github.axolotlclient.modules.sky; -import net.minecraft.client.util.math.MatrixStack; -import org.joml.Matrix4f; - import java.util.ArrayList; import java.util.Objects; import java.util.function.Predicate; +import net.minecraft.client.util.math.MatrixStack; +import org.joml.Matrix4f; + /** * This implementation of custom skies is based on the FabricSkyBoxes mod by AMereBagatelle * Github Link. 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 index 922d57c75..906dcbe4c 100644 --- 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 @@ -22,6 +22,8 @@ package io.github.axolotlclient.modules.tnttime; +import java.text.DecimalFormat; + import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; @@ -31,8 +33,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.text.DecimalFormat; - public class TntTime extends AbstractModule { private static final TntTime Instance = new TntTime(); 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 219e4e940..496a21664 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,6 +22,11 @@ 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; @@ -35,11 +40,6 @@ import org.quiltmc.qsl.networking.api.client.ClientPlayConnectionEvents; import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking; -import java.util.HashMap; -import java.util.Locale; -import java.util.Objects; -import java.util.function.Supplier; - public class FeatureDisabler { private static final HashMap disabledServers = new HashMap<>(); diff --git a/1.20/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.20/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index b35c4ab5d..000000000 --- a/1.20/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2021-2023 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 com.mojang.blaze3d.platform.InputUtil; -import net.minecraft.client.option.KeyBind; -import org.quiltmc.qsl.base.api.event.Event; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = Event.create(MouseInputCallback.class, - listeners -> ((window, button, action, mods) -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(window, button, action, mods); - } - })); - public static final Event KEYBIND_CHANGE = Event.create(ChangeBind.class, listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = Event.create(OnPress.class, listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = Event - .create(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(long window, int button, int action, int mods); - } - - public interface ChangeBind { - - void setBoundKey(InputUtil.Key boundKey); - } - - public interface OnPress { - - void onPress(KeyBind binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/NetworkHelper.java b/1.20/src/main/java/io/github/axolotlclient/util/NetworkHelper.java index 03615cde0..56bd7fa50 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/NetworkHelper.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/NetworkHelper.java @@ -22,17 +22,17 @@ package io.github.axolotlclient.util; +import java.io.IOException; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + import com.google.gson.JsonElement; import io.github.axolotlclient.AxolotlClient; import net.minecraft.client.MinecraftClient; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import java.io.IOException; -import java.util.UUID; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - public class NetworkHelper { private static final AtomicInteger concurrentCalls = new AtomicInteger(0); diff --git a/1.20/src/main/java/io/github/axolotlclient/util/ThreadExecuter.java b/1.20/src/main/java/io/github/axolotlclient/util/ThreadExecuter.java index 9ea06f89b..fc673cc3f 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/ThreadExecuter.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/ThreadExecuter.java @@ -22,11 +22,11 @@ package io.github.axolotlclient.util; -import com.google.common.util.concurrent.ThreadFactoryBuilder; - import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + public class ThreadExecuter { private static final ScheduledThreadPoolExecutor EXECUTER_SERVICE = new ScheduledThreadPoolExecutor(3, diff --git a/1.20/src/main/java/io/github/axolotlclient/util/Util.java b/1.20/src/main/java/io/github/axolotlclient/util/Util.java index c737025c2..05aa1596b 100644 --- a/1.20/src/main/java/io/github/axolotlclient/util/Util.java +++ b/1.20/src/main/java/io/github/axolotlclient/util/Util.java @@ -22,6 +22,9 @@ package io.github.axolotlclient.util; +import java.util.*; +import java.util.stream.Collectors; + import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.mojang.blaze3d.glfw.Window; @@ -38,9 +41,6 @@ import org.apache.commons.lang3.StringUtils; import org.lwjgl.opengl.GL11; -import java.util.*; -import java.util.stream.Collectors; - public class Util { private final static TreeMap map = new TreeMap<>(); diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..65717aca9 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2021-2023 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.events; + +import java.util.Arrays; + +import io.github.axolotlclient.util.events.impl.*; +import org.quiltmc.qsl.base.api.event.Event; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent() { + return Event + .create(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..72214c8aa --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import com.mojang.blaze3d.platform.InputUtil; +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final InputUtil.Key boundKey; + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..62ad3314d --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBind; + +@Data +public class KeyPressEvent { + + private final KeyBind key; +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..1217f4d0d --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final long window; + private final int button, action, mods; +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..460f7b4b2 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..2b813be85 --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final ScoreboardObjective objective; +} diff --git a/1.20/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.20/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.8.9/build.gradle b/1.8.9/build.gradle index 7e92e5f9b..9167d19b1 100644 --- a/1.8.9/build.gradle +++ b/1.8.9/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'io.github.juuxel.loom-quiltflower' version '1.8.+' - id "fabric-loom" version "1.0-SNAPSHOT" + id "fabric-loom" version "1.0.+" } group = maven_group @@ -32,15 +32,13 @@ dependencies { mappings "net.legacyfabric:yarn:${project.mappings_18}" modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader}" - - annotationProcessor "org.ow2.asm:asm:${project.asmVersion}" - annotationProcessor "org.ow2.asm:asm-analysis:${project.asmVersion}" - annotationProcessor "org.ow2.asm:asm-commons:${project.asmVersion}" - annotationProcessor "org.ow2.asm:asm-tree:${project.asmVersion}" - annotationProcessor "org.ow2.asm:asm-util:${project.asmVersion}" + modImplementation("net.fabricmc:dev-launch-injector:0.2.1+build.8") modImplementation "io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}" include "io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}" + modImplementation "io.github.axolotlclient.AxolotlClient-config:AxolotlClientConfig-common:${project.config}" + + modImplementation "net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${project.lfapi}+${project.minecraft_18}" modCompileOnlyApi(files("libs/legacy-modmenu-1.2.0+1.8.9-dev.jar")) 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 0e2e3a24f..06f96bcaf 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 @@ -56,6 +56,7 @@ public class AxolotlClientConfig extends ConfigHolder { public final IntegerOption cloudHeight = new IntegerOption("cloudHeight", 128, 100, 512); public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true); public final BooleanOption fullBright = new BooleanOption("fullBright", false); + public final BooleanOption removeVignette = new BooleanOption("removeVignette", false); public final BooleanOption lowFire = new BooleanOption("lowFire", false); public final ColorOption hitColor = new ColorOption("hitColor", new Color(255, 0, 0, 77)); public final BooleanOption minimalViewBob = new BooleanOption("minimalViewBob", false); @@ -138,6 +139,7 @@ public void init() { AxolotlClientConfigConfig.chromaSpeed, dynamicFOV, fullBright, + removeVignette, lowFire, hitColor, minimalViewBob, diff --git a/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java b/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java index de4b3b169..0b1512a87 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/config/screen/CreditsScreen.java @@ -250,11 +250,11 @@ private void initCredits() { credits.add(new Credit("DragonEggBedrockBreaking", "Bugfixing", "Inspiration of new Features")); credits.add(new Credit("CornetPanique86", "French Translation")); credits.add(new Credit("kuchenag", "Logo/Icon Creator")); + credits.add(new Credit("DarkKronicle", "Bedwars Overlay", "Author of KronHUD, the best HUD mod!")); credits.add(new SpacerTitle("- - - - - - " + I18n.translate("other_people") + " - - - - - -")); credits.add(new Credit("gart", "gartbin dev and host", "Image sharing help", "https://gart.sh")); - credits.add(new Credit("DarkKronicle", "Author of KronHUD, the best HUD mod!")); credits.add(new Credit("AMereBagatelle", "Author of the excellent FabricSkyBoxes Mod")); if (!externalModuleCredits.isEmpty()) { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java index 66fe75ffd..02c8c357e 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/ChatHudMixin.java @@ -25,11 +25,10 @@ import java.util.List; import io.github.axolotlclient.modules.hud.HudManager; -import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; -import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; -import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatHudLine; @@ -49,16 +48,25 @@ public abstract class ChatHudMixin { @Final private List visibleMessages; - @Inject(method = "addMessage(Lnet/minecraft/text/Text;IIZ)V", at = @At("HEAD"), cancellable = true) - public void axolotlclient$autoGG(Text message, int messageId, int timestamp, boolean bl, CallbackInfo ci) { - AutoGG.getInstance().onMessage(message); - AutoBoop.getInstance().onMessage(message); - - if (AutoTip.getInstance().onChatMessage(message)) { + @Inject(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;addMessage(Lnet/minecraft/text/Text;IIZ)V"), cancellable = true) + public void axolotlclient$autoGG(Text message, int messageId, CallbackInfo ci) { + if (message == null) { ci.cancel(); } } + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At("HEAD"), argsOnly = true) + private Text axolotlclient$onChatMessage(Text message) { + ReceiveChatMessageEvent event = new ReceiveChatMessageEvent(false, message.asUnformattedString(), message); + Events.RECEIVE_CHAT_MESSAGE_EVENT.invoker().invoke(event); + if (event.isCancelled()) { + return null; + } else if (event.getNewMessage() != null) { + return event.getNewMessage(); + } + return message; + } + @ModifyArg(method = "addMessage(Lnet/minecraft/text/Text;I)V", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;info(Ljava/lang/String;)V"), remap = false) public String axolotlclient$noNamesInLogIfHidden(String message) { return axolotlclient$editChat(new LiteralText(message)).asUnformattedString(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java index 46d8c2d38..037f191a3 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/EntityMixin.java @@ -22,7 +22,8 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; @@ -51,6 +52,6 @@ public abstract class EntityMixin { pitch = (float) ((double) prevPitch - (double) pitch * 0.15); yaw = (float) ((double) prevYaw + (double) yaw * 0.15); pitch = MathHelper.clamp(pitch, -90.0F, 90.0F); - Hooks.PLAYER_DIRECTION_CHANGE.invoker().onChange(prevPitch, prevYaw, pitch, yaw); + Events.PLAYER_DIRECTION_CHANGE.invoker().invoke(new PlayerDirectionChangeEvent(prevPitch, prevYaw, pitch, yaw)); } } 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 586f5dfbc..6dd5ccbb3 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 @@ -26,6 +26,7 @@ import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.modules.freelook.Perspective; import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.util.Util; import net.minecraft.client.MinecraftClient; @@ -73,31 +74,19 @@ public abstract class EntityRendererMixin { @Inject(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Ljava/lang/String;III)I", ordinal = 1)) public void axolotlclient$addLevel(T entity, String string, double d, double e, double f, int i, CallbackInfo ci) { - if (entity instanceof AbstractClientPlayerEntity) { + if (entity instanceof AbstractClientPlayerEntity && string.contains(entity.getName().asFormattedString())) { if (Util.currentServerAddressContains("hypixel.net")) { - if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get() - && string.contains(entity.getName().asFormattedString())) { - TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; - String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); - - float x = textRenderer.getStringWidth(text) / 2F; - int y = string.contains("deadmau5") ? -20 : -10; - - if (LevelHead.getInstance().background.get()) { - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); - GlStateManager.disableTexture(); - bufferBuilder.begin(7, VertexFormats.POSITION_COLOR); - bufferBuilder.vertex(-x - 1, -1 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); - bufferBuilder.vertex(-x - 1, 8 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); - bufferBuilder.vertex(x + 1, 8 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); - bufferBuilder.vertex(x + 1, -1 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); - tessellator.draw(); - GlStateManager.enableTexture(); + if (BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + BedwarsMod.getInstance().bedwarsLevelHead.get()) { + String levelhead = BedwarsMod.getInstance().getGame().get().getLevelHead((AbstractClientPlayerEntity) entity); + if (levelhead != null) { + axolotlclient$drawLevelHead(levelhead); } + } else if (HypixelAbstractionLayer.hasValidAPIKey() && LevelHead.getInstance().enabled.get()) { + String text = "Level: " + HypixelAbstractionLayer.getPlayerLevel(String.valueOf(entity.getUuid()), LevelHead.getInstance().mode.get()); - textRenderer.draw(text, -x, y, LevelHead.getInstance().textColor.get().getAsInt(), - AxolotlClient.CONFIG.useShadows.get()); + axolotlclient$drawLevelHead(text); } else if (!HypixelAbstractionLayer.hasValidAPIKey()) { HypixelAbstractionLayer.loadApiKey(); } @@ -105,6 +94,29 @@ public abstract class EntityRendererMixin { } } + private void axolotlclient$drawLevelHead(String text) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + + float x = textRenderer.getStringWidth(text) / 2F; + int y = text.contains("deadmau5") ? -20 : -10; + + if (LevelHead.getInstance().background.get()) { + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder bufferBuilder = tessellator.getBuffer(); + GlStateManager.disableTexture(); + bufferBuilder.begin(7, VertexFormats.POSITION_COLOR); + bufferBuilder.vertex(-x - 1, -1 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); + bufferBuilder.vertex(-x - 1, 8 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); + bufferBuilder.vertex(x + 1, 8 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); + bufferBuilder.vertex(x + 1, -1 + y, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).next(); + tessellator.draw(); + GlStateManager.enableTexture(); + } + + textRenderer.draw(text, -x, y, LevelHead.getInstance().textColor.get().getAsInt(), + AxolotlClient.CONFIG.useShadows.get()); + } + @Redirect(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/BufferBuilder;vertex(DDD)Lnet/minecraft/client/render/BufferBuilder;")) public BufferBuilder axolotlclient$noBg(BufferBuilder instance, double d, double e, double f) { if (AxolotlClient.CONFIG.nametagBackground.get()) { 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 85e9e6004..9994e2581 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 @@ -77,9 +77,9 @@ public abstract class GameMenuScreenMixin extends Screen { if (axolotlclient$hasModMenu()) return; - if ((MinecraftClient.getInstance().getServer() != null + if (!MinecraftClient.getInstance().isInSingleplayer() && ((MinecraftClient.getInstance().getServer() != null && MinecraftClient.getInstance().getServer().isPublished()) - || MinecraftClient.getInstance().getCurrentServerEntry() != null) { + || MinecraftClient.getInstance().getCurrentServerEntry() != null)) { args.set(0, 20); args.set(5, I18n.translate("title_short")); } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java index d4c8ce833..3f85548db 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java @@ -23,19 +23,24 @@ package io.github.axolotlclient.mixin; import com.mojang.blaze3d.platform.GlStateManager; +import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.config.AxolotlClientConfig; import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.Window; +import net.minecraft.entity.Entity; +import net.minecraft.entity.vehicle.MinecartEntity; import net.minecraft.scoreboard.ScoreboardObjective; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @@ -50,7 +55,9 @@ public abstract class InGameHudMixin { @Inject(method = "renderScoreboardObjective", at = @At("HEAD"), cancellable = true) public void axolotlclient$customScoreBoard(ScoreboardObjective objective, Window window, CallbackInfo ci) { ScoreboardHud hud = (ScoreboardHud) HudManager.getInstance().get(ScoreboardHud.ID); - if (hud.isEnabled()) { + ScoreboardRenderEvent event = new ScoreboardRenderEvent(window, objective); + Events.SCOREBOARD_RENDER_EVENT.invoker().invoke(event); + if (event.isCancelled() || hud.isEnabled()) { ci.cancel(); } } @@ -159,4 +166,44 @@ public abstract class InGameHudMixin { } return instance.getWidth(); } + + @Unique + private static final Entity axolotlclient$noHungerEntityTM = new MinecartEntity(null); + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), + ordinal = 18 + ) + public int axolotlclient$displayHardcoreHearts(int offset) { + boolean hardcore = BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && BedwarsMod.getInstance().hardcoreHearts.get() && + !BedwarsMod.getInstance().getGame().get().getSelf().isBed(); + return hardcore ? 5 : offset; + } + + @ModifyVariable( + method = "renderStatusBars", + at = @At( + value = "STORE" + ), + ordinal = 0 + ) + public Entity axolotlclient$dontHunger(Entity normal) { + if (normal == null && BedwarsMod.getInstance().isEnabled() && + BedwarsMod.getInstance().inGame() && + !BedwarsMod.getInstance().showHunger.get()) { + return axolotlclient$noHungerEntityTM; + } + return normal; + } + + @Inject(method = "renderVignetteOverlay", at = @At("HEAD"), cancellable = true) + private void axolotlclient$removeVignette(float f, Window window, CallbackInfo ci){ + if(AxolotlClient.CONFIG.removeVignette.get()){ + ci.cancel(); + } + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java index d83cc8096..ccc5abf2f 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/KeyBindingMixin.java @@ -22,7 +22,9 @@ package io.github.axolotlclient.mixin; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.KeyBindChangeEvent; +import io.github.axolotlclient.util.events.impl.KeyPressEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.util.collection.IntObjectStorage; @@ -49,7 +51,7 @@ public abstract class KeyBindingMixin { @Inject(method = "setKeyPressed", at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/KeyBinding;pressed:Z")) private static void axolotlclient$onPress(int keyCode, boolean pressed, CallbackInfo ci) { if (pressed) { - Hooks.KEYBIND_PRESS.invoker().onPress(KEY_MAP.get(keyCode)); + Events.KEY_PRESS.invoker().invoke(new KeyPressEvent(KEY_MAP.get(keyCode))); } } @@ -68,6 +70,6 @@ public abstract class KeyBindingMixin { @Inject(method = "setCode", at = @At("RETURN")) public void axolotlclient$boundKeySet(int code, CallbackInfo ci) { - Hooks.KEYBIND_CHANGE.invoker().setBoundKey(code); + Events.KEYBIND_CHANGE.invoker().invoke(new KeyBindChangeEvent(code)); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java index a281afed3..bfc505621 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/MinecraftClientMixin.java @@ -27,9 +27,11 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.rpc.DiscordRPC; import io.github.axolotlclient.modules.zoom.Zoom; -import io.github.axolotlclient.util.Hooks; import io.github.axolotlclient.util.NetworkHelper; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.MouseInputEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; import net.minecraft.client.gui.screen.Screen; @@ -82,6 +84,11 @@ protected MinecraftClientMixin(TextureManager textureManager) { public void axolotlclient$noWorldGC() { } + @Inject(method = "connect(Lnet/minecraft/client/world/ClientWorld;Ljava/lang/String;)V", at = @At("HEAD")) + private void axolotlclient$onWorldLoad(ClientWorld clientWorld, String string, CallbackInfo ci) { + Events.WORLD_LOAD_EVENT.invoker().invoke(new WorldLoadEvent(clientWorld)); + } + /** * @author moehreag * @reason Customize Window title for use in AxolotlClient @@ -155,7 +162,7 @@ protected MinecraftClientMixin(TextureManager textureManager) { @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getTime()J", ordinal = 0)) public void axolotlclient$onMouseButton(CallbackInfo ci) { if (Mouse.getEventButtonState()) { - Hooks.MOUSE_INPUT.invoker().onMouseButton(Mouse.getEventButton()); + Events.MOUSE_INPUT.invoker().invoke(new MouseInputEvent(Mouse.getEventButton())); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java index 2b1f3ce62..e01fb0765 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerEntityMixin.java @@ -25,6 +25,7 @@ import io.github.axolotlclient.modules.hud.HudManager; import io.github.axolotlclient.modules.hud.gui.hud.simple.ComboHud; import io.github.axolotlclient.modules.hud.gui.hud.simple.ReachHud; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.particles.Particles; import net.minecraft.client.MinecraftClient; import net.minecraft.client.particle.ParticleType; @@ -83,4 +84,17 @@ public PlayerEntityMixin(World world) { comboHud.onEntityDamage(this); } } + + @Inject( + method = "getArmorProtectionValue", + at = @At( + "HEAD" + ), + cancellable = true + ) + public void axolotlclient$disableArmor(CallbackInfoReturnable ci) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().inGame() && !BedwarsMod.getInstance().displayArmor.get()) { + ci.setReturnValue(0); + } + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java index 611e0f5a2..63549b02b 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java @@ -22,36 +22,48 @@ package io.github.axolotlclient.mixin; +import java.util.List; import java.util.UUID; import io.github.axolotlclient.AxolotlClient; +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsGame; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsPlayer; +import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.tablist.Tablist; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.network.ClientConnection; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.scoreboard.ScoreboardObjective; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin extends DrawableHelper { - - MinecraftClient client = MinecraftClient.getInstance(); + @Unique + private final MinecraftClient axolotlclient$client = MinecraftClient.getInstance(); @Shadow private Text header; @Shadow private Text footer; - private PlayerListEntry playerListEntry; + @Unique + private PlayerListEntry axolotlclient$playerListEntry; @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) public void axolotlclient$nickHider(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { @@ -66,13 +78,13 @@ public abstract class PlayerListHudMixin extends DrawableHelper { @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;getPlayerName(Lnet/minecraft/client/network/PlayerListEntry;)Ljava/lang/String;")) public PlayerListEntry axolotlclient$getPlayer(PlayerListEntry playerEntry) { - playerListEntry = playerEntry; + axolotlclient$playerListEntry = playerEntry; return playerEntry; } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;getStringWidth(Ljava/lang/String;)I", ordinal = 0)) public int axolotlclient$moveName(TextRenderer instance, String text) { - if (AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(playerListEntry.getProfile().getId())) + if (AxolotlClient.CONFIG.showBadges.get() && AxolotlClient.isUsingClient(axolotlclient$playerListEntry.getProfile().getId())) return instance.getStringWidth(text) + 10; return instance.getStringWidth(text); } @@ -82,8 +94,8 @@ public abstract class PlayerListHudMixin extends DrawableHelper { float x = args.get(1); float y = args.get(2); if (AxolotlClient.CONFIG.showBadges.get() - && AxolotlClient.isUsingClient(playerListEntry.getProfile().getId())) { - client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); + && AxolotlClient.isUsingClient(axolotlclient$playerListEntry.getProfile().getId())) { + axolotlclient$client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); DrawableHelper.drawTexture((int) x, (int) y, 0, 0, 8, 8, 8, 8); args.set(1, x + 10); } @@ -94,8 +106,8 @@ public abstract class PlayerListHudMixin extends DrawableHelper { float x = args.get(1); float y = args.get(2); if (AxolotlClient.CONFIG.showBadges.get() - && AxolotlClient.isUsingClient(playerListEntry.getProfile().getId())) { - client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); + && AxolotlClient.isUsingClient(axolotlclient$playerListEntry.getProfile().getId())) { + axolotlclient$client.getTextureManager().bindTexture(AxolotlClient.badgeIcon); DrawableHelper.drawTexture((int) x, (int) y, 0, 0, 8, 8, 8, 8); args.set(1, x + 10); } @@ -103,7 +115,9 @@ public abstract class PlayerListHudMixin extends DrawableHelper { @Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true) private void axolotlclient$numericalPing(int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) { - if (Tablist.getInstance().renderNumericPing(width, x, y, entry)) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + ci.cancel(); + } else if (Tablist.getInstance().renderNumericPing(width, x, y, entry)) { ci.cancel(); } } @@ -135,7 +149,133 @@ public abstract class PlayerListHudMixin extends DrawableHelper { } @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getPlayerByUuid(Ljava/util/UUID;)Lnet/minecraft/entity/player/PlayerEntity;")) - private UUID makeStuff(UUID par1) { + private UUID axolotlclient$makeStuff(UUID par1) { return Tablist.getInstance().alwaysShowHeadLayer.get() ? MinecraftClient.getInstance().player.getUuid() : par1; } + + @Inject( + method = "render", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/hud/PlayerListHud;renderLatencyIcon(IIILnet/minecraft/client/network/PlayerListEntry;)V" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + public void axolotlclient$renderWithoutObjective( + int width, Scoreboard scoreboard, ScoreboardObjective playerListScoreboardObjective, CallbackInfo ci, + ClientPlayNetworkHandler clientPlayNetworkHandler, List list, int i, int j, int l, int m, int k, boolean bl, int n, int o, + int p, int q, int r, List list2, int t, int u, int s, int v, int y, PlayerListEntry playerListEntry2 + ) { + if (!BedwarsMod.getInstance().isEnabled() || !BedwarsMod.getInstance().isWaiting()) { + return; + } + int startX = v + i + 1; + int endX = startX + n; + String render; + try { + if (playerListEntry2.getProfile().getName().contains(Formatting.OBFUSCATED.toString())) { + return; + } + + render = String.valueOf(HypixelAbstractionLayer.getPlayerLevel(playerListEntry2 + .getProfile().getId().toString().replace("-", ""), + LevelHeadMode.BEDWARS.toString())); + } catch (Exception e) { + return; + } + this.axolotlclient$client.textRenderer.drawWithShadow( + render, + (float) (endX - this.axolotlclient$client.textRenderer.getStringWidth(render)) + 20, + (float) y, + -1 + ); + } + + @Inject( + method = "renderScoreboardObjective", + at = @At( + value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Ljava/lang/String;FFI)I", ordinal = 1 + ), + cancellable = true + ) + public void axolotlclient$renderCustomScoreboardObjective( + ScoreboardObjective objective, int y, String player, int startX, int endX, PlayerListEntry playerEntry, CallbackInfo ci + ) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null) { + return; + } + + game.renderCustomScoreboardObjective(playerEntry.getProfile().getName(), objective, y, endX); + ci.cancel(); + + + } + + @ModifyVariable( + method = "render", + at = @At( + value = "STORE" + ), + ordinal = 7 + ) + public int axolotlclient$changeWidth(int value) { + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().blockLatencyIcon() && (BedwarsMod.getInstance().isWaiting() || BedwarsMod.getInstance().inGame())) { + value -= 9; + } + if (BedwarsMod.getInstance().isEnabled() && BedwarsMod.getInstance().isWaiting()) { + value += 20; + } + return value; + } + + @Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true) + public void axolotlclient$getPlayerName(PlayerListEntry playerEntry, CallbackInfoReturnable cir) { + if (!BedwarsMod.getInstance().isEnabled()) { + return; + } + BedwarsGame game = BedwarsMod.getInstance().getGame().orElse(null); + if (game == null || !game.isStarted()) { + return; + } + BedwarsPlayer player = game.getPlayer(playerEntry.getProfile().getName()).orElse(null); + if (player == null) { + return; + } + cir.setReturnValue(player.getTabListDisplay()); + } + + @ModifyVariable(method = "render", at = @At(value = "INVOKE_ASSIGN", target = "Lcom/google/common/collect/Ordering;sortedCopy(Ljava/lang/Iterable;)Ljava/util/List;", remap = false)) + public List axolotlclient$overrideSortedPlayers(List original) { + if (!BedwarsMod.getInstance().inGame()) { + return original; + } + List players = BedwarsMod.getInstance().getGame().get().getTabPlayerList(original); + if (players == null) { + return original; + } + return players; + } + + @Inject(method = "setHeader", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeHeader(Text header, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.header = BedwarsMod.getInstance().getGame().get().getTopBarText(); + ci.cancel(); + } + + @Inject(method = "setFooter", at = @At("HEAD"), cancellable = true) + public void axolotlclient$changeFooter(Text footer, CallbackInfo ci) { + if (!BedwarsMod.getInstance().inGame()) { + return; + } + this.footer = BedwarsMod.getInstance().getGame().get().getBottomBarText(); + ci.cancel(); + } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java b/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java new file mode 100644 index 000000000..bd1722f5a --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/mixin/VertexBufferMixin.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2021-2023 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.mixin; + +import java.nio.ByteBuffer; + +import net.minecraft.client.render.VertexBuffer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(VertexBuffer.class) +public class VertexBufferMixin { + @Shadow + private int id; + + @Inject(method = "data", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/VertexBuffer;bind()V"), cancellable = true) + private void axolotlclient$ignoreDeletedBuffers(ByteBuffer byteBuffer, CallbackInfo ci) { + if (id == -1) { + ci.cancel(); + } + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/auth/Auth.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/auth/Auth.java index de347f454..b65e106f8 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/auth/Auth.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/auth/Auth.java @@ -86,6 +86,8 @@ protected void login(MSAccount account) { Runnable runnable = () -> { try { ((MinecraftClientAccessor) client).setSession(new Session(account.getName(), account.getUuid(), account.getAuthToken(), Session.AccountType.MOJANG.name())); + client.getSessionProperties().clear(); + client.getSessionProperties(); save(); current = account; Notifications.getInstance().addStatus(I18n.translate("auth.notif.title"), I18n.translate("auth.notif.login.successful", current.getName())); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java index 4a67615ff..09fe60c92 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/HudManager.java @@ -37,6 +37,7 @@ import io.github.axolotlclient.modules.hud.gui.hud.simple.*; import io.github.axolotlclient.modules.hud.gui.hud.vanilla.*; import io.github.axolotlclient.modules.hud.util.Rectangle; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; @@ -98,6 +99,7 @@ public void init() { add(new ComboHud()); add(new PlayerHud()); add(new ChatHud()); + entries.put(BedwarsMod.getInstance().getUpgradesOverlay().getId(), BedwarsMod.getInstance().getUpgradesOverlay()); entries.values().forEach(HudEntry::init); refreshAllBounds(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java index ff726bd64..8809aca19 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/AbstractHudEntry.java @@ -257,6 +257,4 @@ public void setEnabled(boolean value) { enabled.set(value); } - public void init() { - } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java index e388664b4..df1eaa046 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/KeystrokeHud.java @@ -36,8 +36,9 @@ import io.github.axolotlclient.modules.hud.util.DrawPosition; import io.github.axolotlclient.modules.hud.util.DrawUtil; import io.github.axolotlclient.modules.hud.util.Rectangle; -import io.github.axolotlclient.util.Hooks; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.GameOptions; import net.minecraft.client.option.KeyBinding; @@ -89,8 +90,8 @@ public class KeystrokeHud extends TextHudEntry { public KeystrokeHud() { super(53, 61, true); - Hooks.KEYBIND_CHANGE.register(key -> setKeystrokes()); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.KEYBIND_CHANGE.register(key -> setKeystrokes()); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } public void setKeystrokes() { @@ -131,12 +132,12 @@ public void setKeystrokes() { onMouseMovementOption(mouseMovement.get()); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { // Implementation credit goes to TheKodeToad // This project has the author's approval to use this // https://github.com/Sol-Client/Client/blob/main/game/src/main/java/io/github/solclient/client/mod/impl/hud/keystrokes/KeystrokesMod.java - mouseX += (yaw - prevYaw) / 7F; - mouseY += (pitch - prevPitch) / 7F; + mouseX += (event.getYaw() - event.getPrevYaw()) / 7F; + mouseY += (event.getPitch() - event.getPrevPitch()) / 7F; // 0, 0 will be the center of the HUD element float halfWidth = getWidth() / 2f; mouseX = MathHelper.clamp(mouseX, -halfWidth + 4, halfWidth - 4); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java index 83f258d32..f03cda974 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/PlayerHud.java @@ -30,7 +30,8 @@ import io.github.axolotlclient.AxolotlClientConfig.options.DoubleOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.PlayerDirectionChangeEvent; import lombok.Getter; import net.minecraft.block.material.Material; import net.minecraft.client.render.DiffuseLighting; @@ -61,11 +62,11 @@ public class PlayerHud extends BoxHudEntry { public PlayerHud() { super(62, 94, true); - Hooks.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); + Events.PLAYER_DIRECTION_CHANGE.register(this::onPlayerDirectionChange); } - public void onPlayerDirectionChange(float prevPitch, float prevYaw, float pitch, float yaw) { - yawOffset += (yaw - prevYaw) / 2; + public void onPlayerDirectionChange(PlayerDirectionChangeEvent event) { + yawOffset += (event.getYaw() - event.getPrevYaw()) / 2; } @Override @@ -111,6 +112,9 @@ public boolean movable() { } public void renderPlayer(boolean placeholder, double x, double y, float delta) { + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + if (client.player == null) { return; } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/iconHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/iconHud.java index 25a5a41ce..163eb6441 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/iconHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/iconHud.java @@ -39,7 +39,9 @@ public iconHud() { @Override public Identifier getId() { return ID; - } @Override + } + + @Override public void renderComponent(float delta) { GlStateManager.color(1, 1, 1, 1); MinecraftClient.getInstance().getTextureManager().bindTexture(AxolotlClient.badgeIcon); @@ -63,7 +65,6 @@ public void renderPlaceholderComponent(float delta) { } - @Override public boolean movable() { return true; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java index 5c81e5932..8c9733416 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/CPSHud.java @@ -28,8 +28,9 @@ import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; -import io.github.axolotlclient.util.Hooks; +import io.github.axolotlclient.util.events.Events; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.option.KeyBinding; import net.minecraft.util.Identifier; /** @@ -48,16 +49,17 @@ public class CPSHud extends SimpleTextHudEntry { public CPSHud() { super(); - Hooks.MOUSE_INPUT.register(button -> { + Events.MOUSE_INPUT.register(event -> { if (!fromKeybindings.get()) { - if (button == 0) { + if (event.getButton() == 0) { ClickList.LEFT.click(); - } else if (button == 1) { + } else if (event.getButton() == 1) { ClickList.RIGHT.click(); } } }); - Hooks.KEYBIND_PRESS.register((key) -> { + Events.KEY_PRESS.register((event) -> { + KeyBinding key = event.getKey(); if (fromKeybindings.get()) { if (key.equals(client.options.attackKey)) { ClickList.LEFT.click(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java index 88d64e43c..02c7dd1b1 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/simple/ReachHud.java @@ -22,6 +22,10 @@ package io.github.axolotlclient.modules.hud.gui.hud.simple; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.options.IntegerOption; import io.github.axolotlclient.AxolotlClientConfig.options.Option; import io.github.axolotlclient.modules.hud.gui.entry.SimpleTextHudEntry; @@ -31,10 +35,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3d; -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.util.List; - // https://github.com/AxolotlClient/AxolotlClient-mod/blob/4ae2678bfe9e0908be1a7a34e61e689c8005ae0a/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/ReachDisplayHud.java // https://github.com/DarkKronicle/KronHUD/blob/703b87a7c938ba25da9105d731b70d3bc66efd1e/src/main/java/io/github/darkkronicle/kronhud/gui/hud/simple/ReachHud.java public class ReachHud extends SimpleTextHudEntry { diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java index 4afa2c98d..dae95aa0f 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelMods.java @@ -33,6 +33,7 @@ import io.github.axolotlclient.modules.hypixel.autoboop.AutoBoop; import io.github.axolotlclient.modules.hypixel.autogg.AutoGG; import io.github.axolotlclient.modules.hypixel.autotip.AutoTip; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMod; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHead; import io.github.axolotlclient.modules.hypixel.nickhider.NickHider; import io.github.axolotlclient.modules.hypixel.skyblock.Skyblock; @@ -61,6 +62,7 @@ public void init() { addSubModule(NickHider.getInstance()); addSubModule(AutoBoop.getInstance()); addSubModule(Skyblock.getInstance()); + addSubModule(BedwarsMod.getInstance()); subModules.forEach(AbstractHypixelMod::init); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java index 3fa55a4f4..cbc1f50ad 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autoboop/AutoBoop.java @@ -22,12 +22,14 @@ package io.github.axolotlclient.modules.hypixel.autoboop; +import io.github.axolotlclient.AxolotlClient; import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; -import net.minecraft.text.Text; public class AutoBoop implements AbstractHypixelMod { @@ -40,6 +42,7 @@ public class AutoBoop implements AbstractHypixelMod { @Override public void init() { cat.add(enabled); + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -47,13 +50,16 @@ public OptionCategory getCategory() { return cat; } - public void onMessage(Text message) { - if (enabled.get() && message.asUnformattedString().contains("Friend >") - && message.asUnformattedString().contains("joined.")) { - String player = message.asUnformattedString().substring(message.asFormattedString().indexOf(">"), - message.asUnformattedString().lastIndexOf(" ")); + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage().trim(); + if (enabled.get() && message.contains("Friend >") + && message.contains("joined.")) { + System.out.println(message); + String player = message.substring(message.indexOf("Friend >"), + message.lastIndexOf(" ")); + System.out.println(player); Util.sendChatMessage("/boop " + player); - System.out.println("Booped " + player); + AxolotlClient.LOGGER.info("Booped " + player); } } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java index 6c250b217..52402556b 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autogg/AutoGG.java @@ -32,9 +32,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; /** * Based on DragonEggBedrockBreaking's AutoGG Mod @@ -88,6 +89,8 @@ public void init() { category.add(onBWP); category.add(onPVPL); category.add(onMMC); + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); } @Override @@ -158,7 +161,8 @@ private List addToList(String... strings) { return Arrays.stream(strings).collect(Collectors.toList()); } - public void onMessage(Text message) { + public void onMessage(ReceiveChatMessageEvent event) { + String message = event.getOriginalMessage(); if (client.getCurrentServerEntry() != null) { serverMap.keySet().forEach(s -> { if (serverMap.get(s).get() && client.getCurrentServerEntry().address.contains(s)) { @@ -176,10 +180,10 @@ public void onMessage(Text message) { } } - private void processChat(Text messageReceived, List options, String messageToSend) { + private void processChat(String messageReceived, List options, String messageToSend) { if (System.currentTimeMillis() - this.lastTime > 3000 && options != null) { for (String s : options) { - if (messageReceived.asUnformattedString().contains(s)) { + if (messageReceived.contains(s)) { Util.sendChatMessage(messageToSend); this.lastTime = System.currentTimeMillis(); return; diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java index 5a3fbae7c..c706cdbe8 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/autotip/AutoTip.java @@ -28,9 +28,10 @@ import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; import io.github.axolotlclient.util.Util; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; import lombok.Getter; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.Text; public class AutoTip implements AbstractHypixelMod { @@ -52,6 +53,8 @@ public class AutoTip implements AbstractHypixelMod { public void init() { category.add(enabled, hideMessages); init = true; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onChatMessage); } @Override @@ -77,8 +80,9 @@ public boolean tickable() { return true; } - public boolean onChatMessage(Text text) { - return enabled.get() && hideMessages.get() && - (messagePattern.matcher(text.asUnformattedString()).matches() || tippedPattern.matcher(text.asUnformattedString()).matches()); + public void onChatMessage(ReceiveChatMessageEvent event) { + event.setCancelled(enabled.get() && hideMessages.get() && + (messagePattern.matcher(event.getOriginalMessage()).matches() || + tippedPattern.matcher(event.getOriginalMessage()).matches())); } } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java new file mode 100644 index 000000000..15bd70b26 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsGame.java @@ -0,0 +1,473 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +public class BedwarsGame { + private BedwarsTeam won = null; + private int wonTick = -1; + private int seconds = 0; + private Text topBarText = new LiteralText(""); + private Text bottomBarText = new LiteralText(""); + + private BedwarsPlayer me = null; + + private final Map players = new HashMap<>(); + private final Map playersById = new HashMap<>(); + private final MinecraftClient mc; + @Getter + private boolean started = false; + private final BedwarsMod mod; + @Getter + private final BedwarsTeamUpgrades upgrades = new BedwarsTeamUpgrades(); + private BedwarsPlayer lastKill; + private BedwarsPlayer lastKiller; + + + public BedwarsGame(BedwarsMod mod) { + mc = MinecraftClient.getInstance(); + this.mod = mod; + } + + public void onStart() { + mod.upgradesOverlay.onStart(upgrades); + players.clear(); + playersById.clear(); + Map> teamPlayers = new HashMap<>(); + for (PlayerListEntry player : mc.player.networkHandler.getPlayerList()) { + String name = mc.inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); + if (name.charAt(1) != ' ') { + continue; + } + BedwarsTeam team = BedwarsTeam.fromPrefix(name.charAt(0)).orElse(null); + if (team == null) { + continue; + } + teamPlayers.compute(team, (t, entries) -> { + if (entries == null) { + List players = new ArrayList<>(); + players.add(player); + return players; + } + entries.add(player); + return entries; + }); + } + for (Map.Entry> teamPlayerList : teamPlayers.entrySet()) { + teamPlayerList.getValue().sort(Comparator.comparing(p -> p.getProfile().getName())); + List value = teamPlayerList.getValue(); + for (int i = 0; i < value.size(); i++) { + PlayerListEntry e = value.get(i); + BedwarsPlayer p = new BedwarsPlayer(teamPlayerList.getKey(), e, i + 1); + if (mc.player.getGameProfile().getName().equals(e.getProfile().getName())) { + me = p; + } + players.put(e.getProfile().getName(), p); + playersById.put(e.getProfile().getId(), p); + } + } + this.started = true; + } + + public Text getTopBarText() { + return topBarText; + } + + public Text getBottomBarText() { + return bottomBarText; + } + + private String calculateTopBarText() { + return getFormattedTime()+"\n"+ + "K: "+me.getStats().getGameKills()+ + " D: "+me.getStats().getGameDeaths()+ + " B: "+me.getStats().getGameBedsBroken(); + } + + private String calculateBottomBarText() { + return Formatting.DARK_AQUA + "Last Kill: "+ Formatting.RESET + (lastKill == null ? "N/A" : lastKill.getColoredName()) + + Formatting.DARK_AQUA + " Last Killed By: " + Formatting.RESET + (lastKiller == null ? "N/A" : lastKiller.getColoredName()); + // left in here because it'll be useful later on + /*Comparator comparator = Comparator.comparingInt(o -> o.getStats().getGameKills()); + return "Top 3 Killers: \n" + players.values().stream().filter(Objects::nonNull) + .sorted(comparator.reversed()).limit(3) + .map(p -> p.getColoredName() + ": " + p.getStats().getGameKills()) + .collect(Collectors.joining("\n"));*/ + } + + public String getFormattedTime() { + int minute = seconds / 60; + int second = seconds % 60; + String time = minute + ":"; + if (second < 10) { + time += "0" + second; + } else { + time += second; + } + return time; + } + + public Optional getPlayer(UUID uuid) { + return Optional.ofNullable(playersById.getOrDefault(uuid, null)); + } + + public Optional getPlayer(String name) { + return Optional.ofNullable(players.getOrDefault(name, null)); + } + + private void debug(String message) { + mc.inGameHud.getChatHud().addMessage(new LiteralText("§b§lINFO:§8 " + message)); + } + + private void died(ReceiveChatMessageEvent event, BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + player.died(); + if (killer != null) { + killer.killed(finalDeath); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDeath(player, killer, type, finalDeath))); + } + if(me.equals(killer)){ + lastKill = player; + } else if (me.equals(player)){ + lastKiller = killer; + } + } + + private String formatDisconnect(BedwarsPlayer disconnected) { + String playerFormatted = getPlayerFormatted(disconnected); + return playerFormatted + " §7§o/disconnected/"; + } + + private String formatReconnect(BedwarsPlayer reconnected) { + String playerFormatted = getPlayerFormatted(reconnected); + return playerFormatted + " §7§o/reconnected/"; + } + + private String formatEliminated(BedwarsTeam team) { + StringBuilder message = new StringBuilder( + "§6§l§oTEAM ELIMINATED §8§l> " + team.getColorSection() + team.getName() + " Team §7/eliminated/ "); + for (BedwarsPlayer p : players.values().stream() + .filter(b -> b.getTeam() == team) + .sorted(Comparator.comparingInt(BedwarsPlayer::getNumber)) + .collect(Collectors.toList())) { + BedwarsPlayerStats stats = p.getStats(); + if (stats == null) { + continue; + } + message.append("\n") + .append("§b") + .append(stats.getStars()) + .append(" ") + .append(p.getColoredName()) + .append("§7 Beds: §f") + .append(stats.getBedsBroken()) + .append("§7 Finals: §f") + .append(stats.getFinalKills()) + .append("§7 FKDR: §f") + .append(String.format("%.2f", stats.getFKDR())) + .append("§7 BBLR: §f") + .append(String.format("%.2f", stats.getBBLR())); + } + return message.toString(); + } + + private String formatBed(BedwarsTeam team, BedwarsPlayer breaker) { + String playerFormatted = getPlayerFormatted(breaker); + return "§6§l§oBED BROKEN §8§l> " + team.getColorSection() + team.getName() + " Bed §7/broken/ " + playerFormatted + + (breaker.getStats() == null || breaker.getTeam() != me.getTeam() ? "" : " §6" + breaker.getStats().getBedsBroken()); + } + + private String formatDeath(BedwarsPlayer player, @Nullable BedwarsPlayer killer, BedwarsDeathType type, boolean finalDeath) { + String inner = type.getInner().get(); + if (finalDeath) { + inner = "§6§l/" + inner.toUpperCase(Locale.ROOT) + "/"; + } else { + inner = "§7/" + inner + "/"; + } + String playerFormatted = getPlayerFormatted(player); + if (killer == null) { + return playerFormatted + " " + inner; + } + String killerFormatted = getPlayerFormatted(killer); + if (finalDeath && killer.getStats() != null && killer.getTeam() == me.getTeam()) { + killerFormatted += " §6" + killer.getStats().getFinalKills(); + } + return playerFormatted + " " + inner + " " + killerFormatted; + } + + private String getPlayerFormatted(BedwarsPlayer player) { + return player.getColoredTeamNumber() + " " + player.getProfile().getProfile().getName(); + } + + public boolean isTeamEliminated(BedwarsTeam team) { + return players.values().stream().filter(b -> b.getTeam() == team).allMatch(BedwarsPlayer::isFinalKilled); + } + + public void onChatMessage(String rawMessage, ReceiveChatMessageEvent event) { + try { + if (mod.removeAnnoyingMessages.get() && BedwarsMessages.matched(BedwarsMessages.ANNOYING_MESSAGES, rawMessage).isPresent()) { + event.setCancelled(true); + return; + } + if (BedwarsDeathType.getDeath(rawMessage, (type, m) -> { + died(m, rawMessage, event, type); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.BED_DESTROY, rawMessage, m -> { + BedwarsPlayer player = BedwarsMessages.matched(BedwarsMessages.BED_BREAK, rawMessage).flatMap(m1 -> getPlayer(m1.group(1))).orElse(null); + BedwarsTeam team = BedwarsTeam.fromName(m.group(1)).orElse(me.getTeam()); + bedDestroyed(event, team, player); + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.DISCONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> disconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.RECONNECT, rawMessage, m -> getPlayer(m.group(1)).ifPresent(p -> reconnected(event, p)))) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.GAME_END, rawMessage, m -> { + BedwarsTeam win = players.values().stream().filter(p -> !p.isFinalKilled()).findFirst().map(BedwarsPlayer::getTeam).orElse(null); + this.won = win; + this.wonTick = mc.inGameHud.getTicks() + 10; + })) { + return; + } + if (BedwarsMessages.matched(BedwarsMessages.TEAM_ELIMINATED, rawMessage, m -> BedwarsTeam.fromName(m.group(1)).ifPresent(t -> teamEliminated(event, t)))) { + return; + } + upgrades.onMessage(rawMessage); + } catch (Exception e) { + debug("Error: " + e); + } + } + + private void died(Matcher m, String rawMessage, ReceiveChatMessageEvent event, BedwarsDeathType type) { + BedwarsPlayer killed = getPlayer(m.group(1)).orElse(null); + BedwarsPlayer killer = null; + if (type != BedwarsDeathType.SELF_UNKNOWN && type != BedwarsDeathType.SELF_VOID) { + killer = getPlayer(m.group(2)).orElse(null); + } + if (killed == null) { + debug("Player " + m.group(1) + " was not found"); + return; + } + died(event, killed, killer, type, BedwarsMessages.matched(BedwarsMessages.FINAL_KILL, rawMessage).isPresent()); + } + + private void gameEnd(BedwarsTeam win) { + if (me == null) { + BedwarsMod.getInstance().gameEnd(); + return; + } + + mc.inGameHud.getChatHud().addMessage( + new LiteralText("§8§m----------[§7Winstreaks§8]----------") + ); + for (BedwarsPlayer p : players.values()) { + if (p.getStats() != null && p.getStats().getWinstreak() > 0) { + boolean winner = p.getTeam().equals(win); + int before = p.getStats().getWinstreak(); + int after = winner ? before + 1 : 0; + mc.inGameHud.getChatHud().addMessage( + new LiteralText( + getPlayerFormatted(p) + "§8: §7" + before + " §8 -> §" + (winner ? "a" : "c") + after + )); + } + } + + BedwarsMod.getInstance().gameEnd(); + } + + private void teamEliminated(ReceiveChatMessageEvent event, BedwarsTeam team) { + // Make sure everyone is dead, just in case + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> { + b.setBed(false); + b.died(); + }); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatEliminated(team))); + } + } + + private void bedDestroyed(ReceiveChatMessageEvent event, BedwarsTeam team, @Nullable BedwarsPlayer breaker) { + players.values().stream().filter(b -> b.getTeam() == team).forEach(b -> b.setBed(false)); + if (breaker != null && breaker.getStats() != null) { + breaker.getStats().addBed(); + } + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatBed(team, breaker))); + } + } + + private void disconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.disconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatDisconnect(player))); + } + } + + + private void reconnected(ReceiveChatMessageEvent event, BedwarsPlayer player) { + player.reconnected(); + if (mod.overrideMessages.get()) { + event.setNewMessage(new LiteralText(formatReconnect(player))); + } + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + Collections.reverse(filteredScores); + if (filteredScores.size() < 3) { + return; + } + ScoreboardPlayerScore score = filteredScores.get(2); + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String timer = Team.decorateName(team, score.getPlayerName()); + if (!timer.contains(":")) { + return; + } + int seconds; + try { + seconds = Integer.parseInt(timer.split(":")[1].substring(0, 2)); + } catch (Exception e) { + e.printStackTrace(); + return; + } + int target = (60 - seconds) % 60; + if (this.seconds % 60 != target) { + // Update seconds + while (this.seconds % 60 != target) { + updateClock(); + } + topBarText = new LiteralText(calculateTopBarText()); + bottomBarText = new LiteralText(calculateBottomBarText()); + } + } + + private void updateClock() { + this.seconds++; + } + + public void tick() { + int currentTick = mc.inGameHud.getTicks(); + if (won != null && currentTick >= wonTick) { + gameEnd(won); + } + players.values().forEach(p -> p.tick(currentTick)); + } + + public void updateEntries(List entries) { + // Update latencies and other information for entries + entries.forEach(entry -> + getPlayer(entry.getProfile().getName()).ifPresent(player -> player.updateListEntry(entry)) + ); + } + + public List getTabPlayerList(List original) { + updateEntries(original); + return players.values().stream().filter(b -> !b.isFinalKilled()).sorted((b1, b2) -> { + if (b1.getTeam() == b2.getTeam()) { + return Integer.compare(b1.getNumber(), b2.getNumber()); + } + return Integer.compare(b1.getTeam().ordinal(), b2.getTeam().ordinal()); + }).map(BedwarsPlayer::getProfile).collect(Collectors.toList()); + } + + public BedwarsPlayer getSelf() { + return me; + } + + public String getLevelHead(AbstractClientPlayerEntity entity) { + BedwarsPlayer player = getPlayer(entity.getUuid()).orElse(null); + if (player == null) { + return null; + } + BedwarsPlayerStats stats = player.getStats(); + if (stats == null) { + return null; + } + BedwarsLevelHeadMode mode = BedwarsLevelHeadMode.get(mod.bedwarsLevelHeadMode.get()); + return mode.apply(stats); + } + + public void renderCustomScoreboardObjective(String playerName, ScoreboardObjective objective, int y, int endX){ + BedwarsPlayer bedwarsPlayer = getPlayer(playerName).orElse(null); + if (bedwarsPlayer == null) { + return; + } + + String render; + int color; + if (!bedwarsPlayer.isAlive()) { + if (bedwarsPlayer.isDisconnected()) { + return; + } + int tickTillLive = Math.max(0, bedwarsPlayer.getTickAlive() - mc.inGameHud.getTicks()); + float secondsTillLive = tickTillLive / 20f; + render = String.format("%.1f", secondsTillLive) + "s"; + color = new Color(200, 200, 200).getAsInt(); + } else { + int health = objective.getScoreboard().getPlayerScore(playerName, objective).getScore(); + color = Color.blend(new Color(255, 255, 255), new Color(215, 0, 64), (int) (1 - (health / 20f) * 100)).getAsInt(); + render = String.valueOf(health); + } + // Health + mc.textRenderer.drawWithShadow( + render, + (float) (endX - mc.textRenderer.getStringWidth(render)), + (float) y, + color + ); + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java new file mode 100644 index 000000000..cf6c1b17b --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMod.java @@ -0,0 +1,227 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.EnumOption; +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.modules.hypixel.AbstractHypixelMod; +import io.github.axolotlclient.util.events.Events; +import io.github.axolotlclient.util.events.impl.ReceiveChatMessageEvent; +import io.github.axolotlclient.util.events.impl.ScoreboardRenderEvent; +import io.github.axolotlclient.util.events.impl.WorldLoadEvent; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardPlayerScore; +import net.minecraft.scoreboard.Team; +import net.minecraft.text.LiteralText; +import net.minecraft.util.Formatting; + +/** + * @author DarkKronicle + */ + +public class BedwarsMod implements AbstractHypixelMod { + + private final static Pattern[] GAME_START = { + Pattern.compile("^\\s*?Protect your bed and destroy the enemy beds\\.\\s*?$") + }; + + @Getter + private static BedwarsMod instance = new BedwarsMod(); + + @Getter + private final OptionCategory category = new OptionCategory("bedwars"); + + private final BooleanOption enabled = new BooleanOption("enabled", false); + + public final BooleanOption hardcoreHearts = new BooleanOption(getTranslationKey("hardcoreHearts"), true); + + public final BooleanOption showHunger = new BooleanOption(getTranslationKey("showHunger"), false); + + public final BooleanOption displayArmor = new BooleanOption(getTranslationKey("displayArmor"), true); + + public final BooleanOption bedwarsLevelHead = new BooleanOption(getTranslationKey("bedwarsLevelHead"), true); + public final EnumOption bedwarsLevelHeadMode = new EnumOption(getTranslationKey("bedwarsLevelHeadMode"), + BedwarsLevelHeadMode.values(), + BedwarsLevelHeadMode.GAME_KILLS_GAME_DEATHS.toString()); + + protected BedwarsGame currentGame = null; + + @Getter + protected final TeamUpgradesOverlay upgradesOverlay; + + + protected final BooleanOption removeAnnoyingMessages = new BooleanOption(getTranslationKey("removeAnnoyingMessages"), true); + + + private final BooleanOption tabRenderLatencyIcon = new BooleanOption(getTranslationKey("tabRenderLatencyIcon"), false); + + private final BooleanOption showChatTime = new BooleanOption(getTranslationKey("showChatTime"), true); + + protected final BooleanOption overrideMessages = new BooleanOption(getTranslationKey("overrideMessages"), true); + private int targetTick = -1; + private boolean waiting = false; + + public BedwarsMod() { + upgradesOverlay = new TeamUpgradesOverlay(this); + } + + @Override + public void init() { + category.add(enabled, hardcoreHearts, showHunger, displayArmor, bedwarsLevelHead, bedwarsLevelHeadMode, + removeAnnoyingMessages, tabRenderLatencyIcon, showChatTime, overrideMessages); + category.add(upgradesOverlay.getAllOptions()); + category.add(BedwarsDeathType.getOptions()); + + instance = this; + + Events.RECEIVE_CHAT_MESSAGE_EVENT.register(this::onMessage); + Events.SCOREBOARD_RENDER_EVENT.register(this::onScoreboardRender); + Events.WORLD_LOAD_EVENT.register(this::onWorldLoad); + } + + public boolean isEnabled() { + return enabled.get(); + } + + public void onWorldLoad(WorldLoadEvent event) { + if (currentGame != null) { + gameEnd(); + } + } + + public boolean isWaiting() { + if (inGame()) { + waiting = false; + } + return waiting; + } + + public void onMessage(ReceiveChatMessageEvent event) { + // Remove formatting + String rawMessage = event.getFormattedMessage().asUnformattedString(); + if (currentGame != null) { + currentGame.onChatMessage(rawMessage, event); + String time = "§7" + currentGame.getFormattedTime() + Formatting.RESET + " "; + if (!event.isCancelled() && showChatTime.get()) { + // Add time to every message received in game + if (event.getNewMessage() != null) { + event.setNewMessage(new LiteralText(time).append(event.getNewMessage())); + } else { + event.setNewMessage(new LiteralText(time).append(event.getFormattedMessage())); + } + } + } else if (targetTick < 0 && BedwarsMessages.matched(GAME_START, rawMessage).isPresent()) { + // Give time for Hypixel to sync + targetTick = MinecraftClient.getInstance().inGameHud.getTicks() + 10; + } + } + + public Optional getGame() { + return currentGame == null ? Optional.empty() : Optional.of(currentGame); + } + + @Override + public boolean tickable() { + return true; + } + + @Override + public void tick() { + if (currentGame != null) { + waiting = false; + if (currentGame.isStarted()) { + // Trigger setting the header + MinecraftClient.getInstance().inGameHud.getPlayerListWidget().setHeader(null); + currentGame.tick(); + } else { + if (checkReady()) { + currentGame.onStart(); + } + } + } else { + if (targetTick > 0 && MinecraftClient.getInstance().inGameHud.getTicks() > targetTick) { + currentGame = new BedwarsGame(this); + targetTick = -1; + } + } + } + + private boolean checkReady() { + for (PlayerListEntry player : MinecraftClient.getInstance().player.networkHandler.getPlayerList()) { + String name = MinecraftClient.getInstance().inGameHud.getPlayerListWidget().getPlayerName(player).replaceAll("§.", ""); + if (name.charAt(1) == ' ') { + return true; + } + } + return false; + } + + public boolean inGame() { + return currentGame != null && currentGame.isStarted(); + } + + public void onScoreboardRender(ScoreboardRenderEvent event) { + if (inGame()) { + waiting = false; + currentGame.onScoreboardRender(event); + return; + } + if (!Formatting.strip(event.getObjective().getDisplayName()).contains("BED WARS")) { + return; + } + Scoreboard scoreboard = event.getObjective().getScoreboard(); + Collection scores = scoreboard.getAllPlayerScores(event.getObjective()); + List filteredScores = scores.stream() + .filter(p_apply_1_ -> p_apply_1_.getPlayerName() != null && !p_apply_1_.getPlayerName().startsWith("#")) + .collect(Collectors.toList()); + waiting = filteredScores.stream().anyMatch(score -> { + Team team = scoreboard.getPlayerTeam(score.getPlayerName()); + String format = Formatting.strip(Team.decorateName(team, score.getPlayerName())).replaceAll("[^A-z0-9 .:]", ""); + return format.contains("Waiting...") || format.contains("Starting in"); + }); + } + + public void gameEnd() { + upgradesOverlay.onEnd(); + currentGame = null; + } + + public boolean blockLatencyIcon() { + return !tabRenderLatencyIcon.get(); + } + + private String getTranslationKey(String name) { + return "bedwars." + name; + } + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java new file mode 100644 index 000000000..07bce84e3 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayer.java @@ -0,0 +1,160 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + + +import lombok.Data; +import lombok.Getter; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.PlayerListEntry; + +/** + * @author DarkKronicle + */ + +@Data +public class BedwarsPlayer { + + private final BedwarsTeam team; + @Getter + private PlayerListEntry profile; + private boolean alive = true; + private boolean disconnected = false; + private boolean bed = true; + private final int number; + private BedwarsPlayerStats stats = null; + private boolean triedStats = false; + private int tickAlive = -1; + + public BedwarsPlayer(BedwarsTeam team, PlayerListEntry profile, int number) { + this.team = team; + this.profile = profile; + this.number = number; + } + + public String getColoredTeamNumber(String format) { + return getTeam().getColorSection() + format + getTeam().getPrefix() + getNumber(); + } + + public String getColoredTeamNumber() { + return getTeam().getColorSection() + getTeam().getPrefix() + getNumber(); + } + + public String getName() { + return profile.getProfile().getName(); + } + + public String getColoredName() { + return team.getColorSection() + getName(); + } + + public String getTabListDisplay() { + if (alive) { + if (bed) { + return team.getColorSection() + "§l" + team.getPrefix() + number + " " + getColoredName(); + } + return team.getColorSection() + "§l" + team.getPrefix() + number + team.getColorSection() + "§o " + getName(); + } + if (disconnected) { + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §o§n" + getName(); + } + return team.getColorSection() + "§l§m" + team.getPrefix() + number + "§7 §m" + getName(); + } + + public void updateListEntry(PlayerListEntry entry) { + this.profile = entry; + } + + public boolean isFinalKilled() { + return tickAlive < 0 && !bed && !alive || (!bed && isDisconnected()); + } + + public void tick(int currentTick) { + if (stats == null && !triedStats) { + triedStats = true; + try { + stats = BedwarsPlayerStats.fromAPI(profile.getProfile().getId().toString().replace("-", "")); + } catch (Exception e) { + stats = BedwarsPlayerStats.generateFake(profile.getProfile().getName()); + } + } + if (alive || tickAlive < 0) { + return; + } + if (currentTick >= tickAlive) { + alive = true; + tickAlive = -1; + } + } + + public void died() { + if (!alive) { + if (!bed) { + tickAlive = -1; + } + return; + } + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + alive = false; + if (!bed) { + tickAlive = -1; + return; + } + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 5; // 5 second respawn + } + + public void disconnected() { + if (stats != null) { + if (!bed) { + stats.addFinalDeath(); + } else { + stats.addDeath(); + } + } + disconnected = true; + tickAlive = -1; + alive = false; + } + + public void reconnected() { + disconnected = false; + int currentTick = MinecraftClient.getInstance().inGameHud.getTicks(); + tickAlive = currentTick + 20 * 10; // 10 second respawn + } + + public void killed(boolean finalKill) { + if (stats != null) { + if (finalKill) { + stats.addFinalKill(); + } + stats.addKill(); + } + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java new file mode 100644 index 000000000..124eeddda --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/TeamUpgradesOverlay.java @@ -0,0 +1,138 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.List; + +import com.mojang.blaze3d.platform.GlStateManager; +import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption; +import io.github.axolotlclient.AxolotlClientConfig.options.Option; +import io.github.axolotlclient.modules.hud.gui.entry.BoxHudEntry; +import io.github.axolotlclient.modules.hud.util.DrawPosition; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.BedwarsTeamUpgrades; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TeamUpgrade; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TextureInfo; +import io.github.axolotlclient.modules.hypixel.bedwars.upgrades.TrapUpgrade; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.util.Identifier; + +/** + * @author DarkKronicle + */ + +public class TeamUpgradesOverlay extends BoxHudEntry { + + public final static Identifier ID = new Identifier("axolotlclient", "bedwars_teamupgrades"); + private final BooleanOption renderWhenRelevant = new BooleanOption(ID.getPath()+".renderWhenRelevant", true); + + private BedwarsTeamUpgrades upgrades = null; + private final BedwarsMod mod; + private final MinecraftClient mc; + private final static TextureInfo[] trapEdit = {TrapUpgrade.TrapType.MINER_FATIGUE.getTexInfo(), TrapUpgrade.TrapType.ITS_A_TRAP.getTexInfo()}; + + public TeamUpgradesOverlay(BedwarsMod mod) { + super(60, 40, true); + this.mod = mod; + this.mc = MinecraftClient.getInstance(); + } + + public void onStart(BedwarsTeamUpgrades newUpgrades) { + upgrades = newUpgrades; + } + + public void onEnd() { + upgrades = null; + } + + @Override + public void render(float delta) { + if (!renderWhenRelevant.get() || mod.inGame()) { + super.render(delta); + } + } + + public void drawOverlay(DrawPosition position, boolean editMode) { + if (upgrades == null && !editMode) { + return; + } + + int x = position.x() + 1; + int y = position.y() + 2; + GlStateManager.enableAlphaTest(); + GlStateManager.enableBlend(); + GlStateManager.color(1, 1, 1); + boolean normalUpgrades = false; + if (upgrades != null) { + for (TeamUpgrade u : upgrades.upgrades) { + if (!u.isPurchased()) { + continue; + } + if (u instanceof TrapUpgrade) { + continue; + } + TextureInfo texture; + texture = u.getTexture()[0]; + GlStateManager.color(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(x, y, texture.getU(), texture.getV(), texture.getRegionHeight(), texture.getRegionHeight(), 16, 16, texture.getWidth(), texture.getHeight()); + GlStateManager.color(1, 1, 1); + x += 17; + normalUpgrades = true; + } + } + x = position.x() + 1; + if (normalUpgrades) { + y += 17; + } + for (TextureInfo texture : (editMode ? trapEdit : upgrades.trap.getTexture())) { + GlStateManager.color(texture.getColor().getAlpha()/255F, texture.getColor().getRed()/255F, texture.getColor().getBlue()/255F, texture.getColor().getGreen()/255F); + mc.getTextureManager().bindTexture(new Identifier("minecraft", texture.getTexture())); + DrawableHelper.drawTexture(x, y, texture.getU(), texture.getV(), texture.getRegionHeight(), texture.getRegionHeight(), 16, 16, texture.getWidth(), texture.getHeight()); + GlStateManager.color(1, 1, 1); + x += 17; + } + } + + @Override + public void renderComponent(float delta) { + drawOverlay(getPos(), false); + } + + @Override + public void renderPlaceholderComponent(float delta) { + drawOverlay(getPos(), true); + } + + @Override + public Identifier getId() { + return ID; + } + + @Override + public List> getConfigurationOptions() { + List> options = super.getConfigurationOptions(); + options.add(renderWhenRelevant); + return options; + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java new file mode 100644 index 000000000..a18988493 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BedwarsTeamUpgrades.java @@ -0,0 +1,100 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + + +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; + +/** + * @author DarkKronicle + */ + +public class BedwarsTeamUpgrades { + + public final TrapUpgrade trap = new TrapUpgrade(); + + public final TeamUpgrade sharpness = new BinaryUpgrade( + "sharp", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Sharpened Swords"), + 8, 4, new TextureInfo("textures/items/stone_sword.png"), new TextureInfo("textures/items/diamond_sword.png") + ); + + public final TeamUpgrade dragonBuff = new BinaryUpgrade( + "dragonbuff", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Dragon Buff\\s*$"), + 5, 5, new TextureInfo("textures/items/end_crystal.png", Color.DARK_GRAY), + new TextureInfo("textures/items/end_crystal.png") + ); + + public final TeamUpgrade healPool = new BinaryUpgrade( + "healpool", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Heal Pool\\s*$"), + 3, 1, new TextureInfo("textures/gui/container/inventory.png", 7*18, 198, 256, 256, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/gui/container/inventory.png", 7*18, 198, 256, 256, 18, 18) + ); + + public final TeamUpgrade protection = new TieredUpgrade( + "prot", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Reinforced Armor .{1,3}\\s*$"), + new int[]{5, 10, 20, 30}, new int[]{2, 4, 8, 16}, new TextureInfo[]{ + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18, Color.DARK_GRAY.withAlpha(100)), + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18), + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/gui/container/inventory.png", 6*18, 198 + 18, 256, 256, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade maniacMiner = new TieredUpgrade( + "haste", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased Maniac Miner .{1,3}\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/gui/container/inventory.png", 2*18, 198, 256, 256, 18, 18, Color.DARK_GRAY), + new TextureInfo("textures/gui/container/inventory.png", 2*18, 198, 256, 256, 18, 18, Color.GRAY), + new TextureInfo("textures/gui/container/inventory.png", 2*18, 198, 256, 256, 18, 18), + } + ); + + public final TeamUpgrade forge = new TieredUpgrade( + "forge", Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (?:Iron|Golden|Emerald|Molten) Forge\\s*$"), + new int[]{2, 4}, new int[]{4, 6}, new TextureInfo[]{ + new TextureInfo("textures/blocks/furnace_front_off.png", 6*18, 198 + 18, 18, 18), + new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18), + new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18, Color.parse("#FFFF00")), + new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18, Color.parse("#00FF00")), + new TextureInfo("textures/blocks/furnace_front_on.png", 6*18, 198 + 18, 18, 18, Color.parse("#FF0000")), + } + ); + + public final TeamUpgrade[] upgrades = {trap, sharpness, dragonBuff, healPool, protection, maniacMiner, forge}; + + public BedwarsTeamUpgrades() { + + } + + public void onMessage(String rawMessage) { + for (TeamUpgrade upgrade : upgrades) { + if (upgrade.match(rawMessage)) { + return; + } + } + } + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java new file mode 100644 index 000000000..d4ef4209c --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TrapUpgrade.java @@ -0,0 +1,128 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +public class TrapUpgrade extends TeamUpgrade { + + private final static Pattern[] REGEX = { + Pattern.compile("^\\b[A-Za-z0-9_§]{3,16}\\b purchased (.+) Trap.?\\s*$"), + Pattern.compile("Trap was set (off)!"), + }; + + private final List traps = new ArrayList<>(3); + + public TrapUpgrade() { + super("trap", REGEX); + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + if (matcher.group(1).equals("off")) { + // Trap went off + traps.remove(0); + return; + } + traps.add(TrapType.getFuzzy(matcher.group(1))); + } + + public boolean canPurchase() { + return traps.size() < 3; + } + + @Override + public int getPrice(BedwarsMode mode) { + switch (traps.size()) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 4; + } + ; + return 0; + } + + @Override + public boolean isPurchased() { + return traps.size() > 0; + } + + @Override + public TextureInfo[] getTexture() { + if (traps.size() == 0) { + return new TextureInfo[]{new TextureInfo("textures/items/barrier.png", Color.DARK_GRAY)}; + } + TextureInfo[] trapTextures = new TextureInfo[traps.size()]; + for (int i = 0; i < traps.size(); i++) { + TrapType type = traps.get(i); + trapTextures[i] = type.getTexInfo(); + } + return trapTextures; + } + + @Override + public boolean isMultiUpgrade() { + return true; + } + + @AllArgsConstructor + public enum TrapType { + ITS_A_TRAP(new TextureInfo("textures/gui/container/inventory.png", 5*18, 198 + 18, 256, 256,18, 18)), + COUNTER_OFFENSIVE(new TextureInfo("textures/gui/container/inventory.png", 0, 198, 256, 256, 18, 18)), + ALARM(new TextureInfo("textures/items/ender_eye.png")), + MINER_FATIGUE(new TextureInfo("textures/gui/container/inventory.png", 3 * 18, 198, 256, 256, 18, 18)); + + @Getter + private final TextureInfo texInfo; + + public static TrapType getFuzzy(String s) { + s = s.toLowerCase(Locale.ROOT); + if (s.contains("miner")) { + return MINER_FATIGUE; + } + if (s.contains("alarm")) { + return ALARM; + } + if (s.contains("counter")) { + return COUNTER_OFFENSIVE; + } + return ITS_A_TRAP; + } + } +} 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 index b96c5436d..f2cc5339b 100644 --- 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 @@ -55,7 +55,8 @@ public class DiscordRPC extends AbstractModule { public static Activity currentActivity; public static Core discordRPC; private static DiscordRPC Instance; - private static String modVersion; public BooleanOption enabled = new BooleanOption("enabled", value -> { + private static String modVersion; + public BooleanOption enabled = new BooleanOption("enabled", value -> { if (value) { initRPC(); } else { @@ -220,6 +221,4 @@ public void initRPC() { } - - } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java index a95edd99e..825a3873d 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/MCPSkyboxInstance.java @@ -59,7 +59,7 @@ public MCPSkyboxInstance(JsonObject json) { try { String[] axis = json.get("axis").getAsString().split(" "); for (int i = 0; i < axis.length; i++) { - this.rotationStatic[i] = Float.parseFloat(axis[i]); + this.rotationAxis[i] = Float.parseFloat(axis[i]); } } catch (Exception ignored) { } diff --git a/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java b/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java index 64f9cf488..e23b8c965 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/modules/sky/SkyResourceManager.java @@ -79,14 +79,14 @@ public void reload(ResourceManager resourceManager) { } for (Map.Entry entry : ((SearchableResourceManager) resourceManager) - .findResources("minecraft", "optifine/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("minecraft", "optifine/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loaded sky: " + entry.getKey()); loadMCPSky("optifine", entry.getKey(), entry.getValue()); } for (Map.Entry entry : ((SearchableResourceManager) resourceManager) - .findResources("minecraft", "mcpatcher/sky", identifier -> identifier.getPath().endsWith(".properties")) + .findResources("minecraft", "mcpatcher/sky", identifier -> isMCPSky(identifier.getPath())) .entrySet()) { AxolotlClient.LOGGER.debug("Loaded sky: " + entry.getKey()); loadMCPSky("mcpatcher", entry.getKey(), entry.getValue()); @@ -94,6 +94,10 @@ public void reload(ResourceManager resourceManager) { initialized = true; } + private boolean isMCPSky(String path){ + return path.endsWith(".properties") && path.startsWith("sky"); + } + private void loadMCPSky(String loader, Identifier id, Resource resource) { BufferedReader reader = new BufferedReader( new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java b/1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java deleted file mode 100644 index 08c847ae1..000000000 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/Hooks.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2021-2023 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 net.legacyfabric.fabric.api.event.Event; -import net.legacyfabric.fabric.api.event.EventFactory; -import net.minecraft.client.option.KeyBinding; - -/** - * This implementation of Hud modules is based on KronHUD. - * Github Link. - * - * @license GPL-3.0 - */ - -public class Hooks { - - public static final Event MOUSE_INPUT = EventFactory.createArrayBacked(MouseInputCallback.class, - listeners -> (button -> { - for (MouseInputCallback listener : listeners) { - listener.onMouseButton(button); - } - })); - public static final Event KEYBIND_CHANGE = EventFactory.createArrayBacked(ChangeBind.class, - listeners -> ((key) -> { - for (ChangeBind listener : listeners) { - listener.setBoundKey(key); - } - })); - public static final Event KEYBIND_PRESS = EventFactory.createArrayBacked(OnPress.class, - listeners -> ((key) -> { - for (OnPress listener : listeners) { - listener.onPress(key); - } - })); - public static final Event PLAYER_DIRECTION_CHANGE = EventFactory - .createArrayBacked(PlayerDirectionCallback.class, listeners -> ((prevPitch, prevYaw, pitch, yaw) -> { - for (PlayerDirectionCallback listener : listeners) { - listener.onChange(prevPitch, prevYaw, pitch, yaw); - } - })); - - public interface MouseInputCallback { - - void onMouseButton(int button); - } - - public interface ChangeBind { - - void setBoundKey(int boundKey); - } - - public interface OnPress { - - void onPress(KeyBinding binding); - } - - public interface PlayerDirectionCallback { - - void onChange(float prevPitch, float prevYaw, float pitch, float yaw); - } -} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/Util.java b/1.8.9/src/main/java/io/github/axolotlclient/util/Util.java index bbe430f75..d3e8b1d11 100644 --- a/1.8.9/src/main/java/io/github/axolotlclient/util/Util.java +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/Util.java @@ -22,6 +22,11 @@ package io.github.axolotlclient.util; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Supplier; +import java.util.stream.Collectors; + import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import io.github.axolotlclient.mixin.MinecraftClientAccessor; @@ -37,11 +42,6 @@ import org.jetbrains.annotations.ApiStatus; import org.lwjgl.opengl.GL11; -import java.util.*; -import java.util.function.Consumer; -import java.util.function.Supplier; -import java.util.stream.Collectors; - public class Util { public static Color GlColor = new Color(); diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java new file mode 100644 index 000000000..36ed807fa --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/Events.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2021-2023 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.events; + +import java.util.Arrays; + +import io.github.axolotlclient.util.events.impl.*; +import net.legacyfabric.fabric.api.event.Event; +import net.legacyfabric.fabric.api.event.EventFactory; + +public class Events { + + public static final Event> MOUSE_INPUT = createEvent(); + public static final Event> KEYBIND_CHANGE = createEvent(); + public static final Event> KEY_PRESS = createEvent(); + public static final Event> PLAYER_DIRECTION_CHANGE = createEvent(); + public static final Event> SCOREBOARD_RENDER_EVENT = createEvent(); + public static final Event> RECEIVE_CHAT_MESSAGE_EVENT = createEvent(); + public static final Event> WORLD_LOAD_EVENT = createEvent(); + + private static Event> createEvent() { + return EventFactory + .createArrayBacked(EventCallback.class, listeners -> (event) -> + Arrays.stream(listeners).forEach(l -> l.invoke(event))); + } + + public interface EventCallback { + void invoke(T parameters); + } +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java new file mode 100644 index 000000000..e1b32934f --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyBindChangeEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class KeyBindChangeEvent { + + private final int boundKey; + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java new file mode 100644 index 000000000..c7518b5b8 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/KeyPressEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.option.KeyBinding; + +@Data +public class KeyPressEvent { + + private final KeyBinding key; +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java new file mode 100644 index 000000000..9c154f310 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/MouseInputEvent.java @@ -0,0 +1,31 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class MouseInputEvent { + + private final int button; +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java new file mode 100644 index 000000000..460f7b4b2 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/PlayerDirectionChangeEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; + +@Data +public class PlayerDirectionChangeEvent { + + private final float prevPitch, prevYaw, pitch, yaw; + +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java new file mode 100644 index 000000000..ba3746d79 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ReceiveChatMessageEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.text.Text; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ReceiveChatMessageEvent extends CancellableEvent { + + private final boolean actionBar; + private final String originalMessage; + private final Text formattedMessage; + + private Text newMessage = null; +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java new file mode 100644 index 000000000..8db148f79 --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/ScoreboardRenderEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import io.github.axolotlclient.util.events.types.CancellableEvent; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.minecraft.client.util.Window; +import net.minecraft.scoreboard.ScoreboardObjective; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ScoreboardRenderEvent extends CancellableEvent { + + private final Window window; + private final ScoreboardObjective objective; +} diff --git a/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java new file mode 100644 index 000000000..872d370dd --- /dev/null +++ b/1.8.9/src/main/java/io/github/axolotlclient/util/events/impl/WorldLoadEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.impl; + +import lombok.Data; +import net.minecraft.client.world.ClientWorld; + +@Data +public class WorldLoadEvent { + + private final ClientWorld world; +} diff --git a/1.8.9/src/main/resources/axolotlclient.mixins.json b/1.8.9/src/main/resources/axolotlclient.mixins.json index e79b40c69..91a7ee373 100644 --- a/1.8.9/src/main/resources/axolotlclient.mixins.json +++ b/1.8.9/src/main/resources/axolotlclient.mixins.json @@ -52,6 +52,7 @@ "TextRendererMixin", "TitleScreenMixin", "TntEntityRendererMixin", + "VertexBufferMixin", "WorldRendererAccessor", "WorldRendererMixin" ], diff --git a/CHANGELOG.md b/CHANGELOG.md index f5dadbeb2..763241bfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,3 +127,12 @@ - update to 1.20 - update Chinese translations (HowardZHY) - fix a reach hud bug on 1.8.9 + +### 3.0.4 + +- add DarkKronicle's Bedwars Overlay +- fix the controls screen crashing in 1.8.9 +- add option to remove the vignette +- fix the sky impl mistaking suns for skies +- fix a client lockup issue on 1.8.9 +- fix PlayerHud scaling on 1.8.9 diff --git a/README.md b/README.md index 2890a2fcd..a90993140 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A Complete (nearly) mod to have various features on various Minecraft versions -*Also available in other Languages: [Türkçe](doc/README-tr.md)* +*Also available in other Languages: [Türkçe](doc/README-tr.md), [Deutsch](doc/README-de.md)* ### Features @@ -16,42 +16,42 @@ A Complete (nearly) mod to have various features on various Minecraft versions - Screenshot Utils - Zoom - Various Hud Modules (port of [KronHUD](https://github.com/DarkKronicle/KronHUD), but with additions) - - including, but not limited to: - - Ping - - FPS - - CPS - - Armor - - Potions - - Keystrokes - - ToggleModifiers - - Server IP - - Icon - - Speed - - Scoreboard - - Crosshair - - Coordinates - - ActionBar - - BossBar - - Arrow - - Item Update - - Pack Display - - Real Time - - Reach - - Hotbar - - Memory - - PlayerCount - - Compass - - TPS (Ticks per second) - - Combo - - Player - - Chat + - including, but not limited to: + - Ping + - FPS + - CPS + - Armor + - Potions + - Keystrokes + - ToggleModifiers + - Server IP + - Icon + - Speed + - Scoreboard + - Crosshair + - Coordinates + - ActionBar + - BossBar + - Arrow + - Item Update + - Pack Display + - Real Time + - Reach + - Hotbar + - Memory + - PlayerCount + - Compass + - TPS (Ticks per second) + - Combo + - Player + - Chat - Hypixel Features - - AutoGG / GF / GLHF - - LevelHead - - Nick Hider - - Skyblock - - AutoTip - - AutoBoop + - AutoGG / GF / GLHF + - LevelHead + - Nick Hider + - Skyblock + - AutoTip + - AutoBoop - Custom Block Outlines - Time Changer - Fullbright @@ -75,9 +75,11 @@ A Complete (nearly) mod to have various features on various Minecraft versions - note your changes in CHANGELOG.md to be added to the next version's changelog. To build: + ``` ./gradlew build ``` + Use `-Paxolotlclient.modules.=true` to add a version to the build. Add `-Paxolotlclient.modules.all=true` to build everything. In case you use an IDE, you can also add the respective properties to `gradle.properties` files (or remove them). diff --git a/common/build.gradle b/common/build.gradle index 18b8a52e9..85831d8ae 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -32,6 +32,7 @@ repositories { } dependencies { + implementation 'org.jetbrains:annotations:24.0.0' // take the oldest version just to build against compileOnly("io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}") @@ -41,6 +42,7 @@ dependencies { compileOnly("org.apache.httpcomponents:httpclient:4.3.3") compileOnly("com.google.code.gson:gson:2.2.4") compileOnly("commons-io:commons-io:2.4") + compileOnly("org.apache.commons:commons-lang3:3.3.2") shadow(implementation("net.hypixel:hypixel-api-core:4.1") { exclude group: "com.google.code.gson", module: "gson" diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java index 0c47a91f2..7450e1469 100644 --- a/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/HypixelAbstractionLayer.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.Objects; +import java.util.Random; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -32,6 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; +import com.google.gson.JsonObject; import io.github.axolotlclient.modules.hypixel.levelhead.LevelHeadMode; import io.github.axolotlclient.util.ThreadExecuter; import net.hypixel.api.HypixelAPI; @@ -62,27 +64,51 @@ public static boolean hasValidAPIKey() { return validApiKey; } + public static JsonObject getPlayerProperty(String uuid, String stat) { + if (loadPlayerDataIfAbsent(uuid)) { + PlayerReply.Player player = getPlayer(uuid); + return player == null ? null : player.getProperty(stat).getAsJsonObject(); + } + return null; + } + public static int getPlayerLevel(String uuid, String mode) { if (api == null) { loadApiKey(); } if (loadPlayerDataIfAbsent(uuid)) { - try { + PlayerReply.Player player = getPlayer(uuid); + if (player != null) { if (Objects.equals(mode, LevelHeadMode.NETWORK.toString())) { - return (int) cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer().getNetworkLevel(); + return (int) player.getNetworkLevel(); } else if (Objects.equals(mode, LevelHeadMode.BEDWARS.toString())) { - return cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer() - .getIntProperty("achievements.bedwars_level", 0); + int level = player.getIntProperty("achievements.bedwars_level", -1); + if(level != -1){ + return level; + } } else if (Objects.equals(mode, LevelHeadMode.SKYWARS.toString())) { - int exp = cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer() - .getIntProperty("stats.SkyWars.skywars_experience", 0); - return Math.round(ExpCalculator.getLevelForExp(exp)); + int exp = player + .getIntProperty("stats.SkyWars.skywars_experience", -1); + if(exp != -1) { + return Math.round(ExpCalculator.getLevelForExp(exp)); + } } - } catch (TimeoutException | InterruptedException | ExecutionException e) { - return -1; } } - return 0; + return (int) (new Random().nextGaussian()+150*30); + } + + private static PlayerReply.Player getPlayer(String uuid) { + if (api == null) { + loadApiKey(); + } + if (loadPlayerDataIfAbsent(uuid)) { + try { + return cachedPlayerData.get(uuid).get(1, TimeUnit.MICROSECONDS).getPlayer(); + } catch (TimeoutException | InterruptedException | ExecutionException ignored) { + } + } + return null; } public static void loadApiKey() { @@ -105,7 +131,7 @@ public static void loadApiKey() { private static boolean loadPlayerDataIfAbsent(String uuid) { if (cachedPlayerData.get(uuid) == null) { // set at 115 to have a buffer in case of disparity between threads - if (hypixelApiCalls.get() <= 115) { + if (hypixelApiCalls.get() <= 55) { cachedPlayerData.put(uuid, api.getPlayerByUuid(uuid)); hypixelApiCalls.incrementAndGet(); ThreadExecuter.scheduleTask(hypixelApiCalls::decrementAndGet, 1, TimeUnit.MINUTES); diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java new file mode 100644 index 000000000..f17e347aa --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsDeathType.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory; +import io.github.axolotlclient.AxolotlClientConfig.options.StringOption; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +@AllArgsConstructor +public enum BedwarsDeathType { + COMBAT(createOption("combat", "rekt"), BedwarsMessages.COMBAT_KILL), + VOID(createOption("void","yeeted into void"), BedwarsMessages.VOID_KILL), + PROJECTILE(createOption("projectile","shot"), BedwarsMessages.PROJECTILE_KILL), + FALL(createOption("fall","fall"), BedwarsMessages.FALL_KILL), + GOLEM(createOption("golem","golem moment"), BedwarsMessages.GOLEM_KILL), + SELF_VOID(createOption("self_void","voided"), new Pattern[]{BedwarsMessages.SELF_VOID}), + SELF_UNKNOWN(createOption("self_unknown","died"), new Pattern[]{BedwarsMessages.SELF_UNKNOWN}) + ; + + @Getter + private final StringOption inner; + + @Getter + private final Pattern[] patterns; + + public static boolean getDeath(String rawMessage, BedwarsDeathMatch ifPresent) { + for (BedwarsDeathType type : values()) { + if (BedwarsMessages.matched(type.getPatterns(), rawMessage, m -> ifPresent.onMatch(type, m))) { + return true; + } + } + return false; + } + + public interface BedwarsDeathMatch { + + void onMatch(BedwarsDeathType type, Matcher matcher); + + } + + private static StringOption createOption(String type, String def){ + return new StringOption("bedwars.deathType."+type, def); + } + + @Getter + private static final OptionCategory options = new OptionCategory("bedwars.deathType"); + + static { + Arrays.stream(values()).map(BedwarsDeathType::getInner).forEach(options::add); + } +} diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java new file mode 100644 index 000000000..189ed702e --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsLevelHeadMode.java @@ -0,0 +1,68 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +public enum BedwarsLevelHeadMode { + FINAL_KILLS(stats -> "§7Final Kills (Total): §f" + stats.getFinalKills()), + FINAL_DEATHS(stats -> "§7Final Deaths (Total): §f" + stats.getFinalDeaths()), + BEDS_BROKEN(stats -> "§7Beds Broken (Total): §f" + stats.getBedsBroken()), + GAME_KILLS_GAME_DEATHS(stats -> "§7Kills (Game): §f" + stats.getGameKills() + " §7Deaths (Game): §f" + stats.getGameDeaths()), + KILLS(stats -> "§7Kills (Total): §f" + stats.getKills()), + DEATHS(stats -> "§7Deaths (Total): §f" + stats.getDeaths()), + GAME_FINAL_KILLS(stats -> "§7Final Kills (Game): §f" + stats.getGameFinalKills()), + GAME_BEDS_BROKEN(stats -> "§7Beds Broken (Game): §f" + stats.getGameBedsBroken()), + GAME_DEATHS(stats -> "§7Deaths (Game): §f" + stats.getGameDeaths()), + GAME_KILLS(stats -> "§7Kills (Game): §f" + stats.getGameKills()), + LOSSES(stats -> "§7Losses: §f" + stats.getLosses()), + WINS(stats -> "§7Wins: §f" + stats.getWins()), + WINSTREAK(stats -> "§7Winstreak: §f" + stats.getWinstreak()), + STARS(stats -> "§7Stars: §f" + stats.getStars()), + FKDR(stats -> "§7FKDR: §f" + stats.getFKDR()), + BBLR(stats -> "§7BBLR: §f" + stats.getFKDR()); + + private final Function titleSupplier; + + BedwarsLevelHeadMode(Function titleSupplier) { + this.titleSupplier = titleSupplier; + } + + public String apply(BedwarsPlayerStats stats) { + return titleSupplier.apply(stats); + } + + private static final Map modes; + + static { + modes = Arrays.stream(values()).collect(Collectors.toMap(Enum::name, value -> value)); + } + + public static BedwarsLevelHeadMode get(String mode) { + return modes.get(mode); + } +} diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java new file mode 100644 index 000000000..e086a0c94 --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMessages.java @@ -0,0 +1,312 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Consumer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author DarkKronicle + */ + +public class BedwarsMessages { + + public final static Pattern[] COMBAT_KILL = convert( + "{killed} was struck down by {player}.", + "{killed} was filled full of lead by {player}.", + "{killed} died in close combat to {player}.", + "{killed} was given the cold shoulder by {player}.", + "{killed} was glazed in BBQ sauce by {player}.", + "{killed} was bitten by {player}.", + "{killed} was wrapped into a gift by {player}.", + "{killed} was hunted down by {player}.", + "{killed} was oinked by {player}.", + "{killed} was chewed up by {player}.", + "{killed} was buzzed to death by {player}.", + "{killed} was trampled by {player}.", + "{killed} be sent to Davy Jones' locker by {player}.", + "{killed} got rekt by {player}.", + "{killed} was locked outside during a snow storm by {player}.", + "{killed} was painted pretty by {player}.", + "{killed} was wrapped up by {player}.", + "{killed} was stomped by {player}.", + "{killed} was {player}'s final #{number}", + "{killed} was spooked by {player}.", + "{killed} was tragically backstabbed by {player}.", + "{killed} was crushed by {player}.", + "{killed} was {player}'s final #{number}.", + "{killed} was whacked with a party balloon by {player}.", + "{killed} was crushed into moon dust by {player}.", + "{killed} was smothered in holiday cheer by {player}.", + "{killed} was ripped to shreds by {player}.", + "{killed} was bested by {player}.", + "{killed} was {player}'s final #{number}.", + "{killed} had a small brain moment while fighting {player}.", + "{killed} was too shy to meet {player}.", + "{killed} was yelled at by {player}.", + "{killed} was killed by {player}." + ); + + public final static Pattern[] VOID_KILL = convert( + "{killed} was turned to dust by {player}.", + "{killed} met their end by {player}.", + "{killed} fought to the edge with {player}.", + "{killed} was hit off by a love bomb from {player}.", + "{killed} slipped in BBQ sauce off the edge spilled by {player}.", + "{killed} howled into the void for {player}.", + "{killed} hit the hard-wood floor because of {player}.", + "{killed} stumbled on a trap set by {player}.", + "{killed} slipped into void for {player}.", + "{killed} was scared into the void by {player}.", + "{killed} was bzzz'd into the void by {player}.", + "{killed} was back kicked into the void by {player}.", + "{killed} be cannonballed to death by {player}.", + "{killed} took the L to {player}.", + "{killed} was pushed into a snowbank by {player}.", + "{killed} was deviled into the void by {player}.", + "{killed} was tied into a bow by {player}.", + "{killed} was thrown down a pit by {player}.", + "{killed} was spooked off the map by {player}.", + "{killed} was heartlessly let go by {player}.", + "{killed} was dominated by {player}.", + "{killed} was popped into the void by {player}.", + "{killed} was sent the wrong way by {player}.", + "{killed} was banished into the ether by {player}'s holiday spirit.", + "{killed} was charged by {player}.", + "{killed} was knocked into the void by {player}.", + "{killed} was not able to block clutch against {player}.", + "{killed} didn't distance themselves properly from {player}.", + "{killed} was thrown off the lawn by {player}.", + "{killed} was turned to dust by {player}." + ); + + public final static Pattern[] PROJECTILE_KILL = convert( + "{killed} was melted by {player}.", + "{killed} was killed with dynamite by {player}.", + "{killed} fell to the great marksmanship of {player}.", + "{killed} was struck with Cupid's arrow by {player}.", + "{killed} was thrown chili powder at by {player}.", + "{killed} caught the ball thrown by {player}.", + "{killed} was put on the naughty list by {player}.", + "{killed} got skewered by {player}.", + "{killed} got attacked by a carrot from {player}.", + "{killed} stepped in a mouse trap placed by {player}.", + "{killed} was startled by {player}.", + "{killed} was impaled from a distance by {player}.", + "{killed} be shot and killed by {player}.", + "{killed} got smacked by {player}.", + "{killed} was hit with a snowball from {player}.", + "{killed} slipped into a pan placed by {player}.", + "{killed} was glued up by {player}.", + "{killed} was shot by {player}.", + "{killed} was remotely spooked by {player}.", + "{killed}'s heart was pierced by {player}.", + "{killed} was assassinated by {player}.", + "{killed} was shot with a roman candle by {player}.", + "{killed} was hit by an asteroid from {player}.", + "{killed} was sniped by a missile of festivity by {player}.", + "{killed} was pounced on by {player}.", + "{killed} was shot by {player}.", + "{killed} got 360 no-scoped by {player}.", + "{killed} was coughed at by {player}.", + "{killed} was accidentally spit on by {player}." + ); + + public final static Pattern[] FALL_KILL = convert( + "{killed} was turned to ash by {player}.", + "{killed} lost a drinking contest with {player}.", + "{killed} stumbled off a ledge with help by {player}.", + "{killed} was out of the league of {player}.", + "{killed} was not spicy enough for {player}.", + "{killed} was distracted by a puppy placed by {player}.", + "{killed} was pushed down a slope by {player}.", + "{killed} was thrown into a volcano by {player}.", + "{killed} was distracted by a piglet from {player}.", + "{killed} was distracted by a rat dragging pizza from {player}.", + "{killed} was stung off the edge by {player}.", + "{killed} was headbutted off a cliff by {player}.", + "{killed} be killed with magic by {player}.", + "{killed} got roasted by {player}.", + "{killed} was shoved down an icy slope by {player}.", + "{killed} was flipped off the edge by {player}.", + "{killed} tripped over a present placed by {player}.", + "{killed} was thrown to the ground by {player}.", + "{killed} was totally spooked by {player}.", + "{killed} was delivered into nothingness by {player}.", + "{killed} was thrown off their high horse by {player}.", + "{killed} was launched like a firework by {player}.", + "{killed} was blasted to the moon by {player}.", + "{killed} was pushed by {player}'s holiday spirit.", + "{killed} was ripped and thrown by {player}.", + "{killed} was knocked off an edge by {player}.", + "{killed} was knocked off a cliff by {player}.", + "{killed} forgot how many blocks they had left while fighting {player}.", + "{killed} tripped while trying to run away from {player}.", + "{killed} slipped on the fake teeth of {player}.", + "{killed} was knocked into the void by {player}." + ); + + public final static Pattern[] GOLEM_KILL = convert( + "{killed} was fried by {player}'s Golem.", + "{killed} lost the draw to {player}'s Golem.", + "{killed} tangoed with {player}'s Golem.", + "{killed} was no match for {player}'s Golem.", + "{killed} was sliced up by {player}'s Golem.", + "{killed} played too rough with {player}'s Golem.", + "{killed} was turned to gingerbread by {player}'s Golem.", + "{killed} was mauled by {player}'s Golem.", + "{killed} was oinked by {player}'s Golem.", + "{killed} squeaked around with {player}'s Golem.", + "{killed} was bee'd by {player}'s Golem.", + "{killed} was trampled by {player}'s Golem.", + "{killed} be killed with metal by {player}'s Golem.", + "{killed} got bamboozled by {player}'s Golem.", + "{killed} got snowed in by {player}'s Golem.", + "{killed} was made sunny side up by {player}'s Golem.", + "{killed} was taped together by {player}'s Golem.", + "{killed} was outclassed by {player}'s Golem.", + "{killed} was spooked by {player}'s Golem.", + "{killed} was dismembered by {player}'s Golem.", + "{killed} was degraded by {player}'s Golem.", + "{killed} was lit up by {player}'s Golem.", + "{killed} was blown up by {player}'s Golem.", + "{killed} was sung holiday tunes to by {player}'s Golem.", + "{killed} was ripped to shreds by {player}'s Golem.", + "{killed} was bested by {player}'s Golem.", + "{killed} got absolutely destroyed by {player}'s Golem.", + "{killed} got too close to {player}'s Golem.", + "{killed} was chased away by {player}'s Golem." + ); + + public final static Pattern[] BED_BREAK = Arrays.stream(new String[]{ + "Bed was broken by {player}", + "Bed was incinerated by {player}", + "Bed was iced by {player}", + "Bed had to raise the white flag to {player}", + "Bed was dismantled by {player}", + "Bed was deep fried by {player}", + "Bed was ripped apart by {player}", + "Bed was traded in for milk and cookies by {player}", + "Bed was sacrificed by {player}", + "Bed was gulped by {player}", + "Bed was gulped by {player}", + "Bed was squeaked apart by {player}", + "Bed was stung by {player}", + "Bed was impaled by {player}", + "Bed be shot with cannon by {player}", + "Bed got memed by {player}", + "Bed was made into a snowman by {player}", + "Bed was scrambled by {player}", + "Bed was stuffed with tissue paper by {player}", + "Bed was scrambled by {player}", + "Bed was bed #{number} destroyed by {player}", + "Bed was spooked by {player}", + "Bed was dreadfully corrupted by {player}", + "Bed was bed #{number} destroyed by {player}", + "Bed exploded from a firework by {player}", + "Bed was blasted to dust by {player}", + "Bed was melted by {player}'s holiday spirit", + "Bed was ripped to shreds by {player}", + "Bed has left the game after seeing {player}", + "Bed was spooked by {player}", + "Bed was contaminated by {player}", + "Bed was sold in a garage sale by {player}", + "Bed was destroyed by {player}" + }).map(BedwarsMessages::formatPlaceholder).map(Pattern::compile).toArray(Pattern[]::new); + + public final static Pattern DISCONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) disconnected\\.$"); + public final static Pattern RECONNECT = Pattern.compile("(\\b[A-Za-z0-9_§]{3,16}\\b) reconnected\\.$"); + public final static Pattern FINAL_KILL = Pattern.compile("FINAL KILL!"); + public final static Pattern BED_DESTROY = Pattern.compile("^\\s*?BED DESTRUCTION > (\\w+) Bed"); + public final static Pattern TEAM_ELIMINATED = Pattern.compile("^\\s*?TEAM ELIMINATED > (\\w+) Team"); + + public final static Pattern GAME_END = Pattern.compile("^ +1st Killer - ?\\[?\\w*\\+*\\]? \\w+ - \\d+(?: Kills?)?$"); + + public final static Pattern SELF_VOID = Pattern.compile(formatPlaceholder("^{killed} fell into the void.(?: FINAL KILL!)?\\s*?")); + public final static Pattern SELF_UNKNOWN = Pattern.compile(formatPlaceholder("^{killed} died.(?: FINAL KILL!)?\\s*?")); + + public final static Pattern[] ANNOYING_MESSAGES = Arrays.stream(new String[]{ + "^You will respawn in \\d* seconds!$", + "^You will respawn in \\d* second!$", + "^You purchased Wool$", + "^Cross-teaming is not allowed", + "^\\+\\d+ Coins!", + "^\\+\\d+ coins!", + "^Coins just earned DOUBLE", + "^\\+\\d+ Bed Wars Experience", + "^You have respawned", + "^If you get disconnected use /rejoin to join back in the game\\.$", + }).map(Pattern::compile).toArray(Pattern[]::new); + + private static Pattern[] convert(String... input) { + return Arrays.stream(input).map(str -> Pattern.compile("^" + formatPlaceholder(str) + "(?: FINAL KILL!)?\\s*?")).toArray(Pattern[]::new); + } + + private static String formatPlaceholder(String input) { + return input + .replace("{killed}", "(\\b[A-Za-z0-9_§]{3,16}\\b)") + .replace("{player}", "(\\b[A-Za-z0-9_§]{3,16}\\b)") + .replace("{number}", "[0-9,]+"); + } + + public static boolean matched(Pattern pattern, String input, Consumer consumer) { + Optional matcher = matched(pattern, input); + if (!matcher.isPresent()) { + return false; + } + consumer.accept(matcher.get()); + return true; + } + + public static boolean matched(Pattern[] pattern, String input, Consumer consumer) { + Optional matcher = matched(pattern, input); + if (!matcher.isPresent()) { + return false; + } + consumer.accept(matcher.get()); + return true; + } + + public static Optional matched(Pattern[] pattern, String input) { + for (Pattern p : pattern) { + Optional m = matched(p, input); + if (m.isPresent()) { + return m; + } + } + return Optional.empty(); + } + + public static Optional matched(Pattern pattern, String input) { + Matcher matcher = pattern.matcher(input); + if (matcher.find()) { + return Optional.of(matcher); + } + return Optional.empty(); + } + + +} diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java new file mode 100644 index 000000000..511145cc4 --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsMode.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +public enum BedwarsMode { + SOLO(BedwarsTeam.values()), + DOUBLES(BedwarsTeam.values()), + THREES(BedwarsTeam.BLUE, BedwarsTeam.GREEN, BedwarsTeam.YELLOW, BedwarsTeam.RED), + FOURS(BedwarsTeam.BLUE, BedwarsTeam.GREEN, BedwarsTeam.YELLOW, BedwarsTeam.RED), + FOUR_V_FOUR(BedwarsTeam.BLUE, BedwarsTeam.RED); + + @Getter + private final BedwarsTeam[] teams; + + BedwarsMode(BedwarsTeam... teams) { + this.teams = teams; + } + +} diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java new file mode 100644 index 000000000..5a4a8a2aa --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/BedwarsPlayerStats.java @@ -0,0 +1,180 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars; + +import java.nio.charset.StandardCharsets; +import java.util.Random; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.axolotlclient.modules.hypixel.HypixelAbstractionLayer; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.jetbrains.annotations.Nullable; + +/** + * @author DarkKronicle + */ + +@AllArgsConstructor +public class BedwarsPlayerStats { + + @Getter + private int finalKills; + @Getter + private int finalDeaths; + @Getter + private int bedsBroken; + @Getter + private int deaths; + @Getter + private int kills; + @Getter + private int gameFinalKills; + @Getter + private int gameFinalDeaths; + @Getter + private int gameBedsBroken; + @Getter + private int gameDeaths; + @Getter + private int gameKills; + @Getter + private final int losses; + @Getter + private final int wins; + @Getter + private final int winstreak; + @Getter + private final int stars; + + + public static BedwarsPlayerStats generateFake(String name) { + long seed = 0; + for(int i = 0; i & 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.hypixel.bedwars; + +import java.util.Locale; +import java.util.Optional; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +@AllArgsConstructor +public enum BedwarsTeam { + RED('c', 'R'), + BLUE('9', 'B'), + GREEN('a', 'G'), + YELLOW('e', 'Y'), + AQUA('b', 'A'), + WHITE('f', 'W'), + PINK('d', 'P'), + GRAY('8', 'S'), + ; + + @Getter + private final char code; + + @Getter + private final char prefix; + + public String getColorSection() { + return "§" + code; + } + + public static Optional fromPrefix(char prefix) { + for (BedwarsTeam t : values()) { + if (t.getPrefix() == prefix) { + return Optional.of(t); + } + } + return Optional.empty(); + } + + public static Optional fromName(String name) { + for (BedwarsTeam t : values()) { + if (name.equalsIgnoreCase(t.name())) { + return Optional.of(t); + } + } + return Optional.empty(); + } + + public String getName() { + return name().substring(0, 1).toUpperCase(Locale.ROOT) + name().substring(1).toLowerCase(Locale.ROOT); + } + +} diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java new file mode 100644 index 000000000..dd4b9aec2 --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/BinaryUpgrade.java @@ -0,0 +1,74 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; + +/** + * @author DarkKronicle + */ + +public class BinaryUpgrade extends TeamUpgrade { + + private boolean purchased = false; + + private final int foursPrice; + private final int doublesPrice; + + private final TextureInfo inactiveTexture, activeTexture; + + public BinaryUpgrade(String name, Pattern regex, int foursPrice, int doublesPrice, TextureInfo inactiveTexture, TextureInfo activeTexture) { + super(name, regex); + this.foursPrice = foursPrice; + this.doublesPrice = doublesPrice; + this.inactiveTexture = inactiveTexture; + this.activeTexture = activeTexture; + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + purchased = true; + } + + @Override + public TextureInfo[] getTexture() { + return new TextureInfo[]{(purchased ? activeTexture : inactiveTexture)}; + } + + @Override + public boolean isPurchased() { + return purchased; + } + + @Override + public int getPrice(BedwarsMode mode) { + if (mode.getTeams().length == 8) { + return doublesPrice; + } + return foursPrice; + } + +} diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java new file mode 100644 index 000000000..a6041274d --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TeamUpgrade.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMessages; +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + + +public abstract class TeamUpgrade { + @Getter + protected final String name; + protected final Pattern[] regex; + + public TeamUpgrade(String name, Pattern pattern) { + this(name, new Pattern[]{pattern}); + } + + public TeamUpgrade(String name, Pattern[] pattern) { + this.name = name; + this.regex = pattern; + } + + public boolean match(String unformatedMessage) { + return BedwarsMessages.matched(regex, unformatedMessage, matcher -> onMatch(this, matcher)); + } + + public abstract TextureInfo[] getTexture(); + + public boolean isMultiUpgrade() { + // Basically only trap + return false; + } + + protected abstract void onMatch(TeamUpgrade upgrade, Matcher matcher); + + public abstract int getPrice(BedwarsMode mode); + + + public abstract boolean isPurchased(); +} + diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TextureInfo.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TextureInfo.java new file mode 100644 index 000000000..2474349d5 --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TextureInfo.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import io.github.axolotlclient.AxolotlClientConfig.Color; +import lombok.Getter; + +@Getter +public class TextureInfo { + private final String texture; + private int u = 0, v = 0, width = 16, height = 16, regionWidth = width, regionHeight = height; + private Color color = Color.WHITE.withAlpha(255); + + public TextureInfo(String texture){ + this.texture = texture; + } + + public TextureInfo(String texture, int u, int v){ + this(texture); + this.u = u; + this.v = v; + } + + public TextureInfo(String texture, int u, int v, int width, int height){ + this(texture, u, v); + this.width = width; + this.height = height; + this.regionWidth = width; + this.regionHeight = height; + } + + public TextureInfo(String texture, int u, int v, int width, int height, int regionWidth, int regionHeight){ + this(texture, u, v, width, height); + this.regionWidth = regionWidth; + this.regionHeight = regionHeight; + } + + public TextureInfo(String texture, Color color){ + this(texture); + this.color = color; + } + + public TextureInfo(String texture, int u, int v, Color color){ + this(texture, u, v); + this.color = color; + } + + public TextureInfo(String texture, int u, int v, int width, int height, Color color){ + this(texture, u, v, width, height); + this.color = color; + } + + public TextureInfo(String texture, int u, int v, int width, int height, int regionWidth, int regionHeight, Color color){ + this(texture, u, v, width, height, regionWidth, regionHeight); + this.color = color; + } +} diff --git a/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java new file mode 100644 index 000000000..108c40277 --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/modules/hypixel/bedwars/upgrades/TieredUpgrade.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2021-2023 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.hypixel.bedwars.upgrades; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.github.axolotlclient.modules.hypixel.bedwars.BedwarsMode; +import lombok.Getter; + +/** + * @author DarkKronicle + */ + +public class TieredUpgrade extends TeamUpgrade { + + private final int[] doublesPrice; + private final int[] foursPrice; + @Getter + private int level = 0; + + private final TextureInfo[] textures; + + public TieredUpgrade(String name, Pattern regex, int[] foursPrice, int[] doublesPrice, TextureInfo[] textures) { + super(name, regex); + this.foursPrice = foursPrice; + this.doublesPrice = doublesPrice; + this.textures = textures; + } + + @Override + public TextureInfo[] getTexture() { + return new TextureInfo[]{textures[level]}; + } + + @Override + public boolean isPurchased() { + return level > 0; + } + + @Override + protected void onMatch(TeamUpgrade upgrade, Matcher matcher) { + level += 1; + } + + public boolean isMaxedOut(BedwarsMode mode) { + if (mode.getTeams().length == 8) { + return level >= doublesPrice.length; + } + return level >= foursPrice.length; + } + + @Override + public int getPrice(BedwarsMode mode) { + if (mode.getTeams().length == 8) { + return doublesPrice[level]; + } + return foursPrice[level]; + } +} diff --git a/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java b/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java new file mode 100644 index 000000000..d0efce3e4 --- /dev/null +++ b/common/src/main/java/io/github/axolotlclient/util/events/types/CancellableEvent.java @@ -0,0 +1,32 @@ +/* + * Copyright © 2021-2023 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.events.types; + +import lombok.Data; + +@Data +public abstract class CancellableEvent { + + private boolean cancelled; + +} diff --git a/common/src/main/resources/assets/axolotlclient/lang/en_us.json b/common/src/main/resources/assets/axolotlclient/lang/en_us.json index 03acc1e9b..fc189d692 100644 --- a/common/src/main/resources/assets/axolotlclient/lang/en_us.json +++ b/common/src/main/resources/assets/axolotlclient/lang/en_us.json @@ -49,7 +49,7 @@ "allocated": "Allocated", "alwaysCrit": "Always Show", "alwaysCrit.tooltip": "Whether to always emit these particles when hitting.", - "alwaysShowHatLayer": "Always show Hat Layer", + "alwaysShowHeadLayer": "Always show Hat Layer", "anchorpoint": "Anchorpoint", "applyBlend": "Apply Blending", "armorhud": "Armor HUD", @@ -374,5 +374,43 @@ "zoomScrollStep": "Scroll Step", "zoomScrolling": "Zoom Scrolling", "zoomScrolling.tooltip": "Whether to allow scrolling to modify the zoom factor.", - "zoomSpeed": "Animation Speed" + "zoomSpeed": "Animation Speed", + "bedwars": "Bedwars", + "bedwars.hardcoreHearts": "Hardcore Hearts", + "bedwars.showHunger": "Show Hunger Bar", + "bedwars.displayArmor": "Display Armor", + "bedwars.bedwarsLevelHead": "Bedwars Level Head", + "bedwars.removeAnnoyingMessages": "Remove Annoying Messages", + "bedwars.tabRenderLatencyIcon": "Render Tablist Latency Icon", + "bedwars.showChatTime": "Show Chat Time", + "bedwars.overrideMessages": "Override Messages", + "bedwars_teamupgrades": "Team Upgrades HUD", + "bedwars.bedwarsLevelHeadMode": "LevelHead Mode", + "FINAL_KILLS": "Final Kills (Total)", + "FINAL_DEATHS": "Final Deaths (Total)", + "BEDS_BROKEN": "Beds Broken (Total)", + "GAME_KILLS_GAME_DEATHS": "Kills (Game)/Deaths (Game)", + "KILLS": "Kills (Total)", + "DEATHS": "Deaths (Total)", + "GAME_FINAL_KILLS": "Final Kills (Game)", + "GAME_BEDS_BROKEN": "Beds Broken (Game)", + "GAME_DEATHS": "Deaths (Game)", + "GAME_KILLS": "Kills (Game)", + "LOSSES": "Losses", + "WINS": "Wins", + "WINSTREAK": "Winstreak", + "STARS": "Stars", + "FKDR": "Final Kill/Lose Ratio", + "BBLR": "Bed Break/Lose Ratio", + "bedwars.deathType": "Death Messages", + "bedwars.deathType.combat": "Combat", + "bedwars.deathType.void": "Void", + "bedwars.deathType.projectile": "Projectiles", + "bedwars.deathType.fall": "Fall", + "bedwars.deathType.golem": "Golems", + "bedwars.deathType.self_void": "Void (Self)", + "bedwars.deathType.self_unknown": "Unknown (Self)", + "bedwars_teamupgrades.renderWhenRelevant": "Only Render When Relevant", + "removeVignette": "Remove Vignette", + "bedwars.tabRenderLatencyIcon.tooltip": "This lets you remove the latency icon
since it's always 1 for others while in a game.
This is probably some kind of limitation of hypixel." } diff --git a/doc/README-de.md b/doc/README-de.md index a5f5031ab..c3783beea 100644 --- a/doc/README-de.md +++ b/doc/README-de.md @@ -16,42 +16,42 @@ Ein (fast) vollständiger mod mit verschiedene Funktionen auf verschiedenen Mine - Screenshot Werkzeuge - Zoom - Verschiede Hud Module (teile von [KronHUD](https://github.com/DarkKronicle/KronHUD), aber mit zusätzlichen Funktionen) - - zusätzlich, aber nich aussschließlich: - - Ping - - FPS - - CPS - - Rüstung - - Tränke - - Tastenanschläge - - ToggleModifiers - - Server IP - - Icon - - Geschwindigkeit - - Scoreboard - - Fadenkreuz - - Koordinaten - - Aktions Anzeige - - Boss Anzeige - - Pfeile - - Item Update - - Pack Anzeige - - Echtzeit - - Reichweite - - Hotbar - - Speicher - - Spielerzahl - - Kompass - - TPS (Ticks pro Sekunde) - - Combo - - Spieler - - Chat + - zusätzlich, aber nicht aussschließlich: + - Ping + - FPS + - CPS + - Rüstung + - Tränke + - Tastenanschläge + - ToggleModifiers + - Server IP + - Icon + - Geschwindigkeit + - Scoreboard + - Fadenkreuz + - Koordinaten + - Aktions Anzeige + - Boss Anzeige + - Pfeile + - Item Update + - Pack Anzeige + - Echtzeit + - Reichweite + - Hotbar + - Speicher + - Spielerzahl + - Kompass + - TPS (Ticks pro Sekunde) + - Combo + - Spieler + - Chat - Hypixel Funktionen - - AutoGG / GF / GLHF - - LevelHead - - Spitznamen Verstecker - - Skyblock - - Autotippen - - AutoBoop + - AutoGG / GF / GLHF + - LevelHead + - Spitznamen Verstecker + - Skyblock + - Autotippen + - AutoBoop - Eigene Blockränder - Zeitwechsler - Volle Helligkeit @@ -78,7 +78,7 @@ Ein (fast) vollständiger mod mit verschiedene Funktionen auf verschiedenen Mine - Dieser Mod ist lizensiert unter der LGPL-3.0 Lizenz. - Die deutsche Übersetzung des Lizenztextes unten ist nicht rechtlich bindend. - Die rechtlich bindende Version ist die [vollständige Englische Version](../LICENSE) + Die rechtlich bindende Version ist die [vollständige Englische Version](../LICENSE) ``` AxolotlClient-mod diff --git a/doc/README-tr.md b/doc/README-tr.md index 6b05ad0eb..1d5f20c65 100644 --- a/doc/README-tr.md +++ b/doc/README-tr.md @@ -9,19 +9,19 @@ Legacy Fabric 1.8.9'da çeşitli özelliklere sahip olmak için tamamlanmış (n - Bir Özel Gökyüzü uygulanımı - Zoom tuşu - çeşitli Arayüz modülleri ([KronHUD](https://github.com/DarkKronicle/KronHUD)'un bir alınımı) - - bunları içerir, ama bunlarla limitli değil: - - Sohbet - - Skor Tahtası - - CPS - - FPS - - Gecikme - - Can Barı Arayüzü - - Koordinatlar - - ve başka! + - bunları içerir, ama bunlarla limitli değil: + - Sohbet + - Skor Tahtası + - CPS + - FPS + - Gecikme + - Can Barı Arayüzü + - Koordinatlar + - ve başka! - Hypixel Modları - - OtomatikGG / GF / GLHF - - Seviye Etiketi - - Otomatik Bağış + - OtomatikGG / GF / GLHF + - Seviye Etiketi + - Otomatik Bağış - Özel Blok Anahatları - Discord RPC - Mod'u kullanan oyuncular için rozetler diff --git a/formatting.xml b/formatting.xml index 82de37f90..7eaa84fe1 100644 --- a/formatting.xml +++ b/formatting.xml @@ -1,225 +1,293 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle.properties b/gradle.properties index f53d711fc..0ddfc236d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,8 @@ fabric.loom.multiProjectOptimisation=true axolotlclient.modules.all=true # Mod Properties -version=3.0.3 +version=3.0.4-beta.1 + maven_group=io.github.axolotlclient archives_base_name=AxolotlClient minecraft_1192=1.19.2 @@ -33,5 +34,5 @@ qsl_120=6.0.3 fabric_cts8=0.42.0+1.16 fabric_1165=0.42.0+1.16 lfapi=1.9.0 -config=2.1.12 +config=2.1.13 asmVersion=6.0_BETA diff --git a/settings.gradle b/settings.gradle index 9828c6d24..b0546d0c6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,14 +14,15 @@ pluginManagement { boolean checkProp(String property) { - String value = getProperties().get("axolotlclient.modules."+property) + String value = getProperties().get("axolotlclient.modules." + property) return !(value == null || value.isEmpty() || value == "false" || value == "f") } void optional(String project) { - if (checkProp(project) || checkProp("all")) - System.out.println("Adding "+project) + if (checkProp(project) || checkProp("all")) { + System.out.println("Adding " + project) include project + } } include 'common'