From f3f790ef7ee733a7a92bc3055a60429cc49fc6d2 Mon Sep 17 00:00:00 2001 From: Kamigen <46357922+Edouard127@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:21:05 -0400 Subject: [PATCH 1/2] Migrate to 1.21 --- build.gradle.kts | 45 +++------- .../lambda/mixin/ClientConnectionMixin.java | 76 +++++++++++++++++ .../lambda/mixin/MinecraftClientMixin.java | 84 ++++++++++++++++++ .../baritone/MixinBaritonePlayerContext.java | 31 +++++++ .../mixin/baritone/MixinLookBehavior.java | 41 +++++++++ .../ClientPlayInteractionManagerMixin.java | 30 +++++++ .../mixin/entity/ClientPlayerEntityMixin.java | 82 ++++++++++++++++++ .../com/lambda/mixin/entity/EntityMixin.java | 64 ++++++++++++++ .../mixin/entity/LivingEntityMixin.java | 83 ++++++++++++++++++ .../mixin/entity/PlayerEntityMixin.java | 31 +++++++ .../lambda/mixin/input/KeyBindingMixin.java | 23 +++++ .../com/lambda/mixin/input/KeyboardMixin.java | 19 +++++ .../com/lambda/mixin/input/MouseMixin.java | 21 +++++ .../lambda/mixin/items/BarrierBlockMixin.java | 23 +++++ .../com/lambda/mixin/items/TridentMixin.java | 32 +++++++ .../mixin/render/BlockRenderManagerMixin.java | 22 +++++ .../com/lambda/mixin/render/CameraMixin.java | 58 +++++++++++++ .../mixin/render/ChatInputSuggestorMixin.java | 32 +++++++ .../lambda/mixin/render/ChatScreenMixin.java | 69 +++++++++++++++ .../lambda/mixin/render/DebugHudMixin.java | 24 ++++++ .../mixin/render/GameRendererMixin.java | 26 ++++++ .../mixin/render/GlStateManagerMixin.java | 48 +++++++++++ .../lambda/mixin/render/InGameHudMixin.java | 17 ++++ .../render/InGameOverlayRendererMixin.java | 51 +++++++++++ .../render/LightmapTextureManagerMixin.java | 27 ++++++ .../render/LivingEntityRendererMixin.java | 41 +++++++++ .../mixin/render/RenderLayersMixin.java | 20 +++++ .../mixin/render/RenderTickCounterMixin.java | 31 +++++++ .../mixin/render/ScreenHandlerMixin.java | 21 +++++ .../mixin/render/VertexBufferMixin.java | 25 ++++++ .../mixin/render/WorldRendererMixin.java | 22 +++++ .../mixin/world/ClientChunkManagerMixin.java | 85 +++++++++++++++++++ .../lambda/mixin/world/ClientWorldMixin.java | 27 ++++++ .../lambda/mixin/ClientConnectionMixin.java | 12 +-- .../com/lambda/mixin/render/CameraMixin.java | 16 ++-- .../mixin/render/GameRendererMixin.java | 13 +-- .../lambda/mixin/render/InGameHudMixin.java | 3 +- .../mixin/render/RenderTickCounterMixin.java | 4 +- .../mixin/render/VertexBufferMixin.java | 6 +- .../mixin/render/WorldRendererMixin.java | 12 ++- .../config/serializer/BlockSerializer.kt | 4 +- .../construction/simulation/BuildSimulator.kt | 11 +-- .../interaction/material/ContainerManager.kt | 8 +- .../interaction/material/StackSelection.kt | 8 +- .../visibilty/VisibilityChecker.kt | 1 + .../module/modules/movement/EntityControl.kt | 2 +- .../module/modules/network/ServerSpoof.kt | 4 +- .../module/modules/render/CameraTweaks.kt | 4 +- .../kotlin/com/lambda/sound/SoundManager.kt | 2 +- .../com/lambda/task/tasks/BuildStructure.kt | 3 +- .../com/lambda/task/tasks/PlaceContainer.kt | 4 +- .../kotlin/com/lambda/util/DebugInfoHud.kt | 1 + .../kotlin/com/lambda/util/FolderRegister.kt | 2 +- .../kotlin/com/lambda/util/combat/Damage.kt | 6 +- .../com/lambda/util/combat/Explosion.kt | 8 +- .../com/lambda/util/item/ItemStackUtils.kt | 19 ++--- .../com/lambda/util/player/MovementUtils.kt | 5 +- .../util/primitives/extension/Minecraft.kt | 9 ++ .../kotlin/com/lambda/util/text/TextEvents.kt | 21 ----- .../src/main/resources/lambda.accesswidener | 11 ++- fabric/build.gradle.kts | 29 +++++-- forge/build.gradle.kts | 24 ++++-- gradle.properties | 13 ++- neoforge/build.gradle.kts | 21 +++-- 64 files changed, 1437 insertions(+), 180 deletions(-) create mode 100644 common/remappedSrc/com/lambda/mixin/ClientConnectionMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/MinecraftClientMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java create mode 100644 common/remappedSrc/com/lambda/mixin/baritone/MixinLookBehavior.java create mode 100644 common/remappedSrc/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/entity/ClientPlayerEntityMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/entity/EntityMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/entity/LivingEntityMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/entity/PlayerEntityMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/input/KeyBindingMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/input/KeyboardMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/input/MouseMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/items/BarrierBlockMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/items/TridentMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/BlockRenderManagerMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/CameraMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/ChatInputSuggestorMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/ChatScreenMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/DebugHudMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/GameRendererMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/GlStateManagerMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/InGameHudMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/InGameOverlayRendererMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/LightmapTextureManagerMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/LivingEntityRendererMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/RenderLayersMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/RenderTickCounterMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/ScreenHandlerMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/VertexBufferMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/render/WorldRendererMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/world/ClientChunkManagerMixin.java create mode 100644 common/remappedSrc/com/lambda/mixin/world/ClientWorldMixin.java create mode 100644 common/src/main/kotlin/com/lambda/util/primitives/extension/Minecraft.kt diff --git a/build.gradle.kts b/build.gradle.kts index bafe85b3b..6d91e5297 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,7 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import net.fabricmc.loom.api.LoomGradleExtensionAPI -import net.fabricmc.loom.task.RemapJarTask import org.jetbrains.kotlin.gradle.dsl.JvmTarget import java.util.* -val targets = listOf("META-INF/*.toml", "fabric.mod.json") -val replacements = file("gradle.properties").inputStream().use { stream -> - Properties().apply { load(stream) } -}.map { (k, v) -> k.toString() to v.toString() }.toMap() - val modId: String by project val modVersion: String by project val mavenGroup: String by project @@ -16,6 +9,11 @@ val minecraftVersion: String by project val yarnMappings: String by project val libs = file("libs") +val targets = listOf("META-INF/*.toml", "fabric.mod.json") +val replacements = file("gradle.properties").inputStream().use { stream -> + Properties().apply { load(stream) } +}.map { (k, v) -> k.toString() to v.toString() }.toMap() + val Project.loom: LoomGradleExtensionAPI get() = (this as ExtensionAware).extensions.getByName("loom") as LoomGradleExtensionAPI @@ -23,7 +21,7 @@ plugins { kotlin("jvm") version "2.0.0" id("org.jetbrains.dokka") version "1.9.20" id("architectury-plugin") version "3.4-SNAPSHOT" - id("dev.architectury.loom") version "1.6-SNAPSHOT" apply false + id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false id("com.github.johnrengelman.shadow") version "8.1.1" apply false } @@ -37,38 +35,15 @@ subprojects { dependencies { "minecraft"("com.mojang:minecraft:$minecraftVersion") - "mappings"("net.fabricmc:yarn:$minecraftVersion+$yarnMappings:v2") + "mappings"(loom.layered { + mappings("net.fabricmc:yarn:$minecraftVersion+$yarnMappings:v2") + mappings("dev.architectury:yarn-mappings-patch-neoforge:$minecraftVersion+build.4") // Fix the mappings interaction between Yarn and NeoForge + }) } if (path == ":common") return@subprojects - apply(plugin = "com.github.johnrengelman.shadow") - - val versionWithMCVersion = "$modVersion+$minecraftVersion" - tasks { - val shadowCommon by configurations.creating { - isCanBeConsumed = false - isCanBeResolved = true - } - - val shadow = named("shadowJar") { - archiveVersion = versionWithMCVersion - archiveClassifier.set("shadow") - configurations = listOf(shadowCommon) - } - - named("remapJar") { - dependsOn(shadow) - inputFile = shadow.flatMap { it.archiveFile } - archiveVersion = versionWithMCVersion - archiveClassifier = "" - } - - jar { - enabled = false - } - processResources { // Replaces placeholders in the mod info files filesMatching(targets) { diff --git a/common/remappedSrc/com/lambda/mixin/ClientConnectionMixin.java b/common/remappedSrc/com/lambda/mixin/ClientConnectionMixin.java new file mode 100644 index 000000000..29cc5bb7a --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/ClientConnectionMixin.java @@ -0,0 +1,76 @@ +package com.lambda.mixin; + +import com.lambda.event.EventFlow; +import com.lambda.event.events.ConnectionEvent; +import com.lambda.event.events.PacketEvent; +import io.netty.channel.ChannelHandlerContext; +import net.minecraft.network.ClientConnection; +import net.minecraft.network.NetworkSide; +import net.minecraft.network.listener.PacketListener; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.c2s.handshake.ConnectionIntent; +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.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ClientConnection.class) +public class ClientConnectionMixin { + @Shadow + @Final + private NetworkSide side; + + @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true) + private void sendingPacket(Packet packet, final CallbackInfo callbackInfo) { + if (EventFlow.post(new PacketEvent.Send.Pre(packet)).isCanceled()) { + callbackInfo.cancel(); + } + } + + @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("RETURN")) + private void sendingPacketPost(Packet packet, final CallbackInfo callbackInfo) { + EventFlow.post(new PacketEvent.Send.Post(packet)); + } + + @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;handlePacket(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;)V", shift = At.Shift.BEFORE), cancellable = true, require = 1) + private void receivingPacket( + ChannelHandlerContext channelHandlerContext, + Packet packet, + CallbackInfo callbackInfo + ) { + if (side != NetworkSide.CLIENTBOUND) return; + if (EventFlow.post(new PacketEvent.Receive.Pre(packet)).isCanceled()) { + callbackInfo.cancel(); + } + } + + @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;handlePacket(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;)V", shift = At.Shift.AFTER)) + private void receivingPacketPost( + ChannelHandlerContext channelHandlerContext, + Packet packet, + CallbackInfo callbackInfo + ) { + if (side != NetworkSide.CLIENTBOUND) return; + + EventFlow.post(new PacketEvent.Receive.Post(packet)); + } + + @Inject(method = "connect(Ljava/lang/String;ILnet/minecraft/network/listener/PacketListener;Lnet/minecraft/network/packet/c2s/handshake/ConnectionIntent;)V", at = @At("HEAD")) + private void onConnect( + String address, + int port, + PacketListener listener, + ConnectionIntent intent, + CallbackInfo ci + ) { + EventFlow.post(new ConnectionEvent.Connect(address, port, listener, intent)); + } + + @Inject(method = "disconnect(Lnet/minecraft/text/Text;)V", at = @At("HEAD")) + private void onDisconnect(Text reason, CallbackInfo ci) { + EventFlow.post(new ConnectionEvent.Disconnect(reason)); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/MinecraftClientMixin.java b/common/remappedSrc/com/lambda/mixin/MinecraftClientMixin.java new file mode 100644 index 000000000..3d2e07027 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/MinecraftClientMixin.java @@ -0,0 +1,84 @@ +package com.lambda.mixin; + +import com.lambda.Lambda; +import com.lambda.event.EventFlow; +import com.lambda.event.events.ClientEvent; +import com.lambda.event.events.ScreenEvent; +import com.lambda.event.events.ScreenHandlerEvent; +import com.lambda.event.events.TickEvent; +import com.lambda.module.modules.player.Interact; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; +import net.minecraft.client.network.ClientPlayerInteractionManager; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(MinecraftClient.class) +public class MinecraftClientMixin { + @Shadow @Nullable public Screen currentScreen; + + @Inject(method = "tick", at = @At("HEAD")) + void onTickPre(CallbackInfo ci) { + EventFlow.post(new TickEvent.Pre()); + } + + @Inject(method = "tick", at = @At("RETURN")) + void onTickPost(CallbackInfo ci) { + EventFlow.post(new TickEvent.Post()); + } + + @Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;)V", shift = At.Shift.AFTER, remap = false), method = "stop") + private void onShutdown(CallbackInfo ci) { + EventFlow.post(new ClientEvent.Shutdown()); + } + + /** + * Inject after the thread field is set so `ThreadExecutor#getThread` is available + */ + @Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;thread:Ljava/lang/Thread;", shift = At.Shift.AFTER, ordinal = 0), method = "run") + private void onStartup(CallbackInfo ci) { + EventFlow.post(new ClientEvent.Startup()); + } + + @Inject(method = "setScreen", at = @At("HEAD")) + private void onScreenOpen(@Nullable Screen screen, CallbackInfo ci) { + if (screen == null) return; + if (screen instanceof ScreenHandlerProvider handledScreen) { + EventFlow.post(new ScreenHandlerEvent.Open<>(handledScreen.getScreenHandler())); + } + + EventFlow.post(new ScreenEvent.Open<>(screen)); + } + + @Inject(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;removed()V", shift = At.Shift.AFTER)) + private void onScreenRemove(@Nullable Screen screen, CallbackInfo ci) { + if (currentScreen == null) return; + if (currentScreen instanceof ScreenHandlerProvider handledScreen) { + EventFlow.post(new ScreenHandlerEvent.Close<>(handledScreen.getScreenHandler())); + } + + EventFlow.post(new ScreenEvent.Close<>(currentScreen)); + } + + @Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z")) + boolean injectMultiActon(ClientPlayerInteractionManager instance) { + if (instance == null) return true; + + if (Interact.INSTANCE.isEnabled() && Interact.getMultiAction()) return false; + return instance.isBreakingBlock(); + } + + @Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isRiding()Z")) + void injectFastPlace(CallbackInfo ci) { + if (!Interact.INSTANCE.isEnabled()) return; + + Lambda.getMc().itemUseCooldown = Interact.getPlaceDelay(); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java b/common/remappedSrc/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java new file mode 100644 index 000000000..eadb2657c --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java @@ -0,0 +1,31 @@ +package com.lambda.mixin.baritone; + +import baritone.Baritone; +import baritone.api.utils.Rotation; +import baritone.utils.player.BaritonePlayerContext; +import com.lambda.interaction.RotationManager; +import com.lambda.util.BaritoneUtils; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = BaritonePlayerContext.class, remap = false) // fix compileJava warning +public class MixinBaritonePlayerContext { + @Shadow + @Final + private Baritone baritone; + + // Let baritone know the actual rotation + @Inject(method = "playerRotations", at = @At("HEAD"), cancellable = true, remap = false) + void syncRotationWithBaritone(CallbackInfoReturnable cir) { + if (baritone != BaritoneUtils.getPrimary()) return; + + RotationManager rm = RotationManager.INSTANCE; + cir.setReturnValue(new Rotation( + (float) rm.getCurrentRotation().getYaw(), (float) rm.getCurrentRotation().getPitch()) + ); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/baritone/MixinLookBehavior.java b/common/remappedSrc/com/lambda/mixin/baritone/MixinLookBehavior.java new file mode 100644 index 000000000..1c442fa35 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/baritone/MixinLookBehavior.java @@ -0,0 +1,41 @@ +package com.lambda.mixin.baritone; + +import baritone.api.event.events.PlayerUpdateEvent; +import baritone.api.event.events.RotationMoveEvent; +import baritone.api.utils.Rotation; +import baritone.behavior.LookBehavior; +import com.lambda.interaction.RotationManager; +import com.lambda.util.BaritoneUtils; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(LookBehavior.class) +public class MixinLookBehavior { + // Redirect baritone's rotations into our rotation engine + @Inject(method = "updateTarget", at = @At("HEAD"), remap = false, cancellable = true) + void onTargetUpdate(Rotation rotation, boolean blockInteract, CallbackInfo ci) { + LookBehavior instance = ((LookBehavior) (Object) this); + if (instance.baritone != BaritoneUtils.getPrimary()) return; + + RotationManager.BaritoneProcessor.handleBaritoneRotation(rotation.getYaw(), rotation.getPitch()); + ci.cancel(); + } + + @Inject(method = "onPlayerUpdate", at = @At("HEAD"), remap = false, cancellable = true) + void onUpdate(PlayerUpdateEvent event, CallbackInfo ci) { + LookBehavior instance = ((LookBehavior) (Object) this); + if (instance.baritone != BaritoneUtils.getPrimary()) return; + + ci.cancel(); + } + + @Inject(method = "onPlayerRotationMove", at = @At("HEAD"), remap = false, cancellable = true) + void onMovementUpdate(RotationMoveEvent event, CallbackInfo ci) { + LookBehavior instance = ((LookBehavior) (Object) this); + if (instance.baritone != BaritoneUtils.getPrimary()) return; + + ci.cancel(); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java b/common/remappedSrc/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java new file mode 100644 index 000000000..03da40258 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java @@ -0,0 +1,30 @@ +package com.lambda.mixin.entity; + +import com.lambda.event.EventFlow; +import com.lambda.event.events.InteractionEvent; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.network.ClientPlayerInteractionManager; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ClientPlayerInteractionManager.class) +public class ClientPlayInteractionManagerMixin { + + @Final + @Shadow + private MinecraftClient client; + + @Inject(method = "interactBlock", at = @At("HEAD")) + public void interactBlockHead(final ClientPlayerEntity player, final Hand hand, final BlockHitResult hitResult, final CallbackInfoReturnable cir) { + if (client.world == null) return; + EventFlow.post(new InteractionEvent.Block(client.world, hitResult)); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/entity/ClientPlayerEntityMixin.java b/common/remappedSrc/com/lambda/mixin/entity/ClientPlayerEntityMixin.java new file mode 100644 index 000000000..1e1ca65da --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/entity/ClientPlayerEntityMixin.java @@ -0,0 +1,82 @@ +package com.lambda.mixin.entity; + +import com.lambda.Lambda; +import com.lambda.event.EventFlow; +import com.lambda.event.events.MovementEvent; +import com.lambda.interaction.PlayerPacketManager; +import com.lambda.interaction.RotationManager; +import net.minecraft.client.input.Input; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.entity.MovementType; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Objects; + +@Mixin(value = ClientPlayerEntity.class, priority = Integer.MAX_VALUE) +public abstract class ClientPlayerEntityMixin extends EntityMixin { + + @Shadow + public Input input; + @Shadow + private boolean autoJumpEnabled; + + @Shadow + protected abstract void autoJump(float dx, float dz); + + @Shadow + public abstract boolean isUsingItem(); + + @Inject(method = "move", at = @At("HEAD"), cancellable = true) + void onMove(MovementType movementType, Vec3d movement, CallbackInfo ci) { + ClientPlayerEntity self = (ClientPlayerEntity) (Object) this; + if (self != Lambda.getMc().player) return; + + ci.cancel(); + + float prevX = (float) self.getX(); + float prevZ = (float) self.getZ(); + + EventFlow.post(new MovementEvent.Pre()); + super.move(movementType, self.getVelocity()); + EventFlow.post(new MovementEvent.Post()); + + float currX = (float) self.getX(); + float currZ = (float) self.getZ(); + + this.autoJump(currX - prevX, currZ - prevZ); + } + + @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(ZF)V")) + void processMovement(Input input, boolean slowDown, float slowDownFactor) { + input.tick(slowDown, slowDownFactor); + EventFlow.post(new MovementEvent.InputUpdate(input, slowDown, slowDownFactor)); + } + + @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSprinting()Z")) + boolean isSprinting(ClientPlayerEntity entity) { + return EventFlow.post(new MovementEvent.Sprint(entity.isSprinting())).getSprint(); + } + + @Inject(method = "sendMovementPackets", at = @At(value = "HEAD"), cancellable = true) + void sendBegin(CallbackInfo ci) { + ci.cancel(); + PlayerPacketManager.sendPlayerPackets(); + autoJumpEnabled = Lambda.getMc().options.getAutoJump().getValue(); + } + + @Redirect(method = "tickNewAi", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getYaw()F")) + float fixHeldItemYaw(ClientPlayerEntity instance) { + return Objects.requireNonNullElse(RotationManager.getHandYaw(), instance.getYaw()); + } + + @Redirect(method = "tickNewAi", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getPitch()F")) + float fixHeldItemPitch(ClientPlayerEntity instance) { + return Objects.requireNonNullElse(RotationManager.getHandPitch(), instance.getPitch()); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/entity/EntityMixin.java b/common/remappedSrc/com/lambda/mixin/entity/EntityMixin.java new file mode 100644 index 000000000..88eb86372 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/entity/EntityMixin.java @@ -0,0 +1,64 @@ +package com.lambda.mixin.entity; + +import com.lambda.Lambda; +import com.lambda.interaction.RotationManager; +import com.lambda.util.math.Vec2d; +import net.minecraft.entity.Entity; +import net.minecraft.entity.MovementType; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(Entity.class) +public abstract class EntityMixin { + @Shadow + public void move(MovementType movementType, Vec3d movement) { + } + + @Shadow + public abstract float getYaw(); + + @Redirect(method = "updateVelocity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw()F")) + public float velocityYaw(Entity entity) { + if ((Object) this != Lambda.getMc().player) return getYaw(); + + Float y = RotationManager.getMovementYaw(); + if (y == null) return getYaw(); + + return y; + } + + @Redirect(method = "getRotationVec", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw(F)F")) + float fixDirectionYaw(Entity entity, float tickDelta) { + Vec2d rot = RotationManager.getRotationForVector(tickDelta); + if (entity != Lambda.getMc().player || rot == null) return entity.getYaw(tickDelta); + + return (float) rot.getX(); + } + + @Redirect(method = "getRotationVec", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPitch(F)F")) + float fixDirectionPitch(Entity entity, float tickDelta) { + Vec2d rot = RotationManager.getRotationForVector(tickDelta); + if (entity != Lambda.getMc().player || rot == null) return entity.getPitch(tickDelta); + + return (float) rot.getY(); + } + + @Redirect(method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw()F")) + float fixDirectionYaw2(Entity entity) { + Vec2d rot = RotationManager.getRotationForVector(1.0); + if (entity != Lambda.getMc().player || rot == null) return entity.getYaw(); + + return (float) rot.getX(); + } + + @Redirect(method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPitch()F")) + float fixDirectionPitch2(Entity entity) { + Vec2d rot = RotationManager.getRotationForVector(1.0); + if (entity != Lambda.getMc().player || rot == null) return entity.getPitch(); + + return (float) rot.getY(); + } +} \ No newline at end of file diff --git a/common/remappedSrc/com/lambda/mixin/entity/LivingEntityMixin.java b/common/remappedSrc/com/lambda/mixin/entity/LivingEntityMixin.java new file mode 100644 index 000000000..6be926e8e --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/entity/LivingEntityMixin.java @@ -0,0 +1,83 @@ +package com.lambda.mixin.entity; + +import com.lambda.Lambda; +import com.lambda.event.EventFlow; +import com.lambda.event.events.MovementEvent; +import com.lambda.interaction.RotationManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.Slice; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(LivingEntity.class) +public abstract class LivingEntityMixin extends EntityMixin { + + @Shadow + protected abstract float getJumpVelocity(); + + @Inject(method = "jump", at = @At("HEAD"), cancellable = true) + void onJump(CallbackInfo ci) { + LivingEntity self = (LivingEntity) (Object) this; + if (self != Lambda.getMc().player) return; + ci.cancel(); + + float height = this.getJumpVelocity(); + MovementEvent.Jump event = EventFlow.post(new MovementEvent.Jump(height)); + + if (event.isCanceled()) return; + + Vec3d vec3d = self.getVelocity(); + self.setVelocity(vec3d.x, event.getHeight(), vec3d.z); + + if (self.isSprinting()) { + Float yaw = RotationManager.getMovementYaw(); + float f = ((yaw != null) ? yaw : self.getYaw()) * ((float) Math.PI / 180); + self.setVelocity(self.getVelocity().add(-MathHelper.sin(f) * 0.2f, 0.0, MathHelper.cos(f) * 0.2f)); + } + + self.velocityDirty = true; + } + + @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isImmobile()Z")) + void onTravelH(CallbackInfo ci) { + Entity self = (Entity) (Object) this; + if (self != Lambda.getMc().player) return; + + RotationManager.update(); + } + + @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPitch()F")) + private float hookModifyFallFlyingPitch(LivingEntity entity) { + Float pitch = RotationManager.getMovementPitch(); + if (entity != Lambda.getMc().player || pitch == null) return entity.getPitch(); + + return pitch; + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F"), slice = @Slice(to = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F", ordinal = 1))) + private float rotBody(LivingEntity entity) { + if ((Object) this != Lambda.getMc().player) { + return entity.getYaw(); + } + + Float yaw = RotationManager.getRenderYaw(); + return (yaw == null) ? entity.getYaw() : yaw; + } + + @Redirect(method = "turnHead", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F")) + private float rotHead(LivingEntity entity) { + if ((Object) this != Lambda.getMc().player) { + return entity.getYaw(); + } + + Float yaw = RotationManager.getRenderYaw(); + return (yaw == null) ? entity.getYaw() : yaw; + } +} diff --git a/common/remappedSrc/com/lambda/mixin/entity/PlayerEntityMixin.java b/common/remappedSrc/com/lambda/mixin/entity/PlayerEntityMixin.java new file mode 100644 index 000000000..128bec35a --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/entity/PlayerEntityMixin.java @@ -0,0 +1,31 @@ +package com.lambda.mixin.entity; + +import com.lambda.event.EventFlow; +import com.lambda.event.events.MovementEvent; +import com.lambda.interaction.RotationManager; +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.PlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(PlayerEntity.class) +public class PlayerEntityMixin { + @Inject(method = "clipAtLedge", at = @At(value = "HEAD"), cancellable = true) + private void injectSafeWalk(CallbackInfoReturnable cir) { + MovementEvent.ClipAtLedge event = new MovementEvent.ClipAtLedge(((PlayerEntity) (Object) this).isSneaking()); + cir.setReturnValue(EventFlow.post(event).getClip()); + } + + @Redirect(method = "tickNewAi", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getYaw()F")) + private float injectHeadYaw(PlayerEntity instance) { + if ((Object) this != MinecraftClient.getInstance().player) { + return instance.getYaw(); + } + + Float yaw = RotationManager.getRenderYaw(); + return (yaw != null) ? yaw : instance.getYaw(); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/input/KeyBindingMixin.java b/common/remappedSrc/com/lambda/mixin/input/KeyBindingMixin.java new file mode 100644 index 000000000..224513f02 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/input/KeyBindingMixin.java @@ -0,0 +1,23 @@ +package com.lambda.mixin.input; + +import com.lambda.module.modules.movement.Speed; +import com.lambda.module.modules.movement.Sprint; +import net.minecraft.client.option.KeyBinding; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Objects; + +@Mixin(KeyBinding.class) +public class KeyBindingMixin { + @Inject(method = "isPressed", at = @At("HEAD"), cancellable = true) + void autoSprint(CallbackInfoReturnable cir) { + KeyBinding instance = (KeyBinding) (Object) this; + if (!Objects.equals(instance.getTranslationKey(), "key.sprint")) return; + + if (Sprint.INSTANCE.isEnabled()) cir.setReturnValue(true); + if (Speed.INSTANCE.isEnabled() && Speed.getMode() == Speed.Mode.GRIM_STRAFE) cir.setReturnValue(true); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/input/KeyboardMixin.java b/common/remappedSrc/com/lambda/mixin/input/KeyboardMixin.java new file mode 100644 index 000000000..a0672fc3c --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/input/KeyboardMixin.java @@ -0,0 +1,19 @@ +package com.lambda.mixin.input; + +import com.lambda.event.EventFlow; +import com.lambda.event.events.KeyPressEvent; +import net.minecraft.client.Keyboard; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Keyboard.class) +public class KeyboardMixin { + @Inject(method = "onKey", at = @At("HEAD")) + void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) { + if (key <= 0) return; + if (action != 1) return; + EventFlow.post(new KeyPressEvent(key, scancode, action, modifiers)); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/input/MouseMixin.java b/common/remappedSrc/com/lambda/mixin/input/MouseMixin.java new file mode 100644 index 000000000..77cdeb238 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/input/MouseMixin.java @@ -0,0 +1,21 @@ +package com.lambda.mixin.input; + +import com.lambda.module.modules.player.Freecam; +import net.minecraft.client.Mouse; +import net.minecraft.client.network.ClientPlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(Mouse.class) +public class MouseMixin { + @Redirect(method = "updateMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;changeLookDirection(DD)V")) + private void updateMouseChangeLookDirection(ClientPlayerEntity player, double cursorDeltaX, double cursorDeltaY) { + if (Freecam.INSTANCE.isEnabled()) { + Freecam.updateRotation(cursorDeltaX, cursorDeltaY); + return; + } + + player.changeLookDirection(cursorDeltaX, cursorDeltaY); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/items/BarrierBlockMixin.java b/common/remappedSrc/com/lambda/mixin/items/BarrierBlockMixin.java new file mode 100644 index 000000000..c416a2b5c --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/items/BarrierBlockMixin.java @@ -0,0 +1,23 @@ +package com.lambda.mixin.items; + +import com.lambda.module.modules.render.BlockESP; +import net.minecraft.block.BarrierBlock; +import net.minecraft.block.BlockRenderType; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(BarrierBlock.class) +public class BarrierBlockMixin { + + @Inject(method = "getRenderType", at = @At(value = "RETURN"), cancellable = true) + private void getRenderType(BlockState state, CallbackInfoReturnable cir) { + if (BlockESP.INSTANCE.isEnabled() + && BlockESP.getBarrier() + && state.getBlock() == Blocks.BARRIER + ) cir.setReturnValue(BlockRenderType.MODEL); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/items/TridentMixin.java b/common/remappedSrc/com/lambda/mixin/items/TridentMixin.java new file mode 100644 index 000000000..7381d70ba --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/items/TridentMixin.java @@ -0,0 +1,32 @@ +package com.lambda.mixin.items; + +import com.lambda.module.modules.movement.TridentBoost; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import net.minecraft.item.TridentItem; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +@Mixin(TridentItem.class) +public class TridentMixin { + // Forge doesn't support the @ModityArgs annotation, so we have to chain multiple @ModifyArg + @ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V"), index = 0) + private double modifyVelocity0(double velocity) { + return TridentBoost.INSTANCE.isEnabled() ? velocity * TridentBoost.getTridentSpeed() : velocity; + } + + @ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V"), index = 1) + private double modifyVelocity1(double velocity) { + return TridentBoost.INSTANCE.isEnabled() ? velocity * TridentBoost.getTridentSpeed() : velocity; + } + + @ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V"), index = 2) + private double modifyVelocity2(double velocity) { + return TridentBoost.INSTANCE.isEnabled() ? velocity * TridentBoost.getTridentSpeed() : velocity; + } + + @ModifyExpressionValue(method = {"onStoppedUsing", "use"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isTouchingWaterOrRain()Z")) + private boolean modifyIsTouchingWaterOrRain(boolean original) { + return TridentBoost.INSTANCE.isEnabled() && TridentBoost.getForceUse() || original; + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/BlockRenderManagerMixin.java b/common/remappedSrc/com/lambda/mixin/render/BlockRenderManagerMixin.java new file mode 100644 index 000000000..bda134ec5 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/BlockRenderManagerMixin.java @@ -0,0 +1,22 @@ +package com.lambda.mixin.render; + +import com.lambda.module.modules.render.BlockESP; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.render.block.BlockRenderManager; +import net.minecraft.client.render.model.BakedModel; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(BlockRenderManager.class) +public abstract class BlockRenderManagerMixin { + @Inject(method = "getModel", at = @At("HEAD"), cancellable = true) + private void getModel(BlockState state, CallbackInfoReturnable cir) { + if (BlockESP.INSTANCE.isEnabled() + && BlockESP.getBarrier() + && state.getBlock() == Blocks.BARRIER + ) cir.setReturnValue(BlockESP.getModel()); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/CameraMixin.java b/common/remappedSrc/com/lambda/mixin/render/CameraMixin.java new file mode 100644 index 000000000..393adc7d6 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/CameraMixin.java @@ -0,0 +1,58 @@ +package com.lambda.mixin.render; + +import com.lambda.interaction.RotationManager; +import com.lambda.module.modules.player.Freecam; +import com.lambda.module.modules.render.CameraTweaks; +import net.minecraft.client.render.Camera; +import net.minecraft.entity.Entity; +import net.minecraft.world.BlockView; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Camera.class) +public abstract class CameraMixin { + @Shadow + public abstract void setRotation(float yaw, float pitch); + + @Inject(method = "update", at = @At("TAIL")) + private void onUpdate( + BlockView area, + Entity focusedEntity, + boolean thirdPerson, + boolean inverseView, + float tickDelta, + CallbackInfo ci + ) { + if (!Freecam.INSTANCE.isEnabled()) return; + + Freecam.updateCam(); + } + + @Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V", shift = At.Shift.AFTER)) + private void injectQuickPerspectiveSwap(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) { + var rot = RotationManager.getLockRotation(); + if (rot == null) return; + setRotation(rot.getYawF(), rot.getPitchF()); + } + + @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true) + private void onClipToSpace(double desiredCameraDistance, CallbackInfoReturnable info) { + if (CameraTweaks.INSTANCE.isEnabled() && CameraTweaks.getNoClipCam()) { + info.setReturnValue(desiredCameraDistance); + } + } + + @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;clipToSpace(D)D")) + private double onDistanceUpdate(double desiredCameraDistance) { + if (CameraTweaks.INSTANCE.isEnabled()) { + return CameraTweaks.getCamDistance(); + } + + return desiredCameraDistance; + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/ChatInputSuggestorMixin.java b/common/remappedSrc/com/lambda/mixin/render/ChatInputSuggestorMixin.java new file mode 100644 index 000000000..3061c1e70 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/ChatInputSuggestorMixin.java @@ -0,0 +1,32 @@ +package com.lambda.mixin.render; + +import com.lambda.command.CommandManager; +import com.mojang.brigadier.CommandDispatcher; +import net.minecraft.client.gui.screen.ChatInputSuggestor; +import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.command.CommandSource; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(ChatInputSuggestor.class) +public class ChatInputSuggestorMixin { + + @Shadow + @Final + TextFieldWidget textField; + + @ModifyVariable(method = "refresh", at = @At(value = "STORE"), index = 3) + private boolean refreshModify(boolean showCompletions) { + return CommandManager.INSTANCE.isCommand(textField.getText()); + } + + @Redirect(method = "refresh", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;getCommandDispatcher()Lcom/mojang/brigadier/CommandDispatcher;")) + private CommandDispatcher refreshRedirect(ClientPlayNetworkHandler instance) { + return CommandManager.INSTANCE.currentDispatcher(textField.getText()); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/ChatScreenMixin.java b/common/remappedSrc/com/lambda/mixin/render/ChatScreenMixin.java new file mode 100644 index 000000000..01a68cf78 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/ChatScreenMixin.java @@ -0,0 +1,69 @@ +package com.lambda.mixin.render; + +import com.lambda.Lambda; +import com.lambda.command.CommandManager; +import com.lambda.graphics.renderer.gui.font.FontRenderer; +import com.lambda.graphics.renderer.gui.font.LambdaEmoji; +import com.lambda.graphics.renderer.gui.font.glyph.GlyphInfo; +import com.lambda.module.modules.client.LambdaMoji; +import com.lambda.util.math.Vec2d; +import kotlin.Pair; +import kotlin.ranges.IntRange; +import net.minecraft.client.gui.screen.ChatScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@Mixin(ChatScreen.class) +public abstract class ChatScreenMixin { + @ModifyArg(method = "sendMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendChatMessage(Ljava/lang/String;)V"), index = 0) + private String modifyChatText(String chatText) { + if (LambdaMoji.INSTANCE.isDisabled()) return chatText; + + List> emojis = FontRenderer.Companion.parseEmojis(chatText, LambdaEmoji.Twemoji); + Collections.reverse(emojis); + + List pushEmojis = new ArrayList<>(); + List pushPositions = new ArrayList<>(); + + for (Pair emoji : emojis) { + String emojiString = chatText.substring(emoji.getSecond().getStart() + 1, emoji.getSecond().getEndInclusive()); + if (LambdaEmoji.Twemoji.get(emojiString) == null) + continue; + + // Because the width of a char is bigger than an emoji + // we can simply replace the matches string by a space + // and render it after the text + chatText = chatText.substring(0, emoji.getSecond().getStart()) + " " + chatText.substring(emoji.getSecond().getEndInclusive() + 1); + + // We cannot retain the position in the future, but we can + // assume that every time you send a message the height of + // the position will change by the height of the glyph + // The positions are from the top left corner of the screen + int x = Lambda.getMc().textRenderer.getWidth(chatText.substring(0, emoji.getSecond().getStart())); + int y = Lambda.getMc().textRenderer.fontHeight; + + pushEmojis.add(String.format(":%s:", emojiString)); + pushPositions.add(new Vec2d(x, y)); + } + + // Not optimal because it has to parse the emoji again but who cares + LambdaMoji.INSTANCE.add(pushEmojis, pushPositions); + + return chatText; + } + + @Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true) + void sendMessageInject(String chatText, boolean addToHistory, CallbackInfoReturnable cir) { + if (!CommandManager.INSTANCE.isLambdaCommand(chatText)) return; + CommandManager.INSTANCE.executeCommand(chatText); + + cir.setReturnValue(true); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/DebugHudMixin.java b/common/remappedSrc/com/lambda/mixin/render/DebugHudMixin.java new file mode 100644 index 000000000..9c6439c49 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/DebugHudMixin.java @@ -0,0 +1,24 @@ +package com.lambda.mixin.render; + +import com.lambda.task.RootTask; +import com.lambda.util.DebugInfoHud; +import net.minecraft.client.gui.hud.DebugHud; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; + +@Mixin(DebugHud.class) +public class DebugHudMixin { + @Inject(method = "getRightText", at = @At(value = "TAIL")) + private void onGetRightText(CallbackInfoReturnable> cir) { + DebugInfoHud.addDebugInfo(cir.getReturnValue()); + } + + @Inject(method = "getLeftText", at = @At(value = "TAIL")) + private void onGetLeftText(CallbackInfoReturnable> cir) { + RootTask.INSTANCE.addInfo(cir.getReturnValue()); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/GameRendererMixin.java b/common/remappedSrc/com/lambda/mixin/render/GameRendererMixin.java new file mode 100644 index 000000000..683686ee7 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/GameRendererMixin.java @@ -0,0 +1,26 @@ +package com.lambda.mixin.render; + +import com.lambda.event.EventFlow; +import com.lambda.event.events.RenderEvent; +import com.lambda.graphics.RenderMain; +import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.util.math.MatrixStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GameRenderer.class) +public class GameRendererMixin { + @Inject(method = "updateTargetedEntity", at = @At("HEAD"), cancellable = true) + private void updateTargetedEntityInvoke(float tickDelta, CallbackInfo info) { + if (EventFlow.post(new RenderEvent.UpdateTarget()).isCanceled()) { + info.cancel(); + } + } + + @Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;render(Lnet/minecraft/client/util/math/MatrixStack;FJZLnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/GameRenderer;Lnet/minecraft/client/render/LightmapTextureManager;Lorg/joml/Matrix4f;)V", shift = At.Shift.AFTER)) + private void onRenderWorld(float tickDelta, long limitTime, MatrixStack matrix, CallbackInfo ci) { + RenderMain.render3D(matrix.peek().getPositionMatrix()); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/GlStateManagerMixin.java b/common/remappedSrc/com/lambda/mixin/render/GlStateManagerMixin.java new file mode 100644 index 000000000..0b54475a3 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/GlStateManagerMixin.java @@ -0,0 +1,48 @@ +package com.lambda.mixin.render; + +import com.lambda.graphics.gl.GlStateUtils; +import com.mojang.blaze3d.platform.GlStateManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import static org.lwjgl.opengl.GL11.*; + +@Mixin(GlStateManager.class) +public class GlStateManagerMixin { + @Inject(method = "_enableDepthTest", at = @At("TAIL"), remap = false) + private static void depthTestEnable(CallbackInfo ci) { + GlStateUtils.capSet(GL_DEPTH_TEST, true); + } + + @Inject(method = "_disableDepthTest", at = @At("TAIL"), remap = false) + private static void depthTestDisable(CallbackInfo ci) { + GlStateUtils.capSet(GL_DEPTH_TEST, false); + } + + @Inject(method = "_depthMask", at = @At("TAIL"), remap = false) + private static void depthMask(boolean mask, CallbackInfo ci) { + GlStateUtils.capSet(GL_DEPTH, mask); + } + + @Inject(method = "_enableBlend", at = @At("TAIL"), remap = false) + private static void blendEnable(CallbackInfo ci) { + GlStateUtils.capSet(GL_BLEND, true); + } + + @Inject(method = "_disableBlend", at = @At("TAIL"), remap = false) + private static void blendDisable(CallbackInfo ci) { + GlStateUtils.capSet(GL_BLEND, false); + } + + @Inject(method = "_enableCull", at = @At("TAIL"), remap = false) + private static void cullEnable(CallbackInfo ci) { + GlStateUtils.capSet(GL_CULL_FACE, true); + } + + @Inject(method = "_disableCull", at = @At("TAIL"), remap = false) + private static void cullDisable(CallbackInfo ci) { + GlStateUtils.capSet(GL_CULL_FACE, false); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/InGameHudMixin.java b/common/remappedSrc/com/lambda/mixin/render/InGameHudMixin.java new file mode 100644 index 000000000..f98c97947 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/InGameHudMixin.java @@ -0,0 +1,17 @@ +package com.lambda.mixin.render; + +import com.lambda.graphics.RenderMain; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.hud.InGameHud; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(InGameHud.class) +public class InGameHudMixin { + @Inject(method = "render", at = @At("TAIL")) + private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) { + RenderMain.render2D(); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/InGameOverlayRendererMixin.java b/common/remappedSrc/com/lambda/mixin/render/InGameOverlayRendererMixin.java new file mode 100644 index 000000000..54b9a578c --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/InGameOverlayRendererMixin.java @@ -0,0 +1,51 @@ +package com.lambda.mixin.render; + +import com.lambda.module.modules.render.NoRender; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.hud.InGameOverlayRenderer; +import net.minecraft.client.texture.Sprite; +import net.minecraft.client.util.math.MatrixStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(InGameOverlayRenderer.class) +public class InGameOverlayRendererMixin { + @Inject(method = "renderFireOverlay", at = @At("HEAD"), cancellable = true) + private static void onRenderFireOverlay( + MinecraftClient mc, + MatrixStack matrixStack, + CallbackInfo ci + ) { + if (NoRender.INSTANCE.isEnabled() && NoRender.getNoBurning()) ci.cancel(); + } + + @ModifyArg(method = "renderFireOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;translate(FFF)V"), index = 1) + private static float onRenderFireOverlayTranslate(float x) { + if (NoRender.INSTANCE.isEnabled()) { + return (float) NoRender.getFireOverlayYOffset(); + } else { + return -0.3f; + } + } + + @Inject(method = "renderUnderwaterOverlay", at = @At("HEAD"), cancellable = true) + private static void onRenderUnderwaterOverlay( + MinecraftClient mc, + MatrixStack matrixStack, + CallbackInfo ci + ) { + if (NoRender.INSTANCE.isEnabled() && NoRender.getNoUnderwater()) ci.cancel(); + } + + @Inject(method = "renderInWallOverlay", at = @At("HEAD"), cancellable = true) + private static void onRenderInWallOverlay( + Sprite sprite, + MatrixStack matrices, + CallbackInfo ci + ) { + if (NoRender.INSTANCE.isEnabled() && NoRender.getNoInWall()) ci.cancel(); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/LightmapTextureManagerMixin.java b/common/remappedSrc/com/lambda/mixin/render/LightmapTextureManagerMixin.java new file mode 100644 index 000000000..f2bb2c6d3 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/LightmapTextureManagerMixin.java @@ -0,0 +1,27 @@ +package com.lambda.mixin.render; + +import com.lambda.module.modules.render.Fullbright; +import com.lambda.module.modules.render.NoRender; +import com.lambda.module.modules.render.XRay; +import net.minecraft.client.render.LightmapTextureManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(LightmapTextureManager.class) +public class LightmapTextureManagerMixin { + @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/NativeImage;setColor(III)V"), index = 2) + private int updateModify(int color) { + if (Fullbright.INSTANCE.isEnabled() || XRay.INSTANCE.isEnabled()) { + return 0xFFFFFFFF; + } + return color; + } + + @Inject(method = "getDarknessFactor(F)F", at = @At("HEAD"), cancellable = true) + private void getDarknessFactor(float tickDelta, CallbackInfoReturnable info) { + if (NoRender.getNoDarkness()) info.setReturnValue(0.0f); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/LivingEntityRendererMixin.java b/common/remappedSrc/com/lambda/mixin/render/LivingEntityRendererMixin.java new file mode 100644 index 000000000..5de183ea1 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/LivingEntityRendererMixin.java @@ -0,0 +1,41 @@ +package com.lambda.mixin.render; + +import com.lambda.Lambda; +import com.lambda.interaction.RotationManager; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.MathHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Objects; + +@Mixin(LivingEntityRenderer.class) +public class LivingEntityRendererMixin { + @Unique + private Float lambda$pitch = null; + + @Inject(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) + private void injectRender(T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { + Float rotationPitch = RotationManager.getRenderPitch(); + + this.lambda$pitch = null; + + if (livingEntity != Lambda.getMc().player || rotationPitch == null) { + return; + } + + this.lambda$pitch = rotationPitch; + } + + @Redirect(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;lerp(FFF)F", ordinal = 0)) + private float injectRotationPitch(float g, float f, float s) { + return Objects.requireNonNullElseGet(lambda$pitch, () -> MathHelper.lerp(g, f, s)); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/RenderLayersMixin.java b/common/remappedSrc/com/lambda/mixin/render/RenderLayersMixin.java new file mode 100644 index 000000000..65ed53939 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/RenderLayersMixin.java @@ -0,0 +1,20 @@ +package com.lambda.mixin.render; + +import com.lambda.module.modules.render.XRay; +import net.minecraft.block.BlockState; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.RenderLayers; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(RenderLayers.class) +public class RenderLayersMixin { + @Inject(method = "getBlockLayer", at = @At("HEAD"), cancellable = true) + private static void onGetBlockLayer(BlockState state, CallbackInfoReturnable cir) { + if (XRay.INSTANCE.isDisabled()) return; + + if (!XRay.isSelected(state)) cir.setReturnValue(RenderLayer.getTranslucent()); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/RenderTickCounterMixin.java b/common/remappedSrc/com/lambda/mixin/render/RenderTickCounterMixin.java new file mode 100644 index 000000000..dd0f62f6e --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/RenderTickCounterMixin.java @@ -0,0 +1,31 @@ +package com.lambda.mixin.render; + +import com.lambda.core.TimerManager; +import net.minecraft.client.render.RenderTickCounter; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(RenderTickCounter.class) +public class RenderTickCounterMixin { + + @Shadow + public float lastFrameDuration; + @Shadow + public float tickDelta; + @Shadow + private long prevTimeMillis; + + @Inject(method = "beginRenderTick", at = @At("HEAD"), cancellable = true) + private void beginRenderTick(long timeMillis, CallbackInfoReturnable ci) { + lastFrameDuration = (timeMillis - prevTimeMillis) / TimerManager.getTickLength(); + prevTimeMillis = timeMillis; + tickDelta += lastFrameDuration; + int i = (int) tickDelta; + tickDelta -= i; + + ci.setReturnValue(i); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/ScreenHandlerMixin.java b/common/remappedSrc/com/lambda/mixin/render/ScreenHandlerMixin.java new file mode 100644 index 000000000..9f816cfbb --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/ScreenHandlerMixin.java @@ -0,0 +1,21 @@ +package com.lambda.mixin.render; + +import com.lambda.event.EventFlow; +import com.lambda.event.events.ScreenEvent; +import com.lambda.event.events.ScreenHandlerEvent; +import net.minecraft.item.ItemStack; +import net.minecraft.screen.ScreenHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.List; + +@Mixin(ScreenHandler.class) +public class ScreenHandlerMixin { + @Inject(method = "updateSlotStacks", at = @At("TAIL")) + private void onUpdateSlotStacksHead(int revision, List stacks, ItemStack cursorStack, CallbackInfo ci) { + EventFlow.post(new ScreenHandlerEvent.Loaded(revision, stacks, cursorStack)); + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/VertexBufferMixin.java b/common/remappedSrc/com/lambda/mixin/render/VertexBufferMixin.java new file mode 100644 index 000000000..6c3584660 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/VertexBufferMixin.java @@ -0,0 +1,25 @@ +package com.lambda.mixin.render; + +import com.lambda.graphics.gl.VaoUtils; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gl.VertexBuffer; +import net.minecraft.client.render.BufferBuilder; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.nio.ByteBuffer; + +@Mixin(VertexBuffer.class) +public class VertexBufferMixin { + @Shadow + private int indexBufferId; + + @Inject(method = "uploadIndexBuffer", at = @At("RETURN")) + private void onConfigureIndexBuffer(BufferBuilder.DrawParameters parameters, ByteBuffer vertexBuffer, CallbackInfoReturnable cir) { + RenderSystem.ShapeIndexBuffer value = cir.getReturnValue(); + VaoUtils.lastIbo = value == null ? this.indexBufferId : value.id; + } +} diff --git a/common/remappedSrc/com/lambda/mixin/render/WorldRendererMixin.java b/common/remappedSrc/com/lambda/mixin/render/WorldRendererMixin.java new file mode 100644 index 000000000..e95ee1303 --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/render/WorldRendererMixin.java @@ -0,0 +1,22 @@ +package com.lambda.mixin.render; + +import com.lambda.module.modules.player.Freecam; +import net.minecraft.client.render.Camera; +import net.minecraft.client.render.WorldRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(WorldRenderer.class) +public class WorldRendererMixin { + @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;isThirdPerson()Z")) + private boolean renderIsThirdPerson(Camera camera) { + return Freecam.INSTANCE.isEnabled() || camera.isThirdPerson(); + } + + @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;setupTerrain(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;ZZ)V"), index = 3) + private boolean renderSetupTerrainModifyArg(boolean spectator) { + return Freecam.INSTANCE.isEnabled() || spectator; + } +} diff --git a/common/remappedSrc/com/lambda/mixin/world/ClientChunkManagerMixin.java b/common/remappedSrc/com/lambda/mixin/world/ClientChunkManagerMixin.java new file mode 100644 index 000000000..a2845184e --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/world/ClientChunkManagerMixin.java @@ -0,0 +1,85 @@ +package com.lambda.mixin.world; + +import com.lambda.event.EventFlow; +import com.lambda.event.events.WorldEvent; +import net.minecraft.client.world.ClientChunkManager; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.packet.s2c.play.ChunkData; +import net.minecraft.util.math.ChunkPos; +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.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.function.Consumer; + +@Mixin(ClientChunkManager.class) +public class ClientChunkManagerMixin { + @Final + @Shadow + ClientWorld world; + + @Inject(method = "loadChunkFromPacket", at = @At("TAIL")) + private void onChunkLoad( + int x, + int z, + PacketByteBuf packetByteBuf, + NbtCompound nbtCompound, + Consumer consumer, + CallbackInfoReturnable info + ) { + EventFlow.post(new WorldEvent.ChunkEvent.Load(this.world, info.getReturnValue())); + } + + @Inject(method = "loadChunkFromPacket", at = @At(value = "NEW", target = "net/minecraft/world/chunk/WorldChunk", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) + private void onChunkUnload( + int x, + int z, + PacketByteBuf buf, + NbtCompound tag, + Consumer consumer, + CallbackInfoReturnable info, + int index, + WorldChunk chunk, + ChunkPos chunkPos + ) { + if (chunk != null) { + EventFlow.post(new WorldEvent.ChunkEvent.Unload(this.world, chunk)); + } + } + + @Inject(method = "unload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientChunkManager$ClientChunkMap;compareAndSet(ILnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/WorldChunk;)Lnet/minecraft/world/chunk/WorldChunk;"), locals = LocalCapture.CAPTURE_FAILHARD) + private void onChunkUnload(ChunkPos pos, CallbackInfo ci, int i, WorldChunk chunk) { + EventFlow.post(new WorldEvent.ChunkEvent.Unload(this.world, chunk)); + } + +// @Inject( +// method = "updateLoadDistance", +// at = @At( +// value = "INVOKE", +// target = "net/minecraft/client/world/ClientChunkManager$ClientChunkMap.isInRadius(II)Z" +// ), +// locals = LocalCapture.CAPTURE_FAILHARD +// ) +// private void onUpdateLoadDistance( +// int loadDistance, +// CallbackInfo ci, +// int oldRadius, +// int newRadius, +// ClientChunkManager.ClientChunkMap clientChunkMap, +// int k, +// WorldChunk oldChunk, +// ChunkPos chunkPos +// ) { +// if (!clientChunkMap.isInRadius(chunkPos.x, chunkPos.z)) { +// EventFlow.post(new WorldEvent.ChunkEvent.Unload(this.world, oldChunk)); +// } +// } +} diff --git a/common/remappedSrc/com/lambda/mixin/world/ClientWorldMixin.java b/common/remappedSrc/com/lambda/mixin/world/ClientWorldMixin.java new file mode 100644 index 000000000..af12440bc --- /dev/null +++ b/common/remappedSrc/com/lambda/mixin/world/ClientWorldMixin.java @@ -0,0 +1,27 @@ +package com.lambda.mixin.world; + +import com.lambda.event.EventFlow; +import com.lambda.event.events.WorldEvent; +import net.minecraft.block.BlockState; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ClientWorld.class) +public class ClientWorldMixin { + @Inject(method = "handleBlockUpdate", at = @At("HEAD"), cancellable = true) + private void handleBlockUpdateInject(BlockPos pos, BlockState state, int flags, CallbackInfo ci) { + if (EventFlow.post(new WorldEvent.BlockUpdate(pos, state, flags)).isCanceled()) { + ci.cancel(); + } + } + + @Inject(method = "addEntity", at = @At("HEAD"), cancellable = true) + private void addEntity(Entity entity, CallbackInfo ci) { + if (EventFlow.post(new WorldEvent.EntitySpawn(entity)).isCanceled()) ci.cancel(); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java b/common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java index 29cc5bb7a..388a4c778 100644 --- a/common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java +++ b/common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java @@ -6,7 +6,7 @@ import io.netty.channel.ChannelHandlerContext; import net.minecraft.network.ClientConnection; import net.minecraft.network.NetworkSide; -import net.minecraft.network.listener.PacketListener; +import net.minecraft.network.listener.ClientLoginPacketListener; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.handshake.ConnectionIntent; import net.minecraft.text.Text; @@ -58,15 +58,11 @@ private void receivingPacketPost( EventFlow.post(new PacketEvent.Receive.Post(packet)); } - @Inject(method = "connect(Ljava/lang/String;ILnet/minecraft/network/listener/PacketListener;Lnet/minecraft/network/packet/c2s/handshake/ConnectionIntent;)V", at = @At("HEAD")) + @Inject(method = "connect(Ljava/lang/String;ILnet/minecraft/network/listener/ClientLoginPacketListener;)V", at = @At("HEAD")) private void onConnect( - String address, - int port, - PacketListener listener, - ConnectionIntent intent, - CallbackInfo ci + String address, int port, ClientLoginPacketListener listener, CallbackInfo ci ) { - EventFlow.post(new ConnectionEvent.Connect(address, port, listener, intent)); + EventFlow.post(new ConnectionEvent.Connect(address, port, listener, ConnectionIntent.LOGIN)); } @Inject(method = "disconnect(Lnet/minecraft/text/Text;)V", at = @At("HEAD")) diff --git a/common/src/main/java/com/lambda/mixin/render/CameraMixin.java b/common/src/main/java/com/lambda/mixin/render/CameraMixin.java index 393adc7d6..37192d062 100644 --- a/common/src/main/java/com/lambda/mixin/render/CameraMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/CameraMixin.java @@ -41,18 +41,14 @@ private void injectQuickPerspectiveSwap(BlockView area, Entity focusedEntity, bo } @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true) - private void onClipToSpace(double desiredCameraDistance, CallbackInfoReturnable info) { - if (CameraTweaks.INSTANCE.isEnabled() && CameraTweaks.getNoClipCam()) { - info.setReturnValue(desiredCameraDistance); - } + private void onClipToSpace(float f, CallbackInfoReturnable cir) { + if (CameraTweaks.INSTANCE.isEnabled() && CameraTweaks.getNoClipCam()) cir.setReturnValue(f); } - @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;clipToSpace(D)D")) - private double onDistanceUpdate(double desiredCameraDistance) { - if (CameraTweaks.INSTANCE.isEnabled()) { - return CameraTweaks.getCamDistance(); - } + @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;clipToSpace(F)F")) + private float onDistanceUpdate(float f) { + if (CameraTweaks.INSTANCE.isEnabled()) return CameraTweaks.getCamDistance(); - return desiredCameraDistance; + return f; } } diff --git a/common/src/main/java/com/lambda/mixin/render/GameRendererMixin.java b/common/src/main/java/com/lambda/mixin/render/GameRendererMixin.java index 683686ee7..f5be4a189 100644 --- a/common/src/main/java/com/lambda/mixin/render/GameRendererMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/GameRendererMixin.java @@ -2,9 +2,7 @@ import com.lambda.event.EventFlow; import com.lambda.event.events.RenderEvent; -import com.lambda.graphics.RenderMain; import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,15 +10,8 @@ @Mixin(GameRenderer.class) public class GameRendererMixin { - @Inject(method = "updateTargetedEntity", at = @At("HEAD"), cancellable = true) + @Inject(method = "updateCrosshairTarget", at = @At("HEAD"), cancellable = true) private void updateTargetedEntityInvoke(float tickDelta, CallbackInfo info) { - if (EventFlow.post(new RenderEvent.UpdateTarget()).isCanceled()) { - info.cancel(); - } - } - - @Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;render(Lnet/minecraft/client/util/math/MatrixStack;FJZLnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/GameRenderer;Lnet/minecraft/client/render/LightmapTextureManager;Lorg/joml/Matrix4f;)V", shift = At.Shift.AFTER)) - private void onRenderWorld(float tickDelta, long limitTime, MatrixStack matrix, CallbackInfo ci) { - RenderMain.render3D(matrix.peek().getPositionMatrix()); + if (EventFlow.post(new RenderEvent.UpdateTarget()).isCanceled()) info.cancel(); } } diff --git a/common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java b/common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java index f98c97947..b632ac626 100644 --- a/common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java @@ -3,6 +3,7 @@ import com.lambda.graphics.RenderMain; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -11,7 +12,7 @@ @Mixin(InGameHud.class) public class InGameHudMixin { @Inject(method = "render", at = @At("TAIL")) - private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) { + private void onRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { RenderMain.render2D(); } } diff --git a/common/src/main/java/com/lambda/mixin/render/RenderTickCounterMixin.java b/common/src/main/java/com/lambda/mixin/render/RenderTickCounterMixin.java index dd0f62f6e..6d86e3994 100644 --- a/common/src/main/java/com/lambda/mixin/render/RenderTickCounterMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/RenderTickCounterMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(RenderTickCounter.class) +@Mixin(RenderTickCounter.Dynamic.class) public class RenderTickCounterMixin { @Shadow @@ -18,7 +18,7 @@ public class RenderTickCounterMixin { @Shadow private long prevTimeMillis; - @Inject(method = "beginRenderTick", at = @At("HEAD"), cancellable = true) + @Inject(method = "beginRenderTick*", at = @At("HEAD"), cancellable = true) private void beginRenderTick(long timeMillis, CallbackInfoReturnable ci) { lastFrameDuration = (timeMillis - prevTimeMillis) / TimerManager.getTickLength(); prevTimeMillis = timeMillis; diff --git a/common/src/main/java/com/lambda/mixin/render/VertexBufferMixin.java b/common/src/main/java/com/lambda/mixin/render/VertexBufferMixin.java index 6c3584660..bb7836bab 100644 --- a/common/src/main/java/com/lambda/mixin/render/VertexBufferMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/VertexBufferMixin.java @@ -3,7 +3,7 @@ import com.lambda.graphics.gl.VaoUtils; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gl.VertexBuffer; -import net.minecraft.client.render.BufferBuilder; +import net.minecraft.client.render.BuiltBuffer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -17,8 +17,8 @@ public class VertexBufferMixin { @Shadow private int indexBufferId; - @Inject(method = "uploadIndexBuffer", at = @At("RETURN")) - private void onConfigureIndexBuffer(BufferBuilder.DrawParameters parameters, ByteBuffer vertexBuffer, CallbackInfoReturnable cir) { + @Inject(method = "uploadIndexBuffer(Lnet/minecraft/client/render/BuiltBuffer$DrawParameters;Ljava/nio/ByteBuffer;)Lcom/mojang/blaze3d/systems/RenderSystem$ShapeIndexBuffer;", at = @At("RETURN")) + private void onConfigureIndexBuffer(BuiltBuffer.DrawParameters parameters, ByteBuffer indexBuffer, CallbackInfoReturnable cir) { RenderSystem.ShapeIndexBuffer value = cir.getReturnValue(); VaoUtils.lastIbo = value == null ? this.indexBufferId : value.id; } diff --git a/common/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java b/common/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java index e95ee1303..eff16d8d4 100644 --- a/common/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java @@ -1,12 +1,15 @@ package com.lambda.mixin.render; +import com.lambda.graphics.RenderMain; import com.lambda.module.modules.player.Freecam; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.*; +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(WorldRenderer.class) public class WorldRendererMixin { @@ -19,4 +22,9 @@ private boolean renderIsThirdPerson(Camera camera) { private boolean renderSetupTerrainModifyArg(boolean spectator) { return Freecam.INSTANCE.isEnabled() || spectator; } + + @Inject(method = "render", at = @At(value = "TAIL")) + private void onRenderWorld(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { + RenderMain.render3D(matrix4f); + } } diff --git a/common/src/main/kotlin/com/lambda/config/serializer/BlockSerializer.kt b/common/src/main/kotlin/com/lambda/config/serializer/BlockSerializer.kt index 8c33f8913..350a5e378 100644 --- a/common/src/main/kotlin/com/lambda/config/serializer/BlockSerializer.kt +++ b/common/src/main/kotlin/com/lambda/config/serializer/BlockSerializer.kt @@ -21,5 +21,5 @@ object BlockSerializer : JsonSerializer, JsonDeserializer { typeOfT: Type?, context: JsonDeserializationContext?, ): Block = - Registries.BLOCK.getOrEmpty(Identifier(json?.asString)).orElseThrow() -} \ No newline at end of file + Registries.BLOCK.getOrEmpty(Identifier.ofVanilla(json?.asString)).orElseThrow() +} diff --git a/common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt b/common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt index b75318aaf..25028d817 100644 --- a/common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt +++ b/common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt @@ -28,7 +28,6 @@ import net.minecraft.block.pattern.CachedBlockPosition import net.minecraft.item.BlockItem import net.minecraft.item.ItemPlacementContext import net.minecraft.item.ItemUsageContext -import net.minecraft.registry.RegistryKeys import net.minecraft.util.Hand import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.hit.HitResult @@ -178,10 +177,8 @@ object BuildSimulator { usageContext.blockPos, false ) - val canBePlacedOn = optimalStack.canPlaceOn( - usageContext.world.registryManager.get(RegistryKeys.BLOCK), - cachePos, - ) + val canBePlacedOn = optimalStack.canPlaceOn(cachePos) + if (!player.abilities.allowModifyWorld && !canBePlacedOn) { acc.add(PlaceResult.IllegalUsage(pos)) return@forEach @@ -244,7 +241,7 @@ object BuildSimulator { acc.add(BuildResult.WrongStack(pos, placeContext, target.copy)) return@forEach } - + if (optimalStack.item != currentHandStack.item) { acc.add(BuildResult.WrongItem(pos, placeContext, optimalStack.item)) return@forEach @@ -411,4 +408,4 @@ object BuildSimulator { // val aabb = Box(pBox.minX, pBox.minY - 1.0E-6, pBox.minZ, pBox.maxX, pBox.minY, pBox.maxZ) // return world.findSupportingBlockPos(player, aabb).orElse(null) // } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/interaction/material/ContainerManager.kt b/common/src/main/kotlin/com/lambda/interaction/material/ContainerManager.kt index ad4d35bbf..4f3a23fde 100644 --- a/common/src/main/kotlin/com/lambda/interaction/material/ContainerManager.kt +++ b/common/src/main/kotlin/com/lambda/interaction/material/ContainerManager.kt @@ -19,7 +19,7 @@ import net.minecraft.item.ItemStack import net.minecraft.screen.GenericContainerScreenHandler import net.minecraft.screen.ScreenHandler import net.minecraft.screen.ScreenHandlerType -import java.util.TreeSet +import java.util.* // ToDo: Make this a Configurable to save container caches. Should use a cached region based storage system. object ContainerManager : Loadable { @@ -109,10 +109,10 @@ object ContainerManager : Loadable { blockState: BlockState, availableTools: Set = ItemUtils.tools, ) = availableTools.map { - it to it.getMiningSpeedMultiplier(it.defaultStack, blockState) + it to it.getMiningSpeed(it.defaultStack, blockState) }.filter { (item, speed) -> speed > 1.0 - && item.isSuitableFor(blockState) + && item.isCorrectForDrops(item.defaultStack, blockState) && findContainerWithSelection(item.select()) != null }.maxByOrNull { it.second @@ -121,4 +121,4 @@ object ContainerManager : Loadable { // fun SafeContext.nextDisposable() = player.combined.firstOrNull { it.item in TaskFlow.disposables } class NoContainerFound(selection: StackSelection): Exception("No container found matching $selection") -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt b/common/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt index 857bbbf71..e352c2691 100644 --- a/common/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt +++ b/common/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt @@ -4,9 +4,9 @@ import com.lambda.util.BlockUtils.item import com.lambda.util.item.ItemStackUtils.shulkerBoxContents import net.minecraft.block.Block import net.minecraft.enchantment.Enchantment -import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.item.Item import net.minecraft.item.ItemStack +import net.minecraft.registry.entry.RegistryEntry import net.minecraft.screen.slot.Slot import kotlin.reflect.KClass @@ -138,10 +138,8 @@ class StackSelection { * @return A predicate that matches the [Enchantment] and `level`. */ fun hasEnchantment(enchantment: Enchantment, level: Int = -1): (ItemStack) -> Boolean = { - if (level < 0) { - EnchantmentHelper.getLevel(enchantment, it) > 0 - } else { - EnchantmentHelper.getLevel(enchantment, it) == level + it.enchantments.getLevel(RegistryEntry.of(enchantment)).let { enchantmentLevel -> + level == -1 || enchantmentLevel >= level } } diff --git a/common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt b/common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt index 5e8d6a6f2..e8d5d82b7 100644 --- a/common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt +++ b/common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt @@ -10,6 +10,7 @@ import com.lambda.module.modules.client.TaskFlow import com.lambda.util.BlockUtils.blockState import com.lambda.util.math.VecUtils.distSq import com.lambda.util.primitives.extension.component6 +import com.lambda.util.primitives.extension.tickDelta import com.lambda.util.world.raycast.RayCastUtils.blockResult import com.lambda.util.world.raycast.RayCastUtils.entityResult import net.minecraft.entity.Entity diff --git a/common/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt b/common/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt index f67665104..d1353925a 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt @@ -20,7 +20,7 @@ object EntityControl : Module( /* General */ private val forceMount by setting("Force Mount", true, description = "Attempts to force mount chested entities.", visibility = { page == Page.GENERAL }).apply { onValueChange { _, _ -> - horses.forEach { horse -> horse.updateSaddle() } + horses.forEach { horse -> horse.updateSaddledFlag() } } } diff --git a/common/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt b/common/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt index 1001cb814..d0b79061e 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt @@ -32,7 +32,7 @@ object ServerSpoof : Module( if (packet !is CustomPayloadC2SPacket) return@unsafeListener val payload = packet.payload if (payload !is BrandCustomPayload) return@unsafeListener - if (!spoofClientBrand || payload.id() != BrandCustomPayload.ID) return@unsafeListener + if (!spoofClientBrand || payload.id != BrandCustomPayload.ID) return@unsafeListener payload.write(PacketByteBuf(Unpooled.buffer()).writeString(spoofName)) } @@ -54,4 +54,4 @@ object ServerSpoof : Module( }) } } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt b/common/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt index d6c0f891f..1961a990f 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt @@ -9,7 +9,7 @@ object CameraTweaks : Module( defaultTags = setOf(ModuleTag.RENDER) ) { @JvmStatic - val camDistance by setting("Camera Distance", 4.0, 1.0..20.0, 0.1) + val camDistance by setting("Camera Distance", 4.0f, 1.0f..20.0f, 0.1f) @JvmStatic val noClipCam by setting("No Clip Camera", true) -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/sound/SoundManager.kt b/common/src/main/kotlin/com/lambda/sound/SoundManager.kt index be081fcec..7249ca5ec 100644 --- a/common/src/main/kotlin/com/lambda/sound/SoundManager.kt +++ b/common/src/main/kotlin/com/lambda/sound/SoundManager.kt @@ -22,5 +22,5 @@ object SoundManager { ) } - fun String.toIdentifier() = Identifier(Lambda.MOD_ID, this) + fun String.toIdentifier(): Identifier = Identifier.of(Lambda.MOD_ID, this) } diff --git a/common/src/main/kotlin/com/lambda/task/tasks/BuildStructure.kt b/common/src/main/kotlin/com/lambda/task/tasks/BuildStructure.kt index fc27eb6f3..d8706e60d 100644 --- a/common/src/main/kotlin/com/lambda/task/tasks/BuildStructure.kt +++ b/common/src/main/kotlin/com/lambda/task/tasks/BuildStructure.kt @@ -17,6 +17,7 @@ import com.lambda.module.modules.client.TaskFlow import com.lambda.task.Task import com.lambda.util.BaritoneUtils import com.lambda.util.Communication.info +import com.lambda.util.primitives.extension.tickDelta import net.minecraft.util.math.BlockPos class BuildStructure @Ta5kBuilder constructor( @@ -142,4 +143,4 @@ class BuildStructure @Ta5kBuilder constructor( blockPos.toStructure(TargetState.Air).toBlueprint() ) } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt b/common/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt index b0fd34c96..37bdb79f9 100644 --- a/common/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt +++ b/common/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt @@ -5,12 +5,12 @@ import com.lambda.interaction.construction.Blueprint.Companion.toStructure import com.lambda.interaction.construction.StaticBlueprint.Companion.toBlueprint import com.lambda.interaction.construction.result.BuildResult import com.lambda.interaction.construction.result.PlaceResult -import com.lambda.interaction.construction.result.Resolvable import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.verify.TargetState import com.lambda.task.Task import com.lambda.task.tasks.BuildStructure.Companion.buildStructure import com.lambda.util.BlockUtils.blockPos +import com.lambda.util.primitives.extension.tickDelta import net.minecraft.item.ItemStack import net.minecraft.util.math.BlockPos @@ -50,4 +50,4 @@ class PlaceContainer @Ta5kBuilder constructor( fun placeContainer(stack: ItemStack) = PlaceContainer(stack) } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/util/DebugInfoHud.kt b/common/src/main/kotlin/com/lambda/util/DebugInfoHud.kt index c735a7b4f..a089ebb0d 100644 --- a/common/src/main/kotlin/com/lambda/util/DebugInfoHud.kt +++ b/common/src/main/kotlin/com/lambda/util/DebugInfoHud.kt @@ -6,6 +6,7 @@ import com.lambda.command.CommandRegistry import com.lambda.event.EventFlow import com.lambda.module.ModuleRegistry import com.lambda.util.Formatting.asString +import com.lambda.util.primitives.extension.tickDelta import net.minecraft.util.Formatting import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.hit.EntityHitResult diff --git a/common/src/main/kotlin/com/lambda/util/FolderRegister.kt b/common/src/main/kotlin/com/lambda/util/FolderRegister.kt index ee6ffc8e6..bdb712ffe 100644 --- a/common/src/main/kotlin/com/lambda/util/FolderRegister.kt +++ b/common/src/main/kotlin/com/lambda/util/FolderRegister.kt @@ -42,7 +42,7 @@ object FolderRegister { val path = resolve( hostName.sanitizeForFilename() ).resolve( - mc.world?.dimensionKey?.value?.path?.sanitizeForFilename() ?: "unknown" + mc.world?.dimensionEntry?.value()?.toString()?.sanitizeForFilename() ?: "unknown" ) path.createIfNotExists() return path diff --git a/common/src/main/kotlin/com/lambda/util/combat/Damage.kt b/common/src/main/kotlin/com/lambda/util/combat/Damage.kt index e3c31c1c1..430051619 100644 --- a/common/src/main/kotlin/com/lambda/util/combat/Damage.kt +++ b/common/src/main/kotlin/com/lambda/util/combat/Damage.kt @@ -1,12 +1,10 @@ package com.lambda.util.combat -import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.entity.LivingEntity import net.minecraft.entity.damage.DamageSource import net.minecraft.entity.effect.StatusEffects import net.minecraft.registry.tag.DamageTypeTags import kotlin.math.max -import kotlin.math.min object Damage { /** @@ -24,9 +22,9 @@ object Damage { if (source.isIn(DamageTypeTags.BYPASSES_ENCHANTMENTS)) return damage - val protectionAmount = EnchantmentHelper.getProtectionAmount(entity.armorItems, source) + //val protectionAmount = EnchantmentHelper.getProtectionAmount(entity.armorItems, source) - if (protectionAmount > 0) return damage * (1.0 - min(protectionAmount, 20) / 25.0) + //if (protectionAmount > 0) return damage * (1.0 - min(protectionAmount, 20) / 25.0) return damage } diff --git a/common/src/main/kotlin/com/lambda/util/combat/Explosion.kt b/common/src/main/kotlin/com/lambda/util/combat/Explosion.kt index ac559c39c..1413dd312 100644 --- a/common/src/main/kotlin/com/lambda/util/combat/Explosion.kt +++ b/common/src/main/kotlin/com/lambda/util/combat/Explosion.kt @@ -3,10 +3,7 @@ package com.lambda.util.combat import com.lambda.context.SafeContext import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.fluidState -import com.lambda.util.math.VecUtils.minus -import com.lambda.util.math.VecUtils.times import com.lambda.util.world.WorldUtils.getFastEntities -import net.minecraft.enchantment.ProtectionEnchantment import net.minecraft.entity.LivingEntity import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Vec3d @@ -75,13 +72,14 @@ object Explosion { val distance = entity.pos.distanceTo(position) val size = power * 2.0 - val vel = ProtectionEnchantment.transformExplosionKnockback( + /*val vel = ProtectionEnchantment.transformExplosionKnockback( entity, (1.0 - distance / size) * Explosion.getExposure(position, entity) ) val diff = entity.eyePos - position - return diff.normalize() * vel + return diff.normalize() * vel*/ + return Vec3d.ZERO } fun SafeContext.explosionDestruction(source: Explosion): List { diff --git a/common/src/main/kotlin/com/lambda/util/item/ItemStackUtils.kt b/common/src/main/kotlin/com/lambda/util/item/ItemStackUtils.kt index aa15c663a..15676551d 100644 --- a/common/src/main/kotlin/com/lambda/util/item/ItemStackUtils.kt +++ b/common/src/main/kotlin/com/lambda/util/item/ItemStackUtils.kt @@ -1,11 +1,8 @@ package com.lambda.util.item import com.lambda.util.collections.Cacheable.Companion.cacheable -import net.minecraft.inventory.Inventories -import net.minecraft.item.BlockItem +import net.minecraft.component.DataComponentTypes import net.minecraft.item.ItemStack -import net.minecraft.nbt.NbtElement -import net.minecraft.util.collection.DefaultedList object ItemStackUtils { val ItemStack.spaceLeft get() = maxCount - count @@ -41,13 +38,8 @@ object ItemStackUtils { } val ItemStack.shulkerBoxContents: List by cacheable { stack -> - BlockItem.getBlockEntityNbt(stack)?.takeIf { - it.contains("Items", NbtElement.LIST_TYPE.toInt()) - }?.let { - val list = DefaultedList.ofSize(27, ItemStack.EMPTY) - Inventories.readNbt(it, list) - list - } ?: emptyList() + stack.components.get(DataComponentTypes.CONTAINER)?.stream()?.toList() + ?: emptyList() } /** @@ -60,5 +52,6 @@ object ItemStackUtils { */ fun ItemStack?.equal(other: ItemStack?) = ItemStack.areEqual(this, other) - fun ItemStack.combines(other: ItemStack) = ItemStack.canCombine(this, other) -} \ No newline at end of file + // TODO: Find the new method for this + //fun ItemStack.combines(other: ItemStack) = ItemStack.canCombine(this, other) +} diff --git a/common/src/main/kotlin/com/lambda/util/player/MovementUtils.kt b/common/src/main/kotlin/com/lambda/util/player/MovementUtils.kt index 32f197782..530153c20 100644 --- a/common/src/main/kotlin/com/lambda/util/player/MovementUtils.kt +++ b/common/src/main/kotlin/com/lambda/util/player/MovementUtils.kt @@ -12,7 +12,6 @@ import com.lambda.util.math.VecUtils.times import net.minecraft.client.input.Input import net.minecraft.client.input.KeyboardInput import net.minecraft.client.network.ClientPlayerEntity -import net.minecraft.enchantment.EnchantmentHelper.getSwiftSneakSpeedBoost import net.minecraft.entity.Entity import net.minecraft.util.math.EightWayDirection import net.minecraft.util.math.Vec3d @@ -30,7 +29,7 @@ object MovementUtils { player.input } else { val multiplier = if (!player.shouldSlowDown()) 1f - else (0.3f + getSwiftSneakSpeedBoost(player)).coerceIn(0f, 1f) + else (0.3f + /*getSwiftSneakSpeedBoost(player)*/0).coerceIn(0f, 1f) KeyboardInput(mc.options).apply { tick(true, multiplier) @@ -132,4 +131,4 @@ object MovementUtils { val directionIndex = ((normalizedYaw + 22.5) / 45.0).toInt() % 8 return EightWayDirection.entries[directionIndex] } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/util/primitives/extension/Minecraft.kt b/common/src/main/kotlin/com/lambda/util/primitives/extension/Minecraft.kt new file mode 100644 index 000000000..27b91c457 --- /dev/null +++ b/common/src/main/kotlin/com/lambda/util/primitives/extension/Minecraft.kt @@ -0,0 +1,9 @@ +package com.lambda.util.primitives.extension + +import net.minecraft.client.MinecraftClient + +val MinecraftClient.tickDelta: Float + get() = renderTickCounter.tickDelta + +val MinecraftClient.pausedTickDelta: Float + get() = renderTickCounter.tickDeltaBeforePause diff --git a/common/src/main/kotlin/com/lambda/util/text/TextEvents.kt b/common/src/main/kotlin/com/lambda/util/text/TextEvents.kt index 972153633..6464d0d85 100644 --- a/common/src/main/kotlin/com/lambda/util/text/TextEvents.kt +++ b/common/src/main/kotlin/com/lambda/util/text/TextEvents.kt @@ -18,9 +18,7 @@ package com.lambda.util.text import net.minecraft.entity.Entity import net.minecraft.entity.EntityType -import net.minecraft.item.Item import net.minecraft.item.ItemStack -import net.minecraft.nbt.NbtCompound import net.minecraft.text.ClickEvent import net.minecraft.text.HoverEvent import net.minecraft.text.Text @@ -104,25 +102,6 @@ object HoverEvents { return HoverEvent(HoverEvent.Action.SHOW_ITEM, HoverEvent.ItemStackContent(itemStack)) } - /** - * Creates a [HoverEvent] showing an [ItemStack] created from the given [NBT Compound][nbt]. - * - * @see HoverEvent.Action.SHOW_ITEM - */ - fun showItem(nbt: NbtCompound): HoverEvent { - return showItem(ItemStack.fromNbt(nbt)) - } - - /** - * Creates a [HoverEvent] showing an [ItemStack] created from the given [item] - * with an optional [NBT tag][nbt]. - * - * @see HoverEvent.Action.SHOW_ITEM - */ - fun showItem(item: Item, nbt: NbtCompound? = null): HoverEvent { - return showItem(item.defaultStack.also { it.nbt = nbt }) - } - /** * Creates a [HoverEvent] showing an [Entity] of a specified [type][entityType] * with the specified [uuid] and an optional [name]. diff --git a/common/src/main/resources/lambda.accesswidener b/common/src/main/resources/lambda.accesswidener index 4a8c265d5..24d7ff9a2 100644 --- a/common/src/main/resources/lambda.accesswidener +++ b/common/src/main/resources/lambda.accesswidener @@ -3,12 +3,12 @@ accessWidener v2 named accessible field net/minecraft/client/MinecraftClient itemUseCooldown I accessible field net/minecraft/client/MinecraftClient attackCooldown I accessible field net/minecraft/client/MinecraftClient paused Z -accessible field net/minecraft/client/MinecraftClient pausedTickDelta F accessible field net/minecraft/client/MinecraftClient thread Ljava/lang/Thread; +accessible field net/minecraft/client/MinecraftClient renderTickCounter Lnet/minecraft/client/render/RenderTickCounter$Dynamic; # World -accessible field net/minecraft/client/world/ClientWorld entityManager Lnet/minecraft/client/world/ClientEntityManager; -accessible field net/minecraft/client/world/ClientEntityManager cache Lnet/minecraft/world/entity/SectionedEntityCache; +accessible field net/minecraft/client/world/ClientWorld entityManager Lnet/minecraft/world/entity/ClientEntityManager; +accessible field net/minecraft/world/entity/ClientEntityManager cache Lnet/minecraft/world/entity/SectionedEntityCache; accessible field net/minecraft/world/entity/EntityTrackingSection collection Lnet/minecraft/util/collection/TypeFilterableList; accessible field net/minecraft/client/world/ClientChunkManager chunks Lnet/minecraft/client/world/ClientChunkManager$ClientChunkMap; accessible field net/minecraft/client/world/ClientChunkManager$ClientChunkMap chunks Ljava/util/concurrent/atomic/AtomicReferenceArray; @@ -17,7 +17,7 @@ accessible field net/minecraft/client/world/ClientChunkManager$ClientChunkMap ch accessible field net/minecraft/entity/projectile/FireworkRocketEntity shooter Lnet/minecraft/entity/LivingEntity; accessible method net/minecraft/entity/Entity movementInputToVelocity (Lnet/minecraft/util/math/Vec3d;FF)Lnet/minecraft/util/math/Vec3d; accessible method net/minecraft/entity/passive/AbstractHorseEntity setHorseFlag (IZ)V -accessible method net/minecraft/entity/passive/AbstractHorseEntity updateSaddle ()V +accessible method net/minecraft/entity/passive/AbstractHorseEntity updateSaddledFlag ()V # Camera accessible method net/minecraft/client/render/Camera setPos (DDD)V @@ -27,6 +27,8 @@ accessible method net/minecraft/client/render/Camera setRotation (FF)V accessible field com/mojang/blaze3d/systems/RenderSystem$ShapeIndexBuffer id I accessible field net/minecraft/client/render/BufferRenderer currentVertexBuffer Lnet/minecraft/client/gl/VertexBuffer; accessible field net/minecraft/client/texture/NativeImage pointer J +accessible field net/minecraft/client/render/RenderTickCounter$Dynamic tickDelta F +accessible field net/minecraft/client/render/RenderTickCounter$Dynamic tickDeltaBeforePause F # Text accessible field net/minecraft/text/Style color Lnet/minecraft/text/TextColor; @@ -46,6 +48,7 @@ accessible field net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPa accessible field net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket type Lnet/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler; accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractAtHandler +accessible method net/minecraft/network/packet/BrandCustomPayload write (Lnet/minecraft/network/PacketByteBuf;)V accessible method net/minecraft/network/ClientConnection handlePacket (Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;)V accessible field net/minecraft/network/ClientConnection packetsReceivedCounter I accessible field net/minecraft/network/ClientConnection packetsSentCounter I diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index b82926a0c..b901c6c71 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,3 +1,4 @@ +val modVersion: String by project val minecraftVersion: String by project val fabricLoaderVersion: String by project val fabricApiVersion: String by project @@ -5,6 +6,10 @@ val kotlinFabricVersion: String by project base.archivesName = "${base.archivesName.get()}-fabric" +plugins { + id("com.github.johnrengelman.shadow") version "8.1.1" +} + architectury { platformSetupLoomIde() fabric() @@ -40,11 +45,6 @@ fun DependencyHandlerScope.setupConfigurations() { modImplementation(it) include(it) } - - shadowBundle.dependencies.forEach { - shadowCommon(it) - shadow(it) - } } dependencies { @@ -73,10 +73,23 @@ dependencies { } tasks { - // Access wideners are the successor of the mixins accessor - // that were used in the past to access private fields and methods. - // They allow you to make field, method, and class access public. + shadowJar { + archiveVersion = "$modVersion+$minecraftVersion" + configurations = listOf(shadowBundle) + archiveClassifier = "dev-shadow" + } + remapJar { + dependsOn(shadowJar) + + // Access wideners are the successor of the mixins accessor + // that were used in the past to access private fields and methods. + // They allow you to make field, method, and class access public. injectAccessWidener = true } + + remapJar { + dependsOn(processResources, shadowJar) + inputFile = shadowJar.get().archiveFile + } } diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 5c416a023..12f45e61d 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -1,3 +1,4 @@ +val modVersion: String by project val minecraftVersion: String by project val forgeVersion: String by project val mixinExtrasVersion: String by project @@ -5,6 +6,10 @@ val kotlinForgeVersion: String by project base.archivesName = "${base.archivesName.get()}-forge" +plugins { + id("com.github.johnrengelman.shadow") version "8.1.1" +} + architectury { platformSetupLoomIde() forge() @@ -62,11 +67,6 @@ fun DependencyHandlerScope.setupConfigurations() { forgeRuntimeLibrary(it) include(it) } - - shadowBundle.dependencies.forEach { - shadowCommon(it) - shadow(it) - } } dependencies { @@ -85,9 +85,6 @@ dependencies { implementation("io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion") compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!) - // Fix KFF - compileOnly(kotlin("stdlib")) - // Disable reflections logging include("org.slf4j:slf4j-nop:2.0.13") @@ -105,4 +102,15 @@ tasks { it.output.setResourcesDir(dir) it.java.destinationDirectory.set(dir) } + + shadowJar { + archiveVersion = "$modVersion+$minecraftVersion" + configurations = listOf(shadowBundle) + archiveClassifier = "dev-shadow" + } + + remapJar { + dependsOn(processResources, shadowJar) + inputFile = shadowJar.get().archiveFile + } } diff --git a/gradle.properties b/gradle.properties index bda234554..d9770261e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,24 +6,23 @@ mavenGroup=com.lambda modAuthors=Constructor, Blade, Edouard127 # General -minecraftVersion=1.20.4 +minecraftVersion=1.21 mixinExtrasVersion=0.3.6 kotlinVersion=2.0.0 kotlinxCoroutinesVersion=1.9.0-RC # Fabric https://fabricmc.net/develop/ fabricLoaderVersion=0.15.11 -yarnMappings=build.3 -fabricApiVersion=0.97.1 +yarnMappings=build.7 +fabricApiVersion=0.100.4 kotlinFabricVersion=1.11.0+kotlin.2.0.0 # Forge https://files.minecraftforge.net/ -# Please do not change this version it will implode and create a black hole -forgeVersion=49.0.31 -kotlinForgeVersion=4.11.0 +forgeVersion=51.0.21 +kotlinForgeVersion=5.3.0 # NeoForge https://neoforged.net -neoVersion=20.4.237 +neoVersion=21.0.47-beta # Kotlin https://kotlinlang.org/ kotlin.code.style=official diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 44b5c300a..cc66931b3 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -1,8 +1,14 @@ +val modVersion: String by project +val minecraftVersion: String by project val neoVersion: String by project val kotlinForgeVersion: String by project base.archivesName = "${base.archivesName.get()}-neoforge" +plugins { + id("com.github.johnrengelman.shadow") version "8.1.1" +} + architectury { platformSetupLoomIde() neoForge() @@ -42,11 +48,6 @@ fun DependencyHandlerScope.setupConfigurations() { implementation(it) include(it) } - - shadowBundle.dependencies.forEach { - shadowCommon(it) - shadow(it) - } } dependencies { @@ -79,8 +80,14 @@ tasks { } } + shadowJar { + archiveVersion = "$modVersion+$minecraftVersion" + configurations = listOf(shadowBundle) + archiveClassifier = "dev-shadow" + } + remapJar { - dependsOn(processResources) - atAccessWideners.add("lambda.accesswidener") // Add the access widener to the remapper + dependsOn(processResources, shadowJar) + inputFile = shadowJar.get().archiveFile } } From f02f00da48ecef9cd611e0d9fc324b3834deca56 Mon Sep 17 00:00:00 2001 From: Kamigen <46357922+Edouard127@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:23:28 -0400 Subject: [PATCH 2/2] Removed remapped src --- .../lambda/mixin/ClientConnectionMixin.java | 76 ----------------- .../lambda/mixin/MinecraftClientMixin.java | 84 ------------------ .../baritone/MixinBaritonePlayerContext.java | 31 ------- .../mixin/baritone/MixinLookBehavior.java | 41 --------- .../ClientPlayInteractionManagerMixin.java | 30 ------- .../mixin/entity/ClientPlayerEntityMixin.java | 82 ------------------ .../com/lambda/mixin/entity/EntityMixin.java | 64 -------------- .../mixin/entity/LivingEntityMixin.java | 83 ------------------ .../mixin/entity/PlayerEntityMixin.java | 31 ------- .../lambda/mixin/input/KeyBindingMixin.java | 23 ----- .../com/lambda/mixin/input/KeyboardMixin.java | 19 ----- .../com/lambda/mixin/input/MouseMixin.java | 21 ----- .../lambda/mixin/items/BarrierBlockMixin.java | 23 ----- .../com/lambda/mixin/items/TridentMixin.java | 32 ------- .../mixin/render/BlockRenderManagerMixin.java | 22 ----- .../com/lambda/mixin/render/CameraMixin.java | 58 ------------- .../mixin/render/ChatInputSuggestorMixin.java | 32 ------- .../lambda/mixin/render/ChatScreenMixin.java | 69 --------------- .../lambda/mixin/render/DebugHudMixin.java | 24 ------ .../mixin/render/GameRendererMixin.java | 26 ------ .../mixin/render/GlStateManagerMixin.java | 48 ----------- .../lambda/mixin/render/InGameHudMixin.java | 17 ---- .../render/InGameOverlayRendererMixin.java | 51 ----------- .../render/LightmapTextureManagerMixin.java | 27 ------ .../render/LivingEntityRendererMixin.java | 41 --------- .../mixin/render/RenderLayersMixin.java | 20 ----- .../mixin/render/RenderTickCounterMixin.java | 31 ------- .../mixin/render/ScreenHandlerMixin.java | 21 ----- .../mixin/render/VertexBufferMixin.java | 25 ------ .../mixin/render/WorldRendererMixin.java | 22 ----- .../mixin/world/ClientChunkManagerMixin.java | 85 ------------------- .../lambda/mixin/world/ClientWorldMixin.java | 27 ------ 32 files changed, 1286 deletions(-) delete mode 100644 common/remappedSrc/com/lambda/mixin/ClientConnectionMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/MinecraftClientMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java delete mode 100644 common/remappedSrc/com/lambda/mixin/baritone/MixinLookBehavior.java delete mode 100644 common/remappedSrc/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/entity/ClientPlayerEntityMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/entity/EntityMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/entity/LivingEntityMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/entity/PlayerEntityMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/input/KeyBindingMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/input/KeyboardMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/input/MouseMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/items/BarrierBlockMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/items/TridentMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/BlockRenderManagerMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/CameraMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/ChatInputSuggestorMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/ChatScreenMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/DebugHudMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/GameRendererMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/GlStateManagerMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/InGameHudMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/InGameOverlayRendererMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/LightmapTextureManagerMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/LivingEntityRendererMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/RenderLayersMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/RenderTickCounterMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/ScreenHandlerMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/VertexBufferMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/render/WorldRendererMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/world/ClientChunkManagerMixin.java delete mode 100644 common/remappedSrc/com/lambda/mixin/world/ClientWorldMixin.java diff --git a/common/remappedSrc/com/lambda/mixin/ClientConnectionMixin.java b/common/remappedSrc/com/lambda/mixin/ClientConnectionMixin.java deleted file mode 100644 index 29cc5bb7a..000000000 --- a/common/remappedSrc/com/lambda/mixin/ClientConnectionMixin.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.lambda.mixin; - -import com.lambda.event.EventFlow; -import com.lambda.event.events.ConnectionEvent; -import com.lambda.event.events.PacketEvent; -import io.netty.channel.ChannelHandlerContext; -import net.minecraft.network.ClientConnection; -import net.minecraft.network.NetworkSide; -import net.minecraft.network.listener.PacketListener; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.c2s.handshake.ConnectionIntent; -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.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(ClientConnection.class) -public class ClientConnectionMixin { - @Shadow - @Final - private NetworkSide side; - - @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true) - private void sendingPacket(Packet packet, final CallbackInfo callbackInfo) { - if (EventFlow.post(new PacketEvent.Send.Pre(packet)).isCanceled()) { - callbackInfo.cancel(); - } - } - - @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("RETURN")) - private void sendingPacketPost(Packet packet, final CallbackInfo callbackInfo) { - EventFlow.post(new PacketEvent.Send.Post(packet)); - } - - @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;handlePacket(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;)V", shift = At.Shift.BEFORE), cancellable = true, require = 1) - private void receivingPacket( - ChannelHandlerContext channelHandlerContext, - Packet packet, - CallbackInfo callbackInfo - ) { - if (side != NetworkSide.CLIENTBOUND) return; - if (EventFlow.post(new PacketEvent.Receive.Pre(packet)).isCanceled()) { - callbackInfo.cancel(); - } - } - - @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;handlePacket(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;)V", shift = At.Shift.AFTER)) - private void receivingPacketPost( - ChannelHandlerContext channelHandlerContext, - Packet packet, - CallbackInfo callbackInfo - ) { - if (side != NetworkSide.CLIENTBOUND) return; - - EventFlow.post(new PacketEvent.Receive.Post(packet)); - } - - @Inject(method = "connect(Ljava/lang/String;ILnet/minecraft/network/listener/PacketListener;Lnet/minecraft/network/packet/c2s/handshake/ConnectionIntent;)V", at = @At("HEAD")) - private void onConnect( - String address, - int port, - PacketListener listener, - ConnectionIntent intent, - CallbackInfo ci - ) { - EventFlow.post(new ConnectionEvent.Connect(address, port, listener, intent)); - } - - @Inject(method = "disconnect(Lnet/minecraft/text/Text;)V", at = @At("HEAD")) - private void onDisconnect(Text reason, CallbackInfo ci) { - EventFlow.post(new ConnectionEvent.Disconnect(reason)); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/MinecraftClientMixin.java b/common/remappedSrc/com/lambda/mixin/MinecraftClientMixin.java deleted file mode 100644 index 3d2e07027..000000000 --- a/common/remappedSrc/com/lambda/mixin/MinecraftClientMixin.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.lambda.mixin; - -import com.lambda.Lambda; -import com.lambda.event.EventFlow; -import com.lambda.event.events.ClientEvent; -import com.lambda.event.events.ScreenEvent; -import com.lambda.event.events.ScreenHandlerEvent; -import com.lambda.event.events.TickEvent; -import com.lambda.module.modules.player.Interact; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; -import net.minecraft.client.network.ClientPlayerInteractionManager; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(MinecraftClient.class) -public class MinecraftClientMixin { - @Shadow @Nullable public Screen currentScreen; - - @Inject(method = "tick", at = @At("HEAD")) - void onTickPre(CallbackInfo ci) { - EventFlow.post(new TickEvent.Pre()); - } - - @Inject(method = "tick", at = @At("RETURN")) - void onTickPost(CallbackInfo ci) { - EventFlow.post(new TickEvent.Post()); - } - - @Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;)V", shift = At.Shift.AFTER, remap = false), method = "stop") - private void onShutdown(CallbackInfo ci) { - EventFlow.post(new ClientEvent.Shutdown()); - } - - /** - * Inject after the thread field is set so `ThreadExecutor#getThread` is available - */ - @Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;thread:Ljava/lang/Thread;", shift = At.Shift.AFTER, ordinal = 0), method = "run") - private void onStartup(CallbackInfo ci) { - EventFlow.post(new ClientEvent.Startup()); - } - - @Inject(method = "setScreen", at = @At("HEAD")) - private void onScreenOpen(@Nullable Screen screen, CallbackInfo ci) { - if (screen == null) return; - if (screen instanceof ScreenHandlerProvider handledScreen) { - EventFlow.post(new ScreenHandlerEvent.Open<>(handledScreen.getScreenHandler())); - } - - EventFlow.post(new ScreenEvent.Open<>(screen)); - } - - @Inject(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;removed()V", shift = At.Shift.AFTER)) - private void onScreenRemove(@Nullable Screen screen, CallbackInfo ci) { - if (currentScreen == null) return; - if (currentScreen instanceof ScreenHandlerProvider handledScreen) { - EventFlow.post(new ScreenHandlerEvent.Close<>(handledScreen.getScreenHandler())); - } - - EventFlow.post(new ScreenEvent.Close<>(currentScreen)); - } - - @Redirect(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z")) - boolean injectMultiActon(ClientPlayerInteractionManager instance) { - if (instance == null) return true; - - if (Interact.INSTANCE.isEnabled() && Interact.getMultiAction()) return false; - return instance.isBreakingBlock(); - } - - @Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isRiding()Z")) - void injectFastPlace(CallbackInfo ci) { - if (!Interact.INSTANCE.isEnabled()) return; - - Lambda.getMc().itemUseCooldown = Interact.getPlaceDelay(); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java b/common/remappedSrc/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java deleted file mode 100644 index eadb2657c..000000000 --- a/common/remappedSrc/com/lambda/mixin/baritone/MixinBaritonePlayerContext.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.lambda.mixin.baritone; - -import baritone.Baritone; -import baritone.api.utils.Rotation; -import baritone.utils.player.BaritonePlayerContext; -import com.lambda.interaction.RotationManager; -import com.lambda.util.BaritoneUtils; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = BaritonePlayerContext.class, remap = false) // fix compileJava warning -public class MixinBaritonePlayerContext { - @Shadow - @Final - private Baritone baritone; - - // Let baritone know the actual rotation - @Inject(method = "playerRotations", at = @At("HEAD"), cancellable = true, remap = false) - void syncRotationWithBaritone(CallbackInfoReturnable cir) { - if (baritone != BaritoneUtils.getPrimary()) return; - - RotationManager rm = RotationManager.INSTANCE; - cir.setReturnValue(new Rotation( - (float) rm.getCurrentRotation().getYaw(), (float) rm.getCurrentRotation().getPitch()) - ); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/baritone/MixinLookBehavior.java b/common/remappedSrc/com/lambda/mixin/baritone/MixinLookBehavior.java deleted file mode 100644 index 1c442fa35..000000000 --- a/common/remappedSrc/com/lambda/mixin/baritone/MixinLookBehavior.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.lambda.mixin.baritone; - -import baritone.api.event.events.PlayerUpdateEvent; -import baritone.api.event.events.RotationMoveEvent; -import baritone.api.utils.Rotation; -import baritone.behavior.LookBehavior; -import com.lambda.interaction.RotationManager; -import com.lambda.util.BaritoneUtils; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(LookBehavior.class) -public class MixinLookBehavior { - // Redirect baritone's rotations into our rotation engine - @Inject(method = "updateTarget", at = @At("HEAD"), remap = false, cancellable = true) - void onTargetUpdate(Rotation rotation, boolean blockInteract, CallbackInfo ci) { - LookBehavior instance = ((LookBehavior) (Object) this); - if (instance.baritone != BaritoneUtils.getPrimary()) return; - - RotationManager.BaritoneProcessor.handleBaritoneRotation(rotation.getYaw(), rotation.getPitch()); - ci.cancel(); - } - - @Inject(method = "onPlayerUpdate", at = @At("HEAD"), remap = false, cancellable = true) - void onUpdate(PlayerUpdateEvent event, CallbackInfo ci) { - LookBehavior instance = ((LookBehavior) (Object) this); - if (instance.baritone != BaritoneUtils.getPrimary()) return; - - ci.cancel(); - } - - @Inject(method = "onPlayerRotationMove", at = @At("HEAD"), remap = false, cancellable = true) - void onMovementUpdate(RotationMoveEvent event, CallbackInfo ci) { - LookBehavior instance = ((LookBehavior) (Object) this); - if (instance.baritone != BaritoneUtils.getPrimary()) return; - - ci.cancel(); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java b/common/remappedSrc/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java deleted file mode 100644 index 03da40258..000000000 --- a/common/remappedSrc/com/lambda/mixin/entity/ClientPlayInteractionManagerMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.lambda.mixin.entity; - -import com.lambda.event.EventFlow; -import com.lambda.event.events.InteractionEvent; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.network.ClientPlayerInteractionManager; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ClientPlayerInteractionManager.class) -public class ClientPlayInteractionManagerMixin { - - @Final - @Shadow - private MinecraftClient client; - - @Inject(method = "interactBlock", at = @At("HEAD")) - public void interactBlockHead(final ClientPlayerEntity player, final Hand hand, final BlockHitResult hitResult, final CallbackInfoReturnable cir) { - if (client.world == null) return; - EventFlow.post(new InteractionEvent.Block(client.world, hitResult)); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/entity/ClientPlayerEntityMixin.java b/common/remappedSrc/com/lambda/mixin/entity/ClientPlayerEntityMixin.java deleted file mode 100644 index 1e1ca65da..000000000 --- a/common/remappedSrc/com/lambda/mixin/entity/ClientPlayerEntityMixin.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.lambda.mixin.entity; - -import com.lambda.Lambda; -import com.lambda.event.EventFlow; -import com.lambda.event.events.MovementEvent; -import com.lambda.interaction.PlayerPacketManager; -import com.lambda.interaction.RotationManager; -import net.minecraft.client.input.Input; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.MovementType; -import net.minecraft.util.math.Vec3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.Objects; - -@Mixin(value = ClientPlayerEntity.class, priority = Integer.MAX_VALUE) -public abstract class ClientPlayerEntityMixin extends EntityMixin { - - @Shadow - public Input input; - @Shadow - private boolean autoJumpEnabled; - - @Shadow - protected abstract void autoJump(float dx, float dz); - - @Shadow - public abstract boolean isUsingItem(); - - @Inject(method = "move", at = @At("HEAD"), cancellable = true) - void onMove(MovementType movementType, Vec3d movement, CallbackInfo ci) { - ClientPlayerEntity self = (ClientPlayerEntity) (Object) this; - if (self != Lambda.getMc().player) return; - - ci.cancel(); - - float prevX = (float) self.getX(); - float prevZ = (float) self.getZ(); - - EventFlow.post(new MovementEvent.Pre()); - super.move(movementType, self.getVelocity()); - EventFlow.post(new MovementEvent.Post()); - - float currX = (float) self.getX(); - float currZ = (float) self.getZ(); - - this.autoJump(currX - prevX, currZ - prevZ); - } - - @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;tick(ZF)V")) - void processMovement(Input input, boolean slowDown, float slowDownFactor) { - input.tick(slowDown, slowDownFactor); - EventFlow.post(new MovementEvent.InputUpdate(input, slowDown, slowDownFactor)); - } - - @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSprinting()Z")) - boolean isSprinting(ClientPlayerEntity entity) { - return EventFlow.post(new MovementEvent.Sprint(entity.isSprinting())).getSprint(); - } - - @Inject(method = "sendMovementPackets", at = @At(value = "HEAD"), cancellable = true) - void sendBegin(CallbackInfo ci) { - ci.cancel(); - PlayerPacketManager.sendPlayerPackets(); - autoJumpEnabled = Lambda.getMc().options.getAutoJump().getValue(); - } - - @Redirect(method = "tickNewAi", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getYaw()F")) - float fixHeldItemYaw(ClientPlayerEntity instance) { - return Objects.requireNonNullElse(RotationManager.getHandYaw(), instance.getYaw()); - } - - @Redirect(method = "tickNewAi", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getPitch()F")) - float fixHeldItemPitch(ClientPlayerEntity instance) { - return Objects.requireNonNullElse(RotationManager.getHandPitch(), instance.getPitch()); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/entity/EntityMixin.java b/common/remappedSrc/com/lambda/mixin/entity/EntityMixin.java deleted file mode 100644 index 88eb86372..000000000 --- a/common/remappedSrc/com/lambda/mixin/entity/EntityMixin.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.lambda.mixin.entity; - -import com.lambda.Lambda; -import com.lambda.interaction.RotationManager; -import com.lambda.util.math.Vec2d; -import net.minecraft.entity.Entity; -import net.minecraft.entity.MovementType; -import net.minecraft.util.math.Vec3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(Entity.class) -public abstract class EntityMixin { - @Shadow - public void move(MovementType movementType, Vec3d movement) { - } - - @Shadow - public abstract float getYaw(); - - @Redirect(method = "updateVelocity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw()F")) - public float velocityYaw(Entity entity) { - if ((Object) this != Lambda.getMc().player) return getYaw(); - - Float y = RotationManager.getMovementYaw(); - if (y == null) return getYaw(); - - return y; - } - - @Redirect(method = "getRotationVec", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw(F)F")) - float fixDirectionYaw(Entity entity, float tickDelta) { - Vec2d rot = RotationManager.getRotationForVector(tickDelta); - if (entity != Lambda.getMc().player || rot == null) return entity.getYaw(tickDelta); - - return (float) rot.getX(); - } - - @Redirect(method = "getRotationVec", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPitch(F)F")) - float fixDirectionPitch(Entity entity, float tickDelta) { - Vec2d rot = RotationManager.getRotationForVector(tickDelta); - if (entity != Lambda.getMc().player || rot == null) return entity.getPitch(tickDelta); - - return (float) rot.getY(); - } - - @Redirect(method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw()F")) - float fixDirectionYaw2(Entity entity) { - Vec2d rot = RotationManager.getRotationForVector(1.0); - if (entity != Lambda.getMc().player || rot == null) return entity.getYaw(); - - return (float) rot.getX(); - } - - @Redirect(method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPitch()F")) - float fixDirectionPitch2(Entity entity) { - Vec2d rot = RotationManager.getRotationForVector(1.0); - if (entity != Lambda.getMc().player || rot == null) return entity.getPitch(); - - return (float) rot.getY(); - } -} \ No newline at end of file diff --git a/common/remappedSrc/com/lambda/mixin/entity/LivingEntityMixin.java b/common/remappedSrc/com/lambda/mixin/entity/LivingEntityMixin.java deleted file mode 100644 index 6be926e8e..000000000 --- a/common/remappedSrc/com/lambda/mixin/entity/LivingEntityMixin.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.lambda.mixin.entity; - -import com.lambda.Lambda; -import com.lambda.event.EventFlow; -import com.lambda.event.events.MovementEvent; -import com.lambda.interaction.RotationManager; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.Slice; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(LivingEntity.class) -public abstract class LivingEntityMixin extends EntityMixin { - - @Shadow - protected abstract float getJumpVelocity(); - - @Inject(method = "jump", at = @At("HEAD"), cancellable = true) - void onJump(CallbackInfo ci) { - LivingEntity self = (LivingEntity) (Object) this; - if (self != Lambda.getMc().player) return; - ci.cancel(); - - float height = this.getJumpVelocity(); - MovementEvent.Jump event = EventFlow.post(new MovementEvent.Jump(height)); - - if (event.isCanceled()) return; - - Vec3d vec3d = self.getVelocity(); - self.setVelocity(vec3d.x, event.getHeight(), vec3d.z); - - if (self.isSprinting()) { - Float yaw = RotationManager.getMovementYaw(); - float f = ((yaw != null) ? yaw : self.getYaw()) * ((float) Math.PI / 180); - self.setVelocity(self.getVelocity().add(-MathHelper.sin(f) * 0.2f, 0.0, MathHelper.cos(f) * 0.2f)); - } - - self.velocityDirty = true; - } - - @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isImmobile()Z")) - void onTravelH(CallbackInfo ci) { - Entity self = (Entity) (Object) this; - if (self != Lambda.getMc().player) return; - - RotationManager.update(); - } - - @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPitch()F")) - private float hookModifyFallFlyingPitch(LivingEntity entity) { - Float pitch = RotationManager.getMovementPitch(); - if (entity != Lambda.getMc().player || pitch == null) return entity.getPitch(); - - return pitch; - } - - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F"), slice = @Slice(to = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F", ordinal = 1))) - private float rotBody(LivingEntity entity) { - if ((Object) this != Lambda.getMc().player) { - return entity.getYaw(); - } - - Float yaw = RotationManager.getRenderYaw(); - return (yaw == null) ? entity.getYaw() : yaw; - } - - @Redirect(method = "turnHead", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F")) - private float rotHead(LivingEntity entity) { - if ((Object) this != Lambda.getMc().player) { - return entity.getYaw(); - } - - Float yaw = RotationManager.getRenderYaw(); - return (yaw == null) ? entity.getYaw() : yaw; - } -} diff --git a/common/remappedSrc/com/lambda/mixin/entity/PlayerEntityMixin.java b/common/remappedSrc/com/lambda/mixin/entity/PlayerEntityMixin.java deleted file mode 100644 index 128bec35a..000000000 --- a/common/remappedSrc/com/lambda/mixin/entity/PlayerEntityMixin.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.lambda.mixin.entity; - -import com.lambda.event.EventFlow; -import com.lambda.event.events.MovementEvent; -import com.lambda.interaction.RotationManager; -import net.minecraft.client.MinecraftClient; -import net.minecraft.entity.player.PlayerEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(PlayerEntity.class) -public class PlayerEntityMixin { - @Inject(method = "clipAtLedge", at = @At(value = "HEAD"), cancellable = true) - private void injectSafeWalk(CallbackInfoReturnable cir) { - MovementEvent.ClipAtLedge event = new MovementEvent.ClipAtLedge(((PlayerEntity) (Object) this).isSneaking()); - cir.setReturnValue(EventFlow.post(event).getClip()); - } - - @Redirect(method = "tickNewAi", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getYaw()F")) - private float injectHeadYaw(PlayerEntity instance) { - if ((Object) this != MinecraftClient.getInstance().player) { - return instance.getYaw(); - } - - Float yaw = RotationManager.getRenderYaw(); - return (yaw != null) ? yaw : instance.getYaw(); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/input/KeyBindingMixin.java b/common/remappedSrc/com/lambda/mixin/input/KeyBindingMixin.java deleted file mode 100644 index 224513f02..000000000 --- a/common/remappedSrc/com/lambda/mixin/input/KeyBindingMixin.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.lambda.mixin.input; - -import com.lambda.module.modules.movement.Speed; -import com.lambda.module.modules.movement.Sprint; -import net.minecraft.client.option.KeyBinding; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.Objects; - -@Mixin(KeyBinding.class) -public class KeyBindingMixin { - @Inject(method = "isPressed", at = @At("HEAD"), cancellable = true) - void autoSprint(CallbackInfoReturnable cir) { - KeyBinding instance = (KeyBinding) (Object) this; - if (!Objects.equals(instance.getTranslationKey(), "key.sprint")) return; - - if (Sprint.INSTANCE.isEnabled()) cir.setReturnValue(true); - if (Speed.INSTANCE.isEnabled() && Speed.getMode() == Speed.Mode.GRIM_STRAFE) cir.setReturnValue(true); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/input/KeyboardMixin.java b/common/remappedSrc/com/lambda/mixin/input/KeyboardMixin.java deleted file mode 100644 index a0672fc3c..000000000 --- a/common/remappedSrc/com/lambda/mixin/input/KeyboardMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.lambda.mixin.input; - -import com.lambda.event.EventFlow; -import com.lambda.event.events.KeyPressEvent; -import net.minecraft.client.Keyboard; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(Keyboard.class) -public class KeyboardMixin { - @Inject(method = "onKey", at = @At("HEAD")) - void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) { - if (key <= 0) return; - if (action != 1) return; - EventFlow.post(new KeyPressEvent(key, scancode, action, modifiers)); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/input/MouseMixin.java b/common/remappedSrc/com/lambda/mixin/input/MouseMixin.java deleted file mode 100644 index 77cdeb238..000000000 --- a/common/remappedSrc/com/lambda/mixin/input/MouseMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.lambda.mixin.input; - -import com.lambda.module.modules.player.Freecam; -import net.minecraft.client.Mouse; -import net.minecraft.client.network.ClientPlayerEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(Mouse.class) -public class MouseMixin { - @Redirect(method = "updateMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;changeLookDirection(DD)V")) - private void updateMouseChangeLookDirection(ClientPlayerEntity player, double cursorDeltaX, double cursorDeltaY) { - if (Freecam.INSTANCE.isEnabled()) { - Freecam.updateRotation(cursorDeltaX, cursorDeltaY); - return; - } - - player.changeLookDirection(cursorDeltaX, cursorDeltaY); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/items/BarrierBlockMixin.java b/common/remappedSrc/com/lambda/mixin/items/BarrierBlockMixin.java deleted file mode 100644 index c416a2b5c..000000000 --- a/common/remappedSrc/com/lambda/mixin/items/BarrierBlockMixin.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.lambda.mixin.items; - -import com.lambda.module.modules.render.BlockESP; -import net.minecraft.block.BarrierBlock; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(BarrierBlock.class) -public class BarrierBlockMixin { - - @Inject(method = "getRenderType", at = @At(value = "RETURN"), cancellable = true) - private void getRenderType(BlockState state, CallbackInfoReturnable cir) { - if (BlockESP.INSTANCE.isEnabled() - && BlockESP.getBarrier() - && state.getBlock() == Blocks.BARRIER - ) cir.setReturnValue(BlockRenderType.MODEL); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/items/TridentMixin.java b/common/remappedSrc/com/lambda/mixin/items/TridentMixin.java deleted file mode 100644 index 7381d70ba..000000000 --- a/common/remappedSrc/com/lambda/mixin/items/TridentMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.lambda.mixin.items; - -import com.lambda.module.modules.movement.TridentBoost; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import net.minecraft.item.TridentItem; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -@Mixin(TridentItem.class) -public class TridentMixin { - // Forge doesn't support the @ModityArgs annotation, so we have to chain multiple @ModifyArg - @ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V"), index = 0) - private double modifyVelocity0(double velocity) { - return TridentBoost.INSTANCE.isEnabled() ? velocity * TridentBoost.getTridentSpeed() : velocity; - } - - @ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V"), index = 1) - private double modifyVelocity1(double velocity) { - return TridentBoost.INSTANCE.isEnabled() ? velocity * TridentBoost.getTridentSpeed() : velocity; - } - - @ModifyArg(method = "onStoppedUsing", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;addVelocity(DDD)V"), index = 2) - private double modifyVelocity2(double velocity) { - return TridentBoost.INSTANCE.isEnabled() ? velocity * TridentBoost.getTridentSpeed() : velocity; - } - - @ModifyExpressionValue(method = {"onStoppedUsing", "use"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isTouchingWaterOrRain()Z")) - private boolean modifyIsTouchingWaterOrRain(boolean original) { - return TridentBoost.INSTANCE.isEnabled() && TridentBoost.getForceUse() || original; - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/BlockRenderManagerMixin.java b/common/remappedSrc/com/lambda/mixin/render/BlockRenderManagerMixin.java deleted file mode 100644 index bda134ec5..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/BlockRenderManagerMixin.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.module.modules.render.BlockESP; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.client.render.block.BlockRenderManager; -import net.minecraft.client.render.model.BakedModel; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(BlockRenderManager.class) -public abstract class BlockRenderManagerMixin { - @Inject(method = "getModel", at = @At("HEAD"), cancellable = true) - private void getModel(BlockState state, CallbackInfoReturnable cir) { - if (BlockESP.INSTANCE.isEnabled() - && BlockESP.getBarrier() - && state.getBlock() == Blocks.BARRIER - ) cir.setReturnValue(BlockESP.getModel()); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/CameraMixin.java b/common/remappedSrc/com/lambda/mixin/render/CameraMixin.java deleted file mode 100644 index 393adc7d6..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/CameraMixin.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.interaction.RotationManager; -import com.lambda.module.modules.player.Freecam; -import com.lambda.module.modules.render.CameraTweaks; -import net.minecraft.client.render.Camera; -import net.minecraft.entity.Entity; -import net.minecraft.world.BlockView; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(Camera.class) -public abstract class CameraMixin { - @Shadow - public abstract void setRotation(float yaw, float pitch); - - @Inject(method = "update", at = @At("TAIL")) - private void onUpdate( - BlockView area, - Entity focusedEntity, - boolean thirdPerson, - boolean inverseView, - float tickDelta, - CallbackInfo ci - ) { - if (!Freecam.INSTANCE.isEnabled()) return; - - Freecam.updateCam(); - } - - @Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V", shift = At.Shift.AFTER)) - private void injectQuickPerspectiveSwap(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) { - var rot = RotationManager.getLockRotation(); - if (rot == null) return; - setRotation(rot.getYawF(), rot.getPitchF()); - } - - @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true) - private void onClipToSpace(double desiredCameraDistance, CallbackInfoReturnable info) { - if (CameraTweaks.INSTANCE.isEnabled() && CameraTweaks.getNoClipCam()) { - info.setReturnValue(desiredCameraDistance); - } - } - - @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;clipToSpace(D)D")) - private double onDistanceUpdate(double desiredCameraDistance) { - if (CameraTweaks.INSTANCE.isEnabled()) { - return CameraTweaks.getCamDistance(); - } - - return desiredCameraDistance; - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/ChatInputSuggestorMixin.java b/common/remappedSrc/com/lambda/mixin/render/ChatInputSuggestorMixin.java deleted file mode 100644 index 3061c1e70..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/ChatInputSuggestorMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.command.CommandManager; -import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.client.gui.screen.ChatInputSuggestor; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.command.CommandSource; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(ChatInputSuggestor.class) -public class ChatInputSuggestorMixin { - - @Shadow - @Final - TextFieldWidget textField; - - @ModifyVariable(method = "refresh", at = @At(value = "STORE"), index = 3) - private boolean refreshModify(boolean showCompletions) { - return CommandManager.INSTANCE.isCommand(textField.getText()); - } - - @Redirect(method = "refresh", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;getCommandDispatcher()Lcom/mojang/brigadier/CommandDispatcher;")) - private CommandDispatcher refreshRedirect(ClientPlayNetworkHandler instance) { - return CommandManager.INSTANCE.currentDispatcher(textField.getText()); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/ChatScreenMixin.java b/common/remappedSrc/com/lambda/mixin/render/ChatScreenMixin.java deleted file mode 100644 index 01a68cf78..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/ChatScreenMixin.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.Lambda; -import com.lambda.command.CommandManager; -import com.lambda.graphics.renderer.gui.font.FontRenderer; -import com.lambda.graphics.renderer.gui.font.LambdaEmoji; -import com.lambda.graphics.renderer.gui.font.glyph.GlyphInfo; -import com.lambda.module.modules.client.LambdaMoji; -import com.lambda.util.math.Vec2d; -import kotlin.Pair; -import kotlin.ranges.IntRange; -import net.minecraft.client.gui.screen.ChatScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Mixin(ChatScreen.class) -public abstract class ChatScreenMixin { - @ModifyArg(method = "sendMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendChatMessage(Ljava/lang/String;)V"), index = 0) - private String modifyChatText(String chatText) { - if (LambdaMoji.INSTANCE.isDisabled()) return chatText; - - List> emojis = FontRenderer.Companion.parseEmojis(chatText, LambdaEmoji.Twemoji); - Collections.reverse(emojis); - - List pushEmojis = new ArrayList<>(); - List pushPositions = new ArrayList<>(); - - for (Pair emoji : emojis) { - String emojiString = chatText.substring(emoji.getSecond().getStart() + 1, emoji.getSecond().getEndInclusive()); - if (LambdaEmoji.Twemoji.get(emojiString) == null) - continue; - - // Because the width of a char is bigger than an emoji - // we can simply replace the matches string by a space - // and render it after the text - chatText = chatText.substring(0, emoji.getSecond().getStart()) + " " + chatText.substring(emoji.getSecond().getEndInclusive() + 1); - - // We cannot retain the position in the future, but we can - // assume that every time you send a message the height of - // the position will change by the height of the glyph - // The positions are from the top left corner of the screen - int x = Lambda.getMc().textRenderer.getWidth(chatText.substring(0, emoji.getSecond().getStart())); - int y = Lambda.getMc().textRenderer.fontHeight; - - pushEmojis.add(String.format(":%s:", emojiString)); - pushPositions.add(new Vec2d(x, y)); - } - - // Not optimal because it has to parse the emoji again but who cares - LambdaMoji.INSTANCE.add(pushEmojis, pushPositions); - - return chatText; - } - - @Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true) - void sendMessageInject(String chatText, boolean addToHistory, CallbackInfoReturnable cir) { - if (!CommandManager.INSTANCE.isLambdaCommand(chatText)) return; - CommandManager.INSTANCE.executeCommand(chatText); - - cir.setReturnValue(true); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/DebugHudMixin.java b/common/remappedSrc/com/lambda/mixin/render/DebugHudMixin.java deleted file mode 100644 index 9c6439c49..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/DebugHudMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.task.RootTask; -import com.lambda.util.DebugInfoHud; -import net.minecraft.client.gui.hud.DebugHud; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.List; - -@Mixin(DebugHud.class) -public class DebugHudMixin { - @Inject(method = "getRightText", at = @At(value = "TAIL")) - private void onGetRightText(CallbackInfoReturnable> cir) { - DebugInfoHud.addDebugInfo(cir.getReturnValue()); - } - - @Inject(method = "getLeftText", at = @At(value = "TAIL")) - private void onGetLeftText(CallbackInfoReturnable> cir) { - RootTask.INSTANCE.addInfo(cir.getReturnValue()); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/GameRendererMixin.java b/common/remappedSrc/com/lambda/mixin/render/GameRendererMixin.java deleted file mode 100644 index 683686ee7..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/GameRendererMixin.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.event.EventFlow; -import com.lambda.event.events.RenderEvent; -import com.lambda.graphics.RenderMain; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.math.MatrixStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(GameRenderer.class) -public class GameRendererMixin { - @Inject(method = "updateTargetedEntity", at = @At("HEAD"), cancellable = true) - private void updateTargetedEntityInvoke(float tickDelta, CallbackInfo info) { - if (EventFlow.post(new RenderEvent.UpdateTarget()).isCanceled()) { - info.cancel(); - } - } - - @Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;render(Lnet/minecraft/client/util/math/MatrixStack;FJZLnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/GameRenderer;Lnet/minecraft/client/render/LightmapTextureManager;Lorg/joml/Matrix4f;)V", shift = At.Shift.AFTER)) - private void onRenderWorld(float tickDelta, long limitTime, MatrixStack matrix, CallbackInfo ci) { - RenderMain.render3D(matrix.peek().getPositionMatrix()); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/GlStateManagerMixin.java b/common/remappedSrc/com/lambda/mixin/render/GlStateManagerMixin.java deleted file mode 100644 index 0b54475a3..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/GlStateManagerMixin.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.graphics.gl.GlStateUtils; -import com.mojang.blaze3d.platform.GlStateManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import static org.lwjgl.opengl.GL11.*; - -@Mixin(GlStateManager.class) -public class GlStateManagerMixin { - @Inject(method = "_enableDepthTest", at = @At("TAIL"), remap = false) - private static void depthTestEnable(CallbackInfo ci) { - GlStateUtils.capSet(GL_DEPTH_TEST, true); - } - - @Inject(method = "_disableDepthTest", at = @At("TAIL"), remap = false) - private static void depthTestDisable(CallbackInfo ci) { - GlStateUtils.capSet(GL_DEPTH_TEST, false); - } - - @Inject(method = "_depthMask", at = @At("TAIL"), remap = false) - private static void depthMask(boolean mask, CallbackInfo ci) { - GlStateUtils.capSet(GL_DEPTH, mask); - } - - @Inject(method = "_enableBlend", at = @At("TAIL"), remap = false) - private static void blendEnable(CallbackInfo ci) { - GlStateUtils.capSet(GL_BLEND, true); - } - - @Inject(method = "_disableBlend", at = @At("TAIL"), remap = false) - private static void blendDisable(CallbackInfo ci) { - GlStateUtils.capSet(GL_BLEND, false); - } - - @Inject(method = "_enableCull", at = @At("TAIL"), remap = false) - private static void cullEnable(CallbackInfo ci) { - GlStateUtils.capSet(GL_CULL_FACE, true); - } - - @Inject(method = "_disableCull", at = @At("TAIL"), remap = false) - private static void cullDisable(CallbackInfo ci) { - GlStateUtils.capSet(GL_CULL_FACE, false); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/InGameHudMixin.java b/common/remappedSrc/com/lambda/mixin/render/InGameHudMixin.java deleted file mode 100644 index f98c97947..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/InGameHudMixin.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.graphics.RenderMain; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.hud.InGameHud; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(InGameHud.class) -public class InGameHudMixin { - @Inject(method = "render", at = @At("TAIL")) - private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) { - RenderMain.render2D(); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/InGameOverlayRendererMixin.java b/common/remappedSrc/com/lambda/mixin/render/InGameOverlayRendererMixin.java deleted file mode 100644 index 54b9a578c..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/InGameOverlayRendererMixin.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.module.modules.render.NoRender; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.hud.InGameOverlayRenderer; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.util.math.MatrixStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(InGameOverlayRenderer.class) -public class InGameOverlayRendererMixin { - @Inject(method = "renderFireOverlay", at = @At("HEAD"), cancellable = true) - private static void onRenderFireOverlay( - MinecraftClient mc, - MatrixStack matrixStack, - CallbackInfo ci - ) { - if (NoRender.INSTANCE.isEnabled() && NoRender.getNoBurning()) ci.cancel(); - } - - @ModifyArg(method = "renderFireOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;translate(FFF)V"), index = 1) - private static float onRenderFireOverlayTranslate(float x) { - if (NoRender.INSTANCE.isEnabled()) { - return (float) NoRender.getFireOverlayYOffset(); - } else { - return -0.3f; - } - } - - @Inject(method = "renderUnderwaterOverlay", at = @At("HEAD"), cancellable = true) - private static void onRenderUnderwaterOverlay( - MinecraftClient mc, - MatrixStack matrixStack, - CallbackInfo ci - ) { - if (NoRender.INSTANCE.isEnabled() && NoRender.getNoUnderwater()) ci.cancel(); - } - - @Inject(method = "renderInWallOverlay", at = @At("HEAD"), cancellable = true) - private static void onRenderInWallOverlay( - Sprite sprite, - MatrixStack matrices, - CallbackInfo ci - ) { - if (NoRender.INSTANCE.isEnabled() && NoRender.getNoInWall()) ci.cancel(); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/LightmapTextureManagerMixin.java b/common/remappedSrc/com/lambda/mixin/render/LightmapTextureManagerMixin.java deleted file mode 100644 index f2bb2c6d3..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/LightmapTextureManagerMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.module.modules.render.Fullbright; -import com.lambda.module.modules.render.NoRender; -import com.lambda.module.modules.render.XRay; -import net.minecraft.client.render.LightmapTextureManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(LightmapTextureManager.class) -public class LightmapTextureManagerMixin { - @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/NativeImage;setColor(III)V"), index = 2) - private int updateModify(int color) { - if (Fullbright.INSTANCE.isEnabled() || XRay.INSTANCE.isEnabled()) { - return 0xFFFFFFFF; - } - return color; - } - - @Inject(method = "getDarknessFactor(F)F", at = @At("HEAD"), cancellable = true) - private void getDarknessFactor(float tickDelta, CallbackInfoReturnable info) { - if (NoRender.getNoDarkness()) info.setReturnValue(0.0f); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/LivingEntityRendererMixin.java b/common/remappedSrc/com/lambda/mixin/render/LivingEntityRendererMixin.java deleted file mode 100644 index 5de183ea1..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/LivingEntityRendererMixin.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.Lambda; -import com.lambda.interaction.RotationManager; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.LivingEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.LivingEntity; -import net.minecraft.util.math.MathHelper; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.Objects; - -@Mixin(LivingEntityRenderer.class) -public class LivingEntityRendererMixin { - @Unique - private Float lambda$pitch = null; - - @Inject(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) - private void injectRender(T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { - Float rotationPitch = RotationManager.getRenderPitch(); - - this.lambda$pitch = null; - - if (livingEntity != Lambda.getMc().player || rotationPitch == null) { - return; - } - - this.lambda$pitch = rotationPitch; - } - - @Redirect(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;lerp(FFF)F", ordinal = 0)) - private float injectRotationPitch(float g, float f, float s) { - return Objects.requireNonNullElseGet(lambda$pitch, () -> MathHelper.lerp(g, f, s)); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/RenderLayersMixin.java b/common/remappedSrc/com/lambda/mixin/render/RenderLayersMixin.java deleted file mode 100644 index 65ed53939..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/RenderLayersMixin.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.module.modules.render.XRay; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.RenderLayers; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(RenderLayers.class) -public class RenderLayersMixin { - @Inject(method = "getBlockLayer", at = @At("HEAD"), cancellable = true) - private static void onGetBlockLayer(BlockState state, CallbackInfoReturnable cir) { - if (XRay.INSTANCE.isDisabled()) return; - - if (!XRay.isSelected(state)) cir.setReturnValue(RenderLayer.getTranslucent()); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/RenderTickCounterMixin.java b/common/remappedSrc/com/lambda/mixin/render/RenderTickCounterMixin.java deleted file mode 100644 index dd0f62f6e..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/RenderTickCounterMixin.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.core.TimerManager; -import net.minecraft.client.render.RenderTickCounter; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(RenderTickCounter.class) -public class RenderTickCounterMixin { - - @Shadow - public float lastFrameDuration; - @Shadow - public float tickDelta; - @Shadow - private long prevTimeMillis; - - @Inject(method = "beginRenderTick", at = @At("HEAD"), cancellable = true) - private void beginRenderTick(long timeMillis, CallbackInfoReturnable ci) { - lastFrameDuration = (timeMillis - prevTimeMillis) / TimerManager.getTickLength(); - prevTimeMillis = timeMillis; - tickDelta += lastFrameDuration; - int i = (int) tickDelta; - tickDelta -= i; - - ci.setReturnValue(i); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/ScreenHandlerMixin.java b/common/remappedSrc/com/lambda/mixin/render/ScreenHandlerMixin.java deleted file mode 100644 index 9f816cfbb..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/ScreenHandlerMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.event.EventFlow; -import com.lambda.event.events.ScreenEvent; -import com.lambda.event.events.ScreenHandlerEvent; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.ScreenHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; - -@Mixin(ScreenHandler.class) -public class ScreenHandlerMixin { - @Inject(method = "updateSlotStacks", at = @At("TAIL")) - private void onUpdateSlotStacksHead(int revision, List stacks, ItemStack cursorStack, CallbackInfo ci) { - EventFlow.post(new ScreenHandlerEvent.Loaded(revision, stacks, cursorStack)); - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/VertexBufferMixin.java b/common/remappedSrc/com/lambda/mixin/render/VertexBufferMixin.java deleted file mode 100644 index 6c3584660..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/VertexBufferMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.graphics.gl.VaoUtils; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.gl.VertexBuffer; -import net.minecraft.client.render.BufferBuilder; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.nio.ByteBuffer; - -@Mixin(VertexBuffer.class) -public class VertexBufferMixin { - @Shadow - private int indexBufferId; - - @Inject(method = "uploadIndexBuffer", at = @At("RETURN")) - private void onConfigureIndexBuffer(BufferBuilder.DrawParameters parameters, ByteBuffer vertexBuffer, CallbackInfoReturnable cir) { - RenderSystem.ShapeIndexBuffer value = cir.getReturnValue(); - VaoUtils.lastIbo = value == null ? this.indexBufferId : value.id; - } -} diff --git a/common/remappedSrc/com/lambda/mixin/render/WorldRendererMixin.java b/common/remappedSrc/com/lambda/mixin/render/WorldRendererMixin.java deleted file mode 100644 index e95ee1303..000000000 --- a/common/remappedSrc/com/lambda/mixin/render/WorldRendererMixin.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.module.modules.player.Freecam; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.WorldRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(WorldRenderer.class) -public class WorldRendererMixin { - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;isThirdPerson()Z")) - private boolean renderIsThirdPerson(Camera camera) { - return Freecam.INSTANCE.isEnabled() || camera.isThirdPerson(); - } - - @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;setupTerrain(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/Frustum;ZZ)V"), index = 3) - private boolean renderSetupTerrainModifyArg(boolean spectator) { - return Freecam.INSTANCE.isEnabled() || spectator; - } -} diff --git a/common/remappedSrc/com/lambda/mixin/world/ClientChunkManagerMixin.java b/common/remappedSrc/com/lambda/mixin/world/ClientChunkManagerMixin.java deleted file mode 100644 index a2845184e..000000000 --- a/common/remappedSrc/com/lambda/mixin/world/ClientChunkManagerMixin.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.lambda.mixin.world; - -import com.lambda.event.EventFlow; -import com.lambda.event.events.WorldEvent; -import net.minecraft.client.world.ClientChunkManager; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.packet.s2c.play.ChunkData; -import net.minecraft.util.math.ChunkPos; -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.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import java.util.function.Consumer; - -@Mixin(ClientChunkManager.class) -public class ClientChunkManagerMixin { - @Final - @Shadow - ClientWorld world; - - @Inject(method = "loadChunkFromPacket", at = @At("TAIL")) - private void onChunkLoad( - int x, - int z, - PacketByteBuf packetByteBuf, - NbtCompound nbtCompound, - Consumer consumer, - CallbackInfoReturnable info - ) { - EventFlow.post(new WorldEvent.ChunkEvent.Load(this.world, info.getReturnValue())); - } - - @Inject(method = "loadChunkFromPacket", at = @At(value = "NEW", target = "net/minecraft/world/chunk/WorldChunk", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) - private void onChunkUnload( - int x, - int z, - PacketByteBuf buf, - NbtCompound tag, - Consumer consumer, - CallbackInfoReturnable info, - int index, - WorldChunk chunk, - ChunkPos chunkPos - ) { - if (chunk != null) { - EventFlow.post(new WorldEvent.ChunkEvent.Unload(this.world, chunk)); - } - } - - @Inject(method = "unload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientChunkManager$ClientChunkMap;compareAndSet(ILnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/WorldChunk;)Lnet/minecraft/world/chunk/WorldChunk;"), locals = LocalCapture.CAPTURE_FAILHARD) - private void onChunkUnload(ChunkPos pos, CallbackInfo ci, int i, WorldChunk chunk) { - EventFlow.post(new WorldEvent.ChunkEvent.Unload(this.world, chunk)); - } - -// @Inject( -// method = "updateLoadDistance", -// at = @At( -// value = "INVOKE", -// target = "net/minecraft/client/world/ClientChunkManager$ClientChunkMap.isInRadius(II)Z" -// ), -// locals = LocalCapture.CAPTURE_FAILHARD -// ) -// private void onUpdateLoadDistance( -// int loadDistance, -// CallbackInfo ci, -// int oldRadius, -// int newRadius, -// ClientChunkManager.ClientChunkMap clientChunkMap, -// int k, -// WorldChunk oldChunk, -// ChunkPos chunkPos -// ) { -// if (!clientChunkMap.isInRadius(chunkPos.x, chunkPos.z)) { -// EventFlow.post(new WorldEvent.ChunkEvent.Unload(this.world, oldChunk)); -// } -// } -} diff --git a/common/remappedSrc/com/lambda/mixin/world/ClientWorldMixin.java b/common/remappedSrc/com/lambda/mixin/world/ClientWorldMixin.java deleted file mode 100644 index af12440bc..000000000 --- a/common/remappedSrc/com/lambda/mixin/world/ClientWorldMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.lambda.mixin.world; - -import com.lambda.event.EventFlow; -import com.lambda.event.events.WorldEvent; -import net.minecraft.block.BlockState; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(ClientWorld.class) -public class ClientWorldMixin { - @Inject(method = "handleBlockUpdate", at = @At("HEAD"), cancellable = true) - private void handleBlockUpdateInject(BlockPos pos, BlockState state, int flags, CallbackInfo ci) { - if (EventFlow.post(new WorldEvent.BlockUpdate(pos, state, flags)).isCanceled()) { - ci.cancel(); - } - } - - @Inject(method = "addEntity", at = @At("HEAD"), cancellable = true) - private void addEntity(Entity entity, CallbackInfo ci) { - if (EventFlow.post(new WorldEvent.EntitySpawn(entity)).isCanceled()) ci.cancel(); - } -} \ No newline at end of file