From bf62f30e54ac90c0d9aa377fb7eaa5453a512d91 Mon Sep 17 00:00:00 2001 From: JohnTWD <92451399+JohnTWD@users.noreply.github.com> Date: Sat, 3 Feb 2024 10:07:23 +0800 Subject: [PATCH] Revert "1.20.2 update (#4119)" This reverts commit 5d04f80073908c09fe51e519c60582c0d7859dc8. --- .github/ISSUE_TEMPLATE/bug.yml | 16 +- .github/ISSUE_TEMPLATE/crash.yml | 56 ---- build.gradle | 60 ++-- gradle.properties | 30 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../meteorclient/commands/Commands.java | 6 +- .../arguments/FakePlayerArgumentType.java | 2 +- .../arguments/PlayerArgumentType.java | 4 +- .../commands/commands/DisconnectCommand.java | 39 --- .../commands/commands/DropCommand.java | 1 - .../commands/commands/FakePlayerCommand.java | 4 +- .../commands/commands/InputCommand.java | 42 +-- .../commands/commands/LocateCommand.java | 23 +- .../commands/commands/ServerCommand.java | 4 +- .../commands/commands/SwarmCommand.java | 18 +- .../commands/commands/WaypointCommand.java | 41 +-- .../events/entity/DamageEvent.java | 4 +- .../meteorclient/gui/GuiTheme.java | 8 +- .../meteorclient/gui/GuiThemes.java | 8 +- .../meteorclient/gui/WidgetScreen.java | 14 +- .../gui/screens/ModulesScreen.java | 13 +- .../accounts/AddCrackedAccountScreen.java | 2 +- ...StatusEffectAmplifierMapSettingScreen.java | 14 +- .../StatusEffectListSettingScreen.java | 5 +- .../meteorclient/gui/tabs/Tabs.java | 9 +- .../tabs/builtin/BaritoneTab.java} | 145 +++++---- .../gui/tabs/builtin/PathManagerTab.java | 57 ---- .../gui/widgets/WItemWithLabel.java | 8 +- .../gui/widgets/input/WTextBox.java | 21 +- .../AbstractClientPlayerEntityMixin.java | 9 + .../mixin/AttributeContainerMixin.java | 38 --- .../mixin/BookEditScreenMixin.java | 7 +- .../meteorclient/mixin/BookScreenMixin.java | 15 +- .../mixin/CapeFeatureRendererMixin.java | 25 -- .../meteorclient/mixin/ChatHudMixin.java | 26 +- .../meteorclient/mixin/ChatScreenMixin.java | 4 +- .../mixin/ChunkBorderDebugRendererMixin.java | 39 --- .../mixin/ClientConnectionMixin.java | 10 +- .../mixin/ClientPlayNetworkHandlerMixin.java | 25 +- .../mixin/ClientPlayerEntityMixin.java | 2 +- .../meteorclient/mixin/ClientWorldMixin.java | 4 +- .../mixin/ConnectScreenMixin.java | 2 +- .../mixin/CustomPayloadC2SPacketAccessor.java | 26 ++ .../mixin/CustomPayloadS2CPacketMixin.java | 6 +- .../mixin/DefaultSkinHelperMixin.java | 2 +- .../mixin/DisconnectedScreenMixin.java | 23 +- .../mixin/ElytraFeatureRendererMixin.java | 35 --- .../mixin/EntityAttributeInstanceMixin.java | 39 --- .../meteorclient/mixin/EntityMixin.java | 4 - .../mixin/EntityRendererMixin.java | 8 +- .../meteorclient/mixin/FileCacheAccessor.java | 18 -- .../meteorclient/mixin/GameRendererMixin.java | 4 +- .../mixin/LivingEntityAccessor.java | 11 - .../meteorclient/mixin/LivingEntityMixin.java | 2 +- .../mixin/LivingEntityRendererMixin.java | 5 +- .../mixin/MinecraftClientAccessor.java | 12 +- .../mixin/MinecraftClientMixin.java | 2 +- .../mixin/PacketByteBufMixin.java | 10 +- .../mixin/PlayerEntityRendererMixin.java | 2 +- .../mixin/PlayerListEntryMixin.java | 8 +- .../mixin/PlayerSkinProviderAccessor.java | 6 +- .../mixin/RaycastContextMixin.java | 4 +- .../meteorclient/mixin/RegistriesMixin.java | 21 -- .../meteorclient/mixin/ScreenMixin.java | 18 +- .../mixin/ShulkerEntityAccessor.java | 25 -- .../mixin/SimpleRegistryMixin.java | 22 ++ .../mixin/WorldRendererMixin.java | 8 +- ...drasilMinecraftSessionServiceAccessor.java | 6 +- .../mixin/indigo/AoCalculatorMixin.java | 27 -- .../ChunkAwareBlockCollisionSweeperMixin.java | 2 +- .../sodium/SodiumBiomeColorCacheMixin.java | 6 +- .../sodium/SodiumFluidRendererMixin.java | 7 +- .../sodium/SodiumLightDataAccessMixin.java | 18 +- .../mixininterface/IAttributeContainer.java | 16 - .../IEntityAttributeInstance.java | 15 - .../pathing/BaritonePathManager.java | 248 ---------------- .../meteorclient/pathing/BaritoneUtils.java | 20 -- .../meteorclient/pathing/IPathManager.java | 49 ---- .../meteorclient/pathing/NopPathManager.java | 102 ------- .../meteorclient/pathing/PathManagers.java | 49 ---- .../meteorclient/renderer/Fonts.java | 5 +- .../meteorclient/renderer/GL.java | 7 +- .../meteorclient/renderer/Mesh.java | 2 +- .../meteorclient/renderer/Shader.java | 3 +- .../meteorclient/renderer/text/CharData.java | 24 ++ .../renderer/text/CustomTextRenderer.java | 8 +- .../meteorclient/renderer/text/Font.java | 75 ++--- .../meteorclient/settings/BoolSetting.java | 3 +- .../settings/ColorListSetting.java | 12 +- .../meteorclient/settings/ColorSetting.java | 3 +- .../meteorclient/settings/EnumSetting.java | 10 +- .../meteorclient/systems/System.java | 19 +- .../meteorclient/systems/Systems.java | 4 +- .../systems/accounts/Account.java | 25 +- .../systems/accounts/AccountCache.java | 4 +- .../accounts/types/CrackedAccount.java | 4 +- .../systems/accounts/types/EasyMCAccount.java | 11 +- .../accounts/types/MicrosoftAccount.java | 5 +- .../accounts/types/TheAlteningAccount.java | 36 ++- .../meteorclient/systems/friends/Friend.java | 8 +- .../meteorclient/systems/friends/Friends.java | 6 +- .../meteorclient/systems/hud/Hud.java | 2 +- .../systems/hud/elements/CombatHud.java | 31 +- .../systems/hud/elements/InventoryHud.java | 10 +- .../systems/hud/elements/PlayerModelHud.java | 101 +------ .../systems/hud/elements/PlayerRadarHud.java | 4 +- .../systems/hud/elements/PotionTimersHud.java | 53 ++-- .../systems/hud/screens/HudEditorScreen.java | 2 +- .../meteorclient/systems/modules/Modules.java | 18 +- .../systems/modules/combat/AnchorAura.java | 91 +++--- .../systems/modules/combat/AutoCity.java | 6 +- .../systems/modules/combat/BedAura.java | 5 +- .../systems/modules/combat/BowAimbot.java | 10 +- .../systems/modules/combat/CrystalAura.java | 39 ++- .../systems/modules/combat/HoleFiller.java | 2 +- .../systems/modules/combat/KillAura.java | 36 +-- .../systems/modules/combat/Surround.java | 1 - .../systems/modules/misc/AutoLog.java | 36 +-- .../systems/modules/misc/BetterChat.java | 11 +- .../systems/modules/misc/BookBot.java | 124 +++----- .../systems/modules/misc/DiscordPresence.java | 8 +- .../systems/modules/misc/MessageAura.java | 2 +- .../systems/modules/misc/Notebot.java | 3 +- .../systems/modules/misc/Notifier.java | 10 +- .../systems/modules/misc/ServerSpoof.java | 17 +- .../modules/misc/swarm/SwarmWorker.java | 10 +- .../systems/modules/movement/AutoWalk.java | 27 +- .../systems/modules/movement/ElytraBoost.java | 2 +- .../systems/modules/movement/Flight.java | 2 + .../systems/modules/movement/GUIMove.java | 31 +- .../systems/modules/movement/Jesus.java | 29 +- .../systems/modules/movement/NoFall.java | 11 +- .../systems/modules/movement/Step.java | 26 +- .../systems/modules/player/AutoClicker.java | 4 +- .../systems/modules/player/AutoEat.java | 8 +- .../systems/modules/player/AutoGap.java | 8 +- .../systems/modules/player/AutoTool.java | 4 +- .../systems/modules/player/ChestSwap.java | 12 - .../systems/modules/player/FakePlayer.java | 2 +- .../modules/player/MiddleClickExtra.java | 6 +- .../modules/render/BetterTooltips.java | 13 +- .../modules/render/BreakIndicators.java | 12 +- .../systems/modules/render/ESP.java | 4 +- .../systems/modules/render/EntityOwner.java | 2 +- .../systems/modules/render/Freecam.java | 19 +- .../systems/modules/render/Fullbright.java | 21 +- .../systems/modules/render/LightOverlay.java | 13 +- .../systems/modules/render/LogoutSpots.java | 8 +- .../systems/modules/render/Nametags.java | 4 +- .../modules/render/WaypointsModule.java | 74 +---- .../systems/modules/world/AutoBreed.java | 32 +- .../systems/modules/world/AutoNametag.java | 4 +- .../systems/modules/world/Flamethrower.java | 2 +- .../systems/modules/world/InfinityMiner.java | 2 +- .../systems/modules/world/Nuker.java | 4 +- .../systems/modules/world/SpawnProofer.java | 9 +- .../systems/modules/world/StashFinder.java | 6 +- .../systems/modules/world/VeinMiner.java | 5 +- .../systems/waypoints/Waypoints.java | 77 ++++- .../meteorclient/utils/ReflectInit.java | 2 +- .../meteorclient/utils/Utils.java | 7 +- .../utils/entity/DamageUtils.java | 258 ----------------- .../utils/entity/EntityAttributeHelper.java | 98 ------- .../utils/entity/EntityUtils.java | 10 +- .../utils/entity/StatusEffectHelper.java | 44 --- .../effects/EffectAttributeModifier.java | 30 -- .../entity/effects/EntityEffectCache.java | 25 -- .../entity/effects/MutableParticleColor.java | 43 --- .../effects/StatusEffectBruteForce.java | 242 ---------------- .../entity/fakeplayer/FakePlayerEntity.java | 5 +- .../entity/fakeplayer/FakePlayerManager.java | 4 +- .../utils/misc/BaritoneUtils.java | 42 +++ .../utils/misc/FakeClientPlayer.java | 35 +-- .../utils/misc/MeteorStarscript.java | 20 +- .../meteorclient/utils/misc/Names.java | 13 +- .../meteorclient/utils/misc/NbtUtils.java | 7 +- .../utils/misc/ValueComparableMap.java | 18 +- .../meteorclient/utils/network/Capes.java | 2 +- .../utils/network/PacketUtils.java | 188 ++++++------ .../utils/network/PacketUtilsUtil.java | 211 +++++++------- .../meteorclient/utils/player/ChatUtils.java | 27 +- .../utils/player/DamageUtils.java | 274 ++++++++++++++++++ .../utils/player/EChestMemory.java | 13 - .../meteorclient/utils/player/PathFinder.java | 2 +- .../utils/player/PlayerUtils.java | 40 +-- .../utils/player/TitleScreenCredits.java | 63 +++- .../utils/render/MeteorToast.java | 2 - .../utils/render/PlayerHeadTexture.java | 7 +- .../utils/render/PlayerHeadUtils.java | 3 +- .../utils/tooltip/TextTooltipComponent.java | 26 -- .../meteorclient/utils/world/BlockUtils.java | 31 +- .../utils/world/GoalDirection.java | 69 +++++ src/main/resources/fabric.mod.json | 10 +- .../meteor-client-indigo.mixins.json | 3 +- .../resources/meteor-client.accesswidener | 1 - src/main/resources/meteor-client.mixins.json | 16 +- 196 files changed, 1662 insertions(+), 3366 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/crash.yml delete mode 100644 src/main/java/meteordevelopment/meteorclient/commands/commands/DisconnectCommand.java rename src/main/java/meteordevelopment/meteorclient/{pathing/BaritoneSettings.java => gui/tabs/builtin/BaritoneTab.java} (92%) delete mode 100644 src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/PathManagerTab.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/AttributeContainerMixin.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/CapeFeatureRendererMixin.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/ChunkBorderDebugRendererMixin.java create mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadC2SPacketAccessor.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/ElytraFeatureRendererMixin.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/EntityAttributeInstanceMixin.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/FileCacheAccessor.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/RegistriesMixin.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/ShulkerEntityAccessor.java create mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/SimpleRegistryMixin.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/indigo/AoCalculatorMixin.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixininterface/IAttributeContainer.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/mixininterface/IEntityAttributeInstance.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/pathing/BaritonePathManager.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/pathing/BaritoneUtils.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/pathing/IPathManager.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/pathing/NopPathManager.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/pathing/PathManagers.java create mode 100644 src/main/java/meteordevelopment/meteorclient/renderer/text/CharData.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/utils/entity/DamageUtils.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/utils/entity/EntityAttributeHelper.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/utils/entity/StatusEffectHelper.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/utils/entity/effects/EffectAttributeModifier.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/utils/entity/effects/EntityEffectCache.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/utils/entity/effects/MutableParticleColor.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/utils/entity/effects/StatusEffectBruteForce.java create mode 100644 src/main/java/meteordevelopment/meteorclient/utils/misc/BaritoneUtils.java create mode 100644 src/main/java/meteordevelopment/meteorclient/utils/player/DamageUtils.java delete mode 100644 src/main/java/meteordevelopment/meteorclient/utils/tooltip/TextTooltipComponent.java create mode 100644 src/main/java/meteordevelopment/meteorclient/utils/world/GoalDirection.java diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index cdd9c0885e..346b948719 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -8,10 +8,8 @@ body: label: Describe the bug description: | A clear and concise description of what the issue is. - Provide as much information as possible, videos, images, etc. - placeholder: | - This module is broken / not working as intended. - It should do X but it does Y instead. + Provide as much information as possible, videos, crash reports, etc. + DO NOT PASTE A CRASH REPORT HERE!!!! validations: required: true - type: textarea @@ -19,23 +17,23 @@ body: attributes: label: Steps to reproduce description: How do you trigger this bug? - placeholder: | - 1. I did this thing; - 2. Then I did this other thing, which caused the bug. + render: bash validations: required: true + - type: input + id: crash-report + attributes: + label: Link to crash report/log if applicable (https://mclo.gs) - type: input id: meteor-version attributes: label: Meteor Version - placeholder: Meteor X.Y.Z (or X.Y.Z-build_number) validations: required: true - type: input id: mc-version attributes: label: Minecraft Version - placeholder: MC X.Y.Z validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/crash.yml b/.github/ISSUE_TEMPLATE/crash.yml deleted file mode 100644 index ce24178959..0000000000 --- a/.github/ISSUE_TEMPLATE/crash.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Crash -description: Report a crash to help us improve Meteor. -labels: [ crash ] -body: - - type: textarea - id: reproducing - attributes: - label: Steps to reproduce - description: How do you trigger this crash? - placeholder: | - 1. I did this thing; - 2. Then I did this other thing, which caused the crash. - validations: - required: true - - type: input - id: crash-report - attributes: - label: Link to crash report/log (upload to https://mclo.gs and paste resulting link here) - placeholder: https://mclo.gs/xxxxxx - validations: - required: true - - type: input - id: meteor-version - attributes: - label: Meteor Version - placeholder: Meteor X.Y.Z (or X.Y.Z-build_number) - validations: - required: true - - type: input - id: mc-version - attributes: - label: Minecraft Version - placeholder: MC X.Y.Z - validations: - required: true - - type: dropdown - id: operating-systems - attributes: - label: Operating System - options: - - macOS - - Windows - - Linux - validations: - required: true - - type: checkboxes - id: prerequisites - attributes: - label: Before submitting a crash report - options: - - label: | - This crash wasn't already reported (I have searched crash reports on GitHub). - required: true - - label: | - This is a valid crash (I am able to reproduce this on the latest dev build). - required: true diff --git a/build.gradle b/build.gradle index ca9435e84f..666ba25473 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,11 @@ plugins { - id "fabric-loom" version "1.5-SNAPSHOT" + id "fabric-loom" version "1.2-SNAPSHOT" id "maven-publish" - id "com.github.johnrengelman.shadow" version "8.1.1" + id "com.github.johnrengelman.shadow" version "7.1.2" } +sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 + archivesBaseName = project.archives_base_name version = project.mod_version + (project.hasProperty("devbuild") ? ("-" + project.findProperty("devbuild")) : "") group = project.maven_group @@ -58,7 +60,7 @@ dependencies { modCompileOnly("maven.modrinth:indium:${project.indium_version}") { transitive = false } // Baritone (https://github.com/MeteorDevelopment/baritone) - modCompileOnly "meteordevelopment:baritone:${project.baritone_version}-SNAPSHOT" + modInclude "baritone:fabric:${project.minecraft_version}-SNAPSHOT" // Libraries library "meteordevelopment:orbit:${project.orbit_version}" @@ -67,7 +69,8 @@ dependencies { library "org.reflections:reflections:${project.reflections_version}" library("io.netty:netty-handler-proxy:${project.netty_version}") { transitive = false } library("io.netty:netty-codec-socks:${project.netty_version}") { transitive = false } - library "de.florianmichael:WaybackAuthLib:1.0.0" + library "com.github.LlamaLad7.MixinExtras:mixinextras-fabric:${project.mixin_extras_version}" + annotationProcessor "com.github.LlamaLad7.MixinExtras:mixinextras-fabric:${project.mixin_extras_version}" // Launch sub project shadow project(":launch") @@ -94,37 +97,21 @@ shadowJar { } processResources { - def propertyMap = [ - "version" : project.version, - "devbuild" : project.findProperty("devbuild") ?: "", - "commit" : project.findProperty("commit") ?: "", - "minecraft_version": project.minecraft_version, - "loader_version" : project.loader_version - ] - - inputs.properties(propertyMap) filesMatching("fabric.mod.json") { - expand(propertyMap) + expand "version": project.version, + "devbuild": project.findProperty("devbuild") ?: "", + "commit": project.findProperty("commit") ?: "" } } jar { - from("LICENSE") { - rename { "${it}_${archivesBaseName}" } - } + from "LICENSE" manifest { attributes("Main-Class": "meteordevelopment.meteorclient.Main") } } -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - - withSourcesJar() -} - remapJar { dependsOn shadowJar inputFile.set(shadowJar.archiveFile) @@ -135,22 +122,33 @@ javadoc { options.encoding = "UTF-8" } -tasks.register("javadocJar", Jar) { - from javadoc - archiveClassifier.set("javadoc") +task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier.set("sources") + from sourceSets.main.allSource } -build { - dependsOn javadocJar +task javadocJar(type: Jar) { + archiveClassifier.set("javadoc") + from javadoc } publishing { publications { - mavenJava(MavenPublication) { + java(MavenPublication) { artifactId = "meteor-client" version = project.hasProperty("devbuild") ? (project.mod_version + "-SNAPSHOT") : project.mod_version - from components.java + artifact(remapJar) { + builtBy remapJar + } + + artifact(sourcesJar) { + builtBy remapSourcesJar + } + + artifact(javadocJar) { + builtBy javadocJar + } } } diff --git a/gradle.properties b/gradle.properties index b200c88762..0d58f0181c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,35 +1,29 @@ org.gradle.jvmargs=-Xmx2G # Fabric (https://fabricmc.net/develop) -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.2 -fapi_version=0.95.3+1.20.4 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.1 +loader_version=0.14.21 +fapi_version=0.84.0+1.20.1 # Mod Properties -mod_version=0.5.6 +mod_version=0.5.4 maven_group=meteordevelopment archives_base_name=meteor-client # Dependency Versions -# Baritone (https://github.com/MeteorDevelopment/baritone) -baritone_version=1.20.4 - # Sodium (https://github.com/CaffeineMC/sodium-fabric) -sodium_version=mc1.20.3-0.5.7 +sodium_version=mc1.20.1-0.5.0 # Lithium (https://github.com/CaffeineMC/lithium-fabric) -lithium_version=mc1.20.4-0.12.1 +lithium_version=mc1.20-0.11.2 # Iris (https://github.com/IrisShaders/Iris) -iris_version=1.6.14+1.20.4 - -# Indium (https://github.com/comp500/Indium) -indium_version=1.0.28+mc1.20.4 +iris_version=1.6.5+1.20.1 # Orbit (https://github.com/MeteorDevelopment/orbit) -orbit_version=0.2.4 +orbit_version=0.2.3 # Starscript (https://github.com/MeteorDevelopment/starscript) starscript_version=0.2.2 @@ -42,3 +36,9 @@ reflections_version=0.10.2 # Netty (https://github.com/netty/netty) netty_version=4.1.90.Final + +# Mixin Extras (https://github.com/LlamaLad7/MixinExtras) +mixin_extras_version=0.2.0-beta.8 + +# Indium (https://github.com/comp500/Indium) +indium_version=1.0.25+mc1.20.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a595206642..fae08049a6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/meteordevelopment/meteorclient/commands/Commands.java b/src/main/java/meteordevelopment/meteorclient/commands/Commands.java index c01a2cfe43..fbae5aac16 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/Commands.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/Commands.java @@ -8,7 +8,6 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.exceptions.CommandSyntaxException; import meteordevelopment.meteorclient.commands.commands.*; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.utils.PostInit; import net.minecraft.client.network.ClientCommandSource; import net.minecraft.command.CommandSource; @@ -24,12 +23,11 @@ public class Commands { public static final CommandSource COMMAND_SOURCE = new ClientCommandSource(null, mc); public static final List COMMANDS = new ArrayList<>(); - @PostInit(dependencies = PathManagers.class) + @PostInit public static void init() { add(new VClipCommand()); add(new HClipCommand()); add(new DismountCommand()); - add(new DisconnectCommand()); add(new DamageCommand()); add(new DropCommand()); add(new EnchantCommand()); @@ -37,6 +35,7 @@ public static void init() { add(new FriendsCommand()); add(new CommandsCommand()); add(new InventoryCommand()); + add(new LocateCommand()); add(new NbtCommand()); add(new NotebotCommand()); add(new PeekCommand()); @@ -62,7 +61,6 @@ public static void init() { add(new RotationCommand()); add(new WaypointCommand()); add(new InputCommand()); - add(new LocateCommand()); COMMANDS.sort(Comparator.comparing(Command::getName)); } diff --git a/src/main/java/meteordevelopment/meteorclient/commands/arguments/FakePlayerArgumentType.java b/src/main/java/meteordevelopment/meteorclient/commands/arguments/FakePlayerArgumentType.java index 2ba92b3409..fde62bb80d 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/arguments/FakePlayerArgumentType.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/arguments/FakePlayerArgumentType.java @@ -38,7 +38,7 @@ public String parse(StringReader reader) throws CommandSyntaxException { @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - return suggestMatching(FakePlayerManager.stream().map(fakePlayerEntity -> fakePlayerEntity.getName().getString()), builder); + return suggestMatching(FakePlayerManager.stream().map(FakePlayerEntity::getEntityName), builder); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/commands/arguments/PlayerArgumentType.java b/src/main/java/meteordevelopment/meteorclient/commands/arguments/PlayerArgumentType.java index 10472f55c6..b9ebc0b1e6 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/arguments/PlayerArgumentType.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/arguments/PlayerArgumentType.java @@ -41,7 +41,7 @@ public PlayerEntity parse(StringReader reader) throws CommandSyntaxException { PlayerEntity playerEntity = null; for (PlayerEntity p : mc.world.getPlayers()) { - if (p.getName().getString().equalsIgnoreCase(argument)) { + if (p.getEntityName().equalsIgnoreCase(argument)) { playerEntity = p; break; } @@ -53,7 +53,7 @@ public PlayerEntity parse(StringReader reader) throws CommandSyntaxException { @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - return CommandSource.suggestMatching(mc.world.getPlayers().stream().map(abstractClientPlayerEntity -> abstractClientPlayerEntity.getName().getString()), builder); + return CommandSource.suggestMatching(mc.world.getPlayers().stream().map(PlayerEntity::getEntityName), builder); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/DisconnectCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/DisconnectCommand.java deleted file mode 100644 index 227ac3ae77..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/DisconnectCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.commands.commands; - -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.brigadier.arguments.ArgumentType; -import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import meteordevelopment.meteorclient.commands.Command; -import net.minecraft.client.gui.screen.DisconnectedScreen; -import net.minecraft.command.CommandSource; -import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; - -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - -public class DisconnectCommand extends Command { - public DisconnectCommand() { - super("disconnect", "Disconnect from the server", "dc"); - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.executes(context -> { - mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal("%s[%sDisconnectCommand%s] Disconnected by user.".formatted(Formatting.GRAY, Formatting.BLUE, Formatting.GRAY)))); - return SINGLE_SUCCESS; - }); - - builder.then(argument("reason", StringArgumentType.greedyString()).executes(context -> { - mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal(StringArgumentType.getString(context, "reason")))); - return SINGLE_SUCCESS; - })); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/DropCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/DropCommand.java index 976a47496f..62bbbc5626 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/DropCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/DropCommand.java @@ -55,7 +55,6 @@ public void build(LiteralArgumentBuilder builder) { for (int i = 0; i < player.getInventory().size(); i++) { InvUtils.drop().slot(i); } - InvUtils.drop().slotOffhand(); }))); // Armor diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/FakePlayerCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/FakePlayerCommand.java index 4a05f24d14..122e9a13c6 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/FakePlayerCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/FakePlayerCommand.java @@ -50,7 +50,7 @@ public void build(LiteralArgumentBuilder builder) { } FakePlayerManager.remove(fp); - info("Removed Fake Player %s.".formatted(fp.getName().getString())); + info("Removed Fake Player %s.".formatted(fp.getEntityName())); return SINGLE_SUCCESS; }) @@ -67,7 +67,7 @@ public void build(LiteralArgumentBuilder builder) { builder.then(literal("list") .executes(context -> { info("--- Fake Players ((highlight)%s(default)) ---", FakePlayerManager.count()); - FakePlayerManager.forEach(fp -> ChatUtils.info("(highlight)%s".formatted(fp.getName().getString()))); + FakePlayerManager.forEach(fp -> ChatUtils.info("(highlight)%s".formatted(fp.getEntityName()))); return SINGLE_SUCCESS; }) ); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/InputCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/InputCommand.java index bb6f281619..6e7b0f328b 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/InputCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/InputCommand.java @@ -14,16 +14,12 @@ import net.minecraft.client.option.KeyBinding; import net.minecraft.command.CommandSource; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; import static meteordevelopment.meteorclient.MeteorClient.mc; public class InputCommand extends Command { - private static final List activeHandlers = new ArrayList<>(); - private static final Map keys = Map.of( mc.options.forwardKey, "forwards", mc.options.backKey, "backwards", @@ -45,55 +41,20 @@ public void build(LiteralArgumentBuilder builder) { builder.then(literal(keyBinding.getValue()) .then(argument("ticks", IntegerArgumentType.integer(1)) .executes(context -> { - activeHandlers.add(new KeypressHandler(keyBinding.getKey(), context.getArgument("ticks", Integer.class))); + new KeypressHandler(keyBinding.getKey(), context.getArgument("ticks", Integer.class)); return SINGLE_SUCCESS; }) ) ); } - - builder.then(literal("clear").executes(ctx -> { - if (activeHandlers.isEmpty()) warning("No active keypress handlers."); - else { - info("Cleared all keypress handlers."); - activeHandlers.forEach(MeteorClient.EVENT_BUS::unsubscribe); - activeHandlers.clear(); - } - return SINGLE_SUCCESS; - })); - - builder.then(literal("list").executes(ctx -> { - if (activeHandlers.isEmpty()) warning("No active keypress handlers."); - else { - info("Active keypress handlers: "); - for (int i = 0; i < activeHandlers.size(); i++) { - KeypressHandler handler = activeHandlers.get(i); - info("(highlight)%d(default) - (highlight)%s %d(default) ticks left out of (highlight)%d(default).", i, keys.get(handler.key), handler.ticks, handler.totalTicks); - } - } - return SINGLE_SUCCESS; - })); - - builder.then(literal("remove").then(argument("index", IntegerArgumentType.integer(0)).executes(ctx -> { - int index = IntegerArgumentType.getInteger(ctx, "index"); - if (index >= activeHandlers.size()) warning("Index out of range."); - else { - info("Removed keypress handler."); - MeteorClient.EVENT_BUS.unsubscribe(activeHandlers.get(index)); - activeHandlers.remove(index); - } - return SINGLE_SUCCESS; - }))); } private static class KeypressHandler { private final KeyBinding key; - private final int totalTicks; private int ticks; public KeypressHandler(KeyBinding key, int ticks) { this.key = key; - this.totalTicks = ticks; this.ticks = ticks; MeteorClient.EVENT_BUS.subscribe(this); @@ -105,7 +66,6 @@ private void onTick(TickEvent.Post event) { else { key.setPressed(false); MeteorClient.EVENT_BUS.unsubscribe(this); - activeHandlers.remove(this); } } } diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/LocateCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/LocateCommand.java index fbddc68791..241bc6cad9 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/LocateCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/LocateCommand.java @@ -10,8 +10,6 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.events.packets.PacketEvent; -import meteordevelopment.meteorclient.pathing.BaritoneUtils; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.utils.player.ChatUtils; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.orbit.EventHandler; @@ -19,7 +17,6 @@ import net.minecraft.block.Blocks; import net.minecraft.command.CommandSource; import net.minecraft.entity.EntityType; -import net.minecraft.entity.EyeOfEnderEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; @@ -146,15 +143,10 @@ public void build(LiteralArgumentBuilder builder) { })); builder.then(literal("stronghold").executes(s -> { - if (!BaritoneUtils.IS_AVAILABLE) { - error("Locating this structure requires Baritone."); - return SINGLE_SUCCESS; - } - boolean foundEye = InvUtils.testInHotbar(Items.ENDER_EYE); if (foundEye) { - PathManagers.get().follow(entity -> entity instanceof EyeOfEnderEntity); + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("follow entity minecraft:eye_of_ender"); firstStart = null; firstEnd = null; secondStart = null; @@ -176,11 +168,6 @@ public void build(LiteralArgumentBuilder builder) { })); builder.then(literal("nether_fortress").executes(s -> { - if (!BaritoneUtils.IS_AVAILABLE) { - error("Locating this structure requires Baritone."); - return SINGLE_SUCCESS; - } - Vec3d coords = findByBlockList(netherFortressBlocks); if (coords == null) { error("No nether fortress found."); @@ -194,11 +181,6 @@ public void build(LiteralArgumentBuilder builder) { })); builder.then(literal("monument").executes(s -> { - if (!BaritoneUtils.IS_AVAILABLE) { - error("Locating this structure requires Baritone."); - return SINGLE_SUCCESS; - } - ItemStack stack = mc.player.getInventory().getMainHandStack(); if (stack.getItem() == Items.FILLED_MAP) { NbtCompound tag = stack.getNbt(); @@ -289,8 +271,7 @@ private void lastPosition(double x, double y, double z) { } private void findStronghold() { - PathManagers.get().stop(); - + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("stop"); if (this.firstStart == null || this.firstEnd == null || this.secondStart == null || this.secondEnd == null) { error("Missing position data"); cancel(); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/ServerCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/ServerCommand.java index d4e5b5c056..bf532fed28 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/ServerCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/ServerCommand.java @@ -36,7 +36,7 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; public class ServerCommand extends Command { - private static final List ANTICHEAT_LIST = Arrays.asList("nocheatplus", "negativity", "warden", "horizon", "illegalstack", "coreprotect", "exploitsx", "vulcan", "abc", "spartan", "kauri", "anticheatreloaded", "witherac", "godseye", "matrix", "wraith", "antixrayheuristics", "grimac"); + private static final List ANTICHEAT_LIST = Arrays.asList("nocheatplus", "negativity", "warden", "horizon", "illegalstack", "coreprotect", "exploitsx", "vulcan", "abc", "spartan", "kauri", "anticheatreloaded", "witherac", "godseye", "matrix", "wraith", "antixrayheuristics"); private static final String completionStarts = "/:abcdefghijklmnopqrstuvwxyz0123456789-"; private int ticks = 0; private boolean bukkitMode = false; @@ -194,7 +194,7 @@ private void basicInfo() { info("Port: %d", ServerAddress.parse(server.address).getPort()); - info("Type: %s", mc.getNetworkHandler().getBrand() != null ? mc.getNetworkHandler().getBrand() : "unknown"); + info("Type: %s", mc.player.getServerBrand() != null ? mc.player.getServerBrand() : "unknown"); info("Motd: %s", server.label != null ? server.label.getString() : "unknown"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/SwarmCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/SwarmCommand.java index 317550eabd..8ce4ec004e 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/SwarmCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/SwarmCommand.java @@ -5,6 +5,8 @@ package meteordevelopment.meteorclient.commands.commands; +import baritone.api.BaritoneAPI; +import baritone.api.pathing.goals.GoalXZ; import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.arguments.StringArgumentType; @@ -13,7 +15,6 @@ import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.commands.arguments.ModuleArgumentType; import meteordevelopment.meteorclient.commands.arguments.PlayerArgumentType; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.misc.swarm.Swarm; @@ -26,7 +27,6 @@ import net.minecraft.command.argument.BlockStateArgumentType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.Text; -import net.minecraft.util.math.BlockPos; import java.util.List; import java.util.Random; @@ -104,7 +104,7 @@ else if (swarm.isWorker()) { Swarm swarm = Modules.get().get(Swarm.class); if (swarm.isActive()) { if (swarm.isHost()) { - swarm.host.sendMessage(context.getInput() + " " + mc.player.getName().getString()); + swarm.host.sendMessage(context.getInput() + " " + mc.player.getEntityName()); } else if (swarm.isWorker()) { error("The follow host command must be used by the host."); @@ -124,7 +124,7 @@ else if (swarm.isWorker()) { swarm.host.sendMessage(context.getInput()); } else if (swarm.isWorker() && playerEntity != null) { - PathManagers.get().follow(entity -> entity.getName().getString().equalsIgnoreCase(playerEntity.getName().getString())); + BaritoneAPI.getProvider().getPrimaryBaritone().getFollowProcess().follow(entity -> entity.getEntityName().equalsIgnoreCase(playerEntity.getEntityName())); } } else { @@ -146,7 +146,7 @@ else if (swarm.isWorker()) { int x = IntegerArgumentType.getInteger(context, "x"); int z = IntegerArgumentType.getInteger(context, "z"); - PathManagers.get().moveTo(new BlockPos(x, 0, z), true); + BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(x, z)); } } else { @@ -330,7 +330,7 @@ else if (swarm.isWorker()) { if (swarm.isHost()) { swarm.host.sendMessage(context.getInput()); } else if (swarm.isWorker()) { - PathManagers.get().stop(); + BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); } } else { throw SWARM_NOT_ACTIVE.create(); @@ -362,13 +362,11 @@ private void runInfinityMiner() { private void scatter(int radius) { Random random = new Random(); - double a = random.nextDouble() * 2 * Math.PI; double r = radius * Math.sqrt(random.nextDouble()); double x = mc.player.getX() + r * Math.cos(a); double z = mc.player.getZ() + r * Math.sin(a); - - PathManagers.get().stop(); - PathManagers.get().moveTo(new BlockPos((int) x, 0, (int) z), true); + BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); + BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ((int) x, (int) z)); } } diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java index 598c4fd308..2de5b39fb3 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java @@ -7,17 +7,13 @@ import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.commands.arguments.WaypointArgumentType; import meteordevelopment.meteorclient.systems.waypoints.Waypoint; import meteordevelopment.meteorclient.systems.waypoints.Waypoints; import meteordevelopment.meteorclient.utils.player.PlayerUtils; import net.minecraft.command.CommandSource; -import net.minecraft.command.argument.PosArgument; -import net.minecraft.command.argument.Vec3ArgumentType; import net.minecraft.util.Formatting; -import net.minecraft.util.math.BlockPos; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -49,13 +45,20 @@ public void build(LiteralArgumentBuilder builder) { return SINGLE_SUCCESS; }))); - builder.then(literal("add") - .then(argument("pos", Vec3ArgumentType.vec3()) - .then(argument("waypoint", StringArgumentType.greedyString()).executes(context -> addWaypoint(context, true))) - ) + builder.then(literal("add").then(argument("waypoint", StringArgumentType.greedyString()).executes(context -> { + if (mc.player == null) return -1; - .then(argument("waypoint", StringArgumentType.greedyString()).executes(context -> addWaypoint(context, false))) - ); + Waypoint waypoint = new Waypoint.Builder() + .name(StringArgumentType.getString(context, "waypoint")) + .pos(mc.player.getBlockPos().up(2)) + .dimension(PlayerUtils.getDimension()) + .build(); + + Waypoints.get().add(waypoint); + + info("Created waypoint with name: (highlight)%s(default)", waypoint.name.get()); + return SINGLE_SUCCESS; + }))); builder.then(literal("delete").then(argument("waypoint", WaypointArgumentType.create()).executes(context -> { Waypoint waypoint = WaypointArgumentType.get(context); @@ -81,22 +84,6 @@ private String waypointPos(Waypoint waypoint) { } private String waypointFullPos(Waypoint waypoint) { - return "X: " + waypoint.pos.get().getX() + ", Y: " + waypoint.pos.get().getY() + ", Z: " + waypoint.pos.get().getZ(); - } - - private int addWaypoint(CommandContext context, boolean withCoords) { - if (mc.player == null) return -1; - - BlockPos pos = withCoords ? context.getArgument("pos", PosArgument.class).toAbsoluteBlockPos(mc.player.getCommandSource()) : mc.player.getBlockPos().up(2); - Waypoint waypoint = new Waypoint.Builder() - .name(StringArgumentType.getString(context, "waypoint")) - .pos(pos) - .dimension(PlayerUtils.getDimension()) - .build(); - - Waypoints.get().add(waypoint); - - info("Created waypoint with name: (highlight)%s(default)", waypoint.name.get()); - return SINGLE_SUCCESS; + return "X: " + waypoint.pos.get().getX() + ", Y: " + waypoint.pos.get().getY() + ", Z: " + waypoint.pos.get().getZ(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/events/entity/DamageEvent.java b/src/main/java/meteordevelopment/meteorclient/events/entity/DamageEvent.java index 9ac7d75595..ce3463e843 100644 --- a/src/main/java/meteordevelopment/meteorclient/events/entity/DamageEvent.java +++ b/src/main/java/meteordevelopment/meteorclient/events/entity/DamageEvent.java @@ -13,10 +13,12 @@ public class DamageEvent { public LivingEntity entity; public DamageSource source; + public float amount; - public static DamageEvent get(LivingEntity entity, DamageSource source) { + public static DamageEvent get(LivingEntity entity, DamageSource source, float amount) { INSTANCE.entity = entity; INSTANCE.source = source; + INSTANCE.amount = amount; return INSTANCE; } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/GuiTheme.java b/src/main/java/meteordevelopment/meteorclient/gui/GuiTheme.java index 90b7958459..0168bbdd85 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/GuiTheme.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/GuiTheme.java @@ -116,7 +116,13 @@ public WTextBox textBox(String text) { public abstract WDropdown dropdown(T[] values, T value); public > WDropdown dropdown(T value) { Class klass = value.getClass(); - T[] values = (T[]) klass.getEnumConstants(); + T[] values = null; + try { + values = (T[]) klass.getDeclaredMethod("values").invoke(null); + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + e.printStackTrace(); + } + return dropdown(values, value); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/GuiThemes.java b/src/main/java/meteordevelopment/meteorclient/gui/GuiThemes.java index 2b528f16c7..beb6e164c4 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/GuiThemes.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/GuiThemes.java @@ -35,7 +35,7 @@ public static void init() { public static void postInit() { if (FILE.exists()) { try { - NbtCompound tag = NbtIo.read(FILE.toPath()); + NbtCompound tag = NbtIo.read(FILE); if (tag != null) select(tag.getString("currentTheme")); } catch (IOException e) { @@ -82,7 +82,7 @@ public static void select(String name) { File file = new File(THEMES_FOLDER, get().name + ".nbt"); if (file.exists()) { - NbtCompound tag = NbtIo.read(file.toPath()); + NbtCompound tag = NbtIo.read(file); if (tag != null) get().fromTag(tag); } } catch (IOException e) { @@ -116,7 +116,7 @@ private static void saveTheme() { NbtCompound tag = get().toTag(); THEMES_FOLDER.mkdirs(); - NbtIo.write(tag, new File(THEMES_FOLDER, get().name + ".nbt").toPath()); + NbtIo.write(tag, new File(THEMES_FOLDER, get().name + ".nbt")); } catch (IOException e) { e.printStackTrace(); } @@ -129,7 +129,7 @@ private static void saveGlobal() { tag.putString("currentTheme", get().name); FOLDER.mkdirs(); - NbtIo.write(tag, FILE.toPath()); + NbtIo.write(tag, FILE); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/WidgetScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/WidgetScreen.java index 1128b0b238..8ca1698fd6 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/WidgetScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/WidgetScreen.java @@ -151,12 +151,12 @@ public void mouseMoved(double mouseX, double mouseY) { } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) { + public boolean mouseScrolled(double mouseX, double mouseY, double amount) { if (locked) return false; - root.mouseScrolled(verticalAmount); + root.mouseScrolled(amount); - return super.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount); + return super.mouseScrolled(mouseX, mouseY, amount); } @Override @@ -197,7 +197,8 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { textBox.setCursorMax(); done.set(true); - } else { + } + else { if (textBox.isFocused()) { textBox.setFocused(false); foundFocused.set(true); @@ -219,7 +220,8 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (control && keyCode == GLFW_KEY_C && toClipboard()) { return true; - } else if (control && keyCode == GLFW_KEY_V && fromClipboard()) { + } + else if (control && keyCode == GLFW_KEY_V && fromClipboard()) { reload(); if (parent instanceof WidgetScreen wScreen) { wScreen.reload(); @@ -245,7 +247,7 @@ public boolean charTyped(char chr, int keyCode) { @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { - if (!Utils.canUpdate()) renderBackground(context, mouseX, mouseY, delta); + if (!Utils.canUpdate()) renderBackground(context); double s = mc.getWindow().getScaleFactor(); mouseX *= s; diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/ModulesScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/ModulesScreen.java index 908e9f34b5..c9c82710cd 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/ModulesScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/ModulesScreen.java @@ -164,21 +164,16 @@ protected Cell createFavorites(WContainer c) { } protected boolean createFavoritesW(WWindow w) { - List modules = new ArrayList<>(); + boolean hasFavorites = false; for (Module module : Modules.get().getAll()) { if (module.favorite) { - modules.add(module); + w.add(theme.module(module)).expandX(); + hasFavorites = true; } } - modules.sort((o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.name, o2.name)); - - for (Module module : modules) { - w.add(theme.module(module)).expandX(); - } - - return !modules.isEmpty(); + return hasFavorites; } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/accounts/AddCrackedAccountScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/accounts/AddCrackedAccountScreen.java index 856b231961..7a61275aa7 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/accounts/AddCrackedAccountScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/accounts/AddCrackedAccountScreen.java @@ -32,7 +32,7 @@ public void initWidgets() { // Add add = t.add(theme.button("Add")).expandX().widget(); add.action = () -> { - if (!name.get().isEmpty() && name.get().length() < 17) { + if (!name.get().isEmpty() && (name.get().length() < 17) && name.get().matches("^[a-zA-Z0-9_]+$")) { CrackedAccount account = new CrackedAccount(name.get()); if (!(Accounts.get().exists(account))) { AccountsScreen.addAccount(this, parent, account); diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectAmplifierMapSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectAmplifierMapSettingScreen.java index f4b4c073c8..5da5e5194d 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectAmplifierMapSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectAmplifierMapSettingScreen.java @@ -14,8 +14,6 @@ import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.utils.misc.Names; import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; @@ -27,6 +25,7 @@ public class StatusEffectAmplifierMapSettingScreen extends WindowScreen { private WTable table; + private WTextBox filter; private String filterText = ""; public StatusEffectAmplifierMapSettingScreen(GuiTheme theme, Setting> setting) { @@ -37,7 +36,7 @@ public StatusEffectAmplifierMapSettingScreen(GuiTheme theme, Setting { filterText = filter.get().trim(); @@ -47,7 +46,6 @@ public void initWidgets() { }; table = add(theme.table()).expandX().widget(); - initTable(); } @@ -59,7 +57,7 @@ private void initTable() { String name = Names.get(statusEffect); if (!StringUtils.containsIgnoreCase(name, filterText)) continue; - table.add(theme.itemWithLabel(getPotionStack(statusEffect), name)).expandCellX(); + table.add(theme.label(name)).expandCellX(); WIntEdit level = theme.intEdit(setting.get().getInt(statusEffect), 0, Integer.MAX_VALUE, true); level.action = () -> { @@ -71,10 +69,4 @@ private void initTable() { table.row(); } } - - private ItemStack getPotionStack(StatusEffect effect) { - ItemStack potion = Items.POTION.getDefaultStack(); - potion.getOrCreateNbt().putInt("CustomPotionColor", effect.getColor()); - return potion; - } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectListSettingScreen.java index 39ba69ed93..d9687c73af 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectListSettingScreen.java @@ -10,8 +10,11 @@ import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.utils.misc.Names; import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionUtil; import net.minecraft.registry.Registries; import java.util.List; @@ -33,7 +36,7 @@ protected String getValueName(StatusEffect value) { private ItemStack getPotionStack(StatusEffect effect) { ItemStack potion = Items.POTION.getDefaultStack(); - potion.getOrCreateNbt().putInt("CustomPotionColor", effect.getColor()); + potion.getOrCreateNbt().putInt("CustomPotionColor", PotionUtil.getColor(new Potion(new StatusEffectInstance(effect)))); return potion; } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/tabs/Tabs.java b/src/main/java/meteordevelopment/meteorclient/gui/tabs/Tabs.java index 704eb5989e..237466fcc4 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/tabs/Tabs.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/tabs/Tabs.java @@ -6,8 +6,6 @@ package meteordevelopment.meteorclient.gui.tabs; import meteordevelopment.meteorclient.gui.tabs.builtin.*; -import meteordevelopment.meteorclient.pathing.BaritoneUtils; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.utils.PreInit; import java.util.ArrayList; @@ -16,7 +14,7 @@ public class Tabs { private static final List tabs = new ArrayList<>(); - @PreInit(dependencies = PathManagers.class) + @PreInit public static void init() { add(new ModulesTab()); add(new ConfigTab()); @@ -25,10 +23,7 @@ public static void init() { add(new FriendsTab()); add(new MacrosTab()); add(new ProfilesTab()); - - if (PathManagers.get().getSettings().get().sizeGroups() > 0) { - add(new PathManagerTab()); - } + add(new BaritoneTab()); } public static void add(Tab tab) { diff --git a/src/main/java/meteordevelopment/meteorclient/pathing/BaritoneSettings.java b/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/BaritoneTab.java similarity index 92% rename from src/main/java/meteordevelopment/meteorclient/pathing/BaritoneSettings.java rename to src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/BaritoneTab.java index cc790ceec5..6514ee493f 100644 --- a/src/main/java/meteordevelopment/meteorclient/pathing/BaritoneSettings.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/BaritoneTab.java @@ -3,13 +3,19 @@ * Copyright (c) Meteor Development. */ -package meteordevelopment.meteorclient.pathing; +package meteordevelopment.meteorclient.gui.tabs.builtin; import baritone.api.BaritoneAPI; import baritone.api.utils.SettingsUtil; +import meteordevelopment.meteorclient.gui.GuiTheme; +import meteordevelopment.meteorclient.gui.tabs.Tab; +import meteordevelopment.meteorclient.gui.tabs.TabScreen; +import meteordevelopment.meteorclient.gui.tabs.WindowTabScreen; +import meteordevelopment.meteorclient.gui.widgets.input.WTextBox; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import net.minecraft.block.Block; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.item.Item; import java.awt.*; @@ -20,50 +26,20 @@ import java.util.List; import java.util.Map; -public class BaritoneSettings implements IPathManager.ISettings { - private final Settings settings = new Settings(); - - private Setting walkOnWater, walkOnLava; - private Setting step, noFall; - - public BaritoneSettings() { - createWrappers(); - } - - @Override - public Settings get() { - return settings; - } - - @Override - public Setting getWalkOnWater() { - return walkOnWater; - } - - @Override - public Setting getWalkOnLava() { - return walkOnLava; - } +public class BaritoneTab extends Tab { + private static Settings settings; + private static Map descriptions; - @Override - public Setting getStep() { - return step; + public BaritoneTab() { + super("Baritone"); } - @Override - public Setting getNoFall() { - return noFall; - } - - @Override - public void save() { - SettingsUtil.save(BaritoneAPI.getSettings()); - } + @SuppressWarnings("unchecked") + private static Settings getSettings() { + if (settings != null) return settings; - // Wrappers + settings = new Settings(); - @SuppressWarnings({"rawtypes", "unchecked"}) - private void createWrappers() { SettingGroup sgBool = settings.createGroup("Checkboxes"); SettingGroup sgDouble = settings.createGroup("Numbers"); SettingGroup sgInt = settings.createGroup("Whole Numbers"); @@ -75,7 +51,6 @@ private void createWrappers() { try { Class klass = BaritoneAPI.getSettings().getClass(); - for (Field field : klass.getDeclaredFields()) { Object obj = field.get(BaritoneAPI.getSettings()); if (!(obj instanceof baritone.api.Settings.Setting setting)) continue; @@ -83,7 +58,7 @@ private void createWrappers() { Object value = setting.value; if (value instanceof Boolean) { - Setting wrapper = sgBool.add(new BoolSetting.Builder() + sgBool.add(new BoolSetting.Builder() .name(setting.getName()) .description(getDescription(setting.getName())) .defaultValue((boolean) setting.defaultValue) @@ -91,14 +66,7 @@ private void createWrappers() { .onModuleActivated(booleanSetting -> booleanSetting.set((Boolean) setting.value)) .build() ); - - switch (wrapper.name) { - case "assumeWalkOnWater" -> walkOnWater = wrapper; - case "assumeWalkOnLava" -> walkOnLava = wrapper; - case "assumeStep" -> step = wrapper; - } - } - else if (value instanceof Double) { + } else if (value instanceof Double) { sgDouble.add(new DoubleSetting.Builder() .name(setting.getName()) .description(getDescription(setting.getName())) @@ -107,8 +75,7 @@ else if (value instanceof Double) { .onModuleActivated(doubleSetting -> doubleSetting.set((Double) setting.value)) .build() ); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { sgDouble.add(new DoubleSetting.Builder() .name(setting.getName()) .description(getDescription(setting.getName())) @@ -117,9 +84,8 @@ else if (value instanceof Float) { .onModuleActivated(doubleSetting -> doubleSetting.set(((Float) setting.value).doubleValue())) .build() ); - } - else if (value instanceof Integer) { - Setting wrapper = sgInt.add(new IntSetting.Builder() + } else if (value instanceof Integer) { + sgInt.add(new IntSetting.Builder() .name(setting.getName()) .description(getDescription(setting.getName())) .defaultValue((int) setting.defaultValue) @@ -127,18 +93,7 @@ else if (value instanceof Integer) { .onModuleActivated(integerSetting -> integerSetting.set((Integer) setting.value)) .build() ); - - if (wrapper.name.equals("maxFallHeightNoWater")) { - noFall = new BoolSetting.Builder() - .name(wrapper.name) - .description(wrapper.description) - .defaultValue(false) - .onChanged(aBoolean -> wrapper.set(aBoolean ? 159159 : wrapper.getDefaultValue())) - .onModuleActivated(booleanSetting -> booleanSetting.set(wrapper.get() >= 255)) - .build(); - } - } - else if (value instanceof Long) { + } else if (value instanceof Long) { sgInt.add(new IntSetting.Builder() .name(setting.getName()) .description(getDescription(setting.getName())) @@ -147,8 +102,7 @@ else if (value instanceof Long) { .onModuleActivated(integerSetting -> integerSetting.set(((Long) setting.value).intValue())) .build() ); - } - else if (value instanceof String) { + } else if (value instanceof String) { sgString.add(new StringSetting.Builder() .name(setting.getName()) .description(getDescription(setting.getName())) @@ -157,8 +111,7 @@ else if (value instanceof String) { .onModuleActivated(stringSetting -> stringSetting.set((String) setting.value)) .build() ); - } - else if (value instanceof Color) { + } else if (value instanceof Color) { Color c = (Color) setting.value; sgColor.add(new ColorSetting.Builder() @@ -169,8 +122,7 @@ else if (value instanceof Color) { .onModuleActivated(colorSetting -> colorSetting.set(new SettingColor(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()))) .build() ); - } - else if (value instanceof List) { + } else if (value instanceof List) { Type listType = ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; Type type = ((ParameterizedType) listType).getActualTypeArguments()[0]; @@ -183,8 +135,7 @@ else if (value instanceof List) { .onModuleActivated(blockListSetting -> blockListSetting.set((List) setting.value)) .build() ); - } - else if (type == Item.class) { + } else if (type == Item.class) { sgItemLists.add(new ItemListSetting.Builder() .name(setting.getName()) .description(getDescription(setting.getName())) @@ -196,15 +147,22 @@ else if (type == Item.class) { } } } + } catch (IllegalAccessException e) { + e.printStackTrace(); } - catch (IllegalAccessException e) { - throw new RuntimeException(e); - } + + return settings; } - // Descriptions + @Override + public TabScreen createScreen(GuiTheme theme) { + return new BaritoneScreen(theme, this); + } - private static Map descriptions; + @Override + public boolean isScreen(Screen screen) { + return screen instanceof BaritoneScreen; + } private static void addDescription(String settingName, String description) { descriptions.put(settingName.toLowerCase(), description); @@ -216,6 +174,33 @@ private static String getDescription(String settingName) { return descriptions.get(settingName.toLowerCase()); } + private static class BaritoneScreen extends WindowTabScreen { + public BaritoneScreen(GuiTheme theme, Tab tab) { + super(theme, tab); + + getSettings().onActivated(); + } + + @Override + public void initWidgets() { + WTextBox filter = add(theme.textBox("")).minWidth(400).expandX().widget(); + filter.setFocused(true); + filter.action = () -> { + clear(); + + add(filter); + add(theme.settings(getSettings(), filter.get().trim())).expandX(); + }; + + add(theme.settings(getSettings(), filter.get().trim())).expandX(); + } + + @Override + protected void onClosed() { + SettingsUtil.save(BaritoneAPI.getSettings()); + } + } + private static void loadDescriptions() { descriptions = new HashMap<>(); addDescription("acceptableThrowawayItems", "Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)"); diff --git a/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/PathManagerTab.java b/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/PathManagerTab.java deleted file mode 100644 index d2fd0ade51..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/PathManagerTab.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.gui.tabs.builtin; - -import meteordevelopment.meteorclient.gui.GuiTheme; -import meteordevelopment.meteorclient.gui.tabs.Tab; -import meteordevelopment.meteorclient.gui.tabs.TabScreen; -import meteordevelopment.meteorclient.gui.tabs.WindowTabScreen; -import meteordevelopment.meteorclient.gui.widgets.input.WTextBox; -import meteordevelopment.meteorclient.pathing.PathManagers; -import net.minecraft.client.gui.screen.Screen; - -public class PathManagerTab extends Tab { - public PathManagerTab() { - super(PathManagers.get().getName()); - } - - @Override - public TabScreen createScreen(GuiTheme theme) { - return new PathManagerScreen(theme, this); - } - - @Override - public boolean isScreen(Screen screen) { - return screen instanceof PathManagerScreen; - } - - private static class PathManagerScreen extends WindowTabScreen { - public PathManagerScreen(GuiTheme theme, Tab tab) { - super(theme, tab); - - PathManagers.get().getSettings().get().onActivated(); - } - - @Override - public void initWidgets() { - WTextBox filter = add(theme.textBox("")).minWidth(400).expandX().widget(); - filter.setFocused(true); - filter.action = () -> { - clear(); - - add(filter); - add(theme.settings(PathManagers.get().getSettings().get(), filter.get().trim())).expandX(); - }; - - add(theme.settings(PathManagers.get().getSettings().get(), filter.get().trim())).expandX(); - } - - @Override - protected void onClosed() { - PathManagers.get().getSettings().save(); - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItemWithLabel.java b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItemWithLabel.java index d41771301a..26d3c4ce85 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItemWithLabel.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/widgets/WItemWithLabel.java @@ -14,8 +14,6 @@ import java.util.List; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class WItemWithLabel extends WHorizontalList { private ItemStack itemStack; private String name; @@ -40,13 +38,13 @@ private String getStringToAppend() { if (itemStack.getItem() == Items.POTION) { List effects = PotionUtil.getPotion(itemStack).getEffects(); - if (!effects.isEmpty()) { + if (effects.size() > 0) { str += " "; StatusEffectInstance effect = effects.get(0); - if (effect.getAmplifier() > 0) str += "%d ".formatted(effect.getAmplifier() + 1); + if (effect.getAmplifier() > 0) str += effect.getAmplifier() + 1 + " "; - str += "(%s)".formatted(StatusEffectUtil.getDurationText(effect, 1, mc.world != null ? mc.world.getTickManager().getTickRate() : 20.0F).getString()); + str += "(" + StatusEffectUtil.getDurationText(effect, 1).getString() + ")"; } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/widgets/input/WTextBox.java b/src/main/java/meteordevelopment/meteorclient/gui/widgets/input/WTextBox.java index 61846c92cb..dd44393eb6 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/widgets/input/WTextBox.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/widgets/input/WTextBox.java @@ -319,24 +319,25 @@ else if (cursor != selectionStart || cursor != selectionEnd) { return true; } else if (key == GLFW_KEY_DELETE) { + if (cursor < text.length()) { if (cursor == selectionStart && cursor == selectionEnd) { - if (cursor < text.length()) { - String preText = text; + String preText = text; - int count = mods == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_ALT : MinecraftClient.IS_SYSTEM_MAC ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL) - ? text.length() - cursor - : (mods == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_CONTROL : GLFW_MOD_ALT)) - ? countToNextSpace(false) - : 1; + int count = mods == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_ALT : MinecraftClient.IS_SYSTEM_MAC ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL) + ? text.length() - cursor + : (mods == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_CONTROL : GLFW_MOD_ALT)) + ? countToNextSpace(false) + : 1; - text = text.substring(0, cursor) + text.substring(cursor + count); + text = text.substring(0, cursor) + text.substring(cursor + count); - if (!text.equals(preText)) runAction(); - } + if (!text.equals(preText)) runAction(); } else { clearSelection(); } + } + return true; } else if (key == GLFW_KEY_LEFT) { diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/AbstractClientPlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/AbstractClientPlayerEntityMixin.java index 9f0d700cb3..a5945c409f 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/AbstractClientPlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/AbstractClientPlayerEntityMixin.java @@ -6,8 +6,11 @@ package meteordevelopment.meteorclient.mixin; import meteordevelopment.meteorclient.utils.misc.FakeClientPlayer; +import meteordevelopment.meteorclient.utils.network.Capes; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -17,6 +20,12 @@ @Mixin(AbstractClientPlayerEntity.class) public class AbstractClientPlayerEntityMixin { + @Inject(method = "getCapeTexture", at = @At("HEAD"), cancellable = true) + private void onGetCapeTexture(CallbackInfoReturnable info) { + Identifier id = Capes.get((PlayerEntity) (Object) this); + if (id != null) info.setReturnValue(id); + } + // Player model rendering in main menu @Inject(method = "getPlayerListEntry", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/AttributeContainerMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/AttributeContainerMixin.java deleted file mode 100644 index cad576fb1e..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/AttributeContainerMixin.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import meteordevelopment.meteorclient.mixininterface.IAttributeContainer; -import meteordevelopment.meteorclient.mixininterface.IEntityAttributeInstance; -import net.minecraft.entity.attribute.AttributeContainer; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeInstance; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import java.util.Map; -import java.util.Set; - -@Mixin(AttributeContainer.class) -public abstract class AttributeContainerMixin implements IAttributeContainer { - @Shadow @Final private Map custom; - @Shadow @Final private Set tracked; - - @Override - public void meteor$copyFrom(AttributeContainer other) { - for (var otherInstance : ((AttributeContainerMixin) (Object) other).custom.values()) { - @Nullable EntityAttributeInstance instance = custom.get(otherInstance.getAttribute()); - if (instance != null) { - ((IEntityAttributeInstance) instance).meteor$copyFrom(otherInstance); - } else { - custom.put(otherInstance.getAttribute(), otherInstance); - if (otherInstance.getAttribute().isTracked()) tracked.add(otherInstance); - } - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BookEditScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BookEditScreenMixin.java index 5a2491bed4..ab937ccd9d 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BookEditScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BookEditScreenMixin.java @@ -9,7 +9,10 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.BookEditScreen; import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.nbt.*; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtIo; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtString; import net.minecraft.text.Text; import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Final; @@ -84,7 +87,7 @@ private void onInit(CallbackInfo info) { DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes)); try { - NbtCompound tag = NbtIo.readCompressed(in, NbtSizeTracker.ofUnlimitedBytes()); + NbtCompound tag = NbtIo.read(in); NbtList listTag = tag.getList("pages", 8).copy(); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BookScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BookScreenMixin.java index b66e8e7575..36e9eb5cde 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BookScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BookScreenMixin.java @@ -8,7 +8,6 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream; import meteordevelopment.meteorclient.gui.GuiThemes; import meteordevelopment.meteorclient.gui.screens.EditBookTitleAndAuthorScreen; -import meteordevelopment.meteorclient.utils.player.ChatUtils; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.BookScreen; import net.minecraft.client.gui.widget.ButtonWidget; @@ -21,8 +20,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Hand; import org.lwjgl.glfw.GLFW; -import org.lwjgl.system.MemoryStack; -import org.lwjgl.system.MemoryUtil; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -66,17 +63,7 @@ private void onInit(CallbackInfo info) { e.printStackTrace(); } - String encoded = Base64.getEncoder().encodeToString(bytes.array); - - @SuppressWarnings("resource") - long available = MemoryStack.stackGet().getPointer(); - long size = MemoryUtil.memLengthUTF8(encoded, true); - - if (size > available) { - ChatUtils.error("Could not copy to clipboard: Out of memory."); - } else { - GLFW.glfwSetClipboardString(mc.getWindow().getHandle(), encoded); - } + GLFW.glfwSetClipboardString(mc.getWindow().getHandle(), Base64.getEncoder().encodeToString(bytes.array)); }) .position(4, 4) .size(120, 20) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/CapeFeatureRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/CapeFeatureRendererMixin.java deleted file mode 100644 index 4e9368a904..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/CapeFeatureRendererMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import meteordevelopment.meteorclient.utils.network.Capes; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.feature.CapeFeatureRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(CapeFeatureRenderer.class) -public class CapeFeatureRendererMixin { - @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SkinTextures;capeTexture()Lnet/minecraft/util/Identifier;")) - private Identifier modifyCapeTexture(Identifier original, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, AbstractClientPlayerEntity abstractClientPlayerEntity, float f, float g, float h, float j, float k, float l) { - Identifier id = Capes.get(abstractClientPlayerEntity); - return id == null ? original : id; - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java index 77f38556ca..9f194d731a 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java @@ -31,7 +31,9 @@ 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.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @@ -116,12 +118,12 @@ private void onAddMessage(Text message, @Nullable MessageSignatureData signature } } - //modify max lengths for messages and visible messages - @ModifyConstant(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", constant = @Constant(intValue = 100)) - private int maxLength(int size) { - if (Modules.get() == null || !getBetterChat().isLongerChat()) return size; - - return size + betterChat.getExtraChatLines(); + @ModifyExpressionValue(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", + slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/hud/ChatHud;visibleMessages:Ljava/util/List;")), at = @At(value = "INVOKE", target = "Ljava/util/List;size()I")) + private int addMessageListSizeProxy(int size) { + BetterChat betterChat = getBetterChat(); + if (betterChat.isLongerChat() && betterChat.getChatLength() >= 100) return size - betterChat.getChatLength(); + return size; } // Player Heads @@ -149,20 +151,16 @@ private MessageIndicator onRender_modifyIndicator(MessageIndicator indicator) { @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;isChatFocused()Z"), locals = LocalCapture.CAPTURE_FAILSOFT) private void onBreakChatMessageLines(Text message, MessageSignatureData signature, int ticks, MessageIndicator indicator, boolean refresh, CallbackInfo ci, int i, List list) { - if (Modules.get() == null) return; // baritone calls addMessage before we initialise - getBetterChat().lines.add(0, list.size()); } @Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/hud/ChatHud;messages:Ljava/util/List;")), at = @At(value = "INVOKE", target = "Ljava/util/List;remove(I)Ljava/lang/Object;")) private void onRemoveMessage(Text message, MessageSignatureData signature, int ticks, MessageIndicator indicator, boolean refresh, CallbackInfo ci) { - if (Modules.get() == null) return; - - int extra = getBetterChat().isLongerChat() ? getBetterChat().getExtraChatLines() : 0; - int size = betterChat.lines.size(); + BetterChat betterChat = getBetterChat(); + int size = betterChat.lines.size() - (betterChat.isLongerChat() && betterChat.getChatLength() >= 100 ? betterChat.getChatLength() : 0); - while (size > 100 + extra) { + while (size > 100) { betterChat.lines.removeInt(size - 1); size--; } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ChatScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ChatScreenMixin.java index 379cfb8868..e0a3086f69 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ChatScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ChatScreenMixin.java @@ -15,11 +15,11 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(value = ChatScreen.class, priority = 1001) +@Mixin(ChatScreen.class) public abstract class ChatScreenMixin { @Shadow protected TextFieldWidget chatField; - @Inject(method = "init", at = @At(value = "RETURN")) + @Inject(method = "init", at = @At(value = "TAIL")) private void onInit(CallbackInfo info) { if (Modules.get().get(BetterChat.class).isInfiniteChatBox()) chatField.setMaxLength(Integer.MAX_VALUE); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ChunkBorderDebugRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ChunkBorderDebugRendererMixin.java deleted file mode 100644 index fa0bb28354..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ChunkBorderDebugRendererMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.render.Freecam; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.debug.ChunkBorderDebugRenderer; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.ChunkSectionPos; -import net.minecraft.util.math.MathHelper; -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; - -@Mixin(ChunkBorderDebugRenderer.class) -public class ChunkBorderDebugRendererMixin { - @Shadow - @Final - private MinecraftClient client; - - @ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getChunkPos()Lnet/minecraft/util/math/ChunkPos;")) - private ChunkPos render$getChunkPos(ChunkPos chunkPos) { - Freecam freecam = Modules.get().get(Freecam.class); - if (!freecam.isActive()) return chunkPos; - - float delta = client.getTickDelta(); - - return new ChunkPos( - ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getX(delta))), - ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getZ(delta))) - ); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java index ddbf0dc837..47592eca6a 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.mixin; +import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; import io.netty.handler.proxy.Socks4ProxyHandler; @@ -20,8 +21,7 @@ import meteordevelopment.meteorclient.systems.proxies.Proxy; import net.minecraft.network.ClientConnection; import net.minecraft.network.NetworkSide; -import net.minecraft.network.handler.PacketEncoderException; -import net.minecraft.network.handler.PacketSizeLogger; +import net.minecraft.network.PacketEncoderException; import net.minecraft.network.listener.ClientPlayPacketListener; import net.minecraft.network.listener.PacketListener; import net.minecraft.network.packet.Packet; @@ -59,8 +59,8 @@ private void disconnect(Text disconnectReason, CallbackInfo ci) { } } - @Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At("HEAD")) - private static void onConnect(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable cir) { + @Inject(method = "connect", at = @At("HEAD")) + private static void onConnect(InetSocketAddress address, boolean useEpoll, CallbackInfoReturnable cir) { MeteorClient.EVENT_BUS.post(ServerConnectEndEvent.get(address)); } @@ -84,7 +84,7 @@ private void exceptionCaught(ChannelHandlerContext context, Throwable throwable, } @Inject(method = "addHandlers", at = @At("RETURN")) - private static void onAddHandlers(ChannelPipeline pipeline, NetworkSide side, PacketSizeLogger packetSizeLogger, CallbackInfo ci) { + private static void onAddHandlers(ChannelPipeline pipeline, NetworkSide side, CallbackInfo ci) { if (side != NetworkSide.CLIENTBOUND) return; Proxy proxy = Proxies.get().getEnabled(); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java index 2e51e27d72..57bc791247 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java @@ -19,22 +19,19 @@ import meteordevelopment.meteorclient.events.packets.PlaySoundPacketEvent; import meteordevelopment.meteorclient.events.world.ChunkDataEvent; import meteordevelopment.meteorclient.mixininterface.IExplosionS2CPacket; -import meteordevelopment.meteorclient.pathing.BaritoneUtils; import meteordevelopment.meteorclient.systems.config.Config; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.movement.Velocity; import meteordevelopment.meteorclient.systems.modules.render.NoRender; import meteordevelopment.meteorclient.utils.player.ChatUtils; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientCommonNetworkHandler; -import net.minecraft.client.network.ClientConnectionState; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; -import net.minecraft.network.ClientConnection; import net.minecraft.network.packet.s2c.play.*; import net.minecraft.world.chunk.WorldChunk; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -43,7 +40,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ClientPlayNetworkHandler.class) -public abstract class ClientPlayNetworkHandlerMixin extends ClientCommonNetworkHandler { +public abstract class ClientPlayNetworkHandlerMixin { + @Shadow + @Final + private MinecraftClient client; @Shadow private ClientWorld world; @@ -53,13 +53,8 @@ public abstract class ClientPlayNetworkHandlerMixin extends ClientCommonNetworkH @Unique private boolean ignoreChatMessage; - @Unique private boolean worldNotNull; - protected ClientPlayNetworkHandlerMixin(MinecraftClient client, ClientConnection connection, ClientConnectionState connectionState) { - super(client, connection, connectionState); - } - @Inject(method = "onEntitySpawn", at = @At("HEAD"), cancellable = true) private void onEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo info) { if (packet != null && packet.getEntityType() != null) { @@ -83,12 +78,6 @@ private void onGameJoinTail(GameJoinS2CPacket packet, CallbackInfo info) { MeteorClient.EVENT_BUS.post(GameJoinedEvent.get()); } - // the server sends a GameJoin packet after the reconfiguration phase - @Inject(method = "onEnterReconfiguration", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER)) - private void onEnterReconfiguration(EnterReconfigurationS2CPacket packet, CallbackInfo info) { - MeteorClient.EVENT_BUS.post(GameLeftEvent.get()); - } - @Inject(method = "onPlaySound", at = @At("HEAD")) private void onPlaySound(PlaySoundS2CPacket packet, CallbackInfo info) { MeteorClient.EVENT_BUS.post(PlaySoundPacketEvent.get(packet)); @@ -96,7 +85,7 @@ private void onPlaySound(PlaySoundS2CPacket packet, CallbackInfo info) { @Inject(method = "onChunkData", at = @At("TAIL")) private void onChunkData(ChunkDataS2CPacket packet, CallbackInfo info) { - WorldChunk chunk = client.world.getChunk(packet.getChunkX(), packet.getChunkZ()); + WorldChunk chunk = client.world.getChunk(packet.getX(), packet.getZ()); MeteorClient.EVENT_BUS.post(ChunkDataEvent.get(chunk)); } @@ -141,7 +130,7 @@ private void onItemPickupAnimation(ItemPickupAnimationS2CPacket packet, Callback private void onSendChatMessage(String message, CallbackInfo ci) { if (ignoreChatMessage) return; - if (!message.startsWith(Config.get().prefix.get()) && (BaritoneUtils.IS_AVAILABLE || !message.startsWith(BaritoneUtils.getPrefix()))) { + if (!message.startsWith(Config.get().prefix.get()) && !message.startsWith(BaritoneAPI.getSettings().prefix.value)) { SendMessageEvent event = MeteorClient.EVENT_BUS.post(SendMessageEvent.get(message)); if (!event.isCancelled()) { diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java index c971bd64c4..35bad2d758 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java @@ -74,7 +74,7 @@ private void onPushOutOfBlocks(double x, double d, CallbackInfo info) { @Inject(method = "damage", at = @At("HEAD")) private void onDamage(DamageSource source, float amount, CallbackInfoReturnable info) { - if (Utils.canUpdate() && getWorld().isClient && canTakeDamage()) MeteorClient.EVENT_BUS.post(DamageEvent.get(this, source)); + if (Utils.canUpdate() && getWorld().isClient && canTakeDamage()) MeteorClient.EVENT_BUS.post(DamageEvent.get(this, source, amount)); } @ModifyConstant(method = "canSprint", constant = @Constant(floatValue = 6.0f)) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientWorldMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientWorldMixin.java index 106d8a1d4b..e2b441b389 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientWorldMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientWorldMixin.java @@ -34,8 +34,8 @@ public abstract class ClientWorldMixin { @Shadow @Nullable public abstract Entity getEntityById(int id); - @Inject(method = "addEntity", at = @At("TAIL")) - private void onAddEntity(Entity entity, CallbackInfo info) { + @Inject(method = "addEntityPrivate", at = @At("TAIL")) + private void onAddEntityPrivate(int id, Entity entity, CallbackInfo info) { if (entity != null) MeteorClient.EVENT_BUS.post(EntityAddedEvent.get(entity)); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ConnectScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ConnectScreenMixin.java index fac824368d..2fd47394c5 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ConnectScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ConnectScreenMixin.java @@ -8,7 +8,7 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.ServerConnectBeginEvent; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; +import net.minecraft.client.gui.screen.ConnectScreen; import net.minecraft.client.network.ServerAddress; import net.minecraft.client.network.ServerInfo; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadC2SPacketAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadC2SPacketAccessor.java new file mode 100644 index 0000000000..6ca12566e4 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadC2SPacketAccessor.java @@ -0,0 +1,26 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(CustomPayloadC2SPacket.class) +public interface CustomPayloadC2SPacketAccessor { + @Accessor("channel") + Identifier getChannel(); + + @Accessor("data") + PacketByteBuf getData(); + + @Mutable + @Accessor("data") + void setData(PacketByteBuf data); +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadS2CPacketMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadS2CPacketMixin.java index 01a3ff3fef..553e0fe18e 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadS2CPacketMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/CustomPayloadS2CPacketMixin.java @@ -7,15 +7,15 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.misc.AntiPacketKick; -import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket; +import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; @Mixin(CustomPayloadS2CPacket.class) public class CustomPayloadS2CPacketMixin { - @ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576)) - private static int maxValue(int value) { + @ModifyConstant(method = "", constant = @Constant(intValue = 1048576)) + private int maxValue(int value) { return Modules.get().isActive(AntiPacketKick.class) ? Integer.MAX_VALUE : value; } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/DefaultSkinHelperMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/DefaultSkinHelperMixin.java index a710fc3c87..1eec65c6d7 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/DefaultSkinHelperMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/DefaultSkinHelperMixin.java @@ -16,7 +16,7 @@ @Mixin(DefaultSkinHelper.class) public class DefaultSkinHelperMixin { // Player model rendering in main menu - @Inject(method = "getSkinTextures(Ljava/util/UUID;)Lnet/minecraft/client/util/SkinTextures;", at = @At("HEAD"), cancellable = true) + @Inject(method = "getSkin", at = @At("HEAD"), cancellable = true) private static void onShouldUseSlimModel(UUID uuid, CallbackInfoReturnable info) { if (uuid == null) info.setReturnValue(false); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/DisconnectedScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/DisconnectedScreenMixin.java index 44d87fbacc..7e93545d24 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/DisconnectedScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/DisconnectedScreenMixin.java @@ -7,16 +7,17 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.misc.AutoReconnect; -import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; +import net.minecraft.client.gui.screen.ConnectScreen; import net.minecraft.client.gui.screen.DisconnectedScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.TitleScreen; import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.gui.widget.DirectionalLayoutWidget; +import net.minecraft.client.gui.widget.GridWidget; +import net.minecraft.client.network.ServerAddress; +import net.minecraft.client.network.ServerInfo; +import net.minecraft.client.resource.language.I18n; import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -27,9 +28,6 @@ @Mixin(DisconnectedScreen.class) public abstract class DisconnectedScreenMixin extends Screen { - @Shadow - @Final - private DirectionalLayoutWidget grid; @Unique private ButtonWidget reconnectBtn; @Unique private double time = Modules.get().get(AutoReconnect.class).time.get() * 20; @@ -37,15 +35,14 @@ protected DisconnectedScreenMixin(Text title) { super(title); } - @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/DirectionalLayoutWidget;refreshPositions()V", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) - private void addButtons(CallbackInfo ci, ButtonWidget buttonWidget) { + @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget;refreshPositions()V", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) + private void addButtons(CallbackInfo info, GridWidget.Adder adder) { AutoReconnect autoReconnect = Modules.get().get(AutoReconnect.class); if (autoReconnect.lastServerConnection != null) { - reconnectBtn = new ButtonWidget.Builder(Text.literal(getText()), button -> tryConnecting()).build(); - grid.add(reconnectBtn); + reconnectBtn = adder.add(new ButtonWidget.Builder(Text.literal(getText()), button -> tryConnecting()).build()); - grid.add( + adder.add( new ButtonWidget.Builder(Text.literal("Toggle Auto Reconnect"), button -> { autoReconnect.toggle(); reconnectBtn.setMessage(Text.literal(getText())); @@ -68,14 +65,12 @@ public void tick() { } } - @Unique private String getText() { String reconnectText = "Reconnect"; if (Modules.get().isActive(AutoReconnect.class)) reconnectText += " " + String.format("(%.1f)", time / 20); return reconnectText; } - @Unique private void tryConnecting() { var lastServer = Modules.get().get(AutoReconnect.class).lastServerConnection; ConnectScreen.connect(new TitleScreen(), mc, lastServer.left(), lastServer.right(), false); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ElytraFeatureRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ElytraFeatureRendererMixin.java deleted file mode 100644 index 4fd5c52c9e..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ElytraFeatureRendererMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import meteordevelopment.meteorclient.utils.network.Capes; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.feature.ElytraFeatureRenderer; -import net.minecraft.client.render.entity.feature.FeatureRenderer; -import net.minecraft.client.render.entity.feature.FeatureRendererContext; -import net.minecraft.client.render.entity.model.EntityModel; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.LivingEntity; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(ElytraFeatureRenderer.class) -public abstract class ElytraFeatureRendererMixin> extends FeatureRenderer { - public ElytraFeatureRendererMixin(FeatureRendererContext context) { - super(context); - } - - @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/LivingEntity;FFFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SkinTextures;capeTexture()Lnet/minecraft/util/Identifier;")) - private Identifier modifyCapeTexture(Identifier original, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, T livingEntity, float f, float g, float h, float j, float k, float l) { - if (!(livingEntity instanceof AbstractClientPlayerEntity playerEntity)) return original; - - Identifier id = Capes.get(playerEntity); - return id == null ? original : id; - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/EntityAttributeInstanceMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/EntityAttributeInstanceMixin.java deleted file mode 100644 index 58cf2eb80c..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/EntityAttributeInstanceMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import meteordevelopment.meteorclient.mixininterface.IEntityAttributeInstance; -import net.minecraft.entity.attribute.EntityAttributeInstance; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -@Mixin(EntityAttributeInstance.class) -public abstract class EntityAttributeInstanceMixin implements IEntityAttributeInstance { - @Shadow @Final private Map idToModifiers; - @Shadow @Final private Set persistentModifiers; - @Shadow public abstract Set getModifiers(EntityAttributeModifier.Operation operation); - @Shadow protected abstract void onUpdate(); - - @Override - public void meteor$copyFrom(EntityAttributeInstance other) { - for (var modifier : other.getModifiers()) { - @Nullable EntityAttributeModifier old = idToModifiers.put(modifier.getId(), modifier); - if (old != null) { - getModifiers(old.getOperation()).remove(old); - persistentModifiers.remove(old); - } - getModifiers(modifier.getOperation()).add(modifier); - } - onUpdate(); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java index 74e4af8f4f..13991eab93 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java @@ -13,7 +13,6 @@ import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.combat.Hitboxes; -import meteordevelopment.meteorclient.systems.modules.movement.Flight; import meteordevelopment.meteorclient.systems.modules.movement.NoFall; import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; import meteordevelopment.meteorclient.systems.modules.movement.Velocity; @@ -59,20 +58,17 @@ private Vec3d updateMovementInFluidFluidStateGetVelocity(Vec3d vec) { @Inject(method = "isTouchingWater", at = @At(value = "HEAD"), cancellable = true) private void isTouchingWater(CallbackInfoReturnable info) { - if ((Object) this == mc.player && Modules.get().get(Flight.class).isActive()) info.setReturnValue(false); if ((Object) this == mc.player && Modules.get().get(NoSlow.class).fluidDrag()) info.setReturnValue(false); } @Inject(method = "isInLava", at = @At(value = "HEAD"), cancellable = true) private void isInLava(CallbackInfoReturnable info) { - if ((Object) this == mc.player && Modules.get().get(Flight.class).isActive()) info.setReturnValue(false); if ((Object) this == mc.player && Modules.get().get(NoSlow.class).fluidDrag()) info.setReturnValue(false); } @ModifyExpressionValue(method = "updateSwimming", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isSubmergedInWater()Z")) private boolean isSubmergedInWater(boolean submerged) { if ((Object) this == mc.player && Modules.get().get(NoSlow.class).fluidDrag()) return false; - if ((Object) this == mc.player && Modules.get().get(Flight.class).isActive()) return false; return submerged; } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/EntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/EntityRendererMixin.java index d7d227aedc..b97663704e 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/EntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/EntityRendererMixin.java @@ -22,7 +22,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.world.LightType; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -52,12 +51,7 @@ private void shouldRender(T entity, Frustum frustum, double x, double y, double @ModifyReturnValue(method = "getSkyLight", at = @At("RETURN")) private int onGetSkyLight(int original) { - return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.SKY), original); - } - - @ModifyReturnValue(method = "getBlockLight", at = @At("RETURN")) - private int onGetBlockLight(int original) { - return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.BLOCK), original); + return Math.max(Modules.get().get(Fullbright.class).getLuminance(), original); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/FileCacheAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/FileCacheAccessor.java deleted file mode 100644 index 3683e21f81..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/FileCacheAccessor.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import net.minecraft.client.texture.PlayerSkinProvider; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.nio.file.Path; - -@Mixin(PlayerSkinProvider.FileCache.class) -public interface FileCacheAccessor { - @Accessor - Path getDirectory(); -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java index da6f192634..23fe559f8a 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java @@ -53,7 +53,7 @@ public abstract class GameRendererMixin { @Unique private Renderer3D renderer; @Inject(method = "renderWorld", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", args = { "ldc=hand" }), locals = LocalCapture.CAPTURE_FAILEXCEPTION) - private void onRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo ci, boolean bl, Camera camera, Entity entity, MatrixStack matrixStack, double d, float f, float g, Matrix4f matrix4f, Matrix3f matrix3f) { + private void onRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info, boolean bl, Camera camera, MatrixStack matrixStack, double d, float f, float g, Matrix4f matrix4f, Matrix3f matrix3f) { if (!Utils.canUpdate()) return; client.getProfiler().push(MeteorClient.MOD_ID + "_render"); @@ -169,7 +169,7 @@ private void renderHand(MatrixStack matrices, Camera camera, float tickDelta, Ca info.cancel(); } - @ModifyConstant(method = "updateTargetedEntity", constant = @Constant(doubleValue = 6)) + @ModifyConstant(method = "updateTargetedEntity", constant = @Constant(doubleValue = 3)) private double updateTargetedEntityModifySurvivalReach(double d) { return Modules.get().get(Reach.class).entityReach(); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java index 63d613eeec..c7d4630c92 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java @@ -6,7 +6,6 @@ package meteordevelopment.meteorclient.mixin; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.data.TrackedData; import net.minecraft.fluid.Fluid; import net.minecraft.registry.tag.TagKey; import org.spongepowered.asm.mixin.Mixin; @@ -26,14 +25,4 @@ public interface LivingEntityAccessor { @Accessor("jumpingCooldown") void setJumpCooldown(int cooldown); - - @Accessor("POTION_SWIRLS_COLOR") - static TrackedData meteor$getPotionSwirlsColor() { - throw new AssertionError(); - } - - @Accessor("POTION_SWIRLS_AMBIENT") - static TrackedData meteor$getPotionSwirlsAmbient() { - throw new AssertionError(); - } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java index 5b5f763453..b4bccd5aa8 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java @@ -54,7 +54,7 @@ public LivingEntityMixin(EntityType type, World world) { @Inject(method = "damage", at = @At("HEAD")) private void onDamageHead(DamageSource source, float amount, CallbackInfoReturnable info) { if (Utils.canUpdate() && getWorld().isClient) - MeteorClient.EVENT_BUS.post(DamageEvent.get((LivingEntity) (Object) this, source)); + MeteorClient.EVENT_BUS.post(DamageEvent.get((LivingEntity) (Object) this, source, amount)); } @ModifyReturnValue(method = "canWalkOnFluid", at = @At("RETURN")) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java index a69f012d37..21263b00e1 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java @@ -22,7 +22,6 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.scoreboard.AbstractTeam; -import net.minecraft.scoreboard.Team; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -67,8 +66,8 @@ public float changePitch(float oldValue, LivingEntity entity) { // Player model rendering in main menu - @ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getScoreboardTeam()Lnet/minecraft/scoreboard/Team;")) - private Team hasLabelClientPlayerEntityGetScoreboardTeamProxy(Team team) { + @ModifyExpressionValue(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getScoreboardTeam()Lnet/minecraft/scoreboard/AbstractTeam;")) + private AbstractTeam hasLabelClientPlayerEntityGetScoreboardTeamProxy(AbstractTeam team) { return (mc.player == null) ? null : team; } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java index 48ad6bacdd..cdc94cc8fd 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java @@ -7,22 +7,20 @@ import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mojang.authlib.minecraft.UserApiService; -import com.mojang.authlib.yggdrasil.ProfileResult; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.SocialInteractionsManager; +import net.minecraft.client.report.AbuseReportContext; import net.minecraft.client.resource.ResourceReloadLogger; -import net.minecraft.client.session.ProfileKeys; -import net.minecraft.client.session.Session; -import net.minecraft.client.session.report.AbuseReportContext; import net.minecraft.client.texture.PlayerSkinProvider; +import net.minecraft.client.util.ProfileKeys; +import net.minecraft.client.util.Session; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; import java.net.Proxy; -import java.util.concurrent.CompletableFuture; @Mixin(MinecraftClient.class) public interface MinecraftClientAccessor { @@ -74,8 +72,4 @@ static int getFps() { @Mutable @Accessor("abuseReportContext") void setAbuseReportContext(AbuseReportContext abuseReportContext); - - @Mutable - @Accessor("gameProfileFuture") - void setGameProfileFuture(CompletableFuture future); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientMixin.java index 94c0bad093..02bdc0cc4b 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientMixin.java @@ -141,7 +141,7 @@ private HitResult doItemUseMinecraftClientCrosshairTargetProxy(HitResult origina return MeteorClient.EVENT_BUS.post(ItemUseCrosshairTargetEvent.get(original)).target; } - @ModifyReturnValue(method = "reloadResources(ZLnet/minecraft/client/MinecraftClient$LoadingContext;)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN")) + @ModifyReturnValue(method = "reloadResources(Z)Ljava/util/concurrent/CompletableFuture;", at = @At("RETURN")) private CompletableFuture onReloadResourcesNewCompletableFuture(CompletableFuture original) { return original.thenRun(() -> MeteorClient.EVENT_BUS.post(ResourcePacksReloadedEvent.get())); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PacketByteBufMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PacketByteBufMixin.java index 2a6083c6bf..78401930af 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PacketByteBufMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PacketByteBufMixin.java @@ -7,16 +7,16 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.misc.AntiPacketKick; -import net.minecraft.nbt.NbtSizeTracker; +import net.minecraft.nbt.NbtTagSizeTracker; import net.minecraft.network.PacketByteBuf; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(PacketByteBuf.class) -public abstract class PacketByteBufMixin { - @ModifyArg(method = "readNbt()Lnet/minecraft/nbt/NbtCompound;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;readNbt(Lnet/minecraft/nbt/NbtSizeTracker;)Lnet/minecraft/nbt/NbtElement;")) - private NbtSizeTracker xlPackets(NbtSizeTracker sizeTracker) { - return Modules.get().isActive(AntiPacketKick.class) ? NbtSizeTracker.ofUnlimitedBytes() : sizeTracker; +public class PacketByteBufMixin { + @ModifyArg(method = "readNbt()Lnet/minecraft/nbt/NbtCompound;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;readNbt(Lnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtCompound;")) + private NbtTagSizeTracker xlPackets(NbtTagSizeTracker sizeTracker) { + return Modules.get().isActive(AntiPacketKick.class) ? NbtTagSizeTracker.EMPTY : sizeTracker; } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java index 434a79f3d7..ea35d8defe 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java @@ -30,7 +30,7 @@ private void modifyRenderLayer(Args args, MatrixStack matrices, VertexConsumerPr Chams chams = Modules.get().get(Chams.class); if (chams.isActive() && chams.hand.get()) { - Identifier texture = chams.handTexture.get() ? player.playerListEntry.getSkinTextures().texture() : Chams.BLANK; + Identifier texture = chams.handTexture.get() ? player.getSkinTexture() : Chams.BLANK; args.set(1, vertexConsumers.getBuffer(RenderLayer.getEntityTranslucent(texture))); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListEntryMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListEntryMixin.java index f040007d03..7c5a0c1068 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListEntryMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerListEntryMixin.java @@ -11,7 +11,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.util.DefaultSkinHelper; -import net.minecraft.client.util.SkinTextures; +import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -23,11 +23,11 @@ public abstract class PlayerListEntryMixin { @Shadow public abstract GameProfile getProfile(); - @Inject(method = "getSkinTextures", at = @At("HEAD"), cancellable = true) - private void onGetTexture(CallbackInfoReturnable info) { + @Inject(method = "getSkinTexture", at = @At("HEAD"), cancellable = true) + private void onGetTexture(CallbackInfoReturnable info) { if (getProfile().getName().equals(MinecraftClient.getInstance().getSession().getUsername())) { if (Modules.get().get(NameProtect.class).skinProtect()) { - info.setReturnValue(DefaultSkinHelper.getSkinTextures(getProfile())); + info.setReturnValue(DefaultSkinHelper.getTexture()); } } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerSkinProviderAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerSkinProviderAccessor.java index 88660357dd..5f2dc2f56e 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerSkinProviderAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerSkinProviderAccessor.java @@ -9,8 +9,10 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import java.io.File; + @Mixin(PlayerSkinProvider.class) public interface PlayerSkinProviderAccessor { - @Accessor("skinCache") - PlayerSkinProvider.FileCache getSkinCache(); + @Accessor("skinCacheDir") + File getSkinCacheDir(); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/RaycastContextMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/RaycastContextMixin.java index 659dc3160d..8bd300912b 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/RaycastContextMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/RaycastContextMixin.java @@ -21,7 +21,7 @@ public class RaycastContextMixin implements IRaycastContext { @Shadow @Final @Mutable private Vec3d end; @Shadow @Final @Mutable private RaycastContext.ShapeType shapeType; @Shadow @Final @Mutable private RaycastContext.FluidHandling fluid; - @Shadow @Final @Mutable private ShapeContext shapeContext; + @Shadow @Final @Mutable private ShapeContext entityPosition; @Override public void set(Vec3d start, Vec3d end, RaycastContext.ShapeType shapeType, RaycastContext.FluidHandling fluidHandling, Entity entity) { @@ -29,6 +29,6 @@ public void set(Vec3d start, Vec3d end, RaycastContext.ShapeType shapeType, Rayc this.end = end; this.shapeType = shapeType; this.fluid = fluidHandling; - this.shapeContext = ShapeContext.of(entity); + this.entityPosition = ShapeContext.of(entity); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/RegistriesMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/RegistriesMixin.java deleted file mode 100644 index 625ec10ba5..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/RegistriesMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import net.minecraft.registry.Registries; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.function.Supplier; - -@Mixin(Registries.class) -public abstract class RegistriesMixin { - @Redirect(method = "create(Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/registry/MutableRegistry;Lnet/minecraft/registry/Registries$Initializer;Lcom/mojang/serialization/Lifecycle;)Lnet/minecraft/registry/MutableRegistry;", at = @At(value = "INVOKE", target = "Lnet/minecraft/Bootstrap;ensureBootstrapped(Ljava/util/function/Supplier;)V")) - private static void ignoreBootstrap(Supplier callerGetter) { - // nothing - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ScreenMixin.java index 3fb6f8ecc2..b5dd66cd0d 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ScreenMixin.java @@ -9,10 +9,8 @@ import meteordevelopment.meteorclient.commands.Commands; import meteordevelopment.meteorclient.systems.config.Config; import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.movement.GUIMove; import meteordevelopment.meteorclient.systems.modules.render.NoRender; import meteordevelopment.meteorclient.utils.Utils; -import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Style; import org.spongepowered.asm.mixin.Mixin; @@ -21,13 +19,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.List; - -import static net.minecraft.client.util.InputUtil.*; - @Mixin(value = Screen.class, priority = 500) // needs to be before baritone public abstract class ScreenMixin { - @Inject(method = "renderBackground", at = @At("HEAD"), cancellable = true) + @Inject(method = "renderBackground(Lnet/minecraft/client/gui/DrawContext;)V", at = @At("HEAD"), cancellable = true) private void onRenderBackground(CallbackInfo info) { if (Utils.canUpdate() && Modules.get().get(NoRender.class).noGuiBackground()) info.cancel(); @@ -44,14 +38,4 @@ private void onRunCommand(Style style, CallbackInfoReturnable cir) { } } } - - @Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true) - private void onKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable info) { - if ((Object) (this) instanceof ChatScreen) return; - GUIMove guiMove = Modules.get().get(GUIMove.class); - List arrows = List.of(GLFW_KEY_RIGHT, GLFW_KEY_LEFT, GLFW_KEY_DOWN, GLFW_KEY_UP); - if ((guiMove.disableArrows() && arrows.contains(keyCode)) || (guiMove.disableSpace() && keyCode == GLFW_KEY_SPACE)) { - info.cancel(); - } - } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerEntityAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerEntityAccessor.java deleted file mode 100644 index 715dfab8b5..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerEntityAccessor.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin; - -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.data.TrackedData; -import net.minecraft.entity.mob.ShulkerEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(ShulkerEntity.class) -public interface ShulkerEntityAccessor { - @Accessor("PEEK_AMOUNT") - static TrackedData meteor$getPeekAmount() { - throw new AssertionError(); - } - - @Accessor("COVERED_ARMOR_BONUS") - static EntityAttributeModifier meteor$getCoveredArmorBonus() { - throw new AssertionError(); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/SimpleRegistryMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/SimpleRegistryMixin.java new file mode 100644 index 0000000000..aca4582354 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/SimpleRegistryMixin.java @@ -0,0 +1,22 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import net.minecraft.registry.SimpleRegistry; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.function.Supplier; + +@Mixin(SimpleRegistry.class) +public class SimpleRegistryMixin { + @Redirect(method = "(Lnet/minecraft/registry/RegistryKey;Lcom/mojang/serialization/Lifecycle;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/Bootstrap;ensureBootstrapped(Ljava/util/function/Supplier;)V")) + private void idk(Supplier callerGetter) { + // TODO: Probably extremely retarded but seems to work + // nothing :trolla: + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java index 5baabf8289..c6538a7396 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java @@ -17,7 +17,6 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.LightType; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -128,11 +127,6 @@ private void onRenderEndSkyDraw(MatrixStack matrices, CallbackInfo info) { @ModifyVariable(method = "getLightmapCoordinates(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "STORE"), ordinal = 0) private static int getLightmapCoordinatesModifySkyLight(int sky) { - return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.SKY), sky); - } - - @ModifyVariable(method = "getLightmapCoordinates(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "STORE"), ordinal = 1) - private static int getLightmapCoordinatesModifyBlockLight(int sky) { - return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.BLOCK), sky); + return Math.max(Modules.get().get(Fullbright.class).getLuminance(), sky); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/YggdrasilMinecraftSessionServiceAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/YggdrasilMinecraftSessionServiceAccessor.java index 16ab642ec2..36dc719950 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/YggdrasilMinecraftSessionServiceAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/YggdrasilMinecraftSessionServiceAccessor.java @@ -6,17 +6,15 @@ package meteordevelopment.meteorclient.mixin; import com.mojang.authlib.Environment; -import com.mojang.authlib.yggdrasil.ServicesKeySet; +import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -import java.net.Proxy; - @Mixin(YggdrasilMinecraftSessionService.class) public interface YggdrasilMinecraftSessionServiceAccessor { @Invoker("") - static YggdrasilMinecraftSessionService createYggdrasilMinecraftSessionService(final ServicesKeySet servicesKeySet, final Proxy proxy, final Environment env) { + static YggdrasilMinecraftSessionService createYggdrasilMinecraftSessionService(final YggdrasilAuthenticationService service, final Environment env) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/indigo/AoCalculatorMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/indigo/AoCalculatorMixin.java deleted file mode 100644 index 2d74602f34..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixin/indigo/AoCalculatorMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixin.indigo; - -import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.render.Fullbright; -import net.fabricmc.fabric.impl.client.indigo.renderer.aocalc.AoCalculator; -import net.minecraft.world.LightType; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(AoCalculator.class) -public class AoCalculatorMixin { - @ModifyVariable(method = "getLightmapCoordinates(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "STORE"), ordinal = 0) - private static int getLightmapCoordinatesModifySkyLight(int sky) { - return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.SKY), sky); - } - - @ModifyVariable(method = "getLightmapCoordinates(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)I", at = @At(value = "STORE"), ordinal = 1) - private static int getLightmapCoordinatesModifyBlockLight(int sky) { - return Math.max(Modules.get().get(Fullbright.class).getLuminance(LightType.BLOCK), sky); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/lithium/ChunkAwareBlockCollisionSweeperMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/lithium/ChunkAwareBlockCollisionSweeperMixin.java index 0152627779..eb15d0e2b1 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/lithium/ChunkAwareBlockCollisionSweeperMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/lithium/ChunkAwareBlockCollisionSweeperMixin.java @@ -21,7 +21,7 @@ @Mixin(value = ChunkAwareBlockCollisionSweeper.class) public abstract class ChunkAwareBlockCollisionSweeperMixin { - @Redirect(method = "computeNext()Lnet/minecraft/util/shape/VoxelShape;", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;")) + @Redirect(method = "computeNext", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;")) private VoxelShape onComputeNextCollisionBox(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { VoxelShape shape = state.getCollisionShape(world, pos, context); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBiomeColorCacheMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBiomeColorCacheMixin.java index 92af282d68..3f147c8e58 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBiomeColorCacheMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumBiomeColorCacheMixin.java @@ -25,17 +25,17 @@ private void onInit(CallbackInfo info) { ambience = Modules.get().get(Ambience.class); } - @ModifyExpressionValue(method = "getColor(Lme/jellysquid/mods/sodium/client/world/biome/BiomeColorSource;III)I", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/world/biome/BiomeColorCache;getColor(Lnet/minecraft/world/biome/ColorResolver;III)I", ordinal = 0, remap = true)) + @ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getGrassColorAt(DD)I", remap = true)) private int modify_getGrassColorAt(int color) { return ambience.isActive() && ambience.customGrassColor.get() ? ambience.grassColor.get().getPacked() : color; } - @ModifyExpressionValue(method = "getColor(Lme/jellysquid/mods/sodium/client/world/biome/BiomeColorSource;III)I", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/world/biome/BiomeColorCache;getColor(Lnet/minecraft/world/biome/ColorResolver;III)I", ordinal = 1, remap = true)) + @ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getFoliageColor()I", remap = true)) private int modify_getFoliageColor(int color) { return ambience.isActive() && ambience.customFoliageColor.get() ? ambience.foliageColor.get().getPacked() : color; } - @ModifyExpressionValue(method = "getColor(Lme/jellysquid/mods/sodium/client/world/biome/BiomeColorSource;III)I", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/world/biome/BiomeColorCache;getColor(Lnet/minecraft/world/biome/ColorResolver;III)I", ordinal = 2, remap = true)) + @ModifyExpressionValue(method = "updateColorBuffers", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/Biome;getWaterColor()I", remap = true)) private int modify_getWaterColor(int color) { return ambience.isActive() && ambience.customWaterColor.get() ? ambience.waterColor.get().getPacked() : color; } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumFluidRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumFluidRendererMixin.java index 2ac8a24812..1eb4dbc141 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumFluidRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumFluidRendererMixin.java @@ -14,7 +14,6 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.render.Xray; import meteordevelopment.meteorclient.systems.modules.world.Ambience; -import meteordevelopment.meteorclient.utils.render.color.Color; import net.caffeinemc.mods.sodium.api.util.ColorABGR; import net.minecraft.fluid.FluidState; import net.minecraft.registry.tag.FluidTags; @@ -32,8 +31,7 @@ @Mixin(value = FluidRenderer.class, remap = false) public class SodiumFluidRendererMixin { - @Final - @Shadow + @Final @Shadow private int[] quadColors; @Unique @@ -55,8 +53,7 @@ private void onRender(WorldSlice world, FluidState fluidState, BlockPos blockPos private void onUpdateQuad(ModelQuadView quad, WorldSlice world, BlockPos pos, LightPipeline lighter, Direction dir, float brightness, ColorProvider colorProvider, FluidState fluidState, CallbackInfo info) { // Ambience if (ambience.isActive() && ambience.customLavaColor.get() && fluidState.isIn(FluidTags.LAVA)) { - Color c = ambience.lavaColor.get(); - Arrays.fill(quadColors, ColorABGR.pack(c.r, c.g, c.b, c.a)); + Arrays.fill(quadColors, ColorABGR.withAlpha(ambience.lavaColor.get().getPacked(), 255)); } } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumLightDataAccessMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumLightDataAccessMixin.java index 215bd3de49..e70755b1f8 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumLightDataAccessMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/sodium/SodiumLightDataAccessMixin.java @@ -12,7 +12,6 @@ import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockRenderView; -import net.minecraft.world.LightType; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -35,13 +34,9 @@ public class SodiumLightDataAccessMixin { @Unique private Xray xray; - @Unique - private Fullbright fb; - @Inject(method = "", at = @At("TAIL")) private void onInit(CallbackInfo info) { xray = Modules.get().get(Xray.class); - fb = Modules.get().get(Fullbright.class); } @ModifyVariable(method = "compute", at = @At(value = "TAIL"), name = "bl") @@ -54,15 +49,8 @@ private int compute_modifyBL(int light) { return light; } - // fullbright - - @ModifyVariable(method = "compute", at = @At(value = "STORE"), name = "sl") - private int compute_assignSL(int sl) { - return Math.max(fb.getLuminance(LightType.SKY), sl); - } - - @ModifyVariable(method = "compute", at = @At(value = "STORE"), name = "bl") - private int compute_assignBL(int bl) { - return Math.max(fb.getLuminance(LightType.BLOCK), bl); + @ModifyVariable(method = "compute", at = @At(value = "TAIL"), name = "sl") + private int compute_modifySL(int light) { + return Math.max(Modules.get().get(Fullbright.class).getLuminance(), light); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixininterface/IAttributeContainer.java b/src/main/java/meteordevelopment/meteorclient/mixininterface/IAttributeContainer.java deleted file mode 100644 index 019578179c..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixininterface/IAttributeContainer.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixininterface; - -import net.minecraft.entity.attribute.AttributeContainer; -import net.minecraft.entity.attribute.EntityAttributeInstance; - -public interface IAttributeContainer { - /** - * Copy the {@link EntityAttributeInstance} of the other {@link AttributeContainer} into this one, copying their modifiers if there's a duplicate - */ - void meteor$copyFrom(AttributeContainer other); -} diff --git a/src/main/java/meteordevelopment/meteorclient/mixininterface/IEntityAttributeInstance.java b/src/main/java/meteordevelopment/meteorclient/mixininterface/IEntityAttributeInstance.java deleted file mode 100644 index 558a0a42cc..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/mixininterface/IEntityAttributeInstance.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.mixininterface; - -import net.minecraft.entity.attribute.EntityAttributeInstance; - -public interface IEntityAttributeInstance { - /** - * Adds the modifiers of the other {@link EntityAttributeInstance} to this one, replacing them if there's a duplicate - */ - void meteor$copyFrom(EntityAttributeInstance other); -} diff --git a/src/main/java/meteordevelopment/meteorclient/pathing/BaritonePathManager.java b/src/main/java/meteordevelopment/meteorclient/pathing/BaritonePathManager.java deleted file mode 100644 index 408c7288f0..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/pathing/BaritonePathManager.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.pathing; - -import baritone.api.BaritoneAPI; -import baritone.api.pathing.goals.Goal; -import baritone.api.pathing.goals.GoalGetToBlock; -import baritone.api.pathing.goals.GoalXZ; -import baritone.api.process.IBaritoneProcess; -import baritone.api.process.PathingCommand; -import baritone.api.process.PathingCommandType; -import baritone.api.utils.Rotation; -import baritone.api.utils.SettingsUtil; -import meteordevelopment.meteorclient.MeteorClient; -import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.orbit.EventHandler; -import meteordevelopment.orbit.EventPriority; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; - -import java.lang.invoke.MethodHandles; -import java.lang.invoke.VarHandle; -import java.lang.reflect.Field; -import java.util.function.Predicate; - -import static meteordevelopment.meteorclient.MeteorClient.mc; - -public class BaritonePathManager implements IPathManager { - private final VarHandle rotationField; - private final BaritoneSettings settings; - - private GoalDirection directionGoal; - private boolean pathingPaused; - - public BaritonePathManager() { - // Subscribe to event bus - MeteorClient.EVENT_BUS.subscribe(this); - - // Find rotation field - Class klass = BaritoneAPI.getProvider().getPrimaryBaritone().getLookBehavior().getClass(); - VarHandle rotationField = null; - - for (Field field : klass.getDeclaredFields()) { - if (field.getType() == Rotation.class) { - try { - rotationField = MethodHandles.lookup().unreflectVarHandle(field); - break; - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - this.rotationField = rotationField; - - // Create settings - settings = new BaritoneSettings(); - - // Baritone pathing control - BaritoneAPI.getProvider().getPrimaryBaritone().getPathingControlManager().registerProcess(new BaritoneProcess()); - } - - @Override - public String getName() { - return "Baritone"; - } - - @Override - public boolean isPathing() { - return BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing(); - } - - @Override - public void pause() { - pathingPaused = true; - } - - @Override - public void resume() { - pathingPaused = false; - } - - @Override - public void stop() { - BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); - } - - @Override - public void moveTo(BlockPos pos, boolean ignoreY) { - if (ignoreY) { - BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(pos.getX(), pos.getZ())); - return; - } - - BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalGetToBlock(pos)); - } - - @Override - public void moveInDirection(float yaw) { - directionGoal = new GoalDirection(yaw); - BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(directionGoal); - } - - @Override - public void mine(Block... blocks) { - BaritoneAPI.getProvider().getPrimaryBaritone().getMineProcess().mine(blocks); - } - - @Override - public void follow(Predicate entity) { - BaritoneAPI.getProvider().getPrimaryBaritone().getFollowProcess().follow(entity); - } - - @Override - public float getTargetYaw() { - Rotation rotation = (Rotation) rotationField.get(BaritoneAPI.getProvider().getPrimaryBaritone().getLookBehavior()); - return rotation == null ? 0 : rotation.getYaw(); - } - - @Override - public float getTargetPitch() { - Rotation rotation = (Rotation) rotationField.get(BaritoneAPI.getProvider().getPrimaryBaritone().getLookBehavior()); - return rotation == null ? 0 : rotation.getPitch(); - } - - @Override - public ISettings getSettings() { - return settings; - } - - @EventHandler(priority = EventPriority.HIGHEST) - private void onTick(TickEvent.Pre event) { - if (directionGoal == null) return; - - if (directionGoal != BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().getGoal()) { - directionGoal = null; - return; - } - - directionGoal.tick(); - } - - private static class GoalDirection implements Goal { - private static final double SQRT_2 = Math.sqrt(2); - - private final float yaw; - private int x; - private int z; - - private int timer; - - public GoalDirection(float yaw) { - this.yaw = yaw; - tick(); - } - - public static double calculate(double xDiff, double zDiff) { - double x = Math.abs(xDiff); - double z = Math.abs(zDiff); - double straight; - double diagonal; - if (x < z) { - straight = z - x; - diagonal = x; - } else { - straight = x - z; - diagonal = z; - } - - diagonal *= SQRT_2; - return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.value; - } - - public void tick() { - if (timer > 20) { - timer = 0; - - Vec3d pos = mc.player.getPos(); - float theta = (float) Math.toRadians(yaw); - - x = (int) Math.floor(pos.x - (double) MathHelper.sin(theta) * 100); - z = (int) Math.floor(pos.z + (double) MathHelper.cos(theta) * 100); - } - - timer++; - } - - public boolean isInGoal(int x, int y, int z) { - return x == this.x && z == this.z; - } - - public double heuristic(int x, int y, int z) { - int xDiff = x - this.x; - int zDiff = z - this.z; - return calculate(xDiff, zDiff); - } - - public String toString() { - return String.format("GoalXZ{x=%s,z=%s}", SettingsUtil.maybeCensor(this.x), SettingsUtil.maybeCensor(this.z)); - } - - public int getX() { - return this.x; - } - - public int getZ() { - return this.z; - } - } - - private class BaritoneProcess implements IBaritoneProcess { - @Override - public boolean isActive() { - return pathingPaused; - } - - @Override - public PathingCommand onTick(boolean b, boolean b1) { - BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().clearAllKeys(); - return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); - } - - @Override - public boolean isTemporary() { - return true; - } - - @Override - public void onLostControl() { - } - - @Override - public double priority() { - return 0d; - } - - @Override - public String displayName0() { - return "Meteor Client"; - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/pathing/BaritoneUtils.java b/src/main/java/meteordevelopment/meteorclient/pathing/BaritoneUtils.java deleted file mode 100644 index 7830aafad9..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/pathing/BaritoneUtils.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.pathing; - -import baritone.api.BaritoneAPI; - -public class BaritoneUtils { - public static boolean IS_AVAILABLE = false; - - public static String getPrefix() { - if (IS_AVAILABLE) { - return BaritoneAPI.getSettings().prefix.value; - } - - return ""; - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/pathing/IPathManager.java b/src/main/java/meteordevelopment/meteorclient/pathing/IPathManager.java deleted file mode 100644 index 77e5344612..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/pathing/IPathManager.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.pathing; - -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.Settings; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; - -import java.util.function.Predicate; - -public interface IPathManager { - String getName(); - - boolean isPathing(); - - void pause(); - void resume(); - void stop(); - - default void moveTo(BlockPos pos) { moveTo(pos, false); } - void moveTo(BlockPos pos, boolean ignoreY); - void moveInDirection(float yaw); - - void mine(Block... blocks); - - void follow(Predicate entity); - - float getTargetYaw(); - float getTargetPitch(); - - ISettings getSettings(); - - interface ISettings { - Settings get(); - - Setting getWalkOnWater(); - Setting getWalkOnLava(); - - Setting getStep(); - Setting getNoFall(); - - void save(); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/pathing/NopPathManager.java b/src/main/java/meteordevelopment/meteorclient/pathing/NopPathManager.java deleted file mode 100644 index dc2ab84d21..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/pathing/NopPathManager.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.pathing; - -import meteordevelopment.meteorclient.settings.BoolSetting; -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.Settings; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; - -import java.util.function.Predicate; - -public class NopPathManager implements IPathManager { - private final NopSettings settings = new NopSettings(); - - @Override - public String getName() { - return "none"; - } - - @Override - public boolean isPathing() { - return false; - } - - @Override - public void pause() {} - - @Override - public void resume() {} - - @Override - public void stop() {} - - @Override - public void moveTo(BlockPos pos, boolean ignoreY) {} - - @Override - public void moveInDirection(float yaw) {} - - @Override - public void mine(Block... blocks) {} - - @Override - public void follow(Predicate entity) {} - - @Override - public float getTargetYaw() { - return 0; - } - - @Override - public float getTargetPitch() { - return 0; - } - - @Override - public ISettings getSettings() { - return settings; - } - - private static class NopSettings implements ISettings { - private final Settings settings = new Settings(); - private final Setting setting = new BoolSetting.Builder().build(); - - @Override - public Settings get() { - return settings; - } - - @Override - public Setting getWalkOnWater() { - setting.reset(); - return setting; - } - - @Override - public Setting getWalkOnLava() { - setting.reset(); - return setting; - } - - @Override - public Setting getStep() { - setting.reset(); - return setting; - } - - @Override - public Setting getNoFall() { - setting.reset(); - return setting; - } - - @Override - public void save() {} - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/pathing/PathManagers.java b/src/main/java/meteordevelopment/meteorclient/pathing/PathManagers.java deleted file mode 100644 index d7f9ebf45d..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/pathing/PathManagers.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.pathing; - -import meteordevelopment.meteorclient.MeteorClient; -import meteordevelopment.meteorclient.utils.PreInit; - -import java.lang.reflect.InvocationTargetException; - -public class PathManagers { - private static IPathManager INSTANCE = new NopPathManager(); - - public static IPathManager get() { - return INSTANCE; - } - - @PreInit - public static void init() { - if (exists("meteordevelopment.voyager.PathManager")) { - try { - INSTANCE = (IPathManager) Class.forName("meteordevelopment.voyager.PathManager").getConstructor().newInstance(); - } catch (InstantiationException | IllegalAccessException | InvocationTargetException | - NoSuchMethodException | ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - if (exists("baritone.api.BaritoneAPI")) { - BaritoneUtils.IS_AVAILABLE = true; - - if (INSTANCE instanceof NopPathManager) - INSTANCE = new BaritonePathManager(); - } - - MeteorClient.LOG.info("Path Manager: {}", INSTANCE.getName()); - } - - private static boolean exists(String name) { - try { - Class.forName(name); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/Fonts.java b/src/main/java/meteordevelopment/meteorclient/renderer/Fonts.java index d14498f0cc..d59b1677b3 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/Fonts.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/Fonts.java @@ -56,10 +56,7 @@ public static void refresh() { } public static void load(FontFace fontFace) { - if (RENDERER != null) { - if (RENDERER.fontFace.equals(fontFace)) return; - else RENDERER.destroy(); - } + if (RENDERER != null && RENDERER.fontFace.equals(fontFace)) return; try { RENDERER = new CustomTextRenderer(fontFace); diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/GL.java b/src/main/java/meteordevelopment/meteorclient/renderer/GL.java index 6047ac64c9..19526684bd 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/GL.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/GL.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.renderer; +import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.platform.GlStateManager; import meteordevelopment.meteorclient.mixin.BufferRendererAccessor; import meteordevelopment.meteorclient.mixininterface.ICapabilityTracker; @@ -17,7 +18,6 @@ import java.lang.reflect.Field; import java.nio.ByteBuffer; import java.nio.FloatBuffer; -import java.util.List; import static meteordevelopment.meteorclient.MeteorClient.mc; import static org.lwjgl.opengl.GL32C.*; @@ -133,7 +133,7 @@ public static int createShader(int type) { } public static void shaderSource(int shader, String source) { - GlStateManager.glShaderSource(shader, List.of(source)); + GlStateManager.glShaderSource(shader, ImmutableList.of(source)); } public static String compileShader(int shader) { @@ -338,7 +338,8 @@ private static ICapabilityTracker getTracker(String fieldName) { capStateField.setAccessible(true); return (ICapabilityTracker) capStateField.get(state); } catch (NoSuchFieldException | IllegalAccessException e) { - throw new IllegalStateException("Could not find GL state tracker '" + fieldName + "'", e); + e.printStackTrace(); + return null; } } } diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java b/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java index 4ac1b2a396..930ea6044e 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/Mesh.java @@ -103,7 +103,7 @@ public void destroy() { } public void begin() { - if (building) throw new IllegalStateException("Mesh.begin() called while already building."); + if (building) throw new IllegalStateException("Mesh.end() called while already building."); verticesPointer = verticesPointerStart; vertexI = 0; diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/Shader.java b/src/main/java/meteordevelopment/meteorclient/renderer/Shader.java index dd3cf4aecc..46d308cde9 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/Shader.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/Shader.java @@ -61,7 +61,8 @@ private String read(String path) { try { return IOUtils.toString(mc.getResourceManager().getResource(new MeteorIdentifier("shaders/" + path)).get().getInputStream(), StandardCharsets.UTF_8); } catch (IOException e) { - throw new IllegalStateException("Could not read shader '" + path + "'", e); + e.printStackTrace(); + return ""; } } diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/text/CharData.java b/src/main/java/meteordevelopment/meteorclient/renderer/text/CharData.java new file mode 100644 index 0000000000..b2ea63aed9 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/renderer/text/CharData.java @@ -0,0 +1,24 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.renderer.text; + +public class CharData { + public final float x0, y0, x1, y1; + public final float u0, v0, u1, v1; + public final float xAdvance; + + public CharData(float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float xAdvance) { + this.x0 = x0; + this.y0 = y0; + this.x1 = x1; + this.y1 = y1; + this.u0 = u0; + this.v0 = v0; + this.u1 = u1; + this.v1 = v1; + this.xAdvance = xAdvance; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/text/CustomTextRenderer.java b/src/main/java/meteordevelopment/meteorclient/renderer/text/CustomTextRenderer.java index 447b17753d..a7c52dac92 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/text/CustomTextRenderer.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/text/CustomTextRenderer.java @@ -11,6 +11,7 @@ import net.minecraft.client.util.math.MatrixStack; import org.lwjgl.BufferUtils; +import java.nio.Buffer; import java.nio.ByteBuffer; public class CustomTextRenderer implements TextRenderer { @@ -32,10 +33,11 @@ public CustomTextRenderer(FontFace fontFace) { this.fontFace = fontFace; byte[] bytes = Utils.readBytes(fontFace.toStream()); - ByteBuffer buffer = BufferUtils.createByteBuffer(bytes.length).put(bytes).flip(); + ByteBuffer buffer = BufferUtils.createByteBuffer(bytes.length).put(bytes); fonts = new Font[5]; for (int i = 0; i < fonts.length; i++) { + ((Buffer) buffer).flip(); fonts[i] = new Font(buffer, (int) Math.round(18 * ((i * 0.5) + 1))); } } @@ -130,8 +132,4 @@ public void end(MatrixStack matrices) { building = false; scale = 1; } - - public void destroy() { - mesh.destroy(); - } } diff --git a/src/main/java/meteordevelopment/meteorclient/renderer/text/Font.java b/src/main/java/meteordevelopment/meteorclient/renderer/text/Font.java index 5a7a71d32f..4489824c15 100644 --- a/src/main/java/meteordevelopment/meteorclient/renderer/text/Font.java +++ b/src/main/java/meteordevelopment/meteorclient/renderer/text/Font.java @@ -5,13 +5,15 @@ package meteordevelopment.meteorclient.renderer.text; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import meteordevelopment.meteorclient.renderer.Mesh; import meteordevelopment.meteorclient.utils.render.ByteTexture; import meteordevelopment.meteorclient.utils.render.color.Color; import net.minecraft.client.texture.AbstractTexture; import org.lwjgl.BufferUtils; -import org.lwjgl.stb.*; +import org.lwjgl.stb.STBTTFontinfo; +import org.lwjgl.stb.STBTTPackContext; +import org.lwjgl.stb.STBTTPackedchar; +import org.lwjgl.stb.STBTruetype; import org.lwjgl.system.MemoryStack; import java.nio.ByteBuffer; @@ -19,11 +21,11 @@ public class Font { public AbstractTexture texture; + private final int height; private final float scale; private final float ascent; - private final Int2ObjectOpenHashMap charMap = new Int2ObjectOpenHashMap<>(); - private final static int size = 2048; + private final CharData[] charData; public Font(ByteBuffer buffer, int height) { this.height = height; @@ -32,37 +34,20 @@ public Font(ByteBuffer buffer, int height) { STBTTFontinfo fontInfo = STBTTFontinfo.create(); STBTruetype.stbtt_InitFont(fontInfo, buffer); - // Allocate buffers - ByteBuffer bitmap = BufferUtils.createByteBuffer(size * size); - STBTTPackedchar.Buffer[] cdata = { - STBTTPackedchar.create(95), // Basic Latin - STBTTPackedchar.create(96), // Latin 1 Supplement - STBTTPackedchar.create(128), // Latin Extended-A - STBTTPackedchar.create(144), // Greek and Coptic - STBTTPackedchar.create(256), // Cyrillic - STBTTPackedchar.create(1) // infinity symbol - }; - - // create and initialise packing context + // Allocate STBTTPackedchar buffer + charData = new CharData[128]; + STBTTPackedchar.Buffer cdata = STBTTPackedchar.create(charData.length); + ByteBuffer bitmap = BufferUtils.createByteBuffer(2048 * 2048); + + // Create font texture STBTTPackContext packContext = STBTTPackContext.create(); - STBTruetype.stbtt_PackBegin(packContext, bitmap, size, size, 0 ,1); - - // create the pack range, populate with the specific packing ranges - STBTTPackRange.Buffer packRange = STBTTPackRange.create(cdata.length); - packRange.put(STBTTPackRange.create().set(height, 32, null, 95, cdata[0], (byte) 2, (byte) 2)); - packRange.put(STBTTPackRange.create().set(height, 160, null, 96, cdata[1], (byte) 2, (byte) 2)); - packRange.put(STBTTPackRange.create().set(height, 256, null, 128, cdata[2], (byte) 2, (byte) 2)); - packRange.put(STBTTPackRange.create().set(height, 880, null, 144, cdata[3], (byte) 2, (byte) 2)); - packRange.put(STBTTPackRange.create().set(height, 1024, null, 256, cdata[4], (byte) 2, (byte) 2)); - packRange.put(STBTTPackRange.create().set(height, 8734, null, 1, cdata[5], (byte) 2, (byte) 2)); // lol - packRange.flip(); - - // write and finish - STBTruetype.stbtt_PackFontRanges(packContext, buffer, 0, packRange); + STBTruetype.stbtt_PackBegin(packContext, bitmap, 2048, 2048, 0, 1); + STBTruetype.stbtt_PackSetOversampling(packContext, 2, 2); + STBTruetype.stbtt_PackFontRange(packContext, buffer, 0, height, 32, cdata); STBTruetype.stbtt_PackEnd(packContext); // Create texture object and get font scale - texture = new ByteTexture(size, size, bitmap, ByteTexture.Format.A, ByteTexture.Filter.Linear, ByteTexture.Filter.Linear); + texture = new ByteTexture(2048, 2048, bitmap, ByteTexture.Format.A, ByteTexture.Filter.Linear, ByteTexture.Filter.Linear); scale = STBTruetype.stbtt_ScaleForPixelHeight(fontInfo, height); // Get font vertical ascent @@ -72,17 +57,14 @@ public Font(ByteBuffer buffer, int height) { this.ascent = ascent.get(0); } - for (int i = 0; i < cdata.length; i++) { - STBTTPackedchar.Buffer cbuf = cdata[i]; - int offset = packRange.get(i).first_unicode_codepoint_in_range(); - - for (int j = 0; j < cbuf.capacity(); j++) { - STBTTPackedchar packedChar = cbuf.get(j); + // Populate charData array + for (int i = 0; i < charData.length; i++) { + STBTTPackedchar packedChar = cdata.get(i); - float ipw = 1f / size; // pixel width and height - float iph = 1f / size; + float ipw = 1f / 2048; + float iph = 1f / 2048; - charMap.put(j + offset, new CharData( + charData[i] = new CharData( packedChar.xoff(), packedChar.yoff(), packedChar.xoff2(), @@ -92,8 +74,7 @@ public Font(ByteBuffer buffer, int height) { packedChar.x1() * ipw, packedChar.y1() * iph, packedChar.xadvance() - )); - } + ); } } @@ -102,8 +83,8 @@ public double getWidth(String string, int length) { for (int i = 0; i < length; i++) { int cp = string.charAt(i); - CharData c = charMap.get(cp); - if (c == null) c = charMap.get(32); + if (cp < 32 || cp > 128) cp = 32; + CharData c = charData[cp - 32]; width += c.xAdvance; } @@ -120,8 +101,8 @@ public double render(Mesh mesh, String string, double x, double y, Color color, for (int i = 0; i < string.length(); i++) { int cp = string.charAt(i); - CharData c = charMap.get(cp); - if (c == null) c = charMap.get(32); + if (cp < 32 || cp > 128) cp = 32; + CharData c = charData[cp - 32]; mesh.quad( mesh.vec2(x + c.x0 * scale, y + c.y0 * scale).vec2(c.u0, c.v0).color(color).next(), @@ -135,6 +116,4 @@ public double render(Mesh mesh, String string, double x, double y, Color color, return x; } - - private record CharData(float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float xAdvance) {} } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/BoolSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/BoolSetting.java index e42351541a..cb21ed7035 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/BoolSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/BoolSetting.java @@ -5,13 +5,14 @@ package meteordevelopment.meteorclient.settings; +import com.google.common.collect.ImmutableList; import net.minecraft.nbt.NbtCompound; import java.util.List; import java.util.function.Consumer; public class BoolSetting extends Setting { - private static final List SUGGESTIONS = List.of("true", "false", "toggle"); + private static final List SUGGESTIONS = ImmutableList.of("true", "false", "toggle"); private BoolSetting(String name, String description, Boolean defaultValue, Consumer onChanged, Consumer> onModuleActivated, IVisible visible) { super(name, description, defaultValue, onChanged, onModuleActivated, visible); diff --git a/src/main/java/meteordevelopment/meteorclient/settings/ColorListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/ColorListSetting.java index eb5c3c2fdc..be39b26039 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/ColorListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/ColorListSetting.java @@ -21,16 +21,8 @@ public ColorListSetting(String name, String description, List defa @Override protected List parseImpl(String str) { - List colors = new ArrayList<>(); - try { - String[] colorsStr = str.replaceAll("\\s+", "").split(";"); - for (String colorStr : colorsStr) { - String[] strs = colorStr.split(","); - colors.add(new SettingColor(Integer.parseInt(strs[0]), Integer.parseInt(strs[1]), Integer.parseInt(strs[2]), Integer.parseInt(strs[3]))); - } - } catch (IndexOutOfBoundsException | NumberFormatException ignored) { - } - return colors; + // TODO: I cba to write a text parser for this + return new ArrayList<>(); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/settings/ColorSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/ColorSetting.java index 47ef146303..644028e36f 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/ColorSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/ColorSetting.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.settings; +import com.google.common.collect.ImmutableList; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import net.minecraft.nbt.NbtCompound; @@ -13,7 +14,7 @@ import java.util.function.Consumer; public class ColorSetting extends Setting { - private static final List SUGGESTIONS = List.of("0 0 0 255", "225 25 25 255", "25 225 25 255", "25 25 225 255", "255 255 255 255"); + private static final List SUGGESTIONS = ImmutableList.of("0 0 0 255", "225 25 25 255", "25 225 25 255", "25 25 225 255", "255 255 255 255"); public ColorSetting(String name, String description, SettingColor defaultValue, Consumer onChanged, Consumer> onModuleActivated, IVisible visible) { super(name, description, defaultValue, onChanged, onModuleActivated, visible); diff --git a/src/main/java/meteordevelopment/meteorclient/settings/EnumSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/EnumSetting.java index 9813d056ef..4838f77c8c 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/EnumSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/EnumSetting.java @@ -7,19 +7,25 @@ import net.minecraft.nbt.NbtCompound; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; public class EnumSetting> extends Setting { - private final T[] values; + private T[] values; private final List suggestions; public EnumSetting(String name, String description, T defaultValue, Consumer onChanged, Consumer> onModuleActivated, IVisible visible) { super(name, description, defaultValue, onChanged, onModuleActivated, visible); - values = (T[]) defaultValue.getClass().getEnumConstants(); + try { + values = (T[]) defaultValue.getClass().getMethod("values").invoke(null); + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + e.printStackTrace(); + } + suggestions = new ArrayList<>(values.length); for (T value : values) suggestions.add(value.toString()); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/System.java b/src/main/java/meteordevelopment/meteorclient/systems/System.java index 60b2fb203d..4f6d6353e1 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/System.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/System.java @@ -10,21 +10,15 @@ import meteordevelopment.meteorclient.utils.misc.ISerializable; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtIo; -import net.minecraft.util.crash.CrashException; -import org.apache.commons.io.FilenameUtils; import java.io.File; import java.io.IOException; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Locale; public abstract class System implements ISerializable { private final String name; private File file; protected boolean isFirstInit; - private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT); public System(String name) { this.name = name; @@ -46,7 +40,7 @@ public void save(File folder) { try { File tempFile = File.createTempFile(MeteorClient.MOD_ID, file.getName()); - NbtIo.write(tag, tempFile.toPath()); + NbtIo.write(tag, tempFile); if (folder != null) file = new File(folder, file.getName()); @@ -70,16 +64,7 @@ public void load(File folder) { if (folder != null) file = new File(folder, file.getName()); if (file.exists()) { - try { - fromTag(NbtIo.read(file.toPath())); - } catch (CrashException e) { - String backupName = FilenameUtils.removeExtension(file.getName()) + "-" + ZonedDateTime.now().format(DATE_TIME_FORMATTER) + ".backup.nbt"; - File backup = new File(file.getParentFile(), backupName); - StreamUtils.copy(file, backup); - MeteorClient.LOG.error("Error loading " + this.name + ". Possibly corrupted?"); - MeteorClient.LOG.info("Saved settings backup to '" + backup + "'."); - e.printStackTrace(); - } + fromTag(NbtIo.read(file)); } } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/Systems.java b/src/main/java/meteordevelopment/meteorclient/systems/Systems.java index 40663b851e..5dae1e4eda 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/Systems.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/Systems.java @@ -5,7 +5,6 @@ package meteordevelopment.meteorclient.systems; -import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.game.GameLeftEvent; import meteordevelopment.meteorclient.systems.accounts.Accounts; @@ -21,12 +20,13 @@ import java.io.File; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; public class Systems { @SuppressWarnings("rawtypes") - private static final Map, System> systems = new Reference2ReferenceOpenHashMap<>(); + private static final Map, System> systems = new HashMap<>(); private static final List preLoadTasks = new ArrayList<>(1); public static void addPreLoadTask(Runnable task) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/Account.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/Account.java index 70ca1ac710..96132e9d55 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/Account.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/accounts/Account.java @@ -10,23 +10,18 @@ import com.mojang.authlib.minecraft.UserApiService; import com.mojang.authlib.yggdrasil.ServicesKeyType; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; -import meteordevelopment.meteorclient.mixin.FileCacheAccessor; import meteordevelopment.meteorclient.mixin.MinecraftClientAccessor; import meteordevelopment.meteorclient.mixin.PlayerSkinProviderAccessor; import meteordevelopment.meteorclient.utils.misc.ISerializable; import meteordevelopment.meteorclient.utils.misc.NbtException; import net.minecraft.client.network.SocialInteractionsManager; -import net.minecraft.client.session.ProfileKeys; -import net.minecraft.client.session.Session; -import net.minecraft.client.session.report.AbuseReportContext; -import net.minecraft.client.session.report.ReporterEnvironment; +import net.minecraft.client.report.AbuseReportContext; +import net.minecraft.client.report.ReporterEnvironment; import net.minecraft.client.texture.PlayerSkinProvider; +import net.minecraft.client.util.ProfileKeys; +import net.minecraft.client.util.Session; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.encryption.SignatureVerifier; -import net.minecraft.util.Util; - -import java.nio.file.Path; -import java.util.concurrent.CompletableFuture; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -67,13 +62,17 @@ public AccountCache getCache() { public static void setSession(Session session) { MinecraftClientAccessor mca = (MinecraftClientAccessor) mc; mca.setSession(session); + mc.getSessionProperties().clear(); UserApiService apiService; - apiService = mca.getAuthenticationService().createUserApiService(session.getAccessToken()); + try { + apiService = mca.getAuthenticationService().createUserApiService(session.getAccessToken()); + } catch (AuthenticationException e) { + apiService = UserApiService.OFFLINE; + } mca.setUserApiService(apiService); mca.setSocialInteractionsManager(new SocialInteractionsManager(mc, apiService)); mca.setProfileKeys(ProfileKeys.create(apiService, session, mc.runDirectory.toPath())); mca.setAbuseReportContext(AbuseReportContext.create(ReporterEnvironment.ofIntegratedServer(), apiService)); - mca.setGameProfileFuture(CompletableFuture.supplyAsync(() -> mc.getSessionService().fetchProfile(mc.getSession().getUuidOrNull(), true), Util.getIoWorkerExecutor())); } public static void applyLoginEnvironment(YggdrasilAuthenticationService authService, MinecraftSessionService sessService) { @@ -81,9 +80,7 @@ public static void applyLoginEnvironment(YggdrasilAuthenticationService authServ mca.setAuthenticationService(authService); SignatureVerifier.create(authService.getServicesKeySet(), ServicesKeyType.PROFILE_KEY); mca.setSessionService(sessService); - PlayerSkinProvider.FileCache skinCache = ((PlayerSkinProviderAccessor) mc.getSkinProvider()).getSkinCache(); - Path skinCachePath = ((FileCacheAccessor) skinCache).getDirectory(); - mca.setSkinProvider(new PlayerSkinProvider(mc.getTextureManager(), skinCachePath, sessService, mc)); + mca.setSkinProvider(new PlayerSkinProvider(mc.getTextureManager(), ((PlayerSkinProviderAccessor) mc.getSkinProvider()).getSkinCacheDir(), sessService)); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/AccountCache.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/AccountCache.java index 8ab88f86be..684cf73437 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/AccountCache.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/accounts/AccountCache.java @@ -5,7 +5,7 @@ package meteordevelopment.meteorclient.systems.accounts; -import com.mojang.util.UndashedUuid; +import com.mojang.util.UUIDTypeAdapter; import meteordevelopment.meteorclient.utils.misc.ISerializable; import meteordevelopment.meteorclient.utils.misc.NbtException; import meteordevelopment.meteorclient.utils.render.PlayerHeadTexture; @@ -23,7 +23,7 @@ public PlayerHeadTexture getHeadTexture() { public void loadHead() { if (uuid == null || uuid.isBlank()) return; - headTexture = PlayerHeadUtils.fetchHead(UndashedUuid.fromStringLenient(uuid)); + headTexture = PlayerHeadUtils.fetchHead(UUIDTypeAdapter.fromString(uuid)); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/CrackedAccount.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/CrackedAccount.java index 6087790b0d..447bb623b5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/CrackedAccount.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/CrackedAccount.java @@ -7,7 +7,7 @@ import meteordevelopment.meteorclient.systems.accounts.Account; import meteordevelopment.meteorclient.systems.accounts.AccountType; -import net.minecraft.client.session.Session; +import net.minecraft.client.util.Session; import net.minecraft.util.Uuids; import java.util.Optional; @@ -28,7 +28,7 @@ public boolean login() { super.login(); cache.loadHead(); - setSession(new Session(name, Uuids.getOfflinePlayerUuid(name), "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG)); + setSession(new Session(name, Uuids.getOfflinePlayerUuid(name).toString(), "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG)); return true; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/EasyMCAccount.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/EasyMCAccount.java index 52b1aeeef7..2731612249 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/EasyMCAccount.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/EasyMCAccount.java @@ -7,13 +7,12 @@ import com.mojang.authlib.Environment; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; -import com.mojang.util.UndashedUuid; import meteordevelopment.meteorclient.mixin.MinecraftClientAccessor; import meteordevelopment.meteorclient.mixin.YggdrasilMinecraftSessionServiceAccessor; import meteordevelopment.meteorclient.systems.accounts.Account; import meteordevelopment.meteorclient.systems.accounts.AccountType; import meteordevelopment.meteorclient.utils.network.Http; -import net.minecraft.client.session.Session; +import net.minecraft.client.util.Session; import java.util.Optional; @@ -21,8 +20,8 @@ public class EasyMCAccount extends Account { - private static final Environment ENVIRONMENT = new Environment("https://sessionserver.easymc.io", "https://authserver.mojang.com", "EasyMC"); - private static final YggdrasilAuthenticationService SERVICE = new YggdrasilAuthenticationService(((MinecraftClientAccessor) mc).getProxy(), ENVIRONMENT); + private static final Environment ENVIRONMENT = Environment.create("https://authserver.mojang.com", "https://api.mojang.com", "https://sessionserver.easymc.io", "https://api.minecraftservices.com", "EasyMC"); + private static final YggdrasilAuthenticationService SERVICE = new YggdrasilAuthenticationService(((MinecraftClientAccessor) mc).getProxy(), "", ENVIRONMENT); public EasyMCAccount(String token) { super(AccountType.EasyMC, token); @@ -51,8 +50,8 @@ public boolean fetchInfo() { @Override public boolean login() { - applyLoginEnvironment(SERVICE, YggdrasilMinecraftSessionServiceAccessor.createYggdrasilMinecraftSessionService(SERVICE.getServicesKeySet(), SERVICE.getProxy(), ENVIRONMENT)); - setSession(new Session(cache.username, UndashedUuid.fromStringLenient(cache.uuid), name, Optional.empty(), Optional.empty(), Session.AccountType.MOJANG)); + applyLoginEnvironment(SERVICE, YggdrasilMinecraftSessionServiceAccessor.createYggdrasilMinecraftSessionService(SERVICE, ENVIRONMENT)); + setSession(new Session(cache.username, cache.uuid, name, Optional.empty(), Optional.empty(), Session.AccountType.MOJANG)); cache.loadHead(); return true; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/MicrosoftAccount.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/MicrosoftAccount.java index ba0804ba71..01404a9c09 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/MicrosoftAccount.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/MicrosoftAccount.java @@ -5,11 +5,10 @@ package meteordevelopment.meteorclient.systems.accounts.types; -import com.mojang.util.UndashedUuid; import meteordevelopment.meteorclient.systems.accounts.Account; import meteordevelopment.meteorclient.systems.accounts.AccountType; import meteordevelopment.meteorclient.systems.accounts.MicrosoftLogin; -import net.minecraft.client.session.Session; +import net.minecraft.client.util.Session; import java.util.Optional; @@ -32,7 +31,7 @@ public boolean login() { cache.loadHead(); - setSession(new Session(cache.username, UndashedUuid.fromStringLenient(cache.uuid), token, Optional.empty(), Optional.empty(), Session.AccountType.MSA)); + setSession(new Session(cache.username, cache.uuid, token, Optional.empty(), Optional.empty(), Session.AccountType.MSA)); return true; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/TheAlteningAccount.java b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/TheAlteningAccount.java index 57f2df4bc2..2da37aeb27 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/TheAlteningAccount.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/accounts/types/TheAlteningAccount.java @@ -5,24 +5,25 @@ package meteordevelopment.meteorclient.systems.accounts.types; +import com.mojang.authlib.Agent; import com.mojang.authlib.Environment; +import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; -import de.florianmichael.waybackauthlib.InvalidCredentialsException; -import de.florianmichael.waybackauthlib.WaybackAuthLib; +import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.mixin.MinecraftClientAccessor; import meteordevelopment.meteorclient.mixin.YggdrasilMinecraftSessionServiceAccessor; import meteordevelopment.meteorclient.systems.accounts.Account; import meteordevelopment.meteorclient.systems.accounts.AccountType; -import net.minecraft.client.session.Session; +import net.minecraft.client.util.Session; import java.util.Optional; import static meteordevelopment.meteorclient.MeteorClient.mc; public class TheAlteningAccount extends Account { - private static final Environment ENVIRONMENT = new Environment("http://sessionserver.thealtening.com", "http://authserver.thealtening.com", "The Altening"); - private static final YggdrasilAuthenticationService SERVICE = new YggdrasilAuthenticationService(((MinecraftClientAccessor) mc).getProxy(), ENVIRONMENT); + private static final Environment ENVIRONMENT = Environment.create("http://authserver.thealtening.com", "https://api.mojang.com", "http://sessionserver.thealtening.com", "https://api.minecraftservices.com", "The Altening"); + private static final YggdrasilAuthenticationService SERVICE = new YggdrasilAuthenticationService(((MinecraftClientAccessor) mc).getProxy(), "", ENVIRONMENT); public TheAlteningAccount(String token) { super(AccountType.TheAltening, token); @@ -30,45 +31,42 @@ public TheAlteningAccount(String token) { @Override public boolean fetchInfo() { - WaybackAuthLib auth = getAuth(); + YggdrasilUserAuthentication auth = getAuth(); try { auth.logIn(); - cache.username = auth.getCurrentProfile().getName(); - cache.uuid = auth.getCurrentProfile().getId().toString(); + cache.username = auth.getSelectedProfile().getName(); + cache.uuid = auth.getSelectedProfile().getId().toString(); return true; - } catch (Exception e) { + } catch (AuthenticationException e) { return false; } } @Override public boolean login() { - applyLoginEnvironment(SERVICE, YggdrasilMinecraftSessionServiceAccessor.createYggdrasilMinecraftSessionService(SERVICE.getServicesKeySet(), SERVICE.getProxy(), ENVIRONMENT)); + applyLoginEnvironment(SERVICE, YggdrasilMinecraftSessionServiceAccessor.createYggdrasilMinecraftSessionService(SERVICE, ENVIRONMENT)); - WaybackAuthLib auth = getAuth(); + YggdrasilUserAuthentication auth = getAuth(); try { auth.logIn(); - setSession(new Session(auth.getCurrentProfile().getName(), auth.getCurrentProfile().getId(), auth.getAccessToken(), Optional.empty(), Optional.empty(), Session.AccountType.MOJANG)); + setSession(new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(), auth.getAuthenticatedToken(), Optional.empty(), Optional.empty(), Session.AccountType.MOJANG)); - cache.username = auth.getCurrentProfile().getName(); + cache.username = auth.getSelectedProfile().getName(); cache.loadHead(); return true; - } catch (InvalidCredentialsException e) { - MeteorClient.LOG.error("Invalid TheAltening credentials."); - return false; - } catch (Exception e) { + } catch (AuthenticationException e) { MeteorClient.LOG.error("Failed to login with TheAltening."); return false; } } - private WaybackAuthLib getAuth() { - WaybackAuthLib auth = new WaybackAuthLib(ENVIRONMENT.servicesHost()); + private YggdrasilUserAuthentication getAuth() { + YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) SERVICE.createUserAuthentication(Agent.MINECRAFT); auth.setUsername(name); auth.setPassword("Meteor on Crack!"); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friend.java b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friend.java index 8003a938f1..5b6187301f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friend.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friend.java @@ -5,7 +5,7 @@ package meteordevelopment.meteorclient.systems.friends; -import com.mojang.util.UndashedUuid; +import com.mojang.util.UUIDTypeAdapter; import meteordevelopment.meteorclient.utils.misc.ISerializable; import meteordevelopment.meteorclient.utils.network.Http; import meteordevelopment.meteorclient.utils.render.PlayerHeadTexture; @@ -31,7 +31,7 @@ public Friend(String name, @Nullable UUID id) { } public Friend(PlayerEntity player) { - this(player.getName().getString(), player.getUuid()); + this(player.getEntityName(), player.getUuid()); } public Friend(String name) { this(name, null); @@ -50,7 +50,7 @@ public void updateInfo() { APIResponse res = Http.get("https://api.mojang.com/users/profiles/minecraft/" + name).sendJson(APIResponse.class); if (res == null || res.name == null || res.id == null) return; name = res.name; - id = UndashedUuid.fromStringLenient(res.id); + id = UUIDTypeAdapter.fromString(res.id); headTexture = PlayerHeadUtils.fetchHead(id); updating = false; } @@ -64,7 +64,7 @@ public NbtCompound toTag() { NbtCompound tag = new NbtCompound(); tag.putString("name", name); - if (id != null) tag.putString("id", UndashedUuid.toString(id)); + if (id != null) tag.putString("id", UUIDTypeAdapter.fromUUID(id)); return tag; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java index 3642319fa1..8df4f22ebe 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java @@ -5,7 +5,7 @@ package meteordevelopment.meteorclient.systems.friends; -import com.mojang.util.UndashedUuid; +import com.mojang.util.UUIDTypeAdapter; import meteordevelopment.meteorclient.systems.System; import meteordevelopment.meteorclient.systems.Systems; import meteordevelopment.meteorclient.utils.misc.NbtUtils; @@ -65,7 +65,7 @@ public Friend get(String name) { } public Friend get(PlayerEntity player) { - return get(player.getName().getString()); + return get(player.getEntityName()); } public Friend get(PlayerListEntry player) { @@ -119,7 +119,7 @@ public Friends fromTag(NbtCompound tag) { String uuid = friendTag.getString("id"); Friend friend = !uuid.isBlank() - ? new Friend(name, UndashedUuid.fromStringLenient(uuid)) + ? new Friend(name, UUIDTypeAdapter.fromString(uuid)) : new Friend(name); friends.add(friend); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java index 4e8b962de7..04d89ec506 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java @@ -224,7 +224,7 @@ private void onRender(Render2DEvent event) { if (Utils.isLoading()) return; if (!active || shouldHideHud()) return; - if ((mc.options.hudHidden || mc.inGameHud.getDebugHud().shouldShowDebugHud()) && !HudEditorScreen.isOpen()) return; + if ((mc.options.hudHidden || mc.options.debugEnabled) && !HudEditorScreen.isOpen()) return; HudRenderer.INSTANCE.begin(event.drawContext); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java index fe2e31086f..ee31b24347 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java @@ -57,7 +57,6 @@ public class CombatHud extends HudElement { .defaultValue(2) .min(1) .sliderRange(1, 5) - .onChanged(aDouble -> calculateSize()) .build() ); @@ -178,11 +177,10 @@ public class CombatHud extends HudElement { public CombatHud() { super(INFO); - - calculateSize(); } - private void calculateSize() { + @Override + public void tick(HudRenderer renderer) { setSize(175 * scale.get(), 95 * scale.get()); } @@ -204,29 +202,18 @@ public void render(HudRenderer renderer) { // Background Renderer2D.COLOR.begin(); Renderer2D.COLOR.quad(x, y, getWidth(), getHeight(), backgroundColor.get()); - - if (playerEntity == null) { - if (isInEditor()) { - renderer.line(x, y, x + getWidth(), y + getHeight(), Color.GRAY); - renderer.line(x + getWidth(), y, x, y + getHeight(), Color.GRAY); - Renderer2D.COLOR.render(null); // i know, ill fix it soon - } - return; - } Renderer2D.COLOR.render(null); + if (playerEntity == null) return; + // Player Model InventoryScreen.drawEntity( renderer.drawContext, - (int) x, - (int) y, (int) (x + (25 * scale.get())), (int) (y + (66 * scale.get())), (int) (30 * scale.get()), - 0, -MathHelper.wrapDegrees(playerEntity.prevYaw + (playerEntity.getYaw() - playerEntity.prevYaw) * mc.getTickDelta()), - -playerEntity.getPitch(), - playerEntity + -playerEntity.getPitch(), playerEntity ); // Moving pos to past player model @@ -237,7 +224,7 @@ public void render(HudRenderer renderer) { String breakText = " | "; // Name - String nameText = playerEntity.getName().getString(); + String nameText = playerEntity.getEntityName(); Color nameColor = PlayerUtils.getPlayerColor(playerEntity, primaryColor); // Ping @@ -267,7 +254,8 @@ public void render(HudRenderer renderer) { if (Friends.get().isFriend(playerEntity)) { friendText = "Friend"; friendColor = Config.get().friendColor.get(); - } else { + } + else { boolean naked = true; for (int position = 3; position >= 0; position--) { @@ -279,7 +267,8 @@ public void render(HudRenderer renderer) { if (naked) { friendText = "Naked"; friendColor = GREEN; - } else { + } + else { boolean threat = false; for (int position = 5; position >= 0; position--) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java index 0e192325f5..f61d64eb90 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java @@ -42,7 +42,6 @@ public class InventoryHud extends HudElement { .defaultValue(2) .min(1) .sliderRange(1, 5) - .onChanged(aDouble -> calculateSize()) .build() ); @@ -50,7 +49,6 @@ public class InventoryHud extends HudElement { .name("background") .description("Background of inventory viewer.") .defaultValue(Background.Texture) - .onChanged(bg -> calculateSize()) .build() ); @@ -66,12 +64,12 @@ public class InventoryHud extends HudElement { private InventoryHud() { super(INFO); - - calculateSize(); } @Override public void render(HudRenderer renderer) { + setSize(background.get().width * scale.get(), background.get().height * scale.get()); + double x = this.x, y = this.y; ItemStack container = getContainer(); @@ -101,10 +99,6 @@ public void render(HudRenderer renderer) { }); } - private void calculateSize() { - setSize(background.get().width * scale.get(), background.get().height * scale.get()); - } - private void drawBackground(HudRenderer renderer, int x, int y, Color color) { int w = getWidth(); int h = getHeight(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java index a311bb135f..2f3aa7fd4f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java @@ -10,15 +10,10 @@ import meteordevelopment.meteorclient.systems.hud.HudElement; import meteordevelopment.meteorclient.systems.hud.HudElementInfo; import meteordevelopment.meteorclient.systems.hud.HudRenderer; -import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; -import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ingame.InventoryScreen; -import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.MathHelper; -import org.joml.Quaternionf; -import org.joml.Vector3f; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -35,7 +30,6 @@ public class PlayerModelHud extends HudElement { .defaultValue(2) .min(1) .sliderRange(1, 5) - .onChanged(aDouble -> calculateSize()) .build() ); @@ -46,6 +40,13 @@ public class PlayerModelHud extends HudElement { .build() ); + private final Setting copyPitch = sgGeneral.add(new BoolSetting.Builder() + .name("copy-pitch") + .description("Makes the player model's pitch equal to yours.") + .defaultValue(true) + .build() + ); + private final Setting customYaw = sgGeneral.add(new IntSetting.Builder() .name("custom-yaw") .description("Custom yaw for when copy yaw is off.") @@ -56,13 +57,6 @@ public class PlayerModelHud extends HudElement { .build() ); - private final Setting copyPitch = sgGeneral.add(new BoolSetting.Builder() - .name("copy-pitch") - .description("Makes the player model's pitch equal to yours.") - .defaultValue(true) - .build() - ); - private final Setting customPitch = sgGeneral.add(new IntSetting.Builder() .name("custom-pitch") .description("Custom pitch for when copy pitch is off.") @@ -73,13 +67,6 @@ public class PlayerModelHud extends HudElement { .build() ); - private final Setting centerOrientation = sgGeneral.add(new EnumSetting.Builder() - .name("center-orientation") - .description("Which direction the player faces when the HUD model faces directly forward.") - .defaultValue(CenterOrientation.South) - .build() - ); - // Background private final Setting background = sgBackground.add(new BoolSetting.Builder() @@ -99,90 +86,24 @@ public class PlayerModelHud extends HudElement { public PlayerModelHud() { super(INFO); - - calculateSize(); } @Override public void render(HudRenderer renderer) { + setSize(50 * scale.get(), 75 * scale.get()); + renderer.post(() -> { PlayerEntity player = mc.player; if (player == null) return; - float offset = centerOrientation.get() == CenterOrientation.North ? 180 : 0; - - float yaw = copyYaw.get() ? MathHelper.wrapDegrees(player.prevYaw + (player.getYaw() - player.prevYaw) * mc.getTickDelta() + offset) : (float) customYaw.get(); + float yaw = copyYaw.get() ? MathHelper.wrapDegrees(player.prevYaw + (player.getYaw() - player.prevYaw) * mc.getTickDelta()) : (float) customYaw.get(); float pitch = copyPitch.get() ? player.getPitch() : (float) customPitch.get(); - drawEntity(renderer.drawContext, x, y, (int) (30 * scale.get()), -yaw, -pitch, player); + InventoryScreen.drawEntity(renderer.drawContext, (int) (x + (25 * scale.get())), (int) (y + (66 * scale.get())), (int) (30 * scale.get()), -yaw, -pitch, player); }); if (background.get()) { renderer.quad(x, y, getWidth(), getHeight(), backgroundColor.get()); - } else if (mc.player == null) { - renderer.quad(x, y, getWidth(), getHeight(), backgroundColor.get()); - renderer.line(x, y, x + getWidth(), y + getHeight(), Color.GRAY); - renderer.line(x + getWidth(), y, x, y + getHeight(), Color.GRAY); } } - - private void calculateSize() { - setSize(50 * scale.get(), 75 * scale.get()); - } - - /** - * Draws an entity to the screen. The default version provided by InventoryScreen has had its parameters changed - * such that it's no longer appropriate for this use case. As the new version uses rotation based on the mouse - * position relative to itself, it causes some odd angle positioning that may also look "stuck" to one corner, - * and the model's facing may change depending on how we reposition the element. - * Additionally, it uses OpenGL scissors, which causes the player model to get cut when the Minecraft GUI scale is not 1x. - * This version of drawEntity should fix these issues. - */ - private void drawEntity(DrawContext context, int x, int y, int size, float yaw, float pitch, LivingEntity entity) { - - float tanYaw = (float) Math.atan((yaw) / 40.0f); - float tanPitch = (float) Math.atan((pitch) / 40.0f); - - // By default, the origin of the drawEntity command is the top-center, facing down and straight to the south. - // This means that the player model is upside-down. We'll apply a rotation of PI radians (180 degrees) to fix this. - // This does have the downside of setting the origin to the bottom-center corner, though, so we'll have - // to compensate for this later. - Quaternionf quaternion = new Quaternionf().rotateZ((float) Math.PI); - - // The drawEntity command draws the entity using some entity parameters, so we'll have to manipulate some of - // those to draw as we want. But first, we'll save the previous values, so we can restore them later. - float previousBodyYaw = entity.bodyYaw; - float previousYaw = entity.getYaw(); - float previousPitch = entity.getPitch(); - float previousPrevHeadYaw = entity.prevHeadYaw; // A perplexing name, I know! - float prevHeadYaw = entity.headYaw; - - // Apply the rotation parameters - entity.bodyYaw = 180.0f + tanYaw * 20.0f; - entity.setYaw(180.0f + tanYaw * 40.0f); - entity.setPitch(-tanPitch * 20.0f); - entity.headYaw = entity.getYaw(); - entity.prevHeadYaw = entity.getYaw(); - - // Recall the player's origin is now the bottom-center corner, so we'll have to offset the draw by half the width - // to get it to render in the center. - // As for the y parameter, adding the element's height draws it at the bottom, but in practice we want the player - // to "float" somewhat, so we'll multiply it by some constant to have it hover. It turns out 0.9 is a good value. - // The vector3 parameter applies a translation to the player's model. Given that we're simply offsetting - // the draw in the x and y parameters, we won't really need this, so we'll set it to default. - // It doesn't seem like quaternionf2 does anything, so we'll leave it null to save some computation. - InventoryScreen.drawEntity(context, x + getWidth() / 2, y + getHeight() * 0.9f, size, new Vector3f(), quaternion, null, entity); - - // Restore the previous values - entity.bodyYaw = previousBodyYaw; - entity.setYaw(previousYaw); - entity.setPitch(previousPitch); - entity.prevHeadYaw = previousPrevHeadYaw; - entity.headYaw = prevHeadYaw; - } - - private enum CenterOrientation { - North, - South - } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerRadarHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerRadarHud.java index 879a45d708..2adbde96a8 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerRadarHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerRadarHud.java @@ -153,7 +153,7 @@ public void tick(HudRenderer renderer) { if (entity.equals(mc.player)) continue; if (!friends.get() && Friends.get().isFriend(entity)) continue; - String text = entity.getName().getString(); + String text = entity.getEntityName(); if (distance.get()) text += String.format("(%sm)", Math.round(mc.getCameraEntity().distanceTo(entity))); width = Math.max(width, renderer.textWidth(text, shadow.get(), getScale())); @@ -180,7 +180,7 @@ public void render(HudRenderer renderer) { if (entity.equals(mc.player)) continue; if (!friends.get() && Friends.get().isFriend(entity)) continue; - String text = entity.getName().getString(); + String text = entity.getEntityName(); Color color = PlayerUtils.getPlayerColor(entity, primaryColor.get()); String distanceText = null; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PotionTimersHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PotionTimersHud.java index 332c9ef4a0..92a92cf6ef 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PotionTimersHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PotionTimersHud.java @@ -5,8 +5,6 @@ package meteordevelopment.meteorclient.systems.hud.elements; -import it.unimi.dsi.fastutil.Pair; -import it.unimi.dsi.fastutil.objects.ObjectObjectImmutablePair; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.hud.*; import meteordevelopment.meteorclient.utils.misc.Names; @@ -16,7 +14,6 @@ import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectUtil; -import java.util.ArrayList; import java.util.List; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -155,8 +152,9 @@ public class PotionTimersHud extends HudElement { .build() ); - private final List> texts = new ArrayList<>(); - private double rainbowHue; + private final Color rainbow = new Color(255, 255, 255); + private double rainbowHue1; + private double rainbowHue2; public PotionTimersHud() { super(INFO); @@ -182,14 +180,10 @@ public void tick(HudRenderer renderer) { double width = 0; double height = 0; - texts.clear(); - for (StatusEffectInstance statusEffectInstance : mc.player.getStatusEffects()) { if (hiddenEffects.get().contains(statusEffectInstance.getEffectType())) continue; if (!showAmbient.get() && statusEffectInstance.isAmbient()) continue; - String text = getString(statusEffectInstance); - texts.add(new ObjectObjectImmutablePair<>(statusEffectInstance, text)); - width = Math.max(width, renderer.textWidth(text, shadow.get(), getScale())); + width = Math.max(width, renderer.textWidth(getString(statusEffectInstance), shadow.get(), getScale())); height += renderer.textHeight(shadow.get(), getScale()); } @@ -210,30 +204,39 @@ public void render(HudRenderer renderer) { return; } - rainbowHue += rainbowSpeed.get() * renderer.delta; - if (rainbowHue > 1) rainbowHue -= 1; - else if (rainbowHue < -1) rainbowHue += 1; + rainbowHue1 += rainbowSpeed.get() * renderer.delta; + if (rainbowHue1 > 1) rainbowHue1 -= 1; + else if (rainbowHue1 < -1) rainbowHue1 += 1; - double localRainbowHue = rainbowHue; + rainbowHue2 = rainbowHue1; - for (Pair potionEffectEntry : texts) { - Color color = switch (colorMode.get()) { + for (StatusEffectInstance statusEffectInstance : mc.player.getStatusEffects()) { + if (hiddenEffects.get().contains(statusEffectInstance.getEffectType())) continue; + if (!showAmbient.get() && statusEffectInstance.isAmbient()) continue; + Color color = new Color(255, 255, 255); + + switch (colorMode.get()) { case Effect -> { - int c = potionEffectEntry.left().getEffectType().getColor(); - yield new Color(c).a(255); + int c = statusEffectInstance.getEffectType().getColor(); + color.r = Color.toRGBAR(c); + color.g = Color.toRGBAG(c); + color.b = Color.toRGBAB(c); } case Flat -> { + color = flatColor.get(); flatColor.get().update(); - yield flatColor.get(); } case Rainbow -> { - localRainbowHue += rainbowSpread.get(); - int c = java.awt.Color.HSBtoRGB((float) localRainbowHue, rainbowSaturation.get().floatValue(), rainbowBrightness.get().floatValue()); - yield new Color(c); + rainbowHue2 += rainbowSpread.get(); + int c = java.awt.Color.HSBtoRGB((float) rainbowHue2, rainbowSaturation.get().floatValue(), rainbowBrightness.get().floatValue()); + rainbow.r = Color.toRGBAR(c); + rainbow.g = Color.toRGBAG(c); + rainbow.b = Color.toRGBAB(c); + color = rainbow; } - }; + } - String text = potionEffectEntry.right(); + String text = getString(statusEffectInstance); renderer.text(text, x + alignX(renderer.textWidth(text, shadow.get(), getScale()), alignment.get()), y, color, shadow.get(), getScale()); y += renderer.textHeight(shadow.get(), getScale()); @@ -241,7 +244,7 @@ public void render(HudRenderer renderer) { } private String getString(StatusEffectInstance statusEffectInstance) { - return String.format("%s %d (%s)", Names.get(statusEffectInstance.getEffectType()), statusEffectInstance.getAmplifier() + 1, StatusEffectUtil.getDurationText(statusEffectInstance, 1, mc.world.getTickManager().getTickRate()).getString()); + return String.format("%s %d (%s)", Names.get(statusEffectInstance.getEffectType()), statusEffectInstance.getAmplifier() + 1, statusEffectInstance.isInfinite() ? "inf" : StatusEffectUtil.getDurationText(statusEffectInstance, 1).getString()); //todo remove "inf" when font rendering can use symbols } private double getScale() { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/screens/HudEditorScreen.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/screens/HudEditorScreen.java index 3aa991e061..5b69d1bacb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/screens/HudEditorScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/screens/HudEditorScreen.java @@ -261,7 +261,7 @@ private void renderElement(HudElement element, Color bgColor, Color olColor) { @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { - if (!Utils.canUpdate()) renderBackground(context, mouseX, mouseY, delta); + if (!Utils.canUpdate()) renderBackground(context); double s = mc.getWindow().getScaleFactor(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index c9b07c574d..1e18bfd65d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -5,9 +5,9 @@ package meteordevelopment.meteorclient.systems.modules; +import com.google.common.collect.Ordering; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Lifecycle; -import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.game.GameJoinedEvent; import meteordevelopment.meteorclient.events.game.GameLeftEvent; @@ -16,7 +16,6 @@ import meteordevelopment.meteorclient.events.meteor.KeyEvent; import meteordevelopment.meteorclient.events.meteor.ModuleBindChangedEvent; import meteordevelopment.meteorclient.events.meteor.MouseButtonEvent; -import meteordevelopment.meteorclient.pathing.BaritoneUtils; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.System; @@ -68,8 +67,8 @@ public class Modules extends System { private static final List CATEGORIES = new ArrayList<>(); private final List modules = new ArrayList<>(); - private final Map, Module> moduleInstances = new Reference2ReferenceOpenHashMap<>(); - private final Map> groups = new Reference2ReferenceOpenHashMap<>(); + private final Map, Module> moduleInstances = new HashMap<>(); + private final Map> groups = new HashMap<>(); private final List active = new ArrayList<>(); private Module moduleToBind; @@ -169,7 +168,7 @@ public List getActive() { } public Set searchTitles(String text) { - Map modules = new ValueComparableMap<>(Comparator.naturalOrder()); + Map modules = new ValueComparableMap<>(Ordering.natural()); for (Module module : this.moduleInstances.values()) { int score = Utils.searchLevenshteinDefault(module.title, text, false); @@ -180,7 +179,7 @@ public Set searchTitles(String text) { } public Set searchSettingTitles(String text) { - Map modules = new ValueComparableMap<>(Comparator.naturalOrder()); + Map modules = new ValueComparableMap<>(Ordering.natural()); for (Module module : this.moduleInstances.values()) { int lowest = Integer.MAX_VALUE; @@ -530,7 +529,9 @@ private void initWorld() { add(new BuildHeight()); add(new EChestFarmer()); add(new EndermanLook()); + add(new Excavator()); add(new Flamethrower()); + add(new InfinityMiner()); add(new LiquidFiller()); add(new MountBypass()); add(new NoGhostBlocks()); @@ -540,11 +541,6 @@ private void initWorld() { add(new Timer()); add(new VeinMiner()); add(new HighwayBuilder()); - - if (BaritoneUtils.IS_AVAILABLE) { - add(new Excavator()); - add(new InfinityMiner()); - } } private void initMisc() { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AnchorAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AnchorAura.java index 69541d75e7..38b1a947da 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AnchorAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AnchorAura.java @@ -11,7 +11,6 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; -import meteordevelopment.meteorclient.utils.entity.DamageUtils; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.SortPriority; import meteordevelopment.meteorclient.utils.entity.TargetUtils; @@ -21,13 +20,13 @@ import meteordevelopment.orbit.EventHandler; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.FlowableFluid; import net.minecraft.item.Items; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; public class AnchorAura extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -226,7 +225,6 @@ public class AnchorAura extends Module { private int placeDelayLeft; private int breakDelayLeft; private PlayerEntity target; - private final BlockPos.Mutable mutable = new BlockPos.Mutable(); public AnchorAura() { super(Categories.Combat, "anchor-aura", "Automatically places and breaks Respawn Anchors to harm entities."); @@ -266,8 +264,7 @@ private void onTick(TickEvent.Post event) { breakDelayLeft = 0; if (rotationMode.get() == RotationMode.Both || rotationMode.get() == RotationMode.Break) { - BlockPos immutableBreakPos = breakPos.toImmutable(); - Rotations.rotate(Rotations.getYaw(breakPos), Rotations.getPitch(breakPos), 50, () -> breakAnchor(immutableBreakPos, anchor, glowStone)); + Rotations.rotate(Rotations.getYaw(breakPos), Rotations.getPitch(breakPos), 50, () -> breakAnchor(breakPos, anchor, glowStone)); } else breakAnchor(breakPos, anchor, glowStone); } } @@ -277,7 +274,7 @@ private void onTick(TickEvent.Post event) { if (placePos != null) { placeDelayLeft = 0; - BlockUtils.place(placePos.toImmutable(), anchor, (rotationMode.get() == RotationMode.Place || rotationMode.get() == RotationMode.Both), 50); + BlockUtils.place(placePos, anchor, (rotationMode.get() == RotationMode.Place || rotationMode.get() == RotationMode.Both), 50); } } @@ -304,50 +301,48 @@ private void onRender(Render3DEvent event) { } } - @Nullable private BlockPos findPlacePos(BlockPos targetPlacePos) { switch (placePositions.get()) { - case All -> { - if (isValidPlace(targetPlacePos, 0, -1, 0)) return mutable; - else if (isValidPlace(targetPlacePos, 0, 2, 0)) return mutable; - else if (isValidPlace(targetPlacePos, 1, 0, 0)) return mutable; - else if (isValidPlace(targetPlacePos, -1, 0, 0)) return mutable; - else if (isValidPlace(targetPlacePos, 0, 0, 1)) return mutable; - else if (isValidPlace(targetPlacePos, 0, 0, -1)) return mutable; - else if (isValidPlace(targetPlacePos, 1, 1, 0)) return mutable; - else if (isValidPlace(targetPlacePos, -1, -1, 0)) return mutable; - else if (isValidPlace(targetPlacePos, 0, 1, 1)) return mutable; - else if (isValidPlace(targetPlacePos, 0, 0, -1)) return mutable; - } - case Above -> { - if (isValidPlace(targetPlacePos, 0, 2, 0)) return mutable; - } - case AboveAndBelow -> { - if (isValidPlace(targetPlacePos, 0, -1, 0)) return mutable; - else if (isValidPlace(targetPlacePos, 0, 2, 0)) return mutable; - } - case Around -> { - if (isValidPlace(targetPlacePos, 0, 0, -1)) return mutable; - else if (isValidPlace(targetPlacePos, 1, 0, 0)) return mutable; - else if (isValidPlace(targetPlacePos, -1, 0, 0)) return mutable; - else if (isValidPlace(targetPlacePos, 0, 0, 1)) return mutable; - } + case All: + if (isValidPlace(targetPlacePos.down())) return targetPlacePos.down(); + else if (isValidPlace(targetPlacePos.up(2))) return targetPlacePos.up(2); + else if (isValidPlace(targetPlacePos.add(1, 0, 0))) return targetPlacePos.add(1, 0, 0); + else if (isValidPlace(targetPlacePos.add(-1, 0, 0))) return targetPlacePos.add(-1, 0, 0); + else if (isValidPlace(targetPlacePos.add(0, 0, 1))) return targetPlacePos.add(0, 0, 1); + else if (isValidPlace(targetPlacePos.add(0, 0, -1))) return targetPlacePos.add(0, 0, -1); + else if (isValidPlace(targetPlacePos.add(1, 1, 0))) return targetPlacePos.add(1, 1, 0); + else if (isValidPlace(targetPlacePos.add(-1, -1, 0))) return targetPlacePos.add(-1, -1, 0); + else if (isValidPlace(targetPlacePos.add(0, 1, 1))) return targetPlacePos.add(0, 1, 1); + else if (isValidPlace(targetPlacePos.add(0, 0, -1))) return targetPlacePos.add(0, 0, -1); + break; + case Above: + if (isValidPlace(targetPlacePos.up(2))) return targetPlacePos.up(2); + break; + case AboveAndBelow: + if (isValidPlace(targetPlacePos.down())) return targetPlacePos.down(); + else if (isValidPlace(targetPlacePos.up(2))) return targetPlacePos.up(2); + break; + case Around: + if (isValidPlace(targetPlacePos.north())) return targetPlacePos.north(); + else if (isValidPlace(targetPlacePos.east())) return targetPlacePos.east(); + else if (isValidPlace(targetPlacePos.west())) return targetPlacePos.west(); + else if (isValidPlace(targetPlacePos.south())) return targetPlacePos.south(); + break; } return null; } - @Nullable private BlockPos findBreakPos(BlockPos targetPos) { - if (isValidBreak(targetPos, 0, -1, 0)) return mutable; - else if (isValidBreak(targetPos, 0, 2, 0)) return mutable; - else if (isValidBreak(targetPos, 1, 0, 0)) return mutable; - else if (isValidBreak(targetPos, -1, 0, 0)) return mutable; - else if (isValidBreak(targetPos, 0, 0, 1)) return mutable; - else if (isValidBreak(targetPos, 0, 0, -1)) return mutable; - else if (isValidBreak(targetPos, 1, 1, 0)) return mutable; - else if (isValidBreak(targetPos, -1, -1, 0)) return mutable; - else if (isValidBreak(targetPos, 0, 1, 1)) return mutable; - else if (isValidBreak(targetPos, 0, 0, -1)) return mutable; + if (isValidBreak(targetPos.down())) return targetPos.down(); + else if (isValidBreak(targetPos.up(2))) return targetPos.up(2); + else if (isValidBreak(targetPos.add(1, 0, 0))) return targetPos.add(1, 0, 0); + else if (isValidBreak(targetPos.add(-1, 0, 0))) return targetPos.add(-1, 0, 0); + else if (isValidBreak(targetPos.add(0, 0, 1))) return targetPos.add(0, 0, 1); + else if (isValidBreak(targetPos.add(0, 0, -1))) return targetPos.add(0, 0, -1); + else if (isValidBreak(targetPos.add(1, 1, 0))) return targetPos.add(1, 1, 0); + else if (isValidBreak(targetPos.add(-1, -1, 0))) return targetPos.add(-1, -1, 0); + else if (isValidBreak(targetPos.add(0, 1, 1))) return targetPos.add(0, 1, 1); + else if (isValidBreak(targetPos.add(0, 0, -1))) return targetPos.add(0, 0, -1); return null; } @@ -359,14 +354,12 @@ private boolean getDamageBreak(BlockPos pos) { return breakMode.get() == Safety.Suicide || DamageUtils.anchorDamage(mc.player, pos.toCenterPos()) <= maxDamage.get(); } - private boolean isValidPlace(BlockPos origin, int xOffset, int yOffset, int zOffset) { - BlockUtils.mutateAround(mutable, origin, xOffset, yOffset, zOffset); - return Math.sqrt(mc.player.getBlockPos().getSquaredDistance(mutable)) <= placeRange.get() && getDamagePlace(mutable) && BlockUtils.canPlace(mutable); + private boolean isValidPlace(BlockPos pos) { + return Math.sqrt(mc.player.getBlockPos().getSquaredDistance(pos)) <= placeRange.get() && getDamagePlace(pos) && BlockUtils.canPlace(pos, true); } - private boolean isValidBreak(BlockPos origin, int xOffset, int yOffset, int zOffset) { - BlockUtils.mutateAround(mutable, origin, xOffset, yOffset, zOffset); - return mc.world.getBlockState(mutable).getBlock() == Blocks.RESPAWN_ANCHOR && Math.sqrt(mc.player.getBlockPos().getSquaredDistance(mutable)) <= breakRange.get() && getDamageBreak(mutable); + private boolean isValidBreak(BlockPos pos) { + return mc.world.getBlockState(pos).getBlock() == Blocks.RESPAWN_ANCHOR && Math.sqrt(mc.player.getBlockPos().getSquaredDistance(pos)) <= breakRange.get() && getDamageBreak(pos); } private void breakAnchor(BlockPos pos, FindItemResult anchor, FindItemResult glowStone) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoCity.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoCity.java index 945fcb6a23..effcf624a7 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoCity.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoCity.java @@ -149,7 +149,7 @@ public void onActivate() { } targetPos = EntityUtils.getCityBlock(target); - if (targetPos == null || PlayerUtils.squaredDistanceTo(targetPos) > Math.pow(breakRange.get(), 2)) { + if (targetPos == null || PlayerUtils.distanceTo(targetPos) > breakRange.get()) { if (chatInfo.get()) error("Couldn't find a good block, disabling."); toggle(); return; @@ -157,7 +157,7 @@ public void onActivate() { if (support.get()) { BlockPos supportPos = targetPos.down(); - if (!(PlayerUtils.squaredDistanceTo(supportPos) > Math.pow(placeRange.get(), 2))) { + if (!(PlayerUtils.distanceTo(supportPos) > placeRange.get())) { BlockUtils.place(supportPos, InvUtils.findInHotbar(Items.OBSIDIAN), rotate.get(), 0, true); } } @@ -186,7 +186,7 @@ private void onTick(TickEvent.Pre event) { return; } - if (PlayerUtils.squaredDistanceTo(targetPos) > Math.pow(breakRange.get(), 2)) { + if (PlayerUtils.distanceTo(targetPos) > breakRange.get()) { if (chatInfo.get()) error("Couldn't find a target, disabling."); toggle(); return; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java index 366a95cf4c..522bde5d40 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java @@ -12,7 +12,6 @@ import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.Utils; -import meteordevelopment.meteorclient.utils.entity.DamageUtils; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.SortPriority; import meteordevelopment.meteorclient.utils.entity.TargetUtils; @@ -259,8 +258,8 @@ private BlockPos findPlace(PlayerEntity target) { BlockPos centerPos = target.getBlockPos().up(i); - float headSelfDamage = DamageUtils.bedDamage(mc.player, Utils.vec3d(centerPos)); - float offsetSelfDamage = DamageUtils.bedDamage(mc.player, Utils.vec3d(centerPos.offset(dir.toDirection()))); + double headSelfDamage = DamageUtils.bedDamage(mc.player, Utils.vec3d(centerPos)); + double offsetSelfDamage = DamageUtils.bedDamage(mc.player, Utils.vec3d(centerPos.offset(dir.toDirection()))); if (mc.world.getBlockState(centerPos).isReplaceable() && BlockUtils.canPlace(centerPos.offset(dir.toDirection())) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BowAimbot.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BowAimbot.java index 5c586bba44..4f5361fb35 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BowAimbot.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BowAimbot.java @@ -5,8 +5,8 @@ package meteordevelopment.meteorclient.systems.modules.combat; +import baritone.api.BaritoneAPI; import meteordevelopment.meteorclient.events.render.Render3DEvent; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.systems.modules.Categories; @@ -93,7 +93,7 @@ public void onDeactivate() { @EventHandler private void onRender(Render3DEvent event) { if (!PlayerUtils.isAlive() || !itemInHand()) return; - if (!mc.player.getAbilities().creativeMode && !InvUtils.find(itemStack -> itemStack.getItem() instanceof ArrowItem).found()) return; + if (!InvUtils.find(itemStack -> itemStack.getItem() instanceof ArrowItem).found()) return; target = TargetUtils.get(entity -> { if (entity == mc.player || entity == mc.cameraEntity) return false; @@ -111,15 +111,15 @@ private void onRender(Render3DEvent event) { if (target == null) { if (wasPathing) { - PathManagers.get().resume(); + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("resume"); wasPathing = false; } return; } if (mc.options.useKey.isPressed() && itemInHand()) { - if (pauseOnCombat.get() && PathManagers.get().isPathing() && !wasPathing) { - PathManagers.get().pause(); + if (pauseOnCombat.get() && BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && !wasPathing) { + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("pause"); wasPathing = true; } aim(event.tickDelta); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java index af9915d787..a97a50a22d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java @@ -22,7 +22,6 @@ import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; -import meteordevelopment.meteorclient.utils.entity.DamageUtils; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.Target; import meteordevelopment.meteorclient.utils.misc.Keybind; @@ -83,6 +82,14 @@ public class CrystalAura extends Module { .build() ); + private final Setting ignoreTerrain = sgGeneral.add(new BoolSetting.Builder() + .name("ignore-terrain") + .description("Completely ignores terrain if it can be blown up by end crystals.") + .defaultValue(true) + .build() + ); + + private final Setting minDamage = sgGeneral.add(new DoubleSetting.Builder() .name("min-damage") .description("Minimum damage the crystal needs to deal to your target.") @@ -710,7 +717,7 @@ private void onEntityAdded(EntityAddedEvent event) { } if (fastBreak.get() && !didRotateThisTick && attacks < attackFrequency.get()) { - float damage = getBreakDamage(event.entity, true); + double damage = getBreakDamage(event.entity, true); if (damage > minDamage.get()) doBreak(event.entity); } } @@ -743,12 +750,12 @@ private void doBreak() { if (!doBreak.get() || breakTimer > 0 || switchTimer > 0 || attacks >= attackFrequency.get()) return; if (shouldPause(PauseMode.Break)) return; - float bestDamage = 0; + double bestDamage = 0; Entity crystal = null; // Find best crystal to break for (Entity entity : mc.world.getEntities()) { - float damage = getBreakDamage(entity, true); + double damage = getBreakDamage(entity, true); if (damage > bestDamage) { bestDamage = damage; @@ -760,7 +767,7 @@ private void doBreak() { if (crystal != null) doBreak(crystal); } - private float getBreakDamage(Entity entity, boolean checkCrystalAge) { + private double getBreakDamage(Entity entity, boolean checkCrystalAge) { if (!(entity instanceof EndCrystalEntity)) return 0; // Check only break own @@ -780,15 +787,15 @@ private float getBreakDamage(Entity entity, boolean checkCrystalAge) { // Check damage to self and anti suicide blockPos.set(entity.getBlockPos()).move(0, -1, 0); - float selfDamage = DamageUtils.crystalDamage(mc.player, entity.getPos(), predictMovement.get(), blockPos); + double selfDamage = DamageUtils.crystalDamage(mc.player, entity.getPos(), predictMovement.get(), blockPos, ignoreTerrain.get()); if (selfDamage > maxDamage.get() || (antiSuicide.get() && selfDamage >= EntityUtils.getTotalHealth(mc.player))) return 0; // Check damage to targets and face place - float damage = getDamageToTargets(entity.getPos(), blockPos, true, false); + double damage = getDamageToTargets(entity.getPos(), blockPos, true, false); boolean shouldFacePlace = shouldFacePlace(); - double minimumDamage = shouldFacePlace ? Math.min(minDamage.get(), 1.5d) : minDamage.get(); + double minimumDamage = Math.min(minDamage.get(), shouldFacePlace ? 1.5 : minDamage.get()); - if (damage < minimumDamage) return 0f; + if (damage < minimumDamage) return 0; return damage; } @@ -924,11 +931,11 @@ private void doPlace() { if (isOutOfRange(vec3d, blockPos, true)) return; // Check damage to self and anti suicide - float selfDamage = DamageUtils.crystalDamage(mc.player, vec3d, predictMovement.get(), bp); + double selfDamage = DamageUtils.crystalDamage(mc.player, vec3d, predictMovement.get(), bp, ignoreTerrain.get()); if (selfDamage > maxDamage.get() || (antiSuicide.get() && selfDamage >= EntityUtils.getTotalHealth(mc.player))) return; // Check damage to targets and face place - float damage = getDamageToTargets(vec3d, bp, false, !hasBlock && support.get() == SupportMode.Fast); + double damage = getDamageToTargets(vec3d, bp, false, !hasBlock && support.get() == SupportMode.Fast); boolean shouldFacePlace = shouldFacePlace(); double minimumDamage = Math.min(minDamage.get(), shouldFacePlace ? 1.5 : minDamage.get()); @@ -1160,18 +1167,18 @@ private PlayerEntity getNearestTarget() { return nearestTarget; } - private float getDamageToTargets(Vec3d vec3d, BlockPos obsidianPos, boolean breaking, boolean fast) { - float damage = 0; + private double getDamageToTargets(Vec3d vec3d, BlockPos obsidianPos, boolean breaking, boolean fast) { + double damage = 0; if (fast) { PlayerEntity target = getNearestTarget(); - if (!(smartDelay.get() && breaking && target.hurtTime > 0)) damage = DamageUtils.crystalDamage(target, vec3d, predictMovement.get(), obsidianPos); + if (!(smartDelay.get() && breaking && target.hurtTime > 0)) damage = DamageUtils.crystalDamage(target, vec3d, predictMovement.get(), obsidianPos, ignoreTerrain.get()); } else { for (PlayerEntity target : targets) { if (smartDelay.get() && breaking && target.hurtTime > 0) continue; - float dmg = DamageUtils.crystalDamage(target, vec3d, predictMovement.get(), obsidianPos); + double dmg = DamageUtils.crystalDamage(target, vec3d, predictMovement.get(), obsidianPos, ignoreTerrain.get()); // Update best target if (dmg > bestTargetDamage) { @@ -1199,7 +1206,7 @@ private void findTargets() { for (PlayerEntity player : mc.world.getPlayers()) { if (player.getAbilities().creativeMode || player == mc.player) continue; if (!player.isAlive() || !Friends.get().shouldAttack(player)) continue; - if (player.squaredDistanceTo(mc.player) > Math.pow(targetRange.get(), 2)) continue; + if (player.distanceTo(mc.player) > targetRange.get()) continue; if (ignoreNakeds.get()) { if (player.getOffHandStack().isEmpty() diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/HoleFiller.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/HoleFiller.java index 1a8e92bbc2..562b3133c7 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/HoleFiller.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/HoleFiller.java @@ -343,7 +343,7 @@ private void setTargets() { targets.clear(); for (PlayerEntity player : mc.world.getPlayers()) { - if (player.squaredDistanceTo(mc.player) > Math.pow(targetRange.get(), 2) || + if (player.distanceTo(mc.player) > targetRange.get() || player.isCreative() || player == mc.player || player.isDead() || diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java index ba3a57e159..2b7170b046 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java @@ -5,9 +5,9 @@ package meteordevelopment.meteorclient.systems.modules.combat; +import baritone.api.BaritoneAPI; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.systems.modules.Categories; @@ -149,10 +149,10 @@ public class KillAura extends Module { .build() ); - private final Setting mobAgeFilter = sgTargeting.add(new EnumSetting.Builder() - .name("mob-age-filter") - .description("Determines the age of the mobs to target (baby, adult, or both).") - .defaultValue(EntityAge.Adult) + private final Setting ignoreBabies = sgTargeting.add(new BoolSetting.Builder() + .name("ignore-babies") + .description("Whether or not to attack baby variants of the entity.") + .defaultValue(true) .build() ); @@ -233,6 +233,7 @@ public class KillAura extends Module { .build() ); + CrystalAura ca = Modules.get().get(CrystalAura.class); private final List targets = new ArrayList<>(); private int switchTimer, hitTimer; private boolean wasPathing = false; @@ -252,7 +253,7 @@ private void onTick(TickEvent.Pre event) { if (pauseOnUse.get() && (mc.interactionManager.isBreakingBlock() || mc.player.isUsingItem())) return; if (onlyOnClick.get() && !mc.options.attackKey.isPressed()) return; if (TickRate.INSTANCE.getTimeSinceLastTick() >= 1f && pauseOnLag.get()) return; - if (pauseOnCA.get() && Modules.get().get(CrystalAura.class).isActive() && Modules.get().get(CrystalAura.class).kaTimer > 0) return; + if (pauseOnCA.get() && ca.isActive() && ca.kaTimer > 0) return; if (onlyOnLook.get()) { Entity targeted = mc.targetedEntity; @@ -269,7 +270,7 @@ private void onTick(TickEvent.Pre event) { if (targets.isEmpty()) { if (wasPathing) { - PathManagers.get().resume(); + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("resume"); wasPathing = false; } return; @@ -297,8 +298,8 @@ private void onTick(TickEvent.Pre event) { if (!itemInHand()) return; if (rotation.get() == RotationMode.Always) Rotations.rotate(Rotations.getYaw(primary), Rotations.getPitch(primary, Target.Body)); - if (pauseOnCombat.get() && PathManagers.get().isPathing() && !wasPathing) { - PathManagers.get().pause(); + if (pauseOnCombat.get() && BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && !wasPathing) { + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("pause"); wasPathing = true; } @@ -326,7 +327,7 @@ private boolean shouldShieldBreak() { private boolean entityCheck(Entity entity) { if (entity.equals(mc.player) || entity.equals(mc.cameraEntity)) return false; - if ((entity instanceof LivingEntity livingEntity && livingEntity.isDead()) || !entity.isAlive()) return false; + if ((entity instanceof LivingEntity && ((LivingEntity) entity).isDead()) || !entity.isAlive()) return false; Box hitbox = entity.getBoundingBox(); if (!PlayerUtils.isWithin( @@ -356,14 +357,7 @@ private boolean entityCheck(Entity entity) { if (!Friends.get().shouldAttack(player)) return false; if (shieldMode.get() == ShieldMode.Ignore && player.blockedByShield(mc.world.getDamageSources().playerAttack(mc.player))) return false; } - if (entity instanceof AnimalEntity animal) { - return switch (mobAgeFilter.get()) { - case Baby -> animal.isBaby(); - case Adult -> !animal.isBaby(); - case Both -> true; - }; - } - return true; + return !(entity instanceof AnimalEntity animal) || !ignoreBabies.get() || !animal.isBaby(); } private boolean delayCheck() { @@ -432,10 +426,4 @@ public enum ShieldMode { Break, None } - - public enum EntityAge { - Baby, - Adult, - Both - } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Surround.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Surround.java index 2584880c19..cb08019359 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Surround.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Surround.java @@ -13,7 +13,6 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; -import meteordevelopment.meteorclient.utils.entity.DamageUtils; import meteordevelopment.meteorclient.utils.player.*; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java index 8e9f1ba7e5..e6f5349cbf 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java @@ -15,13 +15,13 @@ import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.Utils; -import meteordevelopment.meteorclient.utils.entity.DamageUtils; +import meteordevelopment.meteorclient.utils.player.DamageUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.orbit.EventHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.decoration.EndCrystalEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket; +import net.minecraft.network.packet.s2c.play.DisconnectS2CPacket; import net.minecraft.text.Text; public class AutoLog extends Module { @@ -100,46 +100,39 @@ private void onTick(TickEvent.Post event) { return; } if (playerHealth <= health.get()) { - disconnect("Health was lower than " + health.get() + "."); + mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal("[AutoLog] Health was lower than " + health.get() + "."))); if(smartToggle.get()) { this.toggle(); enableHealthListener(); } } - if (smart.get() && playerHealth + mc.player.getAbsorptionAmount() - PlayerUtils.possibleHealthReductions() < health.get()){ - disconnect("Health was going to be lower than " + health.get() + "."); + if(smart.get() && playerHealth + mc.player.getAbsorptionAmount() - PlayerUtils.possibleHealthReductions() < health.get()){ + mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal("[AutoLog] Health was going to be lower than " + health.get() + "."))); if (toggleOff.get()) this.toggle(); } - - if (!onlyTrusted.get() && !instantDeath.get() && !crystalLog.get()) return; // only check all entities if needed - for (Entity entity : mc.world.getEntities()) { - if (entity instanceof PlayerEntity player && player.getUuid() != mc.player.getUuid()) { - if (onlyTrusted.get() && player != mc.player && !Friends.get().isFriend(player)) { - disconnect("A non-trusted player appeared in your render distance."); + if (entity instanceof PlayerEntity && entity.getUuid() != mc.player.getUuid()) { + if (onlyTrusted.get() && entity != mc.player && !Friends.get().isFriend((PlayerEntity) entity)) { + mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal("[AutoLog] A non-trusted player appeared in your render distance."))); if (toggleOff.get()) this.toggle(); break; } - if (instantDeath.get() && PlayerUtils.isWithin(entity, 8) && DamageUtils.getAttackDamage(player, mc.player) + if (PlayerUtils.isWithin(entity, 8) && instantDeath.get() && DamageUtils.getSwordDamage((PlayerEntity) entity, true) > playerHealth + mc.player.getAbsorptionAmount()) { - disconnect("Anti-32k measures."); + mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal("[AutoLog] Anti-32k measures."))); if (toggleOff.get()) this.toggle(); break; } } - if (crystalLog.get() && entity instanceof EndCrystalEntity && PlayerUtils.isWithin(entity, range.get())) { - disconnect("End Crystal appeared within specified range."); + if (entity instanceof EndCrystalEntity && PlayerUtils.isWithin(entity, range.get()) && crystalLog.get()) { + mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal("[AutoLog] End Crystal appeared within specified range."))); if (toggleOff.get()) this.toggle(); } } } - private void disconnect(String reason) { - mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal("[AutoLog] " + reason))); - } - private class StaticListener { @EventHandler private void healthListener(TickEvent.Post event) { @@ -156,11 +149,10 @@ else if (Utils.canUpdate() private final StaticListener staticListener = new StaticListener(); - private void enableHealthListener() { + private void enableHealthListener(){ MeteorClient.EVENT_BUS.subscribe(staticListener); } - - private void disableHealthListener() { + private void disableHealthListener(){ MeteorClient.EVENT_BUS.unsubscribe(staticListener); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java index 14c6889448..b260d10588 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java @@ -147,8 +147,8 @@ public class BetterChat extends Module { .name("extra-lines") .description("The amount of extra chat lines.") .defaultValue(1000) - .min(0) - .sliderRange(0, 1000) + .min(100) + .sliderRange(100, 1000) .visible(longerChatHistory::get) .build() ); @@ -394,8 +394,7 @@ private void drawTexture(DrawContext context, IChatHudLine line, int y) { int startOffset = 0; try { - Matcher m = TIMESTAMP_REGEX.matcher(text); - if (m.find()) startOffset = m.end() + 1; + startOffset = TIMESTAMP_REGEX.matcher(text).end(); } catch (IllegalStateException ignored) {} @@ -414,7 +413,7 @@ private void drawTexture(DrawContext context, IChatHudLine line, int y) { PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(sender.getId()); if (entry == null) return; - Identifier skin = entry.getSkinTextures().texture(); + Identifier skin = entry.getSkinTexture(); context.drawTexture(skin, 0, y, 8, 8, 8, 8, 8, 8, 64, 64); context.drawTexture(skin, 0, y, 8, 8, 40, 8, 8, 8, 64, 64); @@ -541,7 +540,7 @@ public boolean isLongerChat() { public boolean keepHistory() { return isActive() && keepHistory.get(); } - public int getExtraChatLines() { + public int getChatLength() { return longerChatLines.get(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BookBot.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BookBot.java index e3f6980b8b..4a270933c5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BookBot.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BookBot.java @@ -19,8 +19,7 @@ import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.orbit.EventHandler; -import net.minecraft.client.font.TextHandler; -import net.minecraft.item.*; +import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtString; @@ -40,8 +39,10 @@ import java.io.FileReader; import java.io.IOException; import java.nio.ByteBuffer; -import java.util.*; -import java.util.function.Predicate; +import java.util.ArrayList; +import java.util.Optional; +import java.util.PrimitiveIterator; +import java.util.Random; public class BookBot extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -53,6 +54,13 @@ public class BookBot extends Module { .build() ); + private final Setting name = sgGeneral.add(new StringSetting.Builder() + .name("name") + .description("The name you want to give your books.") + .defaultValue("Meteor on Crack!") + .build() + ); + private final Setting pages = sgGeneral.add(new IntSetting.Builder() .name("pages") .description("The number of pages to write per book.") @@ -71,6 +79,13 @@ public class BookBot extends Module { .build() ); + private final Setting count = sgGeneral.add(new BoolSetting.Builder() + .name("append-count") + .description("Whether to append the number of the book to the title.") + .defaultValue(true) + .build() + ); + private final Setting delay = sgGeneral.add(new IntSetting.Builder() .name("delay") .description("The amount of delay between writing books.") @@ -80,29 +95,6 @@ public class BookBot extends Module { .build() ); - private final Setting sign = sgGeneral.add(new BoolSetting.Builder() - .name("sign") - .description("Whether to sign the book.") - .defaultValue(true) - .build() - ); - - private final Setting name = sgGeneral.add(new StringSetting.Builder() - .name("name") - .description("The name you want to give your books.") - .defaultValue("Meteor on Crack!") - .visible(sign::get) - .build() - ); - - private final Setting count = sgGeneral.add(new BoolSetting.Builder() - .name("append-count") - .description("Whether to append the number of the book to the title.") - .defaultValue(true) - .visible(sign::get) - .build() - ); - private File file = new File(MeteorClient.FOLDER, "bookbot.txt"); private final PointerBuffer filters; @@ -165,10 +157,7 @@ public void onActivate() { @EventHandler private void onTick(TickEvent.Post event) { - Predicate bookPredicate = i -> - i.getItem() == Items.WRITABLE_BOOK && (i.getNbt() == null || i.getNbt().get("pages") == null || ((NbtList) i.getNbt().get("pages")).isEmpty()); - - FindItemResult writableBook = InvUtils.find(bookPredicate); + FindItemResult writableBook = InvUtils.find(Items.WRITABLE_BOOK); // Check if there is a book to write if (!writableBook.found()) { @@ -177,7 +166,7 @@ private void onTick(TickEvent.Post event) { } // Move the book into hand - if (!InvUtils.testInMainHand(bookPredicate)) { + if (!InvUtils.testInMainHand(Items.WRITABLE_BOOK)) { InvUtils.move().from(writableBook.slot()).toHotbar(mc.player.getInventory().selectedSlot); return; } @@ -247,61 +236,44 @@ private void onTick(TickEvent.Post event) { private void writeBook(PrimitiveIterator.OfInt chars) { ArrayList pages = new ArrayList<>(); - TextHandler.WidthRetriever widthRetriever = ((TextHandlerAccessor) mc.textRenderer.getTextHandler()).getWidthRetriever(); - int maxPages = mode.get() == Mode.File ? 100 : this.pages.get(); + for (int pageI = 0; pageI < (mode.get() == Mode.File ? 100 : this.pages.get()); pageI++) { + // Check if the stream is empty before creating a new page + if (!chars.hasNext()) break; - int pageIndex = 0; - int lineIndex = 0; + StringBuilder page = new StringBuilder(); - final StringBuilder page = new StringBuilder(); + for (int lineI = 0; lineI < 13; lineI++) { + // Check if the stream is empty before creating a new line + if (!chars.hasNext()) break; - float lineWidth = 0; + double lineWidth = 0; + StringBuilder line = new StringBuilder(); - while (chars.hasNext()) { - int c = chars.nextInt(); + while (true) { + // Check if the stream is empty + if (!chars.hasNext()) break; - if (c == '\r' || c == '\n') { - page.append('\n'); - lineWidth = 0; - lineIndex++; - } else { - float charWidth = widthRetriever.getWidth(c, Style.EMPTY); - - // Reached end of line - if (lineWidth + charWidth > 114f) { - page.append('\n'); - lineWidth = charWidth; - lineIndex++; - // Wrap to next line, unless wrapping to next page - if (lineIndex != 14) page.appendCodePoint(c); - } else if (lineWidth == 0f && c == ' ') { - continue; // Prevent leading space from text wrapping - } else { - lineWidth += charWidth; - page.appendCodePoint(c); - } - } + // Get the next character + int nextChar = chars.nextInt(); - // Reached end of page - if (lineIndex == 14) { - pages.add(page.toString()); - page.setLength(0); - pageIndex++; - lineIndex = 0; + // Ignore newline chars when writing lines, should already be organised + if (nextChar == '\r' || nextChar == '\n') break; - // No more pages - if (pageIndex == maxPages) break; + // Make sure the character will fit on the line + double charWidth = ((TextHandlerAccessor) mc.textRenderer.getTextHandler()).getWidthRetriever().getWidth(nextChar, Style.EMPTY); + if (lineWidth + charWidth > 114) break; - // Wrap to next page - if (c != '\r' && c != '\n') { - page.appendCodePoint(c); + // Append it to the line + line.appendCodePoint(nextChar); + lineWidth += charWidth; } + + // Append the line to the page + page.append(line).append('\n'); } - } - // No more characters, end current page - if (!page.isEmpty() && pageIndex != maxPages) { + // Append page to the page list pages.add(page.toString()); } @@ -319,7 +291,7 @@ private void writeBook(PrimitiveIterator.OfInt chars) { if (!pages.isEmpty()) mc.player.getMainHandStack().setSubNbt("pages", pageNbt); // Send book update to server - mc.player.networkHandler.sendPacket(new BookUpdateC2SPacket(mc.player.getInventory().selectedSlot, pages, sign.get() ? Optional.of(title) : Optional.empty())); + mc.player.networkHandler.sendPacket(new BookUpdateC2SPacket(mc.player.getInventory().selectedSlot, pages, Optional.of(title))); bookCount++; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/DiscordPresence.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/DiscordPresence.java index 3ddd3c98ca..3750694c38 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/DiscordPresence.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/DiscordPresence.java @@ -25,13 +25,13 @@ import meteordevelopment.orbit.EventHandler; import meteordevelopment.starscript.Script; import net.minecraft.client.gui.screen.*; -import net.minecraft.client.gui.screen.multiplayer.AddServerScreen; -import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; -import net.minecraft.client.gui.screen.multiplayer.DirectConnectScreen; import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; import net.minecraft.client.gui.screen.option.*; import net.minecraft.client.gui.screen.pack.PackScreen; -import net.minecraft.client.gui.screen.world.*; +import net.minecraft.client.gui.screen.world.CreateWorldScreen; +import net.minecraft.client.gui.screen.world.EditGameRulesScreen; +import net.minecraft.client.gui.screen.world.EditWorldScreen; +import net.minecraft.client.gui.screen.world.SelectWorldScreen; import net.minecraft.client.realms.gui.screen.RealmsScreen; import net.minecraft.util.Pair; import net.minecraft.util.Util; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/MessageAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/MessageAura.java index 23c795b191..3c63a48401 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/MessageAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/MessageAura.java @@ -43,7 +43,7 @@ private void onEntityAdded(EntityAddedEvent event) { if (!(event.entity instanceof PlayerEntity) || event.entity.getUuid().equals(mc.player.getUuid())) return; if (!ignoreFriends.get() || (ignoreFriends.get() && !Friends.get().isFriend((PlayerEntity)event.entity))) { - ChatUtils.sendPlayerMsg("/msg " + event.entity.getName().getString() + " " + message.get()); + ChatUtils.sendPlayerMsg("/msg " + event.entity.getEntityName() + " " + message.get()); } } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java index 00caf88242..772b97bbb5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java @@ -571,8 +571,7 @@ public WWidget getWidget(GuiTheme theme) { WButton alignCenter = table.add(theme.button("Align Center")).expandX().minWidth(100).widget(); alignCenter.action = () -> { if (mc.player == null) return; - Vec3d pos = Vec3d.ofBottomCenter(mc.player.getBlockPos()); - mc.player.setPosition(pos.x, mc.player.getY(), pos.z); + mc.player.setPosition(Vec3d.ofBottomCenter(mc.player.getBlockPos())); }; table.row(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notifier.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notifier.java index 4a91c48eee..adcbcb2825 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notifier.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notifier.java @@ -154,7 +154,7 @@ private void onEntityAdded(EntityAddedEvent event) { if (!event.entity.getUuid().equals(mc.player.getUuid()) && entities.get().contains(event.entity.getType()) && visualRange.get() && this.event.get() != Event.Despawn) { if (event.entity instanceof PlayerEntity) { if ((!visualRangeIgnoreFriends.get() || !Friends.get().isFriend(((PlayerEntity) event.entity))) && (!visualRangeIgnoreFakes.get() || !(event.entity instanceof FakePlayerEntity))) { - ChatUtils.sendMsg(event.entity.getId() + 100, Formatting.GRAY, "(highlight)%s(default) has entered your visual range!", event.entity.getName().getString()); + ChatUtils.sendMsg(event.entity.getId() + 100, Formatting.GRAY, "(highlight)%s(default) has entered your visual range!", event.entity.getEntityName()); if (visualMakeSound.get()) mc.world.playSoundFromEntity(mc.player, mc.player, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.AMBIENT, 3.0F, 1.0F); @@ -180,7 +180,7 @@ private void onEntityRemoved(EntityRemovedEvent event) { if (!event.entity.getUuid().equals(mc.player.getUuid()) && entities.get().contains(event.entity.getType()) && visualRange.get() && this.event.get() != Event.Spawn) { if (event.entity instanceof PlayerEntity) { if ((!visualRangeIgnoreFriends.get() || !Friends.get().isFriend(((PlayerEntity) event.entity))) && (!visualRangeIgnoreFakes.get() || !(event.entity instanceof FakePlayerEntity))) { - ChatUtils.sendMsg(event.entity.getId() + 100, Formatting.GRAY, "(highlight)%s(default) has left your visual range!", event.entity.getName().getString()); + ChatUtils.sendMsg(event.entity.getId() + 100, Formatting.GRAY, "(highlight)%s(default) has left your visual range!", event.entity.getEntityName()); if (visualMakeSound.get()) mc.world.playSoundFromEntity(mc.player, mc.player, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.AMBIENT, 3.0F, 1.0F); @@ -202,7 +202,7 @@ private void onEntityRemoved(EntityRemovedEvent event) { if (pearl.getOwner() != null && pearl.getOwner() instanceof PlayerEntity p) { double d = pearlStartPosMap.get(i).distanceTo(e.getPos()); if ((!Friends.get().isFriend(p) || !pearlIgnoreFriends.get()) && (!p.equals(mc.player) || !pearlIgnoreOwn.get())) { - info("(highlight)%s's(default) pearl landed at %d, %d, %d (highlight)(%.1fm away, travelled %.1fm)(default).", pearl.getOwner().getName().getString(), pearl.getBlockPos().getX(), pearl.getBlockPos().getY(), pearl.getBlockPos().getZ(), pearl.distanceTo(mc.player), d); + info("(highlight)%s's(default) pearl landed at %d, %d, %d (highlight)(%.1fm away, travelled %.1fm)(default).", pearl.getOwner().getEntityName(), pearl.getBlockPos().getX(), pearl.getBlockPos().getY(), pearl.getBlockPos().getZ(), pearl.distanceTo(mc.player), d); } } pearlStartPosMap.remove(i); @@ -246,7 +246,7 @@ private void onReceivePacket(PacketEvent.Receive event) { int pops = totemPopMap.getOrDefault(entity.getUuid(), 0); totemPopMap.put(entity.getUuid(), ++pops); - ChatUtils.sendMsg(getChatId(entity), Formatting.GRAY, "(highlight)%s (default)popped (highlight)%d (default)%s.", entity.getName().getString(), pops, pops == 1 ? "totem" : "totems"); + ChatUtils.sendMsg(getChatId(entity), Formatting.GRAY, "(highlight)%s (default)popped (highlight)%d (default)%s.", entity.getEntityName(), pops, pops == 1 ? "totem" : "totems"); } } @@ -260,7 +260,7 @@ private void onTick(TickEvent.Post event) { if (player.deathTime > 0 || player.getHealth() <= 0) { int pops = totemPopMap.removeInt(player.getUuid()); - ChatUtils.sendMsg(getChatId(player), Formatting.GRAY, "(highlight)%s (default)died after popping (highlight)%d (default)%s.", player.getName().getString(), pops, pops == 1 ? "totem" : "totems"); + ChatUtils.sendMsg(getChatId(player), Formatting.GRAY, "(highlight)%s (default)died after popping (highlight)%d (default)%s.", player.getEntityName(), pops, pops == 1 ? "totem" : "totems"); chatIdMap.removeInt(player.getUuid()); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java index dd0b910d15..8386f1600a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java @@ -8,14 +8,14 @@ import io.netty.buffer.Unpooled; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.packets.PacketEvent; +import meteordevelopment.meteorclient.mixin.CustomPayloadC2SPacketAccessor; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.orbit.EventHandler; import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.packet.BrandCustomPayload; -import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket; -import net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket; +import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket; +import net.minecraft.network.packet.s2c.play.ResourcePackSendS2CPacket; import net.minecraft.text.ClickEvent; import net.minecraft.text.HoverEvent; import net.minecraft.text.MutableText; @@ -77,10 +77,11 @@ private class Listener { private void onPacketSend(PacketEvent.Send event) { if (!isActive()) return; if (!(event.packet instanceof CustomPayloadC2SPacket)) return; - Identifier id = ((CustomPayloadC2SPacket) event.packet).payload().id(); + CustomPayloadC2SPacketAccessor packet = (CustomPayloadC2SPacketAccessor) event.packet; + Identifier id = packet.getChannel(); - if (spoofBrand.get() && id.equals(BrandCustomPayload.ID)) - event.packet.write(new PacketByteBuf(Unpooled.buffer()).writeString(brand.get())); + if (spoofBrand.get() && id.equals(CustomPayloadC2SPacket.BRAND)) + packet.setData(new PacketByteBuf(Unpooled.buffer()).writeString(brand.get())); if (blockChannels.get()) { for (String channel : channels.get()) { @@ -100,12 +101,12 @@ private void onPacketRecieve(PacketEvent.Receive event) { if (!(event.packet instanceof ResourcePackSendS2CPacket packet)) return; event.cancel(); MutableText msg = Text.literal("This server has "); - msg.append(packet.required() ? "a required " : "an optional "); + msg.append(packet.isRequired() ? "a required " : "an optional "); MutableText link = Text.literal("resource pack"); link.setStyle(link.getStyle() .withColor(Formatting.BLUE) .withUnderline(true) - .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, packet.url())) + .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, packet.getURL())) .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to download"))) ); msg.append(link); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmWorker.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmWorker.java index 090a089359..55852e2c8f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmWorker.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/swarm/SwarmWorker.java @@ -5,8 +5,8 @@ package meteordevelopment.meteorclient.systems.modules.misc.swarm; +import baritone.api.BaritoneAPI; import meteordevelopment.meteorclient.commands.Commands; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.utils.player.ChatUtils; import net.minecraft.block.Block; @@ -68,7 +68,7 @@ public void disconnect() { e.printStackTrace(); } - PathManagers.get().stop(); + BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); ChatUtils.infoPrefix("Swarm", "Disconnected from host."); @@ -77,10 +77,8 @@ public void disconnect() { public void tick() { if (target == null) return; - - PathManagers.get().stop(); - PathManagers.get().mine(target); - + BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); + BaritoneAPI.getProvider().getPrimaryBaritone().getMineProcess().mine(target); target = null; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWalk.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWalk.java index ccfb619c18..7277b5ecca 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWalk.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWalk.java @@ -5,15 +5,15 @@ package meteordevelopment.meteorclient.systems.modules.movement; +import baritone.api.BaritoneAPI; import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.pathing.NopPathManager; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.settings.EnumSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.misc.input.Input; +import meteordevelopment.meteorclient.utils.world.GoalDirection; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; import net.minecraft.client.option.KeyBinding; @@ -28,8 +28,10 @@ public class AutoWalk extends Module { .onChanged(mode1 -> { if (isActive()) { if (mode1 == Mode.Simple) { - PathManagers.get().stop(); + BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); + goal = null; } else { + timer = 0; createGoal(); } @@ -50,6 +52,9 @@ public class AutoWalk extends Module { .build() ); + private int timer = 0; + private GoalDirection goal; + public AutoWalk() { super(Categories.Movement, "auto-walk", "Automatically walks forward."); } @@ -62,7 +67,9 @@ public void onActivate() { @Override public void onDeactivate() { if (mode.get() == Mode.Simple) unpress(); - else PathManagers.get().stop(); + else BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().cancelEverything(); + + goal = null; } @EventHandler(priority = EventPriority.HIGH) @@ -75,10 +82,12 @@ private void onTick(TickEvent.Pre event) { case Right -> setPressed(mc.options.rightKey, true); } } else { - if (PathManagers.get() instanceof NopPathManager) { - info("Smart mode requires Baritone"); - toggle(); + if (timer > 20) { + timer = 0; + goal.recalculate(mc.player.getPos()); } + + timer++; } } @@ -95,7 +104,9 @@ private void setPressed(KeyBinding key, boolean pressed) { } private void createGoal() { - PathManagers.get().moveInDirection(mc.player.getYaw()); + timer = 0; + goal = new GoalDirection(mc.player.getPos(), mc.player.getYaw()); + BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(goal); } public enum Mode { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ElytraBoost.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ElytraBoost.java index 4248fadda2..a0b38e253a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ElytraBoost.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ElytraBoost.java @@ -95,7 +95,7 @@ private void boost() { FireworkRocketEntity entity = new FireworkRocketEntity(mc.world, itemStack, mc.player); fireworks.add(entity); if (playSound.get()) mc.world.playSoundFromEntity(mc.player, entity, SoundEvents.ENTITY_FIREWORK_ROCKET_LAUNCH, SoundCategory.AMBIENT, 3.0F, 1.0F); - mc.world.addEntity(entity); + mc.world.addEntity(entity.getId(), entity); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Flight.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Flight.java index bd0d1b6599..33a74f2eb2 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Flight.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Flight.java @@ -146,6 +146,8 @@ private void onPostTick(TickEvent.Post event) { switch (mode.get()) { case Velocity -> { + // TODO: deal with underwater movement, find a way to "spoof" not being in water + mc.player.getAbilities().flying = false; mc.player.setVelocity(0, 0, 0); Vec3d initialVelocity = mc.player.getVelocity(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/GUIMove.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/GUIMove.java index f9ed75835a..0c3bc94cca 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/GUIMove.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/GUIMove.java @@ -7,7 +7,6 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.meteor.KeyEvent; -import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.gui.WidgetScreen; import meteordevelopment.meteorclient.mixin.CreativeInventoryScreenAccessor; @@ -87,7 +86,7 @@ public enum Screens { .min(0) .build() ); - + public GUIMove() { super(Categories.Movement, "gui-move", "Allows you to perform various actions while in GUIs."); } @@ -104,13 +103,6 @@ public void onDeactivate() { if (sprint.get()) set(mc.options.sprintKey, false); } - public boolean disableSpace() { - return isActive() && jump.get() && mc.options.jumpKey.isDefault(); - } - public boolean disableArrows() { - return isActive() && arrowsRotate.get(); - } - @EventHandler private void onTick(TickEvent.Pre event) { if (skip()) return; @@ -126,25 +118,16 @@ private void onTick(TickEvent.Pre event) { if (sneak.get()) set(mc.options.sneakKey, Input.isPressed(mc.options.sneakKey)); if (sprint.get()) set(mc.options.sprintKey, Input.isPressed(mc.options.sprintKey)); - } - - @EventHandler - private void onRender3D(Render3DEvent event) { - if (skip()) return; - if (screens.get() == Screens.GUI && !(mc.currentScreen instanceof WidgetScreen)) return; - if (screens.get() == Screens.Inventory && mc.currentScreen instanceof WidgetScreen) return; - - float rotationDelta = Math.min((float) (rotateSpeed.get() * event.frameTime * 20f), 100); - if (arrowsRotate.get()) { float yaw = mc.player.getYaw(); float pitch = mc.player.getPitch(); - if (Input.isKeyPressed(GLFW_KEY_LEFT)) yaw -= rotationDelta; - if (Input.isKeyPressed(GLFW_KEY_RIGHT)) yaw += rotationDelta; - if (Input.isKeyPressed(GLFW_KEY_UP)) pitch -= rotationDelta; - if (Input.isKeyPressed(GLFW_KEY_DOWN)) pitch += rotationDelta; - + for (int i = 0; i < (rotateSpeed.get() * 2); i++) { + if (Input.isKeyPressed(GLFW_KEY_LEFT)) yaw -= 0.5; + if (Input.isKeyPressed(GLFW_KEY_RIGHT)) yaw += 0.5; + if (Input.isKeyPressed(GLFW_KEY_UP)) pitch -= 0.5; + if (Input.isKeyPressed(GLFW_KEY_DOWN)) pitch += 0.5; + } pitch = MathHelper.clamp(pitch, -90, 90); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java index ff0ab134df..3b7a6b68c2 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.systems.modules.movement; +import baritone.api.BaritoneAPI; import com.google.common.collect.Streams; import meteordevelopment.meteorclient.events.entity.player.CanWalkOnFluidEvent; import meteordevelopment.meteorclient.events.packets.PacketEvent; @@ -12,17 +13,14 @@ import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.mixin.LivingEntityAccessor; import meteordevelopment.meteorclient.mixininterface.IVec3d; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; -import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.orbit.EventHandler; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.enchantment.ProtectionEnchantment; -import net.minecraft.entity.EntityType; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.fluid.Fluids; import net.minecraft.network.packet.Packet; @@ -146,8 +144,8 @@ public class Jesus extends Module { private int tickTimer = 10; private int packetTimer = 0; - private boolean prePathManagerWalkOnWater; - private boolean prePathManagerWalkOnLava; + private boolean preBaritoneAssumeWalkOnWater; + private boolean preBaritoneAssumeWalkOnLava; public Jesus() { super(Categories.Movement, "jesus", "Walk on liquids and powder snow like Jesus."); @@ -155,17 +153,17 @@ public Jesus() { @Override public void onActivate() { - prePathManagerWalkOnWater = PathManagers.get().getSettings().getWalkOnWater().get(); - prePathManagerWalkOnLava = PathManagers.get().getSettings().getWalkOnLava().get(); + preBaritoneAssumeWalkOnWater = BaritoneAPI.getSettings().assumeWalkOnWater.value; + preBaritoneAssumeWalkOnLava = BaritoneAPI.getSettings().assumeWalkOnLava.value; - PathManagers.get().getSettings().getWalkOnWater().set(waterMode.get() == Mode.Solid); - PathManagers.get().getSettings().getWalkOnLava().set(lavaMode.get() == Mode.Solid); + BaritoneAPI.getSettings().assumeWalkOnWater.value = waterMode.get() == Mode.Solid; + BaritoneAPI.getSettings().assumeWalkOnLava.value = lavaMode.get() == Mode.Solid; } @Override public void onDeactivate() { - PathManagers.get().getSettings().getWalkOnWater().set(prePathManagerWalkOnWater); - PathManagers.get().getSettings().getWalkOnLava().set(prePathManagerWalkOnLava); + BaritoneAPI.getSettings().assumeWalkOnWater.value = preBaritoneAssumeWalkOnWater; + BaritoneAPI.getSettings().assumeWalkOnLava.value = preBaritoneAssumeWalkOnLava; } @EventHandler @@ -271,15 +269,6 @@ private void onSendPacket(PacketEvent.Send event) { private boolean waterShouldBeSolid() { if (EntityUtils.getGameMode(mc.player) == GameMode.SPECTATOR || mc.player.getAbilities().flying) return false; - - if (mc.player.getVehicle() != null) { - EntityType vehicle = mc.player.getVehicle().getType(); - if (vehicle == EntityType.BOAT || vehicle == EntityType.CHEST_BOAT) return false; - } - - if (Modules.get().get(Flight.class).isActive()) return false; - - if (dipIfBurning.get() && mc.player.isOnFire()) return false; if (dipOnSneakWater.get() && mc.options.sneakKey.isPressed()) return false; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java index 0ec72a7f64..6bc05b35bb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java @@ -5,12 +5,12 @@ package meteordevelopment.meteorclient.systems.modules.movement; +import baritone.api.BaritoneAPI; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.mixin.PlayerMoveC2SPacketAccessor; import meteordevelopment.meteorclient.mixininterface.IPlayerMoveC2SPacket; import meteordevelopment.meteorclient.mixininterface.IVec3d; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.EnumSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -92,7 +92,7 @@ public class NoFall extends Module { private boolean placedWater; private BlockPos targetPos; private int timer; - private boolean prePathManagerNoFall; + private int preBaritoneFallHeight; public NoFall() { super(Categories.Movement, "no-fall", "Attempts to prevent you from taking fall damage."); @@ -100,15 +100,14 @@ public NoFall() { @Override public void onActivate() { - prePathManagerNoFall = PathManagers.get().getSettings().getNoFall().get(); - if (mode.get() == Mode.Packet) PathManagers.get().getSettings().getNoFall().set(true); - + preBaritoneFallHeight = BaritoneAPI.getSettings().maxFallHeightNoWater.value; + if (mode.get() == Mode.Packet) BaritoneAPI.getSettings().maxFallHeightNoWater.value = 255; placedWater = false; } @Override public void onDeactivate() { - PathManagers.get().getSettings().getNoFall().set(prePathManagerNoFall); + BaritoneAPI.getSettings().maxFallHeightNoWater.value = preBaritoneFallHeight; } @EventHandler diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Step.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Step.java index 04a9f24bf9..63b2994f3d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Step.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Step.java @@ -5,18 +5,19 @@ package meteordevelopment.meteorclient.systems.modules.movement; +import baritone.api.BaritoneAPI; import com.google.common.collect.Streams; import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; -import meteordevelopment.meteorclient.utils.entity.DamageUtils; +import meteordevelopment.meteorclient.utils.player.DamageUtils; import meteordevelopment.orbit.EventHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.decoration.EndCrystalEntity; -import java.util.OptionalDouble; +import java.util.Comparator; +import java.util.Optional; public class Step extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -54,7 +55,7 @@ public class Step extends Module { ); private float prevStepHeight; - private boolean prevPathManagerStep; + private boolean prevBaritoneAssumeStep; public Step() { super(Categories.Movement, "step", "Allows you to walk up full blocks instantly."); @@ -63,9 +64,9 @@ public Step() { @Override public void onActivate() { prevStepHeight = mc.player.getStepHeight(); + prevBaritoneAssumeStep = BaritoneAPI.getSettings().assumeStep.value; - prevPathManagerStep = PathManagers.get().getSettings().getStep().get(); - PathManagers.get().getSettings().getStep().set(true); + BaritoneAPI.getSettings().assumeStep.value = true; } @EventHandler @@ -83,21 +84,20 @@ private void onTick(TickEvent.Post event) { @Override public void onDeactivate() { mc.player.setStepHeight(prevStepHeight); - - PathManagers.get().getSettings().getStep().set(prevPathManagerStep); + BaritoneAPI.getSettings().assumeStep.value = prevBaritoneAssumeStep; } private float getHealth(){ return mc.player.getHealth() + mc.player.getAbsorptionAmount(); } - private double getExplosionDamage() { - OptionalDouble crystalDamage = Streams.stream(mc.world.getEntities()) + private double getExplosionDamage(){ + Optional crystal = Streams.stream(mc.world.getEntities()) .filter(entity -> entity instanceof EndCrystalEntity) .filter(Entity::isAlive) - .mapToDouble(entity -> DamageUtils.crystalDamage(mc.player, entity.getPos())) - .max(); - return crystalDamage.orElse(0.0); + .max(Comparator.comparingDouble(o -> DamageUtils.crystalDamage(mc.player, o.getPos()))) + .map(entity -> (EndCrystalEntity) entity); + return crystal.map(endCrystalEntity -> DamageUtils.crystalDamage(mc.player, endCrystalEntity.getPos())).orElse(0.0); } public enum ActiveWhen { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoClicker.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoClicker.java index 63f9c8aefd..bf634bc9bb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoClicker.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoClicker.java @@ -31,7 +31,7 @@ public class AutoClicker extends Module { .defaultValue(2) .min(0) .sliderMax(60) - .visible(() -> leftClickMode.get() == Mode.Press) + .visible(() -> leftClickMode.get() != Mode.Disabled) .build() ); @@ -48,7 +48,7 @@ public class AutoClicker extends Module { .defaultValue(2) .min(0) .sliderMax(60) - .visible(() -> rightClickMode.get() == Mode.Press) + .visible(() -> rightClickMode.get() != Mode.Disabled) .build() ); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoEat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoEat.java index 307854c048..2ed7a92a6c 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoEat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoEat.java @@ -5,9 +5,9 @@ package meteordevelopment.meteorclient.systems.modules.player; +import baritone.api.BaritoneAPI; import meteordevelopment.meteorclient.events.entity.player.ItemUseCrosshairTargetEvent; import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; @@ -179,9 +179,9 @@ private void startEating() { } // Pause baritone - if (pauseBaritone.get() && PathManagers.get().isPathing() && !wasBaritone) { + if (pauseBaritone.get() && BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && !wasBaritone) { wasBaritone = true; - PathManagers.get().pause(); + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("pause"); } } @@ -213,7 +213,7 @@ private void stopEating() { // Resume baritone if (pauseBaritone.get() && wasBaritone) { wasBaritone = false; - PathManagers.get().resume(); + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("resume"); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoGap.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoGap.java index 5ce30960c1..9c7aa5eb85 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoGap.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoGap.java @@ -5,9 +5,9 @@ package meteordevelopment.meteorclient.systems.modules.player; +import baritone.api.BaritoneAPI; import meteordevelopment.meteorclient.events.entity.player.ItemUseCrosshairTargetEvent; import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.IntSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -195,9 +195,9 @@ private void startEating() { // Pause baritone wasBaritone = false; - if (pauseBaritone.get() && PathManagers.get().isPathing()) { + if (pauseBaritone.get() && BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing()) { wasBaritone = true; - PathManagers.get().pause(); + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("pause"); } } @@ -228,7 +228,7 @@ private void stopEating() { // Resume baritone if (pauseBaritone.get() && wasBaritone) { - PathManagers.get().resume(); + BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("resume"); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java index f72e2fa1d0..7410c1f427 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java @@ -189,7 +189,7 @@ private boolean shouldStopUsing(ItemStack itemStack) { public static double getScore(ItemStack itemStack, BlockState state, boolean silkTouchEnderChest, boolean fortuneOre, EnchantPreference enchantPreference, Predicate good) { if (!good.test(itemStack) || !isTool(itemStack)) return -1; - if (!itemStack.isSuitableFor(state) && !(itemStack.getItem() instanceof SwordItem && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooShootBlock))) return -1; + if (!itemStack.isSuitableFor(state) && !(itemStack.getItem() instanceof SwordItem && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooSaplingBlock))) return -1; if (silkTouchEnderChest && state.getBlock() == Blocks.ENDER_CHEST @@ -213,7 +213,7 @@ && isFortunable(state.getBlock()) if (enchantPreference == EnchantPreference.Fortune) score += EnchantmentHelper.getLevel(Enchantments.FORTUNE, itemStack); if (enchantPreference == EnchantPreference.SilkTouch) score += EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, itemStack); - if (itemStack.getItem() instanceof SwordItem item && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooShootBlock)) + if (itemStack.getItem() instanceof SwordItem item && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooSaplingBlock)) score += 9000 + (item.getMaterial().getMiningLevel() * 1000); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ChestSwap.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ChestSwap.java index 02baa93623..f9b123a40d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ChestSwap.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/ChestSwap.java @@ -17,7 +17,6 @@ import net.minecraft.item.ArmorItem; import net.minecraft.item.Item; import net.minecraft.item.Items; -import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket; public class ChestSwap extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -36,13 +35,6 @@ public class ChestSwap extends Module { .build() ); - private final Setting closeInventory = sgGeneral.add(new BoolSetting.Builder() - .name("close-inventory") - .description("Sends inventory close after swap.") - .defaultValue(false) - .build() - ); - public ChestSwap() { super(Categories.Player, "chest-swap", "Automatically swaps between a chestplate and an elytra."); } @@ -128,10 +120,6 @@ private void equipElytra() { private void equip(int slot) { InvUtils.move().from(slot).toArmor(2); - if (closeInventory.get()) { - // Notchian clients send a Close Window packet with Window ID 0 to close their inventory even though there is never an Open Screen packet for the inventory. - mc.getNetworkHandler().sendPacket(new CloseHandledScreenC2SPacket(0)); - } } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/FakePlayer.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/FakePlayer.java index bd4480eea4..6946dfddf7 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/FakePlayer.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/FakePlayer.java @@ -56,7 +56,7 @@ public WWidget getWidget(GuiTheme theme) { private void fillTable(GuiTheme theme, WTable table) { for (FakePlayerEntity fakePlayer : FakePlayerManager.getFakePlayers()) { - table.add(theme.label(fakePlayer.getName().getString())); + table.add(theme.label(fakePlayer.getEntityName())); WMinus delete = table.add(theme.minus()).expandCellX().right().widget(); delete.action = () -> { FakePlayerManager.remove(fakePlayer); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.java index 6794b7735b..0af7d1116e 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.java @@ -98,11 +98,11 @@ private void onMouseButton(MouseButtonEvent event) { if (!Friends.get().isFriend(player)) { Friends.get().add(new Friend(player)); - info("Added %s to friends", player.getName().getString()); - if (message.get()) ChatUtils.sendPlayerMsg("/msg " + player.getName() + " I just friended you on Meteor."); + info("Added %s to friends", player.getEntityName()); + if (message.get()) ChatUtils.sendPlayerMsg("/msg " + player.getEntityName() + " I just friended you on Meteor."); } else { Friends.get().remove(Friends.get().get(player)); - info("Removed %s from friends", player.getName().getString()); + info("Removed %s from friends", player.getEntityName()); } return; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java index dd22f2b97f..ba593fb806 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java @@ -229,14 +229,14 @@ private void appendTooltip(ItemStackTooltipEvent event) { NbtCompound tag = event.itemStack.getNbt(); if (tag != null) { - NbtList effects = tag.getList("effects", 10); + NbtList effects = tag.getList("Effects", 10); if (effects != null) { for (int i = 0; i < effects.size(); i++) { NbtCompound effectTag = effects.getCompound(i); byte effectId = effectTag.getByte("EffectId"); int effectDuration = effectTag.contains("EffectDuration") ? effectTag.getInt("EffectDuration") : 160; - StatusEffect type = Registries.STATUS_EFFECT.get(effectId); + StatusEffect type = StatusEffect.byRawId(effectId); if (type != null) { StatusEffectInstance effect = new StatusEffectInstance(type, effectDuration, 0); @@ -325,8 +325,7 @@ private void getTooltipData(TooltipDataEvent event) { // EChest preview else if (event.itemStack.getItem() == Items.ENDER_CHEST && previewEChest()) { - event.tooltipData = EChestMemory.isKnown() ? new ContainerTooltipComponent(EChestMemory.ITEMS, ECHEST_COLOR) - : new TextTooltipComponent(Text.literal("Unknown ender chest inventory.").formatted(Formatting.DARK_RED)); + event.tooltipData = new ContainerTooltipComponent(EChestMemory.ITEMS, ECHEST_COLOR); } // Map preview @@ -417,10 +416,10 @@ public void applyCompactShulkerTooltip(ItemStack stack, List tooltip) { private MutableText getStatusText(StatusEffectInstance effect) { MutableText text = Text.translatable(effect.getTranslationKey()); if (effect.getAmplifier() != 0) { - text.append(String.format(" %d (%s)", effect.getAmplifier() + 1, StatusEffectUtil.getDurationText(effect, 1, mc.world.getTickManager().getTickRate()).getString())); + text.append(String.format(" %d (%s)", effect.getAmplifier() + 1, StatusEffectUtil.getDurationText(effect, 1).getString())); } else { - text.append(String.format(" (%s)", StatusEffectUtil.getDurationText(effect, 1, mc.world.getTickManager().getTickRate()).getString())); + text.append(String.format(" (%s)", StatusEffectUtil.getDurationText(effect, 1).getString())); } if (effect.getEffectType().isBeneficial()) return text.formatted(Formatting.BLUE); @@ -436,7 +435,7 @@ private Text getFirstPage(ItemStack stack) { if (stack.getItem() == Items.WRITABLE_BOOK) return Text.literal(pages.getString(0)); try { - return Text.Serialization.fromLenientJson(pages.getString(0)); + return Text.Serializer.fromLenientJson(pages.getString(0)); } catch (JsonParseException e) { return Text.literal("Invalid book data"); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BreakIndicators.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BreakIndicators.java index ebf448ca16..c24d9942b2 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BreakIndicators.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BreakIndicators.java @@ -129,14 +129,14 @@ private void renderPacket(Render3DEvent event, List blocks) private void renderBlock(Render3DEvent event, Box orig, BlockPos pos, double shrinkFactor, double progress) { Box box = orig.shrink( - orig.getLengthX() * shrinkFactor, - orig.getLengthY() * shrinkFactor, - orig.getLengthZ() * shrinkFactor + orig.getXLength() * shrinkFactor, + orig.getYLength() * shrinkFactor, + orig.getZLength() * shrinkFactor ); - double xShrink = (orig.getLengthX() * shrinkFactor) / 2; - double yShrink = (orig.getLengthY() * shrinkFactor) / 2; - double zShrink = (orig.getLengthZ() * shrinkFactor) / 2; + double xShrink = (orig.getXLength() * shrinkFactor) / 2; + double yShrink = (orig.getYLength() * shrinkFactor) / 2; + double zShrink = (orig.getZLength() * shrinkFactor) / 2; double x1 = pos.getX() + box.minX + xShrink; double y1 = pos.getY() + box.minY + yShrink; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ESP.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ESP.java index 080d164d8e..b1699e4487 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ESP.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/ESP.java @@ -314,10 +314,10 @@ public Color getColor(Entity entity) { } private double getFadeAlpha(Entity entity) { - double dist = PlayerUtils.squaredDistanceToCamera(entity.getX() + entity.getWidth() / 2, entity.getY() + entity.getEyeHeight(entity.getPose()), entity.getZ() + entity.getWidth() / 2); + double dist = PlayerUtils.distanceToCamera(entity.getX() + entity.getWidth() / 2, entity.getY() + entity.getEyeHeight(entity.getPose()), entity.getZ() + entity.getWidth() / 2); double fadeDist = Math.pow(fadeDistance.get(), 2); double alpha = 1; - if (dist <= fadeDist * fadeDist) alpha = (float) (Math.sqrt(dist) / fadeDist); + if (dist <= fadeDist) alpha = (float) (dist / fadeDist); if (alpha <= 0.075) alpha = 0; return alpha; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/EntityOwner.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/EntityOwner.java index 5b2f672650..cc1c4db427 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/EntityOwner.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/EntityOwner.java @@ -110,7 +110,7 @@ private void renderNametag(String name) { private String getOwnerName(UUID uuid) { // Check if the player is online PlayerEntity player = mc.world.getPlayerByUuid(uuid); - if (player != null) return player.getName().getString(); + if (player != null) return player.getEntityName(); // Check cache String name = uuidToName.get(uuid); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Freecam.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Freecam.java index 3d85e15f92..9bb2e9ad20 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Freecam.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Freecam.java @@ -144,20 +144,15 @@ public void onActivate() { Utils.set(pos, mc.gameRenderer.getCamera().getPos()); Utils.set(prevPos, mc.gameRenderer.getCamera().getPos()); - if (mc.options.getPerspective() == Perspective.THIRD_PERSON_FRONT) { - yaw += 180; - pitch *= -1; - } - prevYaw = yaw; prevPitch = pitch; - forward = mc.options.forwardKey.isPressed(); - backward = mc.options.backKey.isPressed(); - right = mc.options.rightKey.isPressed(); - left = mc.options.leftKey.isPressed(); - up = mc.options.jumpKey.isPressed(); - down = mc.options.sneakKey.isPressed(); + forward = false; + backward = false; + right = false; + left = false; + up = false; + down = false; unpress(); if (reloadChunks.get()) mc.worldRenderer.reload(); @@ -340,7 +335,7 @@ else if (mc.options.sneakKey.matchesMouse(event.button)) { @EventHandler(priority = EventPriority.LOW) private void onMouseScroll(MouseScrollEvent event) { - if (speedScrollSensitivity.get() > 0 && mc.currentScreen == null) { + if (speedScrollSensitivity.get() > 0) { speedValue += event.value * 0.25 * (speedScrollSensitivity.get() * speedValue); if (speedValue < 0.1) speedValue = 0.1; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Fullbright.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Fullbright.java index d039356086..5c51a78b45 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Fullbright.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Fullbright.java @@ -11,7 +11,6 @@ import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; -import net.minecraft.world.LightType; public class Fullbright extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -20,20 +19,6 @@ public class Fullbright extends Module { .name("mode") .description("The mode to use for Fullbright.") .defaultValue(Mode.Gamma) - .onChanged(mode -> { - if (mc.worldRenderer != null && isActive()) mc.worldRenderer.reload(); - }) - .build() - ); - - public final Setting lightType = sgGeneral.add(new EnumSetting.Builder() - .name("light-type") - .description("Which type of light to use for Luminance mode.") - .defaultValue(LightType.BLOCK) - .visible(() -> mode.get() == Mode.Luminance) - .onChanged(integer -> { - if (mc.worldRenderer != null && isActive()) mc.worldRenderer.reload(); - }) .build() ); @@ -45,7 +30,7 @@ public class Fullbright extends Module { .range(0, 15) .sliderMax(15) .onChanged(integer -> { - if (mc.worldRenderer != null && isActive()) mc.worldRenderer.reload(); + if (mc.worldRenderer != null) mc.worldRenderer.reload(); }) .build() ); @@ -64,8 +49,8 @@ public void onDeactivate() { if (mode.get() == Mode.Luminance) mc.worldRenderer.reload(); } - public int getLuminance(LightType type) { - if (!isActive() || mode.get() != Mode.Luminance || type != lightType.get()) return 0; + public int getLuminance() { + if (!isActive() || mode.get() != Mode.Luminance) return 0; return minimumLightLevel.get(); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/LightOverlay.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/LightOverlay.java index 32b3f02be0..63be9247c1 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/LightOverlay.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/LightOverlay.java @@ -93,11 +93,16 @@ private void onTick(TickEvent.Pre event) { for (Cross cross : crosses) crossPool.free(cross); crosses.clear(); - int spawnLightLevel = newMobSpawnLightLevel.get() ? 0 : 7; BlockIterator.register(horizontalRange.get(), verticalRange.get(), (blockPos, blockState) -> { - switch (BlockUtils.isValidMobSpawn(blockPos, blockState, spawnLightLevel)) { - case Potential -> crosses.add(crossPool.get().set(blockPos, true)); - case Always -> crosses.add((crossPool.get().set(blockPos, false))); + switch (BlockUtils.isValidMobSpawn(blockPos, newMobSpawnLightLevel.get())) { + case Never: + break; + case Potential: + crosses.add(crossPool.get().set(blockPos, true)); + break; + case Always: + crosses.add((crossPool.get().set(blockPos, false))); + break; } }); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/LogoutSpots.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/LogoutSpots.java index 4bba428fec..4d00e47f44 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/LogoutSpots.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/LogoutSpots.java @@ -212,12 +212,12 @@ public Entry(PlayerEntity entity) { y = entity.getY(); z = entity.getZ() - halfWidth; - xWidth = entity.getBoundingBox().getLengthX(); - zWidth = entity.getBoundingBox().getLengthZ(); - height = entity.getBoundingBox().getLengthY(); + xWidth = entity.getBoundingBox().getXLength(); + zWidth = entity.getBoundingBox().getZLength(); + height = entity.getBoundingBox().getYLength(); uuid = entity.getUuid(); - name = entity.getName().getString(); + name = entity.getEntityName(); health = Math.round(entity.getHealth() + entity.getAbsorptionAmount()); maxHealth = Math.round(entity.getMaxHealth() + entity.getAbsorptionAmount()); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java index 79d51bc625..c343ce6bdc 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java @@ -391,8 +391,8 @@ private void renderNametagPlayer(Render2DEvent event, PlayerEntity player, boole String name; Color nameColor = PlayerUtils.getPlayerColor(player, this.nameColor.get()); - if (player == mc.player) name = Modules.get().get(NameProtect.class).getName(player.getName().getString()); - else name = player.getName().getString(); + if (player == mc.player) name = Modules.get().get(NameProtect.class).getName(player.getEntityName()); + else name = player.getEntityName(); // Health float absorption = player.getAbsorptionAmount(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java index 4c28321b0f..45b64bf019 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java @@ -5,8 +5,10 @@ package meteordevelopment.meteorclient.systems.modules.render; +import baritone.api.BaritoneAPI; +import baritone.api.IBaritone; +import baritone.api.pathing.goals.GoalGetToBlock; import meteordevelopment.meteorclient.events.game.OpenScreenEvent; -import meteordevelopment.meteorclient.events.render.Render2DEvent; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.renderer.GuiRenderer; import meteordevelopment.meteorclient.gui.screens.EditSystemScreen; @@ -16,8 +18,6 @@ import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; import meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox; import meteordevelopment.meteorclient.gui.widgets.pressable.WMinus; -import meteordevelopment.meteorclient.pathing.PathManagers; -import meteordevelopment.meteorclient.renderer.text.TextRenderer; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; @@ -25,7 +25,6 @@ import meteordevelopment.meteorclient.systems.waypoints.Waypoints; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; -import meteordevelopment.meteorclient.utils.render.NametagUtils; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.orbit.EventHandler; import net.minecraft.client.gui.screen.DeathScreen; @@ -33,7 +32,6 @@ import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import org.joml.Vector3d; import java.text.SimpleDateFormat; import java.util.Date; @@ -43,7 +41,6 @@ public class WaypointsModule extends Module { private static final Color GRAY = new Color(200, 200, 200); - private static final Color TEXT = new Color(255, 255, 255); private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgDeathPosition = settings.createGroup("Death Position"); @@ -80,64 +77,6 @@ public WaypointsModule() { private final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); - @EventHandler - private void onRender2D(Render2DEvent event) { - TextRenderer text = TextRenderer.get(); - Vector3d center = new Vector3d(mc.getWindow().getFramebufferWidth() / 2.0, mc.getWindow().getFramebufferHeight() / 2.0, 0); - int textRenderDist = textRenderDistance.get(); - - for (Waypoint waypoint : Waypoints.get()) { - // Continue if this waypoint should not be rendered - if (!waypoint.visible.get() || !Waypoints.checkDimension(waypoint)) continue; - - // Calculate distance - BlockPos blockPos = waypoint.getPos(); - Vector3d pos = new Vector3d(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5); - double dist = PlayerUtils.distanceToCamera(pos.x, pos.y, pos.z); - - // Continue if this waypoint should not be rendered - if (dist > waypoint.maxVisible.get()) continue; - if (!NametagUtils.to2D(pos, 1)) continue; - - // Calculate alpha and distance to center of the screen - double distToCenter = pos.distance(center); - double a = 1; - - if (dist < 20) { - a = (dist - 10) / 10; - if (a < 0.01) continue; - } - - // Render - NametagUtils.scale = waypoint.scale.get() - 0.2; - NametagUtils.begin(pos); - - // Render icon - waypoint.renderIcon(-16, -16, a, 32); - - // Render text if cursor is close enough - if (distToCenter <= textRenderDist) { - // Setup text rendering - int preTextA = TEXT.a; - TEXT.a *= a; - text.begin(); - - // Render name - text.render(waypoint.name.get(), -text.getWidth(waypoint.name.get()) / 2, -16 - text.getHeight(), TEXT, true); - - // Render distance - String distText = String.format("%d blocks", (int) Math.round(dist)); - text.render(distText, -text.getWidth(distText) / 2, 16, TEXT, true); - - // End text rendering - text.end(); - TEXT.a = preTextA; - } - - NametagUtils.end(); - } - } - @EventHandler private void onOpenScreen(OpenScreenEvent event) { if (!(event.screen instanceof DeathScreen)) return; @@ -216,10 +155,9 @@ private void initTable(GuiTheme theme, WTable table) { if (validDim) { WButton gotoB = table.add(theme.button("Goto")).widget(); gotoB.action = () -> { - if (PathManagers.get().isPathing()) - PathManagers.get().stop(); - - PathManagers.get().moveTo(waypoint.getPos()); + IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone(); + if (baritone.getPathingBehavior().isPathing()) baritone.getPathingBehavior().cancelEverything(); + baritone.getCustomGoalProcess().setGoalAndPath(new GoalGetToBlock(waypoint.getPos())); }; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoBreed.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoBreed.java index 1aab0f9a7c..224a96eaf2 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoBreed.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoBreed.java @@ -50,10 +50,10 @@ public class AutoBreed extends Module { .build() ); - private final Setting mobAgeFilter = sgGeneral.add(new EnumSetting.Builder() - .name("mob-age-filter") - .description("Determines the age of the mobs to target (baby, adult, or both).") - .defaultValue(EntityAge.Adult) + private final Setting ignoreBabies = sgGeneral.add(new BoolSetting.Builder() + .name("ignore-babies") + .description("Whether or not to ignore the baby variants of the specified entity.") + .defaultValue(true) .build() ); @@ -71,18 +71,16 @@ public void onActivate() { @EventHandler private void onTick(TickEvent.Pre event) { for (Entity entity : mc.world.getEntities()) { - if (!(entity instanceof AnimalEntity animal)) continue; + AnimalEntity animal; + + if (!(entity instanceof AnimalEntity)) continue; + else animal = (AnimalEntity) entity; if (!entities.get().contains(animal.getType()) - || !switch (mobAgeFilter.get()) { - case Baby -> animal.isBaby(); - case Adult -> !animal.isBaby(); - case Both -> true; - } - || animalsFed.contains(animal) - || !PlayerUtils.isWithin(animal, range.get()) - || !animal.isBreedingItem(hand.get() == Hand.MAIN_HAND ? mc.player.getMainHandStack() : mc.player.getOffHandStack())) - continue; + || (animal.isBaby() && !ignoreBabies.get()) + || animalsFed.contains(animal) + || !PlayerUtils.isWithin(animal, range.get()) + || !animal.isBreedingItem(hand.get() == Hand.MAIN_HAND ? mc.player.getMainHandStack() : mc.player.getOffHandStack())) continue; Rotations.rotate(Rotations.getYaw(entity), Rotations.getPitch(entity), -100, () -> { mc.interactionManager.interactEntity(mc.player, animal, hand.get()); @@ -93,10 +91,4 @@ private void onTick(TickEvent.Pre event) { return; } } - - public enum EntityAge { - Baby, - Adult, - Both - } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoNametag.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoNametag.java index 3e1ea5576a..d9e92c68ef 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoNametag.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoNametag.java @@ -86,9 +86,9 @@ private void onTick(TickEvent.Pre event) { if (!PlayerUtils.isWithin(entity, range.get())) return false; if (!entities.get().contains(entity.getType())) return false; if (entity.hasCustomName()) { - return renametag.get() && !entity.getCustomName().equals(mc.player.getInventory().getStack(findNametag.slot()).getName()); + return renametag.get() && entity.getCustomName() != mc.player.getInventory().getStack(findNametag.slot()).getName(); } - return true; + return false; }, priority.get()); if (target == null) return; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java index 1eb6ff4e5d..3d6585f945 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Flamethrower.java @@ -125,7 +125,7 @@ private void interact() { Block block = mc.world.getBlockState(entity.getBlockPos()).getBlock(); Block bottom = mc.world.getBlockState(entity.getBlockPos().down()).getBlock(); if (block == Blocks.WATER || bottom == Blocks.WATER || bottom == Blocks.DIRT_PATH) return; - if (block == Blocks.GRASS_BLOCK) mc.interactionManager.attackBlock(entity.getBlockPos(), Direction.DOWN); + if (block == Blocks.GRASS) mc.interactionManager.attackBlock(entity.getBlockPos(), Direction.DOWN); if (putOutFire.get() && entity instanceof LivingEntity animal && animal.getHealth() < 1) { mc.interactionManager.attackBlock(entity.getBlockPos(), Direction.DOWN); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java index b1618bb819..1d8eb64b1b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java @@ -27,7 +27,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.PickaxeItem; -import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket; +import net.minecraft.network.packet.s2c.play.DisconnectS2CPacket; import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java index ff2eff1a99..b3123ee743 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java @@ -275,7 +275,7 @@ private void onRender(Render3DEvent event) { if (enableRenderBounding.get()){ // Render bounding box if cube and should break stuff if (shape.get() != Shape.Sphere && mode.get() != Mode.Smash) { - box = new Box(pos1.toCenterPos(), pos2.toCenterPos()); + box = new Box(pos1, pos2); event.renderer.box(box, sideColorBox.get(), lineColorBox.get(), shapeModeBox.get(), 0); } } @@ -341,7 +341,7 @@ private void onTickPre(TickEvent.Pre event) { if (mode.get() == Mode.Flatten){ pos1.setY((int) Math.floor(pY)); } - box = new Box(pos1.toCenterPos(), pos2.toCenterPos()); + box = new Box(pos1, pos2); // Find blocks to break BlockIterator.register(Math.max((int) Math.ceil(range.get()+1), maxh), Math.max((int) Math.ceil(range.get()), maxv), (blockPos, blockState) -> { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/SpawnProofer.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/SpawnProofer.java index 0e7354008a..49066626ff 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/SpawnProofer.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/SpawnProofer.java @@ -96,10 +96,8 @@ private void onTickPre(TickEvent.Pre event) { // Find spawn locations for (BlockPos.Mutable blockPos : spawns) spawnPool.free(blockPos); spawns.clear(); - - int lightLevel = newMobSpawnLightLevel.get() ? 0 : 7; BlockIterator.register(range.get(), range.get(), (blockPos, blockState) -> { - BlockUtils.MobSpawn spawn = BlockUtils.isValidMobSpawn(blockPos, blockState, lightLevel); + BlockUtils.MobSpawn spawn = BlockUtils.isValidMobSpawn(blockPos, newMobSpawnLightLevel.get()); if ((spawn == BlockUtils.MobSpawn.Always && (mode.get() == Mode.Always || mode.get() == Mode.Both)) || spawn == BlockUtils.MobSpawn.Potential && (mode.get() == Mode.Potential || mode.get() == Mode.Both)) { @@ -167,10 +165,7 @@ private boolean isNonOpaqueBlock(Block block) { block instanceof AbstractPressurePlateBlock || block instanceof TransparentBlock || block instanceof TripwireBlock || - block instanceof CarpetBlock || - block instanceof LeverBlock || - block instanceof AbstractRedstoneGateBlock || - block instanceof AbstractRailBlock; + block instanceof CarpetBlock; } private boolean isLightSource(Block block) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/StashFinder.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/StashFinder.java index 3cfc6b6d86..b79aa52617 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/StashFinder.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/StashFinder.java @@ -5,6 +5,8 @@ package meteordevelopment.meteorclient.systems.modules.world; +import baritone.api.BaritoneAPI; +import baritone.api.pathing.goals.GoalXZ; import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -17,7 +19,6 @@ import meteordevelopment.meteorclient.gui.widgets.containers.WVerticalList; import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; import meteordevelopment.meteorclient.gui.widgets.pressable.WMinus; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; @@ -26,7 +27,6 @@ import meteordevelopment.orbit.EventHandler; import net.minecraft.block.entity.*; import net.minecraft.item.Items; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import java.io.*; @@ -170,7 +170,7 @@ private void fillTable(GuiTheme theme, WTable table) { open.action = () -> mc.setScreen(new ChunkScreen(theme, chunk)); WButton gotoBtn = table.add(theme.button("Goto")).widget(); - gotoBtn.action = () -> PathManagers.get().moveTo(new BlockPos(chunk.x, 0, chunk.z), true); + gotoBtn.action = () -> BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(chunk.x, chunk.z)); WMinus delete = table.add(theme.minus()).widget(); delete.action = () -> { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/VeinMiner.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/VeinMiner.java index ca985ce861..36781f8748 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/VeinMiner.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/VeinMiner.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.systems.modules.world; +import com.google.common.collect.Sets; import meteordevelopment.meteorclient.events.entity.player.StartBreakingBlockEvent; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; @@ -36,7 +37,7 @@ public class VeinMiner extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgRender = settings.createGroup("Render"); - private final Set blockNeighbours = Set.of( + private final Set blockNeighbours = Sets.newHashSet( new Vec3i(1, -1, 1), new Vec3i(0, -1, 1), new Vec3i(-1, -1, 1), new Vec3i(1, -1, 0), new Vec3i(0, -1, 0), new Vec3i(-1, -1, 0), new Vec3i(1, -1, -1), new Vec3i(0, -1, -1), new Vec3i(-1, -1, -1), @@ -55,7 +56,7 @@ public class VeinMiner extends Module { private final Setting> selectedBlocks = sgGeneral.add(new BlockListSetting.Builder() .name("blocks") .description("Which blocks to select.") - .defaultValue(Blocks.STONE, Blocks.DIRT, Blocks.GRASS_BLOCK) + .defaultValue(Blocks.STONE, Blocks.DIRT, Blocks.GRASS) .build() ); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoints.java b/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoints.java index 2c624f37e9..dbff5fbf8b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoints.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoints.java @@ -8,12 +8,18 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.game.GameJoinedEvent; import meteordevelopment.meteorclient.events.game.GameLeftEvent; +import meteordevelopment.meteorclient.events.render.Render2DEvent; +import meteordevelopment.meteorclient.renderer.text.TextRenderer; import meteordevelopment.meteorclient.systems.System; import meteordevelopment.meteorclient.systems.Systems; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.WaypointsModule; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.files.StreamUtils; import meteordevelopment.meteorclient.utils.misc.NbtUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; +import meteordevelopment.meteorclient.utils.render.NametagUtils; +import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.world.Dimension; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; @@ -21,6 +27,8 @@ import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.nbt.NbtCompound; +import net.minecraft.util.math.BlockPos; +import org.joml.Vector3d; import java.io.File; import java.io.FileInputStream; @@ -29,12 +37,15 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; +import static meteordevelopment.meteorclient.MeteorClient.mc; + public class Waypoints extends System implements Iterable { public static final String[] BUILTIN_ICONS = {"square", "circle", "triangle", "star", "diamond", "skull"}; + private static final Color TEXT = new Color(255, 255, 255); public final Map icons = new ConcurrentHashMap<>(); - public final Map waypoints = new ConcurrentHashMap<>(); + public Map waypoints = new ConcurrentHashMap<>(); public Waypoints() { super(null); @@ -116,6 +127,67 @@ public static boolean checkDimension(Waypoint waypoint) { return playerOpp && waypointOpp; } + @EventHandler + private void onRender2D(Render2DEvent event) { + WaypointsModule module = Modules.get().get(WaypointsModule.class); + if (!module.isActive()) return; + + TextRenderer text = TextRenderer.get(); + Vector3d center = new Vector3d(mc.getWindow().getFramebufferWidth() / 2.0, mc.getWindow().getFramebufferHeight() / 2.0, 0); + int textRenderDist = module.textRenderDistance.get(); + + for (Waypoint waypoint : this) { + // Continue if this waypoint should not be rendered + if (!waypoint.visible.get() || !checkDimension(waypoint)) continue; + + // Calculate distance + BlockPos blockPos = waypoint.getPos(); + Vector3d pos = new Vector3d(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5); + double dist = PlayerUtils.distanceToCamera(pos.x, pos.y, pos.z); + + // Continue if this waypoint should not be rendered + if (dist > waypoint.maxVisible.get()) continue; + if (!NametagUtils.to2D(pos, 1)) continue; + + // Calculate alpha and distance to center of the screen + double distToCenter = pos.distance(center); + double a = 1; + + if (dist < 20) { + a = (dist - 10) / 10; + if (a < 0.01) continue; + } + + // Render + NametagUtils.scale = waypoint.scale.get() - 0.2; + NametagUtils.begin(pos); + + // Render icon + waypoint.renderIcon(-16, -16, a, 32); + + // Render text if cursor is close enough + if (distToCenter <= textRenderDist) { + // Setup text rendering + int preTextA = TEXT.a; + TEXT.a *= a; + text.begin(); + + // Render name + text.render(waypoint.name.get(), -text.getWidth(waypoint.name.get()) / 2, -16 - text.getHeight(), TEXT, true); + + // Render distance + String distText = String.format("%d blocks", (int) Math.round(dist)); + text.render(distText, -text.getWidth(distText) / 2, 16, TEXT, true); + + // End text rendering + text.end(); + TEXT.a = preTextA; + } + + NametagUtils.end(); + } + } + @Override public File getFile() { if (!Utils.canUpdate()) return null; @@ -149,8 +221,7 @@ public NbtCompound toTag() { @Override public Waypoints fromTag(NbtCompound tag) { Map fromNbt = NbtUtils.listFromTag(tag.getList("waypoints", 10), Waypoint::new).stream().collect(Collectors.toMap(o -> o.name.get().toLowerCase(Locale.ROOT), o -> o)); - this.waypoints.clear(); - this.waypoints.putAll(fromNbt); + this.waypoints = new ConcurrentHashMap<>(fromNbt); return this; } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/ReflectInit.java b/src/main/java/meteordevelopment/meteorclient/utils/ReflectInit.java index 1a2564fefa..1baf3b15ad 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/ReflectInit.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/ReflectInit.java @@ -66,7 +66,7 @@ private static void reflectInit(Method task, Class ann try { task.invoke(null); } catch (IllegalAccessException | InvocationTargetException e) { - throw new IllegalStateException("Error running @%s task '%s.%s'".formatted(annotation.getSimpleName(), task.getDeclaringClass().getSimpleName(), task.getName()), e); + e.printStackTrace(); } catch (NullPointerException e) { throw new RuntimeException("Method \"%s\" using Init annotations from non-static context".formatted(task.getName()), e); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java index 3cbead6f0c..c8e84ac468 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java @@ -56,10 +56,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; -import java.util.Arrays; -import java.util.Iterator; -import java.util.Locale; -import java.util.Random; +import java.util.*; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -339,7 +336,7 @@ public static String getWorldName() { // Multiplayer if (mc.getCurrentServerEntry() != null) { - return mc.getCurrentServerEntry().isRealm() ? "realms" : mc.getCurrentServerEntry().address; + return mc.isConnectedToRealms() ? "realms" : mc.getCurrentServerEntry().address; } return ""; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/DamageUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/DamageUtils.java deleted file mode 100644 index 21eea15e72..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/DamageUtils.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.entity; - -import meteordevelopment.meteorclient.mixininterface.IVec3d; -import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerEntity; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.*; -import net.minecraft.entity.attribute.*; -import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.*; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.*; -import net.minecraft.world.BlockView; -import net.minecraft.world.GameMode; -import net.minecraft.world.Heightmap; -import net.minecraft.world.RaycastContext; -import net.minecraft.world.explosion.Explosion; -import org.jetbrains.annotations.Nullable; - -import static meteordevelopment.meteorclient.MeteorClient.mc; - -public class DamageUtils { - // Explosion damage - - public static float explosionDamage(LivingEntity target, Vec3d origin, float power, boolean predictMovement, BlockPos override, BlockState overrideState) { - if (target == null) return 0f; - if (target instanceof PlayerEntity player && EntityUtils.getGameMode(player) == GameMode.CREATIVE && !(player instanceof FakePlayerEntity)) return 0f; - - Vec3d position = predictMovement ? target.getPos().add(target.getVelocity()) : target.getPos(); - - double modDistance = position.distanceTo(origin); - if (modDistance > power) return 0f; - - Box box = target.getBoundingBox(); - if (predictMovement) box = box.offset(target.getVelocity()); - - double exposure = getExposure(origin, box, override, overrideState); - double impact = (1 - (modDistance / power)) * exposure; - float damage = (int) ((impact * impact + impact) / 2 * 7 * 12 + 1); - - return calculateReductions(damage, target, mc.world.getDamageSources().explosion(null)); - } - - public static float crystalDamage(LivingEntity target, Vec3d crystal, boolean predictMovement, BlockPos obsidianPos) { - return explosionDamage(target, crystal, 12f, predictMovement, obsidianPos, Blocks.OBSIDIAN.getDefaultState()); - } - - public static float crystalDamage(LivingEntity target, Vec3d crystal) { - return explosionDamage(target, crystal, 12f, false, null, null); - } - - public static float bedDamage(LivingEntity target, Vec3d bed) { - return explosionDamage(target, bed, 10f, false, null, null); - } - - public static float anchorDamage(LivingEntity target, Vec3d anchor) { - return explosionDamage(target, anchor, 10f, false, BlockPos.ofFloored(anchor), Blocks.AIR.getDefaultState()); - } - - // Sword damage - - /** - * @see PlayerEntity#attack(Entity) - */ - public static float getAttackDamage(LivingEntity attacker, LivingEntity target) { - float itemDamage = (float) EntityAttributeHelper.getAttributeValue(attacker, EntityAttributes.GENERIC_ATTACK_DAMAGE); - - // Get enchant damage - ItemStack stack = attacker.getStackInHand(attacker.getActiveHand()); - float enchantDamage = EnchantmentHelper.getAttackDamage(stack, target.getGroup()); - - // Factor charge - if (attacker instanceof PlayerEntity playerEntity) { - float charge = playerEntity.getAttackCooldownProgress(0.5f); - itemDamage *= 0.2f + charge * charge * 0.8f; - enchantDamage *= charge; - - // Factor critical hit - if (charge > 0.9f && attacker.fallDistance > 0f && !attacker.isOnGround() && !attacker.isClimbing() && !attacker.isTouchingWater() && !attacker.hasStatusEffect(StatusEffects.BLINDNESS) && !attacker.hasVehicle()) { - itemDamage *= 1.5f; - } - } - - float damage = itemDamage + enchantDamage; - - damage = calculateReductions(damage, target, attacker instanceof PlayerEntity player ? mc.world.getDamageSources().playerAttack(player) : mc.world.getDamageSources().mobAttack(attacker)); - - // Factor Fire Aspect - if (EnchantmentHelper.getFireAspect(attacker) > 0 && !StatusEffectHelper.hasStatusEffect(target, StatusEffects.FIRE_RESISTANCE)) { - damage++; - } - - return damage; - } - - // Fall Damage - - /** - * @see LivingEntity#computeFallDamage(float, float) (float, float, DamageSource) - */ - @SuppressWarnings("JavadocReference") - public static float fallDamage(LivingEntity entity) { - if (entity instanceof PlayerEntity player && player.getAbilities().flying) return 0f; - if (StatusEffectHelper.hasStatusEffect(entity, StatusEffects.SLOW_FALLING) || StatusEffectHelper.hasStatusEffect(entity, StatusEffects.LEVITATION)) return 0f; - - // Fast path - Above the surface - int surface = mc.world.getWorldChunk(entity.getBlockPos()).getHeightmap(Heightmap.Type.MOTION_BLOCKING).get(entity.getBlockX(), entity.getBlockZ()); - if (entity.getBlockY() >= surface) return fallDamageReductions(entity, surface); - - // Under the surface - BlockHitResult raycastResult = mc.world.raycast(new RaycastContext(entity.getPos(), new Vec3d(entity.getX(), mc.world.getBottomY(), entity.getZ()), RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.WATER, entity)); - if (raycastResult.getType() == HitResult.Type.MISS) return 0; - - return fallDamageReductions(entity, raycastResult.getBlockPos().getY()); - } - - private static float fallDamageReductions(LivingEntity entity, int surface) { - int fallHeight = (int) (entity.getY() - surface + entity.fallDistance - 3d); - @Nullable StatusEffectInstance jumpBoostInstance = StatusEffectHelper.getStatusEffect(entity, StatusEffects.JUMP_BOOST); - if (jumpBoostInstance != null) fallHeight -= jumpBoostInstance.getAmplifier() + 1; - - return calculateReductions(fallHeight, entity, mc.world.getDamageSources().fall()); - } - - // Utils - - private static float calculateReductions(float damage, LivingEntity entity, DamageSource damageSource) { - if (damageSource.isScaledWithDifficulty()) { - switch (mc.world.getDifficulty()) { - case PEACEFUL -> { - return 0; - } - case EASY -> damage = Math.min(damage / 2 + 1, damage); - case HARD -> damage *= 1.5f; - } - } - - // Armor reduction - damage = DamageUtil.getDamageLeft(damage, getArmor(entity), (float) EntityAttributeHelper.getAttributeValue(entity, EntityAttributes.GENERIC_ARMOR_TOUGHNESS)); - - // Resistance reduction - damage = resistanceReduction(entity, damage); - - // Protection reduction - damage = protectionReduction(entity, damage, damageSource); - - return Math.max(damage, 0); - } - - private static float getArmor(LivingEntity entity) { - return (float) Math.floor(EntityAttributeHelper.getAttributeValue(entity, EntityAttributes.GENERIC_ARMOR)); - } - - /** - * @see LivingEntity#modifyAppliedDamage(DamageSource, float) - */ - @SuppressWarnings("JavadocReference") - private static float protectionReduction(Entity player, float damage, DamageSource source) { - int protLevel = EnchantmentHelper.getProtectionAmount(player.getArmorItems(), source); - return DamageUtil.getInflictedDamage(damage, protLevel); - } - - /** - * @see LivingEntity#modifyAppliedDamage(DamageSource, float) - */ - @SuppressWarnings("JavadocReference") - private static float resistanceReduction(LivingEntity player, float damage) { - StatusEffectInstance resistance = StatusEffectHelper.getStatusEffect(player, StatusEffects.RESISTANCE); - if (resistance != null) { - int lvl = resistance.getAmplifier() + 1; - damage *= (1 - (lvl * 0.2f)); - } - - return Math.max(damage, 0); - } - - /** - * @see Explosion#getExposure(Vec3d, Entity) - */ - private static float getExposure(Vec3d source, Box box, @Nullable BlockPos override, @Nullable BlockState overrideState) { - double xStep = 1 / ((box.maxX - box.minX) * 2 + 1); - double yStep = 1 / ((box.maxY - box.minY) * 2 + 1); - - if (xStep > 0 && yStep > 0) { - int misses = 0; - int hits = 0; - - xStep = xStep * (box.maxX - box.minX); - yStep = yStep * (box.maxY - box.minY); - - double xOffset = (1 - Math.floor(1 / xStep) * xStep) / 2; - double zOffset = (1 - Math.floor(1 / yStep) * yStep) / 2; - - double startX = box.minX + xOffset; - double startY = box.minY; - double startZ = box.minZ + zOffset; - double endX = box.maxX + xOffset; - double endY = box.maxY; - double endZ = box.maxZ + zOffset; - - Vec3d position = new Vec3d(0, 0, 0); - - for (double x = startX; x <= endX; x += xStep) { - for (double y = startY; y <= endY; y += yStep) { - for (double z = startZ; z <= endZ; z += xStep) { - ((IVec3d) position).set(x, y, z); - - if ((override != null ? raycast(position, source, override, overrideState) : raycast(position, source)) == HitResult.Type.MISS) misses++; - - hits++; - } - } - } - - return (float) misses / hits; - } - - return 0f; - } - - /** - * @see BlockView#raycast(RaycastContext) - */ - private static HitResult.Type raycast(Vec3d start, Vec3d end) { - return BlockView.raycast(start, end, null, (_null, blockPos) -> { - BlockState blockState = mc.world.getBlockState(blockPos); - if (blockState.getBlock().getBlastResistance() < 600) return null; - - BlockHitResult hitResult = blockState.getCollisionShape(mc.world, blockPos).raycast(start, end, blockPos); - return hitResult == null ? null : hitResult.getType(); - }, (_null) -> HitResult.Type.MISS); - } - - - private static HitResult.Type raycast(Vec3d start, Vec3d end, BlockPos override, BlockState overrideState) { - return BlockView.raycast(start, end, null, (_null, blockPos) -> { - BlockState blockState; - if (blockPos.equals(override)) blockState = overrideState; - else { - blockState = mc.world.getBlockState(blockPos); - if (blockState.getBlock().getBlastResistance() < 600) return null; - } - - BlockHitResult hitResult = blockState.getCollisionShape(mc.world, blockPos).raycast(start, end, blockPos); - return hitResult == null ? null : hitResult.getType(); - }, (_null) -> HitResult.Type.MISS); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityAttributeHelper.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityAttributeHelper.java deleted file mode 100644 index 367ce2dcf4..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityAttributeHelper.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.entity; - -import com.google.common.collect.Multimap; -import meteordevelopment.meteorclient.mixin.ShulkerEntityAccessor; -import meteordevelopment.meteorclient.mixininterface.IAttributeContainer; -import meteordevelopment.meteorclient.mixininterface.IEntityAttributeInstance; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.*; -import net.minecraft.entity.mob.ShulkerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.function.Function; - -public class EntityAttributeHelper { - /** - * @see LivingEntity#getAttributes() - */ - public static AttributeContainer getAttributes(LivingEntity entity) { - AttributeContainer attributes = new AttributeContainer(getDefaultForEntity(entity)); - - // Equipment - for (var equipmentSlot : EquipmentSlot.values()) { - ItemStack stack = entity.getEquippedStack(equipmentSlot); - attributes.addTemporaryModifiers(stack.getAttributeModifiers(equipmentSlot)); - } - - // Status effects - for (var statusEffect : StatusEffectHelper.getStatusEffects(entity)) { - statusEffect.getEffectType().onApplied(attributes, statusEffect.getAmplifier()); - } - - handleSpecialCases(entity, attributes::getCustomInstance); - - // Copy tracked attributes - ((IAttributeContainer) attributes).meteor$copyFrom(entity.getAttributes()); - - return attributes; - } - - /** - * @see LivingEntity#getAttributeInstance(EntityAttribute) - */ - public static EntityAttributeInstance getAttributeInstance(LivingEntity entity, EntityAttribute attribute) { - double baseValue = getDefaultForEntity(entity).getBaseValue(attribute); - EntityAttributeInstance attributeInstance = new EntityAttributeInstance(attribute, o1 -> {}); - attributeInstance.setBaseValue(baseValue); - - // Equipment - for (var equipmentSlot : EquipmentSlot.values()) { - ItemStack stack = entity.getEquippedStack(equipmentSlot); - Multimap modifiers = stack.getAttributeModifiers(equipmentSlot); - for (var modifier : modifiers.get(attribute)) attributeInstance.addTemporaryModifier(modifier); - } - - // Status effects - for (var statusEffect : StatusEffectHelper.getStatusEffects(entity)) { - AttributeModifierCreator factory = statusEffect.getEffectType().getAttributeModifiers().get(attribute); - if (factory != null) attributeInstance.addPersistentModifier(factory.createAttributeModifier(statusEffect.getAmplifier())); - } - - handleSpecialCases(entity, someAttribute -> someAttribute == attribute ? attributeInstance : null); - - // Copy tracked modifiers - EntityAttributeInstance trackedInstance = entity.getAttributeInstance(attribute); - if (trackedInstance != null) ((IEntityAttributeInstance) attributeInstance).meteor$copyFrom(trackedInstance); - - return attributeInstance; - } - - /** - * @see LivingEntity#getAttributeValue(EntityAttribute) - */ - public static double getAttributeValue(LivingEntity entity, EntityAttribute attribute) { - return getAttributeInstance(entity, attribute).getValue(); - } - - private static void handleSpecialCases(LivingEntity entity, Function consumer) { - if (entity instanceof ShulkerEntity shulkerEntity) { - if (shulkerEntity.getDataTracker().get(ShulkerEntityAccessor.meteor$getPeekAmount()) == 0) { - @Nullable EntityAttributeInstance attributeInstance = consumer.apply(EntityAttributes.GENERIC_ARMOR); - if (attributeInstance != null) attributeInstance.addPersistentModifier(ShulkerEntityAccessor.meteor$getCoveredArmorBonus()); - } - } - } - - @SuppressWarnings("unchecked") - private static DefaultAttributeContainer getDefaultForEntity(T entity) { - return DefaultAttributeRegistry.get((EntityType) entity.getType()); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityUtils.java index 3fa73c7704..1b2edf76e6 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/entity/EntityUtils.java @@ -116,7 +116,7 @@ public static boolean isInRenderDistance(double posX, double posZ) { public static BlockPos getCityBlock(PlayerEntity player) { if (player == null) return null; - double bestDistanceSquared = 6 * 6; + double bestDistance = 6; Direction bestDirection = null; for (Direction direction : Direction.HORIZONTAL) { @@ -126,9 +126,9 @@ public static BlockPos getCityBlock(PlayerEntity player) { if (block != Blocks.OBSIDIAN && block != Blocks.NETHERITE_BLOCK && block != Blocks.CRYING_OBSIDIAN && block != Blocks.RESPAWN_ANCHOR && block != Blocks.ANCIENT_DEBRIS) continue; - double testDistanceSquared = PlayerUtils.squaredDistanceTo(testPos); - if (testDistanceSquared < bestDistanceSquared) { - bestDistanceSquared = testDistanceSquared; + double testDistance = PlayerUtils.distanceTo(testPos); + if (testDistance < bestDistance) { + bestDistance = testDistance; bestDirection = direction; } } @@ -139,7 +139,7 @@ public static BlockPos getCityBlock(PlayerEntity player) { public static String getName(Entity entity) { if (entity == null) return null; - if (entity instanceof PlayerEntity) return entity.getName().getString(); + if (entity instanceof PlayerEntity) return entity.getEntityName(); return entity.getType().getName().getString(); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/StatusEffectHelper.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/StatusEffectHelper.java deleted file mode 100644 index d809b89c87..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/StatusEffectHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.entity; - -import meteordevelopment.meteorclient.utils.entity.effects.EntityEffectCache; -import meteordevelopment.meteorclient.utils.entity.effects.StatusEffectBruteForce; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectInstance; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -import static meteordevelopment.meteorclient.MeteorClient.mc; - -public class StatusEffectHelper { - @Nullable - public static StatusEffectInstance getStatusEffect(LivingEntity entity, StatusEffect effect) { - if (entity == mc.player) return entity.getStatusEffect(effect); - EntityEffectCache container = StatusEffectBruteForce.fetch(entity); - return container == null ? null : container.statusEffects.get(effect); - } - - public static boolean hasStatusEffect(LivingEntity entity, StatusEffect effect) { - if (entity == mc.player) return entity.hasStatusEffect(effect); - EntityEffectCache container = StatusEffectBruteForce.fetch(entity); - return container != null && container.statusEffects.containsKey(effect); - } - - public static Collection getStatusEffects(LivingEntity entity) { - if (entity == mc.player) return entity.getStatusEffects(); - EntityEffectCache container = StatusEffectBruteForce.fetch(entity); - return container == null ? List.of() : container.statusEffects.values(); - } - - public static Map getActiveStatusEffects(LivingEntity entity) { - if (entity == mc.player) return entity.getActiveStatusEffects(); - EntityEffectCache container = StatusEffectBruteForce.fetch(entity); - return container == null ? Map.of() : container.statusEffects; - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/EffectAttributeModifier.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/EffectAttributeModifier.java deleted file mode 100644 index 6245228704..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/EffectAttributeModifier.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.entity.effects; - -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffects; - -import java.util.UUID; - -public record EffectAttributeModifier(StatusEffect effect, EntityAttribute attribute, UUID id, double value) { - private static final EffectAttributeModifier SPEED = new EffectAttributeModifier(StatusEffects.SPEED, EntityAttributes.GENERIC_MOVEMENT_SPEED, "91AEAA56-376B-4498-935B-2F7F68070635", 0.20000000298023224d); - private static final EffectAttributeModifier SLOWNESS = new EffectAttributeModifier(StatusEffects.SLOWNESS, EntityAttributes.GENERIC_MOVEMENT_SPEED, "7107DE5E-7CE8-4030-940E-514C1F160890", -0.15000000596046448d); - private static final EffectAttributeModifier HASTE = new EffectAttributeModifier(StatusEffects.HASTE, EntityAttributes.GENERIC_ATTACK_SPEED, "AF8B6E3F-3328-4C0A-AA36-5BA2BB9DBEF3", 0.10000000149011612d); - private static final EffectAttributeModifier MINING_FATIGUE = new EffectAttributeModifier(StatusEffects.MINING_FATIGUE, EntityAttributes.GENERIC_ATTACK_SPEED, "55FCED67-E92A-486E-9800-B47F202C4386", -0.10000000149011612d); - private static final EffectAttributeModifier HEALTH_BOOST = new EffectAttributeModifier(StatusEffects.HEALTH_BOOST, EntityAttributes.GENERIC_MAX_HEALTH, "5D6F0BA2-1186-46AC-B896-C61C5CEE99CC", 4d); - private static final EffectAttributeModifier LUCK = new EffectAttributeModifier(StatusEffects.LUCK, EntityAttributes.GENERIC_LUCK, "03C3C89D-7037-4B42-869F-B146BCB64D2E", 1d); - private static final EffectAttributeModifier UNLUCK = new EffectAttributeModifier(StatusEffects.UNLUCK, EntityAttributes.GENERIC_LUCK, "CC5AF142-2BD2-4215-B636-2605AED11727", -1d); - - public static final EffectAttributeModifier[] ALL = new EffectAttributeModifier[]{SPEED, SLOWNESS, HASTE, MINING_FATIGUE, HEALTH_BOOST, LUCK, UNLUCK}; - public static final EffectAttributeModifier[] BEACON = new EffectAttributeModifier[]{SPEED, HASTE}; - - private EffectAttributeModifier(StatusEffect effect, EntityAttribute attribute, String id, double value) { - this(effect, attribute, UUID.fromString(id), value); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/EntityEffectCache.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/EntityEffectCache.java deleted file mode 100644 index 77a1993697..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/EntityEffectCache.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.entity.effects; - -import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectInstance; - -import java.util.Map; - -public class EntityEffectCache { - public final Map statusEffects = new Reference2ReferenceOpenHashMap<>(); - public int particleColor; - - public void add(StatusEffect effect, int amplifier) { - statusEffects.put(effect, new StatusEffectInstance(effect, amplifier - 1)); - } - - public void add(StatusEffect effect) { - add(effect, 1); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/MutableParticleColor.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/MutableParticleColor.java deleted file mode 100644 index 779f5910e2..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/MutableParticleColor.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.entity.effects; - -import net.minecraft.entity.effect.StatusEffect; - -import java.util.Objects; - -public class MutableParticleColor { - public static final MutableParticleColor EMPTY = new MutableParticleColor(); - - public float r, g, b; - public int a; - - public void add(StatusEffect effect, int amplifier) { - int color = effect.getColor(); - r += (float)(amplifier * (color >> 16 & 255)) / 255.0F; - g += (float)(amplifier * (color >> 8 & 255)) / 255.0F; - b += (float)(amplifier * (color & 255)) / 255.0F; - a += amplifier; - } - - public void add(StatusEffect effect) { - add(effect, 1); - } - - @Override - public int hashCode() { - return Objects.hash(r, g, b, a); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj instanceof MutableParticleColor other) { - return r == other.r && g == other.g && b == other.b && a == other.a; - } - return false; - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/StatusEffectBruteForce.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/StatusEffectBruteForce.java deleted file mode 100644 index 82a6522054..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/effects/StatusEffectBruteForce.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.entity.effects; - -import com.google.common.collect.Sets; -import it.unimi.dsi.fastutil.ints.IntObjectImmutablePair; -import it.unimi.dsi.fastutil.ints.IntObjectPair; -import it.unimi.dsi.fastutil.objects.*; -import meteordevelopment.meteorclient.MeteorClient; -import meteordevelopment.meteorclient.events.game.GameLeftEvent; -import meteordevelopment.meteorclient.mixin.LivingEntityAccessor; -import meteordevelopment.meteorclient.utils.PreInit; -import meteordevelopment.meteorclient.utils.entity.StatusEffectHelper; -import meteordevelopment.orbit.EventHandler; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.AttributeContainer; -import net.minecraft.entity.data.TrackedData; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.registry.Registries; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; -import java.util.Set; - -/** - * @implNote status effect amplifiers, which are usually zero-indexed, are one-indexed here for ease of maths :thumbs_up: - * @author Crosby - */ -public class StatusEffectBruteForce { - private static final TrackedData POTION_SWIRLS_COLOR = LivingEntityAccessor.meteor$getPotionSwirlsColor(); - private static final TrackedData POTION_SWRISL_AMBIENT = LivingEntityAccessor.meteor$getPotionSwirlsAmbient(); - private static final int EMPTY_COLOR = 3694022; - private static final int MAX_DEPTH = 4; - public static final Set ALL_ENTRIES = new ReferenceOpenHashSet<>(); - public static final Set BEACON_ENTRIES = new ReferenceOpenHashSet<>(); - private static final Map PLAYER_EFFECT_MAP = new Object2ObjectOpenHashMap<>(); - private static final Object2ObjectMap, Map> EFFECT_CACHE_MAP = new Object2ObjectOpenHashMap<>(); - private static final Set> NULL_COLORS = new ObjectOpenHashSet<>(); - - // status effects - - private static final StatusEffectEntry ABSORPTION = StatusEffectEntry.of(StatusEffects.ABSORPTION, 1); - private static final StatusEffectEntry ABSORPTION_STRONG = StatusEffectEntry.of(StatusEffects.ABSORPTION, 4); - - @PreInit - public static void initEntries() { - MeteorClient.EVENT_BUS.subscribe(StatusEffectHelper.class); - - BEACON_ENTRIES.add(StatusEffectEntry.of(StatusEffects.STRENGTH, 1)); - BEACON_ENTRIES.add(StatusEffectEntry.of(StatusEffects.STRENGTH, 2)); - BEACON_ENTRIES.add(StatusEffectEntry.of(StatusEffects.JUMP_BOOST, 1)); - BEACON_ENTRIES.add(StatusEffectEntry.of(StatusEffects.JUMP_BOOST, 2)); - BEACON_ENTRIES.add(StatusEffectEntry.of(StatusEffects.REGENERATION, 1)); - BEACON_ENTRIES.add(StatusEffectEntry.of(StatusEffects.REGENERATION, 2)); - BEACON_ENTRIES.add(StatusEffectEntry.of(StatusEffects.RESISTANCE, 1)); - BEACON_ENTRIES.add(StatusEffectEntry.of(StatusEffects.RESISTANCE, 2)); - - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.SPEED, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.SPEED, 2)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.SLOWNESS, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.SLOWNESS, 4)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.SLOWNESS, 6)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.HASTE, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.HASTE, 2)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.MINING_FATIGUE, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.STRENGTH, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.STRENGTH, 2)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.JUMP_BOOST, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.JUMP_BOOST, 2)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.NAUSEA, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.REGENERATION, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.REGENERATION, 2)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.RESISTANCE, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.RESISTANCE, 2)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.FIRE_RESISTANCE, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.WATER_BREATHING, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.INVISIBILITY, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.BLINDNESS, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.NIGHT_VISION, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.HUNGER, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.WEAKNESS, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.POISON, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.POISON, 2)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.WITHER, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.HEALTH_BOOST, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.ABSORPTION, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.ABSORPTION, 4)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.GLOWING, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.LEVITATION, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.LUCK, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.UNLUCK, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.SLOW_FALLING, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.CONDUIT_POWER, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.DOLPHINS_GRACE, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.BAD_OMEN, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.HERO_OF_THE_VILLAGE, 1)); - ALL_ENTRIES.add(StatusEffectEntry.of(StatusEffects.DARKNESS, 1)); - - for (var statusEffectEntry : Registries.STATUS_EFFECT.getEntrySet()) { - if (statusEffectEntry.getValue().isInstant()) continue; - IntObjectPair cacheKey = new IntObjectImmutablePair<>(statusEffectEntry.getValue().getColor(), MutableParticleColor.EMPTY); - EFFECT_CACHE_MAP.put(cacheKey, Map.of(statusEffectEntry.getValue(), new StatusEffectInstance(statusEffectEntry.getValue()))); - - // Primitive modded compat - if (!statusEffectEntry.getKey().getValue().getNamespace().equals("minecraft")) { - ALL_ENTRIES.add(StatusEffectEntry.of(statusEffectEntry.getValue(), 1)); - } - } - } - - /** - * Creates {@link EntityEffectCache} if missing, updates it if required. - */ - public static EntityEffectCache fetch(LivingEntity entity) { - int particleColor = entity.getDataTracker().get(POTION_SWIRLS_COLOR); - if (isEmpty(particleColor)) return null; - EntityEffectCache container = PLAYER_EFFECT_MAP.computeIfAbsent(entity, o -> new EntityEffectCache()); - if (particleColor != container.particleColor) update(particleColor, entity, container); - return container; - } - - @SuppressWarnings("UnstableApiUsage") - private static void update(int particleColor, LivingEntity entity, EntityEffectCache container) { - container.statusEffects.clear(); - container.particleColor = particleColor; - - MutableParticleColor initialColor = new MutableParticleColor(); - Set possibleEntries; - EffectAttributeModifier[] possibleModifiers; - - if (entity.getDataTracker().get(POTION_SWRISL_AMBIENT)) { // entity is only affected by effects from beacons - possibleEntries = BEACON_ENTRIES; - possibleModifiers = EffectAttributeModifier.BEACON; - } else { - // find status effects based on entity flags - if (entity.isGlowing()) { - initialColor.add(StatusEffects.GLOWING); - container.add(StatusEffects.GLOWING); - } - if (entity.isInvisible()) { - initialColor.add(StatusEffects.INVISIBILITY); - container.add(StatusEffects.INVISIBILITY); - } - - // find status effects based on tracked data - int absorptionLevel = Math.round(entity.getAbsorptionAmount() / 4f); - if (absorptionLevel <= 4) { - possibleEntries = new ReferenceOpenHashSet<>(ALL_ENTRIES); - possibleEntries.add(ABSORPTION_STRONG); - if (absorptionLevel <= 1) possibleEntries.add(ABSORPTION); - } else { - possibleEntries = ALL_ENTRIES; - } - - possibleModifiers = EffectAttributeModifier.ALL; - } - - // find status effects based on tracked attributes - AttributeContainer attributes = entity.getAttributes(); - for (var modifier : possibleModifiers) { - if (attributes.hasModifierForAttribute(modifier.attribute(), modifier.id())) { - double value = attributes.getModifierValue(modifier.attribute(), modifier.id()); - int amplifier = (int) Math.round(value / modifier.value()); - initialColor.add(modifier.effect(), amplifier); - container.add(modifier.effect(), amplifier); - } - } - - // In order to minimize collisions, we hash both the particle color, and the initial state (attributes, tracked data, etc.) via the initial color - IntObjectPair cacheKey = new IntObjectImmutablePair<>(particleColor, initialColor); - - // Map#computeIfAbsent(Object, Function) cannot cache null return values, so we use a separate cache for those - if (NULL_COLORS.contains(cacheKey)) return; - - @Nullable Map match = EFFECT_CACHE_MAP.computeIfAbsent(cacheKey, key -> { - for (int depth = 2; depth <= MAX_DEPTH; depth++) { - for (var combination : Sets.combinations(possibleEntries, depth)) { - int color = blend(initialColor, combination); - if (color == particleColor) { - // If the amplifiers of all applied effects match, then it cannot be inferred and should be assumed to be 1 - boolean assumeLowestAmplifier = combination.stream().mapToInt(o -> o.amplifier).reduce((i1, i2) -> i1 == i2 ? i1 : -1).orElse(-1) != -1; - - Map map = new Reference2ObjectOpenHashMap<>(); - - for (var entry : combination) { - map.put(entry.effect, new StatusEffectInstance(entry.effect, 0, assumeLowestAmplifier ? 0 : entry.amplifier - 1)); - } - - return map; - } - } - } - return null; - }); - if (match != null) container.statusEffects.putAll(match); - else NULL_COLORS.add(cacheKey); - } - - @EventHandler - private static void onLeave(GameLeftEvent event) { - PLAYER_EFFECT_MAP.clear(); - } - - private static boolean isEmpty(int particleColor) { - return particleColor == 0 || particleColor == EMPTY_COLOR; - } - - private static int blend(MutableParticleColor color, Iterable entries) { - float r = color.r; - float g = color.g; - float b = color.b; - int a = color.a; - - for (var entry : entries) { - r += entry.r; - g += entry.g; - b += entry.b; - a += entry.amplifier; - } - - r = r / (float) a * 255.0F; - g = g / (float) a * 255.0F; - b = b / (float) a * 255.0F; - - return (int) r << 16 | (int) g << 8 | (int) b; - } - - public record StatusEffectEntry(StatusEffect effect, int amplifier, float r, float g, float b) { - public static StatusEffectEntry of(StatusEffect effect, int amplifier) { - int color = effect.getColor(); - float r = (float)(amplifier * (color >> 16 & 255)) / 255.0F; - float g = (float)(amplifier * (color >> 8 & 255)) / 255.0F; - float b = (float)(amplifier * (color & 255)) / 255.0F; - return new StatusEffectEntry(effect, amplifier, r, g, b); - } - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerEntity.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerEntity.java index 858e65e862..4ddc217c9e 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerEntity.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerEntity.java @@ -6,7 +6,6 @@ package meteordevelopment.meteorclient.utils.entity.fakeplayer; import com.mojang.authlib.GameProfile; -import meteordevelopment.meteorclient.utils.entity.EntityAttributeHelper; import net.minecraft.client.network.OtherClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.entity.player.PlayerEntity; @@ -34,7 +33,7 @@ public FakePlayerEntity(PlayerEntity player, String name, float health, boolean Byte playerModel = player.getDataTracker().get(PlayerEntity.PLAYER_MODEL_PARTS); dataTracker.set(PlayerEntity.PLAYER_MODEL_PARTS, playerModel); - getAttributes().setFrom(EntityAttributeHelper.getAttributes(player)); + getAttributes().setFrom(player.getAttributes()); setPose(player.getPose()); capeX = getX(); @@ -53,7 +52,7 @@ public FakePlayerEntity(PlayerEntity player, String name, float health, boolean public void spawn() { unsetRemoved(); - mc.world.addEntity(this); + mc.world.addEntity(getId(), this); } public void despawn() { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerManager.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerManager.java index b05a47c29a..b6fe58d550 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerManager.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/entity/fakeplayer/FakePlayerManager.java @@ -23,7 +23,7 @@ public static List getFakePlayers() { public static FakePlayerEntity get(String name) { for (FakePlayerEntity fp : ENTITIES) { - if (fp.getName().getString().equals(name)) return fp; + if (fp.getEntityName().equals(name)) return fp; } return null; @@ -39,7 +39,7 @@ public static void add(String name, float health, boolean copyInv) { public static void remove(FakePlayerEntity fp) { ENTITIES.removeIf(fp1 -> { - if (fp1.getName().getString().equals(fp.getName().getString())) { + if (fp1.getEntityName().equals(fp.getEntityName())) { fp1.despawn(); return true; } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/BaritoneUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/BaritoneUtils.java new file mode 100644 index 0000000000..317385d8ea --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/BaritoneUtils.java @@ -0,0 +1,42 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.utils.misc; + +import baritone.api.BaritoneAPI; +import baritone.api.utils.Rotation; + +import java.lang.reflect.Field; + +public class BaritoneUtils { + private static Field targetField; + + public static Rotation getTarget() { + findField(); + if (targetField == null) return null; + + targetField.setAccessible(true); + + try { + return (Rotation) targetField.get(BaritoneAPI.getProvider().getPrimaryBaritone().getLookBehavior()); + } catch (IllegalAccessException e) { + e.printStackTrace(); + return null; + } + } + + private static void findField() { + if (targetField != null) return; + + Class klass = BaritoneAPI.getProvider().getPrimaryBaritone().getLookBehavior().getClass(); + + for (Field field : klass.getDeclaredFields()) { + if (field.getType() == Rotation.class) { + targetField = field; + break; + } + } + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/FakeClientPlayer.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/FakeClientPlayer.java index 7f5a9e8ab3..9ecddf42e3 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/FakeClientPlayer.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/FakeClientPlayer.java @@ -5,10 +5,10 @@ package meteordevelopment.meteorclient.utils.misc; -import com.mojang.authlib.GameProfile; import meteordevelopment.meteorclient.MeteorClient; +import meteordevelopment.meteorclient.events.game.GameJoinedEvent; import meteordevelopment.meteorclient.utils.PreInit; -import net.minecraft.client.network.ClientConnectionState; +import meteordevelopment.orbit.EventHandler; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.OtherClientPlayerEntity; import net.minecraft.client.network.PlayerListEntry; @@ -18,8 +18,6 @@ import net.minecraft.network.NetworkSide; import net.minecraft.world.Difficulty; -import java.util.UUID; - import static meteordevelopment.meteorclient.MeteorClient.mc; public class FakeClientPlayer { @@ -27,7 +25,7 @@ public class FakeClientPlayer { private static PlayerEntity player; private static PlayerListEntry playerListEntry; - private static UUID lastId; + private static String lastId; private static boolean needsNewEntry; @PreInit @@ -35,30 +33,19 @@ public static void init() { MeteorClient.EVENT_BUS.subscribe(FakeClientPlayer.class); } + @EventHandler + private static void onGameJoined(GameJoinedEvent event) { + } + public static PlayerEntity getPlayer() { - UUID id = mc.getSession().getUuidOrNull(); + String id = mc.getSession().getUuid(); if (player == null || (!id.equals(lastId))) { if (world == null) { - world = new ClientWorld( - new ClientPlayNetworkHandler( - mc, - new ClientConnection(NetworkSide.CLIENTBOUND), - new ClientConnectionState(new GameProfile(mc.getSession().getUuidOrNull(), mc.getSession().getUsername()), null, null, null, null, mc.getCurrentServerEntry(), null) - ), // todo test this - new ClientWorld.Properties(Difficulty.NORMAL, false, false), - world.getRegistryKey(), - world.getDimensionEntry(), - 1, - 1, - mc::getProfiler, - null, - false, - 0 - ); + world = new ClientWorld(new ClientPlayNetworkHandler(mc, null, new ClientConnection(NetworkSide.CLIENTBOUND), mc.getCurrentServerEntry(), mc.getSession().getProfile(), null), new ClientWorld.Properties(Difficulty.NORMAL, false, false), world.getRegistryKey(), world.getDimensionEntry(), 1, 1, mc::getProfiler, null, false, 0); } - player = new OtherClientPlayerEntity(world, new GameProfile(id, mc.getSession().getUsername())); + player = new OtherClientPlayerEntity(world, mc.getSession().getProfile()); lastId = id; needsNewEntry = true; @@ -69,7 +56,7 @@ public static PlayerEntity getPlayer() { public static PlayerListEntry getPlayerListEntry() { if (playerListEntry == null || needsNewEntry) { - playerListEntry = new PlayerListEntry(new GameProfile(lastId, mc.getSession().getUsername()), false); + playerListEntry = new PlayerListEntry(mc.getSession().getProfile(), false); needsNewEntry = false; } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java index eba2bba254..242fb36a4b 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java @@ -11,8 +11,6 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.mixin.ClientPlayerInteractionManagerAccessor; import meteordevelopment.meteorclient.mixin.MinecraftClientAccessor; -import meteordevelopment.meteorclient.pathing.BaritoneUtils; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.systems.config.Config; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Modules; @@ -71,7 +69,7 @@ public class MeteorStarscript { private static final BlockPos.Mutable BP = new BlockPos.Mutable(); private static final StringBuilder SB = new StringBuilder(); - @PreInit(dependencies = PathManagers.class) + @PreInit public static void init() { StandardLib.init(ss); @@ -94,15 +92,13 @@ public static void init() { ); // Baritone - if (BaritoneUtils.IS_AVAILABLE) { - ss.set("baritone", new ValueMap() - .set("is_pathing", () -> Value.bool(BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing())) - .set("distance_to_goal", MeteorStarscript::baritoneDistanceToGoal) - .set("process", MeteorStarscript::baritoneProcess) - .set("process_name", MeteorStarscript::baritoneProcessName) - .set("eta", MeteorStarscript::baritoneETA) - ); - } + ss.set("baritone", new ValueMap() + .set("is_pathing", () -> Value.bool(BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing())) + .set("distance_to_goal", MeteorStarscript::baritoneDistanceToGoal) + .set("process", MeteorStarscript::baritoneProcess) + .set("process_name", MeteorStarscript::baritoneProcessName) + .set("eta", MeteorStarscript::baritoneETA) + ); // Camera ss.set("camera", new ValueMap() diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/Names.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/Names.java index 02eadbac79..a5baa4afc6 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/Names.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/Names.java @@ -5,7 +5,6 @@ package meteordevelopment.meteorclient.utils.misc; -import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.game.ResourcePacksReloadedEvent; import meteordevelopment.meteorclient.utils.PreInit; @@ -29,12 +28,12 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; public class Names { - private static final Map statusEffectNames = new Reference2ObjectOpenHashMap<>(16); - private static final Map itemNames = new Reference2ObjectOpenHashMap<>(128); - private static final Map blockNames = new Reference2ObjectOpenHashMap<>(128); - private static final Map enchantmentNames = new Reference2ObjectOpenHashMap<>(16); - private static final Map, String> entityTypeNames = new Reference2ObjectOpenHashMap<>(64); - private static final Map, String> particleTypesNames = new Reference2ObjectOpenHashMap<>(64); + private static final Map statusEffectNames = new HashMap<>(16); + private static final Map itemNames = new HashMap<>(128); + private static final Map blockNames = new HashMap<>(128); + private static final Map enchantmentNames = new HashMap<>(16); + private static final Map, String> entityTypeNames = new HashMap<>(64); + private static final Map, String> particleTypesNames = new HashMap<>(64); private static final Map soundNames = new HashMap<>(64); @PreInit diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/NbtUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/NbtUtils.java index 1b266d7fee..2d961e52b3 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/NbtUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/NbtUtils.java @@ -8,7 +8,10 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.systems.System; import meteordevelopment.meteorclient.utils.render.prompts.OkPrompt; -import net.minecraft.nbt.*; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; +import net.minecraft.nbt.NbtIo; +import net.minecraft.nbt.NbtList; import org.apache.commons.io.output.ByteArrayOutputStream; import java.io.ByteArrayInputStream; @@ -86,7 +89,7 @@ public static NbtCompound fromClipboard(NbtCompound schema) { byte[] data = Base64.getDecoder().decode(mc.keyboard.getClipboard().trim()); ByteArrayInputStream bis = new ByteArrayInputStream(data); - NbtCompound pasted = NbtIo.readCompressed(new DataInputStream(bis), NbtSizeTracker.ofUnlimitedBytes()); + NbtCompound pasted = NbtIo.readCompressed(new DataInputStream(bis)); for (String key : schema.getKeys()) if (!pasted.getKeys().contains(key)) return null; if (!pasted.getString("name").equals(schema.getString("name"))) return null; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/ValueComparableMap.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/ValueComparableMap.java index a5046c916e..04d953a26b 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/ValueComparableMap.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/ValueComparableMap.java @@ -5,31 +5,29 @@ package meteordevelopment.meteorclient.utils.misc; +import com.google.common.collect.Ordering; + import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; public class ValueComparableMap, V> extends TreeMap { - private final transient Map valueMap; + private final Map valueMap; - public ValueComparableMap(final Comparator partialValueComparator) { - this(partialValueComparator, new HashMap<>()); + public ValueComparableMap(final Ordering partialValueOrdering) { + this(partialValueOrdering, new HashMap()); } - private ValueComparableMap(Comparator partialValueComparator, HashMap valueMap) { - super((k1, k2) -> { - int cmp = partialValueComparator.compare(valueMap.get(k1), valueMap.get(k2)); - return cmp != 0 ? cmp : k1.compareTo(k2); - }); - + private ValueComparableMap(Ordering partialValueOrdering, HashMap valueMap) { + super(partialValueOrdering.onResultOf(valueMap::get).compound(Comparator.naturalOrder())); this.valueMap = valueMap; } @Override public V put(K k, V v) { if (valueMap.containsKey(k)) remove(k); - valueMap.put(k, v); + valueMap.put(k,v); return super.put(k, v); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java b/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java index 40dfccaa19..81f44a413f 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java @@ -133,7 +133,7 @@ public void download() { try { String url = URLS.get(name); if (url == null) { - synchronized (TO_REMOVE) { + synchronized (TO_RETRY) { TO_REMOVE.add(this); downloading = false; return; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java index f20229eda3..6e5cbc6123 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.utils.network; +import com.google.common.collect.Iterators; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Lifecycle; import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; @@ -18,11 +19,10 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.random.Random; import org.jetbrains.annotations.NotNull; - import java.util.*; import java.util.stream.Stream; -public abstract class PacketUtils { +public class PacketUtils { public static final Registry>> REGISTRY = new PacketRegistry(); private static final Map>, String> S2C_PACKETS = new HashMap<>(); @@ -36,12 +36,10 @@ public abstract class PacketUtils { C2S_PACKETS_R.put("ClientStatusC2SPacket", net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket.class, "PlayerInteractItemC2SPacket"); C2S_PACKETS_R.put("PlayerInteractItemC2SPacket", net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.login.EnterConfigurationC2SPacket.class, "EnterConfigurationC2SPacket"); - C2S_PACKETS_R.put("EnterConfigurationC2SPacket", net.minecraft.network.packet.c2s.login.EnterConfigurationC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket.class, "SelectMerchantTradeC2SPacket"); - C2S_PACKETS_R.put("SelectMerchantTradeC2SPacket", net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.class, "PlayerActionC2SPacket"); C2S_PACKETS_R.put("PlayerActionC2SPacket", net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket.class, "SelectMerchantTradeC2SPacket"); + C2S_PACKETS_R.put("SelectMerchantTradeC2SPacket", net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket.class, "CommandExecutionC2SPacket"); C2S_PACKETS_R.put("CommandExecutionC2SPacket", net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.RenameItemC2SPacket.class, "RenameItemC2SPacket"); @@ -54,30 +52,30 @@ public abstract class PacketUtils { C2S_PACKETS_R.put("QueryBlockNbtC2SPacket", net.minecraft.network.packet.c2s.play.QueryBlockNbtC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket.class, "PlayerInteractEntityC2SPacket"); C2S_PACKETS_R.put("PlayerInteractEntityC2SPacket", net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdatePlayerAbilitiesC2SPacket.class, "UpdatePlayerAbilitiesC2SPacket"); - C2S_PACKETS_R.put("UpdatePlayerAbilitiesC2SPacket", net.minecraft.network.packet.c2s.play.UpdatePlayerAbilitiesC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket.class, "RequestCommandCompletionsC2SPacket"); C2S_PACKETS_R.put("RequestCommandCompletionsC2SPacket", net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.AcknowledgeReconfigurationC2SPacket.class, "AcknowledgeReconfigurationC2SPacket"); - C2S_PACKETS_R.put("AcknowledgeReconfigurationC2SPacket", net.minecraft.network.packet.c2s.play.AcknowledgeReconfigurationC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdatePlayerAbilitiesC2SPacket.class, "UpdatePlayerAbilitiesC2SPacket"); + C2S_PACKETS_R.put("UpdatePlayerAbilitiesC2SPacket", net.minecraft.network.packet.c2s.play.UpdatePlayerAbilitiesC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.query.QueryRequestC2SPacket.class, "QueryRequestC2SPacket"); C2S_PACKETS_R.put("QueryRequestC2SPacket", net.minecraft.network.packet.c2s.query.QueryRequestC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket.class, "CustomPayloadC2SPacket"); + C2S_PACKETS_R.put("CustomPayloadC2SPacket", net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateCommandBlockC2SPacket.class, "UpdateCommandBlockC2SPacket"); C2S_PACKETS_R.put("UpdateCommandBlockC2SPacket", net.minecraft.network.packet.c2s.play.UpdateCommandBlockC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket.class, "HandSwingC2SPacket"); C2S_PACKETS_R.put("HandSwingC2SPacket", net.minecraft.network.packet.c2s.play.HandSwingC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.AdvancementTabC2SPacket.class, "AdvancementTabC2SPacket"); - C2S_PACKETS_R.put("AdvancementTabC2SPacket", net.minecraft.network.packet.c2s.play.AdvancementTabC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket.class, "ClickSlotC2SPacket"); C2S_PACKETS_R.put("ClickSlotC2SPacket", net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.AcknowledgeChunksC2SPacket.class, "AcknowledgeChunksC2SPacket"); - C2S_PACKETS_R.put("AcknowledgeChunksC2SPacket", net.minecraft.network.packet.c2s.play.AcknowledgeChunksC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.AdvancementTabC2SPacket.class, "AdvancementTabC2SPacket"); + C2S_PACKETS_R.put("AdvancementTabC2SPacket", net.minecraft.network.packet.c2s.play.AdvancementTabC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ClientSettingsC2SPacket.class, "ClientSettingsC2SPacket"); + C2S_PACKETS_R.put("ClientSettingsC2SPacket", net.minecraft.network.packet.c2s.play.ClientSettingsC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.SpectatorTeleportC2SPacket.class, "SpectatorTeleportC2SPacket"); C2S_PACKETS_R.put("SpectatorTeleportC2SPacket", net.minecraft.network.packet.c2s.play.SpectatorTeleportC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.login.LoginKeyC2SPacket.class, "LoginKeyC2SPacket"); - C2S_PACKETS_R.put("LoginKeyC2SPacket", net.minecraft.network.packet.c2s.login.LoginKeyC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateDifficultyLockC2SPacket.class, "UpdateDifficultyLockC2SPacket"); C2S_PACKETS_R.put("UpdateDifficultyLockC2SPacket", net.minecraft.network.packet.c2s.play.UpdateDifficultyLockC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.login.LoginKeyC2SPacket.class, "LoginKeyC2SPacket"); + C2S_PACKETS_R.put("LoginKeyC2SPacket", net.minecraft.network.packet.c2s.login.LoginKeyC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.JigsawGeneratingC2SPacket.class, "JigsawGeneratingC2SPacket"); C2S_PACKETS_R.put("JigsawGeneratingC2SPacket", net.minecraft.network.packet.c2s.play.JigsawGeneratingC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.QueryEntityNbtC2SPacket.class, "QueryEntityNbtC2SPacket"); @@ -86,42 +84,32 @@ public abstract class PacketUtils { C2S_PACKETS_R.put("UpdateSelectedSlotC2SPacket", net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.RecipeCategoryOptionsC2SPacket.class, "RecipeCategoryOptionsC2SPacket"); C2S_PACKETS_R.put("RecipeCategoryOptionsC2SPacket", net.minecraft.network.packet.c2s.play.RecipeCategoryOptionsC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket.class, "ResourcePackStatusC2SPacket"); - C2S_PACKETS_R.put("ResourcePackStatusC2SPacket", net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.class, "PlayerMoveC2SPacket"); C2S_PACKETS_R.put("PlayerMoveC2SPacket", net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.common.ClientOptionsC2SPacket.class, "ClientOptionsC2SPacket"); - C2S_PACKETS_R.put("ClientOptionsC2SPacket", net.minecraft.network.packet.c2s.common.ClientOptionsC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PickFromInventoryC2SPacket.class, "PickFromInventoryC2SPacket"); C2S_PACKETS_R.put("PickFromInventoryC2SPacket", net.minecraft.network.packet.c2s.play.PickFromInventoryC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket.class, "CustomPayloadC2SPacket"); - C2S_PACKETS_R.put("CustomPayloadC2SPacket", net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayerSessionC2SPacket.class, "PlayerSessionC2SPacket"); C2S_PACKETS_R.put("PlayerSessionC2SPacket", net.minecraft.network.packet.c2s.play.PlayerSessionC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket.class, "CloseHandledScreenC2SPacket"); C2S_PACKETS_R.put("CloseHandledScreenC2SPacket", net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.SlotChangedStateC2SPacket.class, "SlotChangedStateC2SPacket"); - C2S_PACKETS_R.put("SlotChangedStateC2SPacket", net.minecraft.network.packet.c2s.play.SlotChangedStateC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.config.ReadyC2SPacket.class, "ReadyC2SPacket"); - C2S_PACKETS_R.put("ReadyC2SPacket", net.minecraft.network.packet.c2s.config.ReadyC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.BoatPaddleStateC2SPacket.class, "BoatPaddleStateC2SPacket"); C2S_PACKETS_R.put("BoatPaddleStateC2SPacket", net.minecraft.network.packet.c2s.play.BoatPaddleStateC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.class, "ChatMessageC2SPacket"); - C2S_PACKETS_R.put("ChatMessageC2SPacket", net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ButtonClickC2SPacket.class, "ButtonClickC2SPacket"); C2S_PACKETS_R.put("ButtonClickC2SPacket", net.minecraft.network.packet.c2s.play.ButtonClickC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.class, "ChatMessageC2SPacket"); + C2S_PACKETS_R.put("ChatMessageC2SPacket", net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateBeaconC2SPacket.class, "UpdateBeaconC2SPacket"); C2S_PACKETS_R.put("UpdateBeaconC2SPacket", net.minecraft.network.packet.c2s.play.UpdateBeaconC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket.class, "UpdateSignC2SPacket"); - C2S_PACKETS_R.put("UpdateSignC2SPacket", net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.TeleportConfirmC2SPacket.class, "TeleportConfirmC2SPacket"); C2S_PACKETS_R.put("TeleportConfirmC2SPacket", net.minecraft.network.packet.c2s.play.TeleportConfirmC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket.class, "UpdateSignC2SPacket"); + C2S_PACKETS_R.put("UpdateSignC2SPacket", net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateStructureBlockC2SPacket.class, "UpdateStructureBlockC2SPacket"); C2S_PACKETS_R.put("UpdateStructureBlockC2SPacket", net.minecraft.network.packet.c2s.play.UpdateStructureBlockC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateCommandBlockMinecartC2SPacket.class, "UpdateCommandBlockMinecartC2SPacket"); C2S_PACKETS_R.put("UpdateCommandBlockMinecartC2SPacket", net.minecraft.network.packet.c2s.play.UpdateCommandBlockMinecartC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.common.CommonPongC2SPacket.class, "CommonPongC2SPacket"); - C2S_PACKETS_R.put("CommonPongC2SPacket", net.minecraft.network.packet.c2s.common.CommonPongC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.KeepAliveC2SPacket.class, "KeepAliveC2SPacket"); + C2S_PACKETS_R.put("KeepAliveC2SPacket", net.minecraft.network.packet.c2s.play.KeepAliveC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayerInputC2SPacket.class, "PlayerInputC2SPacket"); C2S_PACKETS_R.put("PlayerInputC2SPacket", net.minecraft.network.packet.c2s.play.PlayerInputC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.class, "ClientCommandC2SPacket"); @@ -130,22 +118,24 @@ public abstract class PacketUtils { C2S_PACKETS_R.put("UpdateJigsawC2SPacket", net.minecraft.network.packet.c2s.play.UpdateJigsawC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.query.QueryPingC2SPacket.class, "QueryPingC2SPacket"); C2S_PACKETS_R.put("QueryPingC2SPacket", net.minecraft.network.packet.c2s.query.QueryPingC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket.class, "ResourcePackStatusC2SPacket"); + C2S_PACKETS_R.put("ResourcePackStatusC2SPacket", net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayPongC2SPacket.class, "PlayPongC2SPacket"); + C2S_PACKETS_R.put("PlayPongC2SPacket", net.minecraft.network.packet.c2s.play.PlayPongC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.MessageAcknowledgmentC2SPacket.class, "MessageAcknowledgmentC2SPacket"); C2S_PACKETS_R.put("MessageAcknowledgmentC2SPacket", net.minecraft.network.packet.c2s.play.MessageAcknowledgmentC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.common.KeepAliveC2SPacket.class, "KeepAliveC2SPacket"); - C2S_PACKETS_R.put("KeepAliveC2SPacket", net.minecraft.network.packet.c2s.common.KeepAliveC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket.class, "CreativeInventoryActionC2SPacket"); - C2S_PACKETS_R.put("CreativeInventoryActionC2SPacket", net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket.class, "VehicleMoveC2SPacket"); C2S_PACKETS_R.put("VehicleMoveC2SPacket", net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket.class, "CreativeInventoryActionC2SPacket"); + C2S_PACKETS_R.put("CreativeInventoryActionC2SPacket", net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket.class, "BookUpdateC2SPacket"); C2S_PACKETS_R.put("BookUpdateC2SPacket", net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.RecipeBookDataC2SPacket.class, "RecipeBookDataC2SPacket"); C2S_PACKETS_R.put("RecipeBookDataC2SPacket", net.minecraft.network.packet.c2s.play.RecipeBookDataC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.login.LoginQueryResponseC2SPacket.class, "LoginQueryResponseC2SPacket"); - C2S_PACKETS_R.put("LoginQueryResponseC2SPacket", net.minecraft.network.packet.c2s.login.LoginQueryResponseC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket.class, "HandshakeC2SPacket"); C2S_PACKETS_R.put("HandshakeC2SPacket", net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.login.LoginQueryResponseC2SPacket.class, "LoginQueryResponseC2SPacket"); + C2S_PACKETS_R.put("LoginQueryResponseC2SPacket", net.minecraft.network.packet.c2s.login.LoginQueryResponseC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.UpdateDifficultyC2SPacket.class, "UpdateDifficultyC2SPacket"); C2S_PACKETS_R.put("UpdateDifficultyC2SPacket", net.minecraft.network.packet.c2s.play.UpdateDifficultyC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.CraftRequestC2SPacket.class, "CraftRequestC2SPacket"); @@ -163,6 +153,10 @@ public abstract class PacketUtils { S2C_PACKETS_R.put("WorldBorderSizeChangedS2CPacket", net.minecraft.network.packet.s2c.play.WorldBorderSizeChangedS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.AdvancementUpdateS2CPacket.class, "AdvancementUpdateS2CPacket"); S2C_PACKETS_R.put("AdvancementUpdateS2CPacket", net.minecraft.network.packet.s2c.play.AdvancementUpdateS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket.class, "CustomPayloadS2CPacket"); + S2C_PACKETS_R.put("CustomPayloadS2CPacket", net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.FeaturesS2CPacket.class, "FeaturesS2CPacket"); + S2C_PACKETS_R.put("FeaturesS2CPacket", net.minecraft.network.packet.s2c.play.FeaturesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.WorldBorderInterpolateSizeS2CPacket.class, "WorldBorderInterpolateSizeS2CPacket"); S2C_PACKETS_R.put("WorldBorderInterpolateSizeS2CPacket", net.minecraft.network.packet.s2c.play.WorldBorderInterpolateSizeS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChunkLoadDistanceS2CPacket.class, "ChunkLoadDistanceS2CPacket"); @@ -179,48 +173,42 @@ public abstract class PacketUtils { S2C_PACKETS_R.put("RemoveMessageS2CPacket", net.minecraft.network.packet.s2c.play.RemoveMessageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SetCameraEntityS2CPacket.class, "SetCameraEntityS2CPacket"); S2C_PACKETS_R.put("SetCameraEntityS2CPacket", net.minecraft.network.packet.s2c.play.SetCameraEntityS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket.class, "ResourcePackSendS2CPacket"); - S2C_PACKETS_R.put("ResourcePackSendS2CPacket", net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.DamageTiltS2CPacket.class, "DamageTiltS2CPacket"); S2C_PACKETS_R.put("DamageTiltS2CPacket", net.minecraft.network.packet.s2c.play.DamageTiltS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.CraftFailedResponseS2CPacket.class, "CraftFailedResponseS2CPacket"); - S2C_PACKETS_R.put("CraftFailedResponseS2CPacket", net.minecraft.network.packet.s2c.play.CraftFailedResponseS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.StatisticsS2CPacket.class, "StatisticsS2CPacket"); S2C_PACKETS_R.put("StatisticsS2CPacket", net.minecraft.network.packet.s2c.play.StatisticsS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.CraftFailedResponseS2CPacket.class, "CraftFailedResponseS2CPacket"); + S2C_PACKETS_R.put("CraftFailedResponseS2CPacket", net.minecraft.network.packet.s2c.play.CraftFailedResponseS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.login.LoginQueryRequestS2CPacket.class, "LoginQueryRequestS2CPacket"); S2C_PACKETS_R.put("LoginQueryRequestS2CPacket", net.minecraft.network.packet.s2c.login.LoginQueryRequestS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.VehicleMoveS2CPacket.class, "VehicleMoveS2CPacket"); S2C_PACKETS_R.put("VehicleMoveS2CPacket", net.minecraft.network.packet.s2c.play.VehicleMoveS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityAttributesS2CPacket.class, "EntityAttributesS2CPacket"); S2C_PACKETS_R.put("EntityAttributesS2CPacket", net.minecraft.network.packet.s2c.play.EntityAttributesS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.TickStepS2CPacket.class, "TickStepS2CPacket"); - S2C_PACKETS_R.put("TickStepS2CPacket", net.minecraft.network.packet.s2c.play.TickStepS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.StopSoundS2CPacket.class, "StopSoundS2CPacket"); S2C_PACKETS_R.put("StopSoundS2CPacket", net.minecraft.network.packet.s2c.play.StopSoundS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScoreboardObjectiveUpdateS2CPacket.class, "ScoreboardObjectiveUpdateS2CPacket"); S2C_PACKETS_R.put("ScoreboardObjectiveUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ScoreboardObjectiveUpdateS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.StartChunkSendS2CPacket.class, "StartChunkSendS2CPacket"); - S2C_PACKETS_R.put("StartChunkSendS2CPacket", net.minecraft.network.packet.s2c.play.StartChunkSendS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntitySetHeadYawS2CPacket.class, "EntitySetHeadYawS2CPacket"); S2C_PACKETS_R.put("EntitySetHeadYawS2CPacket", net.minecraft.network.packet.s2c.play.EntitySetHeadYawS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SelectAdvancementTabS2CPacket.class, "SelectAdvancementTabS2CPacket"); - S2C_PACKETS_R.put("SelectAdvancementTabS2CPacket", net.minecraft.network.packet.s2c.play.SelectAdvancementTabS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.KeepAliveS2CPacket.class, "KeepAliveS2CPacket"); + S2C_PACKETS_R.put("KeepAliveS2CPacket", net.minecraft.network.packet.s2c.play.KeepAliveS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SetTradeOffersS2CPacket.class, "SetTradeOffersS2CPacket"); S2C_PACKETS_R.put("SetTradeOffersS2CPacket", net.minecraft.network.packet.s2c.play.SetTradeOffersS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SelectAdvancementTabS2CPacket.class, "SelectAdvancementTabS2CPacket"); + S2C_PACKETS_R.put("SelectAdvancementTabS2CPacket", net.minecraft.network.packet.s2c.play.SelectAdvancementTabS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket.class, "PlaySoundS2CPacket"); S2C_PACKETS_R.put("PlaySoundS2CPacket", net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.BlockEventS2CPacket.class, "BlockEventS2CPacket"); S2C_PACKETS_R.put("BlockEventS2CPacket", net.minecraft.network.packet.s2c.play.BlockEventS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket.class, "PlayerPositionLookS2CPacket"); S2C_PACKETS_R.put("PlayerPositionLookS2CPacket", net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChunkSentS2CPacket.class, "ChunkSentS2CPacket"); - S2C_PACKETS_R.put("ChunkSentS2CPacket", net.minecraft.network.packet.s2c.play.ChunkSentS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.HealthUpdateS2CPacket.class, "HealthUpdateS2CPacket"); S2C_PACKETS_R.put("HealthUpdateS2CPacket", net.minecraft.network.packet.s2c.play.HealthUpdateS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayPingS2CPacket.class, "PlayPingS2CPacket"); + S2C_PACKETS_R.put("PlayPingS2CPacket", net.minecraft.network.packet.s2c.play.PlayPingS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.WorldEventS2CPacket.class, "WorldEventS2CPacket"); S2C_PACKETS_R.put("WorldEventS2CPacket", net.minecraft.network.packet.s2c.play.WorldEventS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.SynchronizeTagsS2CPacket.class, "SynchronizeTagsS2CPacket"); - S2C_PACKETS_R.put("SynchronizeTagsS2CPacket", net.minecraft.network.packet.s2c.common.SynchronizeTagsS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ServerMetadataS2CPacket.class, "ServerMetadataS2CPacket"); S2C_PACKETS_R.put("ServerMetadataS2CPacket", net.minecraft.network.packet.s2c.play.ServerMetadataS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.UpdateSelectedSlotS2CPacket.class, "UpdateSelectedSlotS2CPacket"); @@ -229,16 +217,16 @@ public abstract class PacketUtils { S2C_PACKETS_R.put("ChunkDeltaUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket.class, "QueryResponseS2CPacket"); S2C_PACKETS_R.put("QueryResponseS2CPacket", net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.TeamS2CPacket.class, "TeamS2CPacket"); - S2C_PACKETS_R.put("TeamS2CPacket", net.minecraft.network.packet.s2c.play.TeamS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.CooldownUpdateS2CPacket.class, "CooldownUpdateS2CPacket"); S2C_PACKETS_R.put("CooldownUpdateS2CPacket", net.minecraft.network.packet.s2c.play.CooldownUpdateS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket.class, "OpenScreenS2CPacket"); - S2C_PACKETS_R.put("OpenScreenS2CPacket", net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class, "ExperienceOrbSpawnS2CPacket"); - S2C_PACKETS_R.put("ExperienceOrbSpawnS2CPacket", net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.TeamS2CPacket.class, "TeamS2CPacket"); + S2C_PACKETS_R.put("TeamS2CPacket", net.minecraft.network.packet.s2c.play.TeamS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket.class, "EntityAnimationS2CPacket"); S2C_PACKETS_R.put("EntityAnimationS2CPacket", net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class, "ExperienceOrbSpawnS2CPacket"); + S2C_PACKETS_R.put("ExperienceOrbSpawnS2CPacket", net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket.class, "OpenScreenS2CPacket"); + S2C_PACKETS_R.put("OpenScreenS2CPacket", net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket.class, "PlayerAbilitiesS2CPacket"); S2C_PACKETS_R.put("PlayerAbilitiesS2CPacket", net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.WorldBorderWarningBlocksChangedS2CPacket.class, "WorldBorderWarningBlocksChangedS2CPacket"); @@ -251,26 +239,24 @@ public abstract class PacketUtils { S2C_PACKETS_R.put("UnlockRecipesS2CPacket", net.minecraft.network.packet.s2c.play.UnlockRecipesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.LightUpdateS2CPacket.class, "LightUpdateS2CPacket"); S2C_PACKETS_R.put("LightUpdateS2CPacket", net.minecraft.network.packet.s2c.play.LightUpdateS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket.class, "OverlayMessageS2CPacket"); - S2C_PACKETS_R.put("OverlayMessageS2CPacket", net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.WorldBorderInitializeS2CPacket.class, "WorldBorderInitializeS2CPacket"); S2C_PACKETS_R.put("WorldBorderInitializeS2CPacket", net.minecraft.network.packet.s2c.play.WorldBorderInitializeS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket.class, "OverlayMessageS2CPacket"); + S2C_PACKETS_R.put("OverlayMessageS2CPacket", net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.WorldBorderCenterChangedS2CPacket.class, "WorldBorderCenterChangedS2CPacket"); S2C_PACKETS_R.put("WorldBorderCenterChangedS2CPacket", net.minecraft.network.packet.s2c.play.WorldBorderCenterChangedS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket.class, "EntityVelocityUpdateS2CPacket"); - S2C_PACKETS_R.put("EntityVelocityUpdateS2CPacket", net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.DifficultyS2CPacket.class, "DifficultyS2CPacket"); S2C_PACKETS_R.put("DifficultyS2CPacket", net.minecraft.network.packet.s2c.play.DifficultyS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket.class, "EntityVelocityUpdateS2CPacket"); + S2C_PACKETS_R.put("EntityVelocityUpdateS2CPacket", net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.LookAtS2CPacket.class, "LookAtS2CPacket"); S2C_PACKETS_R.put("LookAtS2CPacket", net.minecraft.network.packet.s2c.play.LookAtS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScoreboardScoreUpdateS2CPacket.class, "ScoreboardScoreUpdateS2CPacket"); - S2C_PACKETS_R.put("ScoreboardScoreUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ScoreboardScoreUpdateS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.TitleS2CPacket.class, "TitleS2CPacket"); - S2C_PACKETS_R.put("TitleS2CPacket", net.minecraft.network.packet.s2c.play.TitleS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScreenHandlerPropertyUpdateS2CPacket.class, "ScreenHandlerPropertyUpdateS2CPacket"); S2C_PACKETS_R.put("ScreenHandlerPropertyUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ScreenHandlerPropertyUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OpenHorseScreenS2CPacket.class, "OpenHorseScreenS2CPacket"); S2C_PACKETS_R.put("OpenHorseScreenS2CPacket", net.minecraft.network.packet.s2c.play.OpenHorseScreenS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.TitleS2CPacket.class, "TitleS2CPacket"); + S2C_PACKETS_R.put("TitleS2CPacket", net.minecraft.network.packet.s2c.play.TitleS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SimulationDistanceS2CPacket.class, "SimulationDistanceS2CPacket"); S2C_PACKETS_R.put("SimulationDistanceS2CPacket", net.minecraft.network.packet.s2c.play.SimulationDistanceS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChatSuggestionsS2CPacket.class, "ChatSuggestionsS2CPacket"); @@ -283,66 +269,64 @@ public abstract class PacketUtils { S2C_PACKETS_R.put("DeathMessageS2CPacket", net.minecraft.network.packet.s2c.play.DeathMessageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.MapUpdateS2CPacket.class, "MapUpdateS2CPacket"); S2C_PACKETS_R.put("MapUpdateS2CPacket", net.minecraft.network.packet.s2c.play.MapUpdateS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket.class, "ScreenHandlerSlotUpdateS2CPacket"); - S2C_PACKETS_R.put("ScreenHandlerSlotUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket.class, "BlockEntityUpdateS2CPacket"); S2C_PACKETS_R.put("BlockEntityUpdateS2CPacket", net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket.class, "ScreenHandlerSlotUpdateS2CPacket"); + S2C_PACKETS_R.put("ScreenHandlerSlotUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SynchronizeTagsS2CPacket.class, "SynchronizeTagsS2CPacket"); + S2C_PACKETS_R.put("SynchronizeTagsS2CPacket", net.minecraft.network.packet.s2c.play.SynchronizeTagsS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerSpawnPositionS2CPacket.class, "PlayerSpawnPositionS2CPacket"); S2C_PACKETS_R.put("PlayerSpawnPositionS2CPacket", net.minecraft.network.packet.s2c.play.PlayerSpawnPositionS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityStatusEffectS2CPacket.class, "EntityStatusEffectS2CPacket"); S2C_PACKETS_R.put("EntityStatusEffectS2CPacket", net.minecraft.network.packet.s2c.play.EntityStatusEffectS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket.class, "ClearTitleS2CPacket"); S2C_PACKETS_R.put("ClearTitleS2CPacket", net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.login.LoginCompressionS2CPacket.class, "LoginCompressionS2CPacket"); - S2C_PACKETS_R.put("LoginCompressionS2CPacket", net.minecraft.network.packet.s2c.login.LoginCompressionS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket.class, "CommandTreeS2CPacket"); S2C_PACKETS_R.put("CommandTreeS2CPacket", net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.CommonPingS2CPacket.class, "CommonPingS2CPacket"); - S2C_PACKETS_R.put("CommonPingS2CPacket", net.minecraft.network.packet.s2c.common.CommonPingS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScoreboardScoreResetS2CPacket.class, "ScoreboardScoreResetS2CPacket"); - S2C_PACKETS_R.put("ScoreboardScoreResetS2CPacket", net.minecraft.network.packet.s2c.play.ScoreboardScoreResetS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.login.LoginCompressionS2CPacket.class, "LoginCompressionS2CPacket"); + S2C_PACKETS_R.put("LoginCompressionS2CPacket", net.minecraft.network.packet.s2c.login.LoginCompressionS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket.class, "TitleFadeS2CPacket"); S2C_PACKETS_R.put("TitleFadeS2CPacket", net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.query.PingResultS2CPacket.class, "PingResultS2CPacket"); - S2C_PACKETS_R.put("PingResultS2CPacket", net.minecraft.network.packet.s2c.query.PingResultS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.UpdateTickRateS2CPacket.class, "UpdateTickRateS2CPacket"); - S2C_PACKETS_R.put("UpdateTickRateS2CPacket", net.minecraft.network.packet.s2c.play.UpdateTickRateS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.InventoryS2CPacket.class, "InventoryS2CPacket"); - S2C_PACKETS_R.put("InventoryS2CPacket", net.minecraft.network.packet.s2c.play.InventoryS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerSpawnS2CPacket.class, "PlayerSpawnS2CPacket"); + S2C_PACKETS_R.put("PlayerSpawnS2CPacket", net.minecraft.network.packet.s2c.play.PlayerSpawnS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerActionResponseS2CPacket.class, "PlayerActionResponseS2CPacket"); S2C_PACKETS_R.put("PlayerActionResponseS2CPacket", net.minecraft.network.packet.s2c.play.PlayerActionResponseS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.InventoryS2CPacket.class, "InventoryS2CPacket"); + S2C_PACKETS_R.put("InventoryS2CPacket", net.minecraft.network.packet.s2c.play.InventoryS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ResourcePackSendS2CPacket.class, "ResourcePackSendS2CPacket"); + S2C_PACKETS_R.put("ResourcePackSendS2CPacket", net.minecraft.network.packet.s2c.play.ResourcePackSendS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChunkBiomeDataS2CPacket.class, "ChunkBiomeDataS2CPacket"); S2C_PACKETS_R.put("ChunkBiomeDataS2CPacket", net.minecraft.network.packet.s2c.play.ChunkBiomeDataS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.WorldBorderWarningTimeChangedS2CPacket.class, "WorldBorderWarningTimeChangedS2CPacket"); S2C_PACKETS_R.put("WorldBorderWarningTimeChangedS2CPacket", net.minecraft.network.packet.s2c.play.WorldBorderWarningTimeChangedS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScoreboardPlayerUpdateS2CPacket.class, "ScoreboardPlayerUpdateS2CPacket"); + S2C_PACKETS_R.put("ScoreboardPlayerUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ScoreboardPlayerUpdateS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.query.QueryPongS2CPacket.class, "QueryPongS2CPacket"); + S2C_PACKETS_R.put("QueryPongS2CPacket", net.minecraft.network.packet.s2c.query.QueryPongS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityDamageS2CPacket.class, "EntityDamageS2CPacket"); S2C_PACKETS_R.put("EntityDamageS2CPacket", net.minecraft.network.packet.s2c.play.EntityDamageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket.class, "ChatMessageS2CPacket"); S2C_PACKETS_R.put("ChatMessageS2CPacket", net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.KeepAliveS2CPacket.class, "KeepAliveS2CPacket"); - S2C_PACKETS_R.put("KeepAliveS2CPacket", net.minecraft.network.packet.s2c.common.KeepAliveS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OpenWrittenBookS2CPacket.class, "OpenWrittenBookS2CPacket"); S2C_PACKETS_R.put("OpenWrittenBookS2CPacket", net.minecraft.network.packet.s2c.play.OpenWrittenBookS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.ResourcePackRemoveS2CPacket.class, "ResourcePackRemoveS2CPacket"); - S2C_PACKETS_R.put("ResourcePackRemoveS2CPacket", net.minecraft.network.packet.s2c.common.ResourcePackRemoveS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlaySoundFromEntityS2CPacket.class, "PlaySoundFromEntityS2CPacket"); S2C_PACKETS_R.put("PlaySoundFromEntityS2CPacket", net.minecraft.network.packet.s2c.play.PlaySoundFromEntityS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket.class, "WorldTimeUpdateS2CPacket"); S2C_PACKETS_R.put("WorldTimeUpdateS2CPacket", net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.config.FeaturesS2CPacket.class, "FeaturesS2CPacket"); - S2C_PACKETS_R.put("FeaturesS2CPacket", net.minecraft.network.packet.s2c.config.FeaturesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SignEditorOpenS2CPacket.class, "SignEditorOpenS2CPacket"); S2C_PACKETS_R.put("SignEditorOpenS2CPacket", net.minecraft.network.packet.s2c.play.SignEditorOpenS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ExplosionS2CPacket.class, "ExplosionS2CPacket"); S2C_PACKETS_R.put("ExplosionS2CPacket", net.minecraft.network.packet.s2c.play.ExplosionS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.login.LoginDisconnectS2CPacket.class, "LoginDisconnectS2CPacket"); - S2C_PACKETS_R.put("LoginDisconnectS2CPacket", net.minecraft.network.packet.s2c.login.LoginDisconnectS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.RemoveEntityStatusEffectS2CPacket.class, "RemoveEntityStatusEffectS2CPacket"); S2C_PACKETS_R.put("RemoveEntityStatusEffectS2CPacket", net.minecraft.network.packet.s2c.play.RemoveEntityStatusEffectS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.login.LoginDisconnectS2CPacket.class, "LoginDisconnectS2CPacket"); + S2C_PACKETS_R.put("LoginDisconnectS2CPacket", net.minecraft.network.packet.s2c.login.LoginDisconnectS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EndCombatS2CPacket.class, "EndCombatS2CPacket"); S2C_PACKETS_R.put("EndCombatS2CPacket", net.minecraft.network.packet.s2c.play.EndCombatS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerListS2CPacket.class, "PlayerListS2CPacket"); S2C_PACKETS_R.put("PlayerListS2CPacket", net.minecraft.network.packet.s2c.play.PlayerListS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.DisconnectS2CPacket.class, "DisconnectS2CPacket"); + S2C_PACKETS_R.put("DisconnectS2CPacket", net.minecraft.network.packet.s2c.play.DisconnectS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChunkRenderDistanceCenterS2CPacket.class, "ChunkRenderDistanceCenterS2CPacket"); S2C_PACKETS_R.put("ChunkRenderDistanceCenterS2CPacket", net.minecraft.network.packet.s2c.play.ChunkRenderDistanceCenterS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ExperienceBarUpdateS2CPacket.class, "ExperienceBarUpdateS2CPacket"); @@ -361,8 +345,6 @@ public abstract class PacketUtils { S2C_PACKETS_R.put("LoginSuccessS2CPacket", net.minecraft.network.packet.s2c.login.LoginSuccessS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.BlockBreakingProgressS2CPacket.class, "BlockBreakingProgressS2CPacket"); S2C_PACKETS_R.put("BlockBreakingProgressS2CPacket", net.minecraft.network.packet.s2c.play.BlockBreakingProgressS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.DisconnectS2CPacket.class, "DisconnectS2CPacket"); - S2C_PACKETS_R.put("DisconnectS2CPacket", net.minecraft.network.packet.s2c.common.DisconnectS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.GameMessageS2CPacket.class, "GameMessageS2CPacket"); S2C_PACKETS_R.put("GameMessageS2CPacket", net.minecraft.network.packet.s2c.play.GameMessageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket.class, "EntityPassengersSetS2CPacket"); @@ -375,30 +357,22 @@ public abstract class PacketUtils { S2C_PACKETS_R.put("SynchronizeRecipesS2CPacket", net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityS2CPacket.class, "EntityS2CPacket"); S2C_PACKETS_R.put("EntityS2CPacket", net.minecraft.network.packet.s2c.play.EntityS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket.class, "EntityTrackerUpdateS2CPacket"); - S2C_PACKETS_R.put("EntityTrackerUpdateS2CPacket", net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityStatusS2CPacket.class, "EntityStatusS2CPacket"); S2C_PACKETS_R.put("EntityStatusS2CPacket", net.minecraft.network.packet.s2c.play.EntityStatusS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.config.DynamicRegistriesS2CPacket.class, "DynamicRegistriesS2CPacket"); - S2C_PACKETS_R.put("DynamicRegistriesS2CPacket", net.minecraft.network.packet.s2c.config.DynamicRegistriesS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket.class, "CustomPayloadS2CPacket"); - S2C_PACKETS_R.put("CustomPayloadS2CPacket", net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket.class, "EntityTrackerUpdateS2CPacket"); + S2C_PACKETS_R.put("EntityTrackerUpdateS2CPacket", net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.SubtitleS2CPacket.class, "SubtitleS2CPacket"); S2C_PACKETS_R.put("SubtitleS2CPacket", net.minecraft.network.packet.s2c.play.SubtitleS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.NbtQueryResponseS2CPacket.class, "NbtQueryResponseS2CPacket"); S2C_PACKETS_R.put("NbtQueryResponseS2CPacket", net.minecraft.network.packet.s2c.play.NbtQueryResponseS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityEquipmentUpdateS2CPacket.class, "EntityEquipmentUpdateS2CPacket"); - S2C_PACKETS_R.put("EntityEquipmentUpdateS2CPacket", net.minecraft.network.packet.s2c.play.EntityEquipmentUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.UnloadChunkS2CPacket.class, "UnloadChunkS2CPacket"); S2C_PACKETS_R.put("UnloadChunkS2CPacket", net.minecraft.network.packet.s2c.play.UnloadChunkS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.config.ReadyS2CPacket.class, "ReadyS2CPacket"); - S2C_PACKETS_R.put("ReadyS2CPacket", net.minecraft.network.packet.s2c.config.ReadyS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EnterReconfigurationS2CPacket.class, "EnterReconfigurationS2CPacket"); - S2C_PACKETS_R.put("EnterReconfigurationS2CPacket", net.minecraft.network.packet.s2c.play.EnterReconfigurationS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityAttachS2CPacket.class, "EntityAttachS2CPacket"); - S2C_PACKETS_R.put("EntityAttachS2CPacket", net.minecraft.network.packet.s2c.play.EntityAttachS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityEquipmentUpdateS2CPacket.class, "EntityEquipmentUpdateS2CPacket"); + S2C_PACKETS_R.put("EntityEquipmentUpdateS2CPacket", net.minecraft.network.packet.s2c.play.EntityEquipmentUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.BossBarS2CPacket.class, "BossBarS2CPacket"); S2C_PACKETS_R.put("BossBarS2CPacket", net.minecraft.network.packet.s2c.play.BossBarS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityAttachS2CPacket.class, "EntityAttachS2CPacket"); + S2C_PACKETS_R.put("EntityAttachS2CPacket", net.minecraft.network.packet.s2c.play.EntityAttachS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket.class, "EntityPositionS2CPacket"); S2C_PACKETS_R.put("EntityPositionS2CPacket", net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket.class, "ChunkDataS2CPacket"); @@ -498,7 +472,7 @@ public Class> get(int index) { @NotNull @Override public Iterator>> iterator() { - return Stream.concat(S2C_PACKETS.keySet().stream(), C2S_PACKETS.keySet().stream()).iterator(); + return Iterators.concat(S2C_PACKETS.keySet().iterator(), C2S_PACKETS.keySet().iterator()); } @Override @@ -508,7 +482,7 @@ public boolean contains(RegistryKey>> key) { @Override public Set>>, Class>>> getEntrySet() { - return Collections.emptySet(); + return null; } @Override @@ -569,7 +543,7 @@ public void populateTags(Map>>, List>>> getKeys() { - return Collections.emptySet(); + return null; } } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java index c296a947e4..c56cd6a02b 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java @@ -16,7 +16,7 @@ import java.io.IOException; import java.util.Set; -public abstract class PacketUtilsUtil { +public class PacketUtilsUtil { private static final String packetRegistryClass = """ private static class PacketRegistry extends SimpleRegistry>> { public PacketRegistry() { @@ -81,7 +81,7 @@ public Class> get(int index) { @NotNull @Override public Iterator>> iterator() { - return Stream.concat(S2C_PACKETS.keySet().stream(), C2S_PACKETS.keySet().stream()).iterator(); + return Iterators.concat(S2C_PACKETS.keySet().iterator(), C2S_PACKETS.keySet().iterator()); } @Override @@ -91,7 +91,7 @@ public boolean contains(RegistryKey>> key) { @Override public Set>>, Class>>> getEntrySet() { - return Collections.emptySet(); + return null; } @Override @@ -152,7 +152,7 @@ public void populateTags(Map>>, List>>> getKeys() { - return Collections.emptySet(); + return null; } } """; @@ -168,111 +168,114 @@ public static void main(String[] args) { public static void init() throws IOException { // Generate PacketUtils.java - File file = new File("src/main/java/%s/PacketUtils.java".formatted(PacketUtilsUtil.class.getPackageName().replace('.', '/'))); + File file = new File("src/main/java/" + PacketUtilsUtil.class.getPackageName().replace('.', '/') + "/PacketUtils.java"); if (!file.exists()) { file.getParentFile().mkdirs(); file.createNewFile(); } - try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { - writer.write("/*\n"); - writer.write(" * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client/).\n"); - writer.write(" * Copyright (c) Meteor Development.\n"); - writer.write(" */\n\n"); - - writer.write("package meteordevelopment.meteorclient.utils.network;\n\n"); - - // Write imports - writer.write("import com.mojang.datafixers.util.Pair;\n"); - writer.write("import com.mojang.serialization.Lifecycle;\n"); - writer.write("import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier;\n"); - writer.write("import net.minecraft.network.packet.Packet;\n"); - writer.write("import net.minecraft.registry.Registry;\n"); - writer.write("import net.minecraft.registry.RegistryKey;\n"); - writer.write("import net.minecraft.registry.SimpleRegistry;\n"); - writer.write("import net.minecraft.registry.entry.RegistryEntry;\n"); - writer.write("import net.minecraft.registry.entry.RegistryEntryList;\n"); - writer.write("import net.minecraft.registry.tag.TagKey;\n"); - writer.write("import net.minecraft.util.Identifier;\n"); - writer.write("import net.minecraft.util.math.random.Random;\n"); - writer.write("import org.jetbrains.annotations.NotNull;\n"); - - writer.write("import java.util.*;\n"); - writer.write("import java.util.stream.Stream;\n"); - - // Write class - writer.write("\npublic abstract class PacketUtils {\n"); - - // Write fields - writer.write(" public static final Registry>> REGISTRY = new PacketRegistry();\n\n"); - writer.write(" private static final Map>, String> S2C_PACKETS = new HashMap<>();\n"); - writer.write(" private static final Map>, String> C2S_PACKETS = new HashMap<>();\n\n"); - writer.write(" private static final Map>> S2C_PACKETS_R = new HashMap<>();\n"); - writer.write(" private static final Map>> C2S_PACKETS_R = new HashMap<>();\n\n"); - - // Write static block - writer.write(" static {\n"); - - // Client -> Sever Packets - Reflections c2s = new Reflections("net.minecraft.network.packet.c2s", Scanners.SubTypes); - Set> c2sPackets = c2s.getSubTypesOf(Packet.class); - - for (Class c2sPacket : c2sPackets) { - String name = c2sPacket.getName(); - String className = name.substring(name.lastIndexOf('.') + 1).replace('$', '.'); - String fullName = name.replace('$', '.'); - - writer.write(" C2S_PACKETS.put(%s.class, \"%s\");%n".formatted(fullName, className)); - writer.write(" C2S_PACKETS_R.put(\"%s\", %s.class);%n".formatted(className, fullName)); - } - - writer.newLine(); - - // Server -> Client Packets - Reflections s2c = new Reflections("net.minecraft.network.packet.s2c", Scanners.SubTypes); - Set> s2cPackets = s2c.getSubTypesOf(Packet.class); - - for (Class s2cPacket : s2cPackets) { - if (s2cPacket == BundlePacket.class) continue; - String name = s2cPacket.getName(); - String className = name.substring(name.lastIndexOf('.') + 1).replace('$', '.'); - String fullName = name.replace('$', '.'); - - writer.write(" S2C_PACKETS.put(%s.class, \"%s\");%n".formatted(fullName, className)); - writer.write(" S2C_PACKETS_R.put(\"%s\", %s.class);%n".formatted(className, fullName)); - } - - writer.write(" }\n\n"); - - // Write getName method - writer.write(" public static String getName(Class> packetClass) {\n"); - writer.write(" String name = S2C_PACKETS.get(packetClass);\n"); - writer.write(" if (name != null) return name;\n"); - writer.write(" return C2S_PACKETS.get(packetClass);\n"); - writer.write(" }\n\n"); - - // Write getPacket method - writer.write(" public static Class> getPacket(String name) {\n"); - writer.write(" Class> packet = S2C_PACKETS_R.get(name);\n"); - writer.write(" if (packet != null) return packet;\n"); - writer.write(" return C2S_PACKETS_R.get(name);\n"); - writer.write(" }\n\n"); - - // Write getS2CPackets method - writer.write(" public static Set>> getS2CPackets() {\n"); - writer.write(" return S2C_PACKETS.keySet();\n"); - writer.write(" }\n\n"); - - // Write getC2SPackets method - writer.write(" public static Set>> getC2SPackets() {\n"); - writer.write(" return C2S_PACKETS.keySet();\n"); - writer.write(" }\n\n"); - - // Write PacketRegistry class - writer.write(packetRegistryClass); - - // Write end class - writer.write("}\n"); + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + + writer.write("/*\n"); + writer.write(" * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client/).\n"); + writer.write(" * Copyright (c) Meteor Development.\n"); + writer.write(" */\n\n"); + + writer.write("package meteordevelopment.meteorclient.utils.network;\n\n"); + + // Write imports + writer.write("import com.google.common.collect.Iterators;\n"); + writer.write("import com.mojang.datafixers.util.Pair;\n"); + writer.write("import com.mojang.serialization.Lifecycle;\n"); + writer.write("import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier;\n"); + writer.write("import net.minecraft.network.packet.Packet;\n"); + writer.write("import net.minecraft.registry.Registry;\n"); + writer.write("import net.minecraft.registry.RegistryKey;\n"); + writer.write("import net.minecraft.registry.SimpleRegistry;\n"); + writer.write("import net.minecraft.registry.entry.RegistryEntry;\n"); + writer.write("import net.minecraft.registry.entry.RegistryEntryList;\n"); + writer.write("import net.minecraft.registry.tag.TagKey;\n"); + writer.write("import net.minecraft.util.Identifier;\n"); + writer.write("import net.minecraft.util.math.random.Random;\n"); + writer.write("import org.jetbrains.annotations.NotNull;\n"); + + writer.write("import java.util.*;\n"); + writer.write("import java.util.stream.Stream;\n"); + + // Write class + writer.write("\npublic class PacketUtils {\n"); + + // Write fields + writer.write(" public static final Registry>> REGISTRY = new PacketRegistry();\n\n"); + writer.write(" private static final Map>, String> S2C_PACKETS = new HashMap<>();\n"); + writer.write(" private static final Map>, String> C2S_PACKETS = new HashMap<>();\n\n"); + writer.write(" private static final Map>> S2C_PACKETS_R = new HashMap<>();\n"); + writer.write(" private static final Map>> C2S_PACKETS_R = new HashMap<>();\n\n"); + + // Write static block + writer.write(" static {\n"); + + // Client -> Sever Packets + Reflections c2s = new Reflections("net.minecraft.network.packet.c2s", Scanners.SubTypes); + Set> c2sPackets = c2s.getSubTypesOf(Packet.class); + + for (Class c2sPacket : c2sPackets) { + String name = c2sPacket.getName(); + String className = name.substring(name.lastIndexOf('.') + 1).replace('$', '.'); + String fullName = name.replace('$', '.'); + + writer.write(String.format(" C2S_PACKETS.put(%s.class, \"%s\");\n", fullName, className)); + writer.write(String.format(" C2S_PACKETS_R.put(\"%s\", %s.class);\n", className, fullName)); + } + + writer.newLine(); + + // Server -> Client Packets + Reflections s2c = new Reflections("net.minecraft.network.packet.s2c", Scanners.SubTypes); + Set> s2cPackets = s2c.getSubTypesOf(Packet.class); + + for (Class s2cPacket : s2cPackets) { + if (s2cPacket == BundlePacket.class) continue; + String name = s2cPacket.getName(); + String className = name.substring(name.lastIndexOf('.') + 1).replace('$', '.'); + String fullName = name.replace('$', '.'); + + writer.write(String.format(" S2C_PACKETS.put(%s.class, \"%s\");\n", fullName, className)); + writer.write(String.format(" S2C_PACKETS_R.put(\"%s\", %s.class);\n", className, fullName)); } + + writer.write(" }\n\n"); + + // Write getName method + writer.write(" public static String getName(Class> packetClass) {\n"); + writer.write(" String name = S2C_PACKETS.get(packetClass);\n"); + writer.write(" if (name != null) return name;\n"); + writer.write(" return C2S_PACKETS.get(packetClass);\n"); + writer.write(" }\n\n"); + + // Write getPacket method + writer.write(" public static Class> getPacket(String name) {\n"); + writer.write(" Class> packet = S2C_PACKETS_R.get(name);\n"); + writer.write(" if (packet != null) return packet;\n"); + writer.write(" return C2S_PACKETS_R.get(name);\n"); + writer.write(" }\n\n"); + + // Write getS2CPackets method + writer.write(" public static Set>> getS2CPackets() {\n"); + writer.write(" return S2C_PACKETS.keySet();\n"); + writer.write(" }\n\n"); + + // Write getC2SPackets method + writer.write(" public static Set>> getC2SPackets() {\n"); + writer.write(" return C2S_PACKETS.keySet();\n"); + writer.write(" }\n\n"); + + // Write PacketRegistry class + writer.write(packetRegistryClass); + + // Write end class + writer.write("}\n"); + + writer.close(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/ChatUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/player/ChatUtils.java index d4eace822e..bf2283e4f6 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/ChatUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/ChatUtils.java @@ -5,10 +5,10 @@ package meteordevelopment.meteorclient.utils.player; +import baritone.api.BaritoneAPI; import com.mojang.brigadier.StringReader; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.mixininterface.IChatHud; -import meteordevelopment.meteorclient.pathing.BaritoneUtils; import meteordevelopment.meteorclient.systems.config.Config; import meteordevelopment.meteorclient.utils.PostInit; import net.minecraft.text.*; @@ -241,20 +241,17 @@ private static MutableText formatMsg(String message, Formatting defaultColor) { public static MutableText formatCoords(Vec3d pos) { String coordsString = String.format("(highlight)(underline)%.0f, %.0f, %.0f(default)", pos.x, pos.y, pos.z); MutableText coordsText = formatMsg(coordsString, Formatting.GRAY); - - Style style = coordsText.getStyle().withFormatting(Formatting.BOLD).withHoverEvent(new HoverEvent( - HoverEvent.Action.SHOW_TEXT, - Text.literal("Set as Baritone goal") - )); - - if (BaritoneUtils.IS_AVAILABLE) { - style = style.withClickEvent(new ClickEvent( - ClickEvent.Action.RUN_COMMAND, - String.format("%sgoto %d %d %d", BaritoneUtils.getPrefix(), (int) pos.x, (int) pos.y, (int) pos.z) - )); - } - - coordsText.setStyle(style); + coordsText.setStyle(coordsText.getStyle() + .withFormatting(Formatting.BOLD) + .withClickEvent(new ClickEvent( + ClickEvent.Action.RUN_COMMAND, + String.format("%sgoto %d %d %d", BaritoneAPI.getSettings().prefix.value, (int) pos.x, (int) pos.y, (int) pos.z) + )) + .withHoverEvent(new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + Text.literal("Set as Baritone goal") + )) + ); return coordsText; } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/DamageUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/player/DamageUtils.java new file mode 100644 index 0000000000..4c5870ce17 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/DamageUtils.java @@ -0,0 +1,274 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.utils.player; + +import meteordevelopment.meteorclient.MeteorClient; +import meteordevelopment.meteorclient.events.game.GameJoinedEvent; +import meteordevelopment.meteorclient.mixininterface.IExplosion; +import meteordevelopment.meteorclient.mixininterface.IRaycastContext; +import meteordevelopment.meteorclient.mixininterface.IVec3d; +import meteordevelopment.meteorclient.utils.PreInit; +import meteordevelopment.meteorclient.utils.entity.EntityUtils; +import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerEntity; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.DamageUtil; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.attribute.EntityAttributes; +import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Items; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.*; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.BlockView; +import net.minecraft.world.GameMode; +import net.minecraft.world.RaycastContext; +import net.minecraft.world.explosion.Explosion; + +import java.util.Objects; + +import static meteordevelopment.meteorclient.MeteorClient.mc; + +public class DamageUtils { + private static final Vec3d vec3d = new Vec3d(0, 0, 0); + private static Explosion explosion; + private static RaycastContext raycastContext; + + @PreInit + public static void init() { + MeteorClient.EVENT_BUS.subscribe(DamageUtils.class); + } + + @EventHandler + private static void onGameJoined(GameJoinedEvent event) { + explosion = new Explosion(mc.world, null, 0, 0, 0, 6, false, Explosion.DestructionType.DESTROY); + raycastContext = new RaycastContext(null, null, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player); + } + + // Crystal damage + + public static double crystalDamage(PlayerEntity player, Vec3d crystal, boolean predictMovement, BlockPos obsidianPos, boolean ignoreTerrain) { + if (player == null) return 0; + if (EntityUtils.getGameMode(player) == GameMode.CREATIVE && !(player instanceof FakePlayerEntity)) return 0; + + ((IVec3d) vec3d).set(player.getPos().x, player.getPos().y, player.getPos().z); + if (predictMovement) ((IVec3d) vec3d).set(vec3d.x + player.getVelocity().x, vec3d.y + player.getVelocity().y, vec3d.z + player.getVelocity().z); + + double modDistance = Math.sqrt(vec3d.squaredDistanceTo(crystal)); + if (modDistance > 12) return 0; + + double exposure = getExposure(crystal, player, predictMovement, raycastContext, obsidianPos, ignoreTerrain); + double impact = (1 - (modDistance / 12)) * exposure; + double damage = ((impact * impact + impact) / 2 * 7 * (6 * 2) + 1); + + damage = getDamageForDifficulty(damage); + damage = DamageUtil.getDamageLeft((float) damage, (float) player.getArmor(), (float) player.getAttributeInstance(EntityAttributes.GENERIC_ARMOR_TOUGHNESS).getValue()); + damage = resistanceReduction(player, damage); + + ((IExplosion) explosion).set(crystal, 6, false); + damage = blastProtReduction(player, damage, explosion); + + return damage < 0 ? 0 : damage; + } + + public static double crystalDamage(PlayerEntity player, Vec3d crystal) { + return crystalDamage(player, crystal, false, null, false); + } + + // Sword damage + + public static double getSwordDamage(PlayerEntity entity, boolean charged) { + // Get sword damage + double damage = 0; + if (charged) { + if (entity.getActiveItem().getItem() == Items.NETHERITE_SWORD) { + damage += 8; + } else if (entity.getActiveItem().getItem() == Items.DIAMOND_SWORD) { + damage += 7; + } else if (entity.getActiveItem().getItem() == Items.GOLDEN_SWORD) { + damage += 4; + } else if (entity.getActiveItem().getItem() == Items.IRON_SWORD) { + damage += 6; + } else if (entity.getActiveItem().getItem() == Items.STONE_SWORD) { + damage += 5; + } else if (entity.getActiveItem().getItem() == Items.WOODEN_SWORD) { + damage += 4; + } + damage *= 1.5; + } + + if (entity.getActiveItem().getEnchantments() != null) { + if (EnchantmentHelper.get(entity.getActiveItem()).containsKey(Enchantments.SHARPNESS)) { + int level = EnchantmentHelper.getLevel(Enchantments.SHARPNESS, entity.getActiveItem()); + damage += (0.5 * level) + 0.5; + } + } + + if (entity.getActiveStatusEffects().containsKey(StatusEffects.STRENGTH)) { + int strength = Objects.requireNonNull(entity.getStatusEffect(StatusEffects.STRENGTH)).getAmplifier() + 1; + damage += 3 * strength; + } + + // Reduce by resistance + damage = resistanceReduction(entity, damage); + + // Reduce by armour + damage = DamageUtil.getDamageLeft((float) damage, (float) entity.getArmor(), (float) entity.getAttributeInstance(EntityAttributes.GENERIC_ARMOR_TOUGHNESS).getValue()); + + // Reduce by enchants + damage = normalProtReduction(entity, damage); + + return damage < 0 ? 0 : damage; + } + + // Bed damage + + public static double bedDamage(LivingEntity player, Vec3d bed) { + if (player instanceof PlayerEntity && ((PlayerEntity) player).getAbilities().creativeMode) return 0; + + double modDistance = Math.sqrt(player.squaredDistanceTo(bed)); + if (modDistance > 10) return 0; + + double exposure = Explosion.getExposure(bed, player); + double impact = (1.0 - (modDistance / 10.0)) * exposure; + double damage = (impact * impact + impact) / 2 * 7 * (5 * 2) + 1; + + // Multiply damage by difficulty + damage = getDamageForDifficulty(damage); + + // Reduce by resistance + damage = resistanceReduction(player, damage); + + // Reduce by armour + damage = DamageUtil.getDamageLeft((float) damage, (float) player.getArmor(), (float) player.getAttributeInstance(EntityAttributes.GENERIC_ARMOR_TOUGHNESS).getValue()); + + // Reduce by enchants + ((IExplosion) explosion).set(bed, 5, true); + damage = blastProtReduction(player, damage, explosion); + + if (damage < 0) damage = 0; + return damage; + } + + // Anchor damage + + public static double anchorDamage(LivingEntity player, Vec3d anchor) { + mc.world.removeBlock(BlockPos.ofFloored(anchor), false); + double damage = bedDamage(player, anchor); + mc.world.setBlockState(BlockPos.ofFloored(anchor), Blocks.RESPAWN_ANCHOR.getDefaultState()); + return damage; + } + + // Utils + + private static double getDamageForDifficulty(double damage) { + return switch (mc.world.getDifficulty()) { + case PEACEFUL -> 0; + case EASY -> Math.min(damage / 2 + 1, damage); + case HARD -> damage * 3 / 2; + default -> damage; + }; + } + + private static double normalProtReduction(Entity player, double damage) { + int protLevel = EnchantmentHelper.getProtectionAmount(player.getArmorItems(), mc.world.getDamageSources().generic()); + if (protLevel > 20) protLevel = 20; + + damage *= 1 - (protLevel / 25.0); + return damage < 0 ? 0 : damage; + } + + private static double blastProtReduction(Entity player, double damage, Explosion explosion) { + int protLevel = EnchantmentHelper.getProtectionAmount(player.getArmorItems(), mc.world.getDamageSources().explosion(explosion)); + if (protLevel > 20) protLevel = 20; + + damage *= (1 - (protLevel / 25.0)); + return damage < 0 ? 0 : damage; + } + + private static double resistanceReduction(LivingEntity player, double damage) { + if (player.hasStatusEffect(StatusEffects.RESISTANCE)) { + int lvl = (player.getStatusEffect(StatusEffects.RESISTANCE).getAmplifier() + 1); + damage *= (1 - (lvl * 0.2)); + } + + return damage < 0 ? 0 : damage; + } + + private static double getExposure(Vec3d source, Entity entity, boolean predictMovement, RaycastContext raycastContext, BlockPos obsidianPos, boolean ignoreTerrain) { + Box box = entity.getBoundingBox(); + if (predictMovement) { + Vec3d v = entity.getVelocity(); + box = box.offset(v.x, v.y, v.z); + } + + double d = 1 / ((box.maxX - box.minX) * 2 + 1); + double e = 1 / ((box.maxY - box.minY) * 2 + 1); + double f = 1 / ((box.maxZ - box.minZ) * 2 + 1); + double g = (1 - Math.floor(1 / d) * d) / 2; + double h = (1 - Math.floor(1 / f) * f) / 2; + + if (!(d < 0) && !(e < 0) && !(f < 0)) { + int i = 0; + int j = 0; + + for (double k = 0; k <= 1; k += d) { + for (double l = 0; l <= 1; l += e) { + for (double m = 0; m <= 1; m += f) { + double n = MathHelper.lerp(k, box.minX, box.maxX); + double o = MathHelper.lerp(l, box.minY, box.maxY); + double p = MathHelper.lerp(m, box.minZ, box.maxZ); + + ((IVec3d) vec3d).set(n + g, o, p + h); + ((IRaycastContext) raycastContext).set(vec3d, source, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, entity); + + if (raycast(raycastContext, obsidianPos, ignoreTerrain).getType() == HitResult.Type.MISS) i++; + + j++; + } + } + } + + return (double) i / j; + } + + return 0; + } + + private static BlockHitResult raycast(RaycastContext context, BlockPos obsidianPos, boolean ignoreTerrain) { + return BlockView.raycast(context.getStart(), context.getEnd(), context, (raycastContext, blockPos) -> { + BlockState blockState; + if (blockPos.equals(obsidianPos)) blockState = Blocks.OBSIDIAN.getDefaultState(); + else { + blockState = mc.world.getBlockState(blockPos); + if (blockState.getBlock().getBlastResistance() < 600 && ignoreTerrain) blockState = Blocks.AIR.getDefaultState(); + } + + Vec3d vec3d = raycastContext.getStart(); + Vec3d vec3d2 = raycastContext.getEnd(); + + VoxelShape voxelShape = raycastContext.getBlockShape(blockState, mc.world, blockPos); + BlockHitResult blockHitResult = mc.world.raycastBlock(vec3d, vec3d2, blockPos, voxelShape, blockState); + VoxelShape voxelShape2 = VoxelShapes.empty(); + BlockHitResult blockHitResult2 = voxelShape2.raycast(vec3d, vec3d2, blockPos); + + double d = blockHitResult == null ? Double.MAX_VALUE : raycastContext.getStart().squaredDistanceTo(blockHitResult.getPos()); + double e = blockHitResult2 == null ? Double.MAX_VALUE : raycastContext.getStart().squaredDistanceTo(blockHitResult2.getPos()); + + return d <= e ? blockHitResult : blockHitResult2; + }, (raycastContext) -> { + Vec3d vec3d = raycastContext.getStart().subtract(raycastContext.getEnd()); + return BlockHitResult.createMissed(raycastContext.getEnd(), Direction.getFacing(vec3d.x, vec3d.y, vec3d.z), BlockPos.ofFloored(raycastContext.getEnd())); + }); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/EChestMemory.java b/src/main/java/meteordevelopment/meteorclient/utils/player/EChestMemory.java index f806c712fb..20797b548f 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/EChestMemory.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/EChestMemory.java @@ -6,7 +6,6 @@ package meteordevelopment.meteorclient.utils.player; import meteordevelopment.meteorclient.MeteorClient; -import meteordevelopment.meteorclient.events.game.GameLeftEvent; import meteordevelopment.meteorclient.events.game.OpenScreenEvent; import meteordevelopment.meteorclient.events.world.BlockActivateEvent; import meteordevelopment.meteorclient.utils.PreInit; @@ -23,7 +22,6 @@ public class EChestMemory { public static final DefaultedList ITEMS = DefaultedList.ofSize(27, ItemStack.EMPTY); private static int echestOpenedState; - private static boolean isKnown = false; @PreInit public static void init() { @@ -51,18 +49,7 @@ private static void onOpenScreenEvent(OpenScreenEvent event) { for (int i = 0; i < 27; i++) { ITEMS.set(i, inv.getStack(i)); } - isKnown = true; echestOpenedState = 0; } - - @EventHandler - private static void onLeaveEvent(GameLeftEvent event) { - ITEMS.clear(); - isKnown = false; - } - - public static boolean isKnown() { - return isKnown; - } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/PathFinder.java b/src/main/java/meteordevelopment/meteorclient/utils/player/PathFinder.java index 5ec128dc2e..20f9747d2f 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/PathFinder.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/PathFinder.java @@ -137,7 +137,7 @@ private void moveEventListener(PlayerMoveEvent event) { if (target != null && mc.player != null) { if (!PlayerUtils.isWithin(target, 3)) { if (currentPathBlock == null) currentPathBlock = getNextPathBlock(); - if (mc.player.getPos().squaredDistanceTo(new Vec3d(currentPathBlock.blockPos.getX(), currentPathBlock.blockPos.getY(), currentPathBlock.blockPos.getZ())) < .01) + if (mc.player.getPos().distanceTo(new Vec3d(currentPathBlock.blockPos.getX(), currentPathBlock.blockPos.getY(), currentPathBlock.blockPos.getZ())) < .1) currentPathBlock = getNextPathBlock(); lookAtDestination(currentPathBlock); if (!mc.options.forwardKey.isPressed()) diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/PlayerUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/player/PlayerUtils.java index 203cd5340f..13b7604ef1 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/PlayerUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/PlayerUtils.java @@ -5,15 +5,16 @@ package meteordevelopment.meteorclient.utils.player; +import baritone.api.BaritoneAPI; +import baritone.api.utils.Rotation; import meteordevelopment.meteorclient.mixininterface.IVec3d; -import meteordevelopment.meteorclient.pathing.PathManagers; import meteordevelopment.meteorclient.systems.config.Config; import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.movement.NoFall; import meteordevelopment.meteorclient.utils.Utils; -import meteordevelopment.meteorclient.utils.entity.DamageUtils; import meteordevelopment.meteorclient.utils.entity.EntityUtils; +import meteordevelopment.meteorclient.utils.misc.BaritoneUtils; import meteordevelopment.meteorclient.utils.misc.text.TextUtils; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.world.Dimension; @@ -25,6 +26,7 @@ import net.minecraft.entity.decoration.EndCrystalEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.PotionItem; +import net.minecraft.item.SwordItem; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; @@ -58,8 +60,9 @@ public static Color getPlayerColor(PlayerEntity entity, Color defaultColor) { public static Vec3d getHorizontalVelocity(double bps) { float yaw = mc.player.getYaw(); - if (PathManagers.get().isPathing()) { - yaw = PathManagers.get().getTargetYaw(); + if (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing()) { + Rotation target = BaritoneUtils.getTarget(); + if (target != null) yaw = target.getYaw(); } Vec3d forward = Vec3d.fromPolar(0, yaw); @@ -178,24 +181,26 @@ public static boolean isInHole(boolean doubles) { return air < 2; } - public static float possibleHealthReductions() { + public static double possibleHealthReductions() { return possibleHealthReductions(true, true); } - public static float possibleHealthReductions(boolean entities, boolean fall) { - float damageTaken = 0; + public static double possibleHealthReductions(boolean entities, boolean fall) { + double damageTaken = 0; if (entities) { for (Entity entity : mc.world.getEntities()) { // Check for end crystals - if (entity instanceof EndCrystalEntity) { - float crystalDamage = DamageUtils.crystalDamage(mc.player, entity.getPos()); - if (crystalDamage > damageTaken) damageTaken = crystalDamage; + if (entity instanceof EndCrystalEntity && damageTaken < DamageUtils.crystalDamage(mc.player, entity.getPos())) { + damageTaken = DamageUtils.crystalDamage(mc.player, entity.getPos()); } // Check for players holding swords - else if (entity instanceof PlayerEntity player && !Friends.get().isFriend(player) && isWithin(entity, 5)) { - float attackDamage = DamageUtils.getAttackDamage(player, mc.player); - if (attackDamage > damageTaken) damageTaken = attackDamage; + else if (entity instanceof PlayerEntity && damageTaken < DamageUtils.getSwordDamage((PlayerEntity) entity, true)) { + if (!Friends.get().isFriend((PlayerEntity) entity) && isWithin(entity, 5)) { + if (((PlayerEntity) entity).getActiveItem().getItem() instanceof SwordItem) { + damageTaken = DamageUtils.getSwordDamage((PlayerEntity) entity, true); + } + } } } @@ -205,9 +210,8 @@ else if (entity instanceof PlayerEntity player && !Friends.get().isFriend(player BlockPos bp = blockEntity.getPos(); Vec3d pos = new Vec3d(bp.getX(), bp.getY(), bp.getZ()); - if (blockEntity instanceof BedBlockEntity) { - float explosionDamage = DamageUtils.bedDamage(mc.player, pos); - if (explosionDamage > damageTaken) damageTaken = explosionDamage; + if (blockEntity instanceof BedBlockEntity && damageTaken < DamageUtils.bedDamage(mc.player, pos)) { + damageTaken = DamageUtils.bedDamage(mc.player, pos); } } } @@ -216,7 +220,7 @@ else if (entity instanceof PlayerEntity player && !Friends.get().isFriend(player // Check for fall distance with water check if (fall) { if (!Modules.get().isActive(NoFall.class) && mc.player.fallDistance > 3) { - float damage = DamageUtils.fallDamage(mc.player); + double damage = mc.player.fallDistance * 0.5; if (damage > damageTaken && !EntityUtils.isAboveWater(mc.player)) { damageTaken = damage; @@ -343,7 +347,7 @@ public static GameMode getGameMode() { return playerListEntry.getGameMode(); } - public static float getTotalHealth() { + public static double getTotalHealth() { return mc.player.getHealth() + mc.player.getAbsorptionAmount(); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/TitleScreenCredits.java b/src/main/java/meteordevelopment/meteorclient/utils/player/TitleScreenCredits.java index e86b163bd0..f0fc734375 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/TitleScreenCredits.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/TitleScreenCredits.java @@ -13,10 +13,11 @@ import meteordevelopment.meteorclient.gui.screens.CommitsScreen; import meteordevelopment.meteorclient.utils.network.Http; import meteordevelopment.meteorclient.utils.network.MeteorExecutor; +import meteordevelopment.meteorclient.utils.render.color.Color; +import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; +import net.minecraft.client.render.BufferBuilder; +import net.minecraft.client.render.VertexConsumerProvider; import java.util.ArrayList; import java.util.Comparator; @@ -24,7 +25,11 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; -public abstract class TitleScreenCredits { +public class TitleScreenCredits { + private static final int WHITE = Color.fromRGBA(255, 255, 255, 255); + private static final int GRAY = Color.fromRGBA(175, 175, 175, 255); + private static final int RED = Color.fromRGBA(225, 25, 25, 255); + private static final List credits = new ArrayList<>(); private static void init() { @@ -33,7 +38,7 @@ private static void init() { for (MeteorAddon addon : AddonManager.ADDONS) add(addon); // Sort by width (Meteor always first) - credits.sort(Comparator.comparingInt(value -> value.addon == MeteorClient.ADDON ? Integer.MIN_VALUE : -mc.textRenderer.getWidth(value.text))); + credits.sort(Comparator.comparingInt(value -> value.sections.get(0).text.equals("Meteor Client ") ? Integer.MIN_VALUE : -value.width)); // Check for latest commits MeteorExecutor.execute(() -> { @@ -41,10 +46,13 @@ private static void init() { if (credit.addon.getRepo() == null || credit.addon.getCommit() == null) continue; GithubRepo repo = credit.addon.getRepo(); - Response res = Http.get("https://api.github.com/repos/%s/branches/%s".formatted(repo.getOwnerName(), repo.branch())).sendJson(Response.class); + Response res = Http.get(String.format("https://api.github.com/repos/%s/branches/%s", repo.getOwnerName(), repo.branch())).sendJson(Response.class); if (res != null && !credit.addon.getCommit().equals(res.commit.sha)) { - credit.text.append(Text.literal("*").formatted(Formatting.RED)); + synchronized (credit.sections) { + credit.sections.add(1, new Section("*", RED)); + credit.calculateWidth(); + } } } }); @@ -53,17 +61,18 @@ private static void init() { private static void add(MeteorAddon addon) { Credit credit = new Credit(addon); - credit.text.append(Text.literal(addon.name).styled(style -> style.withColor(addon.color.getPacked()))); - credit.text.append(Text.literal(" by ").formatted(Formatting.GRAY)); + credit.sections.add(new Section(addon.name, addon.color.getPacked())); + credit.sections.add(new Section(" by ", GRAY)); for (int i = 0; i < addon.authors.length; i++) { if (i > 0) { - credit.text.append(Text.literal(i == addon.authors.length - 1 ? " & " : ", ").formatted(Formatting.GRAY)); + credit.sections.add(new Section(i == addon.authors.length - 1 ? " & " : ", ", GRAY)); } - credit.text.append(Text.literal(addon.authors[i]).formatted(Formatting.WHITE)); + credit.sections.add(new Section(addon.authors[i], WHITE)); } + credit.calculateWidth(); credits.add(credit); } @@ -72,9 +81,14 @@ public static void render(DrawContext context) { int y = 3; for (Credit credit : credits) { - int x = mc.currentScreen.width - 3 - mc.textRenderer.getWidth(credit.text); + int x = mc.currentScreen.width - 3 - credit.width; - context.drawTextWithShadow(mc.textRenderer, credit.text, x, y, -1); + synchronized (credit.sections) { + for (Section section : credit.sections) { + context.drawTextWithShadow(mc.textRenderer, section.text, x, y, section.color); + x += section.width; + } + } y += mc.textRenderer.fontHeight + 2; } @@ -83,9 +97,9 @@ public static void render(DrawContext context) { public static boolean onClicked(double mouseX, double mouseY) { int y = 3; for (Credit credit : credits) { - int x = mc.currentScreen.width - 3 - mc.textRenderer.getWidth(credit.text); + int x = mc.currentScreen.width - 3 - credit.width; - if (mouseX >= x && mouseX <= x + mc.textRenderer.getWidth(credit.text) && mouseY >= y && mouseY <= y + mc.textRenderer.fontHeight + 2) { + if (mouseX >= x && mouseX <= x + credit.width && mouseY >= y && mouseY <= y + mc.textRenderer.fontHeight + 2) { if (credit.addon.getRepo() != null && credit.addon.getCommit() != null) { mc.setScreen(new CommitsScreen(GuiThemes.get(), credit.addon)); return true; @@ -100,11 +114,28 @@ public static boolean onClicked(double mouseX, double mouseY) { private static class Credit { public final MeteorAddon addon; - public final MutableText text = Text.empty(); + public final List
sections = new ArrayList<>(); + public int width; public Credit(MeteorAddon addon) { this.addon = addon; } + + public void calculateWidth() { + width = 0; + for (Section section : sections) width += section.width; + } + } + + private static class Section { + public final String text; + public final int color, width; + + public Section(String text, int color) { + this.text = text; + this.color = color; + this.width = mc.textRenderer.getWidth(text); + } } private static class Response { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java b/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java index 731f31401d..1aec6d3760 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java @@ -19,7 +19,6 @@ import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.text.TextColor; -import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,7 +27,6 @@ public class MeteorToast implements Toast { public static final int TITLE_COLOR = Color.fromRGBA(145, 61, 226, 255); public static final int TEXT_COLOR = Color.fromRGBA(220, 220, 220, 255); - private static final Identifier TEXTURE = new Identifier("textures/gui/sprites/toast/advancement.png"); private ItemStack icon; private Text title, text; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadTexture.java b/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadTexture.java index 34a451889d..94c0b47524 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadTexture.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadTexture.java @@ -8,12 +8,10 @@ import org.lwjgl.BufferUtils; import org.lwjgl.stb.STBImage; import org.lwjgl.system.MemoryStack; -import org.lwjgl.system.MemoryUtil; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; -import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -67,8 +65,8 @@ public PlayerHeadTexture(String url) { } public PlayerHeadTexture() { - try (InputStream inputStream = mc.getResourceManager().getResource(new MeteorIdentifier("textures/steve.png")).get().getInputStream()) { - ByteBuffer data = TextureUtil.readResource(inputStream); + try { + ByteBuffer data = TextureUtil.readResource(mc.getResourceManager().getResource(new MeteorIdentifier("textures/steve.png")).get().getInputStream()); data.rewind(); try (MemoryStack stack = MemoryStack.stackPush()) { @@ -80,7 +78,6 @@ public PlayerHeadTexture() { upload(image); STBImage.stbi_image_free(image); } - MemoryUtil.memFree(data); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadUtils.java index 132cf8f5ff..3da0df73ab 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadUtils.java @@ -1,6 +1,7 @@ package meteordevelopment.meteorclient.utils.render; import com.google.gson.Gson; +import com.mojang.util.UUIDTypeAdapter; import meteordevelopment.meteorclient.systems.accounts.TexturesJson; import meteordevelopment.meteorclient.systems.accounts.UuidToProfileResponse; import meteordevelopment.meteorclient.utils.PostInit; @@ -25,7 +26,7 @@ public static PlayerHeadTexture fetchHead(UUID id) { } public static String getSkinUrl(UUID id) { - UuidToProfileResponse res2 = Http.get("https://sessionserver.mojang.com/session/minecraft/profile/" + id).sendJson(UuidToProfileResponse.class); + UuidToProfileResponse res2 = Http.get("https://sessionserver.mojang.com/session/minecraft/profile/" + UUIDTypeAdapter.fromUUID(id)).sendJson(UuidToProfileResponse.class); if (res2 == null) return null; String base64Textures = res2.getPropertyValue("textures"); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/TextTooltipComponent.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/TextTooltipComponent.java deleted file mode 100644 index 8693e3ed2d..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/TextTooltipComponent.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.tooltip; - -import net.minecraft.client.gui.tooltip.OrderedTextTooltipComponent; -import net.minecraft.client.gui.tooltip.TooltipComponent; -import net.minecraft.text.OrderedText; -import net.minecraft.text.Text; - -public class TextTooltipComponent extends OrderedTextTooltipComponent implements MeteorTooltipData { - public TextTooltipComponent(OrderedText text) { - super(text); - } - - public TextTooltipComponent(Text text) { - this(text.asOrderedText()); - } - - @Override - public TooltipComponent getComponent() { - return this; - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java index 5e193df0ce..e7a53280c3 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java @@ -244,26 +244,20 @@ public static boolean isClickable(Block block) { } public static MobSpawn isValidMobSpawn(BlockPos blockPos, boolean newMobSpawnLightLevel) { - return isValidMobSpawn(blockPos, mc.world.getBlockState(blockPos), newMobSpawnLightLevel ? 0 : 7); - } - - public static MobSpawn isValidMobSpawn(BlockPos blockPos, BlockState blockState, int spawnLightLimit) { - if (!(blockState.getBlock() instanceof AirBlock)) return MobSpawn.Never; + int spawnLightLimit = newMobSpawnLightLevel ? 0 : 7; + if (!(mc.world.getBlockState(blockPos).getBlock() instanceof AirBlock) || + mc.world.getBlockState(blockPos.down()).getBlock() == Blocks.BEDROCK) return MobSpawn.Never; - BlockPos down = blockPos.down(); - BlockState downState = mc.world.getBlockState(down); - if (downState.getBlock() == Blocks.BEDROCK) return MobSpawn.Never; - - if (!topSurface(downState)) { - if (downState.getCollisionShape(mc.world, down) != VoxelShapes.fullCube()) + if (!topSurface(mc.world.getBlockState(blockPos.down()))) { + if (mc.world.getBlockState(blockPos.down()).getCollisionShape(mc.world, blockPos.down()) != VoxelShapes.fullCube()) return MobSpawn.Never; - if (downState.isTransparent(mc.world, down)) return MobSpawn.Never; + if (mc.world.getBlockState(blockPos.down()).isTransparent(mc.world, blockPos.down())) return MobSpawn.Never; } - if (mc.world.getLightLevel(LightType.BLOCK, blockPos) > spawnLightLimit) return MobSpawn.Never; - else if (mc.world.getLightLevel(LightType.SKY, blockPos) > spawnLightLimit) return MobSpawn.Potential; + if (mc.world.getLightLevel(blockPos, 0) <= spawnLightLimit) return MobSpawn.Potential; + else if (mc.world.getLightLevel(LightType.BLOCK, blockPos) <= spawnLightLimit) return MobSpawn.Always; - return MobSpawn.Always; + return MobSpawn.Never; } public static boolean topSurface(BlockState blockState) { @@ -342,11 +336,4 @@ private static double getBlockBreakingSpeed(int slot, BlockState block) { return speed; } - - /** - * Mutates a {@link BlockPos.Mutable} around an origin - */ - public static BlockPos.Mutable mutateAround(BlockPos.Mutable mutable, BlockPos origin, int xOffset, int yOffset, int zOffset) { - return mutable.set(origin.getX() + xOffset, origin.getY() + yOffset, origin.getZ() + zOffset); - } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/world/GoalDirection.java b/src/main/java/meteordevelopment/meteorclient/utils/world/GoalDirection.java new file mode 100644 index 0000000000..72d282f971 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/utils/world/GoalDirection.java @@ -0,0 +1,69 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.utils.world; + +import baritone.api.BaritoneAPI; +import baritone.api.pathing.goals.Goal; +import baritone.api.utils.SettingsUtil; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; + +public class GoalDirection implements Goal { + private static final double SQRT_2 = Math.sqrt(2.0D); + private final float yaw; + private int x; + private int z; + + public GoalDirection(Vec3d origin, float yaw) { + this.yaw = yaw; + recalculate(origin); + } + + public static double calculate(double xDiff, double zDiff) { + double x = Math.abs(xDiff); + double z = Math.abs(zDiff); + double straight; + double diagonal; + if (x < z) { + straight = z - x; + diagonal = x; + } else { + straight = x - z; + diagonal = z; + } + + diagonal *= SQRT_2; + return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.value; + } + + public void recalculate(Vec3d origin) { + float theta = (float) Math.toRadians(yaw); + x = (int) Math.floor(origin.x - (double) MathHelper.sin(theta) * 100); + z = (int) Math.floor(origin.z + (double) MathHelper.cos(theta) * 100); + } + + public boolean isInGoal(int x, int y, int z) { + return x == this.x && z == this.z; + } + + public double heuristic(int x, int y, int z) { + int xDiff = x - this.x; + int zDiff = z - this.z; + return calculate(xDiff, zDiff); + } + + public String toString() { + return String.format("GoalXZ{x=%s,z=%s}", SettingsUtil.maybeCensor(this.x), SettingsUtil.maybeCensor(this.z)); + } + + public int getX() { + return this.x; + } + + public int getZ() { + return this.z; + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index bb2846244b..9152c8dad7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,6 +19,9 @@ "icon": "assets/meteor-client/icon.png", "environment": "client", "entrypoints": { + "preLaunch": [ + "com.llamalad7.mixinextras.MixinExtrasBootstrap::init" + ], "client": [ "meteordevelopment.meteorclient.MeteorClient" ] @@ -45,15 +48,14 @@ }, "depends": { "java": ">=17", - "minecraft": "${minecraft_version}", - "fabricloader": ">=${loader_version}" + "minecraft": [ "1.20", "1.20.1" ], + "fabricloader": ">=0.14.21" }, "breaks": { "optifabric": "*", "feather": "*", "origins": "*", "wurst": "*", - "sodium": "<0.5.6", - "morechathistory": "*" + "sodium": "<0.5.0" } } diff --git a/src/main/resources/meteor-client-indigo.mixins.json b/src/main/resources/meteor-client-indigo.mixins.json index 5bce3e25ad..7dc33a1a5e 100644 --- a/src/main/resources/meteor-client-indigo.mixins.json +++ b/src/main/resources/meteor-client-indigo.mixins.json @@ -4,8 +4,7 @@ "compatibilityLevel": "JAVA_17", "plugin": "meteordevelopment.meteorclient.MixinPlugin", "client": [ - "AbstractBlockRenderContextMixin", - "AoCalculatorMixin" + "AbstractBlockRenderContextMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/meteor-client.accesswidener b/src/main/resources/meteor-client.accesswidener index 30a856f583..5632e6397b 100644 --- a/src/main/resources/meteor-client.accesswidener +++ b/src/main/resources/meteor-client.accesswidener @@ -1,6 +1,5 @@ accessWidener v1 named -accessible class net/minecraft/client/texture/PlayerSkinProvider$FileCache accessible class net/minecraft/client/render/RenderLayer$OutlineMode accessible class net/minecraft/client/particle/FireworksSparkParticle$Explosion accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractType diff --git a/src/main/resources/meteor-client.mixins.json b/src/main/resources/meteor-client.mixins.json index 9b7cf81096..b0ad1f5301 100644 --- a/src/main/resources/meteor-client.mixins.json +++ b/src/main/resources/meteor-client.mixins.json @@ -12,7 +12,6 @@ "AbstractFurnaceScreenMixin", "AbstractSignEditScreenAccessor", "ArmorFeatureRendererMixin", - "AttributeContainerMixin", "BackgroundRendererMixin", "BakedQuadMixin", "BannerBlockEntityRendererMixin", @@ -38,15 +37,12 @@ "BufferRendererAccessor", "CameraMixin", "CapabilityTrackerMixin", - "CapeFeatureRendererMixin", "ChatHudAccessor", "ChatHudLineMixin", - "ChatHudLineVisibleMixin", "ChatHudMixin", "ChatInputSuggestorMixin", "ChatScreenMixin", "ChunkAccessor", - "ChunkBorderDebugRendererMixin", "ChunkOcclusionDataBuilderMixin", "ChunkSkyLightProviderMixin", "ClientChunkManagerAccessor", @@ -68,15 +64,14 @@ "CreativeInventoryScreenAccessor", "CreativeSlotMixin", "CrossbowItemAccessor", + "CustomPayloadC2SPacketAccessor", "CustomPayloadS2CPacketMixin", "DefaultSkinHelperMixin", "DisconnectedScreenMixin", "DrawContextMixin", - "ElytraFeatureRendererMixin", "EnchantingTableBlockEntityRendererMixin", "EndCrystalEntityRendererMixin", "EntityAccessor", - "EntityAttributeInstanceMixin", "EntityBucketItemAccessor", "EntityMixin", "EntityRenderDispatcherMixin", @@ -85,7 +80,6 @@ "EntityVelocityUpdateS2CPacketAccessor", "ExplosionMixin", "ExplosionS2CPacketMixin", - "FileCacheAccessor", "FireworkRocketEntityMixin", "FireworksSparkParticleMixin", "FireworksSparkParticleSubMixin", @@ -117,7 +111,6 @@ "LivingEntityRendererMixin", "MapRendererAccessor", "MapRendererMixin", - "MessageHandlerMixin", "MinecraftClientAccessor", "MinecraftClientMixin", "MinecraftServerAccessor", @@ -140,7 +133,6 @@ "ProjectileEntityAccessor", "ProjectileInGroundAccessor", "RaycastContextMixin", - "RegistriesMixin", "ReloadStateAccessor", "RenderLayersMixin", "RenderTickCounterMixin", @@ -149,10 +141,10 @@ "SectionedEntityCacheAccessor", "ShapeIndexBufferAccessor", "ShulkerBoxBlockMixin", - "ShulkerEntityAccessor", "SignBlockEntityRendererMixin", "SimpleEntityLookupAccessor", "SimpleOptionMixin", + "SimpleRegistryMixin", "SlimeBlockMixin", "SlotMixin", "SoundSystemMixin", @@ -174,7 +166,9 @@ "WorldChunkMixin", "WorldRendererAccessor", "WorldRendererMixin", - "YggdrasilMinecraftSessionServiceAccessor" + "YggdrasilMinecraftSessionServiceAccessor", + "MessageHandlerMixin", + "ChatHudLineVisibleMixin" ], "injectors": { "defaultRequire": 1