|
| 1 | +package smilerryan.ryanware.mixins; |
| 2 | + |
| 3 | +import com.mojang.blaze3d.pipeline.RenderPipeline; |
| 4 | +import meteordevelopment.meteorclient.systems.modules.Modules; |
| 5 | +import net.minecraft.client.MinecraftClient; |
| 6 | +import net.minecraft.client.gui.DrawContext; |
| 7 | +import net.minecraft.client.gui.hud.bar.LocatorBar; |
| 8 | +import net.minecraft.client.resource.waypoint.WaypointStyleAsset; |
| 9 | +import net.minecraft.entity.Entity; |
| 10 | +import net.minecraft.util.Identifier; |
| 11 | +import net.minecraft.util.math.MathHelper; |
| 12 | +import net.minecraft.world.World; |
| 13 | +import net.minecraft.world.waypoint.EntityTickProgress; |
| 14 | +import net.minecraft.world.waypoint.TrackedWaypoint; |
| 15 | +import org.spongepowered.asm.mixin.Final; |
| 16 | +import org.spongepowered.asm.mixin.Mixin; |
| 17 | +import org.spongepowered.asm.mixin.Shadow; |
| 18 | +import org.spongepowered.asm.mixin.Unique; |
| 19 | +import org.spongepowered.asm.mixin.injection.At; |
| 20 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 21 | +import org.spongepowered.asm.mixin.injection.Redirect; |
| 22 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 23 | +import smilerryan.ryanware.modules_standard.Settings; |
| 24 | + |
| 25 | +@Mixin(LocatorBar.class) |
| 26 | +public class MixinLocatorBarRenderer { |
| 27 | + @Shadow @Final private MinecraftClient client; |
| 28 | + @Unique private Identifier blitOverride; |
| 29 | + @Unique private TrackedWaypoint waypoint; |
| 30 | + |
| 31 | + @Inject(method = "method_70870", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/util/Identifier;IIIII)V", shift = At.Shift.BEFORE)) |
| 32 | + private void injectRender(Entity entity, World world, EntityTickProgress tickProgress, DrawContext context, int i, TrackedWaypoint trackedWaypoint, CallbackInfo ci) { |
| 33 | + this.waypoint = trackedWaypoint; |
| 34 | + this.blitOverride = null; |
| 35 | + if (Modules.get().get(Settings.class).s_WaypointHeads.get()) { |
| 36 | + var connection = MinecraftClient.getInstance().getNetworkHandler(); |
| 37 | + if (connection != null && trackedWaypoint.getSource().left().isPresent()) { |
| 38 | + var info = connection.getPlayerListEntry(trackedWaypoint.getSource().left().get()); |
| 39 | + if (info != null) { |
| 40 | + this.blitOverride = info.getSkinTextures().body().texturePath(); |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + @Redirect(method = "method_70870", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/util/Identifier;IIIII)V")) |
| 47 | + private void redirectBlit(DrawContext instance, RenderPipeline renderPipeline, Identifier resourceLocation, int i, int j, int k, int l, int m) { |
| 48 | + if (this.blitOverride == null) { |
| 49 | + instance.drawGuiTexture(renderPipeline, resourceLocation, i, j, k, l, m); |
| 50 | + } else { |
| 51 | + float distance = MathHelper.sqrt((float)this.waypoint.squaredDistanceTo(this.client.getCameraEntity())); |
| 52 | + float progress = 1 - MathHelper.clamp((distance - WaypointStyleAsset.DEFAULT_NEAR_DISTANCE) / (WaypointStyleAsset.DEFAULT_FAR_DISTANCE - WaypointStyleAsset.DEFAULT_NEAR_DISTANCE), 0, 1); |
| 53 | + k = MathHelper.lerp(progress, 5, Math.max(k, 5)); |
| 54 | + l = MathHelper.lerp(progress, 5, Math.max(l, 5)); |
| 55 | + instance.drawTexturedQuad(this.blitOverride, i, j, i + k, j + l, 8f / 64, 16f / 64, 8f / 64, 16f / 64); |
| 56 | + instance.drawTexturedQuad(this.blitOverride, i, j, i + k, j + l, 40f / 64, 48f / 64, 8f / 64, 16f / 64); |
| 57 | + } |
| 58 | + this.blitOverride = null; |
| 59 | + } |
| 60 | +} |
0 commit comments